summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-03-02 19:20:31 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-03-02 19:20:31 +0100
commit444dad0d33aa2d0ca9750bbac49268489854ba4d (patch)
treef02e3f1450df2eaeb1ea6ed86c825238faff1c30
parent526412033bbb5f656770d9ebd1999819adf22d7b (diff)
Add option to specify maximum number of connections
-rw-r--r--Changelog1
-rwxr-xr-xbin/efa7
-rw-r--r--lib/Travel/Routing/DE/EFA.pm19
3 files changed, 27 insertions, 0 deletions
diff --git a/Changelog b/Changelog
index 3c8a344..2b0ed68 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,7 @@
git HEAD
* Improve error message for unparsable (or missing) route data
+ * Add option to specify maximum number of connections
Travel::Routing::DE::VRR 2.04 - Tue Jan 07 2014
diff --git a/bin/efa b/bin/efa
index d3233c7..dcd2b41 100755
--- a/bin/efa
+++ b/bin/efa
@@ -155,6 +155,7 @@ GetOptions(
help|h
ignore-info|I:s
max-change|m=i
+ num-connections|n=i
prefer|P=s
proximity|p
include|i=s
@@ -220,6 +221,7 @@ $efa = eval {
use_near_stops => $opt->{proximity},
walk_speed => $opt->{'walk-speed'},
max_interchanges => $opt->{'max-change'},
+ num_results => $opt->{'num-connections'},
lwp_options => { timeout => $opt->{timeout} },
);
@@ -330,6 +332,11 @@ Display duration, ticket class and price for each route (if available)
Print connections with at most I<number> interchanges
+=item B<-n>|B<--num-connections> I<number>
+
+Return up to I<number> connections. If unset, the default of the respective
+EFA server is used (usually 4 or 5).
+
=item B<-P>|B<--prefer> I<type>
Prefer connections of I<type>:
diff --git a/lib/Travel/Routing/DE/EFA.pm b/lib/Travel/Routing/DE/EFA.pm
index 6d67bd8..4047306 100644
--- a/lib/Travel/Routing/DE/EFA.pm
+++ b/lib/Travel/Routing/DE/EFA.pm
@@ -156,6 +156,14 @@ sub max_interchanges {
return;
}
+sub number_of_trips {
+ my ( $self, $num ) = @_;
+
+ $self->{post}->{calcNumberOfTrips} = $num;
+
+ return;
+}
+
sub select_interchange_by {
my ( $self, $prefer ) = @_;
@@ -312,6 +320,7 @@ sub create_post {
name_destination => q{},
name_origin => q{},
name_via => q{},
+ nextDepsPerLeg => 1,
outputFormat => 'XML',
placeInfo_destination => 'invalid',
placeInfo_origin => 'invalid',
@@ -364,6 +373,9 @@ sub create_post {
if ( $conf->{max_interchanges} ) {
$self->max_interchanges( $conf->{max_interchanges} );
}
+ if ( $conf->{num_results} ) {
+ $self->number_of_trips( $conf->{num_results} );
+ }
if ( $conf->{select_interchange_by} ) {
$self->select_interchange_by( $conf->{select_interchange_by} );
}
@@ -586,6 +598,8 @@ sub parse_xml {
my $tree = $self->{tree}
= XML::LibXML->load_xml( string => $self->{xml_reply}, );
+ # say $tree->toString(2);
+
my $xp_element = XML::LibXML::XPathExpression->new(
'//itdItinerary/itdRouteList/itdRoute');
my $xp_err = XML::LibXML::XPathExpression->new(
@@ -785,6 +799,11 @@ seilbahn, schiff, ast, sonstige
Set maximum number of interchanges
+=item B<num_results> => I<num>
+
+Return up to I<num> connections. If unset, the default of the respective
+EFA server is used (usually 4 or 5).
+
=item B<select_interchange_by> => B<speed>|B<waittime>|B<distance>
Prefer either fast connections (default), connections with low wait time or