feat: select and drag stop lines the same way as crosswalks

Element identity moves behind a provenance-keyed registry, and stop lines join
as its second entry. Selection, the dashed box and the drag all work unchanged —
the registry supplies the group key, the layer the members live in, and the
constraint that moves them.

Stop lines are the useful second case rather than an easy one. They are a group
of one where a crosswalk is six, so adding them proves the grouping does not
quietly depend on there being parts; and they share crossing_node_id with the
zebra they protect on all eight measured groups, so provenance has to pick the
type before the key is ever read. A test holds both.

The registry promises only what the measurements support: provenance picks the
type, then a key picks the group. Arrows are deliberately absent — their group
keys are two-field and derived, group sizes run to 230, and neither has a
constraint kind the geometry stage reads.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
que01andClaude Opus 5 committed 2026-08-31 15:36:33 +08:00
1 parent 323ff9279f
commit 84c82f3f09
3 files changed
+192 -58

No files matched your search

+18 -10
View File
@@ -4,10 +4,12 @@ import { api, isVersionConflict } from './lib/api';
import { MapCanvas } from './components/MapCanvas';
import { ParameterPanel, type ParameterPanelHandle } from './components/ParameterPanel';
import {
crosswalkHandleFor,
elementSelectionFor,
groupMembers,
handleForElement,
orientedBoundsOf,
specFor,
specOfKind,
type ElementSelection,
} from './edit/element';
import { directEditEnabled, intervalEditingSupported } from './edit/flag';
@@ -186,14 +188,15 @@ function App() {
*/
const elementOutline = useMemo<ElementOutline | null>(() => {
if (!directEditEnabled || !element || !state) return null;
const handle = crosswalkHandleFor(element, state.compiled.model.roads, editHandles);
const handle = handleForElement(element, state.compiled.model.roads, editHandles);
if (!handle?.editable) return null;
// Read the preview when there is one. `state.layers` is the last *compiled*
// output and does not move during editing, so measuring the box there left it
// behind at the baseline while the zebra itself — drawn from the preview —
// behind at the baseline while the marking itself — drawn from the preview —
// slid out from under it. A null preview layer means "back to baseline",
// which is what the fallback expresses.
const drawn = preview?.crosswalks ?? state.layers.crosswalks;
const layer = specOfKind(element.kind).layer;
const drawn = preview?.[layer] ?? state.layers[layer];
const bounds = orientedBoundsOf(groupMembers(drawn?.features ?? [], element.elementId));
return bounds ? { handleId: handle.handleId, bounds } : null;
}, [element, editHandles, state, preview]);
@@ -495,11 +498,16 @@ function App() {
);
const handleFeature = (properties: Record<string, unknown>) => {
setMarking(properties);
// A crosswalk is six features but one editable thing. Clicking any stripe
// selects the group; clicking anything else drops the element selection,
// because a box left around a crosswalk the user navigated away from reads
// as a stuck UI.
if (directEditEnabled) setElement(elementSelectionFor(properties, state.layers.crosswalks?.features ?? []));
// A crosswalk is six features but one editable thing; a stop line is one.
// `provenance` picks which, and therefore which layer holds its siblings —
// the two share `crossing_node_id`, so keying on that alone would merge a
// zebra with the stop line protecting it. Clicking anything else drops the
// selection, because a box left around what the user navigated away from
// reads as a stuck UI.
if (directEditEnabled) {
const spec = specFor(properties);
setElement(spec ? elementSelectionFor(properties, state.layers[spec.layer]?.features ?? []) : null);
}
const uid = properties.signal_uid;
if (typeof uid === 'string') setStatus(`已选中原生红绿灯 ${uid}`);
else if (properties.effective_style) setStatus('已选中标线,可在右侧暂存样式');
@@ -517,7 +525,7 @@ function App() {
<span className={editDiagnostics.some((item) => item.severity === 'error') ? 'dirty' : ''}>
{editDiagnostics.find((item) => item.severity === 'error')?.message ||
(element
? `已选中斑马线 ${element.crossingNodeId}(${element.featureIds.length} 条)`
? `已选中${specOfKind(element.kind).label} ${element.crossingNodeId}(${element.featureIds.length} 条)`
: editHandles.length
? `手柄 ${editHandles.length} 个`
: selected