summaryrefslogtreecommitdiff
path: root/lib/Travel
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-11-11 00:44:22 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2023-11-11 00:44:22 +0100
commit58fe3b8be3c434610354e9954e630da3146cc01a (patch)
tree931f56226238f619da2a129818c48f9703a49fce /lib/Travel
parent4520981dde8d12a18632b598f1c02a6649cde9f3 (diff)
expose transfer times between consecutive connection sections
Diffstat (limited to 'lib/Travel')
-rw-r--r--lib/Travel/Routing/DE/HAFAS/Connection.pm10
-rw-r--r--lib/Travel/Routing/DE/HAFAS/Connection/Section.pm13
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/Travel/Routing/DE/HAFAS/Connection.pm b/lib/Travel/Routing/DE/HAFAS/Connection.pm
index 1eee1bd..9a9e28b 100644
--- a/lib/Travel/Routing/DE/HAFAS/Connection.pm
+++ b/lib/Travel/Routing/DE/HAFAS/Connection.pm
@@ -89,6 +89,16 @@ sub new {
);
}
+ my $prev;
+ for my $sec (@sections) {
+ if ( $sec->type eq 'JNY' ) {
+ if ($prev) {
+ $sec->set_transfer_from_previous_section($prev);
+ }
+ $prev = $sec;
+ }
+ }
+
my $tco = {};
for my $tco_id ( @{ $connection->{dTrnCmpSX}{tcocX} // [] } ) {
my $tco_kv = $opt{common}{tcocL}[$tco_id];
diff --git a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm
index 9120e69..a31f57a 100644
--- a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm
+++ b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm
@@ -13,7 +13,7 @@ use Travel::Routing::DE::HAFAS::Utils;
our $VERSION = '0.00';
Travel::Routing::DE::HAFAS::Connection::Section->mk_ro_accessors(
- qw(type schep_dep rt_dep sched_arr rt_arr dep_datetime arr_datetime arr_delay dep_delay journey distance duration dep_loc arr_loc
+ qw(type schep_dep rt_dep sched_arr rt_arr dep_datetime arr_datetime arr_delay dep_delay journey distance duration transfer_duration dep_loc arr_loc
operator id name category category_long class number line line_no load delay direction)
);
@@ -132,6 +132,17 @@ sub new {
# }}}
+# {{{ Private
+
+sub set_transfer_from_previous_section {
+ my ( $self, $prev_sec ) = @_;
+
+ my $delta = $self->dep_datetime - $prev_sec->arr_datetime;
+ $self->{transfer_duration} = $delta;
+}
+
+# }}}
+
# {{{ Accessors
sub messages {