feat(junction): edit complex cutbacks and corners
This commit is contained in:
1 parent
d0e1f62f2b
commit
80f122be46
15 files changed
+354
-38
No files matched your search
@@ -247,13 +247,17 @@ test.describe('workbench editing shell', () => {
|
||||
expect(scoped.handles.handles.length).toBeGreaterThan(0);
|
||||
expect(
|
||||
scoped.handles.handles.every(
|
||||
(handle: { kind: string; editable: boolean }) => handle.kind === 'cluster-carriageway-width' && handle.editable,
|
||||
(handle: { kind: string; editable: boolean }) =>
|
||||
['cluster-carriageway-width', 'cluster-carriageway-cutback', 'cluster-corner-radius'].includes(handle.kind) &&
|
||||
handle.editable,
|
||||
),
|
||||
).toBe(true);
|
||||
expect(scoped.junctionStructure.topologyFingerprint).toBe(structure.topologyFingerprint);
|
||||
await page.getByRole('button', { name: '开启编辑模式' }).click();
|
||||
await expect(workspace.getByText('路口参数', { exact: true })).toBeVisible();
|
||||
await expect(workspace.getByText(/车行道宽度/).first()).toBeVisible();
|
||||
await expect(workspace.getByText(/车行道收口距离/).first()).toBeVisible();
|
||||
await expect(workspace.getByText(/角部圆角/).first()).toBeVisible();
|
||||
await page.reload();
|
||||
await expect(armButtons).toHaveCount(structure.arms.length);
|
||||
await expect(armButtons.first()).toHaveAttribute('aria-pressed', 'false');
|
||||
|
||||
@@ -33,6 +33,13 @@ function anchorFor(kind) {
|
||||
sourceNodeIds: ['node/9', 'node/10'],
|
||||
sourceRoadIds: ['road:way/1:forward'],
|
||||
};
|
||||
if (type === 'cluster-corner')
|
||||
return {
|
||||
type,
|
||||
clusterId: 'cluster/9',
|
||||
cornerKey: 'corner:one>two',
|
||||
carriagewayKeys: ['carriageway:one', 'carriageway:two'],
|
||||
};
|
||||
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' };
|
||||
}
|
||||
@@ -52,6 +59,10 @@ function valueFor(kind) {
|
||||
return { widthMeters: 12.5 };
|
||||
case 'cluster-carriageway-width':
|
||||
return { widthMeters: 12.5 };
|
||||
case 'cluster-carriageway-cutback':
|
||||
return { cutbackMeters: 4 };
|
||||
case 'cluster-corner-radius':
|
||||
return { radiusMeters: 6 };
|
||||
case 'junction-cutback':
|
||||
return { cutbackMeters: 4 };
|
||||
case 'junction-corner-radius':
|
||||
@@ -113,6 +124,8 @@ assert.deepEqual(CONSTRAINT_KINDS, [
|
||||
'road-lane-divider',
|
||||
'junction-approach-width',
|
||||
'cluster-carriageway-width',
|
||||
'cluster-carriageway-cutback',
|
||||
'cluster-corner-radius',
|
||||
'junction-cutback',
|
||||
'junction-corner-radius',
|
||||
'junction-crosswalk-inset',
|
||||
|
||||
@@ -257,8 +257,10 @@ const complexInput = {
|
||||
const complexArea = compileInput(complexInput).area;
|
||||
const clusterState = editState(complexArea, selectionFrom({ cluster: cluster.id }));
|
||||
assert.ok(
|
||||
clusterState.handles.handles.every((handle) => handle.kind === 'cluster-carriageway-width'),
|
||||
'cluster selection publishes only scoped complex carriageway width handles',
|
||||
clusterState.handles.handles.every((handle) =>
|
||||
['cluster-carriageway-width', 'cluster-carriageway-cutback', 'cluster-corner-radius'].includes(handle.kind),
|
||||
),
|
||||
'cluster selection publishes only scoped complex geometry handles',
|
||||
);
|
||||
assert.ok(clusterState.handles.handles.length, 'the complex fixture must publish editable carriageways');
|
||||
assert.deepEqual(clusterState.junctionStructure.junctionRef, { type: 'cluster', id: cluster.id });
|
||||
@@ -320,6 +322,56 @@ assert.notDeepEqual(
|
||||
complexSurface(clusterPreview).geometry,
|
||||
'a cluster carriageway constraint must change compiled complex geometry',
|
||||
);
|
||||
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 = {
|
||||
id: 'constraint:complex-corner',
|
||||
kind: 'cluster-corner-radius',
|
||||
anchor: complexCornerHandle.anchor,
|
||||
anchorSnapshot: {
|
||||
coordinate: complexCornerHandle.position,
|
||||
tangentAzimuth: complexCornerHandle.axisAzimuth,
|
||||
roadLengthMeters: 120,
|
||||
osmNodeIds: cluster.nodeIds,
|
||||
},
|
||||
value: { radiusMeters: complexCornerHandle.value.min },
|
||||
enabled: true,
|
||||
status: 'exact',
|
||||
provenance: { operationId: 'operation:complex-corner', createdAt: '2026-09-08T00:00:00.000Z' },
|
||||
};
|
||||
const roundedClusterPreview = editPreview(complexArea, {
|
||||
document: {
|
||||
...emptyDocument,
|
||||
constraints: [complexCornerConstraint],
|
||||
operations: [
|
||||
{
|
||||
id: 'operation:complex-corner',
|
||||
createdAt: '2026-09-08T00:00:00.000Z',
|
||||
constraintIds: [complexCornerConstraint.id],
|
||||
},
|
||||
],
|
||||
},
|
||||
selection: { cluster: cluster.id },
|
||||
});
|
||||
assert.deepEqual(
|
||||
roundedClusterPreview.constraintStates?.map((state) => state.applied),
|
||||
[true],
|
||||
);
|
||||
const complexCorner = (preview) =>
|
||||
preview.layers.roadSurface.features.find(
|
||||
(feature) => feature.properties.corner_key === complexCornerHandle.anchor.cornerKey,
|
||||
);
|
||||
assert.ok(complexCorner(clusterPreview), 'the corner handle must identify a compiled corner surface');
|
||||
assert.equal(
|
||||
complexCorner(roundedClusterPreview).properties.corner_radius_m,
|
||||
complexCornerConstraint.value.radiusMeters,
|
||||
'the compiled corner must consume its scoped radius value',
|
||||
);
|
||||
assert.notDeepEqual(
|
||||
complexCorner(roundedClusterPreview).geometry,
|
||||
complexCorner(clusterPreview).geometry,
|
||||
'a cluster corner constraint must change its compiled corner geometry',
|
||||
);
|
||||
const browsing = browseState(complexArea);
|
||||
const unavailableStructureState = browseState({
|
||||
...complexArea,
|
||||
|
||||
Reference in new issue
Block a user