[OpenLayers-Commits] r11051 - in sandbox/sonxurxo/sos: examples lib
lib/OpenLayers/Layer lib/OpenLayers/Protocol/SOS
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Fri Jan 21 08:33:59 EST 2011
Author: sonxurxo
Date: 2011-01-21 05:33:59 -0800 (Fri, 21 Jan 2011)
New Revision: 11051
Added:
sandbox/sonxurxo/sos/examples/sosClass.html
sandbox/sonxurxo/sos/lib/OpenLayers/Layer/SOS2.js
Modified:
sandbox/sonxurxo/sos/lib/OpenLayers.js
sandbox/sonxurxo/sos/lib/OpenLayers/Protocol/SOS/v1_0_0_2.js
Log:
Added a SOS convenience class
Added: sandbox/sonxurxo/sos/examples/sosClass.html
===================================================================
--- sandbox/sonxurxo/sos/examples/sosClass.html (rev 0)
+++ sandbox/sonxurxo/sos/examples/sosClass.html 2011-01-21 13:33:59 UTC (rev 11051)
@@ -0,0 +1,60 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
+ <style type="text/css">
+ .sosmap {
+ width: 768px;
+ height: 512px;
+ }
+ </style>
+ <script src="../lib/OpenLayers.js"></script>
+ <script type="text/javascript">
+ var map;
+
+ OpenLayers.ProxyHost = "proxy.cgi?url=";
+
+ OpenLayers.Util.extend(OpenLayers.Lang.en,
+ {
+ 'SOSClientType': "Type",
+ 'SOSClientTime': "Date/time",
+ 'SOSClientLastvalue': "Last value"
+ }
+ );
+
+ function init(){
+ 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"
+ });
+
+ var baseLayer = new OpenLayers.Layer.WMS("Test Layer", "http://vmap0.tiles.osgeo.org/wms/vmap0?", {
+ layers: "basic"}, {singleTile: true});
+ map.addLayers([baseLayer, sosLayer]);
+ map.setCenter(new OpenLayers.LonLat(5, 45), 4);
+ map.addControl( new OpenLayers.Control.LayerSwitcher() );
+ map.addControl( new OpenLayers.Control.MousePosition() );
+ }
+ </script>
+ </head>
+ <body onload="init()">
+ <h1 id="title">SOS client example</h1>
+
+ <div id="tags">
+ sos, sensor, observation, popup, advanced
+ </div>
+ <p id="shortdesc">
+ Shows how to connect OpenLayers to a Sensor Observation Service (SOS)
+ </p>
+ <div id="map" class="sosmap"></div>
+ <div id="docs">
+ <p>This example uses a vector layer with a Protocol.SOS and a fixed Strategy.
+ </p><p>When clicking on a point feature (the weather stations offered by the SOS), the
+ latest values for all offerings are displayed in a popup.</p>
+ </div>
+ </body>
+</html>
Added: sandbox/sonxurxo/sos/lib/OpenLayers/Layer/SOS2.js
===================================================================
--- sandbox/sonxurxo/sos/lib/OpenLayers/Layer/SOS2.js (rev 0)
+++ sandbox/sonxurxo/sos/lib/OpenLayers/Layer/SOS2.js 2011-01-21 13:33:59 UTC (rev 11051)
@@ -0,0 +1,134 @@
+/* Copyright (c) 2006-2010 MetaCarta, Inc., published under the Clear BSD
+ * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license. */
+
+/**
+ * @requires OpenLayers/Layer/Vector.js
+ * @requires OpenLayers/Strategy/Fixed.js
+ * @requires OpenLayers/Protocol/SOS.js
+ * @requires OpenLayers/Format/SOSCapabilities.js
+ */
+
+/**
+ * Class: OpenLayers.Layer.SOS
+ * Convenience layer for accessing Sensor Observation Services (SOS).
+ *
+ * Inherits from:
+ * - <OpenLayers.Layer.Vector>
+ */
+OpenLayers.Layer.SOS2 = OpenLayers.Class(OpenLayers.Layer.Vector, {
+
+ /**
+ * 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
+ *
+ * Example:
+ * (code)
+ * var sos = new OpenLayers.Layer.SOS("Weather stations",
+ * 'http://myhost/sos?');
+ * (end)
+ *
+ * Parameters:
+ * name - {String} A name for the layer
+ * 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) {
+ this.url = url;
+ OpenLayers.Util.extend(options, {
+ styleMap: new OpenLayers.StyleMap({
+ 'default':{
+ strokeColor: "#e8e8e8",
+ strokeOpacity: 1,
+ strokeWidth: 3,
+ fillColor: "#FF5500",
+ fillOpacity: 0.5,
+ pointRadius: 6,
+ pointerEvents: "visiblePainted",
+ label : "${value} ${uom}",
+
+ fontSize: "11px",
+ fontFamily: "Courier New, monospace",
+ fontWeight: "normal",
+ labelAlign: "cm",
+ labelXOffset: "0",
+ labelYOffset: "15"
+ },
+ 'select':{
+ strokeColor: "#a8a8a8",
+ strokeOpacity: 1,
+ strokeWidth: 3,
+ fillColor: "#aa5500",
+ fillOpacity: 0.8,
+ pointRadius: 4,
+ pointerEvents: "visiblePainted",
+ label : "${value} ${uom} (${time})",
+
+ fontSize: "12px",
+ fontFamily: "Courier New, monospace",
+ fontWeight: "bold",
+ labelAlign: "cm",
+ labelXOffset: "0",
+ labelYOffset: "15"
+ }
+ })
+ });
+ OpenLayers.Layer.Vector.prototype.initialize.apply(this,
+ [name, options]);
+ },
+
+ /**
+ * Method: afterAdd
+ * Called at the end of the map.addLayer sequence.
+ */
+ afterAdd: function() {
+ 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);
+ strategy.setLayer(this);
+ strategy.activate();
+
+ this.selectFeature = new OpenLayers.Control.SelectFeature(this, {
+ hover: true
+ });
+ this.map.addControls([this.selectFeature]);
+ this.selectFeature.activate();
+ },
+
+ /**
+ * APIMethod: destroy
+ * 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);
+ },
+
+ CLASS_NAME: "OpenLayers.Layer.SOS2"
+});
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-21 12:37:47 UTC (rev 11050)
+++ sandbox/sonxurxo/sos/lib/OpenLayers/Protocol/SOS/v1_0_0_2.js 2011-01-21 13:33:59 UTC (rev 11051)
@@ -136,8 +136,8 @@
var oAM = this.format.read(doc);
var features = [];
for (var m in oAM.measurements) {
- var foi = oAM.measurements[m].fois[0].features[0];
- var geometry = new OpenLayers.Geometry.Point(foi.geometry.x, foi.geometry.y);
+ var foi = oAM.measurements[m].fois[0].components[0];
+ var geometry = new OpenLayers.Geometry.Point(foi.x, foi.y);
var feature = new OpenLayers.Feature.Vector(geometry, {
value: oAM.measurements[m].result.value,
uom: oAM.measurements[m].result.uom,
Modified: sandbox/sonxurxo/sos/lib/OpenLayers.js
===================================================================
--- sandbox/sonxurxo/sos/lib/OpenLayers.js 2011-01-21 12:37:47 UTC (rev 11050)
+++ sandbox/sonxurxo/sos/lib/OpenLayers.js 2011-01-21 13:33:59 UTC (rev 11051)
@@ -202,6 +202,7 @@
"OpenLayers/Layer/Vector.js",
"OpenLayers/Layer/Vector/RootContainer.js",
"OpenLayers/Layer/SOS.js",
+ "OpenLayers/Layer/SOS2.js",
"OpenLayers/Strategy.js",
"OpenLayers/Strategy/Filter.js",
"OpenLayers/Strategy/Fixed.js",
More information about the Commits
mailing list