Don't auto-split GPX files, only /trackpoints data
authorRichard Fairhurst <richard@systemeD.net>
Tue, 3 Jan 2012 18:26:45 +0000 (18:26 +0000)
committerRichard Fairhurst <richard@systemeD.net>
Tue, 3 Jan 2012 18:26:45 +0000 (18:26 +0000)
net/systemeD/halcyon/connection/Trace.as
net/systemeD/potlatch2/utils/TrackLoader.as

index 2de1bdb404a6c8edcac0b4c8b4feca088169c689..d3bc0f2d8cb8f6bd325679d2040a6b70b921973e 100644 (file)
@@ -126,7 +126,7 @@ package net.systemeD.halcyon.connection {
                                }
                        }
 
-                       Trace.parseTrkSegs(file,connection,action);
+                       Trace.parseTrkSegs(file,connection,action,false);
                        
             for each (var wpt:XML in file.wpt) {
                 var tags:Object = {};
@@ -143,9 +143,10 @@ package net.systemeD.halcyon.connection {
         }
 
                /* Draw ways from <trkseg>s, with elementary filter to remove points within 3 metres of each other. 
+                  Optionally split way if more than 50m from previous point.
                   FIXME: do auto-joining of dupes as per Importer. */
 
-               public static function parseTrkSegs(file:XML, connection:Connection, action:CompositeUndoableAction):void {
+               public static function parseTrkSegs(file:XML, connection:Connection, action:CompositeUndoableAction, smartSplitting:Boolean=false):void {
                        for each (var ns:Namespace in file.namespaceDeclarations()) {
                                if (ns.uri.match(/^http:\/\/www\.topografix\.com\/GPX\/1\/[01]$/)) { default xml namespace = ns; }
                        }
@@ -160,8 +161,8 @@ package net.systemeD.halcyon.connection {
                                        if (isNaN(lastlat)) { lastlat = lat; lastlon = lon; }
                                        dist=Trace.greatCircle(lat, lon, lastlat, lastlon);
                                        if (dist>3) {
-                                               if (dist>50 || nodestring.length>500) {
-                                                       if (dist<=50) nodestring.push(connection.createNode({}, lat, lon, action.push));
+                                               if ((dist>50 && smartSplitting) || nodestring.length>500) {
+                                                       if (dist<=50 || !smartSplitting) nodestring.push(connection.createNode({}, lat, lon, action.push));
                                                        if (nodestring.length>1) connection.createWay({}, nodestring, action.push);
                                                        nodestring=[];
                                                }
index c2b1f9fe1b3ca5205b6ed9d9dceb80b57ccd5466..468d42b7d6c1379361bea22d0e17afed4bb59140 100644 (file)
@@ -62,7 +62,7 @@ package net.systemeD.potlatch2.utils {
                private function parseGPX(event:Event):void {
                        var file:XML = new XML(event.target.data);
                        var action:CompositeUndoableAction = new CompositeUndoableAction("add track objects");
-                       Trace.parseTrkSegs(file,connection,action);
+                       Trace.parseTrkSegs(file,connection,action,true);
             action.doAction(); /* just do it, don't add to undo stack */
                        layer.updateEntityUIs(false, false);
                }