From 655f69c2e956eaca9bb0ffc3cfbf947944d6b3fb Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Wed, 14 Aug 2024 22:00:15 +0200 Subject: get_travel_distance: always return beeline distance --- lib/Travelynx/Model/Journeys.pm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index 031b0b1..2a0a9ec 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -1128,16 +1128,16 @@ sub get_travel_distance { my $distance_polyline = 0; my $distance_intermediate = 0; - my $distance_beeline = 0; - my $skipped = 0; my $geo = GIS::Distance->new(); - my @route = after_incl { $_->[0] eq $from } @{$route_ref}; + my $distance_beeline + = $geo->distance_metal( @{$from_latlon}, @{$to_latlon} ); + my @route = after_incl { $_->[0] eq $from } @{$route_ref}; @route = before_incl { $_->[0] eq $to } @route; if ( @route < 2 ) { # I AM ERROR - return ( 0, 0, 0 ); + return ( 0, 0, $distance_beeline ); } my @polyline = after_incl { $_->[2] and $_->[2] == $from_eva } @@ -1155,7 +1155,7 @@ sub get_travel_distance { } if ( not( defined $route[0][2]{lat} and defined $route[0][2]{lon} ) ) { - return ( $distance_polyline, 0, 0 ); + return ( $distance_polyline, 0, $distance_beeline ); } $prev_station = shift @route; @@ -1169,10 +1169,7 @@ sub get_travel_distance { } } - $distance_beeline = $geo->distance_metal( @{$from_latlon}, @{$to_latlon} ); - - return ( $distance_polyline, $distance_intermediate, - $distance_beeline, $skipped ); + return ( $distance_polyline, $distance_intermediate, $distance_beeline ); } sub grep_single { -- cgit v1.2.3