summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/HAFAS/Stop.pm
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2023-04-11 19:30:05 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2023-04-11 19:30:05 +0200
commit4871bc50f636dca9030575b2d693079a5fd663d7 (patch)
tree7e0f158a035fd311a8b1a37c6465f0983d1fe46f /lib/Travel/Status/DE/HAFAS/Stop.pm
parent72bc43a9e4e010020e94a701648ba51dc8d580ed (diff)
Journey->route: Return Stop instances
Diffstat (limited to 'lib/Travel/Status/DE/HAFAS/Stop.pm')
-rw-r--r--lib/Travel/Status/DE/HAFAS/Stop.pm94
1 files changed, 91 insertions, 3 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Stop.pm b/lib/Travel/Status/DE/HAFAS/Stop.pm
index 3c56900..7e05ad0 100644
--- a/lib/Travel/Status/DE/HAFAS/Stop.pm
+++ b/lib/Travel/Status/DE/HAFAS/Stop.pm
@@ -20,7 +20,7 @@ sub new {
my $loc = $opt{loc};
my $ref = {
- eva => 0 + $loc->{extId},
+ eva => $loc->{extId} + 0,
name => $loc->{name},
lat => $loc->{crd}{x} * 1e-6,
lon => $loc->{crd}{y} * 1e-6,
@@ -28,6 +28,12 @@ sub new {
distance_m => $loc->{dist},
};
+ if ( $opt{extra} ) {
+ while ( my ( $k, $v ) = each %{ $opt{extra} } ) {
+ $ref->{$k} = $v;
+ }
+ }
+
bless( $ref, $obj );
return $ref;
@@ -35,6 +41,20 @@ sub new {
# }}}
+sub TO_JSON {
+ my ($self) = @_;
+
+ my $ret = { %{$self} };
+
+ for my $k ( keys %{$ret} ) {
+ if ( ref( $ret->{$k} ) eq 'DateTime' ) {
+ $ret->{$k} = $ret->{$k}->epoch;
+ }
+ }
+
+ return $ret;
+}
+
1;
__END__
@@ -63,8 +83,8 @@ version 4.09
Travel::Status::DE::HAFAS::Stop describes a HAFAS stop. It may be part of a
journey or part of a geoSearch / locationSearch request.
-geoSearch- and locationSearch-specific accessors are annotated accordingly and
-return undef for non-geoSearch / non-locationSearch stops.
+Journey-, geoSearch- and locationSearch-specific accessors are annotated
+accordingly and return undef in other contexts.
=head1 METHODS
@@ -97,6 +117,74 @@ Distance in meters between the requested coordinates and this stop.
Weight / Relevance / Importance of this stop using an unknown metric.
Higher values indicate more relevant stops.
+=item $stop->rt_arr (journey)
+
+DateTime object for actual arrival.
+
+=item $stop->sched_arr (journey)
+
+DateTime object for scheduled arrival.
+
+=item $stop->arr (journey)
+
+DateTime object for actual or scheduled arrival.
+
+=item $stop->arr_delay (journey)
+
+Arrival delay in minutes.
+
+=item $stop->arr_cancelled (journey)
+
+Arrival is cancelled.
+
+=item $stop->rt_dep (journey)
+
+DateTime object for actual departure.
+
+=item $stop->sched_dep (journey)
+
+DateTime object for scheduled departure.
+
+=item $stop->dep (journey)
+
+DateTIme object for actual or scheduled departure.
+
+=item $stop->dep_delay (journey)
+
+Departure delay in minutes.
+
+=item $stop->dep_cancelled (journey)
+
+Departure is cancelled.
+
+=item $stop->delay (journey)
+
+Departure or arrival delay in minutes.
+
+=item $stop->direction (journey)
+
+Direction signage from this stop on, undef if unchanged.
+
+=item $stop->rt_platform (journey)
+
+Actual platform.
+
+=item $stop->sched_platform (journey)
+
+Scheduled platform.
+
+=item $stop->platform (journey)
+
+Actual or scheduled platform.
+
+=item $stop->is_changed_platform (journey)
+
+True if real-time and scheduled platform disagree.
+
+=item $stop->load (journey)
+
+Expected utilization / passenger load from this stop on.
+
=back
=head1 DIAGNOSTICS