diff options
| author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-07-27 16:57:44 +0200 | 
|---|---|---|
| committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-07-27 16:57:44 +0200 | 
| commit | f59c15b4a0f17aba552baba5d90a6be0680a615d (patch) | |
| tree | e8963938643e1364d50c757f590c8edf38c27cf6 | |
| parent | 136c83548efceaa08e60d4dd9bd81a1bbb733032 (diff) | |
journey: Fix route highlighting
Polyline is still wrong
| -rwxr-xr-x | lib/Travelynx/Model/Journeys.pm | 17 | ||||
| -rw-r--r-- | templates/journey.html.ep | 6 | 
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index c9ac28d..8f940a1 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -13,7 +13,7 @@ use DateTime;  use DateTime::Format::Strptime;  use GIS::Distance;  use JSON; -use List::MoreUtils qw(after_incl before_incl); +use List::MoreUtils qw(after_incl before_incl first_index);  my %visibility_itoa = (  	100 => 'public', @@ -1262,7 +1262,7 @@ sub get_travel_distance {  	# distance for any journey that lacks sched_dep/rt_dep or  	# sched_from/rt_from. -	my @route = after_incl { +	my $route_start = first_index {  		(  			( $_->[1] and $_->[1] == $from_eva or $_->[0] eq $from )  			  and ( not( defined $_->[2]{sched_dep} or defined $_->[2]{rt_dep} ) @@ -1270,14 +1270,23 @@ sub get_travel_distance {  		)  	}  	@{$route_ref}; -	@route = before_incl { +	my $route_end = first_index {  		(  			( $_->[1] and $_->[1] == $to_eva or $_->[0] eq $to )  			  and ( not( defined $_->[2]{sched_arr} or defined $_->[2]{rt_arr} )  				or ( $_->[2]{sched_arr} // $_->[2]{rt_arr} ) == $to_ts )  		)  	} -	@route; +	@{$route_ref}; + +	if ( not defined $route_start and defined $route_end ) { +		return ( 0, 0, $distance_beeline ); +	} + +	$journey->{route_dep_index} = $route_start; +	$journey->{route_arr_index} = $route_end; + +	my @route = @{$route_ref}[ $route_start .. $route_end ];  	if (  		@route < 2 diff --git a/templates/journey.html.ep b/templates/journey.html.ep index 09ce159..f9c78ec 100644 --- a/templates/journey.html.ep +++ b/templates/journey.html.ep @@ -257,11 +257,12 @@  						% my $before = 1;  						% my $within = 0;  						% my $at_startstop = 0; +						% my $i = 0;  						% for my $station (@{$journey->{route}}) { -							% if (($station->[1] and $station->[1] == $journey->{from_eva}) or $station->[0] eq $journey->{from_name}) { +							% if ($i == $journey->{route_dep_index}) {  								% $within = 1; $at_startstop = 1;  							% } -							% elsif (($station->[1] and $station->[1] == $journey->{to_eva}) or $station->[0] eq $journey->{to_name}) { +							% elsif ($i == $journey->{route_arr_index}) {  								% $within = 0; $at_startstop = 1;  							% }  							% else { @@ -298,6 +299,7 @@  								% $before = 0;  							% }  							<br/> +							% $i += 1;  						% }  					</td>  				</tr>  | 
