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
@@ -3,6 +3,7 @@
|
||||
const fs = require('fs');
|
||||
const { structureFromTopology } = require('./junction-topology');
|
||||
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan');
|
||||
const { buildJunctionBoundaryGraph } = require('./junction-boundary-graph');
|
||||
const { convertGeoJson, boundsOf } = require('../reference/gaode');
|
||||
const metricsCache = new WeakMap();
|
||||
const CORNER_FILLET_SEGMENTS = 12;
|
||||
@@ -83,15 +84,22 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
const crossingControls = helpers.clusterCrossingControls || new Map();
|
||||
const armCrosswalkRadiusFor = (arm) =>
|
||||
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
|
||||
// carriageway's outer transition, leaving neighboring arms untouched.
|
||||
const itemOuterRadius = Math.max(coreRadius + 4, outerRadius - Math.max(0, Number(item.approach.cutback) || 0));
|
||||
const outer = pointOnCarriagewayRadius(item, center, itemOuterRadius, helpers);
|
||||
const inner = pointOnCarriagewayRadius(item, center, coreRadius * 0.7, helpers);
|
||||
boundaryParts.push({ item, section });
|
||||
const outerHalf = item.approach.widthMeters / 2;
|
||||
const innerHalf = outerHalf;
|
||||
boundaryParts.push({ item, outer, inner, outerHalf, innerHalf });
|
||||
const incomingRoad = item.approach.roadIds
|
||||
.map((roadId) => model.roads.find((road) => road.id === roadId))
|
||||
.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 = [
|
||||
helpers.offsetCoordinate(outer, item.heading + 90, outerHalf),
|
||||
helpers.offsetCoordinate(inner, item.heading + 90, innerHalf),
|
||||
helpers.offsetCoordinate(inner, item.heading - 90, innerHalf),
|
||||
helpers.offsetCoordinate(outer, item.heading - 90, outerHalf),
|
||||
helpers.offsetCoordinate(outer, item.heading + 90, outerHalf),
|
||||
section.outer.right,
|
||||
section.inner.right,
|
||||
section.inner.left,
|
||||
section.outer.left,
|
||||
section.outer.right,
|
||||
];
|
||||
features.push({
|
||||
type: 'Feature',
|
||||
@@ -553,6 +561,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
0,
|
||||
),
|
||||
width_m: item.approach.widthMeters,
|
||||
boundary_refs: section.edgeRefs,
|
||||
provenance: 'native-road-complex-junction/v5',
|
||||
},
|
||||
geometry: { type: 'Polygon', coordinates: [ring] },
|
||||
|
||||
Reference in new issue
Block a user