Ascent and descent values too high
@morehawes is already working on this.
Since Jan 19, 2024.
Assessment
This issue has not been assessed yet.
Description
Hi
Ascent and descent values are too high, because they are calculated every 1 to 4 meters. They should be calculated in bigger walking distances. My suggestion is 10 meters.
I have adjusted the source code, which is pasted at the end of this message. Only what I have marked with DGF are changes made by me, the rest is the original. There are two functions in leaflet-elevation.js that are affected: _addData and _addPoint.
Best regards.
Daniel.
/*
* Parsing data either from GPX or GeoJSON and update the diagram data
*/
_addData: function(d) {
let geom = d && d.geometry;
let feat = d && d.type === "FeatureCollection";
let gpx = d && d._latlngs;
if (geom) {
switch (geom.type) {
case 'LineString':
this._addGeoJSONData(geom.coordinates);
break;
case 'MultiLineString':
geom.coordinates.forEach(coords => this._addGeoJSONData(coords));
break;
default:
console.warn('Unsopperted GeoJSON feature geometry type:' + geom.type);
}
//DGF if elevation difference is too small, make ascent and descent equal
if (Math.abs(this._ascent-this._descent) <= 10)
{
this.track_info.descent = this.track_info.ascent;
this._descent = this.track_info.descent;
}
//DGF end
}
if (feat) {
d.features.forEach(feature => this._addData(feature));
}
if (gpx) {
this._addGPXdata(d._latlngs);
}
},
/*
* Parse and push a single (x, y, z) point to current elevation profile.
*/
_addPoint: function(x, y, z) {
if (this.options.reverseCoords) {
[x, y] = [y, x];
}
let data = this._data || [];
let eleMax = this._maxElevation || -Infinity;
let eleMin = this._minElevation || +Infinity;
let dist = this._distance || 0;
//DGF
let elevDist = this._elevationMesurementDistance || 0;
//DGF end
let curr = new L.LatLng(x, y);
let prev = data.length ? data[data.length - 1].latlng : curr;
let delta = curr.distanceTo(prev) * this._distanceFactor;
dist = dist + Math.round(delta / 1000 * 100000) / 100000;
//DGF
elevDist = elevDist + delta;
//DGF end
// check and fix missing elevation data on last added point
if (!this.options.skipNullZCoords && data.length > 0)
{
let prevZ = data[data.length - 1].z;
if (isNaN(prevZ)) {
let lastZ = this._lastValidZ;
let currZ = z * this._heightFactor;
if (!isNaN(lastZ) && !isNaN(currZ)) {
prevZ = (lastZ + currZ) / 2;
} else if (!isNaN(lastZ)) {
prevZ = lastZ;
} else if (!isNaN(currZ)) {
prevZ = currZ;
}
if (!isNaN(prevZ)) data[data.length - 1].z = prevZ;
else data.splice(data.length - 1, 1);
}
}
z = z * this._heightFactor;
// skip point if it has not elevation
if (!isNaN(z))
{
eleMax = eleMax < z ? z : eleMax;
eleMin = eleMin > z ? z : eleMin;
// calculate new ascent or descent
//DGF measure elevation only every 10 meters of walking distance
if (elevDist >= 10 || isNaN(this._lastMeasuredZ))
{
elevDist = 0;
let dz = z - this._lastMeasuredZ ; //DGF
if (dz > 0)
{
this.track_info.ascent = (this.track_info.ascent || 0) + dz; // Total Ascent
this._ascent = this.track_info.ascent;
}
else if (dz < 0)
{
this.track_info.descent = (this.track_info.descent || 0) - dz; // Total Descent
this._descent = this.track_info.descent;
}
this._lastMeasuredZ = z; //DGF
}
this._elevationMesurementDistance = elevDist;
//DGF end
this._lastValidZ = z;
// set up last valid z value
}
data.push({
dist: dist,
x: x,
y: y,
z: z,
latlng: curr
});
this._data = data;
this._distance = dist;
this._maxElevation = eleMax;
this._minElevation = eleMin;
},
- Dominant language
- PHP
- Stars
- 29
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenGIS/waymark-wp
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
OpenGIS/waymark-wp#82 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
OpenGIS/waymark-wp#81 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
OpenGIS/waymark-wp#83 ·
-
enhancement good first issue Please Test! To-Do
Difficulty 3/5 1-2 days Newbie friendliness 30/100
OpenGIS/waymark-wp#67 · 2 comments ·
-
enhancement good first issue
Difficulty 3/5 1-2 days Newbie friendliness 25/100
OpenGIS/waymark-wp#49 · 2 comments ·
All issues in OpenGIS/waymark-wp
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
9.1 9.2 Bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
neos/neos-development-collection#6046 ·
Maintainers usually reply within 1 day
-
[Sync EN] Pdo\Pgsql: document session state reset on persistent connections (PHP 8.6) (#6084)Possibly taken @lacatoire claimed this today. Opensync-en
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Перевод устарел
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Potential Bug To Triage
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
matomo-org/matomo#25740 ·
Maintainers usually reply within 1 day