Stephen Dade 5 роки тому
батько
коміт
4b58ae70a4
2 змінених файлів з 41 додано та 2 видалено
  1. 12 2
      README.md
  2. 29 0
      offline_gen.py

+ 12 - 2
README.md

@@ -3,10 +3,18 @@
 ## Summary
 
 This is a website that pre-generates terrain files for Ardupilot. The user enters in the details
-of the area they wish the generate terrain for, then the website will download (if not already cached)
-the raw terrain from ardupilot.org and process it. The user will end up with a terrain.zip that they
+of the area they wish the generate terrain for, then the website will generate a terrain.zip file containing
+the relevant dat files. The user will download this file and then
 then need to unzip to a "terrain" folder on the SD card in their flight controller.
 
+## Pre-generation of Terrain
+
+To ensure the website operates responsively, the terrain for the whole (-60 -> +60 latitude) world
+must be pregenerated. This will take some time.
+
+Run ``offline_gen.py`` to download the SRTM files from ardupilot.org and convert them to the dat
+file format. These files will be stored in the processedTerrain folder.
+
 ## For developers
 
 This website uses the flask library.
@@ -40,3 +48,5 @@ Use gunicorn for deployment:
 ``pip install gunicorn``
 
 ``gunicorn app:app``
+
+

+ 29 - 0
offline_gen.py

@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+'''
+Generation of all dat files at 100m spacing.
+Preprocessing so the website doesn't have to
+
+This will take a long time to process!
+'''
+import os
+
+from MAVProxy.modules.mavproxy_map import srtm
+from terrain_gen import create_degree
+
+downloader = srtm.SRTMDownloader(debug=False, cachedir='./srtmcache')
+downloader.loadFileList()
+
+if __name__ == '__main__':
+
+    targetFolder = os.path.join(os.getcwd(), "processedTerrain")
+    #create folder if required
+    try:
+        os.mkdir(targetFolder)
+    except FileExistsError:
+        pass
+
+    # Loop over the SRTM range - -60->60 latitude and all longitudes
+    for long in range(-180, 180):
+        for lat in range (-60, 60):
+            create_degree(downloader, lat, long, targetFolder, 100)
+