feat: complete carriageway direction interaction

This commit is contained in:
que01 committed 2026-09-11 09:51:02 +08:00
1 parent a5089220b5
commit 067c0e370d
10 files changed
+251 -41

No files matched your search

+73
View File
@@ -530,6 +530,79 @@ const movedEdge = movedCluster.handles.handles.find(
);
assert.ok(haversineMeters(movedEdge.position, clusterWidthHandle.position) > clusterWidthHandle.value.current / 2);
assert.notEqual(movedEdge.axisAzimuth, clusterWidthHandle.axisAzimuth);
const movedPosition = movedCluster.handles.handles.find(
(handle) =>
handle.kind === 'cluster-carriageway-position' &&
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey,
);
const movedWidth = movedCluster.handles.handles.find(
(handle) =>
handle.kind === 'cluster-carriageway-width' &&
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey,
);
const movedDirection = movedCluster.handles.handles.find(
(handle) =>
handle.kind === 'cluster-carriageway-direction' &&
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey,
);
assert.deepEqual(
movedWidth.position,
movedPosition.position,
'width and position controls share the effective inner section',
);
assert.deepEqual(movedDirection.interaction.center, movedPosition.position);
assert.equal(movedDirection.interaction.kind, 'rotation');
assert.ok(
Math.abs(
haversineMeters(movedDirection.interaction.center, movedDirection.position) -
movedDirection.interaction.radiusMeters,
) < 0.02,
'direction control is a radial handle around the effective inner section',
);
const initialEdges = clusterHandleResolution.handles.handles.filter(
(handle) =>
handle.kind === 'cluster-carriageway-edge-offset' &&
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey,
);
for (const edge of initialEdges) {
for (const [suffix, value] of [
['min', edge.value.min],
['max', edge.value.max],
]) {
const result = resolveDirectEditConstraints(
junctionModel,
document([
constraint({
id: `edge-bound-${edge.anchor.side}-${suffix}`,
kind: edge.kind,
anchor: edge.anchor,
value:
edge.anchor.side === 'left'
? { leftOffsetMeters: value, rightOffsetMeters: 0 }
: { leftOffsetMeters: 0, rightOffsetMeters: value },
}),
]),
{ junctionClusters: [{ id: 'cluster-1', nodeIds: ['junction'] }] },
);
assert.equal(result.constraintStates[0].applied, true, `${edge.anchor.side} ${suffix} must be accepted`);
}
const pastMax = resolveDirectEditConstraints(
junctionModel,
document([
constraint({
kind: edge.kind,
anchor: edge.anchor,
value:
edge.anchor.side === 'left'
? { leftOffsetMeters: edge.value.max + 0.01, rightOffsetMeters: 0 }
: { leftOffsetMeters: 0, rightOffsetMeters: edge.value.max + 0.01 },
}),
]),
{ junctionClusters: [{ id: 'cluster-1', nodeIds: ['junction'] }] },
);
assert.equal(pastMax.constraintStates[0].applied, false, `${edge.anchor.side} beyond max must be rejected`);
}
const transitionedCluster = resolveDirectEditConstraints(
junctionModel,