I've built a mobile mapping device for my Search & Rescue group using a Raspberry Pi (3b+) and its primary purpose is to serve a cache of XYZ tiles via its web server, over its WiFi network. The device is powered using a vehicle's 12V power outlet. Our SAR group uses a number of mapping applications that understand the XYZ tile format. We are regularly outside cell service and satellite internet is problematic, so the goal is to take data with us when we head out on a call.
As a bonus feature I've added the ability to export a georeferenced PDF of any area, with the PDFs content built from the relevant XYZ tiles using GDAL. This works OK but it's slow and I'm wondering if I can remove any of the more expensive steps from the transformation.
The current steps are:
- identify all XYZ tiles at a given zoom level that intersect the caller's lat/long bounding box (this is fast)
- call GDAL Transform for every XYZ tile, converting it to a .tif with its
outputBoundsset to the correct bounding box. This can mean several thousand calls to Transform and this part is very slow
- call GDAL Warp to merge all Transformed .tif tiles into a single .tif (relying on the newly-added georeferencing data from step 2)
- call GDAL Transform to convert the merged .tif to a PDF
I'm already using the Pi's "overlay file system", which I believe writes exclusively to memory / swap space - it's effectively a temporary file system where all changes are lost on reboot - and this made the export significantly faster. This also helps to mitigate the risk of storage corruption as the power supply is regularly interrupted.
It seems like there should be a way to remove step 2, where hundreds or thousands of tiles are individually georeferenced before being merged, but this would require some way of telling GDAL a) the overall bounds of the combined XYZ tiles and b) the order in which the XYZ tiles should be assembled, because without georeferencing we don't know where each tile belongs in the world.
Can anyone suggest a way to make this process more efficient?