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

Passmore, James H. jpass at bgs.ac.uk
Thu Apr 6 04:04:36 PDT 2017


Tom,

Thanks for replying, I am no Python expert, but from my explorations I would say that WMC is currently broken in OWSLib.

I changed def _getLayerListElement(self),  in wmc.py setting layer_infos to False, (I just can't work out what was required, other than it relates to layer styles in some fahion) changed my inputs slightly and was able to generate an invalid version 1.0.0 WMC.  After a bit more hacking of wmc.py  I have a valid WMC, but it only has one layer so it's not particularly useful.  It appears that there is some logical error in the code, you can add a list of layer names and titles but not a list of service URLs, so your context would only be able to have a set of layers from the same server.

I'll try to fix the URL issue, then what?

James



-----Original Message-----
From: Tom Kralidis [mailto:tom.kralidis at gmail.com] On Behalf Of Tom Kralidis
Sent: 04 April 2017 20:11
To: Passmore, James H. <jpass at bgs.ac.uk>
Cc: owslib-users at lists.osgeo.org
Subject: Re: [OWSLib-users] How do you create a Web Map Context (WMC)


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?SERVI
> CE=WMS&VERSION=1.1.1&REQUEST=GetMap&BBOX=-3475652.856302516069,-370339
> 9.183262269478,5088484.602957472205,3983478.759379811119&SRS=EPSG:3413
> &WIDTH=986&HEIGHT=886&LAYERS=ARCTIC_NASA_BLUEMARBLE&STYLES=&FORMAT=ima
> ge/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
________________________________
 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