feat: 在地图和场景接口中新增最大速度属性,并在相关组件中实现最大速度的显示和编辑功能
This commit is contained in:
parent
10c3af9477
commit
1c38b4e3dc
@ -43,6 +43,7 @@ export interface MapRouteInfo {
|
|||||||
type: MapRouteType; // 线路类型
|
type: MapRouteType; // 线路类型
|
||||||
direction?: -1 | 1; // 方向
|
direction?: -1 | 1; // 方向
|
||||||
pass?: MapRoutePassType; // 可通行类型
|
pass?: MapRoutePassType; // 可通行类型
|
||||||
|
maxSpeed?: number; // 最大速度
|
||||||
c1?: Point; // 控制点1
|
c1?: Point; // 控制点1
|
||||||
c2?: Point; // 控制点2
|
c2?: Point; // 控制点2
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,6 +59,7 @@ export interface StandardSceneRoute {
|
|||||||
to: string; // 终点点位id
|
to: string; // 终点点位id
|
||||||
type: 'line' | 'bezier2' | 'bezier3'; // 线路类型
|
type: 'line' | 'bezier2' | 'bezier3'; // 线路类型
|
||||||
pass?: number; // 可通行类型
|
pass?: number; // 可通行类型
|
||||||
|
maxSpeed?: number; // 最大速度
|
||||||
c1?: { x?: number; y?: number }; // 控制点1
|
c1?: { x?: number; y?: number }; // 控制点1
|
||||||
c2?: { x?: number; y?: number }; // 控制点2
|
c2?: { x?: number; y?: number }; // 控制点2
|
||||||
config?: object; // 其它属性配置(可按需增加)
|
config?: object; // 其它属性配置(可按需增加)
|
||||||
|
|||||||
@ -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 type="secondary">{{ $t('路段长度') }}</a-typography-text>
|
||||||
<a-typography-text>{{ pen.length?.toFixed() }}</a-typography-text>
|
<a-typography-text>{{ pen.length?.toFixed() }}</a-typography-text>
|
||||||
</a-list-item>
|
</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-list-item>
|
||||||
<a-typography-text style="flex: none" type="secondary">{{ $t('路段方向') }}</a-typography-text>
|
<a-typography-text style="flex: none" type="secondary">{{ $t('路段方向') }}</a-typography-text>
|
||||||
<a-typography-text :content="label" ellipsis />
|
<a-typography-text :content="label" ellipsis />
|
||||||
|
|||||||
@ -78,6 +78,12 @@ function handlePassChange(pass: any) {
|
|||||||
editor.value.updateRoute(props.id, { pass: Number(pass) as MapRoutePassType });
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -119,6 +125,22 @@ function handlePassChange(pass: any) {
|
|||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</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-row align="middle" :gutter="10" :wrap="false">
|
||||||
<a-col flex="none">
|
<a-col flex="none">
|
||||||
<a-typography-text>{{ $t('路段方向') }}:</a-typography-text>
|
<a-typography-text>{{ $t('路段方向') }}:</a-typography-text>
|
||||||
|
|||||||
@ -276,7 +276,7 @@ export class EditorService extends Meta2d {
|
|||||||
#loadSceneRoutes(routes?: StandardSceneRoute[], isImport = false): void {
|
#loadSceneRoutes(routes?: StandardSceneRoute[], isImport = false): void {
|
||||||
if (!routes?.length) return;
|
if (!routes?.length) return;
|
||||||
routes.map((v) => {
|
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 p1 = this.getPenById(from);
|
||||||
const p2 = this.getPenById(to);
|
const p2 = this.getPenById(to);
|
||||||
if (isNil(p1) || isNil(p2)) return;
|
if (isNil(p1) || isNil(p2)) return;
|
||||||
@ -310,6 +310,7 @@ export class EditorService extends Meta2d {
|
|||||||
pass,
|
pass,
|
||||||
c1: transformedC1,
|
c1: transformedC1,
|
||||||
c2: transformedC2,
|
c2: transformedC2,
|
||||||
|
maxSpeed,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ render: false, history: false, doEvent: false },
|
{ render: false, history: false, doEvent: false },
|
||||||
@ -427,7 +428,7 @@ export class EditorService extends Meta2d {
|
|||||||
#mapSceneRoute(pen?: MapPen): StandardSceneRoute | null {
|
#mapSceneRoute(pen?: MapPen): StandardSceneRoute | null {
|
||||||
if (!pen?.id || pen.anchors?.length !== 2 || isEmpty(pen?.route)) return null;
|
if (!pen?.id || pen.anchors?.length !== 2 || isEmpty(pen?.route)) return null;
|
||||||
const { id, anchors, desc, properties } = pen;
|
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!));
|
const [p1, p2] = anchors.map((v) => this.getPenById(v.connectTo!));
|
||||||
if (isNil(p1) || isNil(p2)) return null;
|
if (isNil(p1) || isNil(p2)) return null;
|
||||||
const route: StandardSceneRoute = {
|
const route: StandardSceneRoute = {
|
||||||
@ -437,6 +438,7 @@ export class EditorService extends Meta2d {
|
|||||||
to: direction < 0 ? p1.id! : p2.id!,
|
to: direction < 0 ? p1.id! : p2.id!,
|
||||||
type,
|
type,
|
||||||
pass,
|
pass,
|
||||||
|
maxSpeed,
|
||||||
config: {},
|
config: {},
|
||||||
properties,
|
properties,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user