feat: 在地图和场景接口中新增最大速度属性,并在相关组件中实现最大速度的显示和编辑功能

This commit is contained in:
xudan 2025-10-10 17:01:52 +08:00
parent 10c3af9477
commit 1c38b4e3dc
5 changed files with 32 additions and 2 deletions

View File

@ -43,6 +43,7 @@ export interface MapRouteInfo {
type: MapRouteType; // 线路类型
direction?: -1 | 1; // 方向
pass?: MapRoutePassType; // 可通行类型
maxSpeed?: number; // 最大速度
c1?: Point; // 控制点1
c2?: Point; // 控制点2
}

View File

@ -59,6 +59,7 @@ export interface StandardSceneRoute {
to: string; // 终点点位id
type: 'line' | 'bezier2' | 'bezier3'; // 线路类型
pass?: number; // 可通行类型
maxSpeed?: number; // 最大速度
c1?: { x?: number; y?: number }; // 控制点1
c2?: { x?: number; y?: number }; // 控制点2
config?: object; // 其它属性配置(可按需增加)

View File

@ -48,6 +48,10 @@ const label = computed<string>(() => editor.value.getRouteLabel(pen.value?.id));
<a-typography-text type="secondary">{{ $t('路段长度') }}</a-typography-text>
<a-typography-text>{{ pen.length?.toFixed() }}</a-typography-text>
</a-list-item>
<a-list-item v-if="route.maxSpeed">
<a-typography-text type="secondary">{{ $t('最大速度(m/s)') }}</a-typography-text>
<a-typography-text>{{ route.maxSpeed }}</a-typography-text>
</a-list-item>
<a-list-item>
<a-typography-text style="flex: none" type="secondary">{{ $t('路段方向') }}</a-typography-text>
<a-typography-text :content="label" ellipsis />

View File

@ -78,6 +78,12 @@ function handlePassChange(pass: any) {
editor.value.updateRoute(props.id, { pass: Number(pass) as MapRoutePassType });
}
//
function handleMaxSpeedChange(maxSpeed: any) {
if (!props.id) return;
editor.value.updateRoute(props.id, { maxSpeed: Number(maxSpeed) });
}
</script>
<template>
@ -119,6 +125,22 @@ function handlePassChange(pass: any) {
</a-col>
</a-row>
<a-row align="middle" :gutter="10" :wrap="false">
<a-col flex="none">
<a-typography-text>{{ $t('最大速度(m/s)') }}:</a-typography-text>
</a-col>
<a-col flex="auto">
<a-input-number
style="width: 100%"
:placeholder="$t('请输入')"
:precision="2"
:step="0.1"
:value="route.maxSpeed"
@change="handleMaxSpeedChange($event)"
/>
</a-col>
</a-row>
<a-row align="middle" :gutter="10" :wrap="false">
<a-col flex="none">
<a-typography-text>{{ $t('路段方向') }}:</a-typography-text>

View File

@ -276,7 +276,7 @@ export class EditorService extends Meta2d {
#loadSceneRoutes(routes?: StandardSceneRoute[], isImport = false): void {
if (!routes?.length) return;
routes.map((v) => {
const { id, desc, from, to, type, pass, c1, c2, properties } = v;
const { id, desc, from, to, type, pass, c1, c2, properties, maxSpeed } = v;
const p1 = this.getPenById(from);
const p2 = this.getPenById(to);
if (isNil(p1) || isNil(p2)) return;
@ -310,6 +310,7 @@ export class EditorService extends Meta2d {
pass,
c1: transformedC1,
c2: transformedC2,
maxSpeed,
},
},
{ render: false, history: false, doEvent: false },
@ -427,7 +428,7 @@ export class EditorService extends Meta2d {
#mapSceneRoute(pen?: MapPen): StandardSceneRoute | null {
if (!pen?.id || pen.anchors?.length !== 2 || isEmpty(pen?.route)) return null;
const { id, anchors, desc, properties } = pen;
const { type, direction = 1, pass, c1, c2 } = pen.route;
const { type, direction = 1, pass, c1, c2, maxSpeed } = pen.route;
const [p1, p2] = anchors.map((v) => this.getPenById(v.connectTo!));
if (isNil(p1) || isNil(p2)) return null;
const route: StandardSceneRoute = {
@ -437,6 +438,7 @@ export class EditorService extends Meta2d {
to: direction < 0 ? p1.id! : p2.id!,
type,
pass,
maxSpeed,
config: {},
properties,
};