From 847c9272f8f9e4de3d41840bc23c127c629b0a66 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 3 Mar 2014 00:18:27 +0100 Subject: work around inconsistent platform / platformName patterns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Probably not perfect, but duisburg, düsseldorf, essen look fine. --- lib/Travel/Status/DE/EFA.pm | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm index 0909414..0f199c6 100644 --- a/lib/Travel/Status/DE/EFA.pm +++ b/lib/Travel/Status/DE/EFA.pm @@ -314,7 +314,7 @@ sub results { my $rdate = $e_rdate ? sprintf_date($e_rdate) : $date; my $rtime = $e_rtime ? sprintf_time($e_rtime) : $time; - my $platform; # 'platform' attribute is unreliable + my $platform = $e->getAttribute('platform'); my $platform_name = $e->getAttribute('platformName'); my $line = $e_line->getAttribute('number'); my $dest = $e_line->getAttribute('direction'); @@ -330,12 +330,26 @@ sub results { = grep { $_->{identifier} eq $e_line->getAttribute('stateless') } @{ $self->{lines} }; - if ( $platform_name =~ m{ ^ Gleis }ox ) { + # platform / platformName are inconsistent. The following cases are + # known: + # + # * platform="int", platformName="" : non-DB platform + # * platform="int", platformName="Bstg. int" : non-DB platform + # * platform="#int", platformName="Gleis int" : non-DB platform + # * platform="#int", platformName="Gleis int" : DB platform? + # * platform="", platformName="Gleis int" : DB platform + # * platform="DB", platformName="Gleis int" : DB platform + # * platform="gibberish", platformName="Gleis int" : DB platform + + if ( ( $platform_name and $platform_name =~ m{ ^ Gleis }ox ) + and not( $platform and $platform =~ s{ ^ \# }{}ox ) ) + { $platform_is_db = 1; } - # Gleis x / Bstg. x -> take x - $platform = ( split( / /, $platform_name ) )[1]; + if ($platform_name) { + $platform = ( split( / /, $platform_name ) )[1]; + } push( @results, -- cgit v1.2.3