fix: preserve exclusions in complex junction pavement
This commit is contained in:
1 parent
e8ecfecbf4
commit
818d91d8b5
15 files changed
+606
-37
No files matched your search
@@ -1,6 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const { solveComplexPavementRegion } = require('./junction-pavement-region');
|
||||
const { solveComplexPavementRegion, segmentCoveredByPolygon } = require('./junction-pavement-region');
|
||||
const { intersection } = require('./junction-polygon-ops');
|
||||
|
||||
function hasPositiveArea(regions) {
|
||||
return regions.some((polygon) =>
|
||||
polygon.some((ring, index) => {
|
||||
const area = Math.abs(
|
||||
ring
|
||||
.slice(1)
|
||||
.reduce(
|
||||
(sum, point, pointIndex) => sum + ring[pointIndex][0] * point[1] - point[0] * ring[pointIndex][1],
|
||||
0,
|
||||
) / 2,
|
||||
);
|
||||
return index === 0 ? area > 1e-16 : false;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function buildCoreSurface({ cluster, helpers, center, nodeIds, arms, carriageways, shape, coreRadius, coreClosure }) {
|
||||
const coreRing = coreClosure.status === 'supported' ? coreClosure.ring : null;
|
||||
@@ -100,13 +117,49 @@ function buildApproachSurfaceFeatures(boundaryParts, model, cluster) {
|
||||
return features;
|
||||
}
|
||||
|
||||
function appendPavementRegion(features, crossingRegions, cluster, center, nodeIds, helpers) {
|
||||
function appendPavementRegion(
|
||||
features,
|
||||
crossingRegions,
|
||||
cluster,
|
||||
center,
|
||||
nodeIds,
|
||||
helpers,
|
||||
exclusionRegions,
|
||||
boundaryParts,
|
||||
topology,
|
||||
) {
|
||||
const cornerDiagnostics = [];
|
||||
// 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 pavementRegion = solveComplexPavementRegion(basePavement, crossingRegions);
|
||||
const pavementRegion = solveComplexPavementRegion(
|
||||
basePavement,
|
||||
crossingRegions,
|
||||
exclusionRegions.map((region) => region.ring),
|
||||
);
|
||||
const excludedIds = exclusionRegions.map((region) => String(region.id ?? ''));
|
||||
const missingCarriageways = [];
|
||||
if (exclusionRegions.length && pavementRegion.status === 'supported') {
|
||||
try {
|
||||
if (exclusionRegions.some((region) => hasPositiveArea(intersection(pavementRegion.regions, [region.ring]))))
|
||||
pavementRegion.status = 'exclusion-overlap';
|
||||
for (const item of topology.carriageways) {
|
||||
const part = boundaryParts.find((part) => part.item.key === item.key);
|
||||
if (
|
||||
!part ||
|
||||
!['inner', 'outer'].every((edge) =>
|
||||
segmentCoveredByPolygon(part.section[edge].left, part.section[edge].right, pavementRegion.regions[0]),
|
||||
)
|
||||
)
|
||||
missingCarriageways.push(item.key);
|
||||
}
|
||||
if (missingCarriageways.length) pavementRegion.status = 'required-seam-lost';
|
||||
} catch (error) {
|
||||
pavementRegion.status = 'unsupported';
|
||||
pavementRegion.reason = error.message;
|
||||
}
|
||||
}
|
||||
if (pavementRegion.status === 'supported') {
|
||||
for (const feature of features) feature.properties.pavement_input = true;
|
||||
features.push({
|
||||
@@ -124,21 +177,25 @@ function appendPavementRegion(features, crossingRegions, cluster, center, nodeId
|
||||
},
|
||||
geometry: { type: 'MultiPolygon', coordinates: pavementRegion.regions },
|
||||
});
|
||||
} else
|
||||
cornerDiagnostics.push(
|
||||
helpers.diagnostic(
|
||||
'warning',
|
||||
`junction-cluster:${cluster.id}`,
|
||||
[...nodeIds],
|
||||
pavementRegion.status === 'unsupported'
|
||||
? 'complex-junction-pavement-region-assembly-failed'
|
||||
: 'complex-junction-pavement-region-disconnected',
|
||||
pavementRegion.status === 'unsupported'
|
||||
? '统一铺装区域无法可靠装配,保留结构输入面并拒绝发布统一铺装面。'
|
||||
: '过街与入口无法组成连续铺装区域,保留结构输入面并拒绝发布统一铺装面。',
|
||||
center,
|
||||
),
|
||||
} else {
|
||||
const diagnostic = helpers.diagnostic(
|
||||
'warning',
|
||||
`junction-cluster:${cluster.id}`,
|
||||
[...nodeIds],
|
||||
pavementRegion.status === 'unsupported'
|
||||
? 'complex-junction-pavement-region-assembly-failed'
|
||||
: `complex-junction-pavement-region-${pavementRegion.status}`,
|
||||
pavementRegion.status === 'unsupported'
|
||||
? '统一铺装区域无法可靠装配,保留结构输入面并拒绝发布统一铺装面。'
|
||||
: `统一铺装区域不满足连续通行约束(${pavementRegion.status}),保留结构输入面并拒绝发布统一铺装面。`,
|
||||
center,
|
||||
);
|
||||
if (exclusionRegions.length) {
|
||||
diagnostic.exclusion_region_ids = excludedIds;
|
||||
diagnostic.carriageway_keys = missingCarriageways;
|
||||
}
|
||||
cornerDiagnostics.push(diagnostic);
|
||||
}
|
||||
return cornerDiagnostics;
|
||||
}
|
||||
|
||||
@@ -171,7 +228,19 @@ function assemblePavementSurfaces({
|
||||
// Preserve the structural surface order before publishing canonical pavement.
|
||||
features.push(...cornerFills);
|
||||
if (coreFeature) features.push(coreFeature);
|
||||
diagnostics.push(...appendPavementRegion(features, crossingRegions, cluster, center, nodeIds, helpers));
|
||||
diagnostics.push(
|
||||
...appendPavementRegion(
|
||||
features,
|
||||
crossingRegions,
|
||||
cluster,
|
||||
center,
|
||||
nodeIds,
|
||||
helpers,
|
||||
model.exclusionRegions || [],
|
||||
boundaryParts,
|
||||
topology,
|
||||
),
|
||||
);
|
||||
return { features, diagnostics };
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user