fix(junction): keep complex carriageways connected
This commit is contained in:
1 parent
53a2cb3450
commit
855400fba2
3 files changed
+77
-6
No files matched your search
@@ -14,6 +14,7 @@ const {
|
||||
connectionConnectorId,
|
||||
} = require('./native-ids');
|
||||
const { topologyIdentity } = require('./junction-topology');
|
||||
const { complexJunctionMetrics } = require('./complex-junction');
|
||||
|
||||
const RESOLUTION_SCHEMA = 'road-edit-resolution/v1';
|
||||
const HANDLE_MANIFEST_SCHEMA = 'road-edit-handles/v1';
|
||||
@@ -300,6 +301,13 @@ function numericValue(constraint, key, fallback) {
|
||||
return Number.isFinite(value) ? value : 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)));
|
||||
}
|
||||
|
||||
function roadGroups(model) {
|
||||
const groups = new Map();
|
||||
for (const road of Array.isArray(model?.roads) ? model.roads : []) {
|
||||
@@ -841,6 +849,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
? constraint.value?.widthMeters
|
||||
: constraint.value?.cutbackMeters,
|
||||
);
|
||||
const cluster = clusters.find((candidate) => String(candidate.id) === String(item?.clusterId));
|
||||
const cutbackMax = cluster ? clusterCutbackMaximum(cluster, item?.approach.length || 0) : 0;
|
||||
if (!item) {
|
||||
blocking(diagnostics, constraint, 'direct-edit-cluster-carriageway-missing', '复杂路口车行道锚点不存在。');
|
||||
applied = false;
|
||||
@@ -849,7 +859,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
(constraint.kind === 'cluster-carriageway-width' &&
|
||||
(value < Math.max(MIN_LANE_WIDTH_METERS, item.laneCount * MIN_LANE_WIDTH_METERS) ||
|
||||
value > item.widthMeters * 2)) ||
|
||||
(constraint.kind === 'cluster-carriageway-cutback' && (value < 1 || value > item.approach.length * 0.45))
|
||||
(constraint.kind === 'cluster-carriageway-cutback' && (value < 1 || value > cutbackMax))
|
||||
) {
|
||||
blocking(
|
||||
diagnostics,
|
||||
@@ -1355,6 +1365,8 @@ function makeJunctionHandles(model, junctionData, constraints) {
|
||||
function makeClusterCarriagewayHandles(model, junctionData, constraints, clusters) {
|
||||
const handles = [];
|
||||
for (const [clusterId, items] of clusterCarriageways(model, junctionData, clusters)) {
|
||||
const cluster = clusters.find((item) => String(item.id) === String(clusterId));
|
||||
if (!cluster) continue;
|
||||
for (const item of items) {
|
||||
const road = item.roads[0];
|
||||
const line = item.approach.endpoint.side === 'start' ? road.centerline : [...road.centerline].reverse();
|
||||
@@ -1408,7 +1420,7 @@ function makeClusterCarriagewayHandles(model, junctionData, constraints, cluster
|
||||
value: {
|
||||
current: numericValue(cutbackConstraint, 'cutbackMeters', item.approach.cutback),
|
||||
min: 1,
|
||||
max: item.approach.length * 0.45,
|
||||
max: clusterCutbackMaximum(cluster, item.approach.length),
|
||||
unit: 'meter',
|
||||
},
|
||||
...(cutbackConstraint ? { constraintId: cutbackConstraint.id } : {}),
|
||||
|
||||
Reference in new issue
Block a user