improve GPS track support
authorRichard Fairhurst <richard@systemed.net>
Tue, 24 Aug 2010 13:17:43 +0000 (13:17 +0000)
committerRichard Fairhurst <richard@systemed.net>
Tue, 24 Aug 2010 13:17:43 +0000 (13:17 +0000)
net/systemeD/halcyon/VectorLayer.as
net/systemeD/potlatch2/VectorSourceDialog.mxml
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/DrawWay.as
net/systemeD/potlatch2/utils/GpxImporter.as
net/systemeD/potlatch2/utils/TrackLoader.as
resources/gpx.css [new file with mode: 0644]
resources/stylesheets.xml

index b27e0e8..5648308 100644 (file)
@@ -90,6 +90,9 @@ package net.systemeD.halcyon {
                                paint.wayuis[oldWay.id].redraw();
                                delete ways[oldWay.id];
                                map.paint.createWayUI(newWay);
+                       } else {
+                               // ** should be able to pull nodes through
+                               trace ("Pulling nodes through isn't supported yet");
                        }
                        return newWay;
                }
index d626b3b..732d7dc 100644 (file)
 
        private function loadFiles(url:String,type:String,simplify:Boolean):void {
                var names:Array=url.split('/'); var name:String=names[names.length-1];
-               var vectorlayer:VectorLayer=new VectorLayer(name,map,"potlatch.css");
+               var stylesheet:String="potlatch.css";
+               if (type=='gpx') { stylesheet="gpx.css"; }
+               var vectorlayer:VectorLayer=new VectorLayer(name,map,stylesheet);
                vectorlayer.url=url;
                map.addVectorLayer(vectorlayer);
 
index 42e1286..4556db9 100644 (file)
@@ -65,7 +65,9 @@ package net.systemeD.potlatch2.controller {
                        if ( paint && paint.isBackground ) {
                                if ( event.type == MouseEvent.MOUSE_DOWN && ((event.shiftKey && event.ctrlKey) || event.altKey) ) {
                                        // pull data out of vector background layer
-                                       if (entity is Way) { return new SelectedWay(paint.findSource().pullThrough(entity,controller.connection)); }
+                                       var newEntity:Entity=paint.findSource().pullThrough(entity,controller.connection);
+                                       if (entity is Way) { return new SelectedWay(newEntity); }
+                                       else if (entity is Node) { return new SelectedPOINode(newEntity); }
                                }
                                return (this is NoSelection) ? this : new NoSelection();
                        }
index b63bc3b..d74dda3 100644 (file)
@@ -1,11 +1,13 @@
 package net.systemeD.potlatch2.controller {
        import flash.events.*;
        import flash.geom.*;
+       import flash.display.DisplayObject;
        import flash.ui.Keyboard;
        import net.systemeD.potlatch2.EditController;
        import net.systemeD.halcyon.connection.*;
        import net.systemeD.halcyon.Elastic;
        import net.systemeD.halcyon.Globals;
+       import net.systemeD.halcyon.MapPaint;
 
        public class DrawWay extends SelectedWay {
                private var elastic:Elastic;
@@ -31,11 +33,14 @@ package net.systemeD.potlatch2.controller {
                override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
                        var mouse:Point;
                        var node:Node;
+                       var paint:MapPaint = getMapPaint(DisplayObject(event.target));
+                       var isBackground:Boolean = paint && paint.isBackground;
+
                        if (entity == null && hoverEntity) { entity=hoverEntity; }
                        var focus:Entity = getTopLevelFocusEntity(entity);
 
                        if ( event.type == MouseEvent.MOUSE_UP ) {
-                               if ( entity == null ) {
+                               if ( entity == null || isBackground ) {
                                        node = createAndAddNode(event);
                                        resetElastic(node);
                                        lastClick=node;
@@ -89,7 +94,7 @@ package net.systemeD.potlatch2.controller {
                                                  controller.map.coord2lon(event.localX),
                                                  controller.map.coord2latp(event.localY));
                                elastic.end = mouse;
-                       } else if ( event.type == MouseEvent.ROLL_OVER ) {
+                       } else if ( event.type == MouseEvent.ROLL_OVER && !isBackground ) {
                                if (focus!=selectedWay) {
                                        hoverEntity=focus;
                                        controller.map.setHighlightOnNodes(focus as Way, { hoverway: true });
@@ -102,7 +107,7 @@ package net.systemeD.potlatch2.controller {
                                } else {
                                        controller.setCursor(controller.pen_plus);
                                }
-                       } else if ( event.type == MouseEvent.MOUSE_OUT ) {
+                       } else if ( event.type == MouseEvent.MOUSE_OUT && !isBackground ) {
                                if (entity!=selectedWay) {
                                        hoverEntity=null;
                                        controller.map.setHighlightOnNodes(focus as Way, { hoverway: false });
index 874e289..f39b980 100644 (file)
@@ -32,8 +32,11 @@ package net.systemeD.potlatch2.utils {
                                }
                        }
                        for each (var wpt:XML in file.child("wpt")) {
-                               // ** could potentially get the children and add them as gpx:tags
-                               container.createNode({}, wpt.lat, wpt.lon);
+                               var tags:Object={};
+                               for each (var tag:XML in wpt.children()) {
+                                       tags[tag.name()]=tag.toString();
+                               }
+                               container.createNode(tags, wpt.@lat, wpt.@lon);
                        }
                }
        }
index f2067f4..11017e3 100644 (file)
@@ -7,8 +7,6 @@ package net.systemeD.potlatch2.utils {
        import flash.events.*;
 
        /* still to do:
-       - don't join to GPS track when you click on it
-       - light-blue colour
        - empty layer on reload
        - cope with tracks with timestamps */
 
@@ -24,7 +22,7 @@ package net.systemeD.potlatch2.utils {
                private var map:Map;
                private var apiBaseURL:String;
 
-               private static const STYLESHEET:String="wireframe.css";
+               private static const STYLESHEET:String="gpx.css";
                
                public function TrackLoader(map:Map, url:String) {
                        this.map=map;
diff --git a/resources/gpx.css b/resources/gpx.css
new file mode 100644 (file)
index 0000000..fe08e31
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+
+       Wireframe stylesheet for GPS tracks
+       
+*/
+
+way { z-index: 2; width: 1; color: cyan; } 
+node :poi { z-index: 2; 
+                       icon-image: circle; icon-width: 4; color: orange; 
+                       casing-color: red; casing-width: 1; 
+                       text-offset: 10; font-family: DejaVu; text: name; font-size: 9; text_color: red; }
+
index 122e290..6752518 100755 (executable)
@@ -13,4 +13,8 @@
         <name>OpenCycleMap</name>
         <url>opencyclemap.css</url>
     </stylesheet>
+    <stylesheet>
+        <name>GPS</name>
+        <url>gpx.css</url>
+    </stylesheet>
 </stylesheets>