diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-06-21 17:54:09 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-06-21 17:54:09 +0200 |
commit | 255d0610f1b5b62b7dd409eeba6c63da3fac4092 (patch) | |
tree | 6fe3aeea0e785b55bf02cdb5a21da8e25ecbcd69 /lib/Travelynx/Model | |
parent | 21edf4a406db78a1ed5203b5ac53284a811161d3 (diff) |
Journeys->add: Support complete routes, not just intermediate stops1.20.1
Diffstat (limited to 'lib/Travelynx/Model')
-rwxr-xr-x | lib/Travelynx/Model/Journeys.pm | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index cb10a63..a0981c6 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -130,7 +130,23 @@ sub add { ); } - my @route = ( [ $dep_station->[1], {}, undef ] ); + my $route_has_start = 0; + my $route_has_stop = 0; + + for my $station ( @{ $opt{route} || [] } ) { + if ( $station eq $dep_station->[1] or $station eq $dep_station->[0] ) { + $route_has_start = 1; + } + if ( $station eq $arr_station->[1] or $station eq $arr_station->[0] ) { + $route_has_stop = 1; + } + } + + my @route; + + if ( not $route_has_start ) { + push( @route, [ $dep_station->[1], {}, undef ] ); + } if ( $opt{route} ) { my @unknown_stations; @@ -158,14 +174,8 @@ sub add { } } - push( @route, [ $arr_station->[1], {}, undef ] ); - - if ( $route[0][0] eq $route[1][0] ) { - shift(@route); - } - - if ( $route[-2][0] eq $route[-1][0] ) { - pop(@route); + if ( not $route_has_stop ) { + push( @route, [ $arr_station->[1], {}, undef ] ); } my $entry = { |