[MapProxy] WMS-C as a source

Jeff Konnen jaykayone at gmail.com
Wed Mar 7 16:19:37 EST 2012


Hi,

for the record I've worked around this issue by adding the following:

    def open_image(self, url, data=None):
        resp = self.open(url, data=data)
        if 'content-type' in resp.headers:
            if not resp.headers['content-type'].lower().startswith('image'):
                if resp.read().find("no-data")>-1:
                    raise HTTPClientError('no-data exeception',-999)
                else:
                    raise HTTPClientError('response is not an image: (%s)' % (resp.read()))
        return ImageSource(resp)

to http.py

and this to my yaml -file:

    on_error:
        200:
          response: transparent
          cache: True
        -999:
          response: transparent
          cache: True

It's q quick and dirty workaround but it does work like a charm.

Thanks
Jeff


On 06 Mar 2012, at 23:22, Jeff Konnen wrote:

> Hi Oliver!
> 
> You rock, thanks and it works like a charm!
> 
> Now I finally saw what was probably also the problem when I was using GDAL. Sometimes there are no tiles sent back because it is "nodata".
> Neither GDAL nor MapProxy can handle this.
> 
> I saw in the doc of MP1.4.0a that there is a new parameter on_error.
> I installed the new version and found that my case is not covered yet.
> 
> Actually, what I get is not an error, but an exception:
> 
> [2012-03-06 23:17:34,545] mapproxy.source.request - INFO - GET http://itchy.geoportal.lu/wmsc?service=WMS&request=GetMap&version=1.1.1&layers=ORTHOIMAGERY.ORTHOPHOTOS&styles=&srs=EPSG:310024802&format=image/jpeg&width=256&height=256&bbox=449536.00000000,5514240.00000000,450560.00000000,5515264.00000000 200 1.0 11
> [2012-03-06 23:17:34,548] mapproxy.source.request - INFO - GET http://itchy.geoportal.lu/wmsc?service=WMS&request=GetMap&version=1.1.1&layers=ORTHOIMAGERY.ORTHOPHOTOS&styles=&srs=EPSG:310024802&format=image/jpeg&width=256&height=256&bbox=448512.00000000,5514240.00000000,449536.00000000,5515264.00000000 200 - 15
> [2012-03-06 23:17:34,603] mapproxy.source.request - INFO - GET http://itchy.geoportal.lu/wmsc?service=WMS&request=GetMap&version=1.1.1&layers=ORTHOIMAGERY.ORTHOPHOTOS&styles=&srs=EPSG:310024802&format=image/jpeg&width=256&height=256&bbox=450560.00000000,5514240.00000000,451584.00000000,5515264.00000000 200 - 57
> [2012-03-06 23:17:34,603] mapproxy.source.tile - WARNING - could not retrieve tile: response is not an image: (<?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE ServiceExceptionReport [
>    <!ELEMENT ServiceExceptionReport (ServiceException*)>
>    <!ATTLIST ServiceExceptionReport version CDATA #FIXED "1.1.1">
>    <!ELEMENT ServiceException (#PCDATA)>
>    <!ATTLIST ServiceException code CDATA #IMPLIED>
>    <!ATTLIST ServiceException locator CDATA #IMPLIED>
> ]>
> <ServiceExceptionReport version="1.1.1">
>        <ServiceException code="NoTileFound" locator="">
>                <![CDATA[
>                    Requested tile is not found (eventually because it is an empty "no-data" image).
>                ]]>
>        </ServiceException>
> </ServiceExceptionReport>)
> [2012-03-06 23:17:34,607] mapproxy.source.request - INFO - GET http://itchy.geoportal.lu/wmsc?service=WMS&request=GetMap&version=1.1.1&layers=ORTHOIMAGERY.ORTHOPHOTOS&styles=&srs=EPSG:310024802&format=image/jpeg&width=256&height=256&bbox=451584.00000000,5514240.00000000,452608.00000000,5515264.00000000 200 - 58
> [2012-03-06 23:17:34,607] mapproxy.source.tile - WARNING - could not retrieve tile: response is not an image: (<?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE ServiceExceptionReport [
>    <!ELEMENT ServiceExceptionReport (ServiceException*)>
>    <!ATTLIST ServiceExceptionReport version CDATA #FIXED "1.1.1">
>    <!ELEMENT ServiceException (#PCDATA)>
>    <!ATTLIST ServiceException code CDATA #IMPLIED>
>    <!ATTLIST ServiceException locator CDATA #IMPLIED>
> ]>
> <ServiceExceptionReport version="1.1.1">
>        <ServiceException code="NoTileFound" locator="">
>                <![CDATA[
>                    Requested tile is not found (eventually because it is an empty "no-data" image).
>                ]]>
>        </ServiceException>
> </ServiceExceptionReport>)
> [info] 10.113.80.68 - - [06/Mar/2012 23:17:34] "GET /service?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=Ortho&STYLES=&FORMAT=image/jpeg&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&SRS=EPSG:2169&BBOX=57813.307456103,60448.7767579583,66843.1407711681,66762.9213969255&WIDTH=1340&HEIGHT=937 HTTP/1.1" 200 -
> [2012-03-06 23:17:34,660] mapproxy.source.request - INFO - GET http://itchy.geoportal.lu/wmsc?service=WMS&request=GetMap&version=1.1.1&layers=ORTHOIMAGERY.ORTHOPHOTOS&styles=&srs=EPSG:310024802&format=image/jpeg&width=256&height=256&bbox=452608.00000000,5514240.00000000,453632.00000000,5515264.00000000 200 - 56
> [2012-03-06 23:17:34,661] mapproxy.source.tile - WARNING - could not retrieve tile: response is not an image: (<?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE ServiceExceptionReport [
>    <!ELEMENT ServiceExceptionReport (ServiceException*)>
>    <!ATTLIST ServiceExceptionReport version CDATA #FIXED "1.1.1">
>    <!ELEMENT ServiceException (#PCDATA)>
>    <!ATTLIST ServiceException code CDATA #IMPLIED>
>    <!ATTLIST ServiceException locator CDATA #IMPLIED>
> ]>
> <ServiceExceptionReport version="1.1.1">
>        <ServiceException code="NoTileFound" locator="">
>                <![CDATA[
>                    Requested tile is not found (eventually because it is an empty "no-data" image).
>                ]]>
>        </ServiceException>
> </ServiceExceptionReport>)
> 
> So ideally in addition to on_error there would be an on_exception too ;-)
> 
> I tried forking the repository to write a patch but somehow I can't access bitbucked from behind my proxy..
> 
> Thanks again
> Jeff



More information about the MapProxy mailing list