[OpenLayers-Commits] r1990 - in sandbox/vector/lib/OpenLayers: Geometry Parser
commits at openlayers.org
commits at openlayers.org
Fri Dec 1 12:45:46 EST 2006
Author: pgiraud
Date: 2006-12-01 12:45:43 -0500 (Fri, 01 Dec 2006)
New Revision: 1990
Modified:
sandbox/vector/lib/OpenLayers/Geometry/Polygon.js
sandbox/vector/lib/OpenLayers/Parser/GML.js
Log:
code start to manage polygons with holes
Modified: sandbox/vector/lib/OpenLayers/Geometry/Polygon.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Geometry/Polygon.js 2006-12-01 17:44:00 UTC (rev 1989)
+++ sandbox/vector/lib/OpenLayers/Geometry/Polygon.js 2006-12-01 17:45:43 UTC (rev 1990)
@@ -19,7 +19,8 @@
initialize: function(linearRings) {
OpenLayers.Geometry.Surface.prototype.initialize.apply(this,
arguments);
-
+
+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_");
this.linearRings = [];
if (linearRings instanceof Array) {
@@ -31,6 +32,7 @@
* @returns the coordinates path as a string
*/
toString: function() {
+ // TBD this.path doesn't exist
return this.path.toString();
},
Modified: sandbox/vector/lib/OpenLayers/Parser/GML.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Parser/GML.js 2006-12-01 17:44:00 UTC (rev 1989)
+++ sandbox/vector/lib/OpenLayers/Parser/GML.js 2006-12-01 17:45:43 UTC (rev 1990)
@@ -44,6 +44,8 @@
// Process all the featureMembers
for (var i=0; i < featureNodes.length; i++) {
var feature = this.processXMLNode(featureNodes[i]);
+
+ console.log(feature);
if (feature) {
this.featureCollection.push(feature);
@@ -88,14 +90,8 @@
var polygons = OpenLayers.Ajax.getElementsByTagNameNS(multipolygon,
"http://www.opengis.net/gml", "gml", "Polygon");
for (var i = 0; i < polygons.length; i++) {
- // TBD manage interior rings
- var linearRing = OpenLayers.Ajax.getElementsByTagNameNS(polygons[i], "http://www.opengis.net/gml", "gml", "LinearRing")[0];
-
- points = this.parseCoords(linearRing);
- if(points){
- var polygon = new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing(points)]);
- geom.addComponents(polygon);
- }
+ polygon = this.parsePolygonNode(polygons[i]);
+ geom.addComponents(polygon);
}
}
// match MultiLineString
@@ -136,14 +132,7 @@
var polygon = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
"http://www.opengis.net/gml", "gml", "Polygon")[0];
- // TBD manage interior rings
- var linearRing = OpenLayers.Ajax.getElementsByTagNameNS(polygon,
- "http://www.opengis.net/gml", "gml", "LinearRing")[0];
-
- points = this.parseCoords(linearRing);
- if (points) {
- geom = new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing(points)]);
- }
+ geom = this.parsePolygonNode(polygon);
}
// match LineString
else if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
@@ -167,12 +156,30 @@
}
}
-
feature.setGeometry(geom);
return feature;
},
/**
+ *
+ * @param {XMLNode} xmlNode
+ *
+ * @return {OpenLayers.Geometry.Polygon} polygon geometry
+ */
+ parsePolygonNode: function(polygonNode) {
+ var linearRings = OpenLayers.Ajax.getElementsByTagNameNS(polygonNode,
+ "http://www.opengis.net/gml", "gml", "LinearRing");
+
+ var rings = [];
+ for (var i = 0; i < linearRings.length; i++) {
+ points = this.parseCoords(linearRings[i]);
+ rings.push(new OpenLayers.Geometry.LinearRing(points));
+ }
+
+ return new OpenLayers.Geometry.Polygon(rings);
+ },
+
+ /**
* Extract Geographic coordinates from an XML node.
* @private
* @param {XMLNode} xmlNode
More information about the Commits
mailing list