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

Passmore, James H. jpass at bgs.ac.uk
Wed Mar 22 08:26:31 PDT 2017


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.
________________________________


More information about the OWSLib-users mailing list