From 940a5d0921c3f767254222c3da05a7cdad0b9ce7 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 14 Jul 2019 21:30:53 +0200 Subject: Result: Document ->station accessor, add ->station_uic Both are useful to determine which sub-station a departure belongs to when using with_related => 1. --- lib/Travel/Status/DE/IRIS.pm | 13 +++++++------ lib/Travel/Status/DE/IRIS/Result.pm | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) (limited to 'lib/Travel') diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm index f2d831f..1780557 100644 --- a/lib/Travel/Status/DE/IRIS.pm +++ b/lib/Travel/Status/DE/IRIS.pm @@ -44,7 +44,7 @@ sub new { developer_mode => $opt{developer_mode}, iris_base => $opt{iris_base} // 'http://iris.noncd.db.de/iris-tts/timetable', - lookahead => $opt{lookahead} // ( 2 * 60 ), + lookahead => $opt{lookahead} // ( 2 * 60 ), lookbehind => $opt{lookbehind} // ( 0 * 60 ), main_cache => $opt{main_cache}, rt_cache => $opt{realtime_cache}, @@ -144,7 +144,7 @@ sub new { } @{ $self->{results} } = grep { - my $d = $_->departure // $_->arrival; + my $d = $_->departure // $_->arrival; my $s = $_->sched_arrival // $_->sched_departure // $_->arrival // $d; $d = $d->subtract_datetime( $self->{datetime} ); $s = $s->subtract_datetime( $self->{datetime} ); @@ -292,7 +292,7 @@ sub get_station { } sub add_result { - my ( $self, $station, $s ) = @_; + my ( $self, $station_name, $station_uic, $s ) = @_; my $id = $s->getAttribute('id'); my $e_tl = ( $s->findnodes( $self->{xp_tl} ) )[0]; @@ -308,7 +308,8 @@ sub add_result { classes => $e_tl->getAttribute('f'), # D N S F train_no => $e_tl->getAttribute('n'), # dep number type => $e_tl->getAttribute('c'), # S/ICE/ERB/... - station => $station, + station => $station_name, + station_uic => $station_uic + 0, # UIC IDs are numbers strptime_obj => $self->{strptime_obj}, #unknown_o => $e_tl->getAttribute('o'), # owner: 03/80/R2/... @@ -383,7 +384,7 @@ sub get_timetable { for my $s ( $xml->findnodes('/timetable/s') ) { - $self->add_result( $station, $s ); + $self->add_result( $station, $eva, $s ); } return $self; @@ -426,7 +427,7 @@ sub get_realtime { # add_result will return nothing if no ./tl node is present. The ./tl # check here is for optimization purposes. if ( not $result and ( $s->findnodes( $self->{xp_tl} ) )[0] ) { - $result = $self->add_result( $station, $s ); + $result = $self->add_result( $station, $eva, $s ); if ($result) { $result->set_unscheduled(1); } diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm index 31c37c4..2b3b993 100644 --- a/lib/Travel/Status/DE/IRIS/Result.pm +++ b/lib/Travel/Status/DE/IRIS/Result.pm @@ -111,11 +111,13 @@ Travel::Status::DE::IRIS::Result->mk_ro_accessors( qw(arrival arrival_delay arrival_is_additional arrival_is_cancelled date datetime delay departure departure_delay departure_is_additional departure_is_cancelled - is_transfer is_unscheduled is_wing + ds100 is_transfer is_unscheduled is_wing line_no old_train_id old_train_no platform raw_id realtime_xml route_start route_end sched_arrival sched_departure sched_platform sched_route_start - sched_route_end start stop_no time train_id train_no transfer type + sched_route_end start + station station_uic + stop_no time train_id train_no transfer type unknown_t unknown_o wing_id) ); @@ -1129,6 +1131,14 @@ Name of the first station served by this train according to its schedule. DateTime(3pm) object for the scheduled start of the train on its route (i.e. the departure time at its first station). +=item $result->station + +Name of the station this train result belongs to. + +=item $result->station_uic + +UIC number of the station this train result belongs to. + =item $result->stop_no Number of this stop on the train's route. 1 if it's the start station, 2 -- cgit v1.2.3