fix: 保存车行道左右边界编辑状态
This commit is contained in:
1 parent
f1a5b284a7
commit
44fa82299b
3 files changed
+59
-9
No files matched your search
@@ -1005,7 +1005,11 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
? clusterEdgeOffsets
|
||||
: clusterCutbacks;
|
||||
if (!target.has(item.clusterId)) target.set(item.clusterId, new Map());
|
||||
target.get(item.clusterId).set(item.key, value);
|
||||
if (constraint.kind === 'cluster-carriageway-edge-offset' && constraint.anchor.side) {
|
||||
const previous = target.get(item.clusterId).get(item.key) || { leftOffsetMeters: 0, rightOffsetMeters: 0 };
|
||||
const field = `${constraint.anchor.side}OffsetMeters`;
|
||||
target.get(item.clusterId).set(item.key, { ...previous, [field]: value[field] });
|
||||
} else target.get(item.clusterId).set(item.key, value);
|
||||
applied = true;
|
||||
}
|
||||
} else if (constraint.kind === 'cluster-corner-radius') {
|
||||
@@ -1621,12 +1625,17 @@ function makeClusterCarriagewayHandles(model, junctionData, constraints, cluster
|
||||
editable: true,
|
||||
});
|
||||
}
|
||||
const edgeConstraint = constraintFor(constraints, 'cluster-carriageway-edge-offset', {
|
||||
clusterId,
|
||||
carriagewayKey: item.key,
|
||||
});
|
||||
const edgeValue = edgeConstraint?.value || {};
|
||||
for (const side of ['left', 'right']) {
|
||||
const candidates = constraints.filter(
|
||||
(edit) =>
|
||||
edit.enabled !== false &&
|
||||
edit.kind === 'cluster-carriageway-edge-offset' &&
|
||||
edit.anchor.clusterId === clusterId &&
|
||||
edit.anchor.carriagewayKey === item.key &&
|
||||
(!edit.anchor.side || edit.anchor.side === side),
|
||||
);
|
||||
const edgeConstraint = candidates.at(-1);
|
||||
const edgeValue = edgeConstraint?.value || {};
|
||||
handles.push({
|
||||
handleId: `handle:cluster-carriageway-edge-offset:${side}:${item.key}`,
|
||||
kind: 'cluster-carriageway-edge-offset',
|
||||
@@ -1641,7 +1650,7 @@ function makeClusterCarriagewayHandles(model, junctionData, constraints, cluster
|
||||
position: point,
|
||||
axisAzimuth: (tangentAzimuth(line, station) + (side === 'left' ? 270 : 90)) % 360,
|
||||
value: { current: Number(edgeValue[`${side}OffsetMeters`]) || 0, min: -10, max: 10, unit: 'meter' },
|
||||
...(edgeConstraint ? { constraintId: edgeConstraint.id } : {}),
|
||||
...(edgeConstraint?.anchor.side === side ? { constraintId: edgeConstraint.id } : {}),
|
||||
affects: [`complex-junction:${clusterId}:carriageway:${item.approach.segmentId}`],
|
||||
editable: true,
|
||||
});
|
||||
|
||||
@@ -446,6 +446,43 @@ for (const [kind, value, resultKey] of [
|
||||
);
|
||||
assert.equal(result.clusterCutbacks.size, 0);
|
||||
}
|
||||
for (const sides of [
|
||||
['left', 'right'],
|
||||
['right', 'left'],
|
||||
]) {
|
||||
const result = resolveDirectEditConstraints(
|
||||
junctionModel,
|
||||
document(
|
||||
sides.map((side) =>
|
||||
constraint({
|
||||
id: `edge-${side}`,
|
||||
kind: 'cluster-carriageway-edge-offset',
|
||||
anchor: { ...clusterWidthHandle.anchor, side },
|
||||
value:
|
||||
side === 'left'
|
||||
? { leftOffsetMeters: 0.4, rightOffsetMeters: 0 }
|
||||
: { leftOffsetMeters: 0, rightOffsetMeters: 0.7 },
|
||||
}),
|
||||
),
|
||||
),
|
||||
{ junctionClusters: [{ id: 'cluster-1', nodeIds: ['junction'] }] },
|
||||
);
|
||||
assert.ok(result.constraintStates.every((state) => state.applied));
|
||||
assert.deepEqual(result.clusterEdgeOffsets.get('cluster-1').get(clusterWidthHandle.anchor.carriagewayKey), {
|
||||
leftOffsetMeters: 0.4,
|
||||
rightOffsetMeters: 0.7,
|
||||
});
|
||||
for (const side of sides) {
|
||||
const handle = result.handles.handles.find(
|
||||
(handle) =>
|
||||
handle.kind === 'cluster-carriageway-edge-offset' &&
|
||||
handle.anchor.carriagewayKey === clusterWidthHandle.anchor.carriagewayKey &&
|
||||
handle.anchor.side === side,
|
||||
);
|
||||
assert.equal(handle.constraintId, `edge-${side}`);
|
||||
assert.equal(handle.value.current, side === 'left' ? 0.4 : 0.7);
|
||||
}
|
||||
}
|
||||
const recheckResolution = resolveDirectEditConstraints(
|
||||
junctionModel,
|
||||
{ ...document([anchored]), base: { compilerGeometryVersion: 'old-geometry' } },
|
||||
|
||||
@@ -303,9 +303,13 @@ export function ParameterPanel({
|
||||
|
||||
const groupedHandles = new Map<string, EditHandle[]>();
|
||||
for (const handle of handles) {
|
||||
const list = groupedHandles.get(handle.kind) ?? [];
|
||||
const group =
|
||||
handle.kind === 'cluster-carriageway-edge-offset' && handle.anchor.type === 'cluster-carriageway'
|
||||
? `${handle.kind}:${handle.anchor.side}`
|
||||
: handle.kind;
|
||||
const list = groupedHandles.get(group) ?? [];
|
||||
list.push(handle);
|
||||
groupedHandles.set(handle.kind, list);
|
||||
groupedHandles.set(group, list);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user