feat: establish junction region geometry baseline

This commit is contained in:
que01 committed 2026-09-11 15:27:53 +08:00
1 parent de97600fe8
commit 76f81d024a
14 files changed
+287 -11

No files matched your search

+39 -9
View File
@@ -4,6 +4,7 @@ const fs = require('fs');
const { structureFromTopology } = require('./junction-topology');
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan');
const { buildJunctionBoundaryGraph, buildCoreClosure, ringsOverlap } = require('./junction-boundary-graph');
const { solveCornerFeasibleRegion } = require('./junction-region-solver');
const { complexJunctionMetrics: calculateComplexJunctionMetrics } = require('./junction-metrics');
const { convertGeoJson, boundsOf } = require('../reference/gaode');
const metricsCache = new WeakMap();
@@ -349,6 +350,8 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
// sharp notch instead of a curb. A real corner is one tangent-continuous
// sweep between the two outermost road edges, so fit a fixed-radius fillet
// into the wedge those edges form and fill the sector behind it.
const coreClosure = buildCoreClosure(topology, boundaryGraph, center);
const coreRing = coreClosure.status === 'supported' ? coreClosure.ring : null;
const cornerFills = [];
const sidewalkCorners = [];
const cornerDiagnostics = [];
@@ -445,12 +448,29 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
},
geometry: { type: 'Polygon', coordinates: [ring] },
});
const islandRadius = 3.5;
const islandCenter = helpers.offsetCoordinate(apex, bisector, Math.min(3.5, Math.max(1.5, apexReach * 0.2)));
const islandRing = [0, 90, 180, 270, 360].map((angle) =>
helpers.offsetCoordinate(islandCenter, bisector + angle, islandRadius),
const islandDepth = Math.min(7, Math.max(3, apexReach * 0.35));
const islandHalfWidth = Math.min(
2.2,
Math.max(1.2, Math.min(first.widthMeters || 4, second.widthMeters || 4) * 0.28),
);
if (!cornerOverlapsExclusion(islandRing, first.cornerKey, '安全岛'))
const islandCenter = helpers.offsetCoordinate(apex, bisector, -islandDepth * 0.5);
const islandRing = [
helpers.offsetCoordinate(helpers.offsetCoordinate(apex, bisector, 0.6), bisector + 90, -islandHalfWidth),
helpers.offsetCoordinate(
helpers.offsetCoordinate(islandCenter, bisector, islandDepth * 0.5),
bisector + 90,
-islandHalfWidth * 0.72,
),
helpers.offsetCoordinate(
helpers.offsetCoordinate(islandCenter, bisector, islandDepth * 0.5),
bisector + 90,
islandHalfWidth * 0.72,
),
helpers.offsetCoordinate(helpers.offsetCoordinate(apex, bisector, 0.6), bisector + 90, islandHalfWidth),
helpers.offsetCoordinate(helpers.offsetCoordinate(apex, bisector, 0.6), bisector + 90, -islandHalfWidth),
];
const publishedIslandRing = islandRing;
if (!cornerOverlapsExclusion(publishedIslandRing, first.cornerKey, '安全岛'))
islands.push({
type: 'Feature',
properties: {
@@ -462,7 +482,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
facility_evidence: 'inferred-complex-junction-corner',
provenance: 'native-road-complex-junction-inferred-island/v1',
},
geometry: { type: 'Polygon', coordinates: [islandRing] },
geometry: { type: 'Polygon', coordinates: [publishedIslandRing] },
});
if (
@@ -473,7 +493,16 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
// Complex junctions carry a default diagonal crossing across each safe
// corner. Source crossing nodes refine provenance/inset values, but are
// not required for the default visual treatment.
const diagonalCenter = helpers.offsetCoordinate(apex, bisector, Math.min(5, Math.max(1.5, apexReach * 0.28)));
const islandMidpoint = publishedIslandRing
.slice(0, -1)
.reduce(
(sum, point) => [
sum[0] + point[0] / (publishedIslandRing.length - 1),
sum[1] + point[1] / (publishedIslandRing.length - 1),
],
[0, 0],
);
const diagonalCenter = helpers.offsetCoordinate(islandMidpoint, bisector, islandHalfWidth + 1.2);
const diagonalSpan = Math.min(6, Math.max(2.4, helpers.distanceMeters(tangents[0], tangents[1]) * 0.35));
const diagonalDepth = 2.4;
const stripeCount = 7;
@@ -515,6 +544,9 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
native_id: `complex-corner-crosswalk:${cluster.id}:${index + 1}:${stripe + 1}`,
object_key: `crossing:corner:${first.cornerKey}`,
crossing_key: `crossing:corner:${first.cornerKey}`,
island_key: `island:inferred/${first.cornerKey}`,
from_boundary: `sidewalk:${first.cornerKey}:from`,
to_boundary: `island:inferred/${first.cornerKey}`,
cluster_id: cluster.id,
kind: 'complex-corner-crosswalk',
corner_key: first.cornerKey,
@@ -583,8 +615,6 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
geometry: { type: 'Polygon', coordinates: [sidewalkRing] },
});
}
const coreClosure = buildCoreClosure(topology, boundaryGraph, center);
const coreRing = coreClosure.status === 'supported' ? coreClosure.ring : null;
const features = [];
let coreFeature = null;
if (coreRing)