summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-03-03 00:18:27 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-03-03 00:18:27 +0100
commit847c9272f8f9e4de3d41840bc23c127c629b0a66 (patch)
tree3d3325e3d32f577ac7004d742863549ca6bb4df5
parentf0ee0fb836fbb801ef5ce2babb315a4bdc49ab5a (diff)
work around inconsistent platform / platformName patterns
Probably not perfect, but duisburg, düsseldorf, essen look fine.
-rw-r--r--lib/Travel/Status/DE/EFA.pm22
1 files 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,