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:
1 parent
84c82f3f09
commit
f3924caa5c
10 files changed
+176
-13
No files matched your search
@@ -25,6 +25,7 @@ const SOLVED_KINDS = new Set([
|
||||
'junction-cutback',
|
||||
'junction-corner-radius',
|
||||
'junction-crosswalk-inset',
|
||||
'junction-crosswalk-size',
|
||||
'junction-stop-line-offset',
|
||||
]);
|
||||
const KINDS = [
|
||||
@@ -35,6 +36,7 @@ const KINDS = [
|
||||
'junction-cutback',
|
||||
'junction-corner-radius',
|
||||
'junction-crosswalk-inset',
|
||||
'junction-crosswalk-size',
|
||||
'junction-stop-line-offset',
|
||||
];
|
||||
const MIN_LANE_WIDTH_METERS = 2.4;
|
||||
@@ -47,9 +49,19 @@ const MIN_STOP_LINE_OFFSET_METERS = 0.5;
|
||||
// These live here rather than in native-road.js because the solver must stay free
|
||||
// of fs/path — a test asserts that — so the dependency can only point this way.
|
||||
const CROSSWALK_JUNCTION_INSET_METERS = 1.5;
|
||||
// Zebra geometry. Depth runs along the approach; the span across the road is
|
||||
// `stripeCount * pitch`, not a stored number, because stripe and gap widths are
|
||||
// standardised while the road they cross is not. Pitch is not editable this phase.
|
||||
const CROSSWALK_DEPTH_METERS = 3;
|
||||
const CROSSWALK_STRIPE_WIDTH_METERS = 0.45;
|
||||
const CROSSWALK_STRIPE_PITCH_METERS = 0.9;
|
||||
const MIN_CROSSWALK_DEPTH_METERS = 1;
|
||||
const MAX_CROSSWALK_DEPTH_METERS = 12;
|
||||
const MIN_CROSSWALK_STRIPE_COUNT = 2;
|
||||
const MAX_CROSSWALK_STRIPE_COUNT = 40;
|
||||
const STOP_LINE_OFFSET_METERS = 2.7;
|
||||
/** Junction-anchored but owned by the main map, unlike the junction shape kinds. */
|
||||
const CONTROL_KINDS = new Set(['junction-crosswalk-inset', 'junction-stop-line-offset']);
|
||||
const CONTROL_KINDS = new Set(['junction-crosswalk-inset', 'junction-crosswalk-size', 'junction-stop-line-offset']);
|
||||
const GEOMETRY_VERSION = 'native-road-package/v1.1';
|
||||
|
||||
function emptyHandleManifest(context) {
|
||||
@@ -424,6 +436,35 @@ function applyJunctionConstraint(model, constraint, junctionPlans, junctionData,
|
||||
entry.crosswalkInsetMeters = inset;
|
||||
return true;
|
||||
}
|
||||
case 'junction-crosswalk-size': {
|
||||
const depth = Number(constraint.value?.depthMeters);
|
||||
const stripeCount = constraint.value?.stripeCount;
|
||||
if (!Number.isFinite(depth) || depth < MIN_CROSSWALK_DEPTH_METERS || depth > MAX_CROSSWALK_DEPTH_METERS) {
|
||||
blocking(
|
||||
diagnostics,
|
||||
constraint,
|
||||
'direct-edit-crosswalk-depth-invalid',
|
||||
`斑马线进深必须在 ${MIN_CROSSWALK_DEPTH_METERS} 到 ${MAX_CROSSWALK_DEPTH_METERS} 米之间。`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
!Number.isInteger(stripeCount) ||
|
||||
stripeCount < MIN_CROSSWALK_STRIPE_COUNT ||
|
||||
stripeCount > MAX_CROSSWALK_STRIPE_COUNT
|
||||
) {
|
||||
blocking(
|
||||
diagnostics,
|
||||
constraint,
|
||||
'direct-edit-crosswalk-stripes-invalid',
|
||||
`斑马线条带数必须是 ${MIN_CROSSWALK_STRIPE_COUNT} 到 ${MAX_CROSSWALK_STRIPE_COUNT} 之间的整数。`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
entry.crosswalkDepthMeters = depth;
|
||||
entry.crosswalkStripeCount = stripeCount;
|
||||
return true;
|
||||
}
|
||||
case 'junction-stop-line-offset': {
|
||||
const offset = Number(constraint.value?.offsetMeters);
|
||||
if (!Number.isFinite(offset) || offset < MIN_STOP_LINE_OFFSET_METERS || offset > approach.length * 0.45) {
|
||||
@@ -874,6 +915,11 @@ function resolveDirectEditConstraints(model, editDocument = null, context = {})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
CROSSWALK_DEPTH_METERS,
|
||||
CROSSWALK_STRIPE_PITCH_METERS,
|
||||
CROSSWALK_STRIPE_WIDTH_METERS,
|
||||
MAX_CROSSWALK_STRIPE_COUNT,
|
||||
MIN_CROSSWALK_STRIPE_COUNT,
|
||||
CROSSWALK_JUNCTION_INSET_METERS,
|
||||
STOP_LINE_OFFSET_METERS,
|
||||
RESOLUTION_SCHEMA,
|
||||
|
||||
Reference in new issue
Block a user