From f722cadf2510662676837835dbd68965421db7b9 Mon Sep 17 00:00:00 2001 From: que01 Date: Thu, 10 Sep 2026 13:56:12 +0800 Subject: [PATCH] feat: publish independent carriageway edge handles --- src/compile/direct-edit-solver.js | 25 +++++++++++++++++++++++++ workbench/client/src/edit/projection.ts | 4 +++- workbench/client/src/edit/types.ts | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/compile/direct-edit-solver.js b/src/compile/direct-edit-solver.js index 664d147..1ab0eba 100644 --- a/src/compile/direct-edit-solver.js +++ b/src/compile/direct-edit-solver.js @@ -1621,6 +1621,31 @@ function makeClusterCarriagewayHandles(model, junctionData, constraints, cluster editable: true, }); } + const edgeConstraint = constraintFor(constraints, 'cluster-carriageway-edge-offset', { + clusterId, + carriagewayKey: item.key, + }); + const edgeValue = edgeConstraint?.value || {}; + for (const side of ['left', 'right']) { + handles.push({ + handleId: `handle:cluster-carriageway-edge-offset:${side}:${item.key}`, + kind: 'cluster-carriageway-edge-offset', + anchor: { + type: 'cluster-carriageway', + clusterId, + carriagewayKey: item.key, + side, + sourceNodeIds: item.sourceNodeIds, + sourceRoadIds: item.sourceRoadIds, + }, + position: point, + axisAzimuth: (tangentAzimuth(line, station) + (side === 'left' ? 270 : 90)) % 360, + value: { current: Number(edgeValue[`${side}OffsetMeters`]) || 0, min: -10, max: 10, unit: 'meter' }, + ...(edgeConstraint ? { constraintId: edgeConstraint.id } : {}), + affects: [`complex-junction:${clusterId}:carriageway:${item.approach.segmentId}`], + editable: true, + }); + } } } return handles; diff --git a/workbench/client/src/edit/projection.ts b/workbench/client/src/edit/projection.ts index 8089b5a..d941a7f 100644 --- a/workbench/client/src/edit/projection.ts +++ b/workbench/client/src/edit/projection.ts @@ -113,7 +113,9 @@ export function constraintValueFor( case 'cluster-carriageway-direction': return { offsetDegrees: scalar }; case 'cluster-carriageway-edge-offset': - return { leftOffsetMeters: scalar, rightOffsetMeters: 0 }; + return handle.anchor.type === 'cluster-carriageway' && handle.anchor.side === 'right' + ? { leftOffsetMeters: 0, rightOffsetMeters: scalar } + : { leftOffsetMeters: scalar, rightOffsetMeters: 0 }; case 'cluster-corner-radius': return { radiusMeters: Math.max(0, scalar) }; case 'junction-cutback': diff --git a/workbench/client/src/edit/types.ts b/workbench/client/src/edit/types.ts index c982d95..1796e0b 100644 --- a/workbench/client/src/edit/types.ts +++ b/workbench/client/src/edit/types.ts @@ -79,6 +79,7 @@ export type SemanticAnchor = carriagewayKey: string; sourceNodeIds: string[]; sourceRoadIds: string[]; + side?: Side; } | { type: 'junction-crossing'; crossingId: string; nodeId: string; segmentId: string; roadId: string } | { type: 'junction-corner'; nodeId: string; incomingRoadId: string; outgoingRoadId: string };