summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/HAFAS/Stop.pm
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-11-25 10:02:01 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2023-11-25 10:05:30 +0100
commit9d928f5cf6bb4ec857bf2b300894d5fee5ec61e2 (patch)
treeba370f49dcfcaebeac9012a636397a487320e739 /lib/Travel/Status/DE/HAFAS/Stop.pm
parent6c2ebcb388c3ee99522b2afd9e83dcabe8eb4b61 (diff)
Add support for stop-specific messages in journeys
Diffstat (limited to 'lib/Travel/Status/DE/HAFAS/Stop.pm')
-rw-r--r--lib/Travel/Status/DE/HAFAS/Stop.pm34
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Stop.pm b/lib/Travel/Status/DE/HAFAS/Stop.pm
index 5763465..5d2ab36 100644
--- a/lib/Travel/Status/DE/HAFAS/Stop.pm
+++ b/lib/Travel/Status/DE/HAFAS/Stop.pm
@@ -29,7 +29,8 @@ sub new {
my $common = $opt{common};
my $date = $opt{date};
my $datetime_ref = $opt{datetime_ref};
- my $strp_obj = $opt{strp_obj};
+ my $hafas = $opt{hafas};
+ my $strp_obj = $opt{hafas}{strptime_obj};
my $sched_arr = $stop->{aTimeS};
my $rt_arr = $stop->{aTimeR};
@@ -69,6 +70,21 @@ sub new {
my $arr_cancelled = $stop->{aCncl};
my $dep_cancelled = $stop->{dCncl};
+ my @messages;
+ for my $msg ( @{ $stop->{msgL} // [] } ) {
+ if ( $msg->{type} eq 'REM' and defined $msg->{remX} ) {
+ push( @messages,
+ $hafas->add_message( $opt{common}{remL}[ $msg->{remX} ] ) );
+ }
+ elsif ( $msg->{type} eq 'HIM' and defined $msg->{himX} ) {
+ push( @messages,
+ $hafas->add_message( $opt{common}{himL}[ $msg->{himX} ], 1 ) );
+ }
+ else {
+ say "Unknown message type $msg->{type}";
+ }
+ }
+
my $tco = {};
for my $tco_id ( @{ $stop->{dTrnCmpSX}{tcocX} // [] } ) {
my $tco_kv = $common->{tcocL}[$tco_id];
@@ -94,6 +110,7 @@ sub new {
is_changed_platform => $changed_platform,
platform => $rt_platform // $sched_platform,
load => $tco,
+ messages => \@messages,
};
bless( $ref, $obj );
@@ -121,6 +138,15 @@ sub handle_day_change {
return $timestr;
}
+sub messages {
+ my ($self) = @_;
+
+ if ( $self->{messages} ) {
+ return @{ $self->{messages} };
+ }
+ return;
+}
+
sub TO_JSON {
my ($self) = @_;
@@ -225,6 +251,12 @@ Departure or arrival delay in minutes.
Direction signage from this stop on, undef if unchanged.
+=item $journey->messages
+
+List of Travel::Status::DE::HAFAS::Message(3pm) instances related to this stop.
+These typically refer to delay reasons, platform changes, or changes in the
+line number / direction heading.
+
=item $stop->rt_platform
Actual platform.