[OWSLib-users] How do you create a Web Map Context (WMC)

Tom Kralidis tomkralidis at gmail.com
Tue Apr 4 12:11:29 PDT 2017


James: WMC support is a darker corner of OWSLib and seems to be (judging by
the lack of response here) less supported than other parts (no docs, no tests).

Having said this, unless we hear otherwise, I think WMC support is as-is for
now and contributions to fix bugs or enhancements/refactoring of WMC support
would be valued.

..Tom


On Wed, 22 Mar 2017, Passmore, James H. wrote:

> Date: Wed, 22 Mar 2017 15:26:31 +0000
> From: "Passmore, James H." <jpass at bgs.ac.uk>
> To: "owslib-users at lists.osgeo.org" <owslib-users at lists.osgeo.org>
> Subject: [OWSLib-users] How do you create a Web Map Context (WMC)
> 
> I'm trying to create a Web Map Context but I'm completely stuck.
>
> I posted a question on GIS.SE as below that gives a summary of my troubles (or perhaps misunderstandings)
>
> https://gis.stackexchange.com/questions/232538/how-do-you-create-a-wmc-with-owslib
>
>
> wmc.py tells us that:
>
> class MapContext:
> """ Map Context abstraction
> It uses a Map representation as input and export it as as map
> context
> """
>
> But I have no idea what a 'Map representation' is.  I thought it might be, or be based on, a WMS GetMap request, but if I call wmc.mapToWebMapContext passing either an actual GetMap URL or if I use OWSLIB to generate the GetMap object I get a similar error along the lines " AttributeError: '...' object has no attribute 'id'
>
> Like:
>
> import owslib.wmc as wmc
> context_for_basemap_map2 = wmc.mapToWebMapContext("http://ogc2.bgs.ac.uk/geoserver/OneG/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&BBOX=-3475652.856302516069,-3703399.183262269478,5088484.602957472205,3983478.759379811119&SRS=EPSG:3413&WIDTH=986&HEIGHT=886&LAYERS=ARCTIC_NASA_BLUEMARBLE&STYLES=&FORMAT=image/jpeg&FORMAT_OPTIONS=dpi:96&ID=some_unique_id1&")
>
> AttributeError: 'str' object has no attribute 'id'
>
> And:
>
> import owslib.wms as wms
> import owslib.wmc as wmc
> w = wms.WebMapService("http://ogc2.bgs.ac.uk/geoserver/OneG/ows?", version='1.1.1')
> img = w.getmap(layers=["ARCTIC_NASA_BLUEMARBLE"], srs='EPSG:3413', bbox=(-3475652, -3703399, 5088484, 3983478), size=(986, 886), format='image/jpeg', transparent=False, method="Get", exceptions="application/vnd.ogc.se_xml", format_options="dpi:96", queryable="0", id="some_unique_id1")
> context_for_basemap_map = wmc.mapToWebMapContext(img)
>
> AttributeError: 'ResponseWrapper' object has no attribute 'id'
>
> Then I thought what if I give the object an 'id'  ~ well that's the reason for adding an ID to the GetMap request/object, which didn't work...
>
> So using the second variant above I tried :
>
> basemap_map.id = uuid.uuid4()
> which got rid of the object has no attribute 'id'  error and takes me to the next error object has no attribute 'size'
>
> so I've now got something like:
>
> img.id = uuid.uuid4()
> img.size = (1205,735)
> img.srs = basemap_params['SRS']
> img.bounds = (-3571059.167819473, -4645193.605181879, 4940480.654283983, 546492.5103750005)
> img.layernames = basemap_params['LAYERS']
> img.layertitles = basemap_context['Title']
>
> which all works (well no error) but I'm now stuck with an error:
>
> 'ResponseWrapper' object has no attribute 'getLayerInfos' and I can't work out what it wants.
>
> Does anybody know what I'm doing wrong, I'm assuming I've missed something obvious.
>
> James
>
> James Passmore
> GIS and WWW Specialist
> -------------------------------
> British Geological Survey,
> Environmental Science Centre,
> KEYWORTH,
> United Kingdom,
> NG12 5GG
> Linked Data (vCard):http://data.bgs.ac.uk/ref/BritishGeologicalSurvey
> w3w:http://w3w.co/firmly.legs.craftsmen
> -------------------------------
> Phone:+44 (0)115 936 3125
> Fax:+44 (0)115 936 3200
> -------------------------------
> jpass at bgs.ac.uk
> http://www.bgs.ac.uk/
> -------------------------------
> Skype:BGSjames
>
> ________________________________
> This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.
> ________________________________
> _______________________________________________
> OWSLib-users mailing list
> OWSLib-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/owslib-users


More information about the OWSLib-users mailing list