fix: close divided two-node T junction pavement

This commit is contained in:
que01 committed 2026-09-15 09:54:46 +08:00
1 parent fda733ce72
commit f122e8236a
3 files changed
+49 -5

No files matched your search

+18 -2
View File
@@ -259,8 +259,24 @@ function buildCoreClosure(topology, graph, center) {
const coreSections = graph.sections.filter((section) => section.ringStatus === 'supported');
if (topology.arms.length < 3 || topology.arms.length > 6)
return { status: 'unsupported', reason: 'unsupported-arm-count' };
if (topology.arms.length === 3 && topology.arms.some((arm) => arm.members.length !== 1))
return { status: 'unsupported', reason: 'parallel-carriageway-closure-unresolved' };
if (topology.arms.length === 3 && topology.arms.some((arm) => arm.members.length !== 1)) {
// A short source link between clustered junction nodes can split one
// physical T arm into parallel carriageways while still describing one
// continuous paved core. Keep rejecting arbitrary divided T junctions;
// only a configured cluster with a link that fits inside its core may use
// the constrained entry-cell union below.
const coreRadius = Number(topology.cluster?.coreRadiusMeters);
const shortInternalLink =
Number.isFinite(coreRadius) &&
topology.internalRoadIds?.length > 0 &&
topology.internalLinkLengths?.some((length) => length <= coreRadius * 2) &&
topology.arms.some(
(arm) =>
arm.members.length > 1 &&
arm.members.every((member) => Number.isFinite(member.length) && member.length > coreRadius * 2),
);
if (!shortInternalLink) return { status: 'unsupported', reason: 'parallel-carriageway-closure-unresolved' };
}
// Sort whole entry edges, never their individual endpoints. Each valid
// carriageway contributes its full inner seam, including divided arms.
const angle = (point) => Math.atan2(point[1] - center[1], point[0] - center[0]);