summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-07-26 20:31:12 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-07-26 20:31:12 +0200
commitde828666cfafcf2d767e67c5f0d568f9e6eb9be0 (patch)
tree5d98243bca6a1f3adef816f1778345e85a934ad2 /lib/Travel/Status/DE
parent9231b5cfa20b46cc16e4edf86654a955380a973a (diff)
add mot filter support
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r--lib/Travel/Status/DE/EFA.pm4
-rw-r--r--lib/Travel/Status/DE/EFA/Line.pm13
-rw-r--r--lib/Travel/Status/DE/EFA/Result.pm13
3 files changed, 28 insertions, 2 deletions
diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm
index df79cca..73a05fb 100644
--- a/lib/Travel/Status/DE/EFA.pm
+++ b/lib/Travel/Status/DE/EFA.pm
@@ -293,6 +293,7 @@ sub lines {
my $direction = $e->getAttribute('direction');
my $valid = $e->getAttribute('valid');
my $type = $e_info->getAttribute('name');
+ my $mot = $e->getAttribute('motType');
my $route = ( $e_route ? $e_route->textContent : undef );
my $operator = ( $e_oper ? $e_oper->textContent : undef );
my $identifier = $e->getAttribute('stateless');
@@ -304,6 +305,7 @@ sub lines {
direction => decode( 'UTF-8', $direction ),
valid => $valid,
type => decode( 'UTF-8', $type ),
+ mot => $mot,
route => decode( 'UTF-8', $route ),
operator => decode( 'UTF-8', $operator ),
identifier => $identifier,
@@ -408,6 +410,7 @@ sub results {
my $countdown = $e->getAttribute('countdown');
my $delay = $e_info->getAttribute('delay');
my $type = $e_info->getAttribute('name');
+ my $mot = $e_line->getAttribute('motType');
my $platform_is_db = 0;
@@ -467,6 +470,7 @@ sub results {
sched_date => $date,
sched_time => $time,
type => $type,
+ mot => $mot,
prev_route => \@prev_route,
next_route => \@next_route,
)
diff --git a/lib/Travel/Status/DE/EFA/Line.pm b/lib/Travel/Status/DE/EFA/Line.pm
index 35560b2..0f5f090 100644
--- a/lib/Travel/Status/DE/EFA/Line.pm
+++ b/lib/Travel/Status/DE/EFA/Line.pm
@@ -9,7 +9,12 @@ use parent 'Class::Accessor';
our $VERSION = '1.11';
Travel::Status::DE::EFA::Line->mk_ro_accessors(
- qw(direction name operator route type valid));
+ qw(direction mot name operator route type valid));
+
+my @mot_mapping = qw{
+ zug s-bahn u-bahn stadtbahn tram stadtbus regionalbus
+ schnellbus seilbahn schiff ast sonstige
+};
sub new {
my ( $obj, %conf ) = @_;
@@ -19,6 +24,12 @@ sub new {
return bless( $ref, $obj );
}
+sub mot_name {
+ my ($self) = @_;
+
+ return $mot_mapping[ $self->{mot} ] // 'sonstige';
+}
+
sub TO_JSON {
my ($self) = @_;
diff --git a/lib/Travel/Status/DE/EFA/Result.pm b/lib/Travel/Status/DE/EFA/Result.pm
index d516e25..bb0243b 100644
--- a/lib/Travel/Status/DE/EFA/Result.pm
+++ b/lib/Travel/Status/DE/EFA/Result.pm
@@ -12,9 +12,14 @@ our $VERSION = '1.11';
Travel::Status::DE::EFA::Result->mk_ro_accessors(
qw(countdown date delay destination is_cancelled info key line lineref
- platform platform_db platform_name sched_date sched_time time type)
+ mot platform platform_db platform_name sched_date sched_time time type)
);
+my @mot_mapping = qw{
+ zug s-bahn u-bahn stadtbahn tram stadtbus regionalbus
+ schnellbus seilbahn schiff ast sonstige
+};
+
sub new {
my ( $obj, %conf ) = @_;
@@ -31,6 +36,12 @@ sub new {
return bless( $ref, $obj );
}
+sub mot_name {
+ my ($self) = @_;
+
+ return $mot_mapping[ $self->{mot} ] // 'sonstige';
+}
+
sub route_pre {
my ($self) = @_;