Explorar o código

TerrainGen: Faster gen for ocean tiles

Stephen Dade %!s(int64=5) %!d(string=hai) anos
pai
achega
f4851c27e7
Modificáronse 1 ficheiros con 8 adicións e 2 borrados
  1. 8 2
      terrain_gen.py

+ 8 - 2
terrain_gen.py

@@ -6,6 +6,8 @@ create ardupilot terrain database files
 import math, struct, os
 import crc16, time, struct
 
+from MAVProxy.modules.mavproxy_map import srtm
+
 # MAVLink sends 4x4 grids
 TERRAIN_GRID_MAVLINK_SIZE = 4
 
@@ -262,8 +264,12 @@ def create_degree(downloader, lat, lon, folder, grid_spacing):
                     if waited:
                         print("downloaded %d,%d" % (lat2_int, lon2_int))
                     tiles[tile_idx] = tile
-                altitude = tiles[tile_idx].getAltitudeFromLatLon(lat_e7*1.0e-7, lon_e7*1.0e-7)
-                grid.fill(gx, gy, altitude)
+                if isinstance(tile, srtm.SRTMOceanTile):
+                    # if it's a blank ocean tile, there's a quicker way to generate the tile
+                    grid.fill(gx, gy, 0)
+                else:
+                    altitude = tiles[tile_idx].getAltitudeFromLatLon(lat_e7*1.0e-7, lon_e7*1.0e-7)
+                    grid.fill(gx, gy, altitude)
         dfile.write(grid)
 
 def makeTerrain(downloader, radius, lat, lon, spacing, uuid, folder):