summaryrefslogtreecommitdiff
path: root/lib/Travelynx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travelynx')
-rw-r--r--lib/Travelynx/Command/translation.pm7
-rwxr-xr-xlib/Travelynx/Model/Journeys.pm14
2 files changed, 12 insertions, 9 deletions
diff --git a/lib/Travelynx/Command/translation.pm b/lib/Travelynx/Command/translation.pm
index 70bdaba..cc3a5ac 100644
--- a/lib/Travelynx/Command/translation.pm
+++ b/lib/Travelynx/Command/translation.pm
@@ -92,7 +92,8 @@ __END__
=head1 SYNOPSIS
- Usage: index.pl dumpstops <format> <filename>
+ Usage: index.pl translation <command>
- Exports known stops to <filename>.
- Right now, only the "csv" format is supported.
+ Supported commands:
+
+ * update-ref: update share/locales/reference.md
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm
index c0ba2a9..9efa365 100755
--- a/lib/Travelynx/Model/Journeys.pm
+++ b/lib/Travelynx/Model/Journeys.pm
@@ -1296,7 +1296,7 @@ sub get_travel_distance {
# Assumption: polyline entries are always [lat, lon] or [lat, lon, stop ID]
%seen = ();
- for my $entry ( @{$polyline_ref} ) {
+ for my $entry ( @{ $polyline_ref // [] } ) {
if ( $entry->[2] ) {
$seen{ $entry->[2] } //= 1;
$entry->[3] = $seen{ $entry->[2] };
@@ -1311,17 +1311,19 @@ sub get_travel_distance {
# Just like the route, the polyline may contain the same stop more than
# once. So we need to select based on the seen counter.
- my @polyline = after_incl {
+ my $poly_start = first_index {
$_->[2] and $_->[2] == $from_eva and $_->[3] == $route[0][2]{n}
}
@{ $polyline_ref // [] };
- @polyline = before_incl {
+ my $poly_end = first_index {
$_->[2] and $_->[2] == $to_eva and $_->[3] == $route[-1][2]{n}
}
- @polyline;
+ @{ $polyline_ref // [] };
- # ensure that before_incl matched -- otherwise, @polyline is too long
- if ( @polyline and $polyline[-1][2] == $to_eva ) {
+ if ( defined $poly_start and defined $poly_end ) {
+ $journey->{poly_dep_index} = $poly_start;
+ $journey->{poly_arr_index} = $poly_end;
+ my @polyline = @{$polyline_ref}[ $poly_start .. $poly_end ];
my $prev_station = shift @polyline;
for my $station (@polyline) {
$distance_polyline += $geo->distance_metal(