Loading bin/hafas +4 −8 Original line number Original line Diff line number Diff line Loading @@ -77,12 +77,8 @@ if ($list_services) { parse_mot_options(); parse_mot_options(); my ( $from_stop, $via_stop, $to_stop ) = @ARGV; my ( $from_stop, @via_stops ) = @ARGV; my $to_stop = pop @via_stops; if ( $via_stop and not $to_stop ) { $to_stop = $via_stop; $via_stop = undef; } if ( not( $from_stop and $to_stop ) ) { if ( not( $from_stop and $to_stop ) ) { show_help(1); show_help(1); Loading @@ -91,7 +87,7 @@ if ( not( $from_stop and $to_stop ) ) { my %opt = ( my %opt = ( service => $service, service => $service, from_stop => $from_stop, from_stop => $from_stop, via_stop => $via_stop, via_stops => \@via_stops, to_stop => $to_stop, to_stop => $to_stop, excluded_mots => \@excluded_mots, excluded_mots => \@excluded_mots, exclusive_mots => \@exclusive_mots, exclusive_mots => \@exclusive_mots, Loading Loading @@ -456,7 +452,7 @@ hafas - Interface to HAFAS (e.g. Deutsche Bahn) itinerary services =head1 SYNOPSIS =head1 SYNOPSIS B<hafas> [B<-d> I<date>] [B<-t> I<time>] [B<-m> I<motlist>] B<hafas> [B<-d> I<date>] [B<-t> I<time>] [B<-m> I<motlist>] [B<-s> I<service>] [B<-l> I<language>] [B<-v>] I<from> [I<via>] I<to> [B<-s> I<service>] [B<-l> I<language>] [B<-v>] I<from> [I<via> ...] I<to> =head1 VERSION =head1 VERSION Loading lib/Travel/Routing/DE/HAFAS.pm +22 −31 Original line number Original line Diff line number Diff line Loading @@ -218,7 +218,7 @@ sub new { messages => [], messages => [], results => [], results => [], from_stop => $conf{from_stop}, from_stop => $conf{from_stop}, via_stop => $conf{via_stop}, via_stops => $conf{via_stops} // [], to_stop => $conf{to_stop}, to_stop => $conf{to_stop}, ua => $ua, ua => $ua, now => $now, now => $now, Loading @@ -232,41 +232,21 @@ sub new { my $time = ( $conf{datetime} // $now )->strftime('%H%M%S'); my $time = ( $conf{datetime} // $now )->strftime('%H%M%S'); my $outFrwd = $conf{arrival} ? \0 : undef; my $outFrwd = $conf{arrival} ? \0 : undef; my ( $from_lid, $via_lid, $to_lid ); my @via_locs = map { $self->stop_to_hafas($_) } @{ $self->{via_stops} }; if ( $self->{from_stop} =~ m{ ^ [0-9]+ $ }x ) { $from_lid = 'A=1@L=' . $self->{from_stop} . '@'; } else { $from_lid = 'A=1@O=' . $self->{from_stop} . '@'; } if ( $self->{to_stop} =~ m{ ^ [0-9]+ $ }x ) { $to_lid = 'A=1@L=' . $self->{to_stop} . '@'; } else { $to_lid = 'A=1@O=' . $self->{to_stop} . '@'; } if ( $self->{via_stop} ) { if ( $self->{via_stop} =~ m{ ^ [0-9]+ $ }x ) { $via_lid = 'A=1@L=' . $self->{via_stop} . '@'; } else { $via_lid = 'A=1@O=' . $self->{via_stop} . '@'; } } $req = { $req = { svcReqL => [ svcReqL => [ { { meth => 'TripSearch', meth => 'TripSearch', req => { req => { depLocL => [ { lid => $from_lid } ], depLocL => [ $self->stop_to_hafas( $self->{from_stop} ) ], arrLocL => [ { lid => $to_lid } ], arrLocL => [ $self->stop_to_hafas( $self->{to_stop} ) ], numF => 6, numF => 6, maxChg => $conf{max_change}, maxChg => $conf{max_change}, minChgTime => undef, minChgTime => undef, outFrwd => $outFrwd, outFrwd => $outFrwd, viaLocL => $via_lid viaLocL => @via_locs ? [ { loc => { lid => $via_lid } } ] ? [ map { { loc => $_ } } @via_locs ] : undef, : undef, trfReq => { trfReq => { cType => 'PK', cType => 'PK', Loading Loading @@ -425,6 +405,17 @@ sub mot_mask { return $mot_mask; return $mot_mask; } } sub stop_to_hafas { my ( $self, $stop ) = @_; if ( $stop =~ m{ ^ [0-9]+ $ }x ) { return { lid => 'A=1@L=' . $stop . '@' }; } else { return { lid => 'A=1@O=' . $stop . '@' }; } } sub post_with_cache { sub post_with_cache { my ( $self, $url ) = @_; my ( $self, $url ) = @_; my $cache = $self->{cache}; my $cache = $self->{cache}; Loading Loading @@ -720,10 +711,10 @@ must be specified either by name or by EVA ID (e.g. 8000080 for Dortmund Hbf). Destination stop, e.g. "Essen HBf" or "Alfredusbad, Essen (Ruhr)". The stop Destination stop, e.g. "Essen HBf" or "Alfredusbad, Essen (Ruhr)". The stop must be specified either by name or by EVA ID (e.g. 8000080 for Dortmund Hbf). must be specified either by name or by EVA ID (e.g. 8000080 for Dortmund Hbf). =item B<via_stop> => I<stop> =item B<via_stops> => [I<stop1>, I<stop2>, ...] Only return connections that pass I<stop>. It must be specified either by name Only return connections that pass all specified stops. Individual stops are or by EVA ID (e.g. 8000080 for Dortmund Hbf). identified by name or by EVA ID (e.g. 8000080 for Dortmund Hbf). =item B<arrival> => I<bool> =item B<arrival> => I<bool> Loading Loading
bin/hafas +4 −8 Original line number Original line Diff line number Diff line Loading @@ -77,12 +77,8 @@ if ($list_services) { parse_mot_options(); parse_mot_options(); my ( $from_stop, $via_stop, $to_stop ) = @ARGV; my ( $from_stop, @via_stops ) = @ARGV; my $to_stop = pop @via_stops; if ( $via_stop and not $to_stop ) { $to_stop = $via_stop; $via_stop = undef; } if ( not( $from_stop and $to_stop ) ) { if ( not( $from_stop and $to_stop ) ) { show_help(1); show_help(1); Loading @@ -91,7 +87,7 @@ if ( not( $from_stop and $to_stop ) ) { my %opt = ( my %opt = ( service => $service, service => $service, from_stop => $from_stop, from_stop => $from_stop, via_stop => $via_stop, via_stops => \@via_stops, to_stop => $to_stop, to_stop => $to_stop, excluded_mots => \@excluded_mots, excluded_mots => \@excluded_mots, exclusive_mots => \@exclusive_mots, exclusive_mots => \@exclusive_mots, Loading Loading @@ -456,7 +452,7 @@ hafas - Interface to HAFAS (e.g. Deutsche Bahn) itinerary services =head1 SYNOPSIS =head1 SYNOPSIS B<hafas> [B<-d> I<date>] [B<-t> I<time>] [B<-m> I<motlist>] B<hafas> [B<-d> I<date>] [B<-t> I<time>] [B<-m> I<motlist>] [B<-s> I<service>] [B<-l> I<language>] [B<-v>] I<from> [I<via>] I<to> [B<-s> I<service>] [B<-l> I<language>] [B<-v>] I<from> [I<via> ...] I<to> =head1 VERSION =head1 VERSION Loading
lib/Travel/Routing/DE/HAFAS.pm +22 −31 Original line number Original line Diff line number Diff line Loading @@ -218,7 +218,7 @@ sub new { messages => [], messages => [], results => [], results => [], from_stop => $conf{from_stop}, from_stop => $conf{from_stop}, via_stop => $conf{via_stop}, via_stops => $conf{via_stops} // [], to_stop => $conf{to_stop}, to_stop => $conf{to_stop}, ua => $ua, ua => $ua, now => $now, now => $now, Loading @@ -232,41 +232,21 @@ sub new { my $time = ( $conf{datetime} // $now )->strftime('%H%M%S'); my $time = ( $conf{datetime} // $now )->strftime('%H%M%S'); my $outFrwd = $conf{arrival} ? \0 : undef; my $outFrwd = $conf{arrival} ? \0 : undef; my ( $from_lid, $via_lid, $to_lid ); my @via_locs = map { $self->stop_to_hafas($_) } @{ $self->{via_stops} }; if ( $self->{from_stop} =~ m{ ^ [0-9]+ $ }x ) { $from_lid = 'A=1@L=' . $self->{from_stop} . '@'; } else { $from_lid = 'A=1@O=' . $self->{from_stop} . '@'; } if ( $self->{to_stop} =~ m{ ^ [0-9]+ $ }x ) { $to_lid = 'A=1@L=' . $self->{to_stop} . '@'; } else { $to_lid = 'A=1@O=' . $self->{to_stop} . '@'; } if ( $self->{via_stop} ) { if ( $self->{via_stop} =~ m{ ^ [0-9]+ $ }x ) { $via_lid = 'A=1@L=' . $self->{via_stop} . '@'; } else { $via_lid = 'A=1@O=' . $self->{via_stop} . '@'; } } $req = { $req = { svcReqL => [ svcReqL => [ { { meth => 'TripSearch', meth => 'TripSearch', req => { req => { depLocL => [ { lid => $from_lid } ], depLocL => [ $self->stop_to_hafas( $self->{from_stop} ) ], arrLocL => [ { lid => $to_lid } ], arrLocL => [ $self->stop_to_hafas( $self->{to_stop} ) ], numF => 6, numF => 6, maxChg => $conf{max_change}, maxChg => $conf{max_change}, minChgTime => undef, minChgTime => undef, outFrwd => $outFrwd, outFrwd => $outFrwd, viaLocL => $via_lid viaLocL => @via_locs ? [ { loc => { lid => $via_lid } } ] ? [ map { { loc => $_ } } @via_locs ] : undef, : undef, trfReq => { trfReq => { cType => 'PK', cType => 'PK', Loading Loading @@ -425,6 +405,17 @@ sub mot_mask { return $mot_mask; return $mot_mask; } } sub stop_to_hafas { my ( $self, $stop ) = @_; if ( $stop =~ m{ ^ [0-9]+ $ }x ) { return { lid => 'A=1@L=' . $stop . '@' }; } else { return { lid => 'A=1@O=' . $stop . '@' }; } } sub post_with_cache { sub post_with_cache { my ( $self, $url ) = @_; my ( $self, $url ) = @_; my $cache = $self->{cache}; my $cache = $self->{cache}; Loading Loading @@ -720,10 +711,10 @@ must be specified either by name or by EVA ID (e.g. 8000080 for Dortmund Hbf). Destination stop, e.g. "Essen HBf" or "Alfredusbad, Essen (Ruhr)". The stop Destination stop, e.g. "Essen HBf" or "Alfredusbad, Essen (Ruhr)". The stop must be specified either by name or by EVA ID (e.g. 8000080 for Dortmund Hbf). must be specified either by name or by EVA ID (e.g. 8000080 for Dortmund Hbf). =item B<via_stop> => I<stop> =item B<via_stops> => [I<stop1>, I<stop2>, ...] Only return connections that pass I<stop>. It must be specified either by name Only return connections that pass all specified stops. Individual stops are or by EVA ID (e.g. 8000080 for Dortmund Hbf). identified by name or by EVA ID (e.g. 8000080 for Dortmund Hbf). =item B<arrival> => I<bool> =item B<arrival> => I<bool> Loading