diff --git a/src/modules/infobox/components/FeatureAreaInfo.vue b/src/modules/infobox/components/FeatureAreaInfo.vue index dfd077960..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: { @@ -40,10 +39,10 @@ const humanReadableArea = computed(() => { const value = calculatedArea < unitThreshold ? calculatedArea : calculatedArea / divider result += parseFloat(value.toPrecision(precision)) - if (calculatedArea >= unitThreshold) { - result += ' km' - } else { + if (calculatedArea < unitThreshold) { result += ' m' + } else { + result += ' km' } } return result diff --git a/tests/cypress/tests-e2e/drawing.cy.js b/tests/cypress/tests-e2e/drawing.cy.js index 84b8398df..52d439f1f 100644 --- a/tests/cypress/tests-e2e/drawing.cy.js +++ b/tests/cypress/tests-e2e/drawing.cy.js @@ -586,9 +586,6 @@ describe('Drawing module tests', () => { const [polygonCoordinates] = polygon.getGeometry().getCoordinates() expect(polygonCoordinates).to.be.an('Array').lengthOf(4) }) - cy.get('[data-cy="feature-area-information"]') - .should('be.visible') - .contains('187.224 km') // Changing the color of the polygon and checking that the KMl was updated accordingly cy.get('[data-cy="drawing-style-line-button"]').click() @@ -628,6 +625,35 @@ describe('Drawing module tests', () => { const line = features[1] expect(line.getGeometry().getCoordinates().length).to.eq(2) }) + + cy.goToMapView( + { + zoom: 6, + }, + false + ) + + cy.log('Feature Area Info should be in meters below unit threshold') + cy.goToDrawing() + cy.clickDrawingTool(EditableFeatureTypes.LINEPOLYGON) + + cy.get('[data-cy="ol-map"]').click(100, 200) + cy.get('[data-cy="ol-map"]').click(150, 200) + cy.get('[data-cy="ol-map"]').click(150, 230) + cy.get('[data-cy="ol-map"]').click(100, 200) + cy.get('[data-cy="feature-area-information"]').should('be.visible').contains('74802 m2') + + cy.log('Feature Area Info should be in kilometers above unit threshold') + cy.clickDrawingTool(EditableFeatureTypes.LINEPOLYGON) + + cy.get('[data-cy="ol-map"]').click(200, 200) + cy.get('[data-cy="ol-map"]').click(150, 200) + cy.get('[data-cy="ol-map"]').click(150, 300) + cy.get('[data-cy="ol-map"]').click(200, 200) + + cy.get('[data-cy="feature-area-information"]') + .should('be.visible') + .contains('0.24935 km2') }) }) context('KML management', () => {