diff options
Diffstat (limited to 'lib/Travelynx/Controller')
-rw-r--r-- | lib/Travelynx/Controller/Account.pm | 42 | ||||
-rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 26 |
2 files changed, 68 insertions, 0 deletions
diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index 033b270..74c272f 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -1077,6 +1077,48 @@ sub backend_form { $backend->{homepage} = 'https://www.bahn.de'; $backend->{recommended} = 1; } + elsif ( $backend->{efa} ) { + if ( my $s = $self->efa->get_service( $backend->{name} ) ) { + $type = 'EFA'; + $backend->{longname} = $s->{name}; + $backend->{homepage} = $s->{homepage}; + $backend->{regions} = [ map { $place_map{$_} // $_ } + @{ $s->{coverage}{regions} // [] } ]; + $backend->{has_area} = $s->{coverage}{area} ? 1 : 0; + + if ( + $s->{coverage}{area} + and $s->{coverage}{area}{type} eq 'Polygon' + and $self->lonlat_in_polygon( + $s->{coverage}{area}{coordinates}, + [ $user_lon, $user_lat ] + ) + ) + { + push( @suggested_backends, $backend ); + } + elsif ( $s->{coverage}{area} + and $s->{coverage}{area}{type} eq 'MultiPolygon' ) + { + for my $s_poly ( + @{ $s->{coverage}{area}{coordinates} // [] } ) + { + if ( + $self->lonlat_in_polygon( + $s_poly, [ $user_lon, $user_lat ] + ) + ) + { + push( @suggested_backends, $backend ); + last; + } + } + } + } + else { + $type = undef; + } + } elsif ( $backend->{hafas} ) { # These backends lack a journey endpoint or are no longer diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 0cfccb1..de1a547 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -1091,6 +1091,8 @@ sub station { my $dbris_service = $self->param('dbris') // ( $user->{backend_dbris} ? $user->{backend_name} : undef ); + my $efa_service = $self->param('efa') + // ( $user->{backend_efa} ? $user->{backend_name} : undef ); my $hafas_service = $self->param('hafas') // ( $user->{backend_hafas} ? $user->{backend_name} : undef ); my $motis_service = $self->param('motis') @@ -1127,6 +1129,15 @@ sub station { lookahead => 30, ); } + elsif ($efa_service) { + $promise = $self->efa->get_departures_p( + service => $efa_service, + name => $station, + timestamp => $timestamp, + lookbehind => 30, + lookahead => 30, + ); + } elsif ($motis_service) { if ( $station !~ m/.*_.*/ ) { $self->render_later; @@ -1209,6 +1220,16 @@ sub station { related_stations => [], }; } + elsif ($efa_service) { + @results = map { $_->[0] } + sort { $b->[1] <=> $a->[1] } + map { [ $_, $_->datetime->epoch ] } $status->results; + $status = { + station_eva => $status->stop->id, + station_name => $status->stop->full_name, + related_stations => [], + }; + } elsif ($motis_service) { @results = map { $_->[0] } sort { $b->[1] <=> $a->[1] } @@ -1268,12 +1289,14 @@ sub station { eva => $user_status->{cancellation}{dep_eva}, destination_name => $user_status->{cancellation}{arr_name}, + efa => $efa_service, hafas => $hafas_service, ); } else { $connections_p = $self->get_connecting_trains_p( eva => $status->{station_eva}, + efa => $efa_service, hafas => $hafas_service ); } @@ -1287,6 +1310,7 @@ sub station { 'departures', user => $user, dbris => $dbris_service, + efa => $efa_service, hafas => $hafas_service, motis => $motis_service, eva => $status->{station_eva}, @@ -1308,6 +1332,7 @@ sub station { 'departures', user => $user, dbris => $dbris_service, + efa => $efa_service, hafas => $hafas_service, motis => $motis_service, eva => $status->{station_eva}, @@ -1328,6 +1353,7 @@ sub station { 'departures', user => $user, dbris => $dbris_service, + efa => $efa_service, hafas => $hafas_service, motis => $motis_service, eva => $status->{station_eva}, |