diff --git a/src/compile/direct-edit-solver.js b/src/compile/direct-edit-solver.js index bb93eed..16303d9 100644 --- a/src/compile/direct-edit-solver.js +++ b/src/compile/direct-edit-solver.js @@ -174,7 +174,7 @@ function constraintFor(constraints, kind, anchor) { item.anchor.clusterId === anchor.clusterId && item.anchor.carriagewayKey === anchor.carriagewayKey ); - if (kind === 'cluster-carriageway-cutback') + if (kind === 'cluster-carriageway-transition-length' || kind === 'cluster-carriageway-cutback') return ( item.anchor.type === 'cluster-carriageway' && item.anchor.clusterId === anchor.clusterId && @@ -1456,6 +1456,39 @@ function makeClusterCarriagewayHandles(model, junctionData, constraints, cluster affects: [`complex-junction:${clusterId}:carriageway:${item.approach.segmentId}`], editable: true, }); + const transitionConstraint = constraintFor(constraints, 'cluster-carriageway-transition-length', { + clusterId, + carriagewayKey: item.key, + }); + handles.push({ + handleId: `handle:cluster-carriageway-transition-length:${item.key}`, + kind: 'cluster-carriageway-transition-length', + anchor: { + type: 'cluster-carriageway', + clusterId, + carriagewayKey: item.key, + sourceNodeIds: item.sourceNodeIds, + sourceRoadIds: item.sourceRoadIds, + }, + position: point, + axisAzimuth: tangentAzimuth(line, station), + value: { + current: numericValue( + transitionConstraint, + 'transitionLengthMeters', + Math.max(0, item.approach.length - item.approach.cutback), + ), + min: complexJunctionMetrics(cluster).minimumTransitionMeters, + max: Math.max( + complexJunctionMetrics(cluster).minimumTransitionMeters, + complexJunctionMetrics(cluster).approachOuterRadius - complexJunctionMetrics(cluster).approachInnerRadius, + ), + unit: 'meter', + }, + ...(transitionConstraint ? { constraintId: transitionConstraint.id } : {}), + affects: [`complex-junction:${clusterId}:carriageway:${item.approach.segmentId}`], + editable: true, + }); const cutbackConstraint = constraintFor(constraints, 'cluster-carriageway-cutback', { clusterId, carriagewayKey: item.key,