First cut at styling TIGER data via an option. Needs lots of propagation of uid and...
[potlatch2.git] / net / systemeD / halcyon / connection / XMLBaseConnection.as
index 9c68b0e68382b435f84cc6017b3187a11f696503..c65d6d80a03d303ac77ddbb15a66d16544a69d06 100644 (file)
@@ -8,6 +8,11 @@ package net.systemeD.halcyon.connection {
 
        import net.systemeD.halcyon.Globals;
 
+    /**
+    * XMLBaseConnection is the common code between connecting to an OSM server
+    * (i.e. XMLConnection) and connecting to a standalone .osm file (i.e. OSMConnection)
+    * and so mainly concerns itself with /map -call-ish related matters
+    */
        public class XMLBaseConnection extends Connection {
 
                public function XMLBaseConnection() {
@@ -19,45 +24,10 @@ package net.systemeD.halcyon.connection {
             var map:XML = new XML(URLLoader(event.target).data);
             var id:Number;
             var version:uint;
+            var uid:Number;
+            var timestamp:String;
             var tags:Object;
 
-            for each(var nodeData:XML in map.node) {
-                id = Number(nodeData.@id);
-                version = uint(nodeData.@version);
-
-                var node:Node = getNode(id);
-                if ( node == null || !node.loaded ) {
-                    var lat:Number = Number(nodeData.@lat);
-                    var lon:Number = Number(nodeData.@lon);
-                    tags = parseTags(nodeData.tag);
-                    if ( node == null )
-                        setNode(new Node(id, version, tags, true, lat, lon),false);
-                    else {
-                        node.update(version, tags, true, lat, lon);
-                        sendEvent(new EntityEvent(NEW_NODE, node), false);
-                    }
-                }
-            }
-
-            for each(var data:XML in map.way) {
-                id = Number(data.@id);
-                version = uint(data.@version);
-
-                var way:Way = getWay(id);
-                if ( way == null || !way.loaded ) {
-                    var nodes:Array = [];
-                    for each(var nd:XML in data.nd)
-                        nodes.push(getNode(Number(nd.@ref)));
-                    tags = parseTags(data.tag);
-                    if ( way == null )
-                        setWay(new Way(id, version, tags, true, nodes),false);
-                    else {
-                        way.update(version, tags, true, nodes);
-                        sendEvent(new EntityEvent(NEW_WAY, way), false);
-                    }
-                }
-            }
-            
             for each(var relData:XML in map.relation) {
                 id = Number(relData.@id);
                 version = uint(relData.@version);
@@ -104,6 +74,47 @@ package net.systemeD.halcyon.connection {
                 }
             }
             
+            for each(var nodeData:XML in map.node) {
+                id = Number(nodeData.@id);
+                version = uint(nodeData.@version);
+                uid = Number(nodeData.@uid);
+                timestamp = nodeData.@timestamp;
+
+                var node:Node = getNode(id);
+                if ( node == null || !node.loaded ) {
+                    var lat:Number = Number(nodeData.@lat);
+                    var lon:Number = Number(nodeData.@lon);
+                    tags = parseTags(nodeData.tag);
+                    if ( node == null )
+                        setNode(new Node(id, version, tags, true, lat, lon, uid, timestamp),false);
+                    else {
+                        node.update(version, tags, true, lat, lon, uid, timestamp);
+                        sendEvent(new EntityEvent(NEW_NODE, node), false);
+                    }
+                }
+            }
+
+            for each(var data:XML in map.way) {
+                id = Number(data.@id);
+                version = uint(data.@version);
+                uid = Number(data.@uid);
+                timestamp = data.@timestamp;
+
+                var way:Way = getWay(id);
+                if ( way == null || !way.loaded ) {
+                    var nodes:Array = [];
+                    for each(var nd:XML in data.nd)
+                        nodes.push(getNode(Number(nd.@ref)));
+                    tags = parseTags(data.tag);
+                    if ( way == null )
+                        setWay(new Way(id, version, tags, true, nodes, uid, timestamp),false);
+                    else {
+                        way.update(version, tags, true, nodes, uid, timestamp);
+                        sendEvent(new EntityEvent(NEW_WAY, way), false);
+                    }
+                }
+            }
+            
             registerPOINodes();
         }