Automatically close KML polygons
authorRichard Fairhurst <richard@systemeD.net>
Fri, 5 Oct 2012 09:09:35 +0000 (10:09 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Fri, 5 Oct 2012 09:09:35 +0000 (10:09 +0100)
net/systemeD/potlatch2/utils/KmlImporter.as

index ea846d1..6353068 100644 (file)
@@ -90,12 +90,13 @@ package net.systemeD.potlatch2.utils {
         private function importWay(coordinates:String, tags:Object, polygon:Boolean, push:Function): Way {
             var way:Way;
             var nodestring:Array = [];
+            var nodemap:Object = [];
 
-            if (polygon) {
-                coordinates = coordinates.slice(0, coordinates.lastIndexOf(" "));
-            }
+            var tuples:Array=coordinates.split(" ");
+            if (tuples[0]==tuples[tuples.length-1]) { polygon=true; }
+            if (polygon) { tuples.splice(-1,1); }
 
-            for each (var tuple:String in coordinates.split(" ")) {
+            for each (var tuple:String in tuples) {
                 var coords:Array = tuple.split(",");
                 var lon:Number = coords[0];
                 var lat:Number = coords[1];