MapProxy

From OpenStreetMap Wiki
(Redirected from Mappproxy setup)
Jump to: navigation, search

MapProxy (mapproxy.org) is an open source geospatial tile proxy that supports reprojection. Initially developed by Omniscale

Mapproxy is a python proxy server for geospatial images. It can read data from WMS, tiles, mapserver and mapnik, and cache and serve that data as WMS, WMTS,TMS and KML. It can also do reprojections between different coordinate reference systems

MapProxy setup for serving OSM

Note on reprojecting of tiles from a TMS source like OpenStreetMap's tile server, is a tricky business and might yield strange results. It is really usefull if you want to use open streetmap data as background layer in your own (desktop or web) application and can't use the openstreetmap.org data directly either because

  • you need it as wms (which is hard to come by for osm), or
  • you usually use the same general area (country, city, province) and use it intensively, so local caching saves a bunch of load for the openstreetmap servers, and gives you better performance

Installing

To install MapProxy, just follow their installation documentation which is pretty straight forward (if you have some Python skill). It will be totally straightforward without skill for Ubuntu or any Debian user who will notice, download and click the hidden http://mapproxy.org/static/rel/ mapproxy_1.X.0_all.deb files, making a usual Python installation, and skip to Create a configuration or use the following procedure.
Once you followed that and have a demo version working on http://localhost:8080/demo/, continue with the following:

All you need now is the following mapproxy.yaml file and put it in place of the existing one in your "mymapproxy" folder that you created in the installation documentation.

mapproxy.yaml file for OSM tiles

The meaning of the mapproxy.yaml directives are explained using comments in the file itself. For further information, refer to the Configuration Documentation

services:
  #sets up how to make the source data available
  demo:
  tms:
  wms:
    #srs sets the coordinate reference systems as which you want to make your data available. MapProxy reprojects the source data very well to these projections.
    srs: ['EPSG:900913','EPSG:3857']
    image_formats: ['image/jpeg', 'image/png']
    md:
      # metadata used in capabilities documents
      title: MapProxy WMS Proxy
      abstract: This is the fantastic MapProxy.
      online_resource: http://mapproxy.org/
      contact:
        person: Your Name
        position: Technical Director
        organization: Some Company
        address: Long street
        city: Timbuktu
        postcode: 123456AD
        country: South Pole
        email: info@example.com
      access_constraints:
        This service is intended for private and evaluation use only.
        The data is licensed as Creative Commons Attribution-Share Alike 2.0
        (http://creativecommons.org/licenses/by-sa/2.0/)
      fees: 'None'

layers:
  #sets up which layers you want to make available using the services above. You can add many, but let's stick to osm data here.
  - name: osm
    title: Open Streetmap Tiles
    sources: [osm_cache] #this layer should use the osm_cache (defined below) as it's source.
    
caches:
  #setup the cache for the open streetmap tiles. This cache is used by the layer above.
  osm_cache:
    sources: [osm_tiles] #here you set what source data (defined below) you want to cache
    format: image/png
  
sources:
   osm_tiles:
     #the osm_tiles source refers to the openstreetmap.org tiles. These will be downloaded upon request (if not already cached) and served by MapProxy
     type: tile
     url: http://c.tile.openstreetmap.org/%(tms_path)s.%(format)s
     grid: osm_grid #the grid to use for the osm tiles. This is really important. It is specified below.

grids:
  osm_grid:
    #this srs and origin specify a grid that can be used elsewhere in the configuration. In this example it is used for the osm_tiles source. These settings are correct for openstreetmap.org tiles.
    #The google mercator srs is used (also called EPSG:900913), and the origin of the tiles is north-west). If you get this wrong, you might very well get an all-blue world.
    srs: EPSG:900913
    origin: nw

globals:
  #next are some global configuration options for MapProxy. They mostly explain themselves, or can be looked-up in the MapProxy docs.
  cache:
    # where to store the cached images
    base_dir: './cache_data'
    # where to store lockfiles
    lock_dir: './cache_data/locks'
 
 
  # image/transformation options
  image:
      resampling_method: bilinear
      jpeg_quality: 90

Other proxy/caching related software