fix: suppress orphaned complex junction attachments
This commit is contained in:
1 parent
cd65dbe879
commit
79f2ee5d4e
3 files changed
+179
-37
No files matched your search
@@ -11,11 +11,6 @@ const CORNER_FILLET_SEGMENTS = 12;
|
||||
// Must match DEFAULT_SIDEWALK_WIDTH_METERS in native-road.js so the corner band
|
||||
// lines up with the straight strips it joins.
|
||||
const SIDEWALK_WIDTH_METERS = 2;
|
||||
// The straight strips are trimmed against the cluster boundary using the road
|
||||
// centerline, so they stop a little beyond the carriageway end. Run the corner
|
||||
// past that end and let the two overlap rather than chase an exact seam.
|
||||
const SIDEWALK_CORNER_OVERRUN_METERS = 6;
|
||||
|
||||
// Compatibility export for current compiler consumers. The build-plan module is
|
||||
// pure and is the shared authority for geometry and direct-edit identity.
|
||||
const resolveComplexJunctionTopology = resolveJunctionBuildPlan;
|
||||
@@ -426,26 +421,24 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
// The corner faces clockwise from `first` and counter-clockwise from
|
||||
// `second`, so each arm must carry the footway on that facing side.
|
||||
if (!armCarriesSidewalk(first, model, true) || !armCarriesSidewalk(second, model, false)) continue;
|
||||
const curb = [
|
||||
...edgeRunToRadius(
|
||||
apex,
|
||||
edges[0],
|
||||
tangentDistance,
|
||||
outerRadius + SIDEWALK_CORNER_OVERRUN_METERS,
|
||||
center,
|
||||
helpers,
|
||||
).reverse(),
|
||||
...curve.slice(1, -1),
|
||||
...edgeRunToRadius(
|
||||
apex,
|
||||
edges[1],
|
||||
tangentDistance,
|
||||
outerRadius + SIDEWALK_CORNER_OVERRUN_METERS,
|
||||
center,
|
||||
helpers,
|
||||
),
|
||||
];
|
||||
const seams = edges.map((edge) => exteriorSidewalkSeam(edge, boundaryGraph, helpers));
|
||||
if (!seams.every(Boolean)) {
|
||||
cornerDiagnostics.push(
|
||||
helpers.diagnostic(
|
||||
'warning',
|
||||
`corner:${first.cornerKey}`,
|
||||
edges.flatMap((edge) => edge.roadIds),
|
||||
'complex-junction-sidewalk-seam-unavailable',
|
||||
'该角部缺少两侧可验证的人行道接缝,已省略连接,避免生成悬空步行带。',
|
||||
center,
|
||||
),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const curb = [seams[0].curb, ...curve, seams[1].curb];
|
||||
const outerEdge = offsetPolylineAwayFromCenter(curb, center, SIDEWALK_WIDTH_METERS, helpers);
|
||||
outerEdge[0] = seams[0].outer;
|
||||
outerEdge[outerEdge.length - 1] = seams[1].outer;
|
||||
const sidewalkRing = [...curb, ...outerEdge.slice().reverse(), curb[0]];
|
||||
if (!sidewalkRing.every((point) => point.every(Number.isFinite)) || ringSelfIntersects(sidewalkRing)) {
|
||||
cornerDiagnostics.push(
|
||||
@@ -473,7 +466,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
to_heading: second.heading,
|
||||
bisector_heading: bisector,
|
||||
width_m: SIDEWALK_WIDTH_METERS,
|
||||
overrun_m: SIDEWALK_CORNER_OVERRUN_METERS,
|
||||
seam_source: 'published-exterior-sidewalk',
|
||||
provenance: 'native-road-complex-junction-sidewalk-corner/v1',
|
||||
},
|
||||
geometry: { type: 'Polygon', coordinates: [sidewalkRing] },
|
||||
@@ -729,16 +722,31 @@ function armCarriesSidewalk(arm, model, cornerIsClockwise) {
|
||||
);
|
||||
}
|
||||
|
||||
// Walk outward along a wedge edge from its tangent point until the curb reaches
|
||||
// `targetRadius`, so the corner band overlaps the straight strip it joins.
|
||||
function edgeRunToRadius(apex, edge, tangentDistance, targetRadius, center, helpers) {
|
||||
const points = [];
|
||||
for (let extra = 0; extra <= 40; extra += 2) {
|
||||
const point = helpers.offsetCoordinate(apex, edge.heading, tangentDistance + extra);
|
||||
points.push(point);
|
||||
if (helpers.distanceMeters(point, center) >= targetRadius) break;
|
||||
// Use the emitted strip's complete end edge, including its actual width and
|
||||
// orientation. A radius extension cannot guarantee this seam on curved roads.
|
||||
function exteriorSidewalkSeam(edge, graph, helpers) {
|
||||
const section = graph.sections.find((item) => item.carriagewayKey === edge.carriagewayKey);
|
||||
if (
|
||||
!section ||
|
||||
section.ringStatus !== 'supported' ||
|
||||
section.transitionStatus !== 'supported' ||
|
||||
section.exclusionStatus !== 'clear'
|
||||
)
|
||||
return null;
|
||||
const target = edge.side === 90 ? section.outer.right : section.outer.left;
|
||||
for (const feature of helpers.exteriorSidewalks || []) {
|
||||
const ids = String(feature.properties.directional_road_ids || '').split(',');
|
||||
if (!edge.roadIds.some((id) => ids.includes(String(id)))) continue;
|
||||
const ring = feature.geometry.coordinates[0];
|
||||
const half = (ring.length - 1) / 2;
|
||||
for (const [curb, outer] of [
|
||||
[ring[0], ring[ring.length - 2]],
|
||||
[ring[half - 1], ring[half]],
|
||||
]) {
|
||||
if (helpers.distanceMeters(curb, target) <= 0.01) return { curb, outer };
|
||||
}
|
||||
}
|
||||
return points;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Offset each vertex along the polyline normal that increases distance from the
|
||||
@@ -858,6 +866,9 @@ function cornerEdgeAt(arm, radius, bisector, center, helpers) {
|
||||
return [90, -90].map((side) => ({
|
||||
point: helpers.offsetCoordinate(point, member.heading + side, halfWidth),
|
||||
heading: member.heading,
|
||||
carriagewayKey: member.key,
|
||||
roadIds: member.approach.roadIds,
|
||||
side,
|
||||
}));
|
||||
});
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user