fix(junction): bound complex cutback transitions
This commit is contained in:
1 parent
280b726c6f
commit
4e7274ec61
4 files changed
+23
-4
No files matched your search
@@ -110,7 +110,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
center,
|
||||
{
|
||||
outerRadiusFor: (item) => Math.max(coreRadius + 4, outerRadius - Math.max(0, Number(item.approach.cutback) || 0)),
|
||||
innerRadiusFor: () => coreRadius * 0.7,
|
||||
innerRadiusFor: () => complexJunctionMetrics(cluster).approachInnerRadius,
|
||||
},
|
||||
helpers,
|
||||
model.exclusionRegions || [],
|
||||
|
||||
@@ -344,9 +344,12 @@ function numericValue(constraint, key, fallback) {
|
||||
|
||||
function clusterCutbackMaximum(cluster, approachLength) {
|
||||
const metrics = complexJunctionMetrics(cluster);
|
||||
// The carriageway's outer edge may retreat only to the core safety envelope.
|
||||
// The other cap preserves a usable part of a short source approach.
|
||||
return Math.min(approachLength * 0.45, Math.max(1, metrics.approachOuterRadius - (metrics.coreRadius + 4)));
|
||||
// Keep a measurable local taper between the source-road outer section and
|
||||
// the inner core section. The other cap preserves a usable source approach.
|
||||
return Math.min(
|
||||
approachLength * 0.45,
|
||||
Math.max(1, metrics.approachOuterRadius - (metrics.approachInnerRadius + metrics.minimumTransitionMeters)),
|
||||
);
|
||||
}
|
||||
|
||||
function roadGroups(model) {
|
||||
|
||||
@@ -6,9 +6,16 @@ function complexJunctionMetrics(cluster, calibration = null) {
|
||||
const coreRadius = calibration
|
||||
? Math.max(12, Math.min(24, calibration.shortSpanMeters * 0.14))
|
||||
: Math.max(12, Math.min(80, Number(cluster.coreRadiusMeters) || 28));
|
||||
const approachInnerRadius = coreRadius * 0.7;
|
||||
// The local correction needs a real taper between the immutable source-road
|
||||
// section and the core. This is a geometric feasibility limit, not a UI-only
|
||||
// preference, so solver and compiler consumers derive it from one metric.
|
||||
const minimumTransitionMeters = Math.max(8, coreRadius * 0.5);
|
||||
return {
|
||||
calibration,
|
||||
coreRadius,
|
||||
approachInnerRadius,
|
||||
minimumTransitionMeters,
|
||||
approachOuterRadius: coreRadius + (Number(cluster.outerRadiusExtraMeters) || 18),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const assert = require('assert/strict');
|
||||
const { resolveDirectEditConstraints } = require('../src/compile/direct-edit-solver');
|
||||
const { complexJunctionMetrics } = require('../src/compile/junction-metrics');
|
||||
|
||||
const model = { roads: [], endpoints: [], connections: [], diagnostics: [] };
|
||||
|
||||
@@ -370,6 +371,14 @@ const clusterCutbackHandle = clusterHandleResolution.handles.handles.find(
|
||||
(handle) => handle.kind === 'cluster-carriageway-cutback',
|
||||
);
|
||||
assert.ok(clusterCutbackHandle, 'a cluster selection publishes its carriageway cutback handles');
|
||||
const clusterTransitionMetrics = complexJunctionMetrics({ id: 'cluster-1' });
|
||||
assert.ok(
|
||||
clusterTransitionMetrics.approachOuterRadius -
|
||||
clusterCutbackHandle.value.max -
|
||||
clusterTransitionMetrics.approachInnerRadius >=
|
||||
clusterTransitionMetrics.minimumTransitionMeters - 1e-9,
|
||||
'the cutback limit must retain the minimum transition between source and core sections',
|
||||
);
|
||||
const cutbackAtLimit = resolveDirectEditConstraints(
|
||||
junctionModel,
|
||||
document([
|
||||
|
||||
Reference in new issue
Block a user