From 8f747fff9158452f5397a800900e2e5782620620 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sun, 20 Aug 2023 16:52:09 +0200 Subject: sort HAFAS/IRIS stations by distance --- lib/Travelynx/Controller/Traveling.pm | 9 ++++++--- 1 file 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], } ); } -- cgit v1.2.3