several improvement to the SOSGetObservation Format, p=sonxurxo, r=me (closes #2842)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10902 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2010-11-17 10:06:07 +00:00
parent 7608e867e9
commit 9a3ca5fa7e
4 changed files with 177 additions and 19 deletions

View File

@@ -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<len; i++) {
var feature = foi.features[i];
features.push(new OpenLayers.Feature.Vector(
feature.components[0], feature.attributes));
}
foi.features = features;
},
"result": function(node, measurement) {
var result = {};
measurement.result = result;
@@ -160,6 +180,7 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
}
}
},
"sa": OpenLayers.Format.SOSGetFeatureOfInterest.prototype.readers.sa,
"gml": OpenLayers.Util.applyDefaults({
"TimeInstant": function(node, samplingTime) {
var timeInstant = {};
@@ -169,7 +190,7 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
"timePosition": function(node, timeInstant) {
timeInstant.timePosition = this.getChildValue(node);
}
}, OpenLayers.Format.GML.v3.prototype.readers.gml)
}, OpenLayers.Format.SOSGetFeatureOfInterest.prototype.readers.gml)
},
/**
@@ -188,29 +209,51 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
}
});
this.writeNode("offering", options, node);
this.writeNode("eventTime", options, node);
this.writeNode("procedure", options, node);
this.writeNode("observedProperty", options, node);
if (options.eventTime) {
this.writeNode("eventTime", options, node);
}
for (var procedure in options.procedures) {
this.writeNode("procedure", options.procedures[procedure], node);
}
for (var observedProperty in options.observedProperties) {
this.writeNode("observedProperty", options.observedProperties[observedProperty], node);
}
if (options.foi) {
this.writeNode("featureOfInterest", options.foi, node);
}
this.writeNode("responseFormat", options, node);
this.writeNode("resultModel", options, node);
this.writeNode("responseMode", options, node);
if (options.resultModel) {
this.writeNode("resultModel", options, node);
}
if (options.responseMode) {
this.writeNode("responseMode", options, node);
}
return node;
},
"featureOfInterest": function(foi) {
var node = this.createElementNSPlus("featureOfInterest");
this.writeNode("ObjectID", foi.objectId, node);
return node;
},
"ObjectID": function(options) {
return this.createElementNSPlus("ObjectID",
{value: options});
},
"responseFormat": function(options) {
return this.createElementNSPlus("responseFormat",
{value: options.responseFormat});
},
"procedure": function(options) {
"procedure": function(procedure) {
return this.createElementNSPlus("procedure",
{value: options.procedure});
{value: procedure});
},
"offering": function(options) {
return this.createElementNSPlus("offering", {value:
options.offering});
},
"observedProperty": function(options) {
"observedProperty": function(observedProperty) {
return this.createElementNSPlus("observedProperty",
{value: options.observedProperty});
{value: observedProperty});
},
"eventTime": function(options) {
var node = this.createElementNSPlus("eventTime");