[MapProxy] Hacking mapproxy WMS to use Arcgis REST export

Aron Bierbaum aronbierbaum at gmail.com
Mon Nov 18 16:50:35 PST 2013


If you are interested I have added support for ArcGIS REST directly on our
fork. I have not had the time to clean up the code and get it into an
upstream pull request though.

-Aron

https://github.com/vrsource/mapproxy/commit/e8098ab0644cc7f7e7c6c978a748b2625065ca32


On Mon, Nov 18, 2013 at 6:39 PM, André Pirard <A.Pirard.Papou at gmail.com>wrote:

>  On 2013-03-15 23:21, A.Pirard.Papou wrote :
>
>  On 2013-03-08 15:42, Travis Kirstine wrote :
>
>   Current MapProxy does not support direct connection to the ArcGIS REST
> API using the export map call.  Fortunately ArcGIS server is able to
> publish WMS services as well and you should be able to use the standard WMS
> connection.  If you are not familiar with ArcGIS server you can view the
> "catalog" of service published and determine if WMS is support (not by
> default) ...
>
> Thanks to Travis I was able to access some of that server's maps with
> WMS.  But not all its maps support WMS.  I was however able to trick
> mapproxy into loading the correct "export map" images with a hacked WMS
> configuration.  But the size of the image was incorrect.
> The only thing missing in the request is   &size=705,509  instead of
> &width=705,&height=509
>
> I have verified that WMS and ArcGIS "disregard noise", i.e. they will both
> accept  "&size=705,509&width=705,&height=509".  In other words, one can
> make the requests "bilingual".
> Mapproxy makes no other calls than equivalent to the one below, does it?
> _ts seems unnecessary.
>
> But I do not know python enough to modify the program to do that
> (/usr/share/pyshared/mapproxy/request/wms/__init__.py ?).
>
> If someone could sketch precisely how to add that  &width=<w>,&height=<h>
> to a WMS request, I would make the update, test it, most probably extend
> the "feature" to the other bilingual parameters and return the update to
> the community.
>
> Cheers,
>
>   André.
>
> http://geoservices.wallonie.be/arcgis/rest/services/TOPOGRAPHIE/PICC/MapServer/export?dpi=96&transparent=true&format=png8&bbox=237697.72401485278,135612.54079507195,240495.69836080144,137632.63858526756&bboxSR=31370&imageSR=31370&size=705,509&_ts=1362703550248&f=image
>
> Hi,
>
> No reply, but ...
> THANKS again Travis who taught me and now THANKS to my friend Jo !!!
> I don't speak a word of Python (just a few notes of Cobra with a flute
> ;-)) but I spent my life dissecting any code and I explained Jo in detail
> and pointed him to the right Python modules. And...
>
> On 2013-04-18 23:22, Jo wrote :
>
>   Maybe like this:
>
> [request/base.py]
>
> def query_string(self):
>         """
>         The map request as a query string (the order is not guaranteed).
>
>         >>> RequestParams(dict(foo='egg', bar='ham%eggs', baz=100)).query_string
>         'baz=100&foo=egg&bar=ham%25eggs'
>         """
>         kv_pairs = []
>         self.params['size']=self.params['width'] + ',' + self.params['height']
>         for key, values in self.params.iteritems():
>             value = ','.join(str(v) for v in values)
>             kv_pairs.append(key + '=' + urllib.quote_plus(value, safe=','))
>         return '&'.join(kv_pairs)
>
>  Let me know if it works,
>
>
> AND IT DOES!!!
> I configured MapProxy as follows:
>
>   SPW_BASE_source:
>     type: wms
>     supported_srs: ['EPSG:31370']
>     image:
>       transparent_color: '#ffffff'
>       transparent_color_tolerance: 20
>     req:
>       url:
> http://geoservices.wallonie.be/arcgis/rest/services/TOPOGRAPHIE/PICC/MapServer/export
> ?
>       dpi: 96
>       bboxSR: 31370
>       imageSR: 31370
>       f: image
>       transparent: true
>       format: png8
> ########## &format=image=png
>
>
> and now I have bilingual requests like this:
>
> [2013-11-19 00:04:44,055] mapproxy.source.request - INFO - GET
> http://geoservices.wallonie.be/arcgis/rest/services/TOPOGRAPHIE/PICC/MapServer/export?styles=&service=WMS
> *&format=image%2Fpng*&*f=image*&request=GetMap&*dpi=96*
> &height=1184&srs=EPSG%3A31370&version=1.1.1&*bboxSR=31370*
> &bbox=234355.499252,140451.789859,236183.948366,142275.440871&
> *imageSR=31370*&width=1187&transparent=True&*size=1187,1184* 200 43.7
> 19366
>
> There's a little hitch, however.  Wouldn't life be dull without? ;-)
> My &format=png8 is overridden by Oliver's &format=image/png :-(
> Not a big deal if it works, but isn't it logical and wouldn't it be
> possible that user specified keys override the others (would be applied
> last)?
>
> Things go better even without Coca Cola ;-)
> for i in range(0, 999): print 'THANKS '
>
> Cheers,
>
>   André.
>
> _______________________________________________
> MapProxy mailing list
> MapProxy at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapproxy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapproxy/attachments/20131118/1a626114/attachment.html>


More information about the MapProxy mailing list