From fbd2756660a31e7cf900e57f63fd4a376ad3e81e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 6 Feb 2023 21:26:34 +0100 Subject: hafas: strip common city suffix --- lib/DBInfoscreen/Controller/Stationboard.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index e708305..56bf2c7 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -1588,6 +1588,10 @@ sub handle_result { ); } else { + my $city = q{}; + if ( $result->station =~ m{ , ([^,]+) $ }x ) { + $city = $1; + } push( @departures, { @@ -1603,11 +1607,13 @@ sub handle_result { train_line => $result->line, train_no => $result->number, journey_id => $result->id, - via => - [ map { $_->{name} } $result->route_interesting(3) ], - destination => $result->destination, - origin => $result->origin, - platform => $result->platform, + via => [ + map { $_->{name} =~ s{,$city}{}r } + $result->route_interesting(3) + ], + destination => $result->destination =~ s{,$city}{}r, + origin => $result->origin, + platform => $result->platform, scheduled_platform => $result->sched_platform, info => $info, is_cancelled => $result->is_cancelled, -- cgit v1.2.3