0

For my first attempt at using Mapcache, I wish to create a caching proxy of Bing Maps, serving a WMS. I started 'mapproxy-util serve-develop' with the following .yaml configuration, assembled from studying the documentation :

services:
  wms:
    md:
      abstract: ''
      title: Microsoft Bing orbital imagery caching proxy
    srs: ['EPSG:3857']

layers:
-   name: Bing_imagery_layer
    title: WMS layer from Microsoft Bing orbital imagery tiles
    sources: [Bing_imagery_cache]

caches:
  Bing_imagery_cache:
    grids: [GLOBAL_WEBMERCATOR]
    sources: [Microsoft_Bing_imagery]
    cache:
      type: file
      directory: /home/jm/projects/mapproxy/cache
      directory_layout: tms

sources:
  Microsoft_Bing_imagery:
    type: tile
    grid: GLOBAL_WEBMERCATOR
    url: http://ecn.t2.tiles.virtualearth.net/tiles/a%(quadkey).jpeg?g=1&mkt=en-US

And here is the observed behaviour:

$ mapproxy-util serve-develop Bing_orbital_imagery_cache_WMS.yaml
[2016-05-24 00:17:50,048] mapproxy.config - INFO - reading: /home/jm/projects/mapproxy/mymapproxy/Bing_orbital_imagery_cache_WMS.yaml
[info]  * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
[info]  * Restarting with reloader
[2016-05-24 00:17:50,771] mapproxy.config - INFO - reading: /home/jm/projects/mapproxy/mymapproxy/Bing_orbital_imagery_cache_WMS.yaml
[2016-05-24 00:17:54,457] mapproxy.wsgiapp - CRITICAL - fatal error in wms for /wms?FORMAT=image/jpeg&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS=Bing_imagery_layer&STYLES=&SRS=EPSG:3857&WIDTH=512&HEIGHT=512&BBOX=-1232777.2003892,1692622.3427892,-1227885.2307892,1697514.3123892
Traceback (most recent call last):
  File "/home/jm/projects/mapproxy/local/lib/python2.7/site-packages/mapproxy/wsgiapp.py", line 189, in __call__
    resp = self.handlers[handler_name].handle(req)
  File "/home/jm/projects/mapproxy/local/lib/python2.7/site-packages/mapproxy/service/ows.py", line 38, in handle
    return self.services[service].handle(req)
  File "/home/jm/projects/mapproxy/local/lib/python2.7/site-packages/mapproxy/service/base.py", line 30, in handle
    return handler(parsed_req)
  File "/home/jm/projects/mapproxy/local/lib/python2.7/site-packages/mapproxy/service/wms.py", line 131, in map
    renderer.render(merger)
  File "/home/jm/projects/mapproxy/local/lib/python2.7/site-packages/mapproxy/service/wms.py", line 530, in render
    layer_merger)
  File "/home/jm/projects/mapproxy/local/lib/python2.7/site-packages/mapproxy/service/wms.py", line 567, in _render_capture_source_errors
    raise ex[1]
ValueError: unsupported format character 'j' (0x6a) at index 55
Traceback (most recent call last):
  File "/home/jm/projects/mapproxy/local/lib/python2.7/site-packages/mapproxy/wsgiapp.py", line 189, in __call__
    resp = self.handlers[handler_name].handle(req)
  File "/home/jm/projects/mapproxy/local/lib/python2.7/site-packages/mapproxy/service/ows.py", line 38, in handle

In the URL passed to Mapcache, the only occurrence of the letter "j" mentioned in the error message is in "FORMAT=image/jpeg" - so I thought maybe the forward slash must be encoded as %2F but trying that yielded the same behavior.

Even stranger, I tried passing "FORMAT=image/png" so that the entire URL contains no occurrence of the letter "j" and I got exactly the same result: "ValueError: unsupported format character 'j' (0x6a) at index 55"

At this point, I am at a loss for new hypothesis... From the lack of Google results for "unsupported format character" "mapcache" it seems that I managed to err in exotic ways..

If any of you has hypothesis about where I should look, I'll be thankful.

1

The error was in my template variable syntax... And the letter "j" put me on its trail ! In the configuration,

url: http://ecn.t2.tiles.virtualearth.net/tiles/a%(quadkey).jpeg?g=1&mkt=en-US

is wrong and must be

url: http://ecn.t2.tiles.virtualearth.net/tiles/a%(quadkey)s.jpeg?g=1&mkt=en-US

Note the "s" character after the closing parenthesis - it is part of the template variable syntax, as explained in the documentation

It works !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.