fix: align junction crossings and round pedestrian islands
This commit is contained in:
1 parent
76f81d024a
commit
7a7912f302
18 files changed
+491
-96
No files matched your search
+67
-1
@@ -479,7 +479,14 @@ const sourceCrossingRadius = Math.hypot(
|
||||
(sourceCrossingModel.crossings[0].coordinate[0] - sourceCenter[0]) * sourceLatitudeScale,
|
||||
(sourceCrossingModel.crossings[0].coordinate[1] - sourceCenter[1]) * 111320,
|
||||
);
|
||||
assert.ok(Math.abs(sourcedComplexCrosswalk.properties.radial_distance_m - sourceCrossingRadius) < 0.1);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
sourcedComplexCrosswalk.properties.radial_distance_m -
|
||||
sourceCrossingRadius -
|
||||
sourcedComplexCrosswalk.properties.group_depth_m,
|
||||
) < 0.1,
|
||||
'complex crossing retreats by its full rectangle depth from its source station',
|
||||
);
|
||||
const sourcedStopLine = sourceCrossingGeometry.vehicleStopLines.features.find(
|
||||
(feature) => feature.properties?.crossing_key === inferredStopLine.properties.crossing_key,
|
||||
);
|
||||
@@ -532,3 +539,62 @@ assert.equal(
|
||||
'source-osm-region',
|
||||
);
|
||||
console.log('road compiler package tests passed');
|
||||
|
||||
// Stop lines must remain outside the relocated matching crossing stripes.
|
||||
const polygonClipping = require('polygon-clipping');
|
||||
for (const stop of sourceCrossingGeometry.vehicleStopLines.features) {
|
||||
if (stop.properties.kind !== 'complex-stop-line') continue;
|
||||
for (const stripe of sourceCrossingGeometry.crosswalks.features) {
|
||||
if (stripe.properties.crossing_key !== stop.properties.crossing_key) continue;
|
||||
assert.deepEqual(
|
||||
polygonClipping.intersection(stop.geometry.coordinates, stripe.geometry.coordinates),
|
||||
[],
|
||||
'stop line does not intersect its crosswalk after default retreat',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const minimumStopGeometry = compiler.nativeRoad.compileGeometry(
|
||||
sourceCrossingModel,
|
||||
{ schema: 'native-road-overrides/v1', overrides: [] },
|
||||
{
|
||||
edgeLines: false,
|
||||
junctionTemplates: {
|
||||
enabled: true,
|
||||
clusters: [
|
||||
{
|
||||
id: 'fixture-five-arm',
|
||||
template: 'complex-junction-v1',
|
||||
nodeIds: ['8005332807', '8024512135', '8024512145', '8024512147', '8613058676'],
|
||||
coreRadiusMeters: 24,
|
||||
},
|
||||
],
|
||||
},
|
||||
directEdit: {
|
||||
clusterCrossings: new Map([
|
||||
[
|
||||
'fixture-five-arm',
|
||||
new Map(
|
||||
sourceCrossingGeometry.vehicleStopLines.features
|
||||
.filter((f) => f.properties.kind === 'complex-stop-line')
|
||||
.map((f) => [f.properties.crossing_key, { stopLineOffsetMeters: 0.5 }]),
|
||||
),
|
||||
],
|
||||
]),
|
||||
},
|
||||
},
|
||||
);
|
||||
const minimumStops = minimumStopGeometry.vehicleStopLines.features.filter(
|
||||
(f) => f.properties.kind === 'complex-stop-line',
|
||||
);
|
||||
assert.ok(minimumStops.length > 0);
|
||||
for (const stop of minimumStops) {
|
||||
for (const stripe of minimumStopGeometry.crosswalks.features) {
|
||||
if (stripe.properties.crossing_key !== stop.properties.crossing_key) continue;
|
||||
assert.deepEqual(
|
||||
polygonClipping.intersection(stop.geometry.coordinates, stripe.geometry.coordinates),
|
||||
[],
|
||||
'minimum stop offset must not overlap its matching crossing',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -20,3 +20,88 @@ assert.equal(validateFacilityComposition(island, crossings).valid, true);
|
||||
assert.equal(buildPedestrianIsland({ key: 'bad', ring, crossingKeys: ['a', 'b'] }), null);
|
||||
assert.equal(validateFacilityComposition(island, crossings.slice(0, 2)).reason, 'crossing-reference-missing');
|
||||
console.log('junction facility composition tests passed');
|
||||
|
||||
// User's sketch: a horizontal crossing to the right, a vertical crossing down,
|
||||
// and the island in the upper-left quadrant, bounded by doubled short edges.
|
||||
const { buildIslandFromCrossingEdges } = require('../src/compile/junction-facility-composition');
|
||||
const clipping = require('polygon-clipping');
|
||||
const sketchIsland = buildIslandFromCrossingEdges([0, 0], [0, 6.8], [-6.8, 0]);
|
||||
assert.deepEqual(sketchIsland[0], sketchIsland.at(-1));
|
||||
assert.ok(sketchIsland.every(([x, y]) => x <= 0 && y >= 0));
|
||||
const arcMiddle = sketchIsland[7];
|
||||
assert.ok(arcMiddle[1] - arcMiddle[0] < 6.8, 'hypotenuse bends toward the right-angle vertex');
|
||||
for (const crossing of [
|
||||
[
|
||||
[0, 0],
|
||||
[12, 0],
|
||||
[12, 3.4],
|
||||
[0, 3.4],
|
||||
[0, 0],
|
||||
],
|
||||
[
|
||||
[0, 0],
|
||||
[0, -12],
|
||||
[-3.4, -12],
|
||||
[-3.4, 0],
|
||||
[0, 0],
|
||||
],
|
||||
])
|
||||
assert.deepEqual(clipping.intersection([sketchIsland], [crossing]), [], 'short-edge attachment has no area overlap');
|
||||
const rotate = ([x, y]) => [-y + 20, x - 10];
|
||||
const rotatedIsland = buildIslandFromCrossingEdges(
|
||||
...[
|
||||
[0, 0],
|
||||
[0, 6.8],
|
||||
[-6.8, 0],
|
||||
].map(rotate),
|
||||
);
|
||||
rotatedIsland.forEach((p, i) =>
|
||||
assert.ok(
|
||||
Math.hypot(...p.map((v, j) => v - rotate(sketchIsland[i])[j])) < 1e-10,
|
||||
'composition is independent of world orientation',
|
||||
),
|
||||
);
|
||||
|
||||
const { stripeLayout, orthogonalCrossingHeadings } = require('../src/compile/junction-facility-composition');
|
||||
for (const span of [3.4, 8.123, 31.7]) {
|
||||
const layout = stripeLayout(span);
|
||||
for (let i = 1; i < layout.centers.length; i++)
|
||||
assert.ok(Math.abs(layout.centers[i] - layout.centers[i - 1] - layout.width - layout.gap) < 1e-10);
|
||||
assert.ok(layout.centers[0] >= layout.width / 2);
|
||||
assert.ok(layout.centers.at(-1) + layout.width / 2 <= span + 1e-10);
|
||||
}
|
||||
const fitted = orthogonalCrossingHeadings([62.2, 150.4, 240.7, 332]);
|
||||
for (let i = 1; i < 4; i++) assert.ok(Math.abs(fitted[i] - fitted[i - 1] - 90) < 1e-10);
|
||||
assert.deepEqual(orthogonalCrossingHeadings([0, 120, 240]), [0, 120, 240]);
|
||||
assert.deepEqual(orthogonalCrossingHeadings([0, 40, 180, 270]), [0, 40, 180, 270]);
|
||||
|
||||
const { crossingArcSupport } = require('../src/compile/junction-facility-composition');
|
||||
assert.ok(!sketchIsland.some(([x, y]) => x === 0 && y === 0), 'right-angle vertex is rounded');
|
||||
assert.ok(!sketchIsland.some(([x, y]) => x === 0 && y === 6.8), 'first arc/leg vertex is rounded');
|
||||
assert.ok(!sketchIsland.some(([x, y]) => x === -6.8 && y === 0), 'second arc/leg vertex is rounded');
|
||||
// Curve support must consider the ends of a finite-width bar, not only its centre.
|
||||
const curved = [
|
||||
[-3, 2],
|
||||
[-1, 0],
|
||||
[1, 0],
|
||||
[3, 2],
|
||||
[3, -2],
|
||||
[-3, -2],
|
||||
[-3, 2],
|
||||
];
|
||||
assert.equal(crossingArcSupport(curved, 2), 1);
|
||||
assert.deepEqual(
|
||||
clipping.intersection(
|
||||
[curved],
|
||||
[
|
||||
[
|
||||
[-2, 1],
|
||||
[2, 1],
|
||||
[2, 1.42],
|
||||
[-2, 1.42],
|
||||
[-2, 1],
|
||||
],
|
||||
],
|
||||
),
|
||||
[],
|
||||
);
|
||||
Reference in new issue
Block a user