Unverified Commit d11d0d5c authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

estimate_trip_position: handle duration between legs == 0

parent f7a290c1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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 = (