feat(junction): enable complex carriageway width editing
This commit is contained in:
1 parent
56647fcdaa
commit
c4bcbe8ff9
22 files changed
+449
-52
No files matched your search
@@ -82,7 +82,14 @@ export function JunctionWorkspace({
|
||||
onSignalStatus,
|
||||
onUpdateSignal,
|
||||
}: Props) {
|
||||
const editable = useMemo(() => canEditJunction(descriptor), [descriptor]);
|
||||
const editable = useMemo(
|
||||
() =>
|
||||
canEditJunction(
|
||||
descriptor,
|
||||
handles.some((handle) => handle.editable),
|
||||
),
|
||||
[descriptor, handles],
|
||||
);
|
||||
const complexEnabled = useMemo(() => {
|
||||
const nodes = new Set(descriptor.nodeIds.map(String));
|
||||
return Boolean(
|
||||
@@ -187,7 +194,11 @@ export function JunctionWorkspace({
|
||||
</div>
|
||||
<p>
|
||||
{complexEnabled
|
||||
? '当前按复杂路口渲染'
|
||||
? editable
|
||||
? editMode
|
||||
? '可编辑外部车行道宽度'
|
||||
: '当前按复杂路口渲染,开启编辑后可调整外部车行道宽度'
|
||||
: '当前按复杂路口渲染'
|
||||
: descriptor.status === 'candidate'
|
||||
? '当前按普通路口渲染,可切换为复杂路口'
|
||||
: editable
|
||||
@@ -505,9 +516,7 @@ export function JunctionWorkspace({
|
||||
</div>
|
||||
</>
|
||||
) : editable ? (
|
||||
<p className="junction-workspace__browse-hint">
|
||||
开启编辑模式后,这里会显示进口宽度、进口收口距离和角部圆角控件。
|
||||
</p>
|
||||
<p className="junction-workspace__browse-hint">开启编辑模式后,这里会显示可调整的路口几何参数。</p>
|
||||
) : complexEnabled ? (
|
||||
<p className="junction-workspace__browse-hint">复杂路口几何已启用;首版仅支持查看,不支持参数拖拽编辑。</p>
|
||||
) : null}
|
||||
|
||||
@@ -76,4 +76,23 @@ describe('junction handle labels', () => {
|
||||
),
|
||||
).toBe('道路2 · 东进口 · 进口收口距离');
|
||||
});
|
||||
|
||||
it('names a complex carriageway by its source road', () => {
|
||||
expect(
|
||||
junctionLabelForHandle(
|
||||
handle(
|
||||
{
|
||||
type: 'cluster-carriageway',
|
||||
clusterId: 'cluster-1',
|
||||
carriagewayKey: 'cluster:cluster-1:carriageway:stable',
|
||||
sourceNodeIds: ['junction'],
|
||||
sourceRoadIds: ['road-north'],
|
||||
},
|
||||
'cluster-carriageway-width',
|
||||
),
|
||||
roads as unknown as Road[],
|
||||
[120, 30],
|
||||
),
|
||||
).toBe('创新大道 · 北进口 · 车行道宽度');
|
||||
});
|
||||
});
|
||||
@@ -58,5 +58,10 @@ export function junctionLabelForHandle(handle: EditHandle, roads: Road[], juncti
|
||||
const road = roadForKey(roads, handle.anchor.roadId) ?? roadForKey(roads, handle.anchor.segmentId);
|
||||
return `${approachName(road, roads, junction)} · ${base}`;
|
||||
}
|
||||
const clusterAnchor = handle.anchor;
|
||||
if (handle.kind === 'cluster-carriageway-width' && clusterAnchor.type === 'cluster-carriageway') {
|
||||
const road = roads.find((item) => clusterAnchor.sourceRoadIds.includes(item.id));
|
||||
return `${approachName(road, roads, junction)} · ${base}`;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
@@ -32,8 +32,9 @@ describe('junction workspace session', () => {
|
||||
expect(leaveJunctionSession(session, 'apply')?.status).toBe('applied');
|
||||
});
|
||||
|
||||
it('only ordinary editable nodes can be changed', () => {
|
||||
it('opens a cluster when the server published editable handles', () => {
|
||||
expect(canEditJunction(node as never)).toBe(true);
|
||||
expect(canEditJunction(cluster as never)).toBe(false);
|
||||
expect(canEditJunction(cluster as never, true)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -46,6 +46,6 @@ export function leaveJunctionSession(session: JunctionSession, action: LeaveActi
|
||||
return applyJunctionDraft(session);
|
||||
}
|
||||
|
||||
export function canEditJunction(descriptor: JunctionDescriptor): boolean {
|
||||
return descriptor.ref.type === 'node' && descriptor.status === 'editable';
|
||||
export function canEditJunction(descriptor: JunctionDescriptor, hasEditableHandles = false): boolean {
|
||||
return (descriptor.ref.type === 'node' && descriptor.status === 'editable') || hasEditableHandles;
|
||||
}
|
||||
Reference in new issue
Block a user