Unverified Commit 8036bc9c authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

dbris-m: show train type changes along the route

parent fd4b752e
Loading
Loading
Loading
Loading
+26 −7
Original line number Diff line number Diff line
@@ -414,10 +414,16 @@ elsif ( $opt{journey} and not( $raw_json_output or $json_output ) ) {
		}
	}

	printf( "%s %s am %s\n",
	printf(
		"%s %s am %s\n",
		$trip->type,
		$trip->line_no // join( q{ / }, $trip->trip_numbers ),
		$trip->day->strftime('%d.%m.%Y') );
		$trip->line_no // (
			$trip->trip_numbers
			? join( q{ / }, $trip->trip_numbers )
			: $trip->trip_no
		),
		$trip->day->strftime('%d.%m.%Y')
	);

	if ( $trip->operators ) {
		printf( "Betrieb: %s\n", join( q{, }, $trip->operators ) );
@@ -429,6 +435,11 @@ elsif ( $opt{journey} and not( $raw_json_output or $json_output ) ) {
		$prev_operator = q{};
	}

	my $prev_type;
	if ( scalar $trip->types > 1 ) {
		$prev_type = q{};
	}

	my $prev_trip_no;
	if ( scalar $trip->trip_numbers > 1 ) {
		$prev_trip_no = q{};
@@ -475,11 +486,19 @@ elsif ( $opt{journey} and not( $raw_json_output or $json_output ) ) {
			$prev_operator = $stop->operator;
		}

		if (    defined $prev_trip_no
		if (
			(
				    defined $prev_trip_no
				and defined $stop->trip_no
			and $stop->trip_no ne $prev_trip_no )
				and $stop->trip_no ne $prev_trip_no
			)
			or (    defined $prev_type
				and defined $stop->trip_type
				and $stop->trip_type ne $prev_type )
		  )
		{
			printf( '  (%s %s)', $trip->type, $stop->trip_no );
			printf( '  (%s %s)', $stop->trip_type, $stop->trip_no );
			$prev_type    = $stop->trip_type;
			$prev_trip_no = $stop->trip_no;
		}
		print("\n");