feat(junction): preserve known traffic island regions
This commit is contained in:
1 parent
b6f4dfeb0c
commit
4b8f37a219
3 files changed
+36
-4
No files matched your search
@@ -56,7 +56,7 @@ function sectionAt(item, radius, center, helpers) {
|
||||
// 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) {
|
||||
function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionRegions = []) {
|
||||
const sections = topology.carriageways.map((item) => {
|
||||
const outerRadius = radii.outerRadiusFor(item);
|
||||
const innerRadius = radii.innerRadiusFor(item);
|
||||
@@ -88,6 +88,7 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers) {
|
||||
status: 'entry-sections-only',
|
||||
sections,
|
||||
edges,
|
||||
exclusionRegions: exclusionRegions.filter((region) => Array.isArray(region.ring) && region.ring.length >= 4),
|
||||
unresolvedClosures: topology.arms.map((arm) => arm.cornerKey),
|
||||
};
|
||||
}
|
||||
@@ -114,6 +115,17 @@ function signedArea(ring) {
|
||||
return ring.slice(1).reduce((area, point, index) => area + ring[index][0] * point[1] - point[0] * ring[index][1], 0);
|
||||
}
|
||||
|
||||
function pointInRing(point, ring) {
|
||||
return ring.slice(1).reduce((inside, candidate, index) => {
|
||||
const previous = ring[index];
|
||||
const crosses = previous[1] > point[1] !== candidate[1] > point[1];
|
||||
return crosses &&
|
||||
point[0] < ((candidate[0] - previous[0]) * (point[1] - previous[1])) / (candidate[1] - previous[1]) + previous[0]
|
||||
? !inside
|
||||
: inside;
|
||||
}, false);
|
||||
}
|
||||
|
||||
// A central paved region is safe to infer only when every arm has exactly one
|
||||
// source carriageway. Its shared entry seams are the sections' `inner` edges;
|
||||
// every remaining edge is an explicit closure between adjacent arms.
|
||||
@@ -145,6 +157,8 @@ function buildCoreClosure(topology, graph, center) {
|
||||
});
|
||||
if (ring.length < 7 || !paired || Math.abs(signedArea(ring)) < 1e-14 || ringSelfIntersects(ring))
|
||||
return { status: 'unsupported', reason: 'core-closure-invalid' };
|
||||
if (graph.exclusionRegions.some((region) => region.ring.some((point) => pointInRing(point, ring))))
|
||||
return { status: 'unsupported', reason: 'known-exclusion-region' };
|
||||
return {
|
||||
status: 'supported',
|
||||
ring,
|
||||
|
||||
Reference in new issue
Block a user