feat(junction): edit complex crossing facilities

This commit is contained in:
que01 committed 2026-09-08 15:05:00 +08:00
1 parent bb5dc01c07
commit 49a44fdf73
16 files changed
+307 -39

No files matched your search

+7 -2
View File
@@ -248,8 +248,13 @@ test.describe('workbench editing shell', () => {
expect(
scoped.handles.handles.every(
(handle: { kind: string; editable: boolean }) =>
['cluster-carriageway-width', 'cluster-carriageway-cutback', 'cluster-corner-radius'].includes(handle.kind) &&
handle.editable,
[
'cluster-carriageway-width',
'cluster-carriageway-cutback',
'cluster-corner-radius',
'cluster-crossing-inset',
'cluster-stop-line-offset',
].includes(handle.kind) && handle.editable,
),
).toBe(true);
expect(scoped.junctionStructure.topologyFingerprint).toBe(structure.topologyFingerprint);
+13
View File
@@ -40,6 +40,13 @@ function anchorFor(kind) {
cornerKey: 'corner:one>two',
carriagewayKeys: ['carriageway:one', 'carriageway:two'],
};
if (type === 'cluster-crossing')
return {
type,
clusterId: 'cluster/9',
crossingKey: 'crossing:cluster:cluster%2F9:arm:one',
carriagewayKeys: ['carriageway:one'],
};
if (type === 'lane') return { type, laneId: 'lane:road:way/1:forward:1' };
return { type, nodeId: 'node/9', incomingRoadId: 'road:way/1:forward', outgoingRoadId: 'road:way/2:forward' };
}
@@ -63,6 +70,10 @@ function valueFor(kind) {
return { cutbackMeters: 4 };
case 'cluster-corner-radius':
return { radiusMeters: 6 };
case 'cluster-crossing-inset':
return { insetMeters: 1.5 };
case 'cluster-stop-line-offset':
return { offsetMeters: 2.7 };
case 'junction-cutback':
return { cutbackMeters: 4 };
case 'junction-corner-radius':
@@ -126,6 +137,8 @@ assert.deepEqual(CONSTRAINT_KINDS, [
'cluster-carriageway-width',
'cluster-carriageway-cutback',
'cluster-corner-radius',
'cluster-crossing-inset',
'cluster-stop-line-offset',
'junction-cutback',
'junction-corner-radius',
'junction-crosswalk-inset',
+51 -1
View File
@@ -258,7 +258,13 @@ const complexArea = compileInput(complexInput).area;
const clusterState = editState(complexArea, selectionFrom({ cluster: cluster.id }));
assert.ok(
clusterState.handles.handles.every((handle) =>
['cluster-carriageway-width', 'cluster-carriageway-cutback', 'cluster-corner-radius'].includes(handle.kind),
[
'cluster-carriageway-width',
'cluster-carriageway-cutback',
'cluster-corner-radius',
'cluster-crossing-inset',
'cluster-stop-line-offset',
].includes(handle.kind),
),
'cluster selection publishes only scoped complex geometry handles',
);
@@ -322,6 +328,50 @@ assert.notDeepEqual(
complexSurface(clusterPreview).geometry,
'a cluster carriageway constraint must change compiled complex geometry',
);
const complexCrossingHandle = clusterState.handles.handles.find((handle) => handle.kind === 'cluster-crossing-inset');
assert.ok(complexCrossingHandle, 'the complex fixture must publish grouped crossing handles');
const complexCrossingConstraint = {
id: 'constraint:complex-crossing',
kind: 'cluster-crossing-inset',
anchor: complexCrossingHandle.anchor,
anchorSnapshot: {
coordinate: complexCrossingHandle.position,
tangentAzimuth: complexCrossingHandle.axisAzimuth,
roadLengthMeters: 120,
osmNodeIds: cluster.nodeIds,
},
value: { insetMeters: complexCrossingHandle.value.max },
enabled: true,
status: 'exact',
provenance: { operationId: 'operation:complex-crossing', createdAt: '2026-09-08T00:00:00.000Z' },
};
const movedCrossingPreview = editPreview(complexArea, {
document: {
...emptyDocument,
constraints: [complexCrossingConstraint],
operations: [
{
id: 'operation:complex-crossing',
createdAt: '2026-09-08T00:00:00.000Z',
constraintIds: [complexCrossingConstraint.id],
},
],
},
selection: { cluster: cluster.id },
});
const crossingGeometry = (preview) =>
preview.layers.crosswalks.features.find(
(feature) => feature.properties.crossing_key === complexCrossingHandle.anchor.crossingKey,
)?.geometry;
assert.deepEqual(
movedCrossingPreview.constraintStates?.map((state) => state.applied),
[true],
);
assert.notDeepEqual(
crossingGeometry(movedCrossingPreview),
crossingGeometry(clusterPreview),
'a complex crossing inset must move only its keyed stripe group',
);
const complexCornerHandle = clusterState.handles.handles.find((handle) => handle.kind === 'cluster-corner-radius');
assert.ok(complexCornerHandle, 'the complex fixture must publish stable corner-radius handles');
const complexCornerConstraint = {