Commit 53a32113 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

re-add mot support (basics at least)

parent e51bb2b0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ my $types = q{};
my $language;
my $developer_mode;
my ( $list_services, $service, $hafas_url );
my @excluded_mots;

my @output;

@@ -50,6 +51,7 @@ if ($list_services) {
for my $type ( split( qr{,}, $types ) ) {
	if ( substr( $type, 0, 1 ) eq q{!} ) {
		$train_type{ substr( $type, 1 ) } = 0;
		push( @excluded_mots, substr( $type, 1 ) );
	}
	else {
		$train_type{$type} = 1;
@@ -59,7 +61,7 @@ for my $type ( split( qr{,}, $types ) ) {
my $status = Travel::Status::DE::HAFAS->new(
	date           => $date,
	language       => $language,
	mot            => \%train_type,
	excluded_mots  => \@excluded_mots,
	station        => shift || show_help(1),
	time           => $time,
	mode           => $arrivals ? 'arr' : 'dep',
+27 −10
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@ my %hafas_instance = (
	DB => {
		url  => 'http://reiseauskunft.bahn.de/bin/bhftafel.exe',
		name => 'Deutsche Bahn',
		productbits => [qw[ice ic_ec d regio s bus ferry u tram ondemand x x x x]],
		productbits =>
		  [qw[ice ic_ec d regio s bus ferry u tram ondemand x x x x]],
	},
	NASA => {
		url         => 'http://reiseauskunft.insa.de/bin/stboard.exe',
@@ -60,6 +61,7 @@ sub new {
	my $ref = {
		active_service => $service,
		developer_mode => $conf{developer_mode},
		excluded_mots  => $conf{excluded_mots},
		post           => {
			input => $conf{station},
			date  => $date,
@@ -114,10 +116,25 @@ sub set_productfilter {

	my $service = $self->{active_service};

	if ($service and exists $hafas_instance{$service}{productbits}) {
	if ( not $service or not exists $hafas_instance{$service}{productbits} ) {
		return;
	}

	$self->{post}{productsFilter}
	  = '1' x ( scalar @{ $hafas_instance{$service}{productbits} } );

	if ( $self->{excluded_mots} and @{ $self->{excluded_mots} } ) {
		my %mot_pos;
		for my $i ( 0 .. $#{ $hafas_instance{$service}{productbits} } ) {
			$mot_pos{ $hafas_instance{$service}{productbits}[$i] } = $i;
		}
		for my $mot ( @{ $self->{excluded_mots} } ) {
			if ( exists $mot_pos{$mot} ) {
				substr( $self->{post}{productsFilter}, $mot_pos{$mot}, 1 ) = 0;
			}
		}
	}

}

sub check_input_error {