this'll keep the Germans happy
authorRichard Fairhurst <richard@systemed.net>
Mon, 1 Nov 2010 15:15:18 +0000 (15:15 +0000)
committerRichard Fairhurst <richard@systemed.net>
Mon, 1 Nov 2010 15:15:18 +0000 (15:15 +0000)
TODO.txt
net/systemeD/halcyon/connection/Entity.as
net/systemeD/halcyon/connection/actions/SplitWayAction.as

index 8124fb9..ec1d3bd 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -79,10 +79,6 @@ Requested enhancements
 * The area of pois for dragging on to the map should have a search, with synonyms.
 * If you have both inputSets names and buildingAddress, and name= key is filled in then the basic tab will get both, surely only name should be shown and building name should be ignored e.g. cafes. [Actually this was an issue of addr: being missing from one of them, however this may still be a problem for other overlapping inputSets]
 
-== Turn restrictions ==
-
-* Splitting a way should have smart turn restriction behaviour - i.e. only retain the relation in that part of the way which joins the via point.
-
 == UI ==
 
 * Mouse wheel zooming
index ec5884a..bd786fe 100644 (file)
@@ -213,10 +213,10 @@ package net.systemeD.halcyon.connection {
                        return a;
                }
                
-               public function findParentRelationsOfType(type:String, role:String=""):Array {
+               public function findParentRelationsOfType(type:String, role:String=null):Array {
                        var a:Array=[];
                        for (var o:Object in parents) {
-                               if (o is Relation && Relation(o).tagIs('type',type) && Relation(o).hasMemberInRole(this,role)) { 
+                               if (o is Relation && Relation(o).tagIs('type',type) && (role==null || Relation(o).hasMemberInRole(this,role))) { 
                                        a.push(o);
                                }
                        }
index dd60e0a..b6b815f 100644 (file)
@@ -22,9 +22,19 @@ package net.systemeD.halcyon.connection.actions {
                                        selectedWay.sliceNodes(selectedWay.indexOfNode(selectedNode),selectedWay.length),
                                        push);
 
-                // we reverse the list, which is already sorted by position. This way positions aren't affected
-                // for previous inserts when all the inserts are eventually executed
-                for each (var o:Object in selectedWay.memberships.reverse()) {
+                               // we reverse the list, which is already sorted by position. This way positions aren't affected
+                               // for previous inserts when all the inserts are eventually executed
+                               for each (var o:Object in selectedWay.memberships.reverse()) {
+                                       // don't add a turn restriction to the relation if it's no longer relevant
+                                       if (o.relation.tagIs('type','restriction')) {
+                                               var vias:Array=o.relation.findMembersByRole('via');
+                                               if (vias.length && vias[0] is Node) {
+                                                       if (newWay.indexOfNode(Node(vias[0]))==-1) { 
+                                                               continue;
+                                                       }
+                                               }
+                                       }
+
                   // newWay should be added immediately after the selectedWay, unless the setup
                   // is arse-backwards. By that I mean either:
                   // a) The first node (0) of selectedWay is in the subsequentWay, or
@@ -65,6 +75,17 @@ package net.systemeD.halcyon.connection.actions {
                 
                 // now that we're done with the selectedWay, remove the nodes
                 selectedWay.deleteNodesFrom(selectedWay.indexOfNode(selectedNode)+1, push);
+
+                               // and remove from any turn restrictions that aren't relevant
+                               for each (var r:Relation in selectedWay.findParentRelationsOfType('restriction')) {
+                                       vias=r.findMembersByRole('via');
+                                       if (vias.length && vias[0] is Node) {
+                                               if (selectedWay.indexOfNode(Node(vias[0]))==-1) { 
+                                                       r.removeMember(selectedWay,push);
+                                               }
+                                       }
+                               }
+
             }
             newWay.suspend();
             selectedWay.suspend();