1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
6 * @requires OpenLayers/Feature.js
10 * Class: OpenLayers.Feature.WFS
11 * WFS handling class, for use as a featureClass on the WFS layer for handling
12 * 'point' WFS types. Good for subclassing when creating a custom WFS like
16 * - <OpenLayers.Feature>
18 OpenLayers.Feature.WFS = OpenLayers.Class(OpenLayers.Feature, {
21 * Constructor: OpenLayers.Feature.WFS
22 * Create a WFS feature.
25 * layer - {<OpenLayers.Layer>}
28 initialize: function(layer, xmlNode) {
29 var newArguments = arguments;
30 var data = this.processXMLNode(xmlNode);
31 newArguments = new Array(layer, data.lonlat, data);
32 OpenLayers.Feature.prototype.initialize.apply(this, newArguments);
34 this.layer.addMarker(this.marker);
39 * nullify references to prevent circular references and memory leaks
42 if (this.marker != null) {
43 this.layer.removeMarker(this.marker);
45 OpenLayers.Feature.prototype.destroy.apply(this, arguments);
49 * Method: processXMLNode
50 * When passed an xmlNode, parses it for a GML point, and passes
51 * back an object describing that point.
53 * For subclasses of Feature.WFS, this is the feature to change.
59 * {Object} Data Object with 'id', 'lonlat', and private properties set
61 processXMLNode: function(xmlNode) {
62 //this should be overridden by subclasses
63 // must return an Object with 'id' and 'lonlat' values set
64 var point = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://www.opengis.net/gml", "gml", "Point");
65 var text = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(point[0], "http://www.opengis.net/gml","gml", "coordinates")[0]);
66 var floats = text.split(",");
67 return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]),
68 parseFloat(floats[1])),
73 CLASS_NAME: "OpenLayers.Feature.WFS"