map, journey view: handle renamed stations
This commit is contained in:
parent
1028e47a35
commit
3e9807b393
2 changed files with 30 additions and 3 deletions
|
@ -197,8 +197,7 @@ sub startup {
|
||||||
|
|
||||||
$self->attr(
|
$self->attr(
|
||||||
coordinates_by_station => sub {
|
coordinates_by_station => sub {
|
||||||
my $legacy_names = JSON->new->utf8->decode(
|
my $legacy_names = $self->app->renamed_station;
|
||||||
scalar read_file('share/old_station_names.json') );
|
|
||||||
my %location;
|
my %location;
|
||||||
for
|
for
|
||||||
my $station ( Travel::Status::DE::IRIS::Stations::get_stations() )
|
my $station ( Travel::Status::DE::IRIS::Stations::get_stations() )
|
||||||
|
@ -225,6 +224,14 @@ sub startup {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$self->attr(
|
||||||
|
renamed_station => sub {
|
||||||
|
my $legacy_to_new = JSON->new->utf8->decode(
|
||||||
|
scalar read_file('share/old_station_names.json') );
|
||||||
|
return $legacy_to_new;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$self->attr(
|
$self->attr(
|
||||||
station_by_eva => sub {
|
station_by_eva => sub {
|
||||||
my %map;
|
my %map;
|
||||||
|
@ -2710,6 +2717,12 @@ sub startup {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $opt{verbose} ) {
|
if ( $opt{verbose} ) {
|
||||||
|
my $rename = $self->app->renamed_station;
|
||||||
|
for my $stop ( @{ $ref->{route} } ) {
|
||||||
|
if ( $rename->{ $stop->[0] } ) {
|
||||||
|
$stop->[0] = $rename->{ $stop->[0] };
|
||||||
|
}
|
||||||
|
}
|
||||||
$ref->{cancelled} = $entry->{cancelled};
|
$ref->{cancelled} = $entry->{cancelled};
|
||||||
my @parsed_messages;
|
my @parsed_messages;
|
||||||
for my $message ( @{ $ref->{messages} // [] } ) {
|
for my $message ( @{ $ref->{messages} // [] } ) {
|
||||||
|
|
|
@ -471,9 +471,23 @@ sub map_history {
|
||||||
for my $journey (@journeys) {
|
for my $journey (@journeys) {
|
||||||
|
|
||||||
my @route = map { $_->[0] } @{ $journey->{route} };
|
my @route = map { $_->[0] } @{ $journey->{route} };
|
||||||
|
|
||||||
my $from_index = first_index { $_ eq $journey->{from_name} } @route;
|
my $from_index = first_index { $_ eq $journey->{from_name} } @route;
|
||||||
my $to_index = first_index { $_ eq $journey->{to_name} } @route;
|
my $to_index = first_index { $_ eq $journey->{to_name} } @route;
|
||||||
|
|
||||||
|
if ( $from_index == -1 ) {
|
||||||
|
my $rename = $self->app->renamed_station;
|
||||||
|
$from_index
|
||||||
|
= first_index { ( $rename->{$_} // $_ ) eq $journey->{from_name} }
|
||||||
|
@route;
|
||||||
|
}
|
||||||
|
if ( $to_index == -1 ) {
|
||||||
|
my $rename = $self->app->renamed_station;
|
||||||
|
$to_index
|
||||||
|
= first_index { ( $rename->{$_} // $_ ) eq $journey->{to_name} }
|
||||||
|
@route;
|
||||||
|
}
|
||||||
|
|
||||||
if ( $from_index == -1
|
if ( $from_index == -1
|
||||||
or $to_index == -1 )
|
or $to_index == -1 )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue