feat(junction): edit complex cutbacks and corners

This commit is contained in:
que01 committed 2026-09-08 14:30:43 +08:00
1 parent d0e1f62f2b
commit 80f122be46
15 files changed
+354 -38

No files matched your search

+54 -2
View File
@@ -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,