From c77308c17017b8b7e95b37e1afd66d85a8000670 Mon Sep 17 00:00:00 2001 From: que01 Date: Thu, 10 Sep 2026 13:46:05 +0800 Subject: [PATCH] feat: publish complex carriageway position handles --- src/compile/direct-edit-solver.js | 31 +++++++++++++++++++++++++++++- workbench/client/src/edit/types.ts | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/compile/direct-edit-solver.js b/src/compile/direct-edit-solver.js index a03a6b0..664d147 100644 --- a/src/compile/direct-edit-solver.js +++ b/src/compile/direct-edit-solver.js @@ -180,7 +180,13 @@ function constraintFor(constraints, kind, anchor) { item.anchor.clusterId === anchor.clusterId && item.anchor.carriagewayKey === anchor.carriagewayKey ); - if (kind === 'cluster-carriageway-transition-length' || kind === 'cluster-carriageway-cutback') + if ( + kind === 'cluster-carriageway-transition-length' || + kind === 'cluster-carriageway-cutback' || + kind === 'cluster-carriageway-position' || + kind === 'cluster-carriageway-direction' || + kind === 'cluster-carriageway-edge-offset' + ) return ( item.anchor.type === 'cluster-carriageway' && item.anchor.clusterId === anchor.clusterId && @@ -1592,6 +1598,29 @@ function makeClusterCarriagewayHandles(model, junctionData, constraints, cluster affects: [`complex-junction:${clusterId}:carriageway:${item.approach.segmentId}`], editable: true, }); + for (const [kind, field, unit, min, max] of [ + ['cluster-carriageway-position', 'offsetMeters', 'meter', -20, 20], + ['cluster-carriageway-direction', 'offsetDegrees', 'degree', -15, 15], + ]) { + const edit = constraintFor(constraints, kind, { clusterId, carriagewayKey: item.key }); + handles.push({ + handleId: `handle:${kind}:${item.key}`, + kind, + anchor: { + type: 'cluster-carriageway', + clusterId, + carriagewayKey: item.key, + sourceNodeIds: item.sourceNodeIds, + sourceRoadIds: item.sourceRoadIds, + }, + position: point, + axisAzimuth: tangentAzimuth(line, station), + value: { current: numericValue(edit, field, 0), min, max, unit }, + ...(edit ? { constraintId: edit.id } : {}), + affects: [`complex-junction:${clusterId}:carriageway:${item.approach.segmentId}`], + editable: true, + }); + } } } return handles; diff --git a/workbench/client/src/edit/types.ts b/workbench/client/src/edit/types.ts index e73fc0b..c982d95 100644 --- a/workbench/client/src/edit/types.ts +++ b/workbench/client/src/edit/types.ts @@ -93,7 +93,7 @@ export interface EditHandle { position: [number, number]; /** Draggable direction, degrees clockwise from true north. */ axisAzimuth: number; - value: { current: number; min: number; max: number; unit: 'meter' }; + value: { current: number; min: number; max: number; unit: 'meter' | 'degree' }; constraintId?: string; /** `native_id` of every derived feature this handle changes. */ affects: string[];