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
@@ -266,8 +266,10 @@ function App() {
|
||||
if (junctionDescriptor.ref.type === 'cluster')
|
||||
return manifest.handles.filter(
|
||||
(handle) =>
|
||||
handle.kind === 'cluster-carriageway-width' &&
|
||||
handle.anchor.type === 'cluster-carriageway' &&
|
||||
(handle.kind === 'cluster-carriageway-width' ||
|
||||
handle.kind === 'cluster-carriageway-cutback' ||
|
||||
handle.kind === 'cluster-corner-radius') &&
|
||||
'clusterId' in handle.anchor &&
|
||||
handle.anchor.clusterId === junctionDescriptor.ref.id,
|
||||
);
|
||||
const nodeIds = new Set(junctionDescriptor.nodeIds.map(String));
|
||||
@@ -486,12 +488,23 @@ function App() {
|
||||
// control handles silently returned null and never scheduled a preview.
|
||||
const roadId = 'roadId' in handle.anchor ? handle.anchor.roadId : null;
|
||||
const sourceRoadId = handle.anchor.type === 'cluster-carriageway' ? handle.anchor.sourceRoadIds[0] : null;
|
||||
const cornerAnchor = handle.anchor.type === 'cluster-corner' ? handle.anchor : null;
|
||||
const cornerHandle = cornerAnchor
|
||||
? manifest?.handles.find(
|
||||
(candidate) =>
|
||||
candidate.anchor.type === 'cluster-carriageway' &&
|
||||
cornerAnchor.carriagewayKeys.includes(candidate.anchor.carriagewayKey),
|
||||
)
|
||||
: undefined;
|
||||
const cornerSourceRoadId =
|
||||
cornerHandle?.anchor.type === 'cluster-carriageway' ? cornerHandle.anchor.sourceRoadIds[0] : null;
|
||||
const segmentId = 'segmentId' in handle.anchor ? handle.anchor.segmentId : null;
|
||||
const cornerRoadId = handle.anchor.type === 'junction-corner' ? handle.anchor.incomingRoadId : null;
|
||||
const road = state?.compiled.model.roads.find(
|
||||
(item) =>
|
||||
(roadId ? item.id === roadId : false) ||
|
||||
(sourceRoadId ? item.id === sourceRoadId : false) ||
|
||||
(cornerSourceRoadId ? item.id === cornerSourceRoadId : false) ||
|
||||
(segmentId ? item.segmentId === segmentId : false) ||
|
||||
(cornerRoadId ? item.id === cornerRoadId || item.segmentId === cornerRoadId : false),
|
||||
);
|
||||
|
||||
@@ -114,6 +114,8 @@ const KIND_LABELS: Record<ConstraintKind, string> = {
|
||||
'road-lane-divider': '车道分隔',
|
||||
'junction-approach-width': '进口宽度',
|
||||
'cluster-carriageway-width': '车行道宽度',
|
||||
'cluster-carriageway-cutback': '车行道收口距离',
|
||||
'cluster-corner-radius': '角部圆角',
|
||||
'junction-cutback': '进口收口距离',
|
||||
'junction-corner-radius': '角部圆角',
|
||||
'junction-crosswalk-inset': '斑马线退让',
|
||||
|
||||
@@ -104,6 +104,10 @@ export function constraintValueFor(
|
||||
case 'junction-approach-width':
|
||||
case 'cluster-carriageway-width':
|
||||
return { widthMeters: Math.max(0, scalar) };
|
||||
case 'cluster-carriageway-cutback':
|
||||
return { cutbackMeters: Math.max(0, scalar) };
|
||||
case 'cluster-corner-radius':
|
||||
return { radiusMeters: Math.max(0, scalar) };
|
||||
case 'junction-cutback':
|
||||
return { cutbackMeters: Math.max(0, scalar) };
|
||||
case 'junction-corner-radius':
|
||||
|
||||
@@ -27,6 +27,8 @@ export const CONTROL_KINDS = ['junction-crosswalk-inset', 'junction-stop-line-of
|
||||
export const JUNCTION_KINDS = [
|
||||
'junction-approach-width',
|
||||
'cluster-carriageway-width',
|
||||
'cluster-carriageway-cutback',
|
||||
'cluster-corner-radius',
|
||||
'junction-cutback',
|
||||
'junction-corner-radius',
|
||||
...CONTROL_KINDS,
|
||||
@@ -59,6 +61,7 @@ export type SemanticAnchor =
|
||||
// in projection.ts is the only place that moves it across.
|
||||
boundaryIndex?: number;
|
||||
}
|
||||
| { type: 'cluster-corner'; clusterId: string; cornerKey: string; carriagewayKeys: string[] }
|
||||
| { type: 'junction-approach'; nodeId: string; segmentId: string; side?: Side }
|
||||
| {
|
||||
type: 'cluster-carriageway';
|
||||
|
||||
@@ -59,7 +59,10 @@ export function junctionLabelForHandle(handle: EditHandle, roads: Road[], juncti
|
||||
return `${approachName(road, roads, junction)} · ${base}`;
|
||||
}
|
||||
const clusterAnchor = handle.anchor;
|
||||
if (handle.kind === 'cluster-carriageway-width' && clusterAnchor.type === 'cluster-carriageway') {
|
||||
if (
|
||||
(handle.kind === 'cluster-carriageway-width' || handle.kind === 'cluster-carriageway-cutback') &&
|
||||
clusterAnchor.type === 'cluster-carriageway'
|
||||
) {
|
||||
const road = roads.find((item) => clusterAnchor.sourceRoadIds.includes(item.id));
|
||||
return `${approachName(road, roads, junction)} · ${base}`;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user