feat: display total travel distance in map view
Added calculation and display of total distance traveled in the travel map history view. This enhancement provides users with a quick overview of the cumulative distance covered during their journeys. The addition is beneficial for users tracking their travel metrics for personal or record-keeping purposes.
This commit is contained in:
parent
95e5b593db
commit
f384cfc0fe
2 changed files with 12 additions and 0 deletions
|
@ -1342,6 +1342,7 @@ sub map_history {
|
|||
with_polyline => $with_polyline,
|
||||
after => $filter_from,
|
||||
before => $filter_until,
|
||||
verbose => 1
|
||||
);
|
||||
|
||||
if ($filter_type) {
|
||||
|
@ -1357,12 +1358,19 @@ sub map_history {
|
|||
skipped_journeys => [],
|
||||
station_coordinates => [],
|
||||
polyline_groups => [],
|
||||
distance_traveled => 0,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
my $include_manual = $self->param('include_manual') ? 1 : 0;
|
||||
|
||||
my $total_distance = 0;
|
||||
|
||||
for my $journey (@journeys) {
|
||||
$total_distance += $journey->{km_route} // 0;
|
||||
}
|
||||
|
||||
my $res = $self->journeys_to_map_data(
|
||||
journeys => \@journeys,
|
||||
route_type => $route_type,
|
||||
|
@ -1374,6 +1382,7 @@ sub map_history {
|
|||
year => $year,
|
||||
with_map => 1,
|
||||
title => 'travelynx: Karte',
|
||||
total_distance => $total_distance,
|
||||
%{$res}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
%= include '_map', station_coordinates => $station_coordinates, polyline_groups => $polyline_groups
|
||||
|
||||
%= form_for '/history/map' => begin
|
||||
<p>
|
||||
Gesamtdistanz: <%= sprintf("%.2f", $total_distance // 0) %> km
|
||||
</p>
|
||||
<p>
|
||||
Detailgrad:
|
||||
</p>
|
||||
|
|
Loading…
Reference in a new issue