summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog6
-rwxr-xr-xbin/efa-m24
-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
5 files changed, 55 insertions, 5 deletions
diff --git a/Changelog b/Changelog
index 2aeeacd..5a059b3 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,9 @@
+git HEAD
+
+ * Line: Add mot and mot_name accessors
+ * Result: Add mot and mot_name accessors
+ * efa-m: Add -m / --mot option
+
Travel::Status::DE::VRR 1.11 - Tue Jun 30 2015
* efa-m: Remove -V alias for --version
diff --git a/bin/efa-m b/bin/efa-m
index 8c527a4..520d03a 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -20,7 +20,7 @@ my ( $date, $time, $input_type, $list_lines, $offset, $relative_times );
my ($full_routes);
my ( $filter_via, $track_via );
my ( $timeout, $developer_mode );
-my ( @grep_lines, @grep_platforms );
+my ( @grep_lines, @grep_platforms, @grep_mots );
my ( %edata, @edata_pre );
@ARGV = map { decode( 'UTF-8', $_ ) } @ARGV;
@@ -30,6 +30,7 @@ GetOptions(
'h|help' => sub { show_help(0) },
'l|line=s@' => \@grep_lines,
'L|linelist' => \$list_lines,
+ 'm|mot=s@' => \@grep_mots,
'o|offset=i' => \$offset,
'O|output=s@' => \@edata_pre,
'p|platform=s@' => \@grep_platforms,
@@ -51,6 +52,7 @@ if ( @ARGV != 2 ) {
# --line=foo,bar support
@edata_pre = split( qr{,}, join( q{,}, @edata_pre ) );
@grep_lines = split( qr{,}, join( q{,}, @grep_lines ) );
+@grep_mots = split( qr{,}, join( q{,}, @grep_mots ) );
@grep_platforms = split( qr{,}, join( q{,}, @grep_platforms ) );
my ( $place, $input ) = @ARGV;
@@ -174,7 +176,13 @@ sub show_lines {
for my $l ( $status->lines ) {
- if ( @grep_lines and not( $l->name ~~ \@grep_lines ) ) {
+ if ( ( @grep_lines and not( $l->name ~~ \@grep_lines ) )
+ or ( @grep_mots and not( $l->mot_name ~~ \@grep_mots ) ) )
+ {
+ next;
+ }
+
+ if ( @grep_mots and not( $l->mot_name ~~ \@grep_mots ) ) {
next;
}
@@ -206,7 +214,8 @@ sub show_results {
}
if (
- ( @grep_lines and not( $d->line ~~ \@grep_lines ) )
+ ( @grep_lines and not( $d->line ~~ \@grep_lines ) )
+ or ( @grep_mots and not( $d->mot_name ~~ \@grep_mots ) )
or ( @grep_platforms
and not( $platform ~~ \@grep_platforms ) )
or ( $offset and $d->countdown < $offset )
@@ -326,6 +335,15 @@ using B<--date> and B<--time> are guaranteed to be included.
Only show departures of I<lines> (comma-separatad list, option may be
repeated)
+=item B<-m>, B<--mot> I<motlist>
+
+Only show departures whose type appears in I<motlist> (comma-separated list,
+this option may be repeated).
+
+The following departure types ("modes of transport") are supported:
+zug, s-bahn, u-bahn, stadtbahn, tram, stadtbus, regionalbus, schnellbus,
+seilbahn, schiff, ast, sonstige
+
=item B<-o>, B<--offset> I<minutes>
Ignore departures which are less than I<minutes> from now.
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) = @_;