summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-02-14 22:59:22 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-02-14 22:59:22 +0100
commit56685ea830077964eaa5fc083d2b0cd17bb90aa5 (patch)
tree25f9cc25a7db8ffacf0a976e6a9fa60faf236de0
parent155ddeee707fe31f52e8c54b92476d746f30ea9e (diff)
parse <ref> fields in fchg. not used in db-iris yet.
-rw-r--r--lib/Travel/Status/DE/IRIS.pm21
-rw-r--r--lib/Travel/Status/DE/IRIS/Result.pm27
2 files changed, 39 insertions, 9 deletions
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<is_transfer> for a note about this.
+
+Note that unlike B<old_train_no>, 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,