PlotDirector/Docs/Maps/SettlementAreas.md

3.3 KiB

Settlement areas and geographical containment

Capital, City, Town, Village, Hamlet and Settlement remain Marker features with their existing FeatureID, LocationID and X/Y anchor. New pieces receive an editable boundary. Older records stay visually unchanged until the author selects Convert to area; conversion is undoable and preserves road references.

Select a settlement to choose Move settlement, Edit boundary or Move anchor. Whole movement translates anchor and outline; boundary movement, resizing, rotation and control-point edits leave the anchor fixed; independent anchor movement leaves the outline fixed. Roads continue following the original anchor. Buildings never follow an enclosing boundary automatically. Shape controls reuse the area editor, including adding points and removing a focused point with Delete or its context menu. Smoothing leaves original control points intact. Appearance controls override theme defaults; locks protect boundary and anchor edits.

Geographical containment lists all containing areas and enclosed pieces, including overlaps and nesting. It uses each placed piece's anchor and the rendered outline, including its smoothing, rather than distance from the centre. These associations are derived and never change story Location parents. Containment is invalidated on edits and calculated lazily after editing, with spatial buckets for contents queries; it is not recalculated during each pointer movement.

Fit boundary to contents uses geometrically enclosed pieces and pieces linked to descendant story Locations, excludes paths, and adds a margin. It preserves the anchor and all independent piece coordinates. It is explicit and undoable; with no suitable contents it is disabled.

Storage and compatibility

No schema migration is required. Optional GeometryJson.boundary holds offsetX/offsetY relative to the anchor, width/height, rotation, normalized polygon points, coast smoothing and optional appearance (fillColor/fillOpacity/borderColor/borderWidth/borderStyle). It has no identity or connection target of its own. Existing feature save procedures, project backup/restore and JSON import/export carry this geometry. Server validation rejects invalid dimensions, points, smoothing and styles. Canvas units do not imply physical distance.

Containment samples the same cubic outline used for display (eight samples per segment); points extremely close to a curved edge have the normal approximation tolerance. There is no zoom-dependent representation engine. Existing point markers remain supported indefinitely.

Verification

  • dotnet build PlotLine.slnx
  • dotnet run --project PlotLine.Tests/PlotLine.Tests.csproj
  • node PlotLine.Tests/Browser/maps-settlements-engine.cjs
  • PD_MAPS_TEST_URL=http://127.0.0.1:5238 node PlotLine.Tests/Browser/maps-settlements.cjs with the toolbar browser host running.
  • Explicit isolated Development persistence/restore: --map-settlements-database /tmp/pd-dev-browser-<fixture>/identity.json using a dedicated disposable identity.
  • Authenticated Development browser: node PlotLine.Tests/Browser/maps-settlements-development.cjs /tmp/pd-dev-browser-<fixture>/identity.json.

The database test creates and restores only its own uniquely named fixture project. Browser tests use fixtures or the dedicated disposable account; they never open the author's Birmingham map.