summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/EFA/Trip.pm
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-09-26 05:09:21 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-09-26 05:09:21 +0200
commit3752aa0fb16aaee7b8b55f5bdac42f21b3d0ee43 (patch)
tree0182d89ad528e25b743fadd7285cee4e24c7863a /lib/Travel/Status/DE/EFA/Trip.pm
parent385b25b93a3f10a4044df9fc73027b8ae70dbc8a (diff)
Trip->route: return Stop instances
Diffstat (limited to 'lib/Travel/Status/DE/EFA/Trip.pm')
-rw-r--r--lib/Travel/Status/DE/EFA/Trip.pm28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/Travel/Status/DE/EFA/Trip.pm b/lib/Travel/Status/DE/EFA/Trip.pm
index 3f5b134..9c83816 100644
--- a/lib/Travel/Status/DE/EFA/Trip.pm
+++ b/lib/Travel/Status/DE/EFA/Trip.pm
@@ -5,6 +5,7 @@ use warnings;
use 5.010;
use DateTime::Format::Strptime;
+use Travel::Status::DE::EFA::Stop;
use parent 'Class::Accessor';
@@ -63,20 +64,37 @@ sub route {
}
for my $stop ( @{ $self->{route_raw} // [] } ) {
+ my $chain = $stop;
+ my ( $platform, $place, $name, $name_full );
+ while ( $chain->{type} ) {
+ if ( $chain->{type} eq 'platform' ) {
+ $platform = $chain->{properties}{platformName}
+ // $chain->{properties}{platform};
+ }
+ elsif ( $chain->{type} eq 'stop' ) {
+ $name = $chain->{disassembledName};
+ $name_full = $chain->{name};
+ }
+ elsif ( $chain->{type} eq 'locality' ) {
+ $place = $chain->{name};
+ }
+ $chain = $chain->{parent};
+ }
push(
@{ $self->{route} },
- {
+ Travel::Status::DE::EFA::Stop->new(
sched_arr => $self->parse_dt( $stop->{arrivalTimePlanned} ),
sched_dep => $self->parse_dt( $stop->{departureTimePlanned} ),
rt_arr => $self->parse_dt( $stop->{arrivalTimeEstimated} ),
rt_dep => $self->parse_dt( $stop->{departureTimeEstimated} ),
latlon => $stop->{coord},
- name_full => $stop->{name},
- name => $stop->{parent}{disassembledName},
- place => $stop->{parent}{parent}{name},
+ full_name => $name_full,
+ name => $name,
+ place => $place,
niveau => $stop->{niveau},
+ platform => $platform,
id => $stop->{id},
- }
+ )
);
}