Display delta heigth stats for trkseg
This commit is contained in:
1 parent
73172812f5
commit
99daeefa98
4 files changed
+41
-6
No files matched your search
@@ -0,0 +1,33 @@
|
||||
export const getHeightStats = (wpts: Wpt[]) => {
|
||||
let previous: number | null = null,
|
||||
min: number | null = null,
|
||||
max: number | null = null,
|
||||
positive: number = 0,
|
||||
negative: number = 0;
|
||||
|
||||
wpts.forEach((wpt) => {
|
||||
if (wpt.ele) {
|
||||
const ele = Math.round(wpt.ele);
|
||||
if (!max || ele > max) {
|
||||
max = ele;
|
||||
}
|
||||
if (!min || ele < min) {
|
||||
min = ele;
|
||||
}
|
||||
if (previous) {
|
||||
if (ele > previous) {
|
||||
positive += ele - previous;
|
||||
} else {
|
||||
negative += previous - ele;
|
||||
}
|
||||
}
|
||||
previous = ele;
|
||||
}
|
||||
});
|
||||
return { min, max, positive, negative };
|
||||
};
|
||||
|
||||
export const getFormattedHeightStats = (wpts: Wpt[]) => {
|
||||
const { min, max, positive, negative } = getHeightStats(wpts);
|
||||
return `d+ : ${positive}m, d- : ${negative}m`;
|
||||
};
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { LineString } from 'ol/geom';
|
||||
import { getLength } from 'ol/sphere';
|
||||
|
||||
export const getFormatedLength = (lineString: LineString) => {
|
||||
export const getFormattedLength = (lineString: LineString) => {
|
||||
const length = getLength(lineString, { projection: 'EPSG:4326' });
|
||||
if (length > 1000) {
|
||||
const l = length / 1000;
|
||||
|
||||
Reference in new issue
Block a user