@aibee/crc-bmap 0.0.109 → 0.0.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1 @@
1
1
  export * from './navigation';
2
- export * from './enum';
@@ -1,8 +1,7 @@
1
1
  import { BMap } from "../../bmap";
2
2
  import { Plugin } from "../base";
3
3
  import { Path, PathConfig } from "./path";
4
- import { WorkerEventType } from "./enum";
5
- import { UniqueKey } from "../../utils";
4
+ import { End, RoadData, RouteType, Start, UniqueKey } from "../../utils";
6
5
  import { Floor, Poi, PoiOptions } from "../../elements";
7
6
  import { Group as TweenGroup } from "@tweenjs/tween.js";
8
7
  export type Point = [number, number];
@@ -24,6 +23,7 @@ export interface NavigationConfig {
24
23
  cheapMaximumDistance: number;
25
24
  startPoi: Partial<PoiOptions>;
26
25
  needStartPoi: boolean;
26
+ loadRoad: boolean;
27
27
  }
28
28
  export declare class Navigation extends Plugin<EventMap> {
29
29
  path: Path | null;
@@ -42,23 +42,17 @@ export declare class Navigation extends Plugin<EventMap> {
42
42
  registryEvent(): void;
43
43
  unRegistryEvent(): void;
44
44
  onUpdate: () => void;
45
- triggerWorker(type: WorkerEventType, data?: any): void;
45
+ setRoadData(roadData: RoadData[]): Promise<void>;
46
46
  clearPath(): void;
47
47
  onSwitchFloor: ({ data: { curFloor } }: {
48
48
  data: {
49
49
  curFloor: Floor;
50
50
  };
51
51
  }) => void;
52
- getDirectionPath(points: Point[]): Promise<unknown>;
52
+ getDirectionPath(points: Point[]): Promise<any>;
53
53
  addPath(paths: PathData): void;
54
54
  translatePoints(points: Point[]): Point[];
55
- getPath(start: {
56
- floor: string;
57
- nodeId: string;
58
- }, end: {
59
- floor: string;
60
- nodeId: string;
61
- }): Promise<PathData>;
55
+ getPath(start: Start, end: End, type: RouteType): Promise<PathData>;
62
56
  renderPath(points: Point[]): void;
63
57
  catmullRomCurve3(points: Point[]): [number, number][];
64
58
  /**
@@ -29,4 +29,5 @@ export declare function isContain(point: Position, start: Position, end: Positio
29
29
  export declare function getLongestSideDir(cds: Coordinate[]): Vector3;
30
30
  export declare function getLength(start: [number, number], end: [number, number]): number;
31
31
  export declare function getPathLength(path: [number, number][]): number;
32
+ export declare function calc_angle(p0: [number, number], p1: [number, number], p2: [number, number]): number;
32
33
  export {};
@@ -17,3 +17,7 @@ export * from './event-name';
17
17
  export * from './obj-utils';
18
18
  export * from './ajax';
19
19
  export * from './unique-key';
20
+ export * from './path';
21
+ export * from './road';
22
+ export * from './webworker';
23
+ export * from './string';
@@ -34,3 +34,29 @@ export declare function distancePointToSegment(point: [number, number], start: [
34
34
  * @returns
35
35
  */
36
36
  export declare function moveOnRoute(startPoint: [number, number], endPoint: [number, number], distance: number): [number, number];
37
+ export declare enum PathDirection {
38
+ START = "start",
39
+ END = "end",
40
+ FRONT = "front",
41
+ RIGHT = "right",
42
+ LEFT = "left",
43
+ RIGHT_FRONT = "right_front",
44
+ LEFT_FRONT = "left_front",
45
+ RIGHT_BACK = "right_back",
46
+ LEFT_BACK = "left_back"
47
+ }
48
+ export declare function calc_direction(p0: [number, number], p1: [number, number], p2: [number, number]): PathDirection.FRONT | PathDirection.RIGHT | PathDirection.LEFT | PathDirection.RIGHT_FRONT | PathDirection.LEFT_FRONT | PathDirection.RIGHT_BACK | PathDirection.LEFT_BACK;
49
+ /**
50
+ * 入参 Point[]
51
+ * 返回
52
+ * [{
53
+ * direction: PathDirection
54
+ * distance: number
55
+ * points: Point[]
56
+ * }]
57
+ */
58
+ export declare function getDirectPath(points: [number, number][]): {
59
+ direction: PathDirection;
60
+ distance: number;
61
+ points: [number, number][];
62
+ }[];
@@ -0,0 +1,155 @@
1
+ import Graph from "node-dijkstra";
2
+ export interface RoadData {
3
+ floor: string;
4
+ lines: Array<{
5
+ id: string;
6
+ to: string;
7
+ from: string;
8
+ color: string;
9
+ locked: boolean;
10
+ opacity: number;
11
+ visible: boolean;
12
+ userData: Record<string, string>;
13
+ direction: "double" | "single" | "no";
14
+ }>;
15
+ points: Array<{
16
+ id: string;
17
+ cds: [number, number];
18
+ name: string;
19
+ type: "normal" | "graph" | "straightLadder" | "staircase" | "escalator" | "facility";
20
+ floor: string;
21
+ locked: boolean;
22
+ nodeId: string;
23
+ visible: boolean;
24
+ targetId: string;
25
+ userData: Record<string, string>;
26
+ escalatorType: "" | "single" | "double" | "jd";
27
+ escalatorDirection: "" | "up" | "down" | "exit";
28
+ }>;
29
+ }
30
+ export interface Start {
31
+ floor: string;
32
+ nodeId?: string;
33
+ coord?: [number, number];
34
+ }
35
+ type FacilityEnd = {
36
+ floor?: string;
37
+ facility?: string;
38
+ };
39
+ export type End = Start & FacilityEnd;
40
+ export type RouteType = "" | "escalator" | "straightLadder";
41
+ export type PathData = {
42
+ floor: string;
43
+ points: [number, number][];
44
+ endType: string;
45
+ destId: string;
46
+ }[];
47
+ export declare class RoadNetwork {
48
+ private lift_priority;
49
+ roadInfo: RoadData[];
50
+ pointMap: Map<string, {
51
+ id: string;
52
+ cds: [number, number];
53
+ name: string;
54
+ type: "escalator" | "straightLadder" | "normal" | "graph" | "staircase" | "facility";
55
+ floor: string;
56
+ locked: boolean;
57
+ nodeId: string;
58
+ visible: boolean;
59
+ targetId: string;
60
+ userData: Record<string, string>;
61
+ escalatorType: "" | "single" | "double" | "jd";
62
+ escalatorDirection: "" | "up" | "down" | "exit";
63
+ }>;
64
+ nodeMap: Map<string, string>;
65
+ facilityMap: Map<string, {
66
+ id: string;
67
+ cds: [number, number];
68
+ name: string;
69
+ type: "escalator" | "straightLadder" | "normal" | "graph" | "staircase" | "facility";
70
+ floor: string;
71
+ locked: boolean;
72
+ nodeId: string;
73
+ visible: boolean;
74
+ targetId: string;
75
+ userData: Record<string, string>;
76
+ escalatorType: "" | "single" | "double" | "jd";
77
+ escalatorDirection: "" | "up" | "down" | "exit";
78
+ }[]>;
79
+ straightLadderMap: Map<string, {
80
+ id: string;
81
+ cds: [number, number];
82
+ name: string;
83
+ type: "escalator" | "straightLadder" | "normal" | "graph" | "staircase" | "facility";
84
+ floor: string;
85
+ locked: boolean;
86
+ nodeId: string;
87
+ visible: boolean;
88
+ targetId: string;
89
+ userData: Record<string, string>;
90
+ escalatorType: "" | "single" | "double" | "jd";
91
+ escalatorDirection: "" | "up" | "down" | "exit";
92
+ }[]>;
93
+ escalatorMap: Map<string, {
94
+ start: RoadData["points"][0];
95
+ end: RoadData["points"][0];
96
+ }>;
97
+ staircaseMap: Map<string, {
98
+ id: string;
99
+ cds: [number, number];
100
+ name: string;
101
+ type: "escalator" | "straightLadder" | "normal" | "graph" | "staircase" | "facility";
102
+ floor: string;
103
+ locked: boolean;
104
+ nodeId: string;
105
+ visible: boolean;
106
+ targetId: string;
107
+ userData: Record<string, string>;
108
+ escalatorType: "" | "single" | "double" | "jd";
109
+ escalatorDirection: "" | "up" | "down" | "exit";
110
+ }[]>;
111
+ lineMap: Map<string, Map<string, number>>;
112
+ baseRoute: Graph;
113
+ escalatorRoute: Graph;
114
+ straightLadderRoute: Graph;
115
+ constructor(lift_priority?: number);
116
+ initRoute(roadInfo: RoadData[]): void;
117
+ addLineItem(start: string, end: string, distance: number, lineMap?: Map<string, Map<string, number>>): void;
118
+ /**
119
+ * 把设施添加的路网图中
120
+ * @param escalatorPriority 扶梯权重
121
+ * @param straightLadderPriority 直梯权重
122
+ * @param staircasePriority 步行梯权重
123
+ * @param lineMap 路网
124
+ */
125
+ addFacilityToLineMap(escalatorPriority: number, straightLadderPriority: number, staircasePriority: number, lineMap: Map<string, Map<string, number>>): void;
126
+ initBaseRoute(): void;
127
+ initEscalatorRoute(): void;
128
+ initStraightLadderRoute(): void;
129
+ checkStart(start: Start): boolean;
130
+ checkEnd(end: End): boolean;
131
+ transformStart(start: Start): {
132
+ floor: string;
133
+ id: string;
134
+ } | null;
135
+ transformEnd(end: End): {
136
+ floor: string;
137
+ id: string;
138
+ } | {
139
+ facility: string;
140
+ } | null;
141
+ /**
142
+ *
143
+ * @param start 起点
144
+ * @param end 终点
145
+ * @param type '' 最短路径 escalator 扶梯优先 straightLadder 直梯优先
146
+ * @returns
147
+ */
148
+ getPath(start: Start, end: End, type?: RouteType): "start-error" | "end-error" | "no-start" | "no-end" | PathData | null | undefined;
149
+ private getRoutePath;
150
+ private getBasePath;
151
+ private getEscalatorPath;
152
+ private getStraightLadderPath;
153
+ clear(): void;
154
+ }
155
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 驼峰转下划线
3
+ * @param str
4
+ * @returns
5
+ */
6
+ export declare function convertToSnakeCase(str: string): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 调用webworker的方法
3
+ * @param type
4
+ * @param data
5
+ * @returns Promise<any>
6
+ */
7
+ export declare function triggerWorker<T = any, R = any>(worker: Worker, type: string, data: T): Promise<R>;
8
+ export declare function toWebWorker(obj: Record<string, (...args: any[]) => any>): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibee/crc-bmap",
3
- "version": "0.0.109",
3
+ "version": "0.0.110",
4
4
  "description": "",
5
5
  "main": "lib/bmap.min.js",
6
6
  "module": "lib/bmap.esm.js",
@@ -1,19 +0,0 @@
1
- export declare enum WorkerEventType {
2
- FETCH_PROJECT_ROAD = "fetch_project_road",
3
- GET_DIRECTION_PATH = "get_direction_path",
4
- DIRECTION_PATH_RESULT = "direction_path_result",
5
- FETCH_PROJECT_ROAD_RESULT = "fetch_project_road_result",
6
- GET_PATH = "get_path",
7
- GET_PATH_RESULT = "get_path_result"
8
- }
9
- export declare enum PathDirection {
10
- START = "start",
11
- END = "end",
12
- FRONT = "front",
13
- RIGHT = "right",
14
- LEFT = "left",
15
- RIGHT_FRONT = "right_front",
16
- LEFT_FRONT = "left_front",
17
- RIGHT_BACK = "right_back",
18
- LEFT_BACK = "left_back"
19
- }