From a8eb30553b5ce27ce9217bb90dca773cf1d30bf8 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sun, 22 Sep 2024 09:32:24 +0200 Subject: prevStopSeq, onwardStopSeq: remove requested stop from results --- lib/Travel/Status/DE/EFA.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm index 0f2bdee..ada0ea3 100644 --- a/lib/Travel/Status/DE/EFA.pm +++ b/lib/Travel/Status/DE/EFA.pm @@ -410,7 +410,7 @@ sub parse_line { } sub parse_route { - my ( $self, $stop_seq ) = @_; + my ( $self, $stop_seq, $requested_id ) = @_; my @ret; if ( not $stop_seq ) { @@ -419,6 +419,11 @@ sub parse_route { # Oh EFA, you so silly if ( ref($stop_seq) eq 'HASH' ) { + + # For lines that start or terminate at the requested stop, onwardStopSeq / prevStopSeq includes the requested stop. + if ( $stop_seq->{ref}{id} eq $requested_id ) { + return \@ret; + } $stop_seq = [$stop_seq]; } @@ -488,10 +493,12 @@ sub parse_departure { } if ( $departure->{prevStopSeq} ) { - $prev_route = $self->parse_route( $departure->{prevStopSeq} ); + $prev_route = $self->parse_route( $departure->{prevStopSeq}, + $departure->{stopID} ); } if ( $departure->{onwardStopSeq} ) { - $next_route = $self->parse_route( $departure->{onwardStopSeq} ); + $next_route = $self->parse_route( $departure->{onwardStopSeq}, + $departure->{stopID} ); } return Travel::Status::DE::EFA::Departure->new( -- cgit v1.2.3