Unverified Commit 7285e2ed authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

add via_stop support

parent 05661d3c
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -77,15 +77,21 @@ if ($list_services) {

parse_mot_options();

my ( $from_stop, $to_stop ) = @ARGV;
my ( $from_stop, $via_stop, $to_stop ) = @ARGV;

if ( not $from_stop and $to_stop ) {
if ( $via_stop and not $to_stop ) {
	$to_stop  = $via_stop;
	$via_stop = undef;
}

if ( not( $from_stop and $to_stop ) ) {
	show_help(1);
}

my %opt = (
	service        => $service,
	from_stop      => $from_stop,
	via_stop       => $via_stop,
	to_stop        => $to_stop,
	excluded_mots  => \@excluded_mots,
	exclusive_mots => \@exclusive_mots,
@@ -450,7 +456,7 @@ hafas - Interface to HAFAS (e.g. Deutsche Bahn) itinerary services
=head1 SYNOPSIS

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<to>
[B<-s> I<service>] [B<-l> I<language>] [B<-v>] I<from> [I<via>] I<to>

=head1 VERSION

+19 −3
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ sub new {
		messages       => [],
		results        => [],
		from_stop      => $conf{from_stop},
		via_stop       => $conf{via_stop},
		to_stop        => $conf{to_stop},
		ua             => $ua,
		now            => $now,
@@ -231,7 +232,7 @@ sub new {
	my $time    = ( $conf{datetime} // $now )->strftime('%H%M%S');
	my $outFrwd = $conf{arrival} ? \0 : undef;

	my ( $from_lid, $to_lid );
	my ( $from_lid, $via_lid, $to_lid );
	if ( $self->{from_stop} =~ m{ ^ [0-9]+ $ }x ) {
		$from_lid = 'A=1@L=' . $self->{from_stop} . '@';
	}
@@ -244,6 +245,14 @@ sub new {
	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 = {
		svcReqL => [
@@ -256,7 +265,9 @@ sub new {
					maxChg     => $conf{max_change},
					minChgTime => undef,
					outFrwd    => $outFrwd,
					viaLocL    => undef,
					viaLocL    => $via_lid
					? [ { loc => { lid => $via_lid } } ]
					: undef,
					trfReq => {
						cType    => 'PK',
						tvlrProf => [ { type => 'E' } ],
@@ -709,6 +720,11 @@ 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
must be specified either by name or by EVA ID (e.g. 8000080 for Dortmund Hbf).

=item B<via_stop> => I<stop>

Only return connections that pass I<stop>. It must be specified either by name
or by EVA ID (e.g. 8000080 for Dortmund Hbf).

=item B<arrival> => I<bool>

If true: request connections that arrive at the destination before the