feat(workbench): stabilize junction tools workspace
This commit is contained in:
1 parent
e6b822416d
commit
f10a5da325
22 files changed
+1078
-53
No files matched your search
@@ -0,0 +1,79 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { EditHandle } from '../edit/types';
|
||||
import type { Road } from '../types/state';
|
||||
import { junctionLabelForHandle } from './labels';
|
||||
|
||||
const roads = [
|
||||
{
|
||||
id: 'road-north',
|
||||
segmentId: 'segment:way/-3254/0',
|
||||
centerline: [
|
||||
[120, 30],
|
||||
[120, 30.001],
|
||||
],
|
||||
sourceNodeIds: ['junction'],
|
||||
osmWayIds: [],
|
||||
tags: { name: '创新大道' },
|
||||
highway: 'primary',
|
||||
direction: 'forward',
|
||||
widthMeters: 7,
|
||||
laneCount: 2,
|
||||
sidewalkLeft: false,
|
||||
sidewalkRight: false,
|
||||
},
|
||||
{
|
||||
id: 'road-east',
|
||||
segmentId: 'segment:way/-3255/0',
|
||||
centerline: [
|
||||
[120, 30],
|
||||
[120.001, 30],
|
||||
],
|
||||
sourceNodeIds: ['junction'],
|
||||
osmWayIds: [],
|
||||
tags: {},
|
||||
highway: 'residential',
|
||||
direction: 'forward',
|
||||
widthMeters: 6,
|
||||
laneCount: 2,
|
||||
sidewalkLeft: false,
|
||||
sidewalkRight: false,
|
||||
},
|
||||
] as const;
|
||||
|
||||
function handle(anchor: EditHandle['anchor'], kind: EditHandle['kind']): EditHandle {
|
||||
return {
|
||||
handleId: 'h',
|
||||
kind,
|
||||
anchor,
|
||||
position: [120, 30],
|
||||
axisAzimuth: 0,
|
||||
value: { current: 3, min: 1, max: 8, unit: 'meter' },
|
||||
affects: [],
|
||||
editable: true,
|
||||
};
|
||||
}
|
||||
|
||||
describe('junction handle labels', () => {
|
||||
it('uses road name and geographic approach direction', () => {
|
||||
expect(
|
||||
junctionLabelForHandle(
|
||||
handle(
|
||||
{ type: 'junction-approach', nodeId: 'junction', segmentId: roads[0].segmentId },
|
||||
'junction-approach-width',
|
||||
),
|
||||
roads as unknown as Road[],
|
||||
[120, 30],
|
||||
),
|
||||
).toBe('创新大道 · 北进口 · 进口宽度');
|
||||
});
|
||||
|
||||
it('uses a readable fallback when a road has no name', () => {
|
||||
expect(
|
||||
junctionLabelForHandle(
|
||||
handle({ type: 'junction-approach', nodeId: 'junction', segmentId: roads[1].segmentId }, 'junction-cutback'),
|
||||
roads as unknown as Road[],
|
||||
[120, 30],
|
||||
),
|
||||
).toBe('道路2 · 东进口 · 进口 cutback');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user