diff options
| author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-07-20 10:36:45 +0200 | 
|---|---|---|
| committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-07-20 10:36:45 +0200 | 
| commit | d11d0d5cb53896ea46de5b9186b481d678b5ad93 (patch) | |
| tree | 1f1bc820aea79d94cf9d1c3793a06dee13093997 | |
| parent | f7a290c11c9b03baaa9acfb4cd777d1c5a48928c (diff) | |
estimate_trip_position: handle duration between legs == 0
| -rw-r--r-- | lib/Travelynx/Model/InTransit.pm | 5 | 
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Travelynx/Model/InTransit.pm b/lib/Travelynx/Model/InTransit.pm index ceb8202..aa16038 100644 --- a/lib/Travelynx/Model/InTransit.pm +++ b/lib/Travelynx/Model/InTransit.pm @@ -1665,6 +1665,11 @@ sub estimate_trip_position {  		my $time_total  		  = ( $in_transit->{real_arr_ts} // $in_transit->{sched_arr_ts} )  		  - ( $in_transit->{real_dep_ts} // $in_transit->{sched_dep_ts} ); + +		if ( $time_total == 0 ) { +			return [ $in_transit->{dep_lat}, $in_transit->{dep_lon} ]; +		} +  		my $completion = $time_complete / $time_total;  		$completion = $completion < 0 ? 0 : $completion > 1 ? 1 : $completion;  		@now_latlon = (  | 
