[OpenLayers-Commits] r11061 - in sandbox/sonxurxo/sos: examples lib/OpenLayers/Layer lib/OpenLayers/Protocol/SOS

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Jan 26 07:25:36 EST 2011


Author: sonxurxo
Date: 2011-01-26 04:25:36 -0800 (Wed, 26 Jan 2011)
New Revision: 11061

Modified:
   sandbox/sonxurxo/sos/examples/sosClass.html
   sandbox/sonxurxo/sos/lib/OpenLayers/Layer/SOS2.js
   sandbox/sonxurxo/sos/lib/OpenLayers/Protocol/SOS/v1_0_0_2.js
Log:
Added reprojecting capabilities to SOS2 layer and SOS/v1_0_0_2 protocol

Modified: sandbox/sonxurxo/sos/examples/sosClass.html
===================================================================
--- sandbox/sonxurxo/sos/examples/sosClass.html	2011-01-26 11:32:44 UTC (rev 11060)
+++ sandbox/sonxurxo/sos/examples/sosClass.html	2011-01-26 12:25:36 UTC (rev 11061)
@@ -26,11 +26,15 @@
             map = new OpenLayers.Map( 'map' );
             var url  = 'http://v-swe.uni-muenster.de:8080/WeatherSOS/sos?';
             var sosLayer = new OpenLayers.Layer.SOS2("Stations", url, {
-                offering: "RAIN_GAUGE",
-                observedProperties: ["urn:ogc:def:property:OGC::Precipitation1Hour"],
-                responseFormat: 'text/xml;subtype="om/1.0.0"',
-                resultModel: "om:Measurement",
-                eventTime: "latest"
+                    offering: "RAIN_GAUGE",
+                    observedProperties: ["urn:ogc:def:property:OGC::Precipitation1Hour"],
+                    responseFormat: 'text/xml;subtype="om/1.0.0"',
+                    resultModel: "om:Measurement",
+                    eventTime: "latest"
+//                }
+//, {
+//                    srcSRS: new OpenLayers.Projection("EPSG:4326"),
+//                    dstSRS: new OpenLayers.Projection("EPSG:900913")
             });
 
             var baseLayer = new OpenLayers.Layer.WMS("Test Layer", "http://vmap0.tiles.osgeo.org/wms/vmap0?", {

Modified: sandbox/sonxurxo/sos/lib/OpenLayers/Layer/SOS2.js
===================================================================
--- sandbox/sonxurxo/sos/lib/OpenLayers/Layer/SOS2.js	2011-01-26 11:32:44 UTC (rev 11060)
+++ sandbox/sonxurxo/sos/lib/OpenLayers/Layer/SOS2.js	2011-01-26 12:25:36 UTC (rev 11061)
@@ -18,31 +18,15 @@
  */
 OpenLayers.Layer.SOS2 = OpenLayers.Class(OpenLayers.Layer.Vector, {
 
+    params: null,
+
     /**
      * APIProperty: url
      * {String} The url of the Sensor Observation Service (SOS)
      */
     url: null,
 
-    offering: null,
-
-    observedProperties: [],
-
-    resultModel: null,
-
-    responseFormat: null,
-
-    eventTime: 'latest',
-
     /**
-     * APIProperty: sosCache
-     * {Object} Cache to use for storing parsed results from
-     *     <OpenLayers.Format.SOSCapabilities.read>. If not provided,
-     *     these will be cached on the prototype.
-     */
-    sosCache: {},
-
-    /**
      * Constructor: OpenLayers.Layer.SOS
      * Create a new SOS layer object
      *
@@ -57,8 +41,9 @@
      * url - {String} Base url for the Sensor Observation Service
      * options - {Ojbect} Hashtable of extra options to tag onto the layer
      */
-    initialize: function(name, url, options) {
+    initialize: function(name, url, params, options) {
         this.url = url;
+        options = options || {};
         OpenLayers.Util.extend(options, {
             styleMap: new OpenLayers.StyleMap({
                         'default':{
@@ -97,6 +82,7 @@
                         }
                     })
         });
+        this.params = OpenLayers.Util.extend( {}, params);
         OpenLayers.Layer.Vector.prototype.initialize.apply(this, 
             [name, options]);
     },
@@ -109,8 +95,15 @@
         var strategy = new OpenLayers.Strategy.Fixed();
         this.strategies = [strategy];
 
-        OpenLayers.Util.extend(this.options, {url: this.url});
-        this.protocol = new OpenLayers.Protocol.SOS.v1_0_0_2(this.options);
+        var protocolOptions = {};
+        OpenLayers.Util.extend(protocolOptions, this.params);
+        OpenLayers.Util.extend(protocolOptions, {url: this.url});
+        if (this.options.srcSRS && this.options.dstSRS) {
+            OpenLayers.Util.extend(protocolOptions, {srcSRS: this.options.srcSRS, 
+                dstSRS: this.options.dstSRS
+            });
+        }
+        this.protocol = new OpenLayers.Protocol.SOS.v1_0_0_2(protocolOptions);
         strategy.setLayer(this);
         strategy.activate();
 
@@ -126,7 +119,6 @@
      * Take care of things that are not handled in the superclass.
      */
     destroy: function() {
-        delete this.sosCache[this.id];
         OpenLayers.Layer.Vector.prototype.destroy.apply(this, arguments);
     },
 

Modified: sandbox/sonxurxo/sos/lib/OpenLayers/Protocol/SOS/v1_0_0_2.js
===================================================================
--- sandbox/sonxurxo/sos/lib/OpenLayers/Protocol/SOS/v1_0_0_2.js	2011-01-26 11:32:44 UTC (rev 11060)
+++ sandbox/sonxurxo/sos/lib/OpenLayers/Protocol/SOS/v1_0_0_2.js	2011-01-26 12:25:36 UTC (rev 11061)
@@ -18,23 +18,7 @@
  */
  OpenLayers.Protocol.SOS.v1_0_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
 
-    offering: null,
-
-    observedProperties: [],
-
-    resultModel: null,
-
-    responseFormat: null,
-
-    eventTime: 'latest',
-
     /**
-     * APIProperty: fois
-     * {Array(String)} Array of features of interest (foi)
-     */
-//    fois: null,
-
-    /**
      * Property: formatOptions
      * {Object} Optional options for the format.  If a format is not provided,
      *     this property can be used to extend the default format options.
@@ -137,7 +121,15 @@
         var features = [];
         for (var i=0, len=oAM.measurements.length; i < len; i++) {
             var foi = oAM.measurements[i].fois[0].components[0];
-            var geometry = new OpenLayers.Geometry.Point(foi.x, foi.y);
+            var geometry;
+            if (this.options.srcSRS && this.options.dstSRS) {
+                var transformed = OpenLayers.Projection.transform({x:foi.x, y:foi.y}, 
+                    this.options.srcSRS, this.options.dstSRS);
+                geometry = new OpenLayers.Geometry.Point(transformed.x, transformed.y);
+            }
+            else {
+                geometry = new OpenLayers.Geometry.Point(foi.x, foi.y);
+            }
             var feature = new OpenLayers.Feature.Vector(geometry, {
                 value: oAM.measurements[i].result.value,
                 uom: oAM.measurements[i].result.uom,



More information about the Commits mailing list