Refactoring

This commit is contained in:
vdv committed 2023-01-07 18:00:35 +01:00
1 parent b23e44b576
commit 7483d9f904
4 files changed
+86 -74

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import { LineString } from 'ol/geom';
import { getLength } from 'ol/sphere';
export const getFormatedLength = (lineString: LineString) => {
const length = getLength(lineString, { projection: 'EPSG:4326' });
if (length > 1000) {
const l = length / 1000;
return ` ${l.toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})} km`;
}
return ` ${length.toLocaleString(undefined, {
minimumFractionDigits: 0,
maximumFractionDigits: 0,
})} m`;
};