Unverified Commit 8f747fff authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

sort HAFAS/IRIS stations by distance

parent 3eda3bee
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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],
				}
			);
		}