feat(junction): derive complex approach boundary sections
This commit is contained in:
1 parent
4de971ce68
commit
b4abfdb870
4 files changed
+138
-12
No files matched your search
@@ -19,6 +19,7 @@
|
|||||||
## 2. 连续边界与区域求解(最高风险)
|
## 2. 连续边界与区域求解(最高风险)
|
||||||
|
|
||||||
- [x] 将复杂路口边界半径映射到来源折线的实际首次相交站点,并把同一车行道裁切传递给道路面、边线、中心线、人行道和车道发布线。
|
- [x] 将复杂路口边界半径映射到来源折线的实际首次相交站点,并把同一车行道裁切传递给道路面、边线、中心线、人行道和车道发布线。
|
||||||
|
- [x] 为每条车行道生成带稳定边引用的内外断面,复杂进口面直接消费这些边;核心闭合边显式保留为待解,避免臆造跨分隔通行面。
|
||||||
- [ ] 实现接入断面到固定远端过渡;以共享边界构建中心/进口/角部,取消独立半径拼接作为权威。
|
- [ ] 实现接入断面到固定远端过渡;以共享边界构建中心/进口/角部,取消独立半径拼接作为权威。
|
||||||
- [ ] 支持凹形与已知排除区域,检查环、自交、接缝、必要连接;设计边界可行域并由 solver/manifest 共用。
|
- [ ] 支持凹形与已知排除区域,检查环、自交、接缝、必要连接;设计边界可行域并由 solver/manifest 共用。
|
||||||
- [ ] 审计 roadSurface、sidewalkSurface、edgeLines、lane/center markings 的每个裁切入口,确保消费同一计划。
|
- [ ] 审计 roadSurface、sidewalkSurface、edgeLines、lane/center markings 的每个裁切入口,确保消费同一计划。
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { structureFromTopology } = require('./junction-topology');
|
const { structureFromTopology } = require('./junction-topology');
|
||||||
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan');
|
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan');
|
||||||
|
const { buildJunctionBoundaryGraph } = require('./junction-boundary-graph');
|
||||||
const { convertGeoJson, boundsOf } = require('../reference/gaode');
|
const { convertGeoJson, boundsOf } = require('../reference/gaode');
|
||||||
const metricsCache = new WeakMap();
|
const metricsCache = new WeakMap();
|
||||||
const CORNER_FILLET_SEGMENTS = 12;
|
const CORNER_FILLET_SEGMENTS = 12;
|
||||||
@@ -83,15 +84,22 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
|||||||
const crossingControls = helpers.clusterCrossingControls || new Map();
|
const crossingControls = helpers.clusterCrossingControls || new Map();
|
||||||
const armCrosswalkRadiusFor = (arm) =>
|
const armCrosswalkRadiusFor = (arm) =>
|
||||||
Math.max(1, coreRadius * 0.68 + (crossingControls.get(`crossing:${arm.key}`)?.crosswalkInsetMeters || 0));
|
Math.max(1, coreRadius * 0.68 + (crossingControls.get(`crossing:${arm.key}`)?.crosswalkInsetMeters || 0));
|
||||||
for (const item of carriageways) {
|
const boundaryGraph = buildJunctionBoundaryGraph(
|
||||||
|
topology,
|
||||||
|
center,
|
||||||
|
{
|
||||||
|
outerRadiusFor: (item) => Math.max(coreRadius + 4, outerRadius - Math.max(0, Number(item.approach.cutback) || 0)),
|
||||||
|
innerRadiusFor: () => coreRadius * 0.7,
|
||||||
|
},
|
||||||
|
helpers,
|
||||||
|
);
|
||||||
|
for (const section of boundaryGraph.sections) {
|
||||||
|
const item = carriageways.find((candidate) => candidate.key === section.carriagewayKey);
|
||||||
|
if (!item) continue;
|
||||||
// The approach plan owns the editable handoff distance. It shifts only this
|
// The approach plan owns the editable handoff distance. It shifts only this
|
||||||
// carriageway's outer transition, leaving neighboring arms untouched.
|
// carriageway's outer transition, leaving neighboring arms untouched.
|
||||||
const itemOuterRadius = Math.max(coreRadius + 4, outerRadius - Math.max(0, Number(item.approach.cutback) || 0));
|
boundaryParts.push({ item, section });
|
||||||
const outer = pointOnCarriagewayRadius(item, center, itemOuterRadius, helpers);
|
|
||||||
const inner = pointOnCarriagewayRadius(item, center, coreRadius * 0.7, helpers);
|
|
||||||
const outerHalf = item.approach.widthMeters / 2;
|
const outerHalf = item.approach.widthMeters / 2;
|
||||||
const innerHalf = outerHalf;
|
|
||||||
boundaryParts.push({ item, outer, inner, outerHalf, innerHalf });
|
|
||||||
const incomingRoad = item.approach.roadIds
|
const incomingRoad = item.approach.roadIds
|
||||||
.map((roadId) => model.roads.find((road) => road.id === roadId))
|
.map((roadId) => model.roads.find((road) => road.id === roadId))
|
||||||
.find((road) => String(road?.sourceNodeIds.at(-1)) === String(item.nodeId));
|
.find((road) => String(road?.sourceNodeIds.at(-1)) === String(item.nodeId));
|
||||||
@@ -529,13 +537,13 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (const { item, outer, inner, outerHalf, innerHalf } of boundaryParts) {
|
for (const { item, section } of boundaryParts) {
|
||||||
const ring = [
|
const ring = [
|
||||||
helpers.offsetCoordinate(outer, item.heading + 90, outerHalf),
|
section.outer.right,
|
||||||
helpers.offsetCoordinate(inner, item.heading + 90, innerHalf),
|
section.inner.right,
|
||||||
helpers.offsetCoordinate(inner, item.heading - 90, innerHalf),
|
section.inner.left,
|
||||||
helpers.offsetCoordinate(outer, item.heading - 90, outerHalf),
|
section.outer.left,
|
||||||
helpers.offsetCoordinate(outer, item.heading + 90, outerHalf),
|
section.outer.right,
|
||||||
];
|
];
|
||||||
features.push({
|
features.push({
|
||||||
type: 'Feature',
|
type: 'Feature',
|
||||||
@@ -553,6 +561,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
|||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
width_m: item.approach.widthMeters,
|
width_m: item.approach.widthMeters,
|
||||||
|
boundary_refs: section.edgeRefs,
|
||||||
provenance: 'native-road-complex-junction/v5',
|
provenance: 'native-road-complex-junction/v5',
|
||||||
},
|
},
|
||||||
geometry: { type: 'Polygon', coordinates: [ring] },
|
geometry: { type: 'Polygon', coordinates: [ring] },
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { stationAtDistanceFrom } = require('./junction-build-plan');
|
||||||
|
|
||||||
|
function pointAtStation(line, station, helpers) {
|
||||||
|
let remaining = Math.max(0, station);
|
||||||
|
for (let index = 1; index < line.length; index += 1) {
|
||||||
|
const length = helpers.distanceMeters(line[index - 1], line[index]);
|
||||||
|
if (remaining <= length) {
|
||||||
|
const ratio = length ? remaining / length : 0;
|
||||||
|
return [
|
||||||
|
line[index - 1][0] + (line[index][0] - line[index - 1][0]) * ratio,
|
||||||
|
line[index - 1][1] + (line[index][1] - line[index - 1][1]) * ratio,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
remaining -= length;
|
||||||
|
}
|
||||||
|
return line.at(-1) || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function tangentAtStation(line, station, helpers) {
|
||||||
|
let walked = 0;
|
||||||
|
for (let index = 1; index < line.length; index += 1) {
|
||||||
|
const length = helpers.distanceMeters(line[index - 1], line[index]);
|
||||||
|
if (station <= walked + length || index === line.length - 1)
|
||||||
|
return helpers.headingAtEndpoint([line[index - 1], line[index]]);
|
||||||
|
walked += length;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function offsetCoordinate(point, heading, meters) {
|
||||||
|
if (!point || !Number.isFinite(heading)) return null;
|
||||||
|
const radians = (heading * Math.PI) / 180;
|
||||||
|
const lonMeters = 111320 * Math.cos((point[1] * Math.PI) / 180);
|
||||||
|
return [
|
||||||
|
point[0] + (Math.sin(radians) * meters) / Math.max(lonMeters, 1e-9),
|
||||||
|
point[1] + (Math.cos(radians) * meters) / 111320,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function sectionAt(item, radius, center, helpers) {
|
||||||
|
const station = Math.min(item.length, stationAtDistanceFrom(item.approach.line, center, radius, helpers));
|
||||||
|
const point = pointAtStation(item.approach.line, station, helpers);
|
||||||
|
const tangent = tangentAtStation(item.approach.line, station, helpers);
|
||||||
|
const halfWidth = Math.max(0, Number(item.approach.widthMeters) || 0) / 2;
|
||||||
|
return {
|
||||||
|
stationMeters: station,
|
||||||
|
point,
|
||||||
|
tangent,
|
||||||
|
left: offsetCoordinate(point, tangent - 90, halfWidth),
|
||||||
|
right: offsetCoordinate(point, tangent + 90, halfWidth),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// The graph currently owns only source-derived entry edges. Core closure is
|
||||||
|
// deliberately unresolved until a later stage can distinguish paved links,
|
||||||
|
// medians, and exclusion regions from topology alone.
|
||||||
|
function buildJunctionBoundaryGraph(topology, center, radii, helpers) {
|
||||||
|
const sections = topology.carriageways.map((item) => {
|
||||||
|
const outerRadius = radii.outerRadiusFor(item);
|
||||||
|
const innerRadius = radii.innerRadiusFor(item);
|
||||||
|
const outer = sectionAt(item, outerRadius, center, helpers);
|
||||||
|
const inner = sectionAt(item, innerRadius, center, helpers);
|
||||||
|
const key = `boundary:${item.key}`;
|
||||||
|
return {
|
||||||
|
key,
|
||||||
|
carriagewayKey: item.key,
|
||||||
|
armKey: item.armKey,
|
||||||
|
outer,
|
||||||
|
inner,
|
||||||
|
edgeRefs: {
|
||||||
|
left: `${key}:left`,
|
||||||
|
right: `${key}:right`,
|
||||||
|
outer: `${key}:outer`,
|
||||||
|
inner: `${key}:inner`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const edges = sections.flatMap((section) => [
|
||||||
|
{ key: section.edgeRefs.left, from: section.outer.left, to: section.inner.left, owner: section.carriagewayKey },
|
||||||
|
{ key: section.edgeRefs.right, from: section.inner.right, to: section.outer.right, owner: section.carriagewayKey },
|
||||||
|
{ key: section.edgeRefs.outer, from: section.outer.right, to: section.outer.left, owner: section.carriagewayKey },
|
||||||
|
{ key: section.edgeRefs.inner, from: section.inner.left, to: section.inner.right, owner: section.carriagewayKey },
|
||||||
|
]);
|
||||||
|
return {
|
||||||
|
schema: 'junction-boundary-graph/v1',
|
||||||
|
status: 'entry-sections-only',
|
||||||
|
sections,
|
||||||
|
edges,
|
||||||
|
unresolvedClosures: topology.arms.map((arm) => arm.cornerKey),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { buildJunctionBoundaryGraph };
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
const assert = require('assert/strict');
|
const assert = require('assert/strict');
|
||||||
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('../src/compile/junction-build-plan');
|
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('../src/compile/junction-build-plan');
|
||||||
|
const { buildJunctionBoundaryGraph } = require('../src/compile/junction-boundary-graph');
|
||||||
const { classifyJunctionShape } = require('../src/compile/complex-junction');
|
const { classifyJunctionShape } = require('../src/compile/complex-junction');
|
||||||
|
|
||||||
const metersPerDegree = 111320;
|
const metersPerDegree = 111320;
|
||||||
@@ -90,6 +91,16 @@ assert.ok(
|
|||||||
(item) => item.entrySection.boundaryEndpoints.near.left[0] !== item.entrySection.boundaryEndpoints.near.right[0],
|
(item) => item.entrySection.boundaryEndpoints.near.left[0] !== item.entrySection.boundaryEndpoints.near.right[0],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
const dividedBoundaryGraph = buildJunctionBoundaryGraph(
|
||||||
|
divided.topology,
|
||||||
|
point(0, 0),
|
||||||
|
{ outerRadiusFor: () => 25, innerRadiusFor: () => 10 },
|
||||||
|
divided.helpers,
|
||||||
|
);
|
||||||
|
assert.equal(dividedBoundaryGraph.status, 'entry-sections-only');
|
||||||
|
assert.equal(dividedBoundaryGraph.sections.length, divided.topology.carriageways.length);
|
||||||
|
assert.equal(new Set(dividedBoundaryGraph.sections.map((section) => section.carriagewayKey)).size, 4);
|
||||||
|
assert.equal(dividedBoundaryGraph.edges.length, dividedBoundaryGraph.sections.length * 4);
|
||||||
|
|
||||||
// A T junction has explicit, source-stable entry sections. Closure edges are a
|
// A T junction has explicit, source-stable entry sections. Closure edges are a
|
||||||
// later BoundaryGraph concern and must not be fabricated by topology parsing.
|
// later BoundaryGraph concern and must not be fabricated by topology parsing.
|
||||||
@@ -135,6 +146,16 @@ assert.notEqual(
|
|||||||
curvedShort.topology.carriageways[0].entrySection.nearTangent,
|
curvedShort.topology.carriageways[0].entrySection.nearTangent,
|
||||||
curvedShort.topology.carriageways[0].entrySection.farTangent,
|
curvedShort.topology.carriageways[0].entrySection.farTangent,
|
||||||
);
|
);
|
||||||
|
const curvedBoundaryGraph = buildJunctionBoundaryGraph(
|
||||||
|
curvedShort.topology,
|
||||||
|
point(0, 0),
|
||||||
|
{ outerRadiusFor: () => 8, innerRadiusFor: () => 2 },
|
||||||
|
curvedShort.helpers,
|
||||||
|
);
|
||||||
|
const curvedSection = curvedBoundaryGraph.sections.find(
|
||||||
|
(section) => section.carriagewayKey === curvedShort.topology.carriageways[0].key,
|
||||||
|
);
|
||||||
|
assert.notEqual(curvedSection.outer.tangent, curvedSection.inner.tangent);
|
||||||
|
|
||||||
const curvedBoundaryLine = [point(0, 0), point(0, 5), point(10, 10)];
|
const curvedBoundaryLine = [point(0, 0), point(0, 5), point(10, 10)];
|
||||||
const curvedBoundaryStation = stationAtDistanceFrom(curvedBoundaryLine, point(0, 0), 9, {
|
const curvedBoundaryStation = stationAtDistanceFrom(curvedBoundaryLine, point(0, 0), 9, {
|
||||||
|
|||||||
Reference in new issue
Block a user