fix: publish the crosswalk inset ceiling that actually moves the zebra
Every junction-crosswalk-inset handle advertised max 8. Sweeping the real response across eight groups, the ceiling ran 1.0 to 4.5 and varied per approach, so 44-88% of the declared range moved nothing and returned no diagnostic. Two approaches had a ceiling at or below the 1.5 default, meaning dragging outward there did nothing at all — which is what made direct editing look broken rather than limited. crossingJunctionInset() stops responding once the inset reaches the cutback, and sooner still when the crossing sits beyond the 4m cap, giving cutback - max(0, junctionDistance - 4). Predicted ceilings matched all eight measurements within the 0.5m sweep step, and the published max now matches them 8/8 where it used to be a flat 8. The distance needs to know which crossing an approach serves, which lived only inside compileControlMarkings(). crossing-approach.js now holds that rule at road level, which is model-only and so usable from the solver. Behaviour is unchanged: every lane of a road shares its junction distance, so the compiler's (road, lane) ordering already grouped by road — fixtures confirm the geometry is byte-identical. Both directional roads of a segment can meet at one junction serving different crossings; taking the first match published one road's ceiling on the other's handle. The road that ends at this node wins, which is the same rule the client uses to find the handle and the same one crossingJunctionInset() applies. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8a039f47ab
commit
479ffd00ed
3 files changed
+184
-3
No files matched your search
@@ -499,6 +499,43 @@ const stopOnly = resolveDirectEditConstraints(
|
||||
).junctionPlans.get('junction').approaches['segment:a'];
|
||||
assert.equal(stopOnly.cutbackMeters !== 4, true, 'a stop-line offset must not be written as a cutback');
|
||||
|
||||
// A crosswalk-inset handle must publish the ceiling that still moves the zebra.
|
||||
//
|
||||
// `crossingJunctionInset()` saturates once the inset reaches the cutback, and
|
||||
// sooner when the crossing sits far from the junction, so a flat max left 44-88%
|
||||
// of the declared range moving nothing and saying nothing. The ceiling is
|
||||
// `cutback - max(0, junctionDistance - 4)`.
|
||||
{
|
||||
const { effectiveCrosswalkInsetMax, approachForCrossing } = require('../src/compile/crossing-approach');
|
||||
assert.equal(effectiveCrosswalkInsetMax(9.1, 9.89).toFixed(2), '3.21');
|
||||
// Distance under the 4m cap cannot pull the ceiling below the cutback.
|
||||
assert.equal(effectiveCrosswalkInsetMax(9.1, 2), 9.1);
|
||||
assert.equal(effectiveCrosswalkInsetMax(NaN, 5), null);
|
||||
|
||||
// Both directional roads of one segment can meet at a junction, each serving a
|
||||
// different crossing. Picking the first match published one road's ceiling on
|
||||
// the other's handle, so the road that actually ends at this node has to win.
|
||||
const centerline = (lon) => [
|
||||
[lon, 0],
|
||||
[lon, 0.001],
|
||||
];
|
||||
const twoWay = {
|
||||
roads: [
|
||||
{ id: 'r:fwd', segmentId: 'seg', centerline: centerline(0), sourceNodeIds: ['a', 'far'], osmWayIds: ['w'] },
|
||||
{ id: 'r:bwd', segmentId: 'seg', centerline: centerline(0), sourceNodeIds: ['a', 'near'], osmWayIds: ['w'] },
|
||||
],
|
||||
endpoints: [],
|
||||
connections: [
|
||||
{ enabled: true, fromEndpointId: 'endpoint:r:fwd:end', nodeId: 'far' },
|
||||
{ enabled: true, fromEndpointId: 'endpoint:r:bwd:end', nodeId: 'near' },
|
||||
],
|
||||
crossings: [{ id: 'x', osmWayIds: ['w'], coordinate: [0, 0.0009] }],
|
||||
};
|
||||
const paired = approachForCrossing(twoWay, twoWay.crossings[0]);
|
||||
assert.ok(paired, 'a crossing on a two-way segment must still pair with one road');
|
||||
assert.equal(paired.road.segmentId, 'seg');
|
||||
}
|
||||
|
||||
// The solver must be free of file and network access so preview can share it.
|
||||
const source = require('fs').readFileSync(require.resolve('../src/compile/direct-edit-solver'), 'utf8');
|
||||
for (const forbidden of ["require('fs')", "require('path')", "require('http')", "require('https')"])
|
||||
|
||||
Reference in new issue
Block a user