TransWikia.com

Mapproxy as transparent Openstreetmap cache

Geographic Information Systems Asked by W. Alpha on June 21, 2021

I followed the guide from https://wiki.openstreetmap.org/wiki/MapProxy to create a locale tile proxy for OpenStreetMap, because I need to access the same tiles over and over again. However, there seem to be some problems with the grid definitions.

As a example if I try to access http://localhost:8080/tms/1.0.0/osm/EPSG900913/6/12/11.png the URL is translated to http://c.tile.openstreetmap.org/7/12/116.png

What has to be changed in the config that mapproxy acts as a purely transparent proxy?

3 Answers

The source SRS for OpenStreetMaps is EPSG:3857 (web mercator SRS). You URL is asking for tiles in EPSG:900913 (unofficial SRS from Google).

When you request MapProxy tiles in a different SRS than the source cache is, Mapproxy needs to reproject the tiles into whatever new SRS you are requesting tiles in.

So, I'd recommend you to use only EPSG:3857. Remove all references to EPSG:900913 and try with a direct configuration of the source:

osm_tiles:
    type: tile
    grid: GLOBAL_WEBMERCATOR
    url: http://c.tile.openstreetmap.org/%(z)s/%(x)s/%(y)s.png

Answered by jjmontes on June 21, 2021

Also most TILE SERVERS are XYZ including OSM. MAP PROXY only delivers TMS. make you have cached TMS. otherwise flip Y/ ROW. Lower left versus upper Left as origin. Connect QGIS to your cache folder to test install tile layer plugin add TMS grid

Answered by GeospatialInformationTech on June 21, 2021

There a lot of things that can go wrong, especially srs / grid / bbox, as I've found out trying to work this out... So here is full working example for transparent OSM cache, to help next poor soul finding this:

services:
  #sets up how to make the source data available
  demo:
  tms:
    use_grid_names: true
    # origin for /tiles service
    origin: 'nw'
  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:3857']
    image_formats: ['image/png']
    md:
      # metadata used in capabilities documents
      title: Mapproxy OSM cache
      abstract: This is the MapProxy
      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_demo      # access in JOSM as TMS: http://localhost:8080/tiles/1.0.0/osm_demo/webmercator/{zoom}/{x}/{y}.png
    title: Open Streetmap Tiles (test)
    sources: [osm_cache]

caches:
  #setup the cache for the open streetmap tiles. This cache is used by the layer above.
  osm_cache:
    sources: [osm_tiles]
    format: image/png
    grids: [webmercator]

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: webmercator

grids:
  webmercator:
    base: GLOBAL_WEBMERCATOR

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'

P.S. note that you need to access it as http://localhost:8080/tiles/1.0.0/osm_demo/webmercator/{zoom}/{x}/{y}.png not as default http://localhost:8080/tms/1.0.0/osm_demo/webmercator/{zoom}/{x}/{y}.png shown as setup page, as that will give you dreaded "empty blue" tiles...

Answered by Matija Nalis on June 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP