From b210ccc5b8d5cad05688f14e1e81e29c27d75592 Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Sat, 29 Aug 2026 03:09:35 +0200 Subject: [PATCH] task(H5): polygon area calculation - shoelace polygonArea, formatArea with quadratic scaling, measure-area tool, properties panel area display --- frontend/src/components/PropertiesPanel.tsx | 10 +- .../src/plugins/builtin/core-measure/index.ts | 69 ++++++++- frontend/src/tools/modification/geometry.ts | 16 ++ frontend/src/utils/format.ts | 25 ++++ frontend/tests/measureArea.test.ts | 137 ++++++++++++++++++ 5 files changed, 254 insertions(+), 3 deletions(-) create mode 100644 frontend/tests/measureArea.test.ts diff --git a/frontend/src/components/PropertiesPanel.tsx b/frontend/src/components/PropertiesPanel.tsx index 1c973f5..ee14b9e 100644 --- a/frontend/src/components/PropertiesPanel.tsx +++ b/frontend/src/components/PropertiesPanel.tsx @@ -1,4 +1,6 @@ import React, { useState, useEffect } from 'react'; +import { polygonArea } from '../tools/modification/geometry'; +import { formatArea } from '../utils/format'; import type { PropertiesPanelProps } from '../types/ui.types'; import { formatInputValue, parseDistance, type UnitType } from '../utils/format'; @@ -69,7 +71,13 @@ const PropertiesPanel: React.FC = ({ <>
- Auswahl {el ? `· ${el.type}` : ''} + Auswahl {el ? `· ${el.type} + {((el.type === 'polygon' || el.type === 'polyline') && ((el.properties.points as Array<{ x: number; y: number }> | undefined)?.length ?? 0) >= 3) && ( +
+ + {formatArea(polygonArea(el.properties.points as Array<{ x: number; y: number }>), unit, scaleFactor)} +
+ )}` : ''}
{onDelete && el && (