]> git.openstreetmap.org Git - rails.git/blobdiff - public/lib/OpenLayers/Feature/WFS.js
openlayers madness
[rails.git] / public / lib / OpenLayers / Feature / WFS.js
diff --git a/public/lib/OpenLayers/Feature/WFS.js b/public/lib/OpenLayers/Feature/WFS.js
new file mode 100644 (file)
index 0000000..b2eb0f5
--- /dev/null
@@ -0,0 +1,64 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
+ * text of the license. */
+/**\r
+ * @class\r
+ */\r
+OpenLayers.Feature.WFS = Class.create();\r
+OpenLayers.Feature.WFS.prototype = \r
+  Object.extend( new OpenLayers.Feature(), {\r
+      \r
+    /** \r
+     * @constructor\r
+     * \r
+     * @param {OpenLayers.Layer} layer\r
+     * @param {XMLNode} xmlNode\r
+     */\r
+    initialize: function(layer, xmlNode) {\r
+        var newArguments = arguments;\r
+        if (arguments.length > 0) {\r
+            var data = this.processXMLNode(xmlNode);\r
+            newArguments = new Array(layer, data.lonlat, data, data.id)\r
+        }\r
+        OpenLayers.Feature.prototype.initialize.apply(this, newArguments);\r
+        \r
+        if (arguments.length > 0) {\r
+            this.createMarker();\r
+            this.layer.addMarker(this.marker);\r
+        }\r
+    },\r
+    \r
+    destroy: function() {\r
+        if (this.marker != null) {\r
+            this.layer.removeMarker(this.marker);  \r
+        }\r
+        OpenLayers.Feature.prototype.destroy.apply(this, arguments);\r
+    },\r
+\r
+    /**\r
+     * @param {XMLNode} xmlNode\r
+     * \r
+     * @returns Data Object with 'id', 'lonlat', and private properties set\r
+     * @type Object\r
+     */\r
+    processXMLNode: function(xmlNode) {\r
+        //this should be overridden by subclasses\r
+        // must return an Object with 'id' and 'lonlat' values set\r
+        var point = xmlNode.getElementsByTagName("Point");
+        var text  = point[0].textContent;
+        var floats = text.split(",");
+
+        return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]),
+                                              parseFloat(floats[1])),
+                id: null};
+
+    },\r
+    \r
+    /** @final @type String */\r
+    CLASS_NAME: "OpenLayers.Feature.WFS"\r
+});\r
+  \r
+  \r
+  \r
+  \r
+\r