Skip to content

Commit 1a28319

Browse files
authored
add sensorID and table for parameters
1 parent 1c45c6d commit 1a28319

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

geosk/osk/sos.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import cgi
33
from urllib import urlencode
44
from urllib2 import HTTPError
5-
from xml.etree.ElementTree import XML
5+
from xml.etree.ElementTree import fromstring
6+
from owslib.swe.sensor.sml import SensorML
7+
import requests
68

79
from django.conf import settings
810

@@ -71,6 +73,25 @@ def get_sensors(self, full=False):
7173
#ds['description'] = ds['describe_sensor'].sensor_ml.members[0].description
7274
ds['description'] = ds['describe_sensor'].sensor_ml.members[0].description if ds['describe_sensor'].sensor_ml.members[0].description else ds['describe_sensor'].sensor_ml.members[0].identifiers['long name'].value
7375
ds['isvalid'] = True
76+
# for output content in the SensorML
77+
r = requests.get(sensor_id)
78+
root = fromstring(r.content)
79+
ns = {'sml': 'http://www.opengis.net/sensorML/1.0.1', 'swe': 'http://www.opengis.net/swe/1.0.1'}
80+
outputLen = len(root.findall(".//sml:output", ns))
81+
outputs = []
82+
for i in range(outputLen):
83+
if root.findall(".//sml:output[@name]", ns)[i].attrib["name"] != 'phenomenonTime':
84+
oo = {}
85+
oo["definition"] = root.findall(".//sml:output/swe:Quantity[@definition]", ns)[i-1].attrib["definition"]
86+
oo["name"] = root.findall(".//sml:output[@name]", ns)[i].attrib["name"]
87+
try:
88+
oo["uom"] = root.findall(".//sml:output/swe:Quantity/swe:uom[@code]", ns)[i-1].attrib["code"]
89+
except:
90+
oo["uom"] = ""
91+
outputs.append(oo)
92+
# outputs.append([root.findall(".//sml:output/swe:Quantity[@definition]", ns)[i-1].attrib["definition"], root.findall(".//sml:output[@name]", ns)[i].attrib["name"]])
93+
ds['outputs'] = outputs
94+
# end output content in the SensorML
7495
except: #(AttributeError, IndexError, HTTPError):
7596
ds['description'] = 'Invalid Sensor'
7697
ds['isvalid'] = False

0 commit comments

Comments
 (0)