diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-03-14 20:57:06 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-03-14 20:57:06 +0100 |
commit | b0d3664b35f6288c2b0bfb273b1430a87d361510 (patch) | |
tree | be5a95a7671654993619f8f209b6d0e08dd3f257 | |
parent | 0ce8d6967e907aacaf6e8ac6328a6a674610e8d6 (diff) |
map: handle arrival-only and departure-only stops3.10.9
-rw-r--r-- | lib/DBInfoscreen/Controller/Map.pm | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/DBInfoscreen/Controller/Map.pm b/lib/DBInfoscreen/Controller/Map.pm index b55afe0..b4c9134 100644 --- a/lib/DBInfoscreen/Controller/Map.pm +++ b/lib/DBInfoscreen/Controller/Map.pm @@ -1,4 +1,5 @@ package DBInfoscreen::Controller::Map; + # Copyright (C) 2011-2020 Daniel Friesel # # SPDX-License-Identifier: AGPL-3.0-or-later @@ -138,8 +139,8 @@ sub estimate_train_positions { my $now = $opt{now}; - my $from_dt = $opt{from}{dep}; - my $to_dt = $opt{to}{arr}; + my $from_dt = $opt{from}{dep} // $opt{from}{arr}; + my $to_dt = $opt{to}{arr} // $opt{to}{dep}; my $from_name = $opt{from}{name}; my $to_name = $opt{to}{name}; my $features = $opt{features}; @@ -242,10 +243,10 @@ sub estimate_train_positions2 { my $next_stop; for my $i ( 1 .. $#route ) { - if ( $route[$i]{arr} - and $route[ $i - 1 ]{dep} - and $now > $route[ $i - 1 ]{dep} - and $now < $route[$i]{arr} ) + if ( ( $route[$i]{arr} // $route[$i]{dep} ) + and ( $route[ $i - 1 ]{dep} // $route[ $i - 1 ]{arr} ) + and $now > ( $route[ $i - 1 ]{dep} // $route[ $i - 1 ]{arr} ) + and $now < ( $route[$i]{arr} // $route[$i]{dep} ) ) { # (current position, future positons...) in 2 second steps @@ -262,7 +263,9 @@ sub estimate_train_positions2 { }; last; } - if ( $route[ $i - 1 ]{dep} and $now <= $route[ $i - 1 ]{dep} ) { + if ( ( $route[ $i - 1 ]{dep} // $route[ $i - 1 ]{arr} ) + and $now <= ( $route[ $i - 1 ]{dep} // $route[ $i - 1 ]{arr} ) ) + { @train_positions = ( [ $route[ $i - 1 ]{lat}, $route[ $i - 1 ]{lon} ] ); $next_stop = { |