[MapProxy] Troubles creating a proper configuration for german wmts service

Malte Zacharias saeckereier at gmx.de
Wed Oct 3 04:10:41 PDT 2012


Hi folks,

I'm currently trying to setup MapProxy as a WMS cache for a wmts service. The 
german authorities provide a free-for-private-use service with a complete 
official german map.

Unfortunately this is wmts only and I also want to leverage the cache feature 
for possible offline usage. I'm trying to configure mapproxy to do this but I'm 
failing because with 
my configuration the wrong tiles are requested. In zoom level 0 for example 
tile 0,0 is requested, but the service returns a 404 error. I'm pretty sure 
that there needs to be some 
kind of offset in the tile number, but I don't know how to configure that. Here 
is the WMTSCapabiliites file (I had to remove my user credentials as license 
agreement states
 that I may not publish those, but if you want to try it out you can register 
for a free user id at 
https://upd.geodatenzentrum.de/auftrupd/gdz_webatlas.wade?gdz_kz=0&gdz_service=&gdz_kontakt=&gdz_kontaktr=&gdz_spr=deu  
german language only) :


<?xml version="1.0" encoding="UTF-8"?>
<Capabilities xmlns="http://www.opengis.net/wmts/1.0"
	xmlns:ows="http://www.opengis.net/ows/1.1"
	xmlns:xlink="http://www.w3.org/1999/xlink"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:gml="http://www.opengis.net/gml"
	xsi:schemaLocation="http://www.opengis.net/wmts/1.0 
http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd"
	version="1.0.0">
  <!-- Service Identification --> 
 <ows:ServiceIdentification>
	<ows:Title>Webatlas</ows:Title>
	<ows:ServiceType>OGC WMTS</ows:ServiceType>
	<ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
</ows:ServiceIdentification> <!-- Operations Metadata --> 
<ows:OperationsMetadata>
	<ows:Operation name="GetCapabilities">
		<ows:DCP>
			<ows:HTTP>
				<ows:Get 
xlink:href="https://sg.geodatenzentrum.de/wmts_webatlasde__<userauthorization>/1.0.0/WMTSCapabilities.xml">
					<ows:Constraint name="GetEncoding">
						<ows:AllowedValues>
							<ows:Value>RESTful</ows:Value>
						</ows:AllowedValues>
					</ows:Constraint>
				</ows:Get>
                <!-- add KVP binding in 10.1 -->
                <ows:Get 
xlink:href="https://sg.geodatenzentrum.de/wmts_webatlasde__<userauthorization>?">
                  <ows:Constraint name="GetEncoding">
                    <ows:AllowedValues>
                      <ows:Value>KVP</ows:Value>
                    </ows:AllowedValues>
                  </ows:Constraint>
                </ows:Get>
    		</ows:HTTP>
    </ows:DCP>
	</ows:Operation>
	<ows:Operation name="GetTile">
		<ows:DCP>
			<ows:HTTP>
				<ows:Get 
xlink:href="https://sg.geodatenzentrum.de/wmts_webatlasde__<userauthorization>/tile/1.0.0/">
					<ows:Constraint name="GetEncoding">
						<ows:AllowedValues>
							<ows:Value>RESTful</ows:Value>
						</ows:AllowedValues>
					</ows:Constraint>
				</ows:Get>
                <ows:Get 
xlink:href="https://sg.geodatenzentrum.de/wmts_webatlasde__<userauthorization>?">
                  <ows:Constraint name="GetEncoding">
                    <ows:AllowedValues>
                      <ows:Value>KVP</ows:Value>
                    </ows:AllowedValues>
                  </ows:Constraint>
                </ows:Get>
            </ows:HTTP>
		</ows:DCP>
	</ows:Operation>
</ows:OperationsMetadata> 
<Contents>
  <!--Layer-->  
  <Layer>
    <ows:Title>Webatlas</ows:Title> 
    <ows:Identifier>Webatlas</ows:Identifier>
    
      <ows:BoundingBox crs="urn:ogc:def:crs:EPSG::25832">
        <ows:LowerCorner>280387.70990000013 
5193471.164086349</ows:LowerCorner>
        <ows:UpperCorner>981683.1163957692 6137570.076873273</ows:UpperCorner>
      </ows:BoundingBox>  
      
    <ows:WGS84BoundingBox crs="urn:ogc:def:crs:OGC:2:84">
      <ows:LowerCorner>5.5371920271740755 46.72083286192543</ows:LowerCorner>
      <ows:UpperCorner>16.565765955797936 55.384414826380514</ows:UpperCorner>
    </ows:WGS84BoundingBox>
    <Style isDefault="true">
      <ows:Title>Default Style</ows:Title>
      <ows:Identifier>default</ows:Identifier>
    </Style>
    <Format>image/png</Format>
    <TileMatrixSetLink>
      <TileMatrixSet>default028mm</TileMatrixSet>
    </TileMatrixSetLink>
    <TileMatrixSetLink>
      <TileMatrixSet>nativeTileMatrixSet</TileMatrixSet>  
    </TileMatrixSetLink>    
        
    <ResourceURL format="image/png" resourceType="tile" 
template="https://sg.geodatenzentrum.de/wmts_webatlasde__<userauthorization>/tile/1.0.0/Webatlas/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png" 
/>
  </Layer> 
   <!--TileMatrixSet-->
   <TileMatrixSet>
     <ows:Title>Default TileMatrix using 0.28mm</ows:Title>
     <ows:Abstract>The tile matrix set that has scale values calculated based 
on the dpi defined by OGC specification (dpi assumes 0.28mm as the physical 
distance of a pixel).</ows:Abstract> 
     <ows:Identifier>default028mm</ows:Identifier>
     <ows:SupportedCRS>urn:ogc:def:crs:EPSG::25832</ows:SupportedCRS>
      
          <TileMatrix>
          <ows:Identifier>0</ows:Identifier> 
          <ScaleDenominator>9449404.761904761</ScaleDenominator>
          <TopLeftCorner>-5120900.0 9998100.0</TopLeftCorner>  
          <TileWidth>512</TileWidth> 
          <TileHeight>512</TileHeight>
            
            <MatrixWidth>2</MatrixWidth> 
            <MatrixHeight>2</MatrixHeight>
          
          </TileMatrix>
          
          <TileMatrix>
          <ows:Identifier>1</ows:Identifier> 
          <ScaleDenominator>7087053.571428571</ScaleDenominator>
          <TopLeftCorner>-5120900.0 9998100.0</TopLeftCorner>  
          <TileWidth>512</TileWidth> 
          <TileHeight>512</TileHeight>
            
            <MatrixWidth>2</MatrixWidth> 
            <MatrixHeight>2</MatrixHeight>
          
          </TileMatrix>
          
          <TileMatrix>
          <ows:Identifier>2</ows:Identifier> 
          <ScaleDenominator>4724702.380952381</ScaleDenominator>
          <TopLeftCorner>-5120900.0 9998100.0</TopLeftCorner>  
          <TileWidth>512</TileWidth> 
          <TileHeight>512</TileHeight>
            
            <MatrixWidth>3</MatrixWidth> 
            <MatrixHeight>3</MatrixHeight>
          
          </TileMatrix>
          
          <TileMatrix>
          <ows:Identifier>3</ows:Identifier> 
          <ScaleDenominator>2834821.428571428</ScaleDenominator>
          <TopLeftCorner>-5120900.0 9998100.0</TopLeftCorner>  
          <TileWidth>512</TileWidth> 
          <TileHeight>512</TileHeight>
            
            <MatrixWidth>3</MatrixWidth> 
            <MatrixHeight>3</MatrixHeight>
          
          </TileMatrix>

[... I removed the following levels and also the second TileMatrixSet tokeep 
the mail shorter, please tell me if you need them  ... ]

  </TileMatrixSet>
   
</Contents>
<ServiceMetadataURL 
xlink:href="https://sg.geodatenzentrum.de/wmts_webatlasde__<userauthorization>/1.0.0/WMTSCapabilities.xml" 
/> 
</Capabilities>


Anyway, I hope my question can be answered based on the Capabilities file 
alone.

I am pretty new to all this, so I'm having trouble understanding, how to 
configure mapproxy properly. This is my configuration so far (only changes from 
the standard demo config file):

------------------------------------------------------------------------------------------
layers:
  - name: geoserver
    title: geoserver
    sources: [osm_cache]

caches:
  osm_cache:
    grids: [mygrid]
    sources: [geoserver]

sources:
  geoserver:
    type: tile
    grid: mygrid
    url: https://sg.geodatenzentrum.de/wmts_webatlasde__<user-id 
removed>/tile/1.0.0/Webatlas/default/default028mm/%(z)s/%(y)s/%(x)s.png
    http:
      ssl_no_cert_checks: true # going to change this later
    on_error:
      404:
        response: '#DD7777' # just to highlight the 404 errors
        cache: False
    coverage:
      bbox: [280387.70990000013, 5193471.164086349, 981683.1163957692, 
6137570.076873273]
      bbox_srs: EPSG:25832

  mygrid:
    srs: EPSG:25832
    tile_size: [512, 512]
    bbox: [280387.70990000013, 5193471.164086349, 981683.1163957692, 
6137570.076873273]
    origin: ul
    res: [
         #  res            level     scale @91.0 DPI
         2637.5261643119, #  0     9449404.76190476
         1978.1446232339, #  1     7087053.57142857
         1318.7630821559, #  2     4724702.38095238
          791.2578492936, #  3     2834821.42857143
          527.5052328624, #  4     1889880.95238095
          395.6289246468, #  5     1417410.71428571
          263.7526164312, #  6      944940.47619048
          197.8144623234, #  7      708705.35714286
          131.8763082156, #  8      472470.23809524
           79.1257849294, #  9      283482.14285714
           39.5628924647, # 10      141741.07142857
           26.3752616431, # 11       94494.04761905
           19.7814462323, # 12       70870.53571429
            7.9125784929, # 13       28348.21428571
            5.2750523286, # 14       18898.80952381
            3.9562892465, # 15       14174.10714286
            2.6375261643, # 16        9449.40476190
            1.9781446232, # 17        7087.05357143
            1.3187630822, # 18        4724.70238095
            0.7912578493, # 19        2834.82142857
    ]
------------------------------------------------------------------------------------------


I also know that for example 
https://sg.geodatenzentrum.de/wmts_webatlasde__<user-id 
removed>/tile/1.0.0/Webatlas/default/default028mm/7/44/54.png is a valid URL, 
and if I open the demo page viewer I can actually zoom in to level 7 and pan 
the map around until I finally get to the tile 44/54 and those are displayed 
properly along with the 
surrounding tiles. If I zoom in or out however I'm again not at the right tile 
coordinates. My best guess currently is, that I somehow have to factor in the 
TopLeftCorner from the TileMatrix part in the xml:

          <TileMatrix>
          <ows:Identifier>0</ows:Identifier> 
          <ScaleDenominator>9449404.761904761</ScaleDenominator>
          <TopLeftCorner>-5120900.0 9998100.0</TopLeftCorner>  
          <TileWidth>512</TileWidth> 
          <TileHeight>512</TileHeight>
            
            <MatrixWidth>2</MatrixWidth> 
            <MatrixHeight>2</MatrixHeight>
          
          </TileMatrix>

I'd appreciate your help on this, as I hope it's not much that is left...

Thanks
Malte


More information about the MapProxy mailing list