summaryrefslogtreecommitdiff
path: root/lib/Travel/Routing/DE/EFA.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travel/Routing/DE/EFA.pm')
-rw-r--r--lib/Travel/Routing/DE/EFA.pm175
1 files changed, 52 insertions, 123 deletions
diff --git a/lib/Travel/Routing/DE/EFA.pm b/lib/Travel/Routing/DE/EFA.pm
index a1e07ff..80bfb68 100644
--- a/lib/Travel/Routing/DE/EFA.pm
+++ b/lib/Travel/Routing/DE/EFA.pm
@@ -5,9 +5,7 @@ use warnings;
use 5.010;
use utf8;
-no if $] >= 5.018, warnings => "experimental::smartmatch";
-
-use Carp qw(cluck);
+use Carp qw(cluck);
use Encode qw(encode);
use Travel::Routing::DE::EFA::Route;
use Travel::Routing::DE::EFA::Route::Message;
@@ -42,7 +40,7 @@ use Exception::Class (
},
);
-our $VERSION = '2.19';
+our $VERSION = '2.24';
sub set_time {
my ( $self, %conf ) = @_;
@@ -176,17 +174,19 @@ sub number_of_trips {
sub select_interchange_by {
my ( $self, $prefer ) = @_;
- given ($prefer) {
- when ('speed') { $self->{post}->{routeType} = 'LEASTTIME' }
- when ('waittime') { $self->{post}->{routeType} = 'LEASTINTERCHANGE' }
- when ('distance') { $self->{post}->{routeType} = 'LEASTWALKING' }
- default {
- Travel::Routing::DE::EFA::Exception::Setup->throw(
- option => 'select_interchange_by',
- have => $prefer,
- want => 'speed / waittime / distance',
- );
- }
+ if ( $prefer eq 'speed' ) { $self->{post}->{routeType} = 'LEASTTIME' }
+ elsif ( $prefer eq 'waittime' ) {
+ $self->{post}->{routeType} = 'LEASTINTERCHANGE';
+ }
+ elsif ( $prefer eq 'distance' ) {
+ $self->{post}->{routeType} = 'LEASTWALKING';
+ }
+ else {
+ Travel::Routing::DE::EFA::Exception::Setup->throw(
+ option => 'select_interchange_by',
+ have => $prefer,
+ want => 'speed / waittime / distance',
+ );
}
return;
@@ -195,17 +195,15 @@ sub select_interchange_by {
sub train_type {
my ( $self, $include ) = @_;
- given ($include) {
- when ('local') { $self->{post}->{lineRestriction} = 403 }
- when ('ic') { $self->{post}->{lineRestriction} = 401 }
- when ('ice') { $self->{post}->{lineRestriction} = 400 }
- default {
- Travel::Routing::DE::EFA::Exception::Setup->throw(
- option => 'train_type',
- have => $include,
- want => 'local / ic / ice',
- );
- }
+ if ( $include eq 'local' ) { $self->{post}->{lineRestriction} = 403 }
+ elsif ( $include eq 'ic' ) { $self->{post}->{lineRestriction} = 401 }
+ elsif ( $include eq 'ice' ) { $self->{post}->{lineRestriction} = 400 }
+ else {
+ Travel::Routing::DE::EFA::Exception::Setup->throw(
+ option => 'train_type',
+ have => $include,
+ want => 'local / ic / ice',
+ );
}
return;
@@ -229,7 +227,7 @@ sub use_near_stops {
sub walk_speed {
my ( $self, $walk_speed ) = @_;
- if ( $walk_speed ~~ [ 'normal', 'fast', 'slow' ] ) {
+ if ( $walk_speed =~ m{ ^ (?: normal | fast | slow ) $ }x ) {
$self->{post}->{changeSpeed} = $walk_speed;
}
else {
@@ -305,7 +303,7 @@ sub place {
@{ $self->{post} }{ "place_${which}", "name_${which}" } = ( $place, $stop );
- if ( $type ~~ [qw[address poi stop]] ) {
+ if ( $type =~ m{ ^ (?: address | poi | stop ) $ }x ) {
$self->{post}->{"type_${which}"} = $type;
}
@@ -660,6 +658,8 @@ sub parse_xml_part {
$e_astime //= $e_atime;
my $delay = $e_delay ? $e_delay->getAttribute('delayMinutes') : 0;
+ my $delay_arr
+ = $e_delay ? $e_delay->getAttribute('delayMinutesArr') : 0;
my ( @dep_rms, @dep_sms, @arr_rms, @arr_sms );
@@ -675,17 +675,19 @@ sub parse_xml_part {
}
my $hash = {
- delay => $delay,
departure_date => $self->itddate_str($e_ddate),
+ departure_delay => $delay,
departure_time => $self->itdtime_str($e_dtime),
departure_sdate => $self->itddate_str($e_dsdate),
departure_stime => $self->itdtime_str($e_dstime),
departure_stop => $e_dep->getAttribute('name'),
departure_platform => $e_dep->getAttribute('platformName'),
+ occupancy => $e_dep->getAttribute('occupancy'),
train_line => $e_mot->getAttribute('name'),
train_product => $e_mot->getAttribute('productName'),
train_destination => $e_mot->getAttribute('destination'),
arrival_date => $self->itddate_str($e_adate),
+ arrival_delay => $delay_arr,
arrival_time => $self->itdtime_str($e_atime),
arrival_sdate => $self->itddate_str($e_asdate),
arrival_stime => $self->itdtime_str($e_astime),
@@ -715,8 +717,8 @@ sub parse_xml_part {
$hash->{arrival_stationmaps} = \@arr_sms;
for my $ve ( $e->findnodes($xp_via) ) {
- my $e_vdate = ( $ve->findnodes($xp_date) )[-1];
- my $e_vtime = ( $ve->findnodes($xp_time) )[-1];
+ my $e_vdate = ( $ve->findnodes($xp_date) )[0];
+ my $e_vtime = ( $ve->findnodes($xp_time) )[0];
if ( not( $e_vdate and $e_vtime )
or ( $e_vdate->getAttribute('weekday') == -1 ) )
@@ -724,10 +726,13 @@ sub parse_xml_part {
next;
}
- my $name = $ve->getAttribute('name');
- my $platform = $ve->getAttribute('platformName');
+ my $name = $ve->getAttribute('name');
+ my $platform = $ve->getAttribute('platformName');
+ my $arr_delay = $ve->getAttribute('arrDelay');
- if ( $name ~~ [ $hash->{departure_stop}, $hash->{arrival_stop} ] ) {
+ if ( $name eq $hash->{departure_stop}
+ or $name eq $hash->{arrival_stop} )
+ {
next;
}
@@ -737,7 +742,8 @@ sub parse_xml_part {
$self->itddate_str($e_vdate),
$self->itdtime_str($e_vtime),
$name,
- $platform
+ $platform,
+ $arr_delay,
]
);
}
@@ -819,7 +825,7 @@ sub check_ambiguous_xml {
if ( $s_place eq 'list' ) {
Travel::Routing::DE::EFA::Exception::Ambiguous->throw(
- post_key => 'place',
+ post_key => 'place',
post_value =>
( $e_place->findnodes($xp_place_input) )[0]->textContent,
possibilities => join( q{ | },
@@ -829,7 +835,7 @@ sub check_ambiguous_xml {
}
if ( $s_name eq 'list' ) {
Travel::Routing::DE::EFA::Exception::Ambiguous->throw(
- post_key => 'name',
+ post_key => 'name',
post_value =>
( $e_name->findnodes($xp_name_input) )[0]->textContent,
possibilities => join( q{ | },
@@ -898,40 +904,11 @@ sub get_efa_urls {
name => 'Nahverkehrsgesellschaft Baden-Württemberg',
shortname => 'NVBW',
},
-
- # HTTPS not supported
- {
- url => 'http://efa.svv-info.at/sbs/XSLT_TRIP_REQUEST2',
- name => 'Salzburger Verkehrsverbund',
- shortname => 'SVV',
- },
-
- # HTTPS: invalid certificate
- {
- url =>
- 'http://www.travelineeastmidlands.co.uk/em/XSLT_TRIP_REQUEST2',
- name => 'Traveline East Midlands',
- shortname => 'TLEM',
- },
{
url => 'https://efa.vagfr.de/vagfr3/XSLT_TRIP_REQUEST2',
name => 'Freiburger Verkehrs AG',
shortname => 'VAG',
},
-
- # HTTPS: unsupported protocol
- {
- url => 'http://mobil.vbl.ch/vblmobil/XML_TRIP_REQUEST2',
- name => 'Verkehrsbetriebe Luzern',
- shortname => 'VBL',
- },
-
- # HTTPS not supported
- {
- url => 'http://fahrplan.verbundlinie.at/stv/XSLT_TRIP_REQUEST2',
- name => 'Verkehrsverbund Steiermark',
- shortname => 'Verbundlinie',
- },
{
url => 'https://efa.vgn.de/vgnExt_oeffi/XML_TRIP_REQUEST2',
name => 'Verkehrsverbund Grossraum Nuernberg',
@@ -945,32 +922,22 @@ sub get_efa_urls {
shortname => 'VMV',
},
{
- url => 'https://efa.vor.at/wvb/XSLT_TRIP_REQUEST2',
- name => 'Verkehrsverbund Ost-Region',
- shortname => 'VOR',
- encoding => 'iso-8859-15',
- },
-
- # HTTPS not spported
- {
- url => 'http://fahrplanauskunft.vrn.de/vrn/XML_TRIP_REQUEST2',
+ url => 'https://www.vrn.de/mngvrn/XML_TRIP_REQUEST2',
name => 'Verkehrsverbund Rhein-Neckar',
shortname => 'VRN',
},
{
- url => 'https://efa.vrr.de/vrr/XSLT_TRIP_REQUEST2',
+ url => 'https://app.vrr.de/vrrstd/XML_TRIP_REQUEST2',
name => 'Verkehrsverbund Rhein-Ruhr',
shortname => 'VRR',
},
{
- url => 'https://app.vrr.de/vrrstd/XML_TRIP_REQUEST2',
+ url => 'https://efa.vrr.de/rbgstd3/XSLT_TRIP_REQUEST2',
name => 'Verkehrsverbund Rhein-Ruhr (alternative)',
shortname => 'VRR2',
},
-
- # HTTPS not supported
{
- url => 'http://efa.vvo-online.de:8080/dvb/XSLT_TRIP_REQUEST2',
+ url => 'https://efa.vvo-online.de/VMSSL3/XSLT_TRIP_REQUEST2',
name => 'Verkehrsverbund Oberelbe',
shortname => 'VVO',
},
@@ -995,7 +962,7 @@ Travel::Routing::DE::EFA - unofficial interface to EFA-based itinerary services
use Travel::Routing::DE::EFA;
my $efa = Travel::Routing::DE::EFA->new(
- efa_url => 'http://efa.vrr.de/vrr/XSLT_TRIP_REQUEST2',
+ efa_url => 'https://app.vrr.de/vrrstd/XML_TRIP_REQUEST2';',
origin => [ 'Essen', 'HBf' ],
destination => [ 'Duisburg', 'HBf' ],
);
@@ -1014,7 +981,7 @@ Travel::Routing::DE::EFA - unofficial interface to EFA-based itinerary services
=head1 VERSION
-version 2.19
+version 2.24
=head1 DESCRIPTION
@@ -1041,47 +1008,9 @@ Valid hash keys and their values are:
=item B<efa_url> => I<efa_url>
Mandatory. Sets the entry point to the EFA itinerary service.
-The following URLs (grouped by country) are known. A service marked with [!]
-is not completely supported yet and may not work at all.
-
-=over
-
-=item * Austria
-
-=over
-
-=item * L<http://efa.ivb.at/ivb/XSLT_TRIP_REQUEST2> (Innsbrucker Verkehrsbetriebe)
-
-=item * L<http://efa.svv-info.at/sbs/XSLT_TRIP_REQUEST2> (Salzburger Verkehrsverbund)
-
-=item * L<http://efa.vor.at/wvb/XSLT_TRIP_REQUEST2> (Verkehrsverbund Ost-Region)
-
-=item * L<http://efaneu.vmobil.at/vvv/XSLT_TRIP_REQUEST2> (Vorarlberger Verkehrsverbund)
-
-=item * L<http://www.linzag.at/static/XSLT_TRIP_REQUEST2> (Linz AG) B<[!]>
-
-=item * The STV / Verkehrsverbund Steiermark is not supported since it returns
-data with broken encoding
-
-=back
-
-=item * Germany
-
-=over
-
-=item * L<http://212.114.197.7/vgnExt_oeffi/XML_TRIP_REQUEST2> (Verkehrsverbund GroE<szlig>raum NE<uuml>rnberg)
-
-=item * L<http://efa.vrr.de/vrr/XSLT_TRIP_REQUEST2> (Verkehrsverbund Rhein-Ruhr)
-
-=item * L<http://app.vrr.de/standard/XML_TRIP_REQUEST2> (Verkehrsverbund Rhein-Ruhr with support for B<--full-route>)
-
-=item * L<http://www2.vvs.de/vvs/XSLT_TRIP_REQUEST2> (Verkehrsverbund Stuttgart)
-
-=back
-
-=back
+See C<< efa --list >> for a list of supported services.
-If you found a URL not listed here, please send it to
+If you found a URL not listed there, please send it to
E<lt>derf@finalrewind.orgE<gt>.
=item B<origin> => B<[> I<city>B<,> I<stop> [ B<,> I<type> ] B<]>
@@ -1285,7 +1214,7 @@ None known.
=head1 AUTHOR
-Copyright (C) 2009-2020 by Daniel Friesel E<lt>derf@finalrewind.orgE<gt>
+Copyright (C) 2009-2023 by Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
=head1 LICENSE