Loading bin/dbris +30 −8 Original line number Diff line number Diff line Loading @@ -65,14 +65,26 @@ if ($use_cache) { } } my ( $from_raw, $to_raw ) = @ARGV; if ( not( $from_raw and $to_raw ) ) { my ( $from_raw, @via_raw, $to_raw ); if ( @ARGV < 2 ) { show_help(1); } elsif ( @ARGV == 2 ) { ( $from_raw, $to_raw ) = @ARGV; } elsif ( @ARGV <= 4 ) { ( $from_raw, @via_raw ) = @ARGV; $to_raw = pop(@via_raw); } sub get_stop { my ($stop) = @_; my ( $stop, $is_via ) = @_; my $stopover_duration; if ( $is_via and $stop =~ s{ : (?<duration> \d+ ) $ }{}x ) { $stopover_duration = $+{duration}; } my $ris = Travel::Status::DE::DBRIS->new( cache => $cache, locationSearch => $stop, Loading @@ -85,6 +97,12 @@ sub get_stop { my $found; for my $result ( $ris->results ) { if ( defined $result->eva ) { if ($is_via) { return { stop => $result, duration => $stopover_duration, }; } return $result; } } Loading @@ -93,8 +111,9 @@ sub get_stop { } my %opt = ( from => get_stop($from_raw), to => get_stop($to_raw), from => get_stop( $from_raw, 0 ), to => get_stop( $to_raw, 0 ), via => [ map { get_stop( $_, 1 ) } @via_raw ], language => $language, cache => $cache, developer_mode => $developer_mode, Loading Loading @@ -340,7 +359,8 @@ dbris - Interface to bahn.de public transit routing service =head1 SYNOPSIS B<dbris> [B<-d> I<DD.MM.YYYY>] [B<-t> I<HH:MM>] [...] I<from-stop> I<to-stop> B<dbris> [B<-d> I<DD.MM.YYYY>] [B<-t> I<HH:MM>] [...] I<from-stop> [I<via-stop>[:I<duration>] [I<via-stop>[:I<duration>]]] I<to-stop> =head1 VERSION Loading @@ -349,7 +369,9 @@ version 0.01 =head1 DESCRIPTION B<dbris> is an interface to the public transport routing service available on bahn.de. It requests connections between two stops and prints the results. bahn.de. It requests connections between I<from-stop> and I<to-stop> and prints the result. If one or two I<via-stop>s are specified, it only returns matching connections, with an optional minimum stopover I<duration> given in minutes. =head1 OPTIONS Loading lib/Travel/Routing/DE/DBRIS.pm +15 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,14 @@ sub new { deutschlandTicketVorhanden => \0 }; for my $via ( @{ $conf{via} } ) { my $via_stop = { id => $via->{stop}->id }; if ( $via->{duration} ) { $via_stop->{aufenthaltsdauer} = 0 + $via->{duration}; } push( @{ $req->{zwischenhalte} }, $via_stop ); } if ( @{ $conf{discounts} // [] } ) { $req->{reisende}[0]{ermaessigungen} = []; } Loading Loading @@ -346,6 +354,13 @@ the requested itinerary. A Travel::Status::DE::DBRIS::Location(3pm) instance describing the destination of the requested itinerary. =item B<via> => I<arrayref> An arrayref containing up to two hashrefs that describe stopovers which must be part of the requested itinerary. Each hashref consists of two keys: B<stop> (Travel::Status::DE::DBRIS::Location(3pm) object, mandatory) and B<duration> (stopover duration in minutes, optional, default: 0). =item B<cache> => I<cache> A Cache::File(3pm) instance used for caching bahn.de requests. Loading Loading
bin/dbris +30 −8 Original line number Diff line number Diff line Loading @@ -65,14 +65,26 @@ if ($use_cache) { } } my ( $from_raw, $to_raw ) = @ARGV; if ( not( $from_raw and $to_raw ) ) { my ( $from_raw, @via_raw, $to_raw ); if ( @ARGV < 2 ) { show_help(1); } elsif ( @ARGV == 2 ) { ( $from_raw, $to_raw ) = @ARGV; } elsif ( @ARGV <= 4 ) { ( $from_raw, @via_raw ) = @ARGV; $to_raw = pop(@via_raw); } sub get_stop { my ($stop) = @_; my ( $stop, $is_via ) = @_; my $stopover_duration; if ( $is_via and $stop =~ s{ : (?<duration> \d+ ) $ }{}x ) { $stopover_duration = $+{duration}; } my $ris = Travel::Status::DE::DBRIS->new( cache => $cache, locationSearch => $stop, Loading @@ -85,6 +97,12 @@ sub get_stop { my $found; for my $result ( $ris->results ) { if ( defined $result->eva ) { if ($is_via) { return { stop => $result, duration => $stopover_duration, }; } return $result; } } Loading @@ -93,8 +111,9 @@ sub get_stop { } my %opt = ( from => get_stop($from_raw), to => get_stop($to_raw), from => get_stop( $from_raw, 0 ), to => get_stop( $to_raw, 0 ), via => [ map { get_stop( $_, 1 ) } @via_raw ], language => $language, cache => $cache, developer_mode => $developer_mode, Loading Loading @@ -340,7 +359,8 @@ dbris - Interface to bahn.de public transit routing service =head1 SYNOPSIS B<dbris> [B<-d> I<DD.MM.YYYY>] [B<-t> I<HH:MM>] [...] I<from-stop> I<to-stop> B<dbris> [B<-d> I<DD.MM.YYYY>] [B<-t> I<HH:MM>] [...] I<from-stop> [I<via-stop>[:I<duration>] [I<via-stop>[:I<duration>]]] I<to-stop> =head1 VERSION Loading @@ -349,7 +369,9 @@ version 0.01 =head1 DESCRIPTION B<dbris> is an interface to the public transport routing service available on bahn.de. It requests connections between two stops and prints the results. bahn.de. It requests connections between I<from-stop> and I<to-stop> and prints the result. If one or two I<via-stop>s are specified, it only returns matching connections, with an optional minimum stopover I<duration> given in minutes. =head1 OPTIONS Loading
lib/Travel/Routing/DE/DBRIS.pm +15 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,14 @@ sub new { deutschlandTicketVorhanden => \0 }; for my $via ( @{ $conf{via} } ) { my $via_stop = { id => $via->{stop}->id }; if ( $via->{duration} ) { $via_stop->{aufenthaltsdauer} = 0 + $via->{duration}; } push( @{ $req->{zwischenhalte} }, $via_stop ); } if ( @{ $conf{discounts} // [] } ) { $req->{reisende}[0]{ermaessigungen} = []; } Loading Loading @@ -346,6 +354,13 @@ the requested itinerary. A Travel::Status::DE::DBRIS::Location(3pm) instance describing the destination of the requested itinerary. =item B<via> => I<arrayref> An arrayref containing up to two hashrefs that describe stopovers which must be part of the requested itinerary. Each hashref consists of two keys: B<stop> (Travel::Status::DE::DBRIS::Location(3pm) object, mandatory) and B<duration> (stopover duration in minutes, optional, default: 0). =item B<cache> => I<cache> A Cache::File(3pm) instance used for caching bahn.de requests. Loading