diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-10-07 11:35:47 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-10-07 11:35:47 +0200 |
commit | 6fd985ae7ef9800d5837af942d74ad6e7562c75d (patch) | |
tree | 026e9757dccd327279e1f9f71e601dd03a28d15c /index.pl | |
parent | d95cb9d06a346e16e8cc2a63b9b0e1279a19a251 (diff) |
show close stations via geolocation
Diffstat (limited to 'index.pl')
-rwxr-xr-x | index.pl | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -577,7 +577,7 @@ helper 'navbar_class' => sub { get '/' => sub { my ($self) = @_; - $self->render('landingpage'); + $self->render( 'landingpage', with_geolocation => 1 ); }; post '/action' => sub { @@ -640,6 +640,36 @@ post '/action' => sub { } }; +post '/x/geolocation' => sub { + my ($self) = @_; + + my $lon = $self->param('lon'); + my $lat = $self->param('lat'); + + if ( not $lon or not $lat ) { + $self->render( json => { error => 'Invalid lon/lat received' } ); + } + else { + my @candidates = map { + { + ds100 => $_->[0][0], + name => $_->[0][1], + eva => $_->[0][2], + lon => $_->[0][3], + lat => $_->[0][4], + distance => $_->[1], + } + } Travel::Status::DE::IRIS::Stations::get_station_by_location( $lon, + $lat, 5 ); + $self->render( + json => { + candidates => [@candidates], + } + ); + } + +}; + get '/*station' => sub { my ($self) = @_; my $station = $self->stash('station'); |