Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOS fixes and add a SensorML parsing helper #99

Merged
merged 4 commits into from
Oct 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion owslib/namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ class Namespaces(object):
'rim' : 'urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0',
'rdf' : 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'sml' : 'http://www.opengis.net/sensorML/1.0.1',
'sml101': 'http://www.opengis.net/sensorML/1.0.1',
'sos' : 'http://www.opengis.net/sos/1.0',
'sos20' : 'http://www.opengis.net/sos/2.0',
'srv' : 'http://www.isotc211.org/2005/srv',
'swe' : 'http://www.opengis.net/swe/1.0.1',
'swe10' : 'http://www.opengis.net/swe/1.0',
'swe101': 'http://www.opengis.net/swe/1.0.1',
'swe20': 'http://www.opengis.net/swe/2.0',
'swe20' : 'http://www.opengis.net/swe/2.0',
'swes' : 'http://www.opengis.net/swes/2.0',
'tml' : 'ttp://www.opengis.net/tml',
'wfs' : 'http://www.opengis.net/wfs',
Expand Down
4 changes: 3 additions & 1 deletion owslib/swe/observation/sos100.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_observation(self, responseFormat=None,
request['offering'] = ','.join(offerings)

assert isinstance(observedProperties, list) and len(observedProperties) > 0
request['observedproperty'] = ','.join(observedProperties)
request['observedProperty'] = ','.join(observedProperties)

assert isinstance(responseFormat, str)
request['responseFormat'] = responseFormat
Expand All @@ -168,6 +168,8 @@ def get_observation(self, responseFormat=None,
tr = etree.fromstring(response)
if tr.tag == nspath_eval("ows:ExceptionReport", namespaces):
raise ows.ExceptionReport(tr)
else:
return response
except ows.ExceptionReport:
raise
except BaseException:
Expand Down
4 changes: 3 additions & 1 deletion owslib/swe/observation/sos200.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def get_observation(self, responseFormat=None,
request['offering'] = ','.join(offerings)

assert isinstance(observedProperties, list) and len(observedProperties) > 0
request['observedproperty'] = ','.join(observedProperties)
request['observedProperty'] = ','.join(observedProperties)

if responseFormat is not None:
request['responseFormat'] = responseFormat
Expand All @@ -173,6 +173,8 @@ def get_observation(self, responseFormat=None,
tr = etree.fromstring(response)
if tr.tag == nspath_eval("ows:ExceptionReport", namespaces):
raise ows.ExceptionReport(tr)
else:
return response
except ows.ExceptionReport:
raise
except BaseException:
Expand Down
19 changes: 14 additions & 5 deletions owslib/swe/sensor/sml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from owslib import crs, util
from owslib.util import testXMLValue, testXMLAttribute, nspath_eval, xmltag_split, dict_union, extract_xml_list
from owslib.namespaces import Namespaces
from owslib.swe.common import DataRecord

def get_namespaces():
n = Namespaces()
Expand Down Expand Up @@ -46,14 +45,24 @@ def __init__(self, element):
self.capabilities = {}
for cap in element.findall(nsp('sml:capabilities')):
name = testXMLAttribute(cap, "name")
dr = DataRecord(cap[0])
self.capabilities[name] = dr
self.capabilities[name] = cap[0]

self.characteristics = {}
for cha in element.findall(nsp('sml:characteristics')):
name = testXMLAttribute(cha, "name")
dr = DataRecord(cha[0])
self.characteristics[name] = dr
self.characteristics[name] = cha[0]

def get_capabilities_by_name(self, name):
"""
Return list of element by name, case insensitive
"""
return [self.capabilities[capab] for capab in self.capabilities.keys() if capab.lower() == name.lower()]

def get_characteristics_by_name(self, name):
"""
Return list of element objects by name, case insensitive
"""
return [self.characteristics[charac] for charac in self.characteristics.keys() if charac.lower() == name.lower()]

class ConstraintGroup(object):
def __init__(self, element):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
python-dateutil==1.5
python-dateutil>=1.5
pytz
pytest
pytest-cov
Expand Down