]> git.openstreetmap.org Git - rails.git/blob - public/lib/OpenLayers/Feature/WFS.js
Booleans should be true/false - coding style comments welcome
[rails.git] / public / lib / OpenLayers / Feature / WFS.js
1 /* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
2  * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
3  * text of the license. */
4 /**\r
5  * @class\r
6  */\r
7 OpenLayers.Feature.WFS = Class.create();\r
8 OpenLayers.Feature.WFS.prototype = \r
9   Object.extend( new OpenLayers.Feature(), {\r
10       \r
11     /** \r
12      * @constructor\r
13      * \r
14      * @param {OpenLayers.Layer} layer\r
15      * @param {XMLNode} xmlNode\r
16      */\r
17     initialize: function(layer, xmlNode) {\r
18         var newArguments = arguments;\r
19         if (arguments.length > 0) {\r
20             var data = this.processXMLNode(xmlNode);\r
21             newArguments = new Array(layer, data.lonlat, data, data.id)\r
22         }\r
23         OpenLayers.Feature.prototype.initialize.apply(this, newArguments);\r
24         \r
25         if (arguments.length > 0) {\r
26             this.createMarker();\r
27             this.layer.addMarker(this.marker);\r
28         }\r
29     },\r
30     \r
31     destroy: function() {\r
32         if (this.marker != null) {\r
33             this.layer.removeMarker(this.marker);  \r
34         }\r
35         OpenLayers.Feature.prototype.destroy.apply(this, arguments);\r
36     },\r
37 \r
38     /**\r
39      * @param {XMLNode} xmlNode\r
40      * \r
41      * @returns Data Object with 'id', 'lonlat', and private properties set\r
42      * @type Object\r
43      */\r
44     processXMLNode: function(xmlNode) {\r
45         //this should be overridden by subclasses\r
46         // must return an Object with 'id' and 'lonlat' values set\r
47         var point = xmlNode.getElementsByTagName("Point");
48         var text  = point[0].textContent;
49         var floats = text.split(",");
50
51         return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]),
52                                               parseFloat(floats[1])),
53                 id: null};
54
55     },\r
56     \r
57     /** @final @type String */\r
58     CLASS_NAME: "OpenLayers.Feature.WFS"\r
59 });\r
60   \r
61   \r
62   \r
63   \r
64 \r