fix: close divided two-node T junction pavement
This commit is contained in:
1 parent
fda733ce72
commit
f122e8236a
3 files changed
+49
-5
No files matched your search
@@ -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]);
|
||||
|
||||
@@ -116,6 +116,8 @@ function resolveJunctionBuildPlan(model, cluster, helpers) {
|
||||
.map((id) => helpers.junctionPlans.get(id)?.node)
|
||||
.filter(Boolean);
|
||||
const carriageways = [];
|
||||
const internalRoadIds = new Set();
|
||||
const internalLinkLengths = [];
|
||||
for (const [nodeId, plan] of helpers.junctionPlans) {
|
||||
if (!nodeIds.has(String(nodeId))) continue;
|
||||
for (const approach of plan.approaches || []) {
|
||||
@@ -126,7 +128,12 @@ function resolveJunctionBuildPlan(model, cluster, helpers) {
|
||||
(road) => nodeIds.has(String(road.sourceNodeIds[0])) && nodeIds.has(String(road.sourceNodeIds.at(-1))),
|
||||
)
|
||||
: nodes.some((node) => node !== plan.node && helpers.distanceMeters(approach.line.at(-1), node) < 4);
|
||||
if (internal) continue;
|
||||
if (internal) {
|
||||
roads.forEach((road) => internalRoadIds.add(String(road.id)));
|
||||
if (Number.isFinite(helpers.lineLengthMeters(approach.line)))
|
||||
internalLinkLengths.push(helpers.lineLengthMeters(approach.line));
|
||||
continue;
|
||||
}
|
||||
carriageways.push({
|
||||
nodeId: String(nodeId),
|
||||
approach,
|
||||
@@ -179,7 +186,15 @@ function resolveJunctionBuildPlan(model, cluster, helpers) {
|
||||
}
|
||||
for (let index = 0; index < arms.length; index += 1)
|
||||
arms[index].cornerKey = `corner:${arms[index].key}>${arms[(index + 1) % arms.length].key}`;
|
||||
return { schema: 'junction-build-plan/v1', cluster, nodeIds: [...nodeIds].sort(), carriageways, arms };
|
||||
return {
|
||||
schema: 'junction-build-plan/v1',
|
||||
cluster,
|
||||
nodeIds: [...nodeIds].sort(),
|
||||
internalRoadIds: [...internalRoadIds].sort(),
|
||||
internalLinkLengths,
|
||||
carriageways,
|
||||
arms,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { MIN_ENTRY_SECTION_METERS, resolveJunctionBuildPlan, stationAtDistanceFrom };
|
||||
@@ -19,6 +19,7 @@ const model = compileRoadModel(fs.readFileSync('./inputs/osm/枫树二路.osm',
|
||||
for (const [name, nodeIds] of Object.entries({
|
||||
cross: ['8005332807', '8024512135', '8024512145', '8024512147'],
|
||||
tee: ['8005332807', '8024512135', '8024512145'],
|
||||
dividedTee: ['1590698046', '6538106539'],
|
||||
})) {
|
||||
const geometry = compileGeometry(
|
||||
model,
|
||||
@@ -27,7 +28,14 @@ for (const [name, nodeIds] of Object.entries({
|
||||
edgeLines: false,
|
||||
junctionTemplates: {
|
||||
enabled: true,
|
||||
clusters: [{ id: name, template: 'complex-junction-v1', coreRadiusMeters: 21, nodeIds }],
|
||||
clusters: [
|
||||
{
|
||||
id: name,
|
||||
template: 'complex-junction-v1',
|
||||
coreRadiusMeters: name === 'dividedTee' ? 18 : 21,
|
||||
nodeIds,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -41,6 +49,11 @@ for (const [name, nodeIds] of Object.entries({
|
||||
geometry.diagnostics.some((item) => item.rule === 'complex-junction-pavement-region-disconnected'),
|
||||
false,
|
||||
);
|
||||
if (name === 'dividedTee')
|
||||
assert.ok(
|
||||
geometry.roadSurface.features.some((feature) => feature.properties.kind === 'complex-core'),
|
||||
'dividedTee must publish a closed complex core',
|
||||
);
|
||||
// The region owns road-arm crossings. The island-hypotenuse crossing is a
|
||||
// pedestrian facility above the road layer and does not expand pavement.
|
||||
for (const stripe of geometry.crosswalks.features.filter(
|
||||
|
||||
Reference in new issue
Block a user