[Mapbender-commits] r7099 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Nov 9 05:38:25 EST 2010


Author: kmq
Date: 2010-11-09 02:38:25 -0800 (Tue, 09 Nov 2010)
New Revision: 7099

Modified:
   trunk/mapbender/http/javascripts/geometry.js
Log:
added support to import WKT LINESTRINGS into a geometry array

Modified: trunk/mapbender/http/javascripts/geometry.js
===================================================================
--- trunk/mapbender/http/javascripts/geometry.js	2010-11-08 10:11:14 UTC (rev 7098)
+++ trunk/mapbender/http/javascripts/geometry.js	2010-11-09 10:38:25 UTC (rev 7099)
@@ -354,8 +354,14 @@
 
 GeometryArray.prototype.importGeometryFromText = function (text, srs) {
 	var i, j, m, currentPoint;
+	// remove whitespace after commata
+	text  = text.replace(/,\s*/, ',');
+	
 	var tmpArray = text.split("(");
-	var geometryType = tmpArray[0];
+	// trim whitespace
+	var geometryType = tmpArray[0].replace(/^\s\s*/, '').replace(/\s\s*$/, '');
+	
+	
 
 	switch (geometryType) {
 		case "MULTIPOLYGON":
@@ -409,6 +415,20 @@
 				this.close();
 			}
 			break;
+
+		case "LINESTRING":
+			// generalize the Linestring to a multilinestring, because that's how Mapbender handles this type of thing
+			// Not generalizing Points, because I am not testing it now and something would later break and I'd have to Rage again
+			// It's probably possible though, to do it by just copying this case and converting all "linestring" to "point" 
+			var multilinestring = text.replace('(','((');
+			var multilinestring = multilinestring.replace(')','))');
+			var multilinestring = multilinestring.replace("LINESTRING","MULTILINESTRING");
+			this.importGeometryFromText(multilinestring,srs);
+			break;
+		break;
+
+		default:
+			throw "Can't Import geometries of Type '" + geometryType + "'";
 	}
 };
 



More information about the Mapbender_commits mailing list