From d629ad663f6195287dd31f0204f9d3a163b0869c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 18 Apr 2015 23:03:15 +0200 Subject: wing_id only uses two thirds of the train_id. now wing detection actually works. --- lib/Travel/Status/DE/IRIS.pm | 3 +-- lib/Travel/Status/DE/IRIS/Result.pm | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm index da39a7c..34f7fc4 100644 --- a/lib/Travel/Status/DE/IRIS.pm +++ b/lib/Travel/Status/DE/IRIS.pm @@ -13,7 +13,6 @@ use DateTime; use Encode qw(encode decode); use List::Util qw(first); use LWP::UserAgent; -use Scalar::Util qw(weaken); use Travel::Status::DE::IRIS::Result; use XML::LibXML; @@ -298,7 +297,7 @@ sub get_realtime { sub get_result_by_id { my ( $self, $id ) = @_; - my $res = first { $_->{raw_id} eq $id } $self->results; + my $res = first { $_->wing_id eq $id } @{ $self->{results} }; return $res; } diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm index e49750f..9b09c00 100644 --- a/lib/Travel/Status/DE/IRIS/Result.pm +++ b/lib/Travel/Status/DE/IRIS/Result.pm @@ -13,6 +13,7 @@ use DateTime; use DateTime::Format::Strptime; use List::Compare; use List::MoreUtils qw(none uniq firstval); +use Scalar::Util qw(weaken); our $VERSION = '0.08'; @@ -98,7 +99,7 @@ Travel::Status::DE::IRIS::Result->mk_ro_accessors( 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) + train_id train_no transfer type unknown_t unknown_o wing_id) ); sub new { @@ -113,6 +114,7 @@ sub new { my ( $train_id, $start_ts, $stop_no ) = split( /.\K-/, $opt{raw_id} ); + $ref->{wing_id} = "${train_id}-${start_ts}"; $train_id =~ s{^-}{}; $ref->{start} = $strp->parse_datetime($start_ts); -- cgit v1.2.3