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
|
|
5
|
/**
|
6
|
* @class
|
7
|
*
|
8
|
* @requires OpenLayers/Feature.js
|
9
|
*/
|
10
|
OpenLayers.Feature.WFS = Class.create();
|
11
|
OpenLayers.Feature.WFS.prototype =
|
12
|
Object.extend( new OpenLayers.Feature(), {
|
13
|
|
14
|
/**
|
15
|
* @constructor
|
16
|
*
|
17
|
* @param {OpenLayers.Layer} layer
|
18
|
* @param {XMLNode} xmlNode
|
19
|
*/
|
20
|
initialize: function(layer, xmlNode) {
|
21
|
var newArguments = arguments;
|
22
|
if (arguments.length > 0) {
|
23
|
var data = this.processXMLNode(xmlNode);
|
24
|
newArguments = new Array(layer, data.lonlat, data)
|
25
|
}
|
26
|
OpenLayers.Feature.prototype.initialize.apply(this, newArguments);
|
27
|
|
28
|
if (arguments.length > 0) {
|
29
|
this.createMarker();
|
30
|
this.layer.addMarker(this.marker);
|
31
|
}
|
32
|
},
|
33
|
|
34
|
destroy: function() {
|
35
|
if (this.marker != null) {
|
36
|
this.layer.removeMarker(this.marker);
|
37
|
}
|
38
|
OpenLayers.Feature.prototype.destroy.apply(this, arguments);
|
39
|
},
|
40
|
|
41
|
/**
|
42
|
* @param {XMLNode} xmlNode
|
43
|
*
|
44
|
* @returns Data Object with 'id', 'lonlat', and private properties set
|
45
|
* @type Object
|
46
|
*/
|
47
|
processXMLNode: function(xmlNode) {
|
48
|
//this should be overridden by subclasses
|
49
|
// must return an Object with 'id' and 'lonlat' values set
|
50
|
var point = xmlNode.getElementsByTagName("Point");
|
51
|
var text = OpenLayers.Util.getXmlNodeValue(point[0].getElementsByTagName("coordinates")[0]);
|
52
|
var floats = text.split(",");
|
53
|
return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]),
|
54
|
parseFloat(floats[1])),
|
55
|
id: null};
|
56
|
|
57
|
},
|
58
|
|
59
|
/** @final @type String */
|
60
|
CLASS_NAME: "OpenLayers.Feature.WFS"
|
61
|
});
|
62
|
|
63
|
|
64
|
|
65
|
|
66
|
|