ERA-8882 Show polygon area when measuring with the map ruler - #1679
ERA-8882 Show polygon area when measuring with the map ruler#1679jeslefcourt wants to merge 2 commits into
Conversation
While drawing, the cursor popup shows the live area of the polygon formed by the committed ruler points plus the cursor position, closed back to the first point. After finishing, each point popup shows the measured polygon's area alongside bearing and distance. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds live polygon area measurement to the map ruler tool (MapRulerControl), showing area while drawing (cursor popup) and after finishing (point popups), with shared area-formatting helpers and i18n support.
Changes:
- Introduces area calculation/formatting helpers for ruler points (including cursor-as-vertex handling) and unit tests for those helpers.
- Updates the map ruler cursor popup and point popups to display polygon area when 3+ vertices exist.
- Adds new translation keys across all supported locales and bumps the i18n file version.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/MapRulerControl/utils.js | Adds turf-based area helpers for closed-ring polygon area display (incl. cursor vertex). |
| src/MapRulerControl/utils.test.js | Unit tests covering ring gating, closure, and cursor handling. |
| src/MapRulerControl/PointPopup.js | Displays polygon area on point popups when 3+ points exist. |
| src/MapRulerControl/PointPopup.test.js | Verifies area presence/absence behavior in point popups. |
| src/MapRulerControl/index.js | Injects computed area into the cursor popup via renderCursorPopup. |
| src/MapDrawingTools/index.js | Extends DefaultCursorPopup to optionally render an area line. |
| src/MapDrawingTools/index.test.js | Adds tests for DefaultCursorPopup area rendering and ordering. |
| src/i18n.js | Bumps I18N_FILES_VERSION to pick up updated locale JSON. |
| public/locales/*/map-controls.json | Adds mapDrawingTools.areaLabel and pointPopup.areaLabel translations. |
The fill uses the ring the area readout measures: committed points plus the live cursor vertex while drawing, closed back to the first point. The ruler's MapDrawingTools now sits in its own context provider so its drawing data can no longer leak into the shared context that AreaPicker reads event-area polygons from. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Added in 82fd3d1: while the ruler is active, the measured polygon is now lightly shaded (same red as the polygon-draw fill at 0.1 opacity), tracking the cursor live while drawing via a new opt-in This also wraps the ruler's |
What
Shows the area of the polygon outlined by the map ruler's segments once three or more vertices exist.
Area:line between the existingBearing:andDistance:lines. The polygon is the committed points plus the current cursor position, closed back to the first point, so the value updates live with mouse movement, clicks, and point drags — per the ticket's acceptance criteria it appears from 2 committed points onward.Area is computed with turf (
polygon+area) and displayed in km² to 2 decimals, consistent with the existing km distance readout. Shared helpers live insrc/MapRulerControl/utils.js.How
DefaultCursorPopupinMapDrawingToolstakes an optionalareaprop (defaultnull) injected via the existingrenderCursorPopupoverride, so other consumers (e.g.ReportGeometryDrawer) are unaffected. New i18n keyspointPopup.areaLabelandmapDrawingTools.areaLabelin all six locales;I18N_FILES_VERSIONbumped to 1.44.Testing
New unit coverage for the area helpers (ring gating, cursor-vertex handling), the point popup (area absent below 3 points, present at 3+, shown on non-last points), and the cursor popup (paragraph order bearing → area → distance; unchanged without
area).yarn test src/MapRulerControl src/MapDrawingTools: 3 suites, 26 tests passing; consumer suites (ReportGeometryDrawer,AreaPicker) unaffected. ESLint/stylelint at pre-existing baseline.ERA-8882
🤖 Generated with Claude Code