summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Travel/Routing/DE/HAFAS.pm48
-rw-r--r--lib/Travel/Routing/DE/HAFAS/Connection.pm7
-rw-r--r--lib/Travel/Routing/DE/HAFAS/Connection/Section.pm4
-rw-r--r--lib/Travel/Routing/DE/HAFAS/Utils.pm4
4 files changed, 43 insertions, 20 deletions
diff --git a/lib/Travel/Routing/DE/HAFAS.pm b/lib/Travel/Routing/DE/HAFAS.pm
index ee846ba..692b48c 100644
--- a/lib/Travel/Routing/DE/HAFAS.pm
+++ b/lib/Travel/Routing/DE/HAFAS.pm
@@ -19,7 +19,7 @@ use Travel::Status::DE::HAFAS;
use Travel::Status::DE::HAFAS::Location;
use Travel::Status::DE::HAFAS::Message;
-our $VERSION = '0.06';
+our $VERSION = '0.10';
# {{{ Endpoint Definition
@@ -46,7 +46,7 @@ sub new {
}
if ( not defined $service ) {
- $service = $conf{service} = 'DB';
+ confess("The service option is mandatory");
}
if ( defined $service and not exists $hafas_instance{$service} ) {
@@ -237,13 +237,23 @@ sub mot_mask {
if ( my @mots = @{ $self->{exclusive_mots} // [] } ) {
$mot_mask = 0;
for my $mot (@mots) {
- $mot_mask |= 1 << $mot_pos{$mot};
+ if ( exists $mot_pos{$mot} ) {
+ $mot_mask |= 1 << $mot_pos{$mot};
+ }
+ elsif ( $mot =~ m{ ^ \d+ $ }x ) {
+ $mot_mask |= 1 << $mot;
+ }
}
}
if ( my @mots = @{ $self->{excluded_mots} // [] } ) {
for my $mot (@mots) {
- $mot_mask &= ~( 1 << $mot_pos{$mot} );
+ if ( exists $mot_pos{$mot} ) {
+ $mot_mask &= ~( 1 << $mot_pos{$mot} );
+ }
+ elsif ( $mot =~ m{ ^ \d+ $ }x ) {
+ $mot_mask &= ~( 1 << $mot );
+ }
}
}
@@ -425,7 +435,15 @@ sub add_message {
}
for my $message ( @{ $self->{messages} } ) {
- if ( $code eq $message->{code} and $text eq $message->{text} ) {
+ if (
+ (
+ not( defined $code and defined $message->{code} )
+ or $code eq $message->{code}
+ )
+ and ( not( defined $text and defined $message->{text} )
+ or $text eq $message->{text} )
+ )
+ {
$message->{ref_count}++;
return $message;
}
@@ -509,6 +527,7 @@ Travel::Routing::DE::HAFAS - Interface to HAFAS itinerary services
use Travel::Routing::DE::HAFAS;
my $hafas = Travel::Routing::DE::HAFAS->new(
+ service => 'VRN',
from_stop => 'Eichlinghofen H-Bahn, Dortmund',
to_stop => 'Essen-Kupferdreh',
);
@@ -535,13 +554,12 @@ Travel::Routing::DE::HAFAS - Interface to HAFAS itinerary services
=head1 VERSION
-version 0.06
+version 0.10
=head1 DESCRIPTION
Travel::Routing::DE::HAFAS is an interface to HAFAS itinerary services
-using the mgate.exe interface. It works best with the legacy instance of
-Deutsche Bahn, but supports other transit services as well.
+using the mgate.exe interface.
=head1 METHODS
@@ -556,6 +574,12 @@ supports the following additional flags:
=over
+=item B<service> => I<service> (mandatory)
+
+Request results from I<service>.
+See B<get_services> (and C<< hafas-m --list >>) for a list of supported
+services.
+
=item B<from_stop> => I<stop> (mandatory)
Origin stop, e.g. "Essen HBf" or "Alfredusbad, Essen (Ruhr)". The stop
@@ -621,12 +645,6 @@ Request connections with scheduled changeover durations of at least I<minutes>.
Note that this does not account for real-time data: the backend may return
delayed connections that violate the specified changeover duration.
-=item B<service> => I<service>
-
-Request results from I<service>, defaults to "DB".
-See B<get_services> (and C<< hafas-m --list >>) for a list of supported
-services.
-
=back
=item $hafas_p = Travel::Routing::DE::HAFAS->new_p(I<%opt>)
@@ -719,7 +737,7 @@ None.
=head1 BUGS AND LIMITATIONS
-The non-default services (anything other than DB) are not well tested.
+Some HAFAS services are not well-tested.
=head1 SEE ALSO
diff --git a/lib/Travel/Routing/DE/HAFAS/Connection.pm b/lib/Travel/Routing/DE/HAFAS/Connection.pm
index 05341cc..d1a5d16 100644
--- a/lib/Travel/Routing/DE/HAFAS/Connection.pm
+++ b/lib/Travel/Routing/DE/HAFAS/Connection.pm
@@ -11,7 +11,7 @@ use DateTime::Duration;
use Travel::Routing::DE::HAFAS::Utils;
use Travel::Routing::DE::HAFAS::Connection::Section;
-our $VERSION = '0.06';
+our $VERSION = '0.10';
Travel::Routing::DE::HAFAS::Connection->mk_ro_accessors(
qw(changes duration sched_dep rt_dep sched_arr rt_arr dep arr dep_platform arr_platform dep_loc arr_loc dep_cancelled arr_cancelled is_cancelled load)
@@ -89,6 +89,9 @@ sub new {
my @sections;
for my $sec (@secL) {
+ if ( $sec->{type} eq 'WALK' and not $sec->{gis}{durS} ) {
+ next;
+ }
push(
@sections,
Travel::Routing::DE::HAFAS::Connection::Section->new(
@@ -210,7 +213,7 @@ Travel::Routing::DE::HAFAS::Connection - A single connection between two stops
=head1 VERSION
-version 0.06
+version 0.10
=head1 DESCRIPTION
diff --git a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm
index 477900f..625b8fe 100644
--- a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm
+++ b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm
@@ -11,7 +11,7 @@ use DateTime::Duration;
use Travel::Routing::DE::HAFAS::Utils;
use Travel::Status::DE::HAFAS::Journey;
-our $VERSION = '0.06';
+our $VERSION = '0.10';
Travel::Routing::DE::HAFAS::Connection::Section->mk_ro_accessors(
qw(type schep_dep rt_dep sched_arr rt_arr dep arr arr_delay dep_delay journey distance duration transfer_duration dep_loc arr_loc
@@ -212,7 +212,7 @@ Travel::Routing::DE::HAFAS::Connection::Section - A single trip between two stop
=head1 VERSION
-version 0.06
+version 0.10
=head1 DESCRIPTION
diff --git a/lib/Travel/Routing/DE/HAFAS/Utils.pm b/lib/Travel/Routing/DE/HAFAS/Utils.pm
index 45ee5db..b1568dd 100644
--- a/lib/Travel/Routing/DE/HAFAS/Utils.pm
+++ b/lib/Travel/Routing/DE/HAFAS/Utils.pm
@@ -9,6 +9,8 @@ use 5.014;
use parent 'Exporter';
our @EXPORT = qw(handle_day_change);
+our $VERSION = '0.10';
+
sub handle_day_change {
my (%opt) = @_;
my $datestr = $opt{date};
@@ -53,7 +55,7 @@ None.
=head1 VERSION
-version 0.06
+version 0.10
=head1 METHODS