[MapProxy] pbf vector tiles cachen

Steven M. Ottens steven at minst.net
Thu Jan 21 15:19:41 PST 2016


To answer my own question: yes it can! Though it is not for the faint of 
heart and to do it properly requires input from the mapproxy devs. The 
main problem is that MapProxy assumes it is going to work with images, 
the first problem being that it will request meta-tiles and split those 
into actual tiles. This is easily circumvented by adding
     meta_size: [1, 1]
     meta_buffer: 0
to you cache configuration.
The next hurdle is the _check_resp function in /client/wms.py, which 
checks if the response from the WMSserver is an actual image, it checks 
lazily whether or not the headers are of the proper type, you can 
circumvent this by extending the check like this:
if not (resp.headers.get('Content-type', 'image/').startswith('image/') 
or resp.headers.get('Content-type', 

The final one is that MapProxy doesn't know .pbf so it won't request a 
protobuffer file from GeoServer, a dirty solution would be to add to 
your sources config:
     supported_formats: ['/application/x-protobuf']
(note the extra / in the beginning, for some reason MapProxy replace the 
bit before the first / with image/)

This way it will request protobuffer files from GeoServer regardless of 
the filetype you use in your request. This is quite a dirty hack, since 
now I'm requesting .png files and I receive .pbf files. The files it 
self are cached as expected and loaded from cache when available.

So yes in theory mapproxy can cache vector tiles, though it needs quite 
some work to do it more elegantly.

The big question is of course if caching vector tiles should be a 
feature of MapProxy at all.


On 1/20/2016 5:44 PM, Steven M. Ottens wrote:
> Hi all,
> Geoserver nowadays has a plugin [1] to render vector data as vector 
> tiles in the mapbox vector tiles specification (.pbf) [2]. It supports 
> WMS requests with the format=application/x-protobuf parameter. I was 
> wondering how hard it would be to have mapproxy handle wms-c and tms 
> requests and cache the .pbf tiles. I am aware that the more advanced 
> features of mapproxy, like WMS, reprojection, metatiles will not work 
> as long as mapproxy can't read protobuffer files, and even if it does 
> it would be a difficult thing. But I'd like the easier bits: turn a 
> TMS request into the correct WMS-request, retrieve the .pbf file, 
> store it locally and serve it to the client.
> Any idea if this would be feasible at all, and if so how much work 
> would it be to implement it?
> Cheers,
> Steven
> [1] https://github.com/stefan0722/gs-mvt
> [2] https://github.com/mapbox/vector-tile-spec
> _______________________________________________
> MapProxy mailing list
> MapProxy at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapproxy

More information about the MapProxy mailing list