Remove VectorLayer.as. Cursory check suggests all the vectorlayer-based refactoring...
authorAndy Allan <andy@gravitystorm.co.uk>
Thu, 26 May 2011 16:15:22 +0000 (17:15 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Thu, 26 May 2011 16:15:22 +0000 (17:15 +0100)
REFACTOR.txt
net/systemeD/halcyon/VectorLayer.as [deleted file]

index 7945e60..e4a639b 100644 (file)
@@ -25,11 +25,6 @@ MapPaint.as
 - wayuis, nodeuis etc. should ideally be private
 - removeLayer should blank
 
-VectorLayer.as is completely derelict
-- move into Connection
-- references in Loader classes etc. currently commented out
-- everything derived from VectorLayers (e.g. Traces, Bugs, BikeShopLoader) needs completely refactoring
-
 Global changes:
 - remove all back-references to Map except where necessary for lat/long/scale
 - getParam is messy - stuff sent via flashvars needs somewhere to live: currently in Globals which is ugly
diff --git a/net/systemeD/halcyon/VectorLayer.as b/net/systemeD/halcyon/VectorLayer.as
deleted file mode 100644 (file)
index 04e2ba8..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-package net.systemeD.halcyon {
-
-       import net.systemeD.halcyon.Map;
-       import net.systemeD.halcyon.MapPaint;
-       import net.systemeD.halcyon.connection.*;
-    import net.systemeD.halcyon.connection.actions.*;
-       import net.systemeD.halcyon.styleparser.RuleSet;
-
-    /** The VectorLayer class is used for the concept of Vector Background Layers.
-    * It is similar in concept to the various Connection layers used for the core
-    * OpenStreetMap data, and as such it stores its own list of nodes, ways and relations.
-    * The most interesting function is pullThrough which allows moving entities out
-    * of a VectorLayer and into the main map layer
-    */
-       public class VectorLayer extends Object {
-
-               public var map:Map;
-               public var paint:MapPaint;                                              // sprites
-               public var name:String;
-               public var url:String;
-               public var style:String='';
-
-               public var ways:Object=new Object();                    // geodata
-               public var nodes:Object=new Object();                   //  |
-               public var relations:Object=new Object();               //  |
-               private var pois:Array=[];                                              //  |
-
-        private var markers:Object=new Object();        // markers
-        private var negativeID:Number = -1;
-
-        /** Create a new VectorLayer
-        * @param n The name of the VectorLayer (eg 'GPS tracks')
-        * @param m The map. You probably have a global reference to this
-        * @param s The style you wish to use (eg 'gpx.css')
-        */
-               public function VectorLayer(n:String,m:Map,s:String) {
-                       name=n;
-                       map=m;
-                       style=s;
-                               // >>>> REFACTOR: VectorLayer commented out
-//                     paint=new MapPaint(m,0,0);
-                       redrawFromCSS(style);
-               }
-
-               public function redrawFromCSS(style:String):void {
-                       paint.ruleset=new RuleSet(map.MINSCALE,map.MAXSCALE,paint.redraw,paint.redrawPOIs);
-                       paint.ruleset.loadFromCSS(style);
-               }
-
-        /** Create a new node on the vector layer. Note that the node won't show up until on the map
-        * until the the relevant nodeUI is created, so you will need to instruct the paint to create one
-        *
-        * e.g. <code>layer.paint.updateEntityUIs(...);</code>
-        */
-               public function createNode(tags:Object,lat:Number,lon:Number):Node {
-                               // >>>> REFACTOR: VectorLayer commented out
-//                     var node:Node = new Node(this, negativeID, 0, tags, true, lat, lon);
-//                     nodes[negativeID]=node; negativeID--;
-//                     return node;
-                       return null;
-               }
-
-        /**
-        * @param tags The tags for the new Way
-        * @param nodes An array of Node objects
-        */
-               public function createWay(tags:Object,nodes:Array):Way {
-                               // >>>> REFACTOR: VectorLayer commented out
-//                     var way:Way = new Way(this, negativeID, 0, tags, true, nodes.concat());
-//                     ways[negativeID]=way; negativeID--;
-//                     return way;
-                       return null;
-               }
-
-        /**
-        * @param tags The tags for the new relation
-        * @param members An array of RelationMember objects
-        */
-               public function createRelation(tags:Object,members:Array):Relation {
-                               // >>>> REFACTOR: VectorLayer commented out
-//                     var relation:Relation = new Relation(this, negativeID, 0, tags, true, members.concat());
-//                     relations[negativeID]=relation; negativeID--;
-//                     return relation;
-                       return null;
-               }
-
-        /**
-        * Create a new Marker on the VectorLayer. If you pass in an id it'll check first whether that
-        * marker has been created already, and won't duplicate it.
-        *
-        * @param tags The tags for the new Marker
-        * @param lat The latitude
-        * @param lon The longitude
-        * @param id Use this id for the marker, useful for when layer might be reloaded during panning
-        */
-        public function createMarker(tags:Object,lat:Number,lon:Number,id:Number=NaN):Marker {
-            if (!id) {
-              id = negativeID;
-              negativeID--;
-            }
-                               // >>>> REFACTOR: VectorLayer commented out
-//            var marker:Marker = markers[id];
-//            if (marker == null) {
-//              marker = new Marker(this, id, 0, tags, true, lat, lon);
-//              markers[id]=marker;
-//            }
-//            return marker;
-                       return null;
-        }
-
-        public function registerPOI(node:Node):void {
-            if (pois.indexOf(node)<0) { pois.push(node); }
-        }
-        public function unregisterPOI(node:Node):void {
-                       var index:uint = pois.indexOf(node);
-                       if ( index >= 0 ) { pois.splice(index,1); }
-        }
-
-               public function getObjectsByBbox(left:Number, right:Number, top:Number, bottom:Number):Object {
-                       // ** FIXME: this is just copied-and-pasted from Connection.as, which really isn't very
-                       // good practice. Is there a more elegant way of doing it?
-                       var o:Object = { poisInside: [], poisOutside: [], waysInside: [], waysOutside: [],
-                              markersInside: [], markersOutside: [] };
-                              
-                       for each (var way:Way in ways) {
-                               if (way.within(left,right,top,bottom)) { o.waysInside.push(way); }
-                                                                 else { o.waysOutside.push(way); }
-                       }
-                       for each (var poi:Node in pois) {
-                               if (poi.within(left,right,top,bottom)) { o.poisInside.push(poi); }
-                                                                 else { o.poisOutside.push(poi); }
-                       }
-            for each (var marker:Marker in markers) {
-                if (marker.within(left,right,top,bottom)) { o.markersInside.push(marker); }
-                                                     else { o.markersOutside.push(marker); }
-            }
-                       return o;
-               }
-
-        /**
-        * Transfers an entity from the VectorLayer into the main layer
-        * @param entity The entity from the VectorLayer that you want to transfer.
-        * @param connection The Connection instance to transfer to (eg Connection.getConnection() )
-        *
-        * @return either the newly created entity, or null
-        */
-               public function pullThrough(entity:Entity,connection:Connection):Entity {
-                       var i:uint=0;
-                       var oldNode:Node, newNode:Node;
-                       if (entity is Way) {
-                               // copy way through to main layer
-                               // ** shouldn't do this if the nodes are already in the main layer
-                               //    (or maybe we should just match on lat/long to avoid ways in background having nodes in foreground)
-                               var oldWay:Way=Way(entity);
-                               var newWay:Way=connection.createWay(oldWay.getTagsCopy(), [], MainUndoStack.getGlobalStack().addAction);
-                               var nodemap:Object={};
-                               for (i=0; i<oldWay.length; i++) {
-                                       oldNode = oldWay.getNode(i);
-                                       newNode = nodemap[oldNode.id] ? nodemap[oldNode.id] : connection.createNode(
-                                               oldNode.getTagsCopy(), oldNode.lat, oldNode.lon, 
-                                               MainUndoStack.getGlobalStack().addAction);
-                                       newWay.appendNode(newNode, MainUndoStack.getGlobalStack().addAction);
-                                       nodemap[oldNode.id]=newNode;
-                               }
-                               // delete this way
-                               while (oldWay.length) { 
-                                       var id:Number=oldWay.getNode(0).id;
-                                       oldWay.removeNodeByIndex(0,MainUndoStack.getGlobalStack().addAction,false);
-                                       delete nodes[id];
-                               }
-                               paint.wayuis[oldWay.id].redraw();
-                               delete ways[oldWay.id];
-                               paint.createWayUI(newWay);
-                               return newWay;
-
-                       } else if (entity is Node && !entity.hasParentWays) {
-                               // copy node through to main layer
-                               // ** should be properly undoable
-                               oldNode=Node(entity);
-                               unregisterPOI(oldNode);
-                               // >>>> REFACTOR: VectorLayer commented out
-//                             var newPoiAction:CreatePOIAction = new CreatePOIAction(
-//                                     this, oldNode.getTagsCopy(), oldNode.lat, oldNode.lon);
-//                             MainUndoStack.getGlobalStack().addAction(newPoiAction);
-//                             paint.deleteNodeUI(oldNode);
-//                             delete nodes[oldNode.id];
-//                             return newPoiAction.getNode();
-                               return null;
-                       }
-                       return null;
-               }
-
-        /**
-        * Remove all the nodes, ways, and relations from the VectorLayer.
-        * Also removes the associated NodeUIs, WayUIs and POIs
-        */
-               public function blank():void {
-                       for each (var node:Node in nodes) { paint.deleteNodeUI(node); }
-                       for each (var way:Way in ways) { paint.deleteWayUI(way); }
-                       relations={}; nodes={}; ways={}; pois=[];
-               }
-
-        /**
-        * Load more data, eg during panning of the map. This can be overridden by
-        * vector layers if it makes sense to support it.
-        */
-        public function loadBbox(left:Number, right:Number,
-                                top:Number, bottom:Number):void {
-        }
-
-       }
-}