summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Controller
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-08-20 16:52:09 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2023-08-20 16:52:09 +0200
commit8f747fff9158452f5397a800900e2e5782620620 (patch)
treeda6cab477940de3c84cf6130550dc2e6e906f3c3 /lib/Travelynx/Controller
parent3eda3beeae6aca42c395c9de221782b5d4843f42 (diff)
sort HAFAS/IRIS stations by distance
Diffstat (limited to 'lib/Travelynx/Controller')
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 8f560a9..eba227f 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -593,12 +593,15 @@ sub geolocation {
hafas => 1
}
} $hafas->results;
- if ( @hafas > 5 ) {
- @hafas = @hafas[ 0 .. 4 ];
+ if ( @hafas > 10 ) {
+ @hafas = @hafas[ 0 .. 9 ];
}
+ my @results = map { $_->[0] }
+ sort { $a->[1] <=> $b->[1] }
+ map { [ $_, $_->{distance} ] } ( @iris, @hafas );
$self->render(
json => {
- candidates => [ @iris, @hafas ],
+ candidates => [@results],
}
);
}