fix: publish unified complex junction pavement
This commit is contained in:
1 parent
787faa7604
commit
8882754b23
5 files changed
+155
-1
No files matched your search
@@ -5,6 +5,7 @@ const { COMPLEX_CROSSWALK_DEPTH_METERS } = require('./junction-metrics');
|
||||
const { structureFromTopology } = require('./junction-topology');
|
||||
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan');
|
||||
const { buildJunctionBoundaryGraph, buildCoreClosure, ringsOverlap } = require('./junction-boundary-graph');
|
||||
const { solveComplexPavementRegion, rectangle, connectCornerCrossing } = require('./junction-pavement-region');
|
||||
const {
|
||||
buildIslandFromCrossingEdges,
|
||||
orthogonalCrossingHeadings,
|
||||
@@ -84,6 +85,8 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
const boundaryParts = [];
|
||||
const transitionDiagnostics = [];
|
||||
const crosswalks = [];
|
||||
const crossingRegions = [];
|
||||
const cornerCrossingFrames = [];
|
||||
const stopLines = [];
|
||||
const islands = [];
|
||||
const crossingControls = helpers.clusterCrossingControls || new Map();
|
||||
@@ -340,6 +343,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
arm.crosswalkFrame.endpoints = endpoints;
|
||||
arm.crosswalkFrame.spanMeters = usableSpan;
|
||||
arm.crosswalkFrame.roadEdgeInsetMeters = roadEdgeInset;
|
||||
crossingRegions.push(rectangle(arm.crosswalkFrame.center, crossingHeading, groupDepth, usableSpan));
|
||||
for (let stripe = 0; stripe < stripeCount; stripe += 1) {
|
||||
const along = layout.centers[stripe];
|
||||
const centerPoint = helpers.offsetCoordinate(endpoints[0], bearing(...endpoints), along);
|
||||
@@ -606,6 +610,12 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
const diagonalHeading = outwardHeading;
|
||||
const diagonalCenter = helpers.offsetCoordinate(outerMidpoint, outwardHeading, diagonalDepth / 2);
|
||||
const diagonalSpan = COMPLEX_CROSSWALK_DEPTH_METERS;
|
||||
cornerCrossingFrames.push({
|
||||
center: diagonalCenter,
|
||||
heading: diagonalHeading,
|
||||
depth: diagonalDepth,
|
||||
span: diagonalSpan,
|
||||
});
|
||||
const layout = stripeLayout(diagonalDepth);
|
||||
const stripeCount = layout.centers.length;
|
||||
const stripeSpacing = layout.pitch;
|
||||
@@ -811,6 +821,46 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
// they are smoothing; they never replace an OSM-derived road surface.
|
||||
features.push(...cornerFills);
|
||||
if (coreFeature) features.push(coreFeature);
|
||||
// Publish a single canonical pavement region last. The individual approach,
|
||||
// core and corner polygons above remain structural inputs for editing and
|
||||
// diagnostics; they are no longer the visible authority at the junction.
|
||||
const basePavement = features.map((feature) => feature.geometry.coordinates[0]);
|
||||
const connectedCrossings = [...crossingRegions];
|
||||
const connectors = [];
|
||||
for (const frame of cornerCrossingFrames) {
|
||||
const solved = connectCornerCrossing(basePavement, connectedCrossings, frame);
|
||||
connectedCrossings.push(solved.region);
|
||||
if (solved.connector) connectors.push(solved.connector);
|
||||
}
|
||||
const pavementRegion = solveComplexPavementRegion(basePavement, [...connectedCrossings, ...connectors]);
|
||||
if (pavementRegion.status === 'supported') {
|
||||
for (const feature of features) feature.properties.pavement_input = true;
|
||||
features.push({
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
native_id: `complex-junction:${cluster.id}:pavement-region`,
|
||||
cluster_id: cluster.id,
|
||||
kind: 'complex-pavement-region',
|
||||
complex_part: 'pavement-region',
|
||||
center,
|
||||
region_status: 'supported',
|
||||
region_input_count: pavementRegion.inputCount,
|
||||
crossing_connector_count: connectors.length,
|
||||
provenance: 'native-road-complex-junction-pavement-region/v1',
|
||||
},
|
||||
geometry: { type: 'MultiPolygon', coordinates: pavementRegion.regions },
|
||||
});
|
||||
} else
|
||||
cornerDiagnostics.push(
|
||||
helpers.diagnostic(
|
||||
'warning',
|
||||
`junction-cluster:${cluster.id}`,
|
||||
[...nodeIds],
|
||||
'complex-junction-pavement-region-disconnected',
|
||||
'过街与入口无法组成连续铺装区域,保留结构输入面并拒绝发布统一铺装面。',
|
||||
center,
|
||||
),
|
||||
);
|
||||
// `coreRadiusMeters` is only consulted when there is no reference geometry.
|
||||
// Under calibration the radius comes from the reference span, so a configured
|
||||
// value that silently does nothing has to be reported, not swallowed.
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
const { union } = require('./junction-polygon-ops');
|
||||
|
||||
/**
|
||||
* The road layer has one authoritative complex-junction region. Construction
|
||||
* parts are inputs only; crossings contribute their complete rectangular
|
||||
* carriageway footprint rather than disconnected white stripes.
|
||||
*/
|
||||
function solveComplexPavementRegion(parts, crossingRegions = []) {
|
||||
const inputs = [...parts, ...crossingRegions].filter(
|
||||
(ring) => Array.isArray(ring) && ring.length >= 4 && ring.every((point) => point?.every(Number.isFinite)),
|
||||
);
|
||||
const regions = union(...inputs.map((ring) => [ring]));
|
||||
return {
|
||||
status: regions.length === 1 ? 'supported' : 'disconnected',
|
||||
regions,
|
||||
inputCount: inputs.length,
|
||||
};
|
||||
}
|
||||
|
||||
function offset(point, heading, meters) {
|
||||
const radians = (heading * Math.PI) / 180;
|
||||
const scale = 111320 * Math.cos((point[1] * Math.PI) / 180);
|
||||
return [point[0] + (Math.sin(radians) * meters) / scale, point[1] + (Math.cos(radians) * meters) / 111320];
|
||||
}
|
||||
|
||||
function rectangle(center, heading, depth, span) {
|
||||
const first = offset(offset(center, heading + 90, -span / 2), heading, -depth / 2);
|
||||
const second = offset(offset(center, heading + 90, span / 2), heading, -depth / 2);
|
||||
const third = offset(offset(center, heading + 90, span / 2), heading, depth / 2);
|
||||
const fourth = offset(offset(center, heading + 90, -span / 2), heading, depth / 2);
|
||||
return [first, second, third, fourth, first];
|
||||
}
|
||||
|
||||
// A corner crossing keeps its island landing fixed. When its carriageway-side
|
||||
// edge does not meet the main paved component, seek the shortest narrow
|
||||
// connector behind it. This is a region constraint, not a move of the zebra.
|
||||
function connectCornerCrossing(parts, crossingRegions, crossing) {
|
||||
const original = rectangle(crossing.center, crossing.heading, crossing.depth, crossing.span);
|
||||
const baseline = solveComplexPavementRegion(parts, [...crossingRegions, original]);
|
||||
if (baseline.status === 'supported') return { region: original, connector: null };
|
||||
for (let along = 0.5; along <= 10; along += 0.5) {
|
||||
for (const lateral of [0, -0.5, 0.5, -1, 1, -1.5, 1.5, -2, 2]) {
|
||||
const center = offset(offset(crossing.center, crossing.heading, -along / 2), crossing.heading + 90, lateral);
|
||||
const connector = rectangle(center, crossing.heading, crossing.depth + along + 0.5, crossing.span);
|
||||
const candidate = solveComplexPavementRegion(parts, [...crossingRegions, original, connector]);
|
||||
if (candidate.status === 'supported') return { region: original, connector };
|
||||
}
|
||||
}
|
||||
return { region: original, connector: null };
|
||||
}
|
||||
|
||||
module.exports = { solveComplexPavementRegion, rectangle, connectCornerCrossing };
|
||||
Reference in new issue
Block a user