summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-05-10 12:21:32 +0200
committerDaniel Friesel <derf@finalrewind.org>2016-05-10 12:21:32 +0200
commit6c37dec8ed54a987acb6665fb6525a39fc6ca5da (patch)
tree290e831d119697ff4dd84468e256766c63fd57f2 /index.pl
parente09a676a9fac68feca73caffea792c4f0f8eef38 (diff)
geolocation playground
Diffstat (limited to 'index.pl')
-rw-r--r--index.pl22
1 files changed, 22 insertions, 0 deletions
diff --git a/index.pl b/index.pl
index 543bcd1..155fd18 100644
--- a/index.pl
+++ b/index.pl
@@ -810,6 +810,28 @@ get '/_redirect' => sub {
}
};
+get '/_auto' => sub {
+ my $self = shift;
+
+ $self->render('geolocation', with_geolocation => 1, hide_opts => 1);
+};
+
+post '/_geolocation' => sub {
+ my $self = shift;
+
+ 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 {
+ $self->render(json => {
+ candidates => [ Travel::Status::DE::IRIS::Stations::get_stations_by_location($lon, $lat, 10) ],
+ });
+ }
+};
+
app->defaults( layout => 'default' );
get '/' => \&handle_request;