5.9 KiB
Hierarchy-aware geographical repositioning
Cause and scope
The former operation projected only resolved Marker features. It neither followed canonical Location parents nor changed road frames/control points. Road rendering substitutes the current anchor coordinates for the first/last normalized point, so moving settlements alone pulled endpoints away from bends left in the original frame.
The geographical projection, provider, queue, cache and confirmation rules are unchanged. This enhancement extends the pure proposed-map calculation. No database migration or new parent/road relationship is introduced.
Canonical hierarchy
Geography/State?includeHierarchy=true returns current resolutions plus the project's Location IDs, names and ParentLocationIDs through the existing repositories and access checks. Default callers still receive the original state array. Each preview loads this hierarchy rather than depending on an old Maps-page snapshot.
Resolved unlocked pieces with valid coordinates participate directly, including explicitly associated areas and unanchored paths. Endpoint-anchored paths use their existing anchors instead of acquiring independent geographical references. Non-authoritative descendants walk their existing Location parent chain to the nearest participating geographical ancestor and inherit that ancestor's canvas displacement. Unmapped intermediate parents are supported. Each piece is moved once, so mapped intermediate descendants do not compound the displacement. A child with its own authoritative coordinates is positioned independently.
Cycles, missing hierarchy entries and several map anchors for one ancestor with conflicting displacements are reported; those descendants stay unchanged. Locked pieces remain locked and stationary. A nearer locked geographical ancestor is not bypassed to inherit a more distant participant. Unassociated decoration is unchanged. No proximity or derived geometric-containment relationship is used as a substitute for story parents.
Curves and areas
Path controls are normalized to the feature's X/Y, width/height and rotation; rendering replaces endpoint controls with anchor coordinates. The shared connectionTransform implements the similarity transform already used for free endpoint turn/extension. Geographical positioning uses it to map the entire rendered control polygon from the old to the new endpoint pair. Along-line proportions and perpendicular offsets scale/rotate together. Equal endpoint displacements produce a translation; one moving endpoint leaves the other fixed.
The transformed polygon is stored back in the existing frame/points representation. The label reference point follows the same transform, with its offsets adjusted for the normalised frame. Coincident or near-zero endpoint separation has no unique orientation; the fallback blends endpoint displacements along control-point order while retaining bends. Non-finite/out-of-range geometry or a locked path whose endpoints would move blocks the entire Apply operation. Existing paths are individual segments with at most a start/end anchor; adjoining segments transform through their shared anchors. There is no new per-control-point anchoring model.
Settlement boundaries remain offsets relative to their authoritative anchor, so moving the whole settlement translates its boundary without changing controls, smoothing or styling. Associated forests/lakes/buildings inherit only displacement. Their shapes and local canvas offsets are not geographically scaled. Manual map movement keeps its previous independent-object behaviour.
Preview and persistence
One pure calculation returns the entire proposed feature array, direct and inherited movements, transformed paths, unchanged counts and attention items. The preview renders that array through the normal scene, including drawing-order overrides and overlays. Apply assigns that same array with one existing Undo checkpoint; it does not recalculate. Cancel leaves the live document unchanged. Redo and the normal revision-protected Save preserve the complete operation. Existing GeometryJson storage and project export/import/backup/restore carry transformed curves and boundaries.
Verification
- Build and executable regression harness use the repository's normal gates.
node PlotLine.Tests/Browser/maps-geography-hierarchy-engine.cjs: hierarchy depth/nearest authority, independent children, mapped/unmapped intermediates, areas/decorations, duplicates/cycles/missing links, equal/different/single-moving endpoints, degenerate/reversed/rotated connections and atomic safety refusal.node PlotLine.Tests/Browser/maps-geography-hierarchy.cjs: normal/PWA and light/dark layouts; isolated Rubery/Frankley/Redditch/Barmouth scenario, exact preview/Apply geometry, Cancel, one-step Undo/Redo, Save contract/reopen and unchanged manual behaviour.- Existing geography, Maps engine, settlement and drawing-order regressions cover compatibility.
--map-geography-hierarchy-database /tmp/pd-dev-browser-<fixture>/identity.json: verifies the effective Development database and disposable account, creates only its own unique project, tests complete transformed-map Save/reload and project backup/export/import/restore, then leaves that owned map at its original positions for browser acceptance.node PlotLine.Tests/Browser/maps-geography-hierarchy-development.cjs /tmp/pd-dev-browser-<fixture>/identity.json: authenticated Development verification using the real hierarchy API and real Map Save/reload. Coordinates are explicit fixture responses; the test makes no external geocoder requests and does not modify provider/cache/resolution data. Standard disposable identity cleanup removes the fixtures.
Tests never open the author's actual Birmingham map. Adding a distant place legitimately changes the projection scale; dependent objects preserve their requested local offsets rather than inventing physical distances or a new regional-map system.