Loading lib/Travel/Status/DE/IRIS.pm +28 −20 Original line number Original line Diff line number Diff line Loading @@ -68,17 +68,19 @@ sub new_p { return $promise->reject('station identifier is ambiguous'); return $promise->reject('station identifier is ambiguous'); } } # "uic" is deprecated $self->{station} = { $self->{station} = { ds100 => $candidates[0][0], ds100 => $candidates[0][0], eva => $candidates[0][2], name => $candidates[0][1], name => $candidates[0][1], uic => $candidates[0][2], uic => $candidates[0][2], }; }; $self->{related_stations} = []; $self->{related_stations} = []; my @queue = ( $self->{station}{uic} ); my @queue = ( $self->{station}{eva} ); my @related_reqs; my @related_reqs; my @related_stations; my @related_stations; my %seen = ( $self->{station}{uic} => 1 ); my %seen = ( $self->{station}{eva} => 1 ); my $iter_depth = 0; my $iter_depth = 0; while ( @queue and $iter_depth < 12 and $opt{with_related} ) { while ( @queue and $iter_depth < 12 and $opt{with_related} ) { Loading @@ -97,10 +99,13 @@ sub new_p { @candidates = $opt{get_station}($eva); @candidates = $opt{get_station}($eva); if ( @candidates == 1 ) { if ( @candidates == 1 ) { # "uic" is deprecated push( push( @{ $self->{related_stations} }, @{ $self->{related_stations} }, { { ds100 => $candidates[0][0], ds100 => $candidates[0][0], eva => $candidates[0][2], name => $candidates[0][1], name => $candidates[0][1], uic => $candidates[0][2], uic => $candidates[0][2], } } Loading @@ -110,7 +115,7 @@ sub new_p { my $dt_req = $self->{datetime}->clone; my $dt_req = $self->{datetime}->clone; my @timetable_reqs 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) { for my $eva (@related_stations) { push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); Loading @@ -119,7 +124,7 @@ sub new_p { for ( 1 .. $lookahead_steps ) { for ( 1 .. $lookahead_steps ) { $dt_req->add( hours => 1 ); $dt_req->add( hours => 1 ); push( @timetable_reqs, 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) { for my $eva (@related_stations) { push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); } } Loading @@ -129,7 +134,7 @@ sub new_p { for ( 1 .. $lookbehind_steps ) { for ( 1 .. $lookbehind_steps ) { $dt_req->subtract( hours => 1 ); $dt_req->subtract( hours => 1 ); push( @timetable_reqs, 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) { for my $eva (@related_stations) { push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); } } Loading @@ -138,7 +143,7 @@ sub new_p { $self->{promise}->all(@timetable_reqs)->then( $self->{promise}->all(@timetable_reqs)->then( sub { sub { my @realtime_reqs my @realtime_reqs = ( $self->get_realtime_p( $self->{station}{uic} ) ); = ( $self->get_realtime_p( $self->{station}{eva} ) ); for my $eva (@related_stations) { for my $eva (@related_stations) { push( @realtime_reqs, $self->get_realtime_p( $eva, $dt_req ) ); push( @realtime_reqs, $self->get_realtime_p( $eva, $dt_req ) ); } } Loading Loading @@ -246,7 +251,7 @@ sub new { iris_base => $self->{iris_base}, iris_base => $self->{iris_base}, lookahead => $self->{lookahead}, lookahead => $self->{lookahead}, lookbehind => $self->{lookbehind}, lookbehind => $self->{lookbehind}, station => $ref->{uic}, station => $ref->{eva}, main_cache => $self->{main_cache}, main_cache => $self->{main_cache}, realtime_cache => $self->{rt_cache}, realtime_cache => $self->{rt_cache}, strptime_obj => $self->{strptime_obj}, strptime_obj => $self->{strptime_obj}, Loading @@ -264,15 +269,15 @@ sub new { } } my $dt_req = $self->{datetime}->clone; 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 ) { for ( 1 .. $lookahead_steps ) { $dt_req->add( hours => 1 ); $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; $dt_req = $self->{datetime}->clone; for ( 1 .. $lookbehind_steps ) { for ( 1 .. $lookbehind_steps ) { $dt_req->subtract( hours => 1 ); $dt_req->subtract( hours => 1 ); $self->get_timetable( $self->{station}{uic}, $dt_req ); $self->get_timetable( $self->{station}{eva}, $dt_req ); } } $self->get_realtime; $self->get_realtime; Loading Loading @@ -435,9 +440,10 @@ sub get_station_p { } } $promise->resolve( $promise->resolve( { { uic => $station_node->getAttribute('eva'), name => $station_node->getAttribute('name'), ds100 => $station_node->getAttribute('ds100'), ds100 => $station_node->getAttribute('ds100'), eva => $station_node->getAttribute('eva'), name => $station_node->getAttribute('name'), uic => $station_node->getAttribute('eva'), } } ); ); return; return; Loading Loading @@ -538,14 +544,15 @@ sub get_station { push( push( @ret, @ret, { { uic => $station_node->getAttribute('eva'), name => $station_node->getAttribute('name'), ds100 => $station_node->getAttribute('ds100'), ds100 => $station_node->getAttribute('ds100'), eva => $station_node->getAttribute('eva'), name => $station_node->getAttribute('name'), uic => $station_node->getAttribute('eva'), } } ); ); if ( $self->{developer_mode} ) { 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') ) { if ( $opt{recursive} and defined $station_node->getAttribute('meta') ) { Loading @@ -566,13 +573,13 @@ sub get_station { . "This is probably a bug" ); . "This is probably a bug" ); } } @ret = uniq_by { $_->{uic} } @ret; @ret = uniq_by { $_->{eva} } @ret; return @ret; return @ret; } } sub add_result { sub add_result { my ( $self, $station_name, $station_uic, $s ) = @_; my ( $self, $station_name, $station_eva, $s ) = @_; my $id = $s->getAttribute('id'); my $id = $s->getAttribute('id'); my $e_tl = ( $s->findnodes( $self->{xp_tl} ) )[0]; my $e_tl = ( $s->findnodes( $self->{xp_tl} ) )[0]; Loading @@ -590,7 +597,8 @@ sub add_result { train_no => $e_tl->getAttribute('n'), # dep number train_no => $e_tl->getAttribute('n'), # dep number type => $e_tl->getAttribute('c'), # S/ICE/ERB/... type => $e_tl->getAttribute('c'), # S/ICE/ERB/... station => $station_name, 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}, strptime_obj => $self->{strptime_obj}, #unknown_t => $e_tl->getAttribute('t'), # p #unknown_t => $e_tl->getAttribute('t'), # p Loading Loading @@ -741,7 +749,7 @@ sub get_realtime_p { sub get_realtime { sub get_realtime { my ($self) = @_; my ($self) = @_; my $eva = $self->{station}{uic}; my $eva = $self->{station}{eva}; my ( $raw, $err ) my ( $raw, $err ) = $self->get_with_cache( $self->{rt_cache}, = $self->get_with_cache( $self->{rt_cache}, Loading Loading @@ -1141,7 +1149,7 @@ Returns a list of hashes describing related stations whose arrivals/departures are included in B<results>. Only useful when setting arrivals/departures are included in B<results>. Only useful when setting B<with_related> to a true value, see its documentation above for details. 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 B<name> (station name), and B<ds100> (station code). Note that stations returned by B<related_stations> are not necessarily known to returned by B<related_stations> are not necessarily known to Travel::Status::DE::IRIS::Stations(3pm). Travel::Status::DE::IRIS::Stations(3pm). Loading lib/Travel/Status/DE/IRIS/Result.pm +2 −2 Original line number Original line Diff line number Diff line Loading @@ -25,7 +25,7 @@ Travel::Status::DE::IRIS::Result->mk_ro_accessors( realtime_xml route_start route_end realtime_xml route_start route_end sched_arrival sched_departure sched_platform sched_route_start sched_arrival sched_departure sched_platform sched_route_start sched_route_end start sched_route_end start station station_uic station station_eva station_uic stop_no time train_id train_no transfer type stop_no time train_id train_no transfer type unknown_t unknown_o wing_id wing_of) unknown_t unknown_o wing_id wing_of) ); ); Loading Loading @@ -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. 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. EVA number of the station this train result belongs to. This is often, but not always, identical with the UIC station number. This is often, but not always, identical with the UIC station number. Loading Loading
lib/Travel/Status/DE/IRIS.pm +28 −20 Original line number Original line Diff line number Diff line Loading @@ -68,17 +68,19 @@ sub new_p { return $promise->reject('station identifier is ambiguous'); return $promise->reject('station identifier is ambiguous'); } } # "uic" is deprecated $self->{station} = { $self->{station} = { ds100 => $candidates[0][0], ds100 => $candidates[0][0], eva => $candidates[0][2], name => $candidates[0][1], name => $candidates[0][1], uic => $candidates[0][2], uic => $candidates[0][2], }; }; $self->{related_stations} = []; $self->{related_stations} = []; my @queue = ( $self->{station}{uic} ); my @queue = ( $self->{station}{eva} ); my @related_reqs; my @related_reqs; my @related_stations; my @related_stations; my %seen = ( $self->{station}{uic} => 1 ); my %seen = ( $self->{station}{eva} => 1 ); my $iter_depth = 0; my $iter_depth = 0; while ( @queue and $iter_depth < 12 and $opt{with_related} ) { while ( @queue and $iter_depth < 12 and $opt{with_related} ) { Loading @@ -97,10 +99,13 @@ sub new_p { @candidates = $opt{get_station}($eva); @candidates = $opt{get_station}($eva); if ( @candidates == 1 ) { if ( @candidates == 1 ) { # "uic" is deprecated push( push( @{ $self->{related_stations} }, @{ $self->{related_stations} }, { { ds100 => $candidates[0][0], ds100 => $candidates[0][0], eva => $candidates[0][2], name => $candidates[0][1], name => $candidates[0][1], uic => $candidates[0][2], uic => $candidates[0][2], } } Loading @@ -110,7 +115,7 @@ sub new_p { my $dt_req = $self->{datetime}->clone; my $dt_req = $self->{datetime}->clone; my @timetable_reqs 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) { for my $eva (@related_stations) { push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); Loading @@ -119,7 +124,7 @@ sub new_p { for ( 1 .. $lookahead_steps ) { for ( 1 .. $lookahead_steps ) { $dt_req->add( hours => 1 ); $dt_req->add( hours => 1 ); push( @timetable_reqs, 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) { for my $eva (@related_stations) { push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); } } Loading @@ -129,7 +134,7 @@ sub new_p { for ( 1 .. $lookbehind_steps ) { for ( 1 .. $lookbehind_steps ) { $dt_req->subtract( hours => 1 ); $dt_req->subtract( hours => 1 ); push( @timetable_reqs, 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) { for my $eva (@related_stations) { push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); push( @timetable_reqs, $self->get_timetable_p( $eva, $dt_req ) ); } } Loading @@ -138,7 +143,7 @@ sub new_p { $self->{promise}->all(@timetable_reqs)->then( $self->{promise}->all(@timetable_reqs)->then( sub { sub { my @realtime_reqs my @realtime_reqs = ( $self->get_realtime_p( $self->{station}{uic} ) ); = ( $self->get_realtime_p( $self->{station}{eva} ) ); for my $eva (@related_stations) { for my $eva (@related_stations) { push( @realtime_reqs, $self->get_realtime_p( $eva, $dt_req ) ); push( @realtime_reqs, $self->get_realtime_p( $eva, $dt_req ) ); } } Loading Loading @@ -246,7 +251,7 @@ sub new { iris_base => $self->{iris_base}, iris_base => $self->{iris_base}, lookahead => $self->{lookahead}, lookahead => $self->{lookahead}, lookbehind => $self->{lookbehind}, lookbehind => $self->{lookbehind}, station => $ref->{uic}, station => $ref->{eva}, main_cache => $self->{main_cache}, main_cache => $self->{main_cache}, realtime_cache => $self->{rt_cache}, realtime_cache => $self->{rt_cache}, strptime_obj => $self->{strptime_obj}, strptime_obj => $self->{strptime_obj}, Loading @@ -264,15 +269,15 @@ sub new { } } my $dt_req = $self->{datetime}->clone; 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 ) { for ( 1 .. $lookahead_steps ) { $dt_req->add( hours => 1 ); $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; $dt_req = $self->{datetime}->clone; for ( 1 .. $lookbehind_steps ) { for ( 1 .. $lookbehind_steps ) { $dt_req->subtract( hours => 1 ); $dt_req->subtract( hours => 1 ); $self->get_timetable( $self->{station}{uic}, $dt_req ); $self->get_timetable( $self->{station}{eva}, $dt_req ); } } $self->get_realtime; $self->get_realtime; Loading Loading @@ -435,9 +440,10 @@ sub get_station_p { } } $promise->resolve( $promise->resolve( { { uic => $station_node->getAttribute('eva'), name => $station_node->getAttribute('name'), ds100 => $station_node->getAttribute('ds100'), ds100 => $station_node->getAttribute('ds100'), eva => $station_node->getAttribute('eva'), name => $station_node->getAttribute('name'), uic => $station_node->getAttribute('eva'), } } ); ); return; return; Loading Loading @@ -538,14 +544,15 @@ sub get_station { push( push( @ret, @ret, { { uic => $station_node->getAttribute('eva'), name => $station_node->getAttribute('name'), ds100 => $station_node->getAttribute('ds100'), ds100 => $station_node->getAttribute('ds100'), eva => $station_node->getAttribute('eva'), name => $station_node->getAttribute('name'), uic => $station_node->getAttribute('eva'), } } ); ); if ( $self->{developer_mode} ) { 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') ) { if ( $opt{recursive} and defined $station_node->getAttribute('meta') ) { Loading @@ -566,13 +573,13 @@ sub get_station { . "This is probably a bug" ); . "This is probably a bug" ); } } @ret = uniq_by { $_->{uic} } @ret; @ret = uniq_by { $_->{eva} } @ret; return @ret; return @ret; } } sub add_result { sub add_result { my ( $self, $station_name, $station_uic, $s ) = @_; my ( $self, $station_name, $station_eva, $s ) = @_; my $id = $s->getAttribute('id'); my $id = $s->getAttribute('id'); my $e_tl = ( $s->findnodes( $self->{xp_tl} ) )[0]; my $e_tl = ( $s->findnodes( $self->{xp_tl} ) )[0]; Loading @@ -590,7 +597,8 @@ sub add_result { train_no => $e_tl->getAttribute('n'), # dep number train_no => $e_tl->getAttribute('n'), # dep number type => $e_tl->getAttribute('c'), # S/ICE/ERB/... type => $e_tl->getAttribute('c'), # S/ICE/ERB/... station => $station_name, 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}, strptime_obj => $self->{strptime_obj}, #unknown_t => $e_tl->getAttribute('t'), # p #unknown_t => $e_tl->getAttribute('t'), # p Loading Loading @@ -741,7 +749,7 @@ sub get_realtime_p { sub get_realtime { sub get_realtime { my ($self) = @_; my ($self) = @_; my $eva = $self->{station}{uic}; my $eva = $self->{station}{eva}; my ( $raw, $err ) my ( $raw, $err ) = $self->get_with_cache( $self->{rt_cache}, = $self->get_with_cache( $self->{rt_cache}, Loading Loading @@ -1141,7 +1149,7 @@ Returns a list of hashes describing related stations whose arrivals/departures are included in B<results>. Only useful when setting arrivals/departures are included in B<results>. Only useful when setting B<with_related> to a true value, see its documentation above for details. 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 B<name> (station name), and B<ds100> (station code). Note that stations returned by B<related_stations> are not necessarily known to returned by B<related_stations> are not necessarily known to Travel::Status::DE::IRIS::Stations(3pm). Travel::Status::DE::IRIS::Stations(3pm). Loading
lib/Travel/Status/DE/IRIS/Result.pm +2 −2 Original line number Original line Diff line number Diff line Loading @@ -25,7 +25,7 @@ Travel::Status::DE::IRIS::Result->mk_ro_accessors( realtime_xml route_start route_end realtime_xml route_start route_end sched_arrival sched_departure sched_platform sched_route_start sched_arrival sched_departure sched_platform sched_route_start sched_route_end start sched_route_end start station station_uic station station_eva station_uic stop_no time train_id train_no transfer type stop_no time train_id train_no transfer type unknown_t unknown_o wing_id wing_of) unknown_t unknown_o wing_id wing_of) ); ); Loading Loading @@ -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. 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. EVA number of the station this train result belongs to. This is often, but not always, identical with the UIC station number. This is often, but not always, identical with the UIC station number. Loading