Skip to content
Commits on Source (5)
Travel::Status::DE::IRIS 1.94 - Mon Jan 29 2024
* Update stations list
* Do not use now-deprecated smartmatch features
Travel::Status::DE::IRIS 1.93 - Fri Dec 22 2023
* Update stations list
......
......@@ -4,9 +4,7 @@ use warnings;
use 5.014;
use utf8;
no if $] >= 5.018, warnings => 'experimental::smartmatch';
our $VERSION = '1.93';
our $VERSION = '1.94';
use DateTime;
use DateTime::Format::Strptime;
......@@ -14,7 +12,7 @@ use Encode qw(decode);
use Getopt::Long qw(:config no_ignore_case bundling);
use JSON;
use List::Util qw(first max);
use List::MoreUtils qw(none);
use List::MoreUtils qw(any none);
use Travel::Status::DE::IRIS;
use Travel::Status::DE::IRIS::Stations;
......@@ -121,20 +119,18 @@ if ($time) {
}
for my $efield (@edata_pre) {
given ($efield) {
when ('a') { $edata{additional} = 1 }
when ('c') { $edata{canceled} = 1 }
when ('d') { $edata{delay} = 1 }
when ('D') { $edata{delays} = 1 }
when ('f') { $edata{fullroute} = 1 }
when ('m') { $edata{messages} = 1 }
when ('q') { $edata{qos} = 1 }
when ('r') { $edata{route} = 1 }
when ('R') { $edata{replacements} = 1 }
when ('t') { $edata{times} = 1 }
when ('!') { $edata{debug} = 1 }
default { $edata{$efield} = 1 }
}
if ( $efield eq 'a' ) { $edata{additional} = 1 }
elsif ( $efield eq 'c' ) { $edata{canceled} = 1 }
elsif ( $efield eq 'd' ) { $edata{delay} = 1 }
elsif ( $efield eq 'D' ) { $edata{delays} = 1 }
elsif ( $efield eq 'f' ) { $edata{fullroute} = 1 }
elsif ( $efield eq 'm' ) { $edata{messages} = 1 }
elsif ( $efield eq 'q' ) { $edata{qos} = 1 }
elsif ( $efield eq 'r' ) { $edata{route} = 1 }
elsif ( $efield eq 'R' ) { $edata{replacements} = 1 }
elsif ( $efield eq 't' ) { $edata{times} = 1 }
elsif ( $efield eq '!' ) { $edata{debug} = 1 }
else { $edata{$efield} = 1 }
}
if ($use_cache) {
......@@ -461,15 +457,33 @@ for my $d ( $status->results() ) {
# route may be incomplete, so check route_end as well
@via = ( $d->route_post, $d->route_end );
if ( ( $filter_via and not( first { $_ =~ m{$filter_via}io } @via ) )
or ( @grep_class and none { $_ ~~ \@grep_class } $d->classes )
or ( @grep_platform and not( $d->platform ~~ \@grep_platform ) )
or ( @grep_type and not( $d->type ~~ \@grep_type ) )
if ( ( $filter_via and not( first { $_ =~ m{$filter_via}io } @via ) )
or $d->is_wing )
{
next;
}
if ( @grep_platform and none { $d->platform eq $_ } @grep_platform ) {
next;
}
if ( @grep_type and none { $d->type eq $_ } @grep_type ) {
next;
}
if (@grep_class) {
my $skip = 1;
for my $class ( $d->classes ) {
if ( any { $class eq $_ } @grep_class ) {
$skip = 0;
last;
}
}
if ($skip) {
next;
}
}
my $delay = format_delay($d);
my $platformstr = $d->platform // q{};
......@@ -534,7 +548,7 @@ for my $d ( $status->results() ) {
push( @processed_wings, $wing->wing_id );
}
for my $wing ( $d->arrival_wings ) {
if ( not $wing->wing_id ~~ \@processed_wings ) {
if ( none { $wing->wing_id eq $_ } @processed_wings ) {
my $wingdelay = format_delay($wing);
push(
@output,
......@@ -573,7 +587,7 @@ B<db-iris> [B<-rx>] [B<-d> I<date>] [B<-o> I<output-flags>]
=head1 VERSION
version 1.93
version 1.94
=head1 DESCRIPTION
......@@ -844,7 +858,7 @@ There are no known bugs at the moment.
=head1 AUTHOR
Copyright (C) 2013-2023 by Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
Copyright (C) 2013-2024 by Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
The station data used by this script is provided by DB
Station&Service AG, Europaplatz 1, 10557 Berlin, Germany and available
......
......@@ -4,14 +4,12 @@ use strict;
use warnings;
use 5.014;
no if $] >= 5.018, warnings => 'experimental::smartmatch';
our $VERSION = '1.93';
our $VERSION = '1.94';
use Carp qw(confess cluck);
use DateTime;
use DateTime::Format::Strptime;
use List::Util qw(first);
use List::Util qw(none first);
use List::MoreUtils qw(uniq);
use List::UtilsBy qw(uniq_by);
use LWP::UserAgent;
......@@ -237,11 +235,11 @@ sub new {
for my $ref (@related_stations) {
# We (the parent) perform transfer processing, so child requests must not
# do it themselves. Otherwise, trains from child requests will be
# processed twice and may be lost.
# Similarly, child requests must not perform requests to related
# stations -- we're already doing that right now.
# We (the parent) perform transfer processing, so child requests must not
# do it themselves. Otherwise, trains from child requests will be
# processed twice and may be lost.
# Similarly, child requests must not perform requests to related
# stations -- we're already doing that right now.
my $ref_status = Travel::Status::DE::IRIS->new(
datetime => $self->{datetime},
developer_mode => $self->{developer_mode},
......@@ -554,8 +552,12 @@ sub get_station {
if ( $opt{recursive} and defined $station_node->getAttribute('meta') ) {
my @refs
= uniq( split( m{ \| }x, $station_node->getAttribute('meta') ) );
@refs = grep { not( $_ ~~ \@seen or $_ ~~ \@queue ) } @refs;
push( @queue, @refs );
for my $ref (@refs) {
if ( none { $_ == $ref } @seen and none { $_ == $ref } @queue )
{
push( @queue, @refs );
}
}
$opt{root} = 0;
}
}
......@@ -798,13 +800,13 @@ sub parse_realtime {
my $msgid = $e_m->getAttribute('id');
my $ts = $e_m->getAttribute('ts');
# 0 and 1 (with key "f") are related to canceled trains and
# do not appear to hold information (or at least none we can access).
# All observed cases of message ID 900 were related to bus
# connections ("Anschlussbus wartet"). We can't access which bus
# it refers to, so we don't show that either.
# ID 1000 is a generic free text message, which (as we lack access
# to the text itself) is not helpful either.
# 0 and 1 (with key "f") are related to canceled trains and
# do not appear to hold information (or at least none we can access).
# All observed cases of message ID 900 were related to bus
# connections ("Anschlussbus wartet"). We can't access which bus
# it refers to, so we don't show that either.
# ID 1000 is a generic free text message, which (as we lack access
# to the text itself) is not helpful either.
if ( defined $value and $value > 1 and $value < 100 ) {
$messages{$msgid} = [ $ts, $type, $value ];
}
......@@ -824,9 +826,9 @@ sub parse_realtime {
type => $e_ref->getAttribute('c'), # S/ICE/ERB/...
line_no => $e_ref->getAttribute('l'), # 1 -> S1, ...
#unknown_t => $e_ref->getAttribute('t'), # p
#unknown_o => $e_ref->getAttribute('o'), # owner: 03/80/R2/...
# TODO ps='a' -> rerouted and normally unscheduled train?
#unknown_t => $e_ref->getAttribute('t'), # p
#unknown_o => $e_ref->getAttribute('o'), # owner: 03/80/R2/...
# TODO ps='a' -> rerouted and normally unscheduled train?
);
}
if ($e_ar) {
......@@ -987,7 +989,7 @@ Non-blocking variant (EXPERIMENTAL):
=head1 VERSION
version 1.93
version 1.94
=head1 DESCRIPTION
......@@ -1190,7 +1192,7 @@ L<https://github.com/derf/Travel-Status-DE-IRIS>
=head1 AUTHOR
Copyright (C) 2013-2023 by Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
Copyright (C) 2013-2024 by Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
=head1 LICENSE
......
......@@ -5,17 +5,16 @@ use warnings;
use 5.014;
use utf8;
no if $] >= 5.018, warnings => 'experimental::smartmatch';
use parent 'Class::Accessor';
use Carp qw(cluck);
use DateTime;
use DateTime::Format::Strptime;
use List::Compare;
use List::MoreUtils qw(none uniq lastval);
use List::Util qw(any);
use List::MoreUtils qw(uniq lastval);
use Scalar::Util qw(weaken);
our $VERSION = '1.93';
our $VERSION = '1.94';
Travel::Status::DE::IRIS::Result->mk_ro_accessors(
qw(arrival arrival_delay arrival_has_realtime arrival_is_additional arrival_is_cancelled arrival_hidden
......@@ -642,8 +641,8 @@ sub delay_messages {
my @ret;
for my $id (@msgids) {
if ( my @superseded = $self->superseded_messages($id) ) {
@ret = grep { not( $_->[2] ~~ \@superseded ) } @ret;
for my $superseded ( $self->superseded_messages($id) ) {
@ret = grep { not( $_->[2] == $superseded ) } @ret;
}
my $msg = lastval { $_->[2] == $id } @msgs;
push( @ret, $msg );
......@@ -697,12 +696,12 @@ sub qos_messages {
my @keys = sort keys %{ $self->{messages} };
my @msgs
= grep { $_->[1] ~~ [qw[f q]] } map { $self->{messages}{$_} } @keys;
= grep { $_->[1] =~ m{^[fq]$} } map { $self->{messages}{$_} } @keys;
my @ret;
for my $msg (@msgs) {
if ( my @superseded = $self->superseded_messages( $msg->[2] ) ) {
@ret = grep { not( $_->[2] ~~ \@superseded ) } @ret;
for my $superseded ( $self->superseded_messages( $msg->[2] ) ) {
@ret = grep { not( $_->[2] == $superseded ) } @ret;
}
@ret = grep { $_->[2] != $msg->[2] } @ret;
......@@ -834,7 +833,7 @@ sub route_interesting {
while ( @via_show < $max_parts and @via_main ) {
my $stop = shift(@via_main);
if ( $stop ~~ \@via_show or $stop eq $last_stop ) {
if ( any { $stop eq $_ } @via_show or $stop eq $last_stop ) {
next;
}
push( @via_show, $stop );
......@@ -944,7 +943,7 @@ arrival/departure received by Travel::Status::DE::IRIS
=head1 VERSION
version 1.93
version 1.94
=head1 DESCRIPTION
......@@ -1624,7 +1623,7 @@ Travel::Status::DE::IRIS(3pm).
=head1 AUTHOR
Copyright (C) 2013-2023 by Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
Copyright (C) 2013-2024 by Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
=head1 LICENSE
......
......@@ -34,7 +34,7 @@ use Text::LevenshteinXS qw(distance);
# TODO switch to Text::Levenshtein::XS once AUR/Debian packages become available
our $VERSION = '1.93';
our $VERSION = '1.94';
# Automatically generated, see share/stations.json
my @stations = (
......@@ -204,7 +204,7 @@ Travel::Status::DE::IRIS::Stations - Station name to station code mapping
=head1 VERSION
version 1.93
version 1.94
=head1 DESCRIPTION
......@@ -311,7 +311,7 @@ Travel::Status::DE::IRIS(3pm).
Station data: Copyright (C) 2016 by DB Station&Service AG, Europaplatz 1, 10557 Berlin, Germany
Lookup code: Copyright (C) 2014-2023 by Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
Lookup code: Copyright (C) 2014-2024 by Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
=head1 LICENSE
......
......@@ -1286,6 +1286,12 @@
"8011901" : [
8089117
],
"8012308" : [
8012309
],
"8012309" : [
8012308
],
"8012494" : [
8017017
],
......
......@@ -278,15 +278,6 @@
],
"name" : "Burgos Rosa de Lima"
},
{
"ds100" : "XICO",
"eva" : 8300192,
"latlong" : [
43.959903,
12.745023
],
"name" : "Cattolica-SG Gabicce"
},
{
"ds100" : "XICTL",
"eva" : 8300375,
......@@ -341,15 +332,6 @@
],
"name" : "Duisburg-Bissingheim"
},
{
"ds100" : "HDUS",
"eva" : 8070358,
"latlong" : [
52.918346,
8.618534
],
"name" : "Dünsen DHE"
},
{
"ds100" : "NDW",
"eva" : 8070805,
......@@ -494,15 +476,6 @@
],
"name" : "Gorzow Wlkp."
},
{
"ds100" : "HGIP",
"eva" : 8070403,
"latlong" : [
52.939956,
8.63013
],
"name" : "Groß Ippener DHE"
},
{
"ds100" : "LGRK",
"eva" : 8011685,
......@@ -1070,15 +1043,6 @@
],
"name" : "Osternienburg"
},
{
"ds100" : "XIPE",
"eva" : 8300216,
"latlong" : [
43.905968,
12.904752
],
"name" : "Pesaro"
},
{
"ds100" : "WPE",
"eva" : 8012627,
......@@ -1142,15 +1106,6 @@
],
"name" : "Rech"
},
{
"ds100" : "XIRN",
"eva" : 8300225,
"latlong" : [
43.999231,
12.658493
],
"name" : "Riccione"
},
{
"ds100" : "WRIW",
"eva" : 8012768,
......
......@@ -14264,6 +14264,15 @@
],
"name" : "Castrop-Rauxel-Merklinde"
},
{
"ds100" : "XICO",
"eva" : 8300192,
"latlong" : [
43.959903,
12.745023
],
"name" : "Cattolica-SG Gabicce"
},
{
"ds100" : "XFCAV",
"eva" : 8700888,
......@@ -19529,6 +19538,15 @@
],
"name" : "Dülmen"
},
{
"ds100" : "HDUS",
"eva" : 8070358,
"latlong" : [
52.918346,
8.618534
],
"name" : "Dünsen DHE"
},
{
"ds100" : "KDN",
"eva" : 8000084,
......@@ -29276,6 +29294,15 @@
],
"name" : "Groß Gerau-Dornheim"
},
{
"ds100" : "HGIP",
"eva" : 8070403,
"latlong" : [
52.939956,
8.63013
],
"name" : "Groß Ippener DHE"
},
{
"ds100" : "FGKA",
"eva" : 8002388,
......@@ -62099,6 +62126,15 @@
],
"name" : "Pertoltice pod Ralskem"
},
{
"ds100" : "XIPE",
"eva" : 8300216,
"latlong" : [
43.905968,
12.904752
],
"name" : "Pesaro"
},
{
"ds100" : "XIPDG",
"eva" : 8300124,
......@@ -66383,6 +66419,15 @@
],
"name" : "Ribnitz-Damgarten West"
},
{
"ds100" : "XIRN",
"eva" : 8300225,
"latlong" : [
43.999231,
12.658493
],
"name" : "Riccione"
},
{
"ds100" : "RRIH",
"eva" : 8005077,