Unverified Commit 80139a3a authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Make origins return a list of hashrefs, just like destinations

parent 5859764f
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -73,7 +73,12 @@ my $wr = Travel::Status::DE::DBWagenreihung->new(
printf(
printf(
	"%s: %s → %s\n",
	"%s: %s → %s\n",
	join( ' / ', map { $wr->train_type . ' ' . $_ } $wr->train_numbers ),
	join( ' / ', map { $wr->train_type . ' ' . $_ } $wr->train_numbers ),
	join( ' / ', $wr->origins ),
	join(
		' / ',
		map {
			sprintf( '%s (%s)', $_->{name}, join( q{}, @{ $_->{sections} } ) )
		} $wr->origins
	),
	join(
	join(
		' / ',
		' / ',
		map {
		map {
+20 −11
Original line number Original line Diff line number Diff line
@@ -255,13 +255,20 @@ sub origins {
	}
	}


	my @origins;
	my @origins;
	my %section;


	for my $group ( @{ $self->{data}{istformation}{allFahrzeuggruppe} } ) {
	for my $group ( @{ $self->{data}{istformation}{allFahrzeuggruppe} } ) {
		push( @origins, $group->{startbetriebsstellename} );
		my $origin   = $group->{startbetriebsstellename};
		my @sections = map { $_->{fahrzeugsektor} } @{ $group->{allFahrzeug} };
		push( @{ $section{$origin} }, @sections );
		push( @origins,               $origin );
	}
	}


	@origins = uniq @origins;
	@origins = uniq @origins;


	@origins
	  = map { { name => $_, sections => [ uniq @{ $section{$_} } ] } } @origins;

	$self->{origins} = \@origins;
	$self->{origins} = \@origins;


	return @origins;
	return @origins;
@@ -805,13 +812,13 @@ Train number. Do not include the train type: Use "8" for "EC 8" or


=item $wr->destinations
=item $wr->destinations


Returns a list describing all final destinations of this train. In most
Returns a list describing the destinations of this train's wagons. In most
cases, it contains one element, however, for trains consisting of multiple
cases, it contains one element. For trains consisting of multiple wings or
wings, it contains one element for each wing.
trains that switch locomotives along the way, it contains one element for each
wing or other kind of wagon group.


Each destination is a hash ref containing the destination B<name> and the
Each destination is a hash ref containing its B<name> and the corresponding
corresponding platform I<sections> (at the moment, this is a list of section
platform I<sections> (at the moment, this is a list of section identifiers).
identifiers).


This function is subject to change.
This function is subject to change.


@@ -828,11 +835,13 @@ Returns undef otherwise.


=item $wr->origins
=item $wr->origins


Returns a list of stations this train originates from. In most cases, this is
Returns a list describing the origins of this train's wagons. In most
just one element; however, for trains consisting of multiple wings, it gives
cases, it contains one element. For trains consisting of multiple wings or
the origin of each wing unless they are identical.
trains that switch locomotives along the way, it contains one element for each
wing or other kind of wagon group.


Each origin is a station name.
Each origin is a hash ref containing its B<name> and the corresponding
platform I<sections> (at the moment, this is a list of section identifiers).


This function is subject to change.
This function is subject to change.