Refactoring
This commit is contained in:
1 parent
b23e44b576
commit
7483d9f904
4 files changed
+86
-74
No files matched your search
@@ -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`;
|
||||
};
|
||||
Reference in new issue
Block a user