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
@@ -113,6 +113,7 @@ const KIND_LABELS: Record<ConstraintKind, string> = {
|
||||
'road-sidewalk-width': '步行带宽度',
|
||||
'road-lane-divider': '车道分隔',
|
||||
'junction-approach-width': '进口宽度',
|
||||
'cluster-carriageway-width': '车行道宽度',
|
||||
'junction-cutback': '进口收口距离',
|
||||
'junction-corner-radius': '角部圆角',
|
||||
'junction-crosswalk-inset': '斑马线退让',
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
projectIntervalEnd,
|
||||
reserveWindow,
|
||||
} from './projection';
|
||||
import type { ConstraintKind, EditHandle, JunctionReserve, RoadIntervalAnchor, Side } from './types';
|
||||
import type { ConstraintKind, EditHandle, JunctionReserve, RoadIntervalAnchor, SemanticAnchor, Side } from './types';
|
||||
|
||||
const CENTER: Coordinate = [116.397, 39.908];
|
||||
/** The road heads due north, so the manifest reports normal = tangent + 90 = east. */
|
||||
@@ -38,7 +38,7 @@ function interval(side?: Side, boundaryIndex?: number): RoadIntervalAnchor {
|
||||
};
|
||||
}
|
||||
|
||||
function makeHandle(kind: ConstraintKind, anchor: RoadIntervalAnchor, current = 0, min = -5, max = 5): EditHandle {
|
||||
function makeHandle(kind: ConstraintKind, anchor: SemanticAnchor, current = 0, min = -5, max = 5): EditHandle {
|
||||
return {
|
||||
handleId: `handle:${kind}`,
|
||||
kind,
|
||||
@@ -110,6 +110,25 @@ describe('road-sidewalk-width projection', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('complex carriageway width projection', () => {
|
||||
it('writes the shared width value shape', () => {
|
||||
const handle = makeHandle(
|
||||
'cluster-carriageway-width',
|
||||
{
|
||||
type: 'cluster-carriageway',
|
||||
clusterId: 'cluster-1',
|
||||
carriagewayKey: 'cluster:cluster-1:carriageway:stable',
|
||||
sourceNodeIds: ['node-1'],
|
||||
sourceRoadIds: ['road-1'],
|
||||
},
|
||||
6,
|
||||
4.8,
|
||||
12,
|
||||
);
|
||||
expect(constraintValueFor(handle, 7.5)).toEqual({ widthMeters: 7.5 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('road-lane-divider projection', () => {
|
||||
it('is a signed lateral offset, with no side flip', () => {
|
||||
const handle = makeHandle('road-lane-divider', interval(undefined, 2), 0, -1.2, 1.2);
|
||||
|
||||
@@ -102,6 +102,7 @@ export function constraintValueFor(
|
||||
case 'road-lane-divider':
|
||||
return { boundaryIndex: boundaryIndexOf(handle), offsetMeters: scalar, transition };
|
||||
case 'junction-approach-width':
|
||||
case 'cluster-carriageway-width':
|
||||
return { widthMeters: Math.max(0, scalar) };
|
||||
case 'junction-cutback':
|
||||
return { cutbackMeters: Math.max(0, scalar) };
|
||||
|
||||
@@ -26,6 +26,7 @@ export const ROAD_KINDS = ['road-edge-offset', 'road-sidewalk-width', 'road-lane
|
||||
export const CONTROL_KINDS = ['junction-crosswalk-inset', 'junction-stop-line-offset'] as const;
|
||||
export const JUNCTION_KINDS = [
|
||||
'junction-approach-width',
|
||||
'cluster-carriageway-width',
|
||||
'junction-cutback',
|
||||
'junction-corner-radius',
|
||||
...CONTROL_KINDS,
|
||||
@@ -59,6 +60,13 @@ export type SemanticAnchor =
|
||||
boundaryIndex?: number;
|
||||
}
|
||||
| { type: 'junction-approach'; nodeId: string; segmentId: string; side?: Side }
|
||||
| {
|
||||
type: 'cluster-carriageway';
|
||||
clusterId: string;
|
||||
carriagewayKey: string;
|
||||
sourceNodeIds: string[];
|
||||
sourceRoadIds: string[];
|
||||
}
|
||||
| { type: 'junction-crossing'; crossingId: string; nodeId: string; segmentId: string; roadId: string }
|
||||
| { type: 'junction-corner'; nodeId: string; incomingRoadId: string; outgoingRoadId: string };
|
||||
|
||||
|
||||
Reference in new issue
Block a user