@@ -15,6 +15,7 @@ describe('iD.actionReverse', function () {
15
15
expect ( graph . entity ( way . id ) . tags ) . to . eql ( { 'highway' : 'residential' } ) ;
16
16
} ) ;
17
17
18
+
18
19
describe ( 'reverses directional tags on nodes' , function ( ) {
19
20
it ( 'reverses relative directions' , function ( ) {
20
21
var node1 = iD . osmNode ( { tags : { 'direction' : 'forward' } } ) ;
@@ -95,6 +96,7 @@ describe('iD.actionReverse', function () {
95
96
} ) ;
96
97
} ) ;
97
98
99
+
98
100
describe ( 'reverses oneway' , function ( ) {
99
101
it ( 'preserves oneway tags' , function ( ) {
100
102
var way = iD . osmWay ( { tags : { 'oneway' : 'yes' } } ) ;
@@ -588,6 +590,47 @@ describe('iD.actionReverse', function () {
588
590
var target = graph . entity ( node2 . id ) ;
589
591
expect ( target . tags [ 'traffic_signals:direction' ] ) . to . eql ( 'empty' ) ;
590
592
} ) ;
593
+ } ) ;
594
+
595
+
596
+ describe ( 'does not reverse values which are relative to another reversed tag' , function ( ) {
597
+ it ( 'preserves the turn direction of a single lane road' , function ( ) {
598
+ var way = iD . osmWay ( { tags : { 'turn:lanes' : 'right' } } ) ;
599
+ var graph = iD . actionReverse ( way . id ) ( iD . coreGraph ( [ way ] ) ) ;
600
+ var target = graph . entity ( way . id ) ;
601
+ expect ( target . tags [ 'turn:lanes' ] ) . to . eql ( 'right' ) ;
602
+ } ) ;
603
+
604
+ it ( 'preserves the turn directions of a multi-lane road' , function ( ) {
605
+ var way = iD . osmWay ( { tags : { 'turn:lanes' : 'through|through|right' } } ) ;
606
+ var graph = iD . actionReverse ( way . id ) ( iD . coreGraph ( [ way ] ) ) ;
607
+ var target = graph . entity ( way . id ) ;
608
+ expect ( target . tags [ 'turn:lanes' ] ) . to . eql ( 'through|through|right' ) ;
609
+ } ) ;
610
+
611
+ // https://github.com/openstreetmap/iD/issues/5674
612
+ it ( 'preserves the turn direction of each direction with a single lane' , function ( ) {
613
+ var way = iD . osmWay ( { tags : { 'turn:lanes:forward' : 'right' , 'turn:lanes:backward' : 'left' } } ) ;
614
+ var graph = iD . actionReverse ( way . id ) ( iD . coreGraph ( [ way ] ) ) ;
615
+ var target = graph . entity ( way . id ) ;
616
+ expect ( target . tags [ 'turn:lanes:backward' ] ) . to . eql ( 'right' ) ;
617
+ expect ( target . tags [ 'turn:lanes:forward' ] ) . to . eql ( 'left' ) ;
618
+ } ) ;
619
+
620
+ it ( 'preserves the turn direction of each direction with multiple lanes' , function ( ) {
621
+ var way = iD . osmWay ( { tags : { 'turn:lanes:forward' : 'through|right' , 'turn:lanes:backward' : 'through|through|left' } } ) ;
622
+ var graph = iD . actionReverse ( way . id ) ( iD . coreGraph ( [ way ] ) ) ;
623
+ var target = graph . entity ( way . id ) ;
624
+ expect ( target . tags [ 'turn:lanes:backward' ] ) . to . eql ( 'through|right' ) ;
625
+ expect ( target . tags [ 'turn:lanes:forward' ] ) . to . eql ( 'through|through|left' ) ;
626
+ } ) ;
627
+
628
+ it ( 'preserves the turn direction of explicitly bidirectional turn lane values' , function ( ) {
629
+ var way = iD . osmWay ( { tags : { 'turn:lanes:both_ways' : 'left' } } ) ;
630
+ var graph = iD . actionReverse ( way . id ) ( iD . coreGraph ( [ way ] ) ) ;
631
+ var target = graph . entity ( way . id ) ;
632
+ expect ( target . tags [ 'turn:lanes:both_ways' ] ) . to . eql ( 'left' ) ;
633
+ } ) ;
591
634
592
635
it ( 'preserves the value of the side tag of a cycling waiting aid' , function ( ) {
593
636
var node1 = iD . osmNode ( ) ;
@@ -603,5 +646,22 @@ describe('iD.actionReverse', function () {
603
646
expect ( target . tags . direction ) . to . eql ( 'backward' ) ;
604
647
expect ( target . tags . side ) . to . eql ( 'right' ) ;
605
648
} ) ;
649
+
650
+ it ( 'preserves the direction of a red turn at a traffic signal' , function ( ) {
651
+ var node1 = iD . osmNode ( ) ;
652
+ var node2 = iD . osmNode ( { tags : {
653
+ 'highway' : 'traffic_signals' ,
654
+ 'traffic_signals:direction' : 'forward' ,
655
+ 'red_turn:right' : 'no' ,
656
+ 'red_turn:right:bicycle' : 'yes'
657
+ } } ) ;
658
+ var node3 = iD . osmNode ( ) ;
659
+ var way = iD . osmWay ( { nodes : [ node1 . id , node2 . id , node3 . id ] } ) ;
660
+ var graph = iD . actionReverse ( way . id ) ( iD . coreGraph ( [ node1 , node2 , node3 , way ] ) ) ;
661
+ var target = graph . entity ( node2 . id ) ;
662
+ expect ( target . tags [ 'traffic_signals:direction' ] ) . to . eql ( 'backward' ) ;
663
+ expect ( target . tags [ 'red_turn:right' ] ) . to . eql ( 'no' ) ;
664
+ expect ( target . tags [ 'red_turn:right:bicycle' ] ) . to . eql ( 'yes' ) ;
665
+ } ) ;
606
666
} ) ;
607
667
} ) ;
0 commit comments