summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Helper
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2023-01-15 16:37:32 +0100
committerDaniel Friesel <derf@finalrewind.org>2023-01-15 16:37:32 +0100
commit4abc43b72e597f7c441fc2c287ed38255a1f439b (patch)
treef02d83b69808ae0eee646dce978f2907d7488ab4 /lib/Travelynx/Helper
parentf198c96e308d6e1a5cb20ae2258befefb1254517 (diff)
change route/stop layout to [name, eva, {data}]
Diffstat (limited to 'lib/Travelynx/Helper')
-rw-r--r--lib/Travelynx/Helper/HAFAS.pm30
-rw-r--r--lib/Travelynx/Helper/IRIS.pm18
2 files changed, 28 insertions, 20 deletions
diff --git a/lib/Travelynx/Helper/HAFAS.pm b/lib/Travelynx/Helper/HAFAS.pm
index 92cf1c2..803c10e 100644
--- a/lib/Travelynx/Helper/HAFAS.pm
+++ b/lib/Travelynx/Helper/HAFAS.pm
@@ -125,22 +125,22 @@ sub get_route_timestamps_p {
for my $stop ( $journey->route ) {
my $name = $stop->{name};
$ret->{$name} = $ret->{ $stop->{eva} } = {
- name => $stop->{name},
- eva => $stop->{eva},
- sched_arr => _epoch( $stop->{sched_arr} ),
- sched_dep => _epoch( $stop->{sched_dep} ),
- rt_arr => _epoch( $stop->{rt_arr} ),
- rt_dep => _epoch( $stop->{rt_dep} ),
- arr_delay => $stop->{arr_delay},
- dep_delay => $stop->{dep_delay},
- eva => $stop->{eva},
- load => $stop->{load},
- isCancelled => (
- ( $stop->{arr_cancelled} or not $stop->{sched_arr} )
- and
- ( $stop->{dep_cancelled} or not $stop->{sched_dep} )
- ),
+ name => $stop->{name},
+ eva => $stop->{eva},
+ sched_arr => _epoch( $stop->{sched_arr} ),
+ sched_dep => _epoch( $stop->{sched_dep} ),
+ rt_arr => _epoch( $stop->{rt_arr} ),
+ rt_dep => _epoch( $stop->{rt_dep} ),
+ arr_delay => $stop->{arr_delay},
+ dep_delay => $stop->{dep_delay},
+ eva => $stop->{eva},
+ load => $stop->{load}
};
+ if ( ( $stop->{arr_cancelled} or not $stop->{sched_arr} )
+ and ( $stop->{dep_cancelled} or not $stop->{sched_dep} ) )
+ {
+ $ret->{$name}{isCancelled} = 1;
+ }
if (
$station_is_past
and not $ret->{$name}{isCancelled}
diff --git a/lib/Travelynx/Helper/IRIS.pm b/lib/Travelynx/Helper/IRIS.pm
index 3222dad..eee7b58 100644
--- a/lib/Travelynx/Helper/IRIS.pm
+++ b/lib/Travelynx/Helper/IRIS.pm
@@ -179,27 +179,35 @@ sub route_diff {
while ( $route_idx <= $#route and $sched_idx <= $#sched_route ) {
if ( $route[$route_idx] eq $sched_route[$sched_idx] ) {
- push( @json_route, [ $route[$route_idx], {}, undef ] );
+ push( @json_route, [ $route[$route_idx], undef, {} ] );
$route_idx++;
$sched_idx++;
}
# this branch is inefficient, but won't be taken frequently
elsif ( not( grep { $_ eq $route[$route_idx] } @sched_route ) ) {
- push( @json_route, [ $route[$route_idx], {}, 'additional' ], );
+ push( @json_route,
+ [ $route[$route_idx], undef, { isAdditional => 1 } ],
+ );
$route_idx++;
}
else {
- push( @json_route, [ $sched_route[$sched_idx], {}, 'cancelled' ], );
+ push( @json_route,
+ [ $sched_route[$sched_idx], undef, { isCancelled => 1 } ],
+ );
$sched_idx++;
}
}
while ( $route_idx <= $#route ) {
- push( @json_route, [ $route[$route_idx], {}, 'additional' ], );
+ push( @json_route,
+ [ $route[$route_idx], undef, { isAdditional => 1 } ],
+ );
$route_idx++;
}
while ( $sched_idx <= $#sched_route ) {
- push( @json_route, [ $sched_route[$sched_idx], {}, 'cancelled' ], );
+ push( @json_route,
+ [ $sched_route[$sched_idx], undef, { isCancelled => 1 } ],
+ );
$sched_idx++;
}
return @json_route;