Skip to content
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,21 @@ const _getTravelStats = (locationHistory) => {
Object.keys(locationHistory).forEach((user) => {
Object.keys(locationHistory[user]).forEach((device) => {
let lastLatLng = null;
let lastAlt = null;
locationHistory[user][device].forEach((location) => {
if (
config.filters.minAccuracy !== null &&
location.acc > config.filters.minAccuracy
)
return;
const latLng = L.latLng(location.lat, location.lon, location.alt ?? 0);
const latLng = L.latLng(location.lat, location.lon, location.alt);
if (lastLatLng !== null) {
const distance = distanceBetweenCoordinates(lastLatLng, latLng);
const elevationChange = latLng.alt - lastLatLng.alt;
// calculate the elevationChange only if there is an alt available
let elevationChange = 0;
if (lastAlt !== null && latLng.alt !== null) {
Comment thread
linusg marked this conversation as resolved.
Outdated
elevationChange = latLng.alt - lastAlt;
}
if (
typeof config.map.maxPointDistance === "number" &&
config.map.maxPointDistance > 0
Expand All @@ -153,6 +158,9 @@ const _getTravelStats = (locationHistory) => {
else elevationLoss += -elevationChange;
}
}
if (latLng.alt !== null) {
lastAlt = latLng.alt;
}
lastLatLng = latLng;
});
});
Expand Down
Loading