From 5583505fb32d23a277c357f07340347ab4cd282a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 1 Nov 2014 19:45:45 +0100 Subject: allow realtime ppth to override static ppth This way, if a train has so much delay that its scheduled data was not requested in the first place, it's still possible to compared its scheduled route with its actual route --- lib/Travel/Status/DE/IRIS.pm | 18 ++++++++++-------- lib/Travel/Status/DE/IRIS/Result.pm | 12 ++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) (limited to 'lib/Travel/Status') diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm index ac7b744..06ef067 100644 --- a/lib/Travel/Status/DE/IRIS.pm +++ b/lib/Travel/Status/DE/IRIS.pm @@ -253,18 +253,20 @@ sub get_realtime { } if ($e_ar) { $result->add_ar( - arrival_ts => $e_ar->getAttribute('ct'), - platform => $e_ar->getAttribute('cp'), - route_pre => $e_ar->getAttribute('cpth'), - status => $e_ar->getAttribute('cs'), + arrival_ts => $e_ar->getAttribute('ct'), + platform => $e_ar->getAttribute('cp'), + route_pre => $e_ar->getAttribute('cpth'), + sched_route_pre => $e_ar->getAttribute('ppth'), + status => $e_ar->getAttribute('cs'), ); } if ($e_dp) { $result->add_dp( - departure_ts => $e_dp->getAttribute('ct'), - platform => $e_dp->getAttribute('cp'), - route_post => $e_dp->getAttribute('cpth'), - status => $e_dp->getAttribute('cs'), + departure_ts => $e_dp->getAttribute('ct'), + platform => $e_dp->getAttribute('cp'), + route_post => $e_dp->getAttribute('cpth'), + sched_route_post => $e_dp->getAttribute('ppth'), + status => $e_dp->getAttribute('cs'), ); } diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm index a121792..930533d 100644 --- a/lib/Travel/Status/DE/IRIS/Result.pm +++ b/lib/Travel/Status/DE/IRIS/Result.pm @@ -118,6 +118,12 @@ sub add_ar { $self->{route_start} = $self->{route_pre}[0]; } + if ( $attrib{sched_route_pre} ) { + $self->{sched_route_pre} + = [ split( qr{[|]}, $attrib{sched_route_pre} // q{} ) ]; + $self->{sched_route_start} = $self->{sched_route_pre}[0]; + } + if ( $attrib{status} and $attrib{status} eq 'c' ) { $self->{is_cancelled} = 1; } @@ -149,6 +155,12 @@ sub add_dp { $self->{route_end} = $self->{route_post}[-1]; } + if ( $attrib{sched_route_post} ) { + $self->{sched_route_post} + = [ split( qr{[|]}, $attrib{sched_route_post} // q{} ) ]; + $self->{sched_route_end} = $self->{sched_route_post}[-1]; + } + if ( $attrib{status} and $attrib{status} eq 'c' ) { $self->{is_cancelled} = 1; } -- cgit v1.2.3