Skip to content

feat(district,maps_utils): load map layer tiles from MapProxy instance

filip.varecha requested to merge feat-use-mapproxy-to-serve-tiles into test

Use MapProxy to serve map tiles. This has several advantages:

  • Less traffic to paid tile providers (hopefully free plans will work fine)
  • No need to create API keys per website - everything is stored on the MapProxy level
  • Potentially more reliable, when the provider is down, we still might have cache

Make sure MapProxy works and is configured before merging/deploying this. I described necessary MapProxy configuration to @ramaseuski and will also verify locally when he applies it. Once ready, I'll mention it here so that you guys know we can proceed safely.

For the record, here is necessary MapProxy config:

# -------------------------------
# MapProxy example configuration.
# -------------------------------
#
# This is a minimal MapProxy configuration.
# See full_example.yaml and the documentation for more options.
#

# Starts the following services:
# Demo:
#     http://localhost:8080/demo
# WMS:
#     capabilities: http://localhost:8080/service?REQUEST=GetCapabilities
# WMTS:
#     capabilities: http://localhost:8080/wmts/1.0.0/WMTSCapabilities.xml
#     first tile: http://localhost:8080/wmts/osm/webmercator/0/0/0.png
# Tile service (compatible with OSM/etc.)
#     first tile: http://localhost:8080/tiles/osm_mapnik/webmercator/0/0/0.png
# TMS:
#     note: TMS is not compatible with OSM/Google Maps/etc.
#     first tile: http://localhost:8080/tms/1.0.0/osm/webmercator/0/0/0.png
# KML:
#     initial doc: http://localhost:8080/kml/osm/webmercator

services:
  demo:
  tms:
    use_grid_names: true
    # origin for /tiles service
    origin: 'nw'
  kml:
      use_grid_names: true
  wmts:
  wms:
    md:
      title: MapProxy WMS Proxy
      abstract: This is a minimal MapProxy example.

layers:
  - name: osm_mapnik
    title: OSM Mapnik
    sources: [osm_mapnik_cache]

  - name: stamen_toner
    title: Stamen Toner
    sources: [stamen_toner_cache]

  - name: stamen_terrain
    title: Stamen Terrain
    sources: [stamen_terrain_cache]

  - name: stadia_osm_bright
    title: Stadia OSM Bright
    sources: [stadia_osm_bright_cache]

  - name: stadia_osm_bright_hq
    title: Stadia OSM Bright HQ
    sources: [stadia_osm_bright_hq_cache]

  - name: stadia_outdoors
    title: Stadia Outdoors
    sources: [stadia_outdoors_cache]

  - name: stadia_outdoors_hq
    title: Stadia Outdoors HQ
    sources: [stadia_outdoors_hq_cache]

  - name: mapbox_streets
    title: Mapbox Streets
    sources: [mapbox_streets_cache]

  - name: mapbox_streets_hq
    title: Mapbox Streets HQ
    sources: [mapbox_streets_hq_cache]

  - name: mapbox_outdoors
    title: Mapbox Outdoors
    sources: [mapbox_outdoors_cache]

  - name: mapbox_outdoors_hq
    title: Mapbox Streets HQ
    sources: [mapbox_outdoors_hq_cache]

  - name: mapbox_light
    title: Mapbox Light
    sources: [mapbox_light_cache]

  - name: mapbox_light_hq
    title: Mapbox Light HQ
    sources: [mapbox_light_hq_cache]

  - name: mapbox_dark
    title: Mapbox Dark
    sources: [mapbox_dark_cache]

  - name: mapbox_dark_hq
    title: Mapbox Dark HQ
    sources: [mapbox_dark_hq_cache]

  - name: mapbox_satellite
    title: Mapbox Satellite
    sources: [mapbox_satellite_cache]

  - name: mapbox_satellite_hq
    title: Mapbox Satellite HQ
    sources: [mapbox_satellite_hq_cache]

  - name: mapbox_pirate
    title: Mapbox Pirate
    sources: [mapbox_pirate_cache]

  - name: mapbox_pirate_hq
    title: Mapbox Pirate HQ
    sources: [mapbox_pirate_hq_cache]

caches:
  osm_mapnik_cache:
    grids: [webmercator]
    sources: [osm_mapnik]

  stamen_toner_cache:
    grids: [webmercator]
    sources: [stamen_toner]

  stamen_terrain_cache:
    grids: [webmercator]
    sources: [stamen_terrain]

  stadia_osm_bright_cache:
    grids: [webmercator]
    sources: [stadia_osm_bright]

  stadia_osm_bright_hq_cache:
    grids: [webmercator]
    sources: [stadia_osm_bright_hq]

  stadia_outdoors_cache:
    grids: [webmercator]
    sources: [stadia_outdoors]

  stadia_outdoors_hq_cache:
    grids: [webmercator]
    sources: [stadia_outdoors_hq]

  mapbox_streets_cache:
    grids: [mapbox_webmercator]
    sources: [mapbox_streets]

  mapbox_streets_hq_cache:
    grids: [mapbox_webmercator_hq]
    sources: [mapbox_streets_hq]

  mapbox_outdoors_cache:
    grids: [mapbox_webmercator]
    sources: [mapbox_outdoors]

  mapbox_outdoors_hq_cache:
    grids: [mapbox_webmercator_hq]
    sources: [mapbox_outdoors_hq]

  mapbox_light_cache:
    grids: [mapbox_webmercator]
    sources: [mapbox_light]

  mapbox_light_hq_cache:
    grids: [mapbox_webmercator_hq]
    sources: [mapbox_light_hq]

  mapbox_dark_cache:
    grids: [mapbox_webmercator]
    sources: [mapbox_dark]

  mapbox_dark_hq_cache:
    grids: [mapbox_webmercator_hq]
    sources: [mapbox_dark_hq]

  mapbox_satellite_cache:
    grids: [mapbox_webmercator]
    sources: [mapbox_satellite]

  mapbox_satellite_hq_cache:
    grids: [mapbox_webmercator_hq]
    sources: [mapbox_satellite_hq]

  mapbox_pirate_cache:
    grids: [mapbox_webmercator]
    sources: [mapbox_pirate]

  mapbox_pirate_hq_cache:
    grids: [mapbox_webmercator_hq]
    sources: [mapbox_pirate_hq]

sources:
  osm_mapnik:
    type: tile
    url: https://a.tile.openstreetmap.org/%(z)s/%(x)s/%(y)s.png
    transparent: true
    grid: webmercator

  stamen_toner:
    type: tile
    url: https://stamen-tiles.a.ssl.fastly.net/toner/%(z)s/%(x)s/%(y)s.png
    transparent: true
    grid: webmercator

  stamen_terrain:
    type: tile
    url: https://stamen-tiles.a.ssl.fastly.net/terrain/%(z)s/%(x)s/%(y)s.png
    transparent: true
    grid: webmercator

  stadia_osm_bright:
    type: tile
    url: https://tiles.stadiamaps.com/tiles/osm_bright/%(z)s/%(x)s/%(y)s.png?api_key=[STADIA_API_KEY]
    transparent: true
    grid: webmercator

  stadia_osm_bright_hq:
    type: tile
    url: https://tiles.stadiamaps.com/tiles/osm_bright/%(z)s/%(x)s/%(y)s@2x.png?api_key=[STADIA_API_KEY]
    transparent: true
    grid: webmercator

  stadia_outdoors:
    type: tile
    url: https://tiles.stadiamaps.com/tiles/outdoors/%(z)s/%(x)s/%(y)s.png?api_key=[STADIA_API_KEY]
    transparent: true
    grid: webmercator

  stadia_outdoors_hq:
    type: tile
    url: https://tiles.stadiamaps.com/tiles/outdoors/%(z)s/%(x)s/%(y)s@2x.png?api_key=[STADIA_API_KEY]
    transparent: true
    grid: webmercator

  mapbox_streets:
    type: tile
    url: https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/%(z)s/%(x)s/%(y)s?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator

  mapbox_streets_hq:
    type: tile
    url: https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/%(z)s/%(x)s/%(y)s@2x?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator_hq

  mapbox_outdoors:
    type: tile
    url: https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/tiles/%(z)s/%(x)s/%(y)s?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator

  mapbox_outdoors_hq:
    type: tile
    url: https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/tiles/%(z)s/%(x)s/%(y)s@2x?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator_hq

  mapbox_light:
    type: tile
    url: https://api.mapbox.com/styles/v1/mapbox/light-v10/tiles/%(z)s/%(x)s/%(y)s?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator

  mapbox_light_hq:
    type: tile
    url: https://api.mapbox.com/styles/v1/mapbox/light-v10/tiles/%(z)s/%(x)s/%(y)s@2x?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator_hq

  mapbox_dark:
    type: tile
    url: https://api.mapbox.com/styles/v1/mapbox/dark-v10/tiles/%(z)s/%(x)s/%(y)s?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator

  mapbox_dark_hq:
    type: tile
    url: https://api.mapbox.com/styles/v1/mapbox/dark-v10/tiles/%(z)s/%(x)s/%(y)s@2x?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator_hq

  mapbox_satellite:
    type: tile
    url: https://api.mapbox.com/styles/v1/mapbox/satellite-v9/tiles/%(z)s/%(x)s/%(y)s?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator

  mapbox_satellite_hq:
    type: tile
    url: https://api.mapbox.com/styles/v1/mapbox/satellite-v9/tiles/%(z)s/%(x)s/%(y)s@2x?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator_hq

  mapbox_pirate:
    type: tile
    url: https://api.mapbox.com/styles/v1/xaralis/ck4oblwty0fgk1fjzxmqow2r5/tiles/%(z)s/%(x)s/%(y)s?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator

  mapbox_pirate_hq:
    type: tile
    url: https://api.mapbox.com/styles/v1/xaralis/ck4oblwty0fgk1fjzxmqow2r5/tiles/%(z)s/%(x)s/%(y)s@2x?access_token=[MAPBOX_ACCESS_TOKEN]
    transparent: true
    grid: mapbox_webmercator_hq

grids:
  webmercator:
    srs: "EPSG:3857"
    origin: nw
    num_levels: 20
  mapbox_webmercator:
    srs: "EPSG:3857"
    origin: nw
    num_levels: 22
    tile_size: [512, 512]
  mapbox_webmercator_hq:
    srs: "EPSG:3857"
    origin: nw
    num_levels: 22
    tile_size: [1024, 1024]

globals:
Edited by filip.varecha

Merge request reports

Loading