Loading lib/DBInfoscreen/Controller/Static.pm +15 −0 Original line number Diff line number Diff line Loading @@ -42,8 +42,23 @@ sub redirect { sub geostop { my ($self) = @_; my ( $api_link, $api_text, $api_icon ); if ( $self->param('hafas') ) { $api_link = '/_autostop'; $api_text = 'Auf Bahnverkehr wechseln'; $api_icon = 'directions_bus'; } else { $api_link = '/_autostop?hafas=1'; $api_text = 'Auf Nahverkehr wechseln'; $api_icon = 'train'; } $self->render( 'geostop', api_link => $api_link, api_text => $api_text, api_icon => $api_icon, with_geostop => 1, hide_opts => 1 ); Loading lib/DBInfoscreen/Controller/Stationboard.pm +37 −2 Original line number Diff line number Diff line Loading @@ -1765,10 +1765,44 @@ sub stations_by_coordinates { my $lon = $self->param('lon'); my $lat = $self->param('lat'); my $hafas = $self->param('hafas'); if ( not $lon or not $lat ) { $self->render( json => { error => 'Invalid lon/lat received' } ); } if ($hafas) { $self->render_later; Travel::Status::DE::HAFAS->new_p( promise => 'Mojo::Promise', user_agent => $self->ua, geoSearch => { lat => $lat, lon => $lon } )->then( sub { my ($hafas) = @_; my @candidates = map { { name => $_->name, eva => $_->eva, distance => $_->distance_m / 1000, hafas => 1 } } $hafas->results; $self->render( json => { candidates => [@candidates], } ); } )->catch( sub { my ($err) = @_; $self->render( json => { error => $err } ); } )->wait; } else { my @candidates = map { { Loading @@ -1778,6 +1812,7 @@ sub stations_by_coordinates { lon => $_->[0][3], lat => $_->[0][4], distance => $_->[1], hafas => 0, } } Travel::Status::DE::IRIS::Stations::get_station_by_location( $lon, $lat, 10 ); Loading public/static/js/geostop.js +7 −6 Original line number Diff line number Diff line Loading @@ -32,17 +32,18 @@ $(function() { if (data.error) { showError('Backend-Fehler:', data.error, null); } else if (data.candidates.length == 0) { showError('Keine Bahnhöfe in 70km Umkreis gefunden', '', null); showError('Keine Stationen in 70km Umkreis gefunden', '', null); } else { $.each(data.candidates, function(i, candidate) { var ds100 = candidate.ds100, var eva = candidate.eva, name = candidate.name, distance = candidate.distance; distance = candidate.distance, hafas = candidate.hafas; distance = distance.toFixed(1); var stationlink = $(document.createElement('a')); stationlink.attr('href', ds100); stationlink.attr('href', eva + '?hafas=' + hafas); stationlink.text(name); var distancenode = $(document.createElement('div')); Loading @@ -56,11 +57,11 @@ $(function() { }; var processLocation = function(loc) { $.post('/_geolocation', {lon: loc.coords.longitude, lat: loc.coords.latitude}, processResult).fail(function(jqXHR, textStatus, errorThrown) { $.post('/_geolocation', {lon: loc.coords.longitude, lat: loc.coords.latitude, hafas: window.location.href.match('hafas=1') ? 1 : 0}, processResult).fail(function(jqXHR, textStatus, errorThrown) { removeStatus(); showError("Netzwerkfehler: ", textStatus, errorThrown); }); $('div.candidatestatus').text('Suche Bahnhöfe…'); $('div.candidatestatus').text('Suche Stationen…'); }; var processError = function(error) { Loading Loading
lib/DBInfoscreen/Controller/Static.pm +15 −0 Original line number Diff line number Diff line Loading @@ -42,8 +42,23 @@ sub redirect { sub geostop { my ($self) = @_; my ( $api_link, $api_text, $api_icon ); if ( $self->param('hafas') ) { $api_link = '/_autostop'; $api_text = 'Auf Bahnverkehr wechseln'; $api_icon = 'directions_bus'; } else { $api_link = '/_autostop?hafas=1'; $api_text = 'Auf Nahverkehr wechseln'; $api_icon = 'train'; } $self->render( 'geostop', api_link => $api_link, api_text => $api_text, api_icon => $api_icon, with_geostop => 1, hide_opts => 1 ); Loading
lib/DBInfoscreen/Controller/Stationboard.pm +37 −2 Original line number Diff line number Diff line Loading @@ -1765,10 +1765,44 @@ sub stations_by_coordinates { my $lon = $self->param('lon'); my $lat = $self->param('lat'); my $hafas = $self->param('hafas'); if ( not $lon or not $lat ) { $self->render( json => { error => 'Invalid lon/lat received' } ); } if ($hafas) { $self->render_later; Travel::Status::DE::HAFAS->new_p( promise => 'Mojo::Promise', user_agent => $self->ua, geoSearch => { lat => $lat, lon => $lon } )->then( sub { my ($hafas) = @_; my @candidates = map { { name => $_->name, eva => $_->eva, distance => $_->distance_m / 1000, hafas => 1 } } $hafas->results; $self->render( json => { candidates => [@candidates], } ); } )->catch( sub { my ($err) = @_; $self->render( json => { error => $err } ); } )->wait; } else { my @candidates = map { { Loading @@ -1778,6 +1812,7 @@ sub stations_by_coordinates { lon => $_->[0][3], lat => $_->[0][4], distance => $_->[1], hafas => 0, } } Travel::Status::DE::IRIS::Stations::get_station_by_location( $lon, $lat, 10 ); Loading
public/static/js/geostop.js +7 −6 Original line number Diff line number Diff line Loading @@ -32,17 +32,18 @@ $(function() { if (data.error) { showError('Backend-Fehler:', data.error, null); } else if (data.candidates.length == 0) { showError('Keine Bahnhöfe in 70km Umkreis gefunden', '', null); showError('Keine Stationen in 70km Umkreis gefunden', '', null); } else { $.each(data.candidates, function(i, candidate) { var ds100 = candidate.ds100, var eva = candidate.eva, name = candidate.name, distance = candidate.distance; distance = candidate.distance, hafas = candidate.hafas; distance = distance.toFixed(1); var stationlink = $(document.createElement('a')); stationlink.attr('href', ds100); stationlink.attr('href', eva + '?hafas=' + hafas); stationlink.text(name); var distancenode = $(document.createElement('div')); Loading @@ -56,11 +57,11 @@ $(function() { }; var processLocation = function(loc) { $.post('/_geolocation', {lon: loc.coords.longitude, lat: loc.coords.latitude}, processResult).fail(function(jqXHR, textStatus, errorThrown) { $.post('/_geolocation', {lon: loc.coords.longitude, lat: loc.coords.latitude, hafas: window.location.href.match('hafas=1') ? 1 : 0}, processResult).fail(function(jqXHR, textStatus, errorThrown) { removeStatus(); showError("Netzwerkfehler: ", textStatus, errorThrown); }); $('div.candidatestatus').text('Suche Bahnhöfe…'); $('div.candidatestatus').text('Suche Stationen…'); }; var processError = function(error) { Loading