MapProxy – Creating Correct mapproxy.yaml from GetCapabilities XML

getcapabilitiesmapproxyurlwmsxyz-tiles

Slovakia publishes an orthophoto WMS service:

https://zbgisws.skgeodesy.sk/zbgis_ortofoto_wms/service.svc/get?request=GetCapabilities&service=WMS

I would like to set up a locally run Tile service using MapProxy, using this WMS as datasource.

What works

I follow the Getting started part of mapproxy.org, and after

mapproxy-util serve-develop ./mapproxy.yaml

I have a running server. To test it, I visit http://localhost:8080/tiles/osm/webmercator/13/4485/2842.png, which nicely returns a tile of central Bratislava:

enter image description here

mapproxy.yaml:

# -------------------------------
# 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/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
    title: Omniscale OSM WMS - osm.omniscale.net
    sources: [osm_cache]

caches:
  osm_cache:
    grids: [webmercator]
    sources: [osm_wms]

sources:
  osm_wms:
    type: wms
    req:
      url: https://maps.omniscale.net/v2/demo/style.default/service?
      layers: osm

grids:
    webmercator:
        base: GLOBAL_WEBMERCATOR

globals:

What doesn't work

I would like to view the same 13/4485/2842 tile, but using the Slovak Ortophoto WMS as datasource. To do that, I fist observe in the capabilities XML that EPSG:3857 is supported:

<CRS>EPSG:3857</CRS>

I also connect to the WMS using QGIS to make sure it works:

enter image description here

It does indeed work:

enter image description here

Based on QGIS, and that the capabilities XML says:

<Layer queryable="1">
<Name>1</Name>

I believe the name of the Ortophoto layer is 1.

I set the url field in mapproxy.yaml to be https://zbgisws.skgeodesy.sk/zbgis_ortofoto_wms/service.svc/get?request=GetCapabilities&service=WMS instead of https://maps.omniscale.net/v2/demo/style.default/service?. I set the layers field to 1 instead of osm. The new mapproxy.yaml:

# -------------------------------
# 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/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
    title: Omniscale OSM WMS - osm.omniscale.net
    sources: [osm_cache]

caches:
  osm_cache:
    grids: [webmercator]
    sources: [osm_wms]

sources:
  osm_wms:
    type: wms
    req:
      url: https://zbgisws.skgeodesy.sk/zbgis_ortofoto_wms/service.svc/get?request=GetCapabilities&service=WMS
      layers: 1

grids:
    webmercator:
        base: GLOBAL_WEBMERCATOR

globals:

I launch the server again (mapproxy-util serve-develop ./mapproxy.yaml), load http://localhost:8080/tiles/osm/webmercator/13/4485/2842.png. I still get back the OSM tile (as above), instead of orthophoto data. I suspect this might be due to some caching, so I load a tile far away from the previous one:

http://localhost:8080/tiles/osm/webmercator/13/4531/2822.png

Instead of downtown Banská Bystrica, I get:

no image returned from source WMS: https://zbgisws.skgeodesy.sk/zbgis_ortofoto_wms/service.svc/get?request=GetCapabilities&service=WMS&layers=1&format=image%2Fpng&bbox=2111802.217462851,6221056.858073925,2134427.577835263,6243682.218446338&width=1184&height=1184&srs=EPSG%3A3857&request=GetMap&version=1.1.1&service=WMS&styles=

I suspect the problem is with the url and/or the layers field within my new mapproxy.yaml.

Question

If this assessment is right, I would like to know, given a Capabilities XML, how do I find the right url and layers values to use within mapproxy.yaml?

Best Answer

This question talks about a similar issue, but the problems arising there are broader than raised thread (projection issues).

There, the GetCapabilities XML is:

https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?language=ita&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

It is suggested in the comments, that the URL used should be:

https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?language=ita&

which belongs to the OnlineResource section of the XML:

enter image description here

Using this, we can look for OnlineResource in the Ortophoto XML:

https://zbgisws.skgeodesy.sk/zbgis_ortofoto_wms/service.svc/get?request=GetCapabilities&service=WMS

enter image description here

and we can arrive to the link:

https://zbgisws.skgeodesy.sk/zbgis_ortofoto_wms/service.svc/get?

Replacing https://zbgisws.skgeodesy.sk/zbgis_ortofoto_wms/service.svc/get?request=GetCapabilities&service=WMS in the mapproxy.yaml by https://zbgisws.skgeodesy.sk/zbgis_ortofoto_wms/service.svc/get? solves the problem. After launching the server again, then loading http://localhost:8080/tiles/osm/webmercator/13/4531/2822.png, we indeed get a view of downtown Banská Bystrica:

enter image description here