summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Controller
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-11-16 15:24:16 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-11-16 15:24:16 +0100
commit77e4998708a31d38e4d04f185c9fc12e26245d2c (patch)
tree0296fcf3092e2854d678ec0ae40979decb522b14 /lib/Travelynx/Controller
parent45f747961e14c5f63e895cdda97a830c5837a118 (diff)
move station -> location map to generic helper
Diffstat (limited to 'lib/Travelynx/Controller')
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 3c4a8d7..1fb43a2 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -416,13 +416,7 @@ sub history {
sub map_history {
my ($self) = @_;
- my %location;
-
- for my $station ( Travel::Status::DE::IRIS::Stations::get_stations() ) {
- if ( $station->[3] ) {
- $location{ $station->[1] } = [ $station->[4], $station->[3] ];
- }
- }
+ my $location = $self->app->coordinates_by_station;
# TODO create map-specific get_user_travels function returning EVA/DS100 station codes?
my @journeys = $self->get_user_travels;
@@ -430,8 +424,8 @@ sub map_history {
my @stations = uniq map { $_->{to_name} } @journeys;
push( @stations, uniq map { $_->{from_name} } @journeys );
@stations = uniq @stations;
- my @station_coordinates
- = map { [ $location{$_}, $_ ] } grep { exists $location{$_} } @stations;
+ my @station_coordinates = map { [ $location->{$_}, $_ ] }
+ grep { exists $location->{$_} } @stations;
my @uniq_by_route = uniq_by {
join( '|', map { $_->[0] } @{ $_->{route} } )
@@ -459,10 +453,11 @@ sub map_history {
@station_pairs = uniq_by { $_->[0] . '|' . $_->[1] } @station_pairs;
@station_pairs
- = grep { exists $location{ $_->[0] } and exists $location{ $_->[1] } }
+ = grep { exists $location->{ $_->[0] } and exists $location->{ $_->[1] } }
@station_pairs;
@station_pairs
- = map { [ $location{ $_->[0] }, $location{ $_->[1] } ] } @station_pairs;
+ = map { [ $location->{ $_->[0] }, $location->{ $_->[1] } ] }
+ @station_pairs;
my @routes;