Skip to content

Latest commit

 

History

History
187 lines (176 loc) · 6.5 KB

MAPPROXY.md

File metadata and controls

187 lines (176 loc) · 6.5 KB

INAV Configurator MapProxy setup

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

Generic MapProxy Installation Guides

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)

Linux MapProxy virtual machine setup instructions

  1. 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

  2. Use NAT networking so that the virtual machine can download maps while online

  3. Create a mapproxy user (this can be done during installation)

  4. All commands executed as mapproxy user from mapproxy user home directory

  5. Choose defaults for everything else unless you want to change anything

  6. After installation, update all packages and reboot

    sudo apt-get update && sudo apt-get upgrade && sudo reboot
  7. 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
  8. Install ssh server so you can connect from host

    sudo apt-get -y install openssh-server
  9. Connect to virtual machine ssh using mapproxy@192.168.145.20

  10. 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
  11. Update pillow and install mapproxy

    sudo pip install pillow 
    sudo pip install MapProxy
  12. 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
  13. 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>
  14. 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')
  15. Enable wsgi and restart apache

    sudo a2enmod wsgi
    sudo service apache2 restart
  16. Test your MapProxy instance using web browser on host, you should see a demo link http://192.168.145.20/inavmapproxy/

  17. Open iNav Configurator, connect to your flight controller

  18. In upper right corner click on Application Options (gears icon)

  19. For MapProxy URL use: http://192.168.145.20/inavmapproxy/service?

  20. For MapProxy layer use: osm

  21. If everything is working you should see a map in the GPS and Mission Planner tabs

  22. 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
  23. 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
  24. 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