From 56685ea830077964eaa5fc083d2b0cd17bb90aa5 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 14 Feb 2014 22:59:22 +0100 Subject: parse fields in fchg. not used in db-iris yet. --- lib/Travel/Status/DE/IRIS.pm | 21 ++++++++++++++++----- lib/Travel/Status/DE/IRIS/Result.pm | 27 +++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 9 deletions(-) (limited to 'lib/Travel/Status') diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm index aef946d..79852e7 100644 --- a/lib/Travel/Status/DE/IRIS.pm +++ b/lib/Travel/Status/DE/IRIS.pm @@ -192,11 +192,12 @@ sub get_realtime { my $station = ( $xml->findnodes('/timetable') )[0]->getAttribute('station'); for my $s ( $xml->findnodes('/timetable/s') ) { - my $id = $s->getAttribute('id'); - my $e_tl = ( $s->findnodes('./tl') )[0]; - my $e_ar = ( $s->findnodes('./ar') )[0]; - my $e_dp = ( $s->findnodes('./dp') )[0]; - my @e_ms = $s->findnodes('.//m'); + my $id = $s->getAttribute('id'); + my $e_tl = ( $s->findnodes('./tl') )[0]; + my $e_ar = ( $s->findnodes('./ar') )[0]; + my $e_dp = ( $s->findnodes('./dp') )[0]; + my $e_ref = ( $s->findnodes('./ref') )[0]; + my @e_ms = $s->findnodes('.//m'); my %messages; @@ -234,6 +235,16 @@ sub get_realtime { unknown_o => $e_tl->getAttribute('o'), # owner: 03/80/R2/... ); } + if ($e_ref) { + $result->add_ref( + class => $e_ref->getAttribute('f'), # D N S F + unknown_t => $e_ref->getAttribute('t'), # p + train_no => $e_ref->getAttribute('n'), # dep number + type => $e_ref->getAttribute('c'), # S/ICE/ERB/... + line_no => $e_ref->getAttribute('l'), # 1 -> S1, ... + unknown_o => $e_ref->getAttribute('o'), # owner: 03/80/R2/... + ); + } if ($e_ar) { $result->add_ar( arrival_ts => $e_ar->getAttribute('ct'), diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm index 6b4ebb1..75f02cc 100644 --- a/lib/Travel/Status/DE/IRIS/Result.pm +++ b/lib/Travel/Status/DE/IRIS/Result.pm @@ -17,10 +17,10 @@ our $VERSION = '0.03'; Travel::Status::DE::IRIS::Result->mk_ro_accessors( qw(arrival classes date datetime delay departure is_cancelled is_transfer - 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 unknown_t unknown_o) + line_no train_no_transfer 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 unknown_t unknown_o) ); sub new { @@ -171,6 +171,16 @@ sub add_realtime { return $self; } +sub add_ref { + my ( $self, %attrib ) = @_; + + $self->{train_no_transfer} = $attrib{train_no}; + + # TODO + + return $self; +} + sub add_tl { my ( $self, %attrib ) = @_; @@ -766,6 +776,15 @@ stations. Number of this train, unique per day. E.g. C<< 2225 >> for C<< IC 2225 >>. +=item $result->train_no_transfer + +Number of this train after a following transfer, undefined if no such transfer +exists. See B for a note about this. + +Note that unlike B, this information is always based on realtime +data (not included in any schedule) and only set for stations before the +transfer station, not the transfer station itself. + =item $result->type Type of this train, e.g. C<< S >> for S-Bahn, C<< RE >> for Regional-Express, -- cgit v1.2.3