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,
|
with_polyline => $with_polyline,
|
||||||
after => $filter_from,
|
after => $filter_from,
|
||||||
before => $filter_until,
|
before => $filter_until,
|
||||||
|
verbose => 1
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($filter_type) {
|
if ($filter_type) {
|
||||||
|
@ -1357,12 +1358,19 @@ sub map_history {
|
||||||
skipped_journeys => [],
|
skipped_journeys => [],
|
||||||
station_coordinates => [],
|
station_coordinates => [],
|
||||||
polyline_groups => [],
|
polyline_groups => [],
|
||||||
|
distance_traveled => 0,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $include_manual = $self->param('include_manual') ? 1 : 0;
|
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(
|
my $res = $self->journeys_to_map_data(
|
||||||
journeys => \@journeys,
|
journeys => \@journeys,
|
||||||
route_type => $route_type,
|
route_type => $route_type,
|
||||||
|
@ -1374,6 +1382,7 @@ sub map_history {
|
||||||
year => $year,
|
year => $year,
|
||||||
with_map => 1,
|
with_map => 1,
|
||||||
title => 'travelynx: Karte',
|
title => 'travelynx: Karte',
|
||||||
|
total_distance => $total_distance,
|
||||||
%{$res}
|
%{$res}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
%= include '_map', station_coordinates => $station_coordinates, polyline_groups => $polyline_groups
|
%= include '_map', station_coordinates => $station_coordinates, polyline_groups => $polyline_groups
|
||||||
|
|
||||||
%= form_for '/history/map' => begin
|
%= form_for '/history/map' => begin
|
||||||
|
<p>
|
||||||
|
Gesamtdistanz: <%= sprintf("%.2f", $total_distance // 0) %> km
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Detailgrad:
|
Detailgrad:
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in a new issue