summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r--lib/Travel/Status/DE/URA/Result.pm50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/Travel/Status/DE/URA/Result.pm b/lib/Travel/Status/DE/URA/Result.pm
index bf2f0b0..c59d9e1 100644
--- a/lib/Travel/Status/DE/URA/Result.pm
+++ b/lib/Travel/Status/DE/URA/Result.pm
@@ -56,6 +56,56 @@ sub type {
return 'Bus';
}
+sub route_interesting {
+ my ( $self, $max_parts ) = @_;
+
+ my @via = map { $_->[1] } @{ $self->{route_timetable} };
+
+ my ( @via_main, @via_show, $last_stop );
+ $max_parts //= 3;
+
+ for my $stop (@via) {
+ if (
+ $stop->name_suf =~ m{ bf | hbf | Flughafen | bahnhof
+ | Krankenhaus | Klinik | bushof | busstation }iox
+ )
+ {
+ push( @via_main, $stop );
+ }
+ }
+ $last_stop = pop(@via);
+
+ if ( @via_main and $via_main[-1] == $last_stop ) {
+ pop(@via_main);
+ }
+ if ( @via and $via[-1] == $last_stop ) {
+ pop(@via);
+ }
+
+ if ( @via_main and @via and $via[0] == $via_main[0] ) {
+ shift(@via_main);
+ }
+
+ if ( @via < $max_parts ) {
+ @via_show = @via;
+ }
+ else {
+ if ( @via_main >= $max_parts ) {
+ @via_show = ( $via[0] );
+ }
+ else {
+ @via_show = splice( @via, 0, $max_parts - @via_main );
+ }
+
+ while ( @via_show < $max_parts and @via_main ) {
+ my $stop = shift(@via_main);
+ push( @via_show, $stop );
+ }
+ }
+
+ return @via_show;
+}
+
sub route_timetable {
my ($self) = @_;