feat(junction): close verified complex cores

This commit is contained in:
que01 committed 2026-09-09 09:15:58 +08:00
1 parent b4abfdb870
commit 88d8b841e5
5 files changed
+97 -25

No files matched your search

+8 -21
View File
@@ -3,7 +3,7 @@
const fs = require('fs');
const { structureFromTopology } = require('./junction-topology');
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan');
const { buildJunctionBoundaryGraph } = require('./junction-boundary-graph');
const { buildJunctionBoundaryGraph, buildCoreClosure } = require('./junction-boundary-graph');
const { convertGeoJson, boundsOf } = require('../reference/gaode');
const metricsCache = new WeakMap();
const CORNER_FILLET_SEGMENTS = 12;
@@ -485,22 +485,8 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
geometry: { type: 'Polygon', coordinates: [sidewalkRing] },
});
}
// Build the conflict area from one envelope per effective arm. Using every
// carriageway here duplicates same-direction lanes and can create a warped
// or self-crossing core for 2x1/T-shaped junctions.
const corePoints = arms
.flatMap((arm) => {
const envelope = armEnvelopeAtRadius(arm, coreRadius * 0.7, center, helpers);
if (!envelope) return [];
const half = envelope.widthMeters / 2;
return [
helpers.offsetCoordinate(envelope.center, arm.heading + 90, half),
helpers.offsetCoordinate(envelope.center, arm.heading - 90, half),
];
})
.sort((first, second) => angleAround(center, first) - angleAround(center, second));
const coreValid = corePoints.length >= 6 && !ringSelfIntersects([...corePoints, corePoints[0]]);
const coreRing = coreValid ? roundedPolygonRing(corePoints, 0.16) : null;
const coreClosure = buildCoreClosure(topology, boundaryGraph, center);
const coreRing = coreClosure.status === 'supported' ? coreClosure.ring : null;
const features = [];
if (coreRing)
features.push({
@@ -520,8 +506,9 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
arm_count: arms.length,
through_pair_count: shape.throughPairCount,
approach_headings: sorted.map((item) => Math.round(item.heading * 10) / 10),
corner_rounding_ratio: 0.16,
provenance: 'native-road-complex-junction/v6-rounded-core',
boundary_refs: coreClosure.sharedEdgeRefs,
closure_count: coreClosure.closureCount,
provenance: 'native-road-complex-junction/v7-shared-entry-core',
},
geometry: { type: 'Polygon', coordinates: [coreRing] },
});
@@ -531,8 +518,8 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
'warning',
`junction-cluster:${cluster.id}`,
[...nodeIds],
'complex-junction-core-fallback',
'路口中心区域几何不可靠,已跳过复杂中心面并保留各进口道路面。',
'complex-junction-core-closure-unsupported',
`路口中心区域缺少可验证的闭合边(${coreClosure.reason}),已保留各进口道路面。`,
center,
),
);