diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Travel/Routing/DE/HAFAS.pm | 4 | ||||
-rw-r--r-- | lib/Travel/Routing/DE/HAFAS/Connection.pm | 10 | ||||
-rw-r--r-- | lib/Travel/Routing/DE/HAFAS/Connection/Section.pm | 26 |
3 files changed, 24 insertions, 16 deletions
diff --git a/lib/Travel/Routing/DE/HAFAS.pm b/lib/Travel/Routing/DE/HAFAS.pm index 74e21b5..f6cf6a1 100644 --- a/lib/Travel/Routing/DE/HAFAS.pm +++ b/lib/Travel/Routing/DE/HAFAS.pm @@ -648,9 +648,9 @@ Travel::Routing::DE::HAFAS - Interface to HAFAS itinerary services if ( $sec->type eq 'JNY' ) { printf("%s -> %s\n%s ab %s\n%s an %s\n\n", $sec->name, $sec->direction, - $sec->dep_datetime->strftime('%H:%M'), + $sec->dep->strftime('%H:%M'), $sec->dep_loc->name, - $sec->arr_datetime->strftime('%H:%M'), + $sec->arr->strftime('%H:%M'), $sec->arr_loc->name, ); } diff --git a/lib/Travel/Routing/DE/HAFAS/Connection.pm b/lib/Travel/Routing/DE/HAFAS/Connection.pm index c7ae121..ffb9702 100644 --- a/lib/Travel/Routing/DE/HAFAS/Connection.pm +++ b/lib/Travel/Routing/DE/HAFAS/Connection.pm @@ -14,7 +14,7 @@ use Travel::Routing::DE::HAFAS::Connection::Section; our $VERSION = '0.00'; Travel::Routing::DE::HAFAS::Connection->mk_ro_accessors( - qw(changes duration sched_dep rt_dep sched_arr rt_arr dep_datetime arr_datetime dep_platform arr_platform dep_loc arr_loc dep_cancelled arr_cancelled is_cancelled load) + 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) ); # {{{ Constructor @@ -119,8 +119,8 @@ sub new { dep_cancelled => $dep_cancelled, arr_cancelled => $arr_cancelled, is_cancelled => $is_cancelled, - dep_datetime => $rt_dep // $sched_dep, - arr_datetime => $rt_arr // $sched_arr, + dep => $rt_dep // $sched_dep, + arr => $rt_arr // $sched_arr, dep_platform => $connection->{dep}{dPlatfR} // $connection->{dep}{dPlatfS}, arr_platform => $connection->{arr}{aPlatfR} @@ -201,7 +201,7 @@ individual parts of the connection. True if the arrival of the last section in this connection has been cancelled, false otherwise. -=item $connection->arr_datetime +=item $connection->arr DateTime(3pm) object holding the arrival time and date. Based on real-time data if available, falls back to schedule data otherwise. @@ -223,7 +223,7 @@ Number of changes between different modes of transport. True if the departure of the first section in this connection has been cancelled, false otherwise. -=item $connection->dep_datetime +=item $connection->dep DateTime(3pm) object holding the departure time and date. Based on real-time data if available, falls back to schedule data otherwise. diff --git a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm index eb7198c..b3f2273 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 transfer_duration dep_loc arr_loc + 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 dep_platform arr_platform dep_cancelled arr_cancelled operator id name category category_long class number line line_no load delay direction) ); @@ -72,14 +72,17 @@ sub new { } } + # TODO load + # TODO operator + my $ref = { type => $sec->{type}, sched_dep => $sched_dep, rt_dep => $rt_dep, sched_arr => $sched_arr, rt_arr => $rt_arr, - dep_datetime => $rt_dep // $sched_dep, - arr_datetime => $rt_arr // $sched_arr, + dep => $rt_dep // $sched_dep, + arr => $rt_arr // $sched_arr, dep_loc => $locs->[ $sec->{dep}{locX} ], arr_loc => $locs->[ $sec->{arr}{locX} ], dep_platform => $sec->{dep}{dplatfR} // $sec->{dep}{dPlatfS}, @@ -99,7 +102,6 @@ sub new { if ( $sec->{type} eq 'JNY' ) { - #operator id name type type_long class number line line_no load delay direction) my $journey = $sec->{jny}; my $product = $prodL[ $journey->{prodX} ]; $ref->{id} = $journey->{jid}; @@ -119,6 +121,12 @@ sub new { { $ref->{name} .= ' ' . $product->{nameS}; } + + my @stops; + for my $stop ( @{ $journey->{stopL} // [] } ) { + my $loc = $locs->[ $stop->{locX} ]; + say $loc->name; + } } elsif ( $sec->{type} eq 'WALK' ) { $ref->{distance} = $sec->{gis}{dist}; @@ -142,7 +150,7 @@ sub new { sub set_transfer_from_previous_section { my ( $self, $prev_sec ) = @_; - my $delta = $self->dep_datetime - $prev_sec->arr_datetime; + my $delta = $self->dep - $prev_sec->arr; $self->{transfer_duration} = $delta; } @@ -175,9 +183,9 @@ Travel::Routing::DE::HAFAS::Connection::Section - A single trip between two stop for my $sec ( $connection->sections ) { printf("%s -> %s\n%s ab %s\n%s an %s\n\n", $sec->name, $sec->direction, - $sec->dep_datetime->strftime('%H:%M'), + $sec->dep->strftime('%H:%M'), $sec->dep_loc->name, - $sec->arr_datetime->strftime('%H:%M'), + $sec->arr->strftime('%H:%M'), $sec->arr_loc->name, ); } @@ -207,7 +215,7 @@ in which they are valid and return undef when called in other contexts. True if the arrival at the end of this section has been cancelled. False otherwise. -=item $section->arr_datetime +=item $section->arr DateTime(3pm) object holding the arrival time and date. Based on real-time data if available, falls back to schedule data otherwise. @@ -229,7 +237,7 @@ Arrival platform as string, not necessarily numeric. Undef if unknown. True if the departure at the start of this section has been cancelled. False otherwise. -=item $section->dep_datetime +=item $section->dep DateTime(3pm) object holding the departure time and date. Based on real-time data if available, falls back to schedule data otherwise. |