fix: preserve approach lane separators near junction controls
This commit is contained in:
1 parent
ad0f55e79d
commit
062f20f34c
3 files changed
+57
-4
No files matched your search
+1
-1
@@ -8,7 +8,7 @@
|
||||
"road-compiler": "bin/road-compiler.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/index.js && node test/junction-structure.js && node test/connector-trajectories.js && node test/junction-projection.js && node test/junction-build-plan-counterexamples.js && node test/junction-polygon-ops.js && node test/junction-region-solver.js && node test/junction-facility-composition.js && node test/native-road-edits.js && node test/road-revisions.js && node test/direct-edit-solver.js && node test/workbench-edit-api.js && node test/workbench-import-compile.js && node test/fixtures.js",
|
||||
"test": "node test/index.js && node test/junction-structure.js && node test/connector-trajectories.js && node test/junction-projection.js && node test/junction-build-plan-counterexamples.js && node test/junction-polygon-ops.js && node test/junction-region-solver.js && node test/junction-facility-composition.js && node test/junction-marking-containment.js && node test/native-road-edits.js && node test/road-revisions.js && node test/direct-edit-solver.js && node test/workbench-edit-api.js && node test/workbench-import-compile.js && node test/fixtures.js",
|
||||
"test:fixtures:update-baseline": "node test/update-fixture-baselines.js",
|
||||
"road:workbench": "node bin/road-workbench.js",
|
||||
"road:export": "node bin/road-compiler.js",
|
||||
|
||||
@@ -1139,7 +1139,11 @@ function compileComplexLaneSeparators(features, controls = []) {
|
||||
(point[0] + right[pointIndex][0]) / 2,
|
||||
(point[1] + right[pointIndex][1]) / 2,
|
||||
]);
|
||||
const visibleLine = trimLineBeforeFirstControl(line, controls, 0.12);
|
||||
// A control on a crossing arm must not trim this arm's separator. In
|
||||
// oblique and multi-node clusters their envelopes can otherwise overlap
|
||||
// near the core and make the separator disappear entirely.
|
||||
const roadControls = controls.filter((control) => String(control.properties?.road_id || '') === String(roadId));
|
||||
const visibleLine = trimLineBeforeFirstControl(line, roadControls, 0.12);
|
||||
const ring = visibleLine ? roadRing(visibleLine, 0.12) : null;
|
||||
if (!ring) continue;
|
||||
result.push({
|
||||
@@ -1675,6 +1679,9 @@ function compileLaneMarkings(model, overrides, lanes, diagnostics, junctionPlans
|
||||
const cluster = clusterForRoad(road, options);
|
||||
const internalCluster = cluster && roadInternalToCluster(road, cluster);
|
||||
const roadLanes = (lanes.markingByRoadId || lanes.byRoadId).get(road.id) || [];
|
||||
const roadControls = controlFeatures.filter(
|
||||
(control) => String(control.properties?.road_id || '') === String(road.id),
|
||||
);
|
||||
for (let index = 1; index < roadLanes.length; index += 1) {
|
||||
const left = roadLanes[index - 1].coordinates;
|
||||
const right = roadLanes[index].coordinates;
|
||||
@@ -1698,7 +1705,7 @@ function compileLaneMarkings(model, overrides, lanes, diagnostics, junctionPlans
|
||||
provenance: 'native-road-lane-separator/v1',
|
||||
};
|
||||
if (style.pattern === 'solid') {
|
||||
const visibleLine = trimLineBeforeFirstControl(centerline, controlFeatures, 0.12);
|
||||
const visibleLine = trimLineBeforeFirstControl(centerline, roadControls, 0.12);
|
||||
const ring = visibleLine ? roadRing(visibleLine, 0.12) : null;
|
||||
if (ring)
|
||||
separators.push({
|
||||
@@ -1707,7 +1714,7 @@ function compileLaneMarkings(model, overrides, lanes, diagnostics, junctionPlans
|
||||
geometry: { type: 'Polygon', coordinates: [ring] },
|
||||
});
|
||||
} else {
|
||||
const visibleLine = trimLineBeforeFirstControl(centerline, controlFeatures, 0.12);
|
||||
const visibleLine = trimLineBeforeFirstControl(centerline, roadControls, 0.12);
|
||||
const visibleLength = visibleLine ? lineLengthMeters(visibleLine) : 0;
|
||||
for (let distance = 1, part = 1; visibleLine && distance + 1 <= visibleLength; distance += 4, part += 1) {
|
||||
const placement = pointAndAxisAlongLine(visibleLine, distance);
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert/strict');
|
||||
const fs = require('fs');
|
||||
const { compileRoadModel, compileGeometry } = require('../src/compile/native-road');
|
||||
|
||||
const clusterNodeIds = new Set(['8005332807', '8024512135', '8024512145', '8024512147']);
|
||||
const model = compileRoadModel(fs.readFileSync('./inputs/osm/枫树二路.osm', 'utf8'), { overrides: [] });
|
||||
const geometry = compileGeometry(
|
||||
model,
|
||||
{ overrides: [] },
|
||||
{
|
||||
edgeLines: false,
|
||||
junctionTemplates: {
|
||||
enabled: true,
|
||||
clusters: [
|
||||
{
|
||||
id: 'marking-containment',
|
||||
template: 'complex-junction-v1',
|
||||
coreRadiusMeters: 21,
|
||||
nodeIds: [...clusterNodeIds],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const previewRoads = new Set(
|
||||
geometry.laneCenterlines.features
|
||||
.filter((feature) => feature.properties.cluster_preview)
|
||||
.map((feature) => feature.properties.road_id),
|
||||
);
|
||||
const separatorsByRoad = new Map();
|
||||
for (const feature of geometry.laneSeparators.features) {
|
||||
const roadId = feature.properties.road_id;
|
||||
separatorsByRoad.set(roadId, (separatorsByRoad.get(roadId) || 0) + 1);
|
||||
}
|
||||
|
||||
for (const road of model.roads.filter((candidate) => previewRoads.has(candidate.id))) {
|
||||
const internal = road.sourceNodeIds.every((nodeId) => clusterNodeIds.has(String(nodeId)));
|
||||
const count = separatorsByRoad.get(road.id) || 0;
|
||||
if (internal) assert.equal(count, 0, `${road.id} is internal and should not publish separators`);
|
||||
else assert.ok(count > 0, `${road.id} lost all approach separators after control trimming`);
|
||||
}
|
||||
|
||||
console.log('junction marking containment tests passed');
|
||||
Reference in new issue
Block a user