fix: respect finite extents in junction region overlap
This commit is contained in:
1 parent
101bcb3792
commit
c003edaf51
2 files changed
+34
-1
No files matched your search
@@ -4,11 +4,35 @@
|
||||
|
||||
const assert = require('assert/strict');
|
||||
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('../src/compile/junction-build-plan');
|
||||
const { buildJunctionBoundaryGraph, buildCoreClosure } = require('../src/compile/junction-boundary-graph');
|
||||
const {
|
||||
buildJunctionBoundaryGraph,
|
||||
buildCoreClosure,
|
||||
ringsOverlap,
|
||||
} = require('../src/compile/junction-boundary-graph');
|
||||
const { classifyJunctionShape } = require('../src/compile/complex-junction');
|
||||
|
||||
const metersPerDegree = 111320;
|
||||
const point = (east, north) => [east / metersPerDegree, north / metersPerDegree];
|
||||
const square = (x, y, size = 2) =>
|
||||
[
|
||||
[x, y],
|
||||
[x + size, y],
|
||||
[x + size, y + size],
|
||||
[x, y + size],
|
||||
[x, y],
|
||||
].map(([east, north]) => point(east, north));
|
||||
for (const [other, expected] of [
|
||||
[square(10, 0), false],
|
||||
[square(0, 10), false],
|
||||
[square(2, 0), true],
|
||||
[square(2, 2), true],
|
||||
[square(1, 1), true],
|
||||
[square(0.5, 0.5, 0.5), true],
|
||||
]) {
|
||||
assert.equal(ringsOverlap(square(0, 0), other), expected);
|
||||
assert.equal(ringsOverlap(other, square(0, 0)), expected);
|
||||
assert.equal(ringsOverlap(square(0, 0).reverse(), other.slice().reverse()), expected);
|
||||
}
|
||||
|
||||
function heading(line) {
|
||||
const [from, to] = line;
|
||||
|
||||
Reference in new issue
Block a user