feat: make crosswalk size a constraint the geometry stage reads

Every zebra was six stripes at 3m by 0.45m on a 0.9m pitch, all literals. Depth
and stripe count are now a constraint, junction-crosswalk-size, and the loop
reads them.

The span across the road stays derived rather than stored: it is count times
pitch, and pitch is fixed because stripe and gap widths are standardised while
the road they cross is not. Widening a crossing means adding stripes, which is
what a real one does, and it is why the span quantises in 0.9m steps.

That also fixes a span pinned at 4.95m regardless of the street. Measured, every
crossing sat on a 6.50m carriageway and covered under four fifths of it. The
default now follows the segment width — both directions, since a crossing spans
the carriageway — giving eight stripes and 6.74m, reaching the kerb rather than
stopping short. Fixture baselines move for exactly two entries on the one area
with crossings; the area without them is untouched.

No handle is published yet. design.md requires proving compileGeometry() consumes
a parameter before any grip is drawn — the rule left over from profile.interval
shipping a handle that did nothing — so the grips come next, on a value already
known to work.

Adding the kind made the client's exhaustive scalar switch fail to compile, which
is the check working: size is a pair and has no dragged-scalar form, so that case
now says so and throws rather than writing half a value.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
que01andClaude Opus 5 committed 2026-08-31 17:10:45 +08:00
1 parent 84c82f3f09
commit f3924caa5c
10 files changed
+176 -13

No files matched your search

@@ -7,7 +7,7 @@
"bytes": 18111
},
"comparison.json": {
"contentHash": "d8d4fc7d72527fce08c766f1619777a69813080a2def35652c402edd55a64a2e",
"contentHash": "11a057394a8023953386c4dc2b35022281eaf7a5d61f989a82b4f43c33d64a32",
"bytes": 1015
},
"compiled.json": {
@@ -27,8 +27,8 @@
"bytes": 99978
},
"layers/crosswalks.geojson": {
"contentHash": "72079521c1f6891b77b226b87ee3656c113f3a72c4fb51981dfdaa9dafc4eeb2",
"bytes": 28012
"contentHash": "3123c6f4ae5f35e91aff854576df6131d20341d6297451fe262b9eed4c7f1cc1",
"bytes": 37342
},
"layers/direction_arrows.geojson": {
"contentHash": "5e60d48520fa09aa75a8aa9bb89c4701c7f5dabc4e5ce57c9dc87bdefbbf3d1c",
+31
View File
@@ -499,6 +499,37 @@ 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');
// Crosswalk size reaches the geometry, and bad values are refused rather than
// clamped. The kind exists only because compileGeometry() reads it — the rule
// design.md sets after `profile.interval` shipped a handle that did nothing.
{
const sized = resolveDirectEditConstraints(
controlModel,
document([controlConstraint('junction-crosswalk-size', { depthMeters: 4, stripeCount: 10 })]),
{},
);
const plan = sized.junctionPlans.get('junction').approaches['segment:a'];
assert.equal(plan.crosswalkDepthMeters, 4);
assert.equal(plan.crosswalkStripeCount, 10);
for (const [value, rule] of [
[{ depthMeters: 0, stripeCount: 8 }, 'direct-edit-crosswalk-depth-invalid'],
[{ depthMeters: 3, stripeCount: 1 }, 'direct-edit-crosswalk-stripes-invalid'],
[{ depthMeters: 3, stripeCount: 6.5 }, 'direct-edit-crosswalk-stripes-invalid'],
]) {
const bad = resolveDirectEditConstraints(
controlModel,
document([controlConstraint('junction-crosswalk-size', value)]),
{},
);
assert.equal(bad.constraintStates[0].applied, false);
assert.ok(
bad.diagnostics.some((item) => item.rule === rule),
`${JSON.stringify(value)} must produce ${rule}`,
);
}
}
// A crosswalk-inset handle must publish the ceiling that still moves the zebra.
//
// `crossingJunctionInset()` saturates once the inset reaches the cutback, and
+3
View File
@@ -47,6 +47,8 @@ function valueFor(kind) {
return { radiusMeters: 6 };
case 'junction-crosswalk-inset':
return { insetMeters: 1.5 };
case 'junction-crosswalk-size':
return { depthMeters: 3, stripeCount: 8 };
case 'junction-stop-line-offset':
return { offsetMeters: 2.7 };
default:
@@ -100,6 +102,7 @@ assert.deepEqual(CONSTRAINT_KINDS, [
'junction-cutback',
'junction-corner-radius',
'junction-crosswalk-inset',
'junction-crosswalk-size',
'junction-stop-line-offset',
]);