@@ -21,33 +21,38 @@ impl Speedwalk {
2121 . mercator
2222 . to_wgs84_gj ( & graph. intersections [ & junction. i ] . point ) ;
2323
24- let mut debug_arms = Vec :: new ( ) ;
24+ let mut arms = Vec :: new ( ) ;
2525 for e in junction. arms {
2626 let edge = & graph. edges [ & e] ;
27- debug_arms . push ( self . mercator . to_wgs84_gj ( & edge. linestring ) ) ;
27+ arms . push ( self . mercator . to_wgs84_gj ( & edge. linestring ) ) ;
2828 }
29- let crossing_count = junction. crossings . len ( ) ;
30- let explicit_non_crossing_count = junction. explicit_non_crossings . len ( ) ;
31- let mut debug_crossings = Vec :: new ( ) ;
29+
30+ let mut crossings = Vec :: new ( ) ;
3231 for n in & junction. crossings {
33- debug_crossings . push (
32+ crossings . push (
3433 self . mercator
3534 . to_wgs84_gj ( & Point :: from ( self . derived_nodes [ n] . pt ) ) ,
3635 ) ;
3736 }
38- let mut debug_explicit_non_crossings = Vec :: new ( ) ;
37+
38+ let mut explicit_non_crossings = Vec :: new ( ) ;
3939 for n in & junction. explicit_non_crossings {
40- debug_explicit_non_crossings . push (
40+ explicit_non_crossings . push (
4141 self . mercator
4242 . to_wgs84_gj ( & Point :: from ( self . derived_nodes [ n] . pt ) ) ,
4343 ) ;
4444 }
45- f. set_property ( "complete" , debug_arms. len ( ) == crossing_count + explicit_non_crossing_count) ;
46- f. set_property ( "arms" , GeoJson :: from ( debug_arms) ) ;
47- f. set_property ( "crossings" , GeoJson :: from ( debug_crossings) ) ;
48- f. set_property ( "explicit_non_crossings" , GeoJson :: from ( debug_explicit_non_crossings) ) ;
49- f. set_property ( "crossing_count" , crossing_count) ;
50- f. set_property ( "explicit_non_crossing_count" , explicit_non_crossing_count) ;
45+
46+ f. set_property (
47+ "complete" ,
48+ arms. len ( ) == crossings. len ( ) + explicit_non_crossings. len ( ) ,
49+ ) ;
50+ f. set_property ( "arms" , GeoJson :: from ( arms) ) ;
51+ f. set_property ( "crossings" , GeoJson :: from ( crossings) ) ;
52+ f. set_property (
53+ "explicit_non_crossings" ,
54+ GeoJson :: from ( explicit_non_crossings) ,
55+ ) ;
5156
5257 features. push ( f) ;
5358 }
@@ -89,8 +94,7 @@ impl Speedwalk {
8994 // Iterate backward from dst to src
9095 Box :: new ( edge. node_ids . iter ( ) . rev ( ) . skip ( 1 ) )
9196 } else {
92- // Shouldn't happen, but fallback to all nodes
93- Box :: new ( edge. node_ids . iter ( ) )
97+ unreachable ! ( )
9498 } ;
9599
96100 for n in node_iter {
@@ -102,6 +106,8 @@ impl Speedwalk {
102106 }
103107 if node. is_crossing ( ) {
104108 crossings. insert ( * n) ;
109+ // Stop iterating along this edge when we hit the first crossing
110+ break ;
105111 }
106112 }
107113 }
0 commit comments