feat(workbench): unify lane maneuver edits in v2
This commit is contained in:
1 parent
118dc8e9aa
commit
c804a373ca
15 files changed
+337
-263
No files matched your search
@@ -28,6 +28,7 @@ function readFlag(): boolean {
|
||||
* Resolved once at module load so a single render pass cannot see the flag flip
|
||||
* halfway through and build a half-wired map.
|
||||
*/
|
||||
/** Initial mode for compatibility with the old URL opt-in. The UI may switch it at runtime. */
|
||||
export const directEditEnabled = readFlag();
|
||||
|
||||
/**
|
||||
|
||||
@@ -108,6 +108,7 @@ export function metersToStation(meters: number, roadLengthMeters: number): numbe
|
||||
}
|
||||
|
||||
const KIND_LABELS: Record<ConstraintKind, string> = {
|
||||
'lane-maneuver': '导向箭头位置',
|
||||
'road-edge-offset': '外缘偏移',
|
||||
'road-sidewalk-width': '步行带宽度',
|
||||
'road-lane-divider': '车道分隔',
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
import type {
|
||||
AnchorSnapshot,
|
||||
ConstraintValue,
|
||||
LaneManeuverValue,
|
||||
EditHandle,
|
||||
JunctionReserve,
|
||||
RoadConstraint,
|
||||
@@ -92,6 +93,8 @@ export function constraintValueFor(
|
||||
transition: Transition = 'smoothstep',
|
||||
): ConstraintValue {
|
||||
switch (handle.kind) {
|
||||
case 'lane-maneuver':
|
||||
throw new Error('lane-maneuver requires laneManeuverValueFor');
|
||||
case 'road-edge-offset':
|
||||
return { offsetMeters: scalar, transition };
|
||||
case 'road-sidewalk-width':
|
||||
@@ -117,6 +120,11 @@ export function constraintValueFor(
|
||||
}
|
||||
}
|
||||
|
||||
/** Packages the two-field lane arrow edit as one direct-edit value. */
|
||||
export function laneManeuverValueFor(maneuver: string, placementDistanceMeters: number): LaneManeuverValue {
|
||||
return { maneuver, placementDistanceMeters };
|
||||
}
|
||||
|
||||
/**
|
||||
* The station range a road interval may occupy, i.e. everything outside the
|
||||
* junction reserves. Mirrors the window `makeRoadHandles()` centres its handles
|
||||
|
||||
@@ -9,6 +9,7 @@ import { reserveWindow, type IntervalWindow } from './projection';
|
||||
import {
|
||||
isControlKind,
|
||||
isRoadKind,
|
||||
LANE_KINDS,
|
||||
type EditHandle,
|
||||
type HandleManifest,
|
||||
type JunctionReserve,
|
||||
@@ -35,6 +36,10 @@ export function handlesForSegment(
|
||||
): EditHandle[] {
|
||||
if (!manifest || !segmentId) return [];
|
||||
return manifest.handles.filter((handle) => {
|
||||
if ((LANE_KINDS as readonly string[]).includes(handle.kind)) {
|
||||
const roadId = handle.anchor.type === 'lane' ? handle.anchor.roadId : undefined;
|
||||
return typeof roadId === 'string' && segmentOf(roadId) === segmentId;
|
||||
}
|
||||
if (isControlKind(handle.kind)) return 'segmentId' in handle.anchor && handle.anchor.segmentId === segmentId;
|
||||
if (!isRoadKind(handle.kind)) return false;
|
||||
const roadId = 'roadId' in handle.anchor ? handle.anchor.roadId : undefined;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// imports from here rather than casting response fields locally, so there is one
|
||||
// definition of "a valid manifest" on this side of the wire.
|
||||
|
||||
import type { GeoJson, Override } from '../types/state';
|
||||
import type { GeoJson } from '../types/state';
|
||||
|
||||
export type Side = 'left' | 'right';
|
||||
export type Transition = 'smoothstep' | 'linear';
|
||||
@@ -34,15 +34,18 @@ export const JUNCTION_KINDS = [
|
||||
// the panel when the corner grips exist to drive it.
|
||||
'junction-crosswalk-size',
|
||||
] as const;
|
||||
export const LANE_KINDS = ['lane-maneuver'] as const;
|
||||
|
||||
export type RoadConstraintKind = (typeof ROAD_KINDS)[number];
|
||||
export type ControlConstraintKind = (typeof CONTROL_KINDS)[number];
|
||||
export type JunctionConstraintKind = (typeof JUNCTION_KINDS)[number];
|
||||
export type ConstraintKind = RoadConstraintKind | JunctionConstraintKind;
|
||||
export type LaneConstraintKind = (typeof LANE_KINDS)[number];
|
||||
export type ConstraintKind = RoadConstraintKind | JunctionConstraintKind | LaneConstraintKind;
|
||||
|
||||
export type ConstraintStatus = 'exact' | 'recheck' | 'pending' | 'conflicted' | 'stale';
|
||||
|
||||
export type SemanticAnchor =
|
||||
| { type: 'lane'; laneId: string; roadId?: string }
|
||||
| { type: 'road-station'; roadId: string; station: number; side?: Side }
|
||||
| {
|
||||
type: 'road-interval';
|
||||
@@ -99,6 +102,7 @@ export interface AnchorSnapshot {
|
||||
}
|
||||
|
||||
export type ConstraintValue =
|
||||
| { maneuver: string; placementDistanceMeters?: number }
|
||||
| { offsetMeters: number; transition?: Transition }
|
||||
| { widthMeters: number; transition?: Transition }
|
||||
| { boundaryIndex: number; offsetMeters: number; transition?: Transition }
|
||||
@@ -106,13 +110,18 @@ export type ConstraintValue =
|
||||
| { cutbackMeters: number }
|
||||
| { radiusMeters: number }
|
||||
| { insetMeters: number };
|
||||
export interface LaneManeuverValue {
|
||||
maneuver: string;
|
||||
placementDistanceMeters: number;
|
||||
}
|
||||
export type ConstraintValueWithLane = ConstraintValue | LaneManeuverValue;
|
||||
|
||||
export interface RoadConstraint {
|
||||
id: string;
|
||||
kind: ConstraintKind;
|
||||
anchor: SemanticAnchor;
|
||||
anchorSnapshot: AnchorSnapshot;
|
||||
value: ConstraintValue;
|
||||
value: ConstraintValueWithLane;
|
||||
enabled: boolean;
|
||||
status: ConstraintStatus;
|
||||
provenance: { operationId: string; createdAt: string; author?: string };
|
||||
@@ -207,7 +216,6 @@ export type EditSelection = { segment: string } | { junction: string };
|
||||
*/
|
||||
export interface EditPreviewRequest {
|
||||
previewSeq: number;
|
||||
overrides?: Override[];
|
||||
constraints?: RoadConstraint[];
|
||||
operations?: RoadEditOperation[];
|
||||
document?: RoadEditDocument;
|
||||
|
||||
Reference in new issue
Block a user