fix: align carriageway edge handles with entry geometry
This commit is contained in:
1 parent
44fa82299b
commit
a5089220b5
5 files changed
+157
-3
No files matched your search
@@ -3,6 +3,7 @@
|
||||
const assert = require('assert/strict');
|
||||
const { resolveDirectEditConstraints } = require('../src/compile/direct-edit-solver');
|
||||
const { complexJunctionMetrics } = require('../src/compile/junction-metrics');
|
||||
const { haversineMeters } = require('../src/geometry/lane-geometry');
|
||||
|
||||
const model = { roads: [], endpoints: [], connections: [], diagnostics: [] };
|
||||
|
||||
@@ -371,6 +372,10 @@ const clusterCutbackHandle = clusterHandleResolution.handles.handles.find(
|
||||
(handle) => handle.kind === 'cluster-carriageway-cutback',
|
||||
);
|
||||
assert.ok(clusterCutbackHandle, 'a cluster selection publishes its carriageway cutback handles');
|
||||
const clusterTransitionHandle = clusterHandleResolution.handles.handles.find(
|
||||
(handle) => handle.kind === 'cluster-carriageway-transition-length',
|
||||
);
|
||||
assert.ok(clusterTransitionHandle, 'a cluster selection publishes its carriageway transition handles');
|
||||
const clusterTransitionMetrics = complexJunctionMetrics({ id: 'cluster-1' });
|
||||
assert.ok(
|
||||
clusterTransitionMetrics.approachOuterRadius -
|
||||
@@ -472,6 +477,7 @@ for (const sides of [
|
||||
leftOffsetMeters: 0.4,
|
||||
rightOffsetMeters: 0.7,
|
||||
});
|
||||
const edgePositions = {};
|
||||
for (const side of sides) {
|
||||
const handle = result.handles.handles.find(
|
||||
(handle) =>
|
||||
@@ -481,7 +487,76 @@ for (const sides of [
|
||||
);
|
||||
assert.equal(handle.constraintId, `edge-${side}`);
|
||||
assert.equal(handle.value.current, side === 'left' ? 0.4 : 0.7);
|
||||
edgePositions[side] = handle.position;
|
||||
assert.equal(
|
||||
handle.axisAzimuth,
|
||||
clusterWidthHandle.axisAzimuth,
|
||||
'both edge handles publish the rightward normal; the client reverses the left side once',
|
||||
);
|
||||
}
|
||||
assert.ok(
|
||||
haversineMeters(edgePositions.left, edgePositions.right) > clusterWidthHandle.value.current,
|
||||
'independent edge handles must be placed on opposite sides of the effective entry section',
|
||||
);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
haversineMeters(edgePositions.left, edgePositions.right) - (clusterWidthHandle.value.current + 0.4 + 0.7),
|
||||
) < 0.02,
|
||||
'edge handle separation must equal the effective width plus both independent edge offsets',
|
||||
);
|
||||
}
|
||||
|
||||
const movedCluster = resolveDirectEditConstraints(
|
||||
junctionModel,
|
||||
document([
|
||||
constraint({
|
||||
kind: 'cluster-carriageway-position',
|
||||
anchor: clusterWidthHandle.anchor,
|
||||
value: { offsetMeters: 1 },
|
||||
}),
|
||||
constraint({
|
||||
kind: 'cluster-carriageway-direction',
|
||||
anchor: clusterWidthHandle.anchor,
|
||||
value: { offsetDegrees: 5 },
|
||||
}),
|
||||
]),
|
||||
{ junctionClusters: [{ id: 'cluster-1', nodeIds: ['junction'] }] },
|
||||
);
|
||||
const movedEdge = movedCluster.handles.handles.find(
|
||||
(handle) =>
|
||||
handle.kind === 'cluster-carriageway-edge-offset' &&
|
||||
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey &&
|
||||
handle.anchor.side === 'right',
|
||||
);
|
||||
assert.ok(haversineMeters(movedEdge.position, clusterWidthHandle.position) > clusterWidthHandle.value.current / 2);
|
||||
assert.notEqual(movedEdge.axisAzimuth, clusterWidthHandle.axisAzimuth);
|
||||
|
||||
const transitionedCluster = resolveDirectEditConstraints(
|
||||
junctionModel,
|
||||
document([
|
||||
constraint({
|
||||
kind: 'cluster-carriageway-transition-length',
|
||||
anchor: clusterWidthHandle.anchor,
|
||||
value: { transitionLengthMeters: clusterTransitionHandle.value.min },
|
||||
}),
|
||||
]),
|
||||
{ junctionClusters: [{ id: 'cluster-1', nodeIds: ['junction'] }] },
|
||||
);
|
||||
const transitionedHandle = transitionedCluster.handles.handles.find(
|
||||
(handle) =>
|
||||
handle.kind === 'cluster-carriageway-transition-length' &&
|
||||
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey,
|
||||
);
|
||||
const transitionedEdges = transitionedCluster.handles.handles.filter(
|
||||
(handle) =>
|
||||
handle.kind === 'cluster-carriageway-edge-offset' &&
|
||||
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey,
|
||||
);
|
||||
for (const edge of transitionedEdges) {
|
||||
assert.ok(
|
||||
Math.abs(haversineMeters(edge.position, transitionedHandle.position) - clusterWidthHandle.value.current / 2) < 0.02,
|
||||
'edge handles must use the same effective inner station as the transition handle',
|
||||
);
|
||||
}
|
||||
const recheckResolution = resolveDirectEditConstraints(
|
||||
junctionModel,
|
||||
|
||||
Reference in new issue
Block a user