diff --git a/examples/sos.html b/examples/sos.html
index 6577c931b9..71d3923194 100644
--- a/examples/sos.html
+++ b/examples/sos.html
@@ -133,7 +133,7 @@
responseMode: 'inline',
procedure: feature.attributes.id,
offering: name,
- observedProperty: offering.observedProperties[0],
+ observedProperties: offering.observedProperties,
responseFormat: this.responseFormat
});
OpenLayers.Request.POST({
diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js
index a7024405e5..5a0a6cd634 100644
--- a/lib/OpenLayers.js
+++ b/lib/OpenLayers.js
@@ -287,8 +287,8 @@
"OpenLayers/Format/WMSGetFeatureInfo.js",
"OpenLayers/Format/SOSCapabilities.js",
"OpenLayers/Format/SOSCapabilities/v1_0_0.js",
- "OpenLayers/Format/SOSGetObservation.js",
"OpenLayers/Format/SOSGetFeatureOfInterest.js",
+ "OpenLayers/Format/SOSGetObservation.js",
"OpenLayers/Format/OWSContext.js",
"OpenLayers/Format/OWSContext/v0_3_1.js",
"OpenLayers/Format/WMTSCapabilities.js",
diff --git a/lib/OpenLayers/Format/SOSGetObservation.js b/lib/OpenLayers/Format/SOSGetObservation.js
index 98a3cb8e08..2a02761873 100644
--- a/lib/OpenLayers/Format/SOSGetObservation.js
+++ b/lib/OpenLayers/Format/SOSGetObservation.js
@@ -5,8 +5,7 @@
/**
* @requires OpenLayers/Format/XML.js
- * @requires OpenLayers/Format/GML.js
- * @requires OpenLayers/Format/GML/v3.js
+ * @requires OpenLayers/Format/SOSGetFeatureOfInterest.js
*/
/**
@@ -29,6 +28,7 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
sos: "http://www.opengis.net/sos/1.0",
ogc: "http://www.opengis.net/ogc",
om: "http://www.opengis.net/om/1.0",
+ sa: "http://www.opengis.net/sampling/1.0",
xlink: "http://www.w3.org/1999/xlink",
xsi: "http://www.w3.org/2001/XMLSchema-instance"
},
@@ -88,7 +88,7 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
if(data && data.nodeType == 9) {
data = data.documentElement;
}
- var info = {measurements: []};
+ var info = {measurements: [], observations: []};
this.readNode(data, info);
return info;
},
@@ -105,6 +105,7 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
write: function(options) {
var node = this.writeNode("sos:GetObservation", options);
node.setAttribute("xmlns:om", this.namespaces.om);
+ node.setAttribute("xmlns:ogc", this.namespaces.ogc);
this.setAttributeNS(
node, this.namespaces.xsi,
"xsi:schemaLocation", this.schemaLocation
@@ -134,6 +135,11 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
observationCollection.measurements.push(measurement);
this.readChildNodes(node, measurement);
},
+ "Observation": function(node, observationCollection) {
+ var observation = {};
+ observationCollection.observations.push(observation);
+ this.readChildNodes(node, observation);
+ },
"samplingTime": function(node, measurement) {
var samplingTime = {};
measurement.samplingTime = samplingTime;
@@ -149,6 +155,20 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
this.getAttributeNS(node, this.namespaces.xlink, "href");
this.readChildNodes(node, measurement);
},
+ "featureOfInterest": function(node, observation) {
+ var foi = {features: []};
+ observation.fois = [];
+ observation.fois.push(foi);
+ this.readChildNodes(node, foi);
+ // postprocessing to get actual features
+ var features = [];
+ for (var i=0, len=foi.features.length; i
function test_read_SOSGetObservation(t) {
- t.plan(7);
+ t.plan(13);
var parser = new OpenLayers.Format.SOSGetObservation();
var text =
@@ -49,15 +49,130 @@
t.eq(measurement.result.uom, "Cel", "Units of measurement correctly parsed");
t.eq(measurement.result.value, "4.9", "Value correctly parsed");
t.eq(measurement.samplingTime.timeInstant.timePosition, "2009-12-02T10:35:00.000+01:00", "Sampling time correctly parsed");
+
+ var response = [];
+ response.push('',
+'',
+' ',
+' ',
+' 46.611644 7.6103',
+' 51.9412 13.883498',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' 2009-09-28T13:45:00.000+02:00',
+' 2009-09-28T13:45:00.000+02:00',
+' ',
+' ',
+' ',
+' ',
+' ',
+' resultComponents',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' waether @ roof of the FH Kaernten, Villach, Austria',
+' ',
+' ',
+' ',
+' 46.611644 13.883498',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' 1',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' ',
+' 2009-09-28T13:45:00.000+02:00,urn:ogc:object:feature:OSIRIS-HWS:efeb807b-bd24-4128-a920-f6729bcdd111,0.0;',
+' ',
+' ',
+' ',
+' ',
+'');
+ text = response.join("");
+ var res = parser.read(text);
+ t.eq(res.observations.length, 1, "1 observation parsed");
+ var observation = res.observations[0];
+ t.eq(observation.procedure, "urn:ogc:object:feature:OSIRIS-HWS:efeb807b-bd24-4128-a920-f6729bcdd111", "procedure parsed correctly");
+ t.eq(observation.fois.length, 1, "One foi parsed for the observation");
+ var foi = observation.fois[0];
+ var feature = foi.features[0];
+ t.eq(feature.attributes.id, "urn:ogc:object:feature:OSIRIS-HWS:efeb807b-bd24-4128-a920-f6729bcdd111", "Foi id correctly parsed");
+ t.eq(feature.attributes.name, "waether @ roof of the FH Kaernten, Villach, Austria", "Foi name correctly parsed");
+ t.ok(feature.geometry instanceof OpenLayers.Geometry.Point, "Geometry correctly parsed");
}
function test_write_SOSGetObservation(t) {
- t.plan(1);
+ t.plan(2);
var expect = 'TEMPERATUREurn:ogc:data:time:iso8601latesturn:ogc:object:feature:OSIRIS-HWS:4fc335bc-06d7-4d5e-a72a-1ac73b9f3b56urn:x-ogc:def:property:OGC::Temperaturetext/xml;subtype="om/1.0.0"Measurementinline';
var format = new OpenLayers.Format.SOSGetObservation();
var output = format.write({eventTime: 'latest', resultModel: 'Measurement', responseMode: 'inline',
- procedure: 'urn:ogc:object:feature:OSIRIS-HWS:4fc335bc-06d7-4d5e-a72a-1ac73b9f3b56', responseFormat: 'text/xml;subtype="om/1.0.0"',
- offering: 'TEMPERATURE', observedProperty: 'urn:x-ogc:def:property:OGC::Temperature'});
+ procedures: ['urn:ogc:object:feature:OSIRIS-HWS:4fc335bc-06d7-4d5e-a72a-1ac73b9f3b56'], responseFormat: 'text/xml;subtype="om/1.0.0"',
+ offering: 'TEMPERATURE', observedProperties: ['urn:x-ogc:def:property:OGC::Temperature']});
+ t.xml_eq(output, expect, "Request XML is written out correctly");
+
+ var expected = [];
+
+ expected.push('',
+'',
+' RAIN_GAUGE',
+' ',
+' ',
+' urn:ogc:data:time:iso8601',
+' ',
+' latest',
+' ',
+' ',
+' ',
+' urn:ogc:def:property:OGC::Precipitation1Hour',
+' ',
+' urn:ogc:object:feature:OSIRIS-HWS:3d3b239f-7696-4864-9d07-15447eae2b93',
+' ',
+' text/xml;subtype="om/1.0.0"',
+'');
+ expect = expected.join("");
+ var output = format.write({eventTime: 'latest', offering: 'RAIN_GAUGE',
+ observedProperties: ['urn:ogc:def:property:OGC::Precipitation1Hour'],
+ responseFormat: 'text/xml;subtype="om/1.0.0"',
+ foi: {objectId: 'urn:ogc:object:feature:OSIRIS-HWS:3d3b239f-7696-4864-9d07-15447eae2b93'}});
t.xml_eq(output, expect, "Request XML is written out correctly");
}