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

Consistently use id_num and id_code accessor names for stop IDs

parent c1d880d8
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -330,7 +330,8 @@ sub show_coord {
sub show_stopfinder {
sub show_stopfinder {
	my $max_len = max map { length( $_->full_name ) } $efa->results;
	my $max_len = max map { length( $_->full_name ) } $efa->results;
	for my $stop ( $efa->results ) {
	for my $stop ( $efa->results ) {
		printf( "%-${max_len}s  %s\n", $stop->full_name, $stop->id );
		printf( "%-${max_len}s  %s  %s\n",
			$stop->full_name, $stop->id_num, $stop->id_code );
	}
	}
}
}


+6 −4
Original line number Original line Diff line number Diff line
@@ -441,7 +441,8 @@ sub stop {
		place     => $place,
		place     => $place,
		full_name => $point->{name},
		full_name => $point->{name},
		name      => $point->{name} =~ s{\Q$place\E,? ?}{}r,
		name      => $point->{name} =~ s{\Q$place\E,? ?}{}r,
		id        => $point->{stateless},
		id_num    => $point->{ref}{id},
		id_code   => $point->{ref}{gid},
	);
	);


	return $self->{stop};
	return $self->{stop};
@@ -468,7 +469,8 @@ sub stops {
				place     => $stop->{place},
				place     => $stop->{place},
				name      => $stop->{name},
				name      => $stop->{name},
				full_name => $stop->{nameWithPlace},
				full_name => $stop->{nameWithPlace},
				id        => $stop->{stopID},
				id_num    => $stop->{stopID},
				id_code   => $stop->{gid},
			)
			)
		);
		);
	}
	}
@@ -588,8 +590,8 @@ sub results_stopfinder {
				place     => $stop->{ref}{place},
				place     => $stop->{ref}{place},
				full_name => $stop->{name},
				full_name => $stop->{name},
				name      => $stop->{object},
				name      => $stop->{object},
				id        => $stop->{stateless},
				id_num    => $stop->{ref}{id},
				stop_id   => $stop->{ref}{gid},
				id_code   => $stop->{ref}{gid},
			)
			)
		);
		);
	}
	}
+8 −5
Original line number Original line Diff line number Diff line
@@ -15,7 +15,7 @@ our $VERSION = '3.05';
Travel::Status::DE::EFA::Departure->mk_ro_accessors(
Travel::Status::DE::EFA::Departure->mk_ro_accessors(
	qw(countdown datetime delay destination is_cancelled key line lineref mot
	qw(countdown datetime delay destination is_cancelled key line lineref mot
	  occupancy operator origin platform platform_db platform_name rt_datetime
	  occupancy operator origin platform platform_db platform_name rt_datetime
	  sched_datetime stateless stop_id train_type train_name train_no type)
	  sched_datetime stateless stop_id_num train_type train_name train_no type)
);
);


my @mot_mapping = qw{
my @mot_mapping = qw{
@@ -69,7 +69,7 @@ sub new {
		platform_type  => $departure->{pointType},
		platform_type  => $departure->{pointType},
		key            => $departure->{servingLine}{key},
		key            => $departure->{servingLine}{key},
		stateless      => $departure->{servingLine}{stateless},
		stateless      => $departure->{servingLine}{stateless},
		stop_id        => $departure->{stopID},
		stop_id_num    => $departure->{stopID},
		line           => $departure->{servingLine}{symbol},
		line           => $departure->{servingLine}{symbol},
		train_type     => $departure->{servingLine}{trainType},
		train_type     => $departure->{servingLine}{trainType},
		train_name     => $departure->{servingLine}{trainName},
		train_name     => $departure->{servingLine}{trainName},
@@ -154,7 +154,8 @@ sub parse_route {
				sched_dep => $dep,
				sched_dep => $dep,
				arr_delay => $ref->{arrValid} ? $ref->{arrDelay} : undef,
				arr_delay => $ref->{arrValid} ? $ref->{arrDelay} : undef,
				dep_delay => $ref->{depValid} ? $ref->{depDelay} : undef,
				dep_delay => $ref->{depValid} ? $ref->{depDelay} : undef,
				id        => $ref->{id},
				id_num    => $ref->{id},
				id_code   => $ref->{gid},
				full_name => $stop->{name},
				full_name => $stop->{name},
				place     => $stop->{place},
				place     => $stop->{place},
				name      => $stop->{nameWO},
				name      => $stop->{nameWO},
@@ -176,7 +177,9 @@ sub id {


	return $self->{id} = sprintf( '%s@%d(%s)%d',
	return $self->{id} = sprintf( '%s@%d(%s)%d',
		$self->stateless =~ s{ }{}gr,
		$self->stateless =~ s{ }{}gr,
		scalar $self->route_pre ? ( $self->route_pre )[0]->id : $self->stop_id,
		scalar $self->route_pre
		? ( $self->route_pre )[0]->id
		: $self->stop_id_num,
		$self->sched_datetime->strftime('%Y%m%d'),
		$self->sched_datetime->strftime('%Y%m%d'),
		$self->key );
		$self->key );
}
}
@@ -342,7 +345,7 @@ may be recent news related to the line's schedule.


Stringified unique(?) identifier of this departure; suitable for passing to
Stringified unique(?) identifier of this departure; suitable for passing to
Travel::Status::DE::EFA->new(stopseq) after decomposing it again.
Travel::Status::DE::EFA->new(stopseq) after decomposing it again.
The returned string combines B<stateless>, B<stop_id> (or the ID of the first
The returned string combines B<stateless>, B<stop_id_num> (or the ID of the first
stop in B<route_pre>, if present), B<sched_datetime>, and B<key>.
stop in B<route_pre>, if present), B<sched_datetime>, and B<key>.


=item $departure->is_cancelled
=item $departure->is_cancelled
+5 −6
Original line number Original line Diff line number Diff line
@@ -12,7 +12,7 @@ Travel::Status::DE::EFA::Stop->mk_ro_accessors(
	qw(sched_arr rt_arr arr arr_delay
	qw(sched_arr rt_arr arr arr_delay
	  sched_dep rt_dep dep dep_delay
	  sched_dep rt_dep dep dep_delay
	  occupancy delay distance_m
	  occupancy delay distance_m
	  place name full_name id stop_id latlon
	  place name full_name id_num id_code latlon
	  platform niveau)
	  platform niveau)
);
);


@@ -152,14 +152,13 @@ Delay in minutes. Departure delya if available, arrival delay otherwise.
Distance from request coordinates in meters. undef if the object has not
Distance from request coordinates in meters. undef if the object has not
been obtained by means of a coord request.
been obtained by means of a coord request.


=item $stop->id
=item $stop->id_num


Stop ID.
Stop ID (numeric).


=item $stop->stop_id
=item $stop->id_code


The other kind of stop ID.
Stop ID (code).
Yes, EFA has two.


=item $stop->place
=item $stop->place


+6 −4
Original line number Original line Diff line number Diff line
@@ -49,6 +49,7 @@ sub polyline {
	my ( $self, %opt ) = @_;
	my ( $self, %opt ) = @_;


	if ( $opt{fallback} and not @{ $self->{polyline} // [] } ) {
	if ( $opt{fallback} and not @{ $self->{polyline} // [] } ) {

		# TODO add $_->{id} as well?
		# TODO add $_->{id} as well?
		return map { $_->{latlon} } $self->route;
		return map { $_->{latlon} } $self->route;
	}
	}
@@ -77,7 +78,7 @@ sub route {


	for my $stop ( @{ $self->{route_raw} // [] } ) {
	for my $stop ( @{ $self->{route_raw} // [] } ) {
		my $chain = $stop;
		my $chain = $stop;
		my ( $platform, $place, $name, $name_full, $stop_id );
		my ( $platform, $place, $name, $name_full, $id_num, $id_code );
		while ( $chain->{type} ) {
		while ( $chain->{type} ) {
			if ( $chain->{type} eq 'platform' ) {
			if ( $chain->{type} eq 'platform' ) {
				$platform = $chain->{properties}{platformName}
				$platform = $chain->{properties}{platformName}
@@ -86,7 +87,8 @@ sub route {
			elsif ( $chain->{type} eq 'stop' ) {
			elsif ( $chain->{type} eq 'stop' ) {
				$name      = $chain->{disassembledName};
				$name      = $chain->{disassembledName};
				$name_full = $chain->{name};
				$name_full = $chain->{name};
				$stop_id   = $chain->{properties}{stopId};
				$id_code   = $chain->{id};
				$id_num    = $chain->{properties}{stopId};
			}
			}
			elsif ( $chain->{type} eq 'locality' ) {
			elsif ( $chain->{type} eq 'locality' ) {
				$place = $chain->{name};
				$place = $chain->{name};
@@ -106,8 +108,8 @@ sub route {
				place     => $place,
				place     => $place,
				niveau    => $stop->{niveau},
				niveau    => $stop->{niveau},
				platform  => $platform,
				platform  => $platform,
				id        => $stop->{id},
				id_code   => $id_code,
				stop_id   => $stop_id,
				id_num    => $id_num,
			)
			)
		);
		);
	}
	}