sort HAFAS/IRIS stations by distance

This commit is contained in:
Birte Kristina Friesel 2023-08-20 16:52:09 +02:00
parent 3eda3beeae
commit 8f747fff91
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA

View file

@ -593,12 +593,15 @@ sub geolocation {
hafas => 1 hafas => 1
} }
} $hafas->results; } $hafas->results;
if ( @hafas > 5 ) { if ( @hafas > 10 ) {
@hafas = @hafas[ 0 .. 4 ]; @hafas = @hafas[ 0 .. 9 ];
} }
my @results = map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [ $_, $_->{distance} ] } ( @iris, @hafas );
$self->render( $self->render(
json => { json => {
candidates => [ @iris, @hafas ], candidates => [@results],
} }
); );
} }