Unverified Commit 31ef58b4 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

station board: add mode-of-transit filter

parent 6d44f63a
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ use List::Util qw(max);
use Travel::Status::DE::DBRIS;

my ( $date, $time );
my $mots;
my $developer_mode;
my $show_jid;
my $use_cache = 1;
@@ -34,6 +35,7 @@ GetOptions(
	'd|date=s'             => \$date,
	'h|help'               => sub { show_help(0) },
	'j|with-jid'           => \$show_jid,
	'm|modes-of-transit=s' => \$mots,
	't|time=s'             => \$time,
	'V|version'            => \&show_version,
	'cache!'               => \$use_cache,
@@ -140,6 +142,10 @@ if ( $date or $time ) {
	$opt{datetime} = $dt;
}

if ($mots) {
	$opt{modes_of_transit} = [ split( qr{, *}, $mots ) ];
}

my $status = Travel::Status::DE::DBRIS->new(%opt);

sub show_help {
+11 −6
Original line number Diff line number Diff line
@@ -49,6 +49,13 @@ sub new {
	if ( my $station = $conf{station} ) {
		my $dt = $conf{datetime}
		  // DateTime->now( time_zone => 'Europe/Berlin' );
		my @mots
		  = (
			qw(ICE EC_IC IR REGIONAL SBAHN BUS SCHIFF UBAHN TRAM ANRUFPFLICHTIG)
		  );
		if ( $conf{modes_of_transit} ) {
			@mots = @{ $conf{modes_of_transit} // [] };
		}
		$req
		  = 'https://www.bahn.de/web/api/reiseloesung/abfahrten'
		  . '?datum='
@@ -59,12 +66,10 @@ sub new {
		  . $station->{eva}
		  . '&ortId='
		  . $station->{id}
		  . '&mitVias=true&maxVias=8'
		  . '&verkehrsmittel[]=ICE&verkehrsmittel[]=EC_IC'
		  . '&verkehrsmittel[]=IR&verkehrsmittel[]=REGIONAL'
		  . '&verkehrsmittel[]=SBAHN&verkehrsmittel[]=BUS'
		  . '&verkehrsmittel[]=SCHIFF&verkehrsmittel[]=UBAHN'
		  . '&verkehrsmittel[]=TRAM&verkehrsmittel[]=ANRUFPFLICHTIG';
		  . '&mitVias=true&maxVias=8';
		for my $mot (@mots) {
			$req .= '&verkehrsmittel[]=' . $mot;
		}
	}
	elsif ( my $gs = $conf{geoSearch} ) {
		my $lat = $gs->{latitude};