feat(junction): taper complex carriageway edits

This commit is contained in:
que01 committed 2026-09-09 10:24:57 +08:00
1 parent d353b48a0b
commit 280b726c6f
4 files changed
+31 -6

No files matched your search

+4 -1
View File
@@ -507,8 +507,11 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
0,
),
width_m: item.approach.widthMeters,
outer_width_m: section.outerWidthMeters,
inner_width_m: section.innerWidthMeters,
transition_length_m: Math.round((section.outer.stationMeters - section.inner.stationMeters) * 10) / 10,
boundary_refs: section.edgeRefs,
provenance: 'native-road-complex-junction/v5',
provenance: 'native-road-complex-junction/v6-shared-transition-sections',
},
geometry: { type: 'Polygon', coordinates: [ring] },
});
+8 -4
View File
@@ -39,11 +39,11 @@ function offsetCoordinate(point, heading, meters) {
];
}
function sectionAt(item, radius, center, helpers) {
function sectionAt(item, radius, center, widthMeters, helpers) {
const station = Math.min(item.length, stationAtDistanceFrom(item.approach.line, center, radius, helpers));
const point = pointAtStation(item.approach.line, station, helpers);
const tangent = tangentAtStation(item.approach.line, station, helpers);
const halfWidth = Math.max(0, Number(item.approach.widthMeters) || 0) / 2;
const halfWidth = Math.max(0, Number(widthMeters) || 0) / 2;
return {
stationMeters: station,
point,
@@ -60,13 +60,17 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionR
const sections = topology.carriageways.map((item) => {
const outerRadius = radii.outerRadiusFor(item);
const innerRadius = radii.innerRadiusFor(item);
const outer = sectionAt(item, outerRadius, center, helpers);
const inner = sectionAt(item, innerRadius, center, helpers);
const outerWidthMeters = Number(item.approach.sourceWidthMeters) || item.approach.widthMeters;
const innerWidthMeters = item.approach.widthMeters;
const outer = sectionAt(item, outerRadius, center, outerWidthMeters, helpers);
const inner = sectionAt(item, innerRadius, center, innerWidthMeters, helpers);
const key = `boundary:${item.key}`;
return {
key,
carriagewayKey: item.key,
armKey: item.armKey,
outerWidthMeters,
innerWidthMeters,
outer,
inner,
edgeRefs: {
+7 -1
View File
@@ -988,7 +988,13 @@ function applyDirectClusterPlans(model, junctionPlans, directEdit, clusters) {
});
for (const item of topology.carriageways) {
const width = widths.get(item.key);
if (Number.isFinite(width)) item.approach.widthMeters = width;
if (Number.isFinite(width)) {
// The outer section stays attached to the untouched source road. The
// complex approach then tapers from that fixed width to this local
// correction instead of opening a seam at the cluster boundary.
item.approach.sourceWidthMeters ??= item.approach.widthMeters;
item.approach.widthMeters = width;
}
const cutback = cutbacks.get(item.key);
if (Number.isFinite(cutback)) item.approach.cutback = cutback;
}
+12
View File
@@ -328,6 +328,18 @@ assert.notDeepEqual(
complexSurface(clusterPreview).geometry,
'a cluster carriageway constraint must change compiled complex geometry',
);
const baselineApproachRing = complexSurface(clusterPreview).geometry.coordinates[0];
const widenedApproachRing = complexSurface(widenedClusterPreview).geometry.coordinates[0];
assert.deepEqual(
[widenedApproachRing[0], widenedApproachRing[3]],
[baselineApproachRing[0], baselineApproachRing[3]],
'a local width correction must preserve the source-road outer seam',
);
assert.notDeepEqual(
[widenedApproachRing[1], widenedApproachRing[2]],
[baselineApproachRing[1], baselineApproachRing[2]],
'a local width correction must taper into the edited inner section',
);
const complexCrossingHandle = clusterState.handles.handles.find((handle) => handle.kind === 'cluster-crossing-inset');
assert.ok(complexCrossingHandle, 'the complex fixture must publish grouped crossing handles');
const renderedComplexCrosswalk = clusterPreview.layers.crosswalks.features.find(