@maptalks/traffic 0.101.0 → 0.101.1
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maptalks/traffic",
|
|
3
|
-
"version": "0.101.
|
|
3
|
+
"version": "0.101.1",
|
|
4
4
|
"description": "a tool to render traffic effect",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dist/maptalks.traffic.d.ts"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@maptalks/gltf-layer": "0.103.
|
|
23
|
+
"@maptalks/gltf-layer": "0.103.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @maptalks/traffic v0.98.6
|
|
3
|
-
* LICENSE : UNLICENSED
|
|
4
|
-
* (c) 2016-2024 maptalks.org
|
|
5
|
-
*/
|
|
6
|
-
declare class Point {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
constructor(x?: number, y?: number);
|
|
10
|
-
get length(): number;
|
|
11
|
-
get direction(): number;
|
|
12
|
-
get normalized(): Point;
|
|
13
|
-
add(point: Point): Point;
|
|
14
|
-
subtract(point: Point): Point;
|
|
15
|
-
mult(ratio: number): Point;
|
|
16
|
-
divide(ratio: number): Point;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare class LanePosition {
|
|
20
|
-
id: string;
|
|
21
|
-
position: number;
|
|
22
|
-
free: boolean;
|
|
23
|
-
car: Car;
|
|
24
|
-
tmpLane: Lane;
|
|
25
|
-
constructor(car: Car, lane?: Lane, position?: number);
|
|
26
|
-
get lane(): Lane;
|
|
27
|
-
set lane(lane: Lane);
|
|
28
|
-
get relativePosition(): number;
|
|
29
|
-
get nextCarDistance(): {
|
|
30
|
-
car: Car;
|
|
31
|
-
distance: number;
|
|
32
|
-
};
|
|
33
|
-
acquire(): LanePosition;
|
|
34
|
-
release(): boolean;
|
|
35
|
-
getNext(): LanePosition;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
declare class ControlSignals {
|
|
39
|
-
flipMultiplier: number;
|
|
40
|
-
time: number;
|
|
41
|
-
stateNum: number;
|
|
42
|
-
lightsFlipInterval: number;
|
|
43
|
-
states: string[][];
|
|
44
|
-
intersection: Intersection;
|
|
45
|
-
constructor(intersection: Intersection);
|
|
46
|
-
get flipInterval(): number;
|
|
47
|
-
get state(): number[][];
|
|
48
|
-
decode(str: string): number[];
|
|
49
|
-
flip(): number;
|
|
50
|
-
onTick(delta: number): number;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
declare class Segment {
|
|
54
|
-
source: Point;
|
|
55
|
-
target: Point;
|
|
56
|
-
constructor(source: Point, target: Point);
|
|
57
|
-
get vector(): Point;
|
|
58
|
-
get length(): number;
|
|
59
|
-
get direction(): number;
|
|
60
|
-
get center(): Point;
|
|
61
|
-
split(n: number, reverse?: boolean): Segment[];
|
|
62
|
-
getPoint(atPoint: number): Point;
|
|
63
|
-
subsegment(a: number, b: number): Segment;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
declare class Rect {
|
|
67
|
-
x: number;
|
|
68
|
-
y: number;
|
|
69
|
-
width: number;
|
|
70
|
-
height: number;
|
|
71
|
-
constructor(x?: number, y?: number, width?: number, height?: number);
|
|
72
|
-
static copy(rect: Rect): Rect;
|
|
73
|
-
toJSON(): {} & this;
|
|
74
|
-
area(): number;
|
|
75
|
-
left(left?: number): number;
|
|
76
|
-
right(right?: number): number;
|
|
77
|
-
top(top?: number): number;
|
|
78
|
-
bottom(bottom?: number): number;
|
|
79
|
-
center(center?: {
|
|
80
|
-
x: number;
|
|
81
|
-
y: number;
|
|
82
|
-
}): Point;
|
|
83
|
-
containsPoint(point: Point): boolean;
|
|
84
|
-
containsRect(rect: Rect): boolean;
|
|
85
|
-
getVertices(): Point[];
|
|
86
|
-
getSide(i: number): Segment;
|
|
87
|
-
getSectorId(point: Point): 0 | 1 | 2 | 3;
|
|
88
|
-
getSector(point: Point): Segment;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
declare class Intersection {
|
|
92
|
-
id: string;
|
|
93
|
-
rect: Rect;
|
|
94
|
-
controlSignals: ControlSignals;
|
|
95
|
-
roads: Road[];
|
|
96
|
-
inRoads: Road[];
|
|
97
|
-
connectRoads?: Road[];
|
|
98
|
-
constructor(rect: Rect);
|
|
99
|
-
static copy(intersection: Intersection): Intersection;
|
|
100
|
-
toJSON(): {
|
|
101
|
-
id: string;
|
|
102
|
-
rect: Rect;
|
|
103
|
-
};
|
|
104
|
-
update(): number[][];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
declare class Road {
|
|
108
|
-
id: string;
|
|
109
|
-
source: Intersection;
|
|
110
|
-
target: Intersection;
|
|
111
|
-
sourceSideId: number;
|
|
112
|
-
targetSideId: number;
|
|
113
|
-
sourceSide: Segment;
|
|
114
|
-
targetSide: Segment;
|
|
115
|
-
lanes: Lane[];
|
|
116
|
-
lanesNumber: number | null;
|
|
117
|
-
gridSize: number;
|
|
118
|
-
constructor(source?: Intersection, target?: Intersection, gridSize?: number);
|
|
119
|
-
get length(): number;
|
|
120
|
-
get leftmostLane(): Lane;
|
|
121
|
-
get rightmostLane(): Lane;
|
|
122
|
-
copy(road: Road): Road;
|
|
123
|
-
toJSON(): {
|
|
124
|
-
id: string;
|
|
125
|
-
source: string;
|
|
126
|
-
target: string;
|
|
127
|
-
};
|
|
128
|
-
getTurnDirection(other: Road): number;
|
|
129
|
-
update(): number[];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
declare class Lane {
|
|
133
|
-
length: number;
|
|
134
|
-
sourceSegment: Segment;
|
|
135
|
-
targetSegment: Segment;
|
|
136
|
-
road: Road;
|
|
137
|
-
leftAdjacent: Lane;
|
|
138
|
-
rightAdjacent: Lane;
|
|
139
|
-
leftmostAdjacent: Lane | null;
|
|
140
|
-
rightmostAdjacent: Lane | null;
|
|
141
|
-
middleLine: Segment;
|
|
142
|
-
direction: number;
|
|
143
|
-
carsPositions: Record<string, LanePosition>;
|
|
144
|
-
constructor(sourceSegment: Segment, targetSegment: Segment, road: Road);
|
|
145
|
-
get sourceSideId(): number;
|
|
146
|
-
get targetSideId(): number;
|
|
147
|
-
get isRightmost(): boolean;
|
|
148
|
-
get isLeftmost(): boolean;
|
|
149
|
-
get leftBorder(): Segment;
|
|
150
|
-
get rightBorder(): Segment;
|
|
151
|
-
toJSON(): Lane;
|
|
152
|
-
update(): number;
|
|
153
|
-
getTurnDirection(other: Lane): number;
|
|
154
|
-
getDirection(): number;
|
|
155
|
-
getPoint(a: number): Point;
|
|
156
|
-
addCarPosition(carPosition: LanePosition): LanePosition;
|
|
157
|
-
removeCar(carPosition: LanePosition): boolean;
|
|
158
|
-
getNext(carPosition: LanePosition): LanePosition;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
declare class Trajectory {
|
|
162
|
-
isChangingLanes: boolean;
|
|
163
|
-
current: LanePosition;
|
|
164
|
-
next: LanePosition;
|
|
165
|
-
car: Car;
|
|
166
|
-
temp: LanePosition;
|
|
167
|
-
constructor(car: Car, lane: Lane, position: number);
|
|
168
|
-
get lane(): Lane;
|
|
169
|
-
get absolutePosition(): number;
|
|
170
|
-
get relativePosition(): number;
|
|
171
|
-
get direction(): number;
|
|
172
|
-
get coords(): Point;
|
|
173
|
-
get nextCarDistance(): {
|
|
174
|
-
car: Car;
|
|
175
|
-
distance: number;
|
|
176
|
-
};
|
|
177
|
-
get distanceToStopLine(): number;
|
|
178
|
-
get nextIntersection(): Intersection;
|
|
179
|
-
get previousIntersection(): Intersection;
|
|
180
|
-
isValidTurn(): boolean;
|
|
181
|
-
canEnterIntersection(): number | true;
|
|
182
|
-
getDistanceToIntersection(): number;
|
|
183
|
-
timeToMakeTurn(plannedStep?: number): boolean;
|
|
184
|
-
moveForward(distance: number): Lane;
|
|
185
|
-
changeLane(nextLane: Lane): number;
|
|
186
|
-
release(): boolean;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
declare class Car {
|
|
190
|
-
type: number;
|
|
191
|
-
id: string;
|
|
192
|
-
color: number | number[];
|
|
193
|
-
preferedLane: any;
|
|
194
|
-
trajectory: Trajectory;
|
|
195
|
-
nextLane: Lane;
|
|
196
|
-
width: number;
|
|
197
|
-
length: number;
|
|
198
|
-
tmpSpeed: number;
|
|
199
|
-
maxSpeed: number;
|
|
200
|
-
s0: number;
|
|
201
|
-
timeHeadway: number;
|
|
202
|
-
maxAcceleration: number;
|
|
203
|
-
maxDeceleration: number;
|
|
204
|
-
alive: boolean;
|
|
205
|
-
constructor(lane: Lane, position?: number);
|
|
206
|
-
get coords(): Point;
|
|
207
|
-
get speed(): number;
|
|
208
|
-
set speed(speed: number);
|
|
209
|
-
get direction(): number;
|
|
210
|
-
release(): boolean;
|
|
211
|
-
getAcceleration(): number;
|
|
212
|
-
move(delta: number): false | Lane;
|
|
213
|
-
pickNextRoad(): Road;
|
|
214
|
-
pickNextLane(): Lane;
|
|
215
|
-
popNextLane(): Lane;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
type Factory = Intersection | Car | Road;
|
|
219
|
-
declare class Pool {
|
|
220
|
-
objects: Record<string, Factory>;
|
|
221
|
-
factory: Factory;
|
|
222
|
-
constructor(factory: any, pool: Pool);
|
|
223
|
-
get length(): number;
|
|
224
|
-
toJSON(): Record<string, Factory>;
|
|
225
|
-
get(id: string): Factory;
|
|
226
|
-
put(obj: Factory): Factory;
|
|
227
|
-
pop(obj: Factory): Factory;
|
|
228
|
-
all(): Record<string, Factory>;
|
|
229
|
-
clear(): {};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
interface TrafficSceneOptions {
|
|
233
|
-
carsNumber?: number;
|
|
234
|
-
gridSize?: number;
|
|
235
|
-
}
|
|
236
|
-
declare class TrafficScene {
|
|
237
|
-
toRemove: any[];
|
|
238
|
-
options: TrafficSceneOptions;
|
|
239
|
-
carsNumber: number;
|
|
240
|
-
gridSize: number;
|
|
241
|
-
carsList: {};
|
|
242
|
-
cars: Pool;
|
|
243
|
-
intersections: Pool;
|
|
244
|
-
roads: Pool;
|
|
245
|
-
constructor(options: TrafficSceneOptions);
|
|
246
|
-
/**
|
|
247
|
-
* 开始运行交通轨迹。
|
|
248
|
-
*
|
|
249
|
-
* @english
|
|
250
|
-
* Start running traffic trajectory.
|
|
251
|
-
* @return void
|
|
252
|
-
*/
|
|
253
|
-
run(): void;
|
|
254
|
-
/**
|
|
255
|
-
* 停止运行交通轨迹。
|
|
256
|
-
*
|
|
257
|
-
* @english
|
|
258
|
-
* Stop running traffic trajectory.
|
|
259
|
-
* @return void
|
|
260
|
-
*/
|
|
261
|
-
stop(): void;
|
|
262
|
-
/**
|
|
263
|
-
* 移除当前轨迹图层。
|
|
264
|
-
*
|
|
265
|
-
* @english
|
|
266
|
-
* Remove the traffic trajectory layer.
|
|
267
|
-
* @return void
|
|
268
|
-
*/
|
|
269
|
-
remove(): void;
|
|
270
|
-
/**
|
|
271
|
-
* 设置模型的样式。
|
|
272
|
-
*
|
|
273
|
-
* @english
|
|
274
|
-
* Set symbols of gltf models.
|
|
275
|
-
* @param symbols - symbols of gltf markers
|
|
276
|
-
* @return void
|
|
277
|
-
*/
|
|
278
|
-
setSymbols(symbols: object[]): void;
|
|
279
|
-
/**
|
|
280
|
-
* 显示隐藏车辆模型。
|
|
281
|
-
*
|
|
282
|
-
* @english
|
|
283
|
-
* Show or hide car model.
|
|
284
|
-
* @param car - car model
|
|
285
|
-
* @param type - action type show or hide
|
|
286
|
-
* @param id - car model id
|
|
287
|
-
* @return void
|
|
288
|
-
*/
|
|
289
|
-
showHideCar(car: Car, type?: string, id?: string): void;
|
|
290
|
-
/**
|
|
291
|
-
* 获取瞬时速度。
|
|
292
|
-
*
|
|
293
|
-
* @english
|
|
294
|
-
* Get instant speed.
|
|
295
|
-
* @return instant speed
|
|
296
|
-
*/
|
|
297
|
-
get instantSpeed(): number;
|
|
298
|
-
get map(): any;
|
|
299
|
-
/**
|
|
300
|
-
* 图层添加到 GroupGlLayer。
|
|
301
|
-
*
|
|
302
|
-
* @english
|
|
303
|
-
* Add the layer to groupGlLayer.
|
|
304
|
-
* @param symbols - symbols of gltf markers
|
|
305
|
-
* @return void
|
|
306
|
-
*/
|
|
307
|
-
addTo(groupgllayer: any): void;
|
|
308
|
-
/**
|
|
309
|
-
* 整体设置图层上的数据信息。
|
|
310
|
-
*
|
|
311
|
-
* @english
|
|
312
|
-
* Overall setting of data information on layers.
|
|
313
|
-
* @return cars number
|
|
314
|
-
*/
|
|
315
|
-
set(obj?: any): number;
|
|
316
|
-
/**
|
|
317
|
-
* 保存当前图层数据信息到localStorage。
|
|
318
|
-
*
|
|
319
|
-
* @english
|
|
320
|
-
* Save this layer data info to localStorage.
|
|
321
|
-
* @return data string
|
|
322
|
-
*/
|
|
323
|
-
save(): string;
|
|
324
|
-
/**
|
|
325
|
-
* 设置车辆模型数量。
|
|
326
|
-
*
|
|
327
|
-
* @english
|
|
328
|
-
* Set the number of car models.
|
|
329
|
-
* @param num - number of cars
|
|
330
|
-
* @return void
|
|
331
|
-
*/
|
|
332
|
-
setCarNumber(num: number): void;
|
|
333
|
-
/**
|
|
334
|
-
* 获取车辆模型数量。
|
|
335
|
-
*
|
|
336
|
-
* @english
|
|
337
|
-
* Get the number of car models.
|
|
338
|
-
* @return cars number
|
|
339
|
-
*/
|
|
340
|
-
getCarNumber(): number;
|
|
341
|
-
load(): any[];
|
|
342
|
-
/**
|
|
343
|
-
* 设置交叉路段。
|
|
344
|
-
*
|
|
345
|
-
* @english
|
|
346
|
-
* Set a intersect segment.
|
|
347
|
-
* @param segment - segment data
|
|
348
|
-
* @param line - line data
|
|
349
|
-
* @return intersect data info
|
|
350
|
-
*/
|
|
351
|
-
intersectSegment(segment: any, line: any): any;
|
|
352
|
-
intersection(segment: any, compareLineIndex: any, segmentIndex: any, lines: any, intersectPoints: any, lineLengthMap: any): void;
|
|
353
|
-
/**
|
|
354
|
-
* 生成交通数据。
|
|
355
|
-
*
|
|
356
|
-
* @english
|
|
357
|
-
* Generate traffic data.
|
|
358
|
-
* @param lines - line data to generate traffic
|
|
359
|
-
* @return void
|
|
360
|
-
*/
|
|
361
|
-
generateTraffic(lines: any): void;
|
|
362
|
-
/**
|
|
363
|
-
* 比较当前点数据和前一个点数据。
|
|
364
|
-
*
|
|
365
|
-
* @english
|
|
366
|
-
* Compare current point and pre point.
|
|
367
|
-
* @param point - point data
|
|
368
|
-
* @param index - data index
|
|
369
|
-
* @param intersectPoints - intersect points data
|
|
370
|
-
* @return void
|
|
371
|
-
*/
|
|
372
|
-
comparePrePoint(point: any, index: any, intersectPoints: any): void;
|
|
373
|
-
/**
|
|
374
|
-
* 获取前一个数据。
|
|
375
|
-
*
|
|
376
|
-
* @english
|
|
377
|
-
* Get pre data.
|
|
378
|
-
* @param point - point data
|
|
379
|
-
* @return pre data
|
|
380
|
-
*/
|
|
381
|
-
getPre(point: any): {
|
|
382
|
-
pre: any;
|
|
383
|
-
lineIndex: string;
|
|
384
|
-
};
|
|
385
|
-
/**
|
|
386
|
-
* 刷新车辆。
|
|
387
|
-
*
|
|
388
|
-
* @english
|
|
389
|
-
* Refresh cars added in layer.
|
|
390
|
-
* @return car
|
|
391
|
-
*/
|
|
392
|
-
clear(): number;
|
|
393
|
-
onTick(delta: number): any[];
|
|
394
|
-
/**
|
|
395
|
-
* 刷新车辆。
|
|
396
|
-
*
|
|
397
|
-
* @english
|
|
398
|
-
* Refresh cars added in layer.
|
|
399
|
-
* @return car
|
|
400
|
-
*/
|
|
401
|
-
refreshCars(): Car | Intersection | Road;
|
|
402
|
-
/**
|
|
403
|
-
* 添加道路。
|
|
404
|
-
*
|
|
405
|
-
* @english
|
|
406
|
-
* Add a road.
|
|
407
|
-
* @param road - road data
|
|
408
|
-
* @return road
|
|
409
|
-
*/
|
|
410
|
-
addRoad(road: Road): number[];
|
|
411
|
-
/**
|
|
412
|
-
* 根据id获取道路数据。
|
|
413
|
-
*
|
|
414
|
-
* @english
|
|
415
|
-
* Get a road info by id.
|
|
416
|
-
* @param id - road id
|
|
417
|
-
* @return road
|
|
418
|
-
*/
|
|
419
|
-
getRoad(id: string): Car | Intersection | Road;
|
|
420
|
-
/**
|
|
421
|
-
* 添加车辆模型。
|
|
422
|
-
*
|
|
423
|
-
* @english
|
|
424
|
-
* Add a car model.
|
|
425
|
-
* @param car - car model
|
|
426
|
-
* @return car
|
|
427
|
-
*/
|
|
428
|
-
addCar(car: Car): Car | Intersection | Road;
|
|
429
|
-
/**
|
|
430
|
-
* 根据id获取车辆信息。
|
|
431
|
-
*
|
|
432
|
-
* @english
|
|
433
|
-
* Get a car info by id.
|
|
434
|
-
* @param id - model id
|
|
435
|
-
* @return car
|
|
436
|
-
*/
|
|
437
|
-
getCar(id: string): Car | Intersection | Road;
|
|
438
|
-
/**
|
|
439
|
-
* 移除车辆模型。
|
|
440
|
-
*
|
|
441
|
-
* @english
|
|
442
|
-
* Remove a car.
|
|
443
|
-
* @param car - car model
|
|
444
|
-
* @return car
|
|
445
|
-
*/
|
|
446
|
-
removeCar(car: Car): Car | Intersection | Road;
|
|
447
|
-
/**
|
|
448
|
-
* 清空临时移除项目。
|
|
449
|
-
*
|
|
450
|
-
* @english
|
|
451
|
-
* Empty temporary removal items.
|
|
452
|
-
* @return void
|
|
453
|
-
*/
|
|
454
|
-
clearTmpRemove(): void;
|
|
455
|
-
/**
|
|
456
|
-
* 添加交叉路口。
|
|
457
|
-
*
|
|
458
|
-
* @english
|
|
459
|
-
* Add a intersection.
|
|
460
|
-
* @param intersection - intersection data
|
|
461
|
-
* @return intersection
|
|
462
|
-
*/
|
|
463
|
-
addIntersection(intersection: Intersection): Car | Intersection | Road;
|
|
464
|
-
/**
|
|
465
|
-
* 根据id获取交叉路口信息。
|
|
466
|
-
*
|
|
467
|
-
* @english
|
|
468
|
-
* Get a intersection info by id.
|
|
469
|
-
* @param id - intersection id
|
|
470
|
-
* @return intersection
|
|
471
|
-
*/
|
|
472
|
-
getIntersection(id: string): Car | Intersection | Road;
|
|
473
|
-
/**
|
|
474
|
-
* 添加一个随机车辆模型。
|
|
475
|
-
*
|
|
476
|
-
* @english
|
|
477
|
-
* Add a random car model.
|
|
478
|
-
* @return car
|
|
479
|
-
*/
|
|
480
|
-
addRandomCar(): Car | Intersection | Road;
|
|
481
|
-
/**
|
|
482
|
-
* 移除一个随机车辆模型。
|
|
483
|
-
*
|
|
484
|
-
* @english
|
|
485
|
-
* Remove a random car model.
|
|
486
|
-
* @return car
|
|
487
|
-
*/
|
|
488
|
-
removeRandomCar(): Car | Intersection | Road;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
export { TrafficScene };
|
|
492
|
-
//# sourceMappingURL=maptalks.traffic.d.ts.map
|