Loading Changelog +4 −0 Original line number Diff line number Diff line git HEAD * IRIS / db-iris: Add lookahead option Travel::Status::DE::IRIS 0.02 - Mon Feb 03 2014 * Fix warnings when encountering unplanned (fchg-only) trains without Loading bin/db-iris +18 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ use List::MoreUtils qw(none); use Travel::Status::DE::IRIS; use Travel::Status::DE::IRIS::Stations; my ( $date, $time ); my ( $date, $time, $lookahead ); my $datetime = DateTime->now( time_zone => 'Europe/Berlin' ); my $realtime = 0; my ( $filter_via, $track_via, $status_via ); Loading @@ -34,6 +34,7 @@ GetOptions( 'c|class=s@' => \@grep_class, 'd|date=s' => \$date, 'h|help' => sub { show_help(0) }, 'l|lookahead=i' => \$lookahead, 'o|output=s@' => \@edata_pre, 'p|platform=s@' => \@grep_platform, 'r|realtime' => \$realtime, Loading Loading @@ -94,9 +95,13 @@ for my $efield (@edata_pre) { my $status = Travel::Status::DE::IRIS->new( datetime => $datetime, lookahead => $lookahead, station => $station, ); if ($track_via) { # lookahead should not be used here - the via stop is reached an unknown # amount of time later $status_via = Travel::Status::DE::IRIS->new( datetime => $datetime, station => $track_via, Loading Loading @@ -378,6 +383,16 @@ Request results for I<date> in dd.mm. oder dd.mm.YYYY format. Note that only slight (a few hours max) deviations from the current time are supported by the IRIS backend, larger ones will not return data. =item B<-l>, B<--lookahead> I<int> Return only those results which are less than I<int> minutes in the future. Defaults to 240 (4 hours). Note that this is only an upper limit, not a guarantee to get every train with a departure in less than I<int> minutes. This guarantee holds only for I<int> below 120. However, any non-negative number is accepted for this option. =item B<-o>, B<--output> I<outputtypes> For each result, output I<outputtypes> in addition to the normal time, delay, Loading lib/Travel/Status/DE/IRIS.pm +15 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ sub new { // DateTime->now( time_zone => 'Europe/Berlin' ), iris_base => $opt{iris_base} // 'http://iris.noncd.db.de/iris-tts/timetable', lookahead => $opt{lookahead} // ( 4 * 60 ), station => $opt{station}, user_agent => $ua, }; Loading Loading @@ -68,7 +69,7 @@ sub new { my $d = ( $_->departure // $_->arrival ) ->subtract_datetime( $self->{datetime} ); not $d->is_negative and $d->in_units('hours') < 4 not $d->is_negative and $d->in_units('minutes') < $self->{lookahead} } @{ $self->{results} }; @{ $self->{results} } Loading Loading @@ -303,6 +304,18 @@ current date and time. IRIS base url, defaults to C<< http://iris.noncd.db.de/iris-tts/timetable >>. =item B<lookahead> => I<int> Compute only those results which are less than I<int> minutes in the future. Default: 240 (4 hours). Note that the DeutscheBahn IRIS backend only provides schedules up to four to five hours into the future, and this module only requests data for up to three hours. So in most cases, setting this to a value above 180 minutes will have no effect. However, as the IRIS occasionally contains unscheduled departures or qos messages known far in advance (e.g. 12 hours from now), any non-negative integer is accepted. =item B<station> => I<stationcode> Mandatory: Which station to return departures for. Note that this is not a Loading t/31-result-basics.t +19 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ use 5.014; use utf8; use DateTime; use Test::More tests => 435; use Test::More tests => 436; use Test::Fatal; use Travel::Status::DE::IRIS; Loading Loading @@ -87,3 +87,21 @@ $status = Travel::Status::DE::IRIS->new( @results = $status->results; is(@results, 0, 'no data available -> empty result list'); $status = Travel::Status::DE::IRIS->new( iris_base => 'file:t/in', lookahead => 0, station => 'EE', datetime => DateTime->new( year => 2014, month => 1, day => 3, hour => 20, minute => 1, time_zone => 'Europe/Berlin' ) ); @results = $status->results; is(@results, 0, 'lookahead 0 -> no results'); Loading
Changelog +4 −0 Original line number Diff line number Diff line git HEAD * IRIS / db-iris: Add lookahead option Travel::Status::DE::IRIS 0.02 - Mon Feb 03 2014 * Fix warnings when encountering unplanned (fchg-only) trains without Loading
bin/db-iris +18 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ use List::MoreUtils qw(none); use Travel::Status::DE::IRIS; use Travel::Status::DE::IRIS::Stations; my ( $date, $time ); my ( $date, $time, $lookahead ); my $datetime = DateTime->now( time_zone => 'Europe/Berlin' ); my $realtime = 0; my ( $filter_via, $track_via, $status_via ); Loading @@ -34,6 +34,7 @@ GetOptions( 'c|class=s@' => \@grep_class, 'd|date=s' => \$date, 'h|help' => sub { show_help(0) }, 'l|lookahead=i' => \$lookahead, 'o|output=s@' => \@edata_pre, 'p|platform=s@' => \@grep_platform, 'r|realtime' => \$realtime, Loading Loading @@ -94,9 +95,13 @@ for my $efield (@edata_pre) { my $status = Travel::Status::DE::IRIS->new( datetime => $datetime, lookahead => $lookahead, station => $station, ); if ($track_via) { # lookahead should not be used here - the via stop is reached an unknown # amount of time later $status_via = Travel::Status::DE::IRIS->new( datetime => $datetime, station => $track_via, Loading Loading @@ -378,6 +383,16 @@ Request results for I<date> in dd.mm. oder dd.mm.YYYY format. Note that only slight (a few hours max) deviations from the current time are supported by the IRIS backend, larger ones will not return data. =item B<-l>, B<--lookahead> I<int> Return only those results which are less than I<int> minutes in the future. Defaults to 240 (4 hours). Note that this is only an upper limit, not a guarantee to get every train with a departure in less than I<int> minutes. This guarantee holds only for I<int> below 120. However, any non-negative number is accepted for this option. =item B<-o>, B<--output> I<outputtypes> For each result, output I<outputtypes> in addition to the normal time, delay, Loading
lib/Travel/Status/DE/IRIS.pm +15 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ sub new { // DateTime->now( time_zone => 'Europe/Berlin' ), iris_base => $opt{iris_base} // 'http://iris.noncd.db.de/iris-tts/timetable', lookahead => $opt{lookahead} // ( 4 * 60 ), station => $opt{station}, user_agent => $ua, }; Loading Loading @@ -68,7 +69,7 @@ sub new { my $d = ( $_->departure // $_->arrival ) ->subtract_datetime( $self->{datetime} ); not $d->is_negative and $d->in_units('hours') < 4 not $d->is_negative and $d->in_units('minutes') < $self->{lookahead} } @{ $self->{results} }; @{ $self->{results} } Loading Loading @@ -303,6 +304,18 @@ current date and time. IRIS base url, defaults to C<< http://iris.noncd.db.de/iris-tts/timetable >>. =item B<lookahead> => I<int> Compute only those results which are less than I<int> minutes in the future. Default: 240 (4 hours). Note that the DeutscheBahn IRIS backend only provides schedules up to four to five hours into the future, and this module only requests data for up to three hours. So in most cases, setting this to a value above 180 minutes will have no effect. However, as the IRIS occasionally contains unscheduled departures or qos messages known far in advance (e.g. 12 hours from now), any non-negative integer is accepted. =item B<station> => I<stationcode> Mandatory: Which station to return departures for. Note that this is not a Loading
t/31-result-basics.t +19 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ use 5.014; use utf8; use DateTime; use Test::More tests => 435; use Test::More tests => 436; use Test::Fatal; use Travel::Status::DE::IRIS; Loading Loading @@ -87,3 +87,21 @@ $status = Travel::Status::DE::IRIS->new( @results = $status->results; is(@results, 0, 'no data available -> empty result list'); $status = Travel::Status::DE::IRIS->new( iris_base => 'file:t/in', lookahead => 0, station => 'EE', datetime => DateTime->new( year => 2014, month => 1, day => 3, hour => 20, minute => 1, time_zone => 'Europe/Berlin' ) ); @results = $status->results; is(@results, 0, 'lookahead 0 -> no results');