Changeset 2657
- Timestamp:
- 03/11/07 00:18:40 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/vector-2.4/lib/OpenLayers/Format/KML.js
r2655 r2657 26 26 } 27 27 var featureNodes = OpenLayers.Ajax.getElementsByTagNameNS(data, this.kmlns, "", "Placemark"); 28 29 // We only support 2D at the moment30 this.dim = 2;31 28 32 29 var features = []; … … 64 61 if (p.points) { 65 62 geom = p.points[0]; 63 // TBD Bounds only set for one of multiple geometries 64 geom.extendBounds(p.bounds); 65 } 66 67 // match LineString 68 } else if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 69 this.kmlns, "", "LineString").length != 0) { 70 var linestring = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 71 this.kmlns, "", "LineString")[0]; 72 p = this.parseCoords(linestring); 73 if (p.points) { 74 geom = new OpenLayers.Geometry.LineString(p.points); 66 75 // TBD Bounds only set for one of multiple geometries 67 76 geom.extendBounds(p.bounds); … … 115 124 parseCoords: function(xmlNode) { 116 125 var p = []; 117 p.points = [];126 p.points = []; 118 127 // TBD: Need to handle an array of coordNodes not just coordNodes[0] 119 128 120 var coordString = OpenLayers.Util.getXmlNodeValue(xmlNode); 129 var coordNodes = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.kmlns, "", "coordinates")[0]; 130 var coordString = OpenLayers.Util.getXmlNodeValue(coordNodes); 121 131 132 var firstCoord = coordString.split(" "); 133 134 while (firstCoord[0] == "") 135 firstCoord.shift(); 136 137 var dim = firstCoord[0].split(",").length; 138 122 139 // Extract an array of Numbers from CoordString 123 140 var nums = (coordString) ? coordString.split(/[, \n\t]+/) : []; 141 124 142 125 143 // Remove elements caused by leading and trailing white space … … 130 148 nums.pop(); 131 149 132 for(i = 0; i < nums.length; i = i + this.dim) {150 for(i = 0; i < nums.length; i = i + dim) { 133 151 x = parseFloat(nums[i]); 134 152 y = parseFloat(nums[i+1]);
