MapProxy install and quick start guide

1. Installing MapProxy and dependecies

  1. Install python-is-pyhton3:

~$ sudo apt install python-is-python3

check it:

~$ python -V

  1. Install MapProxy through pip

~$ sudo pip install MapProxy

  1. Install VirtualEnv

~$ sudo apt install python3-virtualenv

  1. Create a new virtual environment

~$ virtualenv --system-site-packages mapproxy

  1. Activate virtual environment (optional?)

~$ source mapproxy/bin/activate

  1. Install dependencies

~$ sudo apt-get install python3-pil python3-yaml libproj12

libproj12 -> libproj19??

optional packages:

~$ sudo apt-get install libgeos-dev python3-lxml libgdal-dev python3-shapely

2. Config

  1. Create a configuration:

~$ mapproxy-util create -t base-config mymapproxy

  1. Edit ~/mymapproxy/mapproxy.yaml:

don't forger to replace with your user name!

mapproxy.yaml:

services:
  demo:
  tms:
    use_grid_names: true
    # origin for /tiles service
    origin: 'nw'
  kml:
      use_grid_names: true
  wmts:

  wms:
    srs: ['EPSG:4326','EPSG:3857', 'EPSG:32637']
    md:
      title: MapProxy WMS Proxy
      abstract: This is a minimal MapProxy example.

layers:
  - name: osm
    title: Omniscale OSM WMS - osm.omniscale.net
    sources: [osm_cache]
  - name: myosm
    title: local osm mapnik
    sources: [mapnik_cache]
  - name: myosm_nocache
    title: osm_mapnik no chache
    sources: [mapnik_naspc]

caches:
  osm_cache:
    grids: [webmercator, EPSG32637]
    sources: [osm_wms]
    cache:
        type: file
        tile_lock_dir: /home/<username>/mymapproxy/cache_data
  mapnik_cache:
    grids: [webmercator, EPSG32637, testmercator]
    sources: [mapnik_naspc]
    cache:
        type: file
        tile_lock_dir: /home/<username>/mymapproxy/cache_data

sources:
  osm_wms:
    type: wms
    req:
      url: https://maps.omniscale.net/v2/demo/style.default/service?
      layers: osm
  mapnik_naspc:
    type: mapnik
    mapfile: /home/<username>/src/openstreetmap-carto/mapnik_mp.xml
    use_mapnik2: true

grids:
    webmercator:
        base: GLOBAL_WEBMERCATOR
    testmercator:
        base: GLOBAL_MERCATOR
        origin: sw
    EPSG32637:
        srs: 'EPSG:32637'
        bbox: [200000, 6000000, 600000, 6400000]
        bbox_srs: 'EPSG:32637'
        num_levels: 21
        stretch_factor: 1.25
        origin: sw

globals:

Mapnik_mp.xml: link

3. Start Test Server

~$ cd mymapproxy

...$ mapproxy-util serve-develop mapproxy.yaml

4. Access rights

mkdir /home/<user>/mymapproxy/cache_data/

chmod -R 777 /home/<user>/mapproxy/cache_data/

chmod -R 777 /home/<user>/mymapproxy/cache_data/

5. apache2 WSGI

Create role <user>

sudo -i -u postgres

psql -d <osm_db_name>

CREATE USER <user>;
GRANT ALL PRIVILEGES ON DATABASE "<osm_db_name>" to <user>;
GRANT ALL ON ALL TABLES IN SCHEMA public TO <user>;

Install mod-wsgi:

sudo apt install libapache2-mod-wsgi-py3

Create mapproxy config:

mapproxy-util create -t wsgi-app -f mapproxy.yaml config.py

Create apache2 config:

/etc/apache2/conf-enabled/mapproxy.conf:

# if not loaded elsewhere
LoadModule wsgi_module modules/mod_wsgi.so

WSGIScriptAlias / /home/<user>/mapproxy/config.py

WSGIDaemonProcess mapproxy user=<user> group=<user> processes=4 threads=8
WSGIProcessGroup mapproxy
# WSGIPythonHome should contain the bin and lib dir of your virtualenv
WSGIPythonHome /home/<user>/mapproxy/
WSGIApplicationGroup %{GLOBAL}

<Directory /home/<user>/mapproxy/>
  Order deny,allow
  Require all granted
#  Allow from all
</Directory>

6. Configure FRPS

See post: Configure FRPS

See also

MapProxy config: https://mapproxy.org/docs/nightly/sources.html#mapnik


Создано: 16/02/2023 08:07, Изменено: 19/05/2023 17:45, Просмотров: 208
Назад