feat(junction): edit complex crossing facilities

This commit is contained in:
que01 committed 2026-09-08 15:05:00 +08:00
1 parent bb5dc01c07
commit 49a44fdf73
16 files changed
+307 -39

No files matched your search

+38 -4
View File
@@ -25,6 +25,8 @@ import { azimuthBetween, eastNorthMeters, haversineMeters, offsetCoordinate, typ
export const CROSSWALK_PROVENANCE = 'native-road-crosswalk/v1';
/** Stop lines share `controlFeature()`; kept so the two are never confused. */
export const STOP_LINE_PROVENANCE = 'native-road-stop-line/v1';
export const COMPLEX_CROSSWALK_PROVENANCE = 'native-road-complex-junction-crosswalk/v6-road-clipped';
export const COMPLEX_STOP_LINE_PROVENANCE = 'native-road-complex-junction-stop-line/v1';
/** Turn arrows are grouped by both the lane and the rendered maneuver. */
export const TURN_ARROW_PROVENANCE = 'native-road-turn-arrow/v1';
/** Lane centerlines are the entry point for lanes which do not yet draw an arrow. */
@@ -50,7 +52,8 @@ export interface ElementSpec {
/** Layer the members live in, in both `state.layers` and a preview. */
layer: 'crosswalks' | 'vehicleStopLines' | 'turnArrows';
/** The constraint that moves this control element. */
constraintKind?: 'junction-crosswalk-inset' | 'junction-stop-line-offset';
constraintKind?:
'junction-crosswalk-inset' | 'junction-stop-line-offset' | 'cluster-crossing-inset' | 'cluster-stop-line-offset';
label: string;
/** Properties whose ordered values group rendered parts together. */
groupProperties: readonly string[];
@@ -72,6 +75,24 @@ export const ELEMENT_SPECS: readonly ElementSpec[] = [
label: '斑马线',
groupProperties: ['crossing_node_id'],
},
{
kind: 'crosswalk',
provenance: COMPLEX_CROSSWALK_PROVENANCE,
idPrefix: 'complex-crosswalk:',
layer: 'crosswalks',
constraintKind: 'cluster-crossing-inset',
label: '斑马线',
groupProperties: ['crossing_key'],
},
{
kind: 'stop-line',
provenance: COMPLEX_STOP_LINE_PROVENANCE,
idPrefix: 'complex-stop-line:',
layer: 'vehicleStopLines',
constraintKind: 'cluster-stop-line-offset',
label: '停止线',
groupProperties: ['crossing_key'],
},
{
kind: 'stop-line',
provenance: STOP_LINE_PROVENANCE,
@@ -110,6 +131,7 @@ export interface ControlElementSelection {
roadId: string;
/** `native_id` of every member, for highlight and preview scoping. */
featureIds: string[];
constraintKind?: NonNullable<ElementSpec['constraintKind']>;
}
/** A discrete v1 override target, selected from an arrow or a lane centerline. */
@@ -215,7 +237,7 @@ export function elementSelectionFor(
}
: null;
}
const crossingNodeId = text(first.crossing_node_id);
const crossingNodeId = text(first.crossing_key) ?? text(first.crossing_node_id);
if (!crossingNodeId) return null;
return {
kind: spec.kind,
@@ -223,6 +245,7 @@ export function elementSelectionFor(
crossingNodeId,
roadId,
featureIds: members.map((member) => text(member.properties?.native_id)).filter((id): id is string => Boolean(id)),
...(spec.constraintKind?.startsWith('cluster-') ? { constraintKind: spec.constraintKind } : {}),
};
}
@@ -259,20 +282,31 @@ export function handleForElement<T extends { kind: string; anchor: Record<string
handles: readonly T[],
): T | null {
const spec = specOfKind(element.kind);
const constraintKind =
element.constraintKind ?? (element.kind === 'crosswalk' ? 'junction-crosswalk-inset' : 'junction-stop-line-offset');
if (constraintKind?.startsWith('cluster-'))
return (
handles.find(
(handle) =>
handle.kind === constraintKind &&
handle.anchor.type === 'cluster-crossing' &&
String(handle.anchor.crossingKey) === String(element.crossingNodeId),
) ?? null
);
const road = roads.find((item) => item.id === element.roadId);
const nodeId = road?.sourceNodeIds.at(-1);
if (!road || nodeId === undefined) return null;
return (
handles.find(
(handle) =>
handle.kind === spec.constraintKind &&
handle.kind === constraintKind &&
handle.anchor.type === 'junction-crossing' &&
String(handle.anchor.crossingId) === String(element.crossingNodeId),
) ??
// Accept legacy manifests while a saved server document is being upgraded.
handles.find(
(handle) =>
handle.kind === spec.constraintKind &&
handle.kind === constraintKind &&
handle.anchor.segmentId === road.segmentId &&
String(handle.anchor.nodeId) === String(nodeId),
) ??
+2
View File
@@ -116,6 +116,8 @@ const KIND_LABELS: Record<ConstraintKind, string> = {
'cluster-carriageway-width': '车行道宽度',
'cluster-carriageway-cutback': '车行道收口距离',
'cluster-corner-radius': '角部圆角',
'cluster-crossing-inset': '斑马线退让',
'cluster-stop-line-offset': '停止线偏移',
'junction-cutback': '进口收口距离',
'junction-corner-radius': '角部圆角',
'junction-crosswalk-inset': '斑马线退让',
+2
View File
@@ -113,8 +113,10 @@ export function constraintValueFor(
case 'junction-corner-radius':
return { radiusMeters: Math.max(0, scalar) };
case 'junction-crosswalk-inset':
case 'cluster-crossing-inset':
return { insetMeters: Math.max(0, scalar) };
case 'junction-stop-line-offset':
case 'cluster-stop-line-offset':
return { offsetMeters: Math.max(0, scalar) };
case 'junction-crosswalk-size':
// Size is a pair — depth and stripe count — so no single dragged scalar
+7 -1
View File
@@ -23,7 +23,12 @@ export const ROAD_KINDS = ['road-edge-offset', 'road-sidewalk-width', 'road-lane
* offers this edit. Placement of the zebra and the stop line is therefore the main
* map's, and JunctionTools keeps the three shape kinds below.
*/
export const CONTROL_KINDS = ['junction-crosswalk-inset', 'junction-stop-line-offset'] as const;
export const CONTROL_KINDS = [
'junction-crosswalk-inset',
'junction-stop-line-offset',
'cluster-crossing-inset',
'cluster-stop-line-offset',
] as const;
export const JUNCTION_KINDS = [
'junction-approach-width',
'cluster-carriageway-width',
@@ -61,6 +66,7 @@ export type SemanticAnchor =
// in projection.ts is the only place that moves it across.
boundaryIndex?: number;
}
| { type: 'cluster-crossing'; clusterId: string; crossingKey: string; carriagewayKeys: string[] }
| { type: 'cluster-corner'; clusterId: string; cornerKey: string; carriagewayKeys: string[] }
| { type: 'junction-approach'; nodeId: string; segmentId: string; side?: Side }
| {