diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2020-02-25 17:55:19 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2020-02-25 17:55:19 +0100 |
commit | 1d2b37f8496fbb9aa03afec50ac9dc496567a908 (patch) | |
tree | d0e92cc0d6d91c265f8260c96265f92ce02d9bd3 | |
parent | 5c05ed609f3033fa97ec00089ed6885034ad9405 (diff) |
Ignore polylines which do not agree with IRIS route1.15.2
-rwxr-xr-x | lib/Travelynx.pm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 538ec29..7795ed4 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -2052,6 +2052,7 @@ sub startup { my ($tx) = @_; my $body = decode( 'utf-8', $tx->res->body ); my $json = JSON->new->decode($body); + my @station_list; my @coordinate_list; for my $feature ( @{ $json->{polyline}{features} } ) { @@ -2061,6 +2062,8 @@ sub startup { and $feature->{properties}{type} eq 'stop' ) { push( @{$coord}, $feature->{properties}{id} ); + push( @station_list, + $feature->{properties}{name} ); } push( @coordinate_list, $coord ); } @@ -2073,7 +2076,20 @@ sub startup { }; $cache->freeze( $url, $ret ); - $promise->resolve($ret); + + my $iris_stations = join( '|', $train->route ); + my $hafas_stations = join( '|', @station_list ); + + if ( $iris_stations ne $hafas_stations ) { + $self->app->log->warn( 'Ignoring polyline for ' + . $train->line + . ": IRIS route does not agree with HAFAS route: $iris_stations != $hafas_stations" + ); + $promise->reject('polyline route mismatch'); + } + else { + $promise->resolve($ret); + } } )->catch( sub { |