feat: drag road handles with ghost and server preview
Three things, kept in one commit because they touch overlapping hunks of the same two files and this environment has no interactive hunk staging. Splitting them by file would have drawn boundaries that misrepresent what changed. 1. Step 4 of the map editor. A native OpenLayers PointerInteraction turns a drag into a clamped constraint value, the ghost source shows it immediately, and the solver's answer replaces a parallel set of preview layers while the baseline layers are hidden rather than overwritten. Preview requests debounce at 80 ms, pointerup flushes without waiting, and a newer request aborts the one in flight; EditSession decides which answers count. Handle positions come from the clamped value, so a handle stops at its limit instead of following the cursor. Three of the four drag capabilities are live: edge offset, sidewalk width, lane divider. 2. Road edge handles were drawn on the wrong side. offsetLine() offsets counter-clockwise from the direction of travel and sidewalks use `heading + (side === 'left' ? -90 : 90)`, so left is `tangent - 90`; makeRoadHandles() placed the left handle at `tangent + 90`, over the right kerb. Dragging the visually-left handle moved the right edge. Fixed on both sides of the wire, with regression tests that name the sides geographically rather than by axis sign. 3. Roads the junctions geometrically fill are now read-only. The 0.45 cap per reserve made the existing `unavailable` branch unreachable, so a 14.5 m stub between two junctions was offered a 1.5 m editable band with no room for the transitions a road-interval constraint needs. Greying only affects the manifest: constraints already saved against such a road keep being solved, so the geometry output is unchanged and the fixture baselines do not move. Range handles are built and unit-tested but hidden behind `intervalEditingSupported`: compileGeometry() reads neither profile.interval nor profile.transitions, so every edit applies to the whole road and the control would have had no effect. Recorded in research/interval-not-applied.md, which also blocks one PRD acceptance criterion. The ol-ext probe stays in the tree as a manual harness; ol-ext is still not a dependency. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -482,11 +482,25 @@ function makeRoadHandles(model, groups, reserves, constraints) {
|
||||
const unavailable = start >= end;
|
||||
const width = roads.reduce((sum, item) => sum + (Number(item.widthMeters) || 0), 0);
|
||||
const laneCount = roads.reduce((sum, item) => sum + (Number(item.laneCount) || 0), 0);
|
||||
// `junctionReserves()` caps each end's reserve at 0.45, so `unavailable`
|
||||
// alone can never fire — it would need start >= end, i.e. 0.45 >= 0.55. On a
|
||||
// road the junctions geometrically fill, that cap invents an editable band in
|
||||
// the middle (1.5 m on a 14.5 m road) with no room for the smoothstep
|
||||
// transitions a road-interval constraint needs at both ends.
|
||||
//
|
||||
// Compare in meters rather than stations: a transition needs real distance,
|
||||
// and a band shorter than the road is wide cannot carry a cross-section
|
||||
// change. This only marks handles read-only; existing constraints on such a
|
||||
// road keep being solved, so a compiler upgrade never silently drops a saved
|
||||
// edit and the geometry output is unchanged.
|
||||
const bandMeters = Math.max(0, end - start) * length;
|
||||
const junctionDominated = bandMeters < width;
|
||||
const point = coordinateAt(road.centerline, station);
|
||||
const tangent = tangentAzimuth(road.centerline, station);
|
||||
const normal = (tangent + 90) % 360;
|
||||
const interval = { type: 'road-interval', roadId: road.id, startStation: start, endStation: end };
|
||||
const baseDisabled = unavailable ? '该道路全部位于路口保留区,请进入 JunctionTools 编辑。' : undefined;
|
||||
const baseDisabled =
|
||||
unavailable || junctionDominated ? '该道路全部位于路口保留区,请进入 JunctionTools 编辑。' : undefined;
|
||||
const add = (kind, anchor, value, min, max, axis, position, affects, constraint) => {
|
||||
const disabledReason = baseDisabled;
|
||||
handles.push({
|
||||
@@ -503,7 +517,12 @@ function makeRoadHandles(model, groups, reserves, constraints) {
|
||||
});
|
||||
};
|
||||
for (const side of ['left', 'right']) {
|
||||
const sideSign = side === 'left' ? 1 : -1;
|
||||
// Left is `tangent - 90`, matching the geometry compiler: `offsetLine()`
|
||||
// shifts a positive offset counter-clockwise from the direction of travel,
|
||||
// and sidewalks use `heading + (side === 'left' ? -90 : 90)`. Placing the
|
||||
// left handle at `tangent + 90` drew it over the right kerb, so dragging the
|
||||
// visually-left handle moved the right edge.
|
||||
const sideSign = side === 'left' ? -1 : 1;
|
||||
const edgeAnchor = { ...interval, side };
|
||||
const edgeConstraint = constraintFor(constraints, 'road-edge-offset', edgeAnchor);
|
||||
add(
|
||||
|
||||
Reference in New Issue
Block a user