Commit 1d5e4aed authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Initial support for intermediate stops (via -E -E). will be cleaned up tomorrow

parent 10d600e8
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ GetOptions(
		date|d=s
		depart=s
		exclude|e=s@
		extended-info|E
		extended-info|E+
		from=s@{2}
		help|h
		ignore-info|I:s
@@ -215,9 +215,18 @@ for my $i ( 0 .. $#routes ) {
		}

		printf(
			"%-5s ab  %-30s %-20s %s\n%-5s an  %s\n\n",
			"%-5s ab  %-30s %-20s %s\n",
			$c->departure_time, $c->departure_stop_and_platform,
			$c->train_line,     $c->train_destination,
		);

		if ( $opt->{'extended-info'} and $opt->{'extended-info'} == 2 ) {
			for my $via ( @{ $c->{via} } ) {
				printf( "%-5s     %-22s %s\n", @{$via}[ 1 .. 3 ] );
			}
		}

		printf( "%-5s an  %s\n\n",
			$c->arrival_time, $c->arrival_stop_and_platform,
		);
	}
+29 −0
Original line number Diff line number Diff line
@@ -443,6 +443,7 @@ sub parse_part {
	  = XML::LibXML::XPathExpression->new('./itdPoint[@usage="arrival"]');
	my $xp_date = XML::LibXML::XPathExpression->new('./itdDateTime/itdDate');
	my $xp_time = XML::LibXML::XPathExpression->new('./itdDateTime/itdTime');
	my $xp_via  = XML::LibXML::XPathExpression->new('./itdStopSeq/itdPoint');

#	my $xp_tdate = XML::LibXML::XPathExpression->new('./itdDateTimeTarget/itdDate');
#	my $xp_ttime = XML::LibXML::XPathExpression->new('./itdDateTimeTarget/itdTime');
@@ -497,6 +498,34 @@ sub parse_part {
			$hash->{$key} = decode( 'UTF-8', $hash->{$key} );
		}

		for my $ve ( $e->findnodes($xp_via) ) {
			my $e_vdate = ( $ve->findnodes($xp_date) )[-1];
			my $e_vtime = ( $ve->findnodes($xp_time) )[-1];

			if ( not( $e_vdate and $e_vtime )
				or ( $e_vdate->getAttribute('weekday') == -1 ) )
			{
				next;
			}

			my $name = decode( 'UTF-8', $ve->getAttribute('name') );
			my $platform = $ve->getAttribute('platformName');

			if ( $name ~~ [ $hash->{departure_stop}, $hash->{arrival_stop} ] ) {
				next;
			}

			push(
				@{ $hash->{via} },
				[
					$self->itddate_str($e_vdate),
					$self->itdtime_str($e_vtime),
					$name,
					$platform
				]
			);
		}

		$hash->{extra} = [ map { decode( 'UTF-8', $_->textContent ) } @e_info ];

		push( @route_parts, $hash );