diff --git a/src/modules/infobox/components/FeatureAreaInfo.vue b/src/modules/infobox/components/FeatureAreaInfo.vue index 7250de67b..38b62cfef 100644 --- a/src/modules/infobox/components/FeatureAreaInfo.vue +++ b/src/modules/infobox/components/FeatureAreaInfo.vue @@ -6,7 +6,6 @@ import { useStore } from 'vuex' import { useTippyTooltip } from '@/utils/composables/useTippyTooltip' import { WGS84 } from '@/utils/coordinates/coordinateSystems' import { reprojectGeoJsonData, transformIntoTurfEquivalent } from '@/utils/geoJsonUtils' -import { round } from '@/utils/numberUtils' const props = defineProps({ geometry: { @@ -34,22 +33,20 @@ const humanReadableArea = computed(() => { const calculatedArea = area(transformIntoTurfEquivalent(geometryWgs84.value)) let result = '' if (calculatedArea) { - result += roundValueIfGreaterThan(calculatedArea, 1000, 1000000) - if (calculatedArea > 10000) { - result += ' km' - } else { + const unitThreshold = 1e5 + const divider = 1e6 + const precision = 5 + + const value = calculatedArea < unitThreshold ? calculatedArea : calculatedArea / divider + result += parseFloat(value.toPrecision(precision)) + if (calculatedArea < unitThreshold) { result += ' m' + } else { + result += ' km' } } return result }) - -function roundValueIfGreaterThan(value, threshold, divider) { - if (value > threshold) { - return `${round(value / divider, 2)}` - } - return `${round(value, 2)}` -}