There are several different approaches to setting up MapProxy service. All that iNav needs is a working MapProxy WMS URL and the name of the layer that you want to use for caching
https://mapproxy.org/docs/latest/install.html Unix Install Guide
https://mapproxy.org/docs/latest/install_windows.html Windows Install Guide
https://hub.docker.com/r/yagajs/mapproxy/ Docker image (untested)
-
Using virtualization platform of your choice, install a base 14.04 LTS Ubuntu server http://releases.ubuntu.com/14.04/ubuntu-14.04.5-server-i386.iso
-
Use NAT networking so that the virtual machine can download maps while online
-
Create a mapproxy user (this can be done during installation)
-
All commands executed as mapproxy user from mapproxy user home directory
-
Choose defaults for everything else unless you want to change anything
-
After installation, update all packages and reboot
sudo apt-get update && sudo apt-get upgrade && sudo reboot
-
Set a static IP so that your iNav proxy URL does not need to be updated
# get dhcp ip address and host gateway mapproxy@MapProxy:~$ ip route get 8.8.8.8 | awk '{print $NF; exit}' 192.168.145.133 mapproxy@MapProxy:~$ cat /etc/resolv.conf | tail -n 1 nameserver 192.168.145.2 mapproxy@MapProxy:~$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.145.2 0.0.0.0 UG 0 0 0 eth0 192.168.145.0 * 255.255.255.0 U 0 0 0 eth0 mapproxy@MapProxy:~$ sudo vi /etc/network/interfaces # replace existing eth0 section with this: auto eth0 iface eth0 inet static address 192.168.145.20 netmask 255.255.255.0 network 192.168.145.0 broadcast 192.168.145.255 gateway 192.168.145.2 dns-nameservers 192.168.145.2 # reboot to apply changes mapproxy@MapProxy:~$ sudo reboot
-
Install ssh server so you can connect from host
sudo apt-get -y install openssh-server
-
Connect to virtual machine ssh using mapproxy@192.168.145.20
-
Install python-virtualenv and dependencies
sudo apt install python-virtualenv python-imaging python-yaml libproj0 \ build-essential python-dev libjpeg-dev \ zlib1g-dev libfreetype6-dev libapache2-mod-wsgi apache2
-
Update pillow and install mapproxy
sudo pip install pillow sudo pip install MapProxy
-
Initialize MapProxy server
# check that mapproxy is installed mapproxy-util --version # create inav config mapproxy-util create -t base-config inavmapproxy virtualenv --system-site-packages mapproxy source mapproxy/bin/activate
-
Update apache wsgi.conf
sudo vi /etc/apache2/mods-available/wsgi.conf
so it looks like this:
WSGIScriptAlias /inavmapproxy /home/mapproxy/inavmapproxy/config.py WSGIDaemonProcess mapproxy user=mapproxy group=mapproxy processes=8 threads=25 WSGIProcessGroup mapproxy # WSGIPythonHome should contain the bin and lib dir of your virtualenv WSGIPythonHome /home/mapproxy/mapproxy WSGIApplicationGroup %{GLOBAL} <Directory /home/mapproxy/inavmapproxy/> Order deny,allow Require all granted </Directory>
-
Create wsgi config file
vi inavmapproxy/config.py
with the following content:
from mapproxy.wsgiapp import make_wsgi_app application = make_wsgi_app(r'/home/mapproxy/inavmapproxy/mapproxy.yaml')
-
Enable wsgi and restart apache
sudo a2enmod wsgi sudo service apache2 restart
-
Test your MapProxy instance using web browser on host, you should see a demo link http://192.168.145.20/inavmapproxy/
-
Open iNav Configurator, connect to your flight controller
-
In upper right corner click on Application Options (gears icon)
-
For MapProxy URL use: http://192.168.145.20/inavmapproxy/service?
-
For MapProxy layer use: osm
-
If everything is working you should see a map in the GPS and Mission Planner tabs
-
You can change your server configuration by editing
mapproxy@MapProxy:~$ vi ~/inavmapproxy/mapproxy.yaml
After editing configuration, restart apache
mapproxy@MapProxy:~$ sudo /etc/init.d/apache2 restart
-
Some additional sample configurations, use at your own discretion (change layer in inav to layer from configuration)
# mundialis openstreetmap wms example services: demo: wms: md: title: MapProxy WMS Proxy layers: - name: osm title: mundialis sources: [osm_cache] caches: osm_cache: grids: [webmercator] sources: [osm_wms] sources: osm_wms: type: wms req: url: http://ows.mundialis.de/services/service? layers: osm grids: webmercator: base: GLOBAL_WEBMERCATOR
# google maps hybrid example, use inav_layer in configurator as layer name services: demo: wms: md: title: MapProxy WMS Proxy layers: - name: inav_layer title: Google Maps Hybrid sources: [inav_cache] caches: inav_cache: grids: [inav_grid] sources: [inav] cache: type: file directory_layout: tms sources: inav: type: tile url: http://mt0.google.com/vt/lyrs=y&hl=en&x=%(x)s&y=%(y)s&z=%(z)s grid: inav_grid grids: inav_grid: base: GLOBAL_MERCATOR origin: ul
-
You can use any map provider that is compatible with MapProxy, and once you zoom in on the region you will be flying in, the map tiles will be cached for offline use. You can test this by disabling your internet connection and browsing the demo url in a browser
https://wiki.openstreetmap.org/wiki/WMS#OSM_WMS_Servers OpenStreetMap WSM servers
https://lpdaac.usgs.gov/data_access/web_map_services_wms # USGS currently has 400+ WMS layers
-
You can use QGIS to browse different provieders and pick the maps you like for your iNav layers https://qgis.org/en/site/
-
There are many government and public wms providers available in different regions worldwide
-