diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2023-08-20 16:52:09 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2023-08-20 16:52:09 +0200 |
commit | 8f747fff9158452f5397a800900e2e5782620620 (patch) | |
tree | da6cab477940de3c84cf6130550dc2e6e906f3c3 /lib | |
parent | 3eda3beeae6aca42c395c9de221782b5d4843f42 (diff) |
sort HAFAS/IRIS stations by distance
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 9 |
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], } ); } |