[MapProxy] Restricting a layer to a polygon extent

Paul Norman penorman at mac.com
Tue Sep 4 17:15:47 PDT 2012


I have a mapproxy server that I am going to be using to mosaic several
imagery layers together. Some are local caches of WMS layers but one of them
is a cache of a TMS layer with the lower zoom tiles pre-cached.

To mosaic the imagery I need to have it transparent outside a polygon
extent, unfortunately the tile layer is black outside of its extent and not
transparent. To get around this I was intending to use the authorization
API.

limited_to is documented under
http://mapproxy.org/docs/latest/auth.html#wms-service but not under TMS. Is
this WMS only? If so, I guess I could serve the layer as WMS with
authentication then use the WMS as a source for the mosaic layer.

I'm using mod_wsgi to run mapproxy with WSGI pointing at a python script
which calls make_wsgi_app.

Would adding the following lines above the make_wsgi_app be going down the
right path?

os.environ["mapproxy.authorize"] = "authorize"
def authorize(service, layers=[], environ=None, **kw):
    if service != 'wmswms':
        return {'authorized':'full'}
    return { 
        'authorized': 'partial',
        'layers': {
            'mylayer': {
                'map': True,
                'limited_to': {
                    'geometry': 'POLYGON((...))',
                    'srs': 'EPSG:4326'
                }
            }
        }
    }



More information about the MapProxy mailing list