diff options
-rw-r--r-- | Changelog | 1 | ||||
-rwxr-xr-x | bin/efa | 70 |
2 files changed, 44 insertions, 27 deletions
@@ -5,6 +5,7 @@ git HEAD * Support EFA services which do not distinguish between scheduled and realtime data (also pointed out by Gregor Herrmann) * efa: Add -D/--discover option + * efa: Add -A/--auto-url option * Travel::Routing::DE::EFA: Add get_efa_urls method Travel::Routing::DE::VRR 2.06 - Sat Aug 02 2014 @@ -157,6 +157,7 @@ GetOptions( $opt, qw{ arrive|a=s + auto-url|discover-and-print|A bike|b date|d=s depart=s @@ -221,7 +222,7 @@ if ( $opt->{exclude} ) { $opt->{exclude} = [ split( /,/, join( ',', @{ $opt->{exclude} } ) ) ]; } -if ( $opt->{discover} ) { +if ( $opt->{discover} or $opt->{'auto-url'} ) { for my $pair ( Travel::Routing::DE::EFA::get_efa_urls() ) { my ( $url, $name ) = @{$pair}; $efa = eval { @@ -249,36 +250,42 @@ if ( $opt->{discover} ) { ); }; if ($efa) { + if ( $opt->{'auto-url'} ) { + last; + } printf( "%-55s (%s)\n", $url, $name ); } } - exit 0; + if ( $opt->{'discover'} ) { + exit 0; + } +} +else { + $efa = eval { + Travel::Routing::DE::EFA->new( + efa_url => $efa_url, + + origin => [ @from, $from_type ], + destination => [ @to, $to_type ], + via => ( @via ? [ @via, $via_type ] : undef ), + + arrival_time => $opt->{arrive}, + departure_time => $opt->{depart} // $opt->{time}, + date => $opt->{date}, + exclude => $opt->{exclude}, + train_type => $opt->{include}, + with_bike => $opt->{bike}, + + select_interchange_by => $opt->{prefer}, + use_near_stops => $opt->{proximity}, + walk_speed => $opt->{'walk-speed'}, + max_interchanges => $opt->{'max-change'}, + num_results => $opt->{'num-connections'}, + + lwp_options => { timeout => $opt->{timeout} }, + ); + }; } - -$efa = eval { - Travel::Routing::DE::EFA->new( - efa_url => $efa_url, - - origin => [ @from, $from_type ], - destination => [ @to, $to_type ], - via => ( @via ? [ @via, $via_type ] : undef ), - - arrival_time => $opt->{arrive}, - departure_time => $opt->{depart} // $opt->{time}, - date => $opt->{date}, - exclude => $opt->{exclude}, - train_type => $opt->{include}, - with_bike => $opt->{bike}, - - select_interchange_by => $opt->{prefer}, - use_near_stops => $opt->{proximity}, - walk_speed => $opt->{'walk-speed'}, - max_interchanges => $opt->{'max-change'}, - num_results => $opt->{'num-connections'}, - - lwp_options => { timeout => $opt->{timeout} }, - ); -}; check_for_error($@); @@ -375,6 +382,15 @@ Journey end time (overrides --time/--depart) Journey date +=item B<-A>|B<--auto-url>|B<--discover-and-print> + +Probe all known EFA entry points for the specified connection. Print the first +result which was not an error. + +Note that this may take a while and will not neccessarily return the best +result. Also, using this option by default is not recommended, as it puts +EFA services under considerable additional load. + =item B<-b>|B<--bike> Choose connections allowing to carry a bike |