diff options
-rw-r--r-- | Changelog | 7 | ||||
-rwxr-xr-x | bin/db-iris | 4 | ||||
-rw-r--r-- | lib/Travel/Status/DE/IRIS.pm | 52 | ||||
-rw-r--r-- | lib/Travel/Status/DE/IRIS/Result.pm | 8 | ||||
-rw-r--r-- | lib/Travel/Status/DE/IRIS/Stations.pm.PL | 4 |
5 files changed, 45 insertions, 30 deletions
@@ -1,3 +1,10 @@ +Travel::Status::DE::IRIS 1.96 - Sun Feb 25 2024 + + * Re-add Wipperliese stations (service resumes on March 29th, 2024) + * IRIS->new / get_station: correctly handle non-EVA station identifiers + in with_related mode. Previously, these caused (harmless, but annoying) + "isn't numeric in numeric eq (==)" warnings. + Travel::Status::DE::IRIS 1.95 - Thu Feb 22 2024 * Update qos/delay message texts diff --git a/bin/db-iris b/bin/db-iris index 1f5b555..08906e2 100755 --- a/bin/db-iris +++ b/bin/db-iris @@ -4,7 +4,7 @@ use warnings; use 5.014; use utf8; -our $VERSION = '1.95'; +our $VERSION = '1.96'; use DateTime; use DateTime::Format::Strptime; @@ -587,7 +587,7 @@ B<db-iris> [B<-rx>] [B<-d> I<date>] [B<-o> I<output-flags>] =head1 VERSION -version 1.95 +version 1.96 =head1 DESCRIPTION diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm index c059411..60f5d49 100644 --- a/lib/Travel/Status/DE/IRIS.pm +++ b/lib/Travel/Status/DE/IRIS.pm @@ -4,7 +4,7 @@ use strict; use warnings; use 5.014; -our $VERSION = '1.95'; +our $VERSION = '1.96'; use Carp qw(confess cluck); use DateTime; @@ -68,17 +68,19 @@ sub new_p { return $promise->reject('station identifier is ambiguous'); } + # "uic" is deprecated $self->{station} = { ds100 => $candidates[0][0], + eva => $candidates[0][2], name => $candidates[0][1], uic => $candidates[0][2], }; $self->{related_stations} = []; - my @queue = ( $self->{station}{uic} ); + my @queue = ( $self->{station}{eva} ); my @related_reqs; my @related_stations; - my %seen = ( $self->{station}{uic} => 1 ); + my %seen = ( $self->{station}{eva} => 1 ); my $iter_depth = 0; while ( @queue and $iter_depth < 12 and $opt{with_related} ) { @@ -97,10 +99,13 @@ sub new_p { @candidates = $opt{get_station}($eva); if ( @candidates == 1 ) { + + # "uic" is deprecated push( @{ $self->{related_stations} }, { ds100 => $candidates[0][0], + eva => $candidates[0][2], name => $candidates[0][1], uic => $candidates[0][2], } @@ -110,7 +115,7 @@ sub new_p { my $dt_req = $self->{datetime}->clone; my @timetable_reqs - = ( $self->get_timetable_p( $self->{station}{uic}, $dt_req ) ); + = ( $self->get_timetable_p( $self->{station}{eva}, $dt_req ) ); for my $eva (@related_stations) { push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); @@ -119,7 +124,7 @@ sub new_p { for ( 1 .. $lookahead_steps ) { $dt_req->add( hours => 1 ); push( @timetable_reqs, - $self->get_timetable_p( $self->{station}{uic}, $dt_req ) ); + $self->get_timetable_p( $self->{station}{eva}, $dt_req ) ); for my $eva (@related_stations) { push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); } @@ -129,7 +134,7 @@ sub new_p { for ( 1 .. $lookbehind_steps ) { $dt_req->subtract( hours => 1 ); push( @timetable_reqs, - $self->get_timetable_p( $self->{station}{uic}, $dt_req ) ); + $self->get_timetable_p( $self->{station}{eva}, $dt_req ) ); for my $eva (@related_stations) { push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); } @@ -138,7 +143,7 @@ sub new_p { $self->{promise}->all(@timetable_reqs)->then( sub { my @realtime_reqs - = ( $self->get_realtime_p( $self->{station}{uic} ) ); + = ( $self->get_realtime_p( $self->{station}{eva} ) ); for my $eva (@related_stations) { push( @realtime_reqs, $self->get_realtime_p( $eva, $dt_req ) ); } @@ -246,7 +251,7 @@ sub new { iris_base => $self->{iris_base}, lookahead => $self->{lookahead}, lookbehind => $self->{lookbehind}, - station => $ref->{uic}, + station => $ref->{eva}, main_cache => $self->{main_cache}, realtime_cache => $self->{rt_cache}, strptime_obj => $self->{strptime_obj}, @@ -264,15 +269,15 @@ sub new { } my $dt_req = $self->{datetime}->clone; - $self->get_timetable( $self->{station}{uic}, $dt_req ); + $self->get_timetable( $self->{station}{eva}, $dt_req ); for ( 1 .. $lookahead_steps ) { $dt_req->add( hours => 1 ); - $self->get_timetable( $self->{station}{uic}, $dt_req ); + $self->get_timetable( $self->{station}{eva}, $dt_req ); } $dt_req = $self->{datetime}->clone; for ( 1 .. $lookbehind_steps ) { $dt_req->subtract( hours => 1 ); - $self->get_timetable( $self->{station}{uic}, $dt_req ); + $self->get_timetable( $self->{station}{eva}, $dt_req ); } $self->get_realtime; @@ -435,9 +440,10 @@ sub get_station_p { } $promise->resolve( { - uic => $station_node->getAttribute('eva'), - name => $station_node->getAttribute('name'), ds100 => $station_node->getAttribute('ds100'), + eva => $station_node->getAttribute('eva'), + name => $station_node->getAttribute('name'), + uic => $station_node->getAttribute('eva'), } ); return; @@ -538,14 +544,15 @@ sub get_station { push( @ret, { - uic => $station_node->getAttribute('eva'), - name => $station_node->getAttribute('name'), ds100 => $station_node->getAttribute('ds100'), + eva => $station_node->getAttribute('eva'), + name => $station_node->getAttribute('name'), + uic => $station_node->getAttribute('eva'), } ); if ( $self->{developer_mode} ) { - printf( " -> %s (%s / %s)\n", @{ $ret[-1] }{qw{name uic ds100}} ); + printf( " -> %s (%s / %s)\n", @{ $ret[-1] }{qw{name eva ds100}} ); } if ( $opt{recursive} and defined $station_node->getAttribute('meta') ) { @@ -566,13 +573,13 @@ sub get_station { . "This is probably a bug" ); } - @ret = uniq_by { $_->{uic} } @ret; + @ret = uniq_by { $_->{eva} } @ret; return @ret; } sub add_result { - my ( $self, $station_name, $station_uic, $s ) = @_; + my ( $self, $station_name, $station_eva, $s ) = @_; my $id = $s->getAttribute('id'); my $e_tl = ( $s->findnodes( $self->{xp_tl} ) )[0]; @@ -590,7 +597,8 @@ sub add_result { train_no => $e_tl->getAttribute('n'), # dep number type => $e_tl->getAttribute('c'), # S/ICE/ERB/... station => $station_name, - station_uic => $station_uic + 0, # UIC IDs are numbers + station_eva => $station_eva + 0, # EVA IDs are numbers + station_uic => $station_eva + 0, # deprecated strptime_obj => $self->{strptime_obj}, #unknown_t => $e_tl->getAttribute('t'), # p @@ -741,7 +749,7 @@ sub get_realtime_p { sub get_realtime { my ($self) = @_; - my $eva = $self->{station}{uic}; + my $eva = $self->{station}{eva}; my ( $raw, $err ) = $self->get_with_cache( $self->{rt_cache}, @@ -988,7 +996,7 @@ Non-blocking variant (EXPERIMENTAL): =head1 VERSION -version 1.95 +version 1.96 =head1 DESCRIPTION @@ -1141,7 +1149,7 @@ Returns a list of hashes describing related stations whose arrivals/departures are included in B<results>. Only useful when setting B<with_related> to a true value, see its documentation above for details. -Each hash contains the keys B<uic> (EVA number; often same as UIC station ID), +Each hash contains the keys B<eva> (EVA number; often same as UIC station ID), B<name> (station name), and B<ds100> (station code). Note that stations returned by B<related_stations> are not necessarily known to Travel::Status::DE::IRIS::Stations(3pm). diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm index 8b2f5ca..9113f88 100644 --- a/lib/Travel/Status/DE/IRIS/Result.pm +++ b/lib/Travel/Status/DE/IRIS/Result.pm @@ -14,7 +14,7 @@ use List::Util qw(any); use List::MoreUtils qw(uniq lastval); use Scalar::Util qw(weaken); -our $VERSION = '1.95'; +our $VERSION = '1.96'; Travel::Status::DE::IRIS::Result->mk_ro_accessors( qw(arrival arrival_delay arrival_has_realtime arrival_is_additional arrival_is_cancelled arrival_hidden @@ -25,7 +25,7 @@ Travel::Status::DE::IRIS::Result->mk_ro_accessors( realtime_xml route_start route_end sched_arrival sched_departure sched_platform sched_route_start sched_route_end start - station station_uic + station station_eva station_uic stop_no time train_id train_no transfer type unknown_t unknown_o wing_id wing_of) ); @@ -939,7 +939,7 @@ arrival/departure received by Travel::Status::DE::IRIS =head1 VERSION -version 1.95 +version 1.96 =head1 DESCRIPTION @@ -1284,7 +1284,7 @@ DateTime(3pm) object for the scheduled start of the train on its route Name of the station this train result belongs to. -=item $result->station_uic +=item $result->station_eva EVA number of the station this train result belongs to. This is often, but not always, identical with the UIC station number. diff --git a/lib/Travel/Status/DE/IRIS/Stations.pm.PL b/lib/Travel/Status/DE/IRIS/Stations.pm.PL index 3e0189c..edfcf63 100644 --- a/lib/Travel/Status/DE/IRIS/Stations.pm.PL +++ b/lib/Travel/Status/DE/IRIS/Stations.pm.PL @@ -34,7 +34,7 @@ use Text::LevenshteinXS qw(distance); # TODO switch to Text::Levenshtein::XS once AUR/Debian packages become available -our $VERSION = '1.95'; +our $VERSION = '1.96'; # Automatically generated, see share/stations.json my @stations = ( @@ -204,7 +204,7 @@ Travel::Status::DE::IRIS::Stations - Station name to station code mapping =head1 VERSION -version 1.95 +version 1.96 =head1 DESCRIPTION |