mobility-toolbox-js 3.0.1-beta.0 → 3.0.1-beta.2
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/README.md +11 -3
- package/api/HttpAPI.js +1 -3
- package/api/RealtimeAPI.d.ts +47 -47
- package/api/RealtimeAPI.js +74 -74
- package/api/WebSocketAPI.js +0 -1
- package/common/controls/StopFinderControlCommon.d.ts +1 -1
- package/common/controls/StopFinderControlCommon.js +1 -1
- package/common/styles/realtimeDefaultStyle.js +0 -5
- package/common/styles/realtimeHeadingStyle.js +0 -5
- package/common/styles/realtimeSimpleStyle.d.ts +0 -1
- package/common/styles/realtimeSimpleStyle.js +0 -1
- package/common/typedefs.d.ts +0 -117
- package/common/typedefs.js +0 -31
- package/common/utils/RealtimeEngine.d.ts +214 -0
- package/common/utils/RealtimeEngine.js +554 -0
- package/common/utils/getLayersAsFlatArray.d.ts +0 -1
- package/common/utils/getLayersAsFlatArray.js +0 -1
- package/common/utils/getVehiclePosition.js +1 -4
- package/common/utils/realtimeConfig.d.ts +1 -1
- package/common/utils/realtimeConfig.js +0 -1
- package/common/utils/renderTrajectories.d.ts +1 -0
- package/common/utils/renderTrajectories.js +1 -0
- package/common/utils/sortAndFilterDepartures.d.ts +1 -0
- package/common/utils/sortAndFilterDepartures.js +1 -0
- package/maplibre/controls/CopyrightControl.d.ts +9 -6
- package/maplibre/controls/CopyrightControl.js +11 -8
- package/maplibre/layers/Layer.d.ts +7 -6
- package/maplibre/layers/Layer.js +1 -2
- package/maplibre/layers/RealtimeLayer.d.ts +54 -111
- package/maplibre/layers/RealtimeLayer.js +126 -114
- package/maplibre/utils/getSourceCoordinates.d.ts +1 -0
- package/maplibre/utils/getSourceCoordinates.js +5 -4
- package/mbt.js +6960 -14605
- package/mbt.js.map +4 -4
- package/mbt.min.js +68 -71
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +13 -5
- package/ol/controls/CopyrightControl.js +13 -5
- package/ol/controls/RoutingControl.d.ts +29 -18
- package/ol/controls/RoutingControl.js +44 -56
- package/ol/controls/StopFinderControl.d.ts +21 -2
- package/ol/controls/StopFinderControl.js +22 -3
- package/ol/index.d.ts +0 -1
- package/ol/index.js +0 -1
- package/ol/layers/Layer.d.ts +17 -92
- package/ol/layers/Layer.js +17 -3
- package/ol/layers/MaplibreLayer.d.ts +47 -114
- package/ol/layers/MaplibreLayer.js +102 -46
- package/ol/layers/MaplibreStyleLayer.d.ts +67 -147
- package/ol/layers/MaplibreStyleLayer.js +170 -123
- package/ol/layers/RealtimeLayer.d.ts +85 -218
- package/ol/layers/RealtimeLayer.js +170 -181
- package/ol/layers/VectorLayer.d.ts +1 -2
- package/ol/layers/VectorLayer.js +7 -6
- package/ol/renderers/MaplibreLayerRenderer.d.ts +9 -0
- package/ol/renderers/MaplibreLayerRenderer.js +35 -137
- package/ol/renderers/MaplibreStyleLayerRenderer.js +2 -2
- package/ol/renderers/RealtimeLayerRenderer.d.ts +1 -1
- package/ol/renderers/RealtimeLayerRenderer.js +6 -31
- package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
- package/ol/styles/fullTrajectoryStyle.d.ts +1 -2
- package/ol/styles/fullTrajectoryStyle.js +5 -7
- package/ol/styles/routingStyle.d.ts +0 -1
- package/ol/styles/routingStyle.js +13 -10
- package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
- package/ol/utils/defineDeprecatedProperties.js +180 -0
- package/package.json +40 -39
- package/setupTests.js +14 -0
- package/types/common.d.ts +4 -27
- package/types/realtime.d.ts +7 -2
- package/common/mixins/RealtimeLayerMixin.d.ts +0 -267
- package/common/mixins/RealtimeLayerMixin.js +0 -751
- package/ol/mixins/MobilityLayerMixin.d.ts +0 -96
- package/ol/mixins/MobilityLayerMixin.js +0 -6
- package/ol/mixins/PropertiesLayerMixin.d.ts +0 -136
- package/ol/mixins/PropertiesLayerMixin.js +0 -178
- package/ol/mixins/index.d.ts +0 -1
- package/ol/mixins/index.js +0 -2
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The tools in this library have been inspired by many projects realized for publi
|
|
|
10
10
|
|
|
11
11
|
## Documentation and examples
|
|
12
12
|
|
|
13
|
-
Visit https://mobility-toolbox-js.
|
|
13
|
+
Visit https://mobility-toolbox-js.geops.io/
|
|
14
14
|
|
|
15
15
|
## Demos
|
|
16
16
|
|
|
@@ -24,7 +24,7 @@ Visit https://mobility-toolbox-js.vercel.app/
|
|
|
24
24
|
Install the library and the peer dependencies:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
yarn add mobility-toolbox-js
|
|
27
|
+
yarn add ol maplibre-gl mobility-toolbox-js
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
## Development
|
|
@@ -34,9 +34,17 @@ yarn install
|
|
|
34
34
|
yarn dev
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
`yarn dev` starts a vite server using the `index.html` file at the root of the project.
|
|
38
|
+
This html file loads the `dev.js` file. Use this file to develop the library.
|
|
39
|
+
Each time you modifiy the library code you have to run `yarn build:tsc` to see the changes.
|
|
40
|
+
|
|
41
|
+
## Development documentation
|
|
42
|
+
|
|
43
|
+
The documentations website is located in the `doc/` folder.
|
|
44
|
+
It's a nextJS website that use the mobility-toolbox-js library built from the `build/` folder.
|
|
45
|
+
|
|
37
46
|
## Deploy
|
|
38
47
|
|
|
39
48
|
This library website is deployed automatically using [Vercel](https://vercel.com/geops).
|
|
40
49
|
For Vercel we have to add the nextjs and raw-loader modules in the dev dependencies of the main package.json.
|
|
41
50
|
But those 2 librairies are not needed to build the library.
|
|
42
|
-
|
package/api/HttpAPI.js
CHANGED
|
@@ -14,9 +14,7 @@ import getUrlWithParams from '../common/utils/getUrlWithParams';
|
|
|
14
14
|
*/
|
|
15
15
|
class HttpAPI {
|
|
16
16
|
constructor(options) {
|
|
17
|
-
/** @private */
|
|
18
17
|
this.url = options.url;
|
|
19
|
-
/** @private */
|
|
20
18
|
this.apiKey = options.apiKey;
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
@@ -29,7 +27,7 @@ class HttpAPI {
|
|
|
29
27
|
if (!this.url) {
|
|
30
28
|
throw new Error(`No url defined for request to ${this.url}/${path}`);
|
|
31
29
|
}
|
|
32
|
-
if (!this.url && !this.apiKey &&
|
|
30
|
+
if (!this.url && !this.apiKey && !this.url.includes('key=')) {
|
|
33
31
|
// eslint-disable-next-line no-console
|
|
34
32
|
throw new Error(`No apiKey defined for request to ${this.url}`);
|
|
35
33
|
}
|
package/api/RealtimeAPI.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export declare const RealtimeModes: {
|
|
|
55
55
|
* });
|
|
56
56
|
*
|
|
57
57
|
* // Close the websocket connection
|
|
58
|
-
*
|
|
58
|
+
* api.close();
|
|
59
59
|
*
|
|
60
60
|
* @public
|
|
61
61
|
*/
|
|
@@ -63,12 +63,55 @@ declare class RealtimeAPI {
|
|
|
63
63
|
_bbox?: RealtimeBbox;
|
|
64
64
|
_buffer?: number[];
|
|
65
65
|
_url: string;
|
|
66
|
+
version: RealtimeVersion;
|
|
67
|
+
wsApi: WebSocketAPI;
|
|
68
|
+
/**
|
|
69
|
+
* This callback type is called `requestCallback` and is displayed as a global symbol.
|
|
70
|
+
*
|
|
71
|
+
* @callback onFullTrajectoryMessageCallback
|
|
72
|
+
* @param {number} responseCode
|
|
73
|
+
* @param {string} responseMessage
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* The bounding box to receive data from.\
|
|
77
|
+
* Example: [minX, minY, maxX, maxY, zoom, mots , gen_level, tenant, ...]\
|
|
78
|
+
* \
|
|
79
|
+
* Where:
|
|
80
|
+
* - **minX**: a string representation of an integer (not a float) representing the minimal X coordinate (in EPSG:3857) of a bounding box\
|
|
81
|
+
*
|
|
82
|
+
* - **minY**: a string representation of an integer (not a float) representing the minimal Y coordinate (in EPSG:3857) of a bounding box\
|
|
83
|
+
*
|
|
84
|
+
* - **maxX**: a string representation of an integer (not a float) representing the maximal X coordinate (in EPSG:3857) of a bounding box\
|
|
85
|
+
*
|
|
86
|
+
* - **maxY**: a string representation of an integer (not a float) representing the maximal Y coordinate (in EPSG:3857) of a bounding box\
|
|
87
|
+
*
|
|
88
|
+
* - **zoom**: a string representation of an integer representing the zoom level (from 4 to 22). When zoom < 8 only the trains are displayed for performance reasons.\
|
|
89
|
+
*
|
|
90
|
+
* - **mots**: A comma separated list of modes of transport. **Optional**.\
|
|
91
|
+
* Example: "mots=rail,subway".\
|
|
92
|
+
*
|
|
93
|
+
* - **gen_level**: An integer representing the generalization level. **Optional**.\
|
|
94
|
+
* Example: "gen_level=5"\
|
|
95
|
+
*
|
|
96
|
+
* - **tenant**: A string representing the tenant. **Optional**.\
|
|
97
|
+
* Example: "tenant=sbb"\
|
|
98
|
+
*
|
|
99
|
+
* - ...: Any other values added to the bbox will be send to the server
|
|
100
|
+
*
|
|
101
|
+
* @type {string[]}
|
|
102
|
+
*
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
get bbox(): RealtimeBbox | undefined;
|
|
106
|
+
set bbox(newBbox: RealtimeBbox | undefined);
|
|
107
|
+
get buffer(): number[] | undefined;
|
|
108
|
+
set buffer(newBuffer: number[] | undefined);
|
|
109
|
+
get url(): string;
|
|
110
|
+
set url(newUrl: string);
|
|
66
111
|
private pingInterval;
|
|
67
112
|
private pingIntervalMs;
|
|
68
113
|
private reconnectTimeout?;
|
|
69
114
|
private reconnectTimeoutMs?;
|
|
70
|
-
version: RealtimeVersion;
|
|
71
|
-
wsApi: WebSocketAPI;
|
|
72
115
|
/**
|
|
73
116
|
* Constructor
|
|
74
117
|
*
|
|
@@ -350,55 +393,12 @@ declare class RealtimeAPI {
|
|
|
350
393
|
* @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
351
394
|
* @public
|
|
352
395
|
*/
|
|
353
|
-
|
|
396
|
+
unsubscribeTimetable(stationId: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
|
|
354
397
|
/**
|
|
355
398
|
* Unsubscribe to trajectory channels.
|
|
356
399
|
* @param {function(data: { content: RealtimeTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
357
400
|
* @public
|
|
358
401
|
*/
|
|
359
402
|
unsubscribeTrajectory(onMessage: WebSocketAPIMessageCallback<RealtimeTrajectory>): void;
|
|
360
|
-
/**
|
|
361
|
-
* This callback type is called `requestCallback` and is displayed as a global symbol.
|
|
362
|
-
*
|
|
363
|
-
* @callback onFullTrajectoryMessageCallback
|
|
364
|
-
* @param {number} responseCode
|
|
365
|
-
* @param {string} responseMessage
|
|
366
|
-
*/
|
|
367
|
-
/**
|
|
368
|
-
* The bounding box to receive data from.\
|
|
369
|
-
* Example: [minX, minY, maxX, maxY, zoom, mots , gen_level, tenant, ...]\
|
|
370
|
-
* \
|
|
371
|
-
* Where:
|
|
372
|
-
* - **minX**: a string representation of an integer (not a float) representing the minimal X coordinate (in EPSG:3857) of a bounding box\
|
|
373
|
-
*
|
|
374
|
-
* - **minY**: a string representation of an integer (not a float) representing the minimal Y coordinate (in EPSG:3857) of a bounding box\
|
|
375
|
-
*
|
|
376
|
-
* - **maxX**: a string representation of an integer (not a float) representing the maximal X coordinate (in EPSG:3857) of a bounding box\
|
|
377
|
-
*
|
|
378
|
-
* - **maxY**: a string representation of an integer (not a float) representing the maximal Y coordinate (in EPSG:3857) of a bounding box\
|
|
379
|
-
*
|
|
380
|
-
* - **zoom**: a string representation of an integer representing the zoom level (from 4 to 22). When zoom < 8 only the trains are displayed for performance reasons.\
|
|
381
|
-
*
|
|
382
|
-
* - **mots**: A comma separated list of modes of transport. **Optional**.\
|
|
383
|
-
* Example: "mots=rail,subway".\
|
|
384
|
-
*
|
|
385
|
-
* - **gen_level**: An integer representing the generalization level. **Optional**.\
|
|
386
|
-
* Example: "gen_level=5"\
|
|
387
|
-
*
|
|
388
|
-
* - **tenant**: A string representing the tenant. **Optional**.\
|
|
389
|
-
* Example: "tenant=sbb"\
|
|
390
|
-
*
|
|
391
|
-
* - ...: Any other values added to the bbox will be send to the server
|
|
392
|
-
*
|
|
393
|
-
* @type {string[]}
|
|
394
|
-
*
|
|
395
|
-
* @public
|
|
396
|
-
*/
|
|
397
|
-
get bbox(): RealtimeBbox | undefined;
|
|
398
|
-
set bbox(newBbox: RealtimeBbox | undefined);
|
|
399
|
-
get buffer(): number[] | undefined;
|
|
400
|
-
set buffer(newBuffer: number[] | undefined);
|
|
401
|
-
get url(): string;
|
|
402
|
-
set url(newUrl: string);
|
|
403
403
|
}
|
|
404
404
|
export default RealtimeAPI;
|
package/api/RealtimeAPI.js
CHANGED
|
@@ -39,11 +39,82 @@ export const RealtimeModes = {
|
|
|
39
39
|
* });
|
|
40
40
|
*
|
|
41
41
|
* // Close the websocket connection
|
|
42
|
-
*
|
|
42
|
+
* api.close();
|
|
43
43
|
*
|
|
44
44
|
* @public
|
|
45
45
|
*/
|
|
46
46
|
class RealtimeAPI {
|
|
47
|
+
/**
|
|
48
|
+
* This callback type is called `requestCallback` and is displayed as a global symbol.
|
|
49
|
+
*
|
|
50
|
+
* @callback onFullTrajectoryMessageCallback
|
|
51
|
+
* @param {number} responseCode
|
|
52
|
+
* @param {string} responseMessage
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* The bounding box to receive data from.\
|
|
56
|
+
* Example: [minX, minY, maxX, maxY, zoom, mots , gen_level, tenant, ...]\
|
|
57
|
+
* \
|
|
58
|
+
* Where:
|
|
59
|
+
* - **minX**: a string representation of an integer (not a float) representing the minimal X coordinate (in EPSG:3857) of a bounding box\
|
|
60
|
+
*
|
|
61
|
+
* - **minY**: a string representation of an integer (not a float) representing the minimal Y coordinate (in EPSG:3857) of a bounding box\
|
|
62
|
+
*
|
|
63
|
+
* - **maxX**: a string representation of an integer (not a float) representing the maximal X coordinate (in EPSG:3857) of a bounding box\
|
|
64
|
+
*
|
|
65
|
+
* - **maxY**: a string representation of an integer (not a float) representing the maximal Y coordinate (in EPSG:3857) of a bounding box\
|
|
66
|
+
*
|
|
67
|
+
* - **zoom**: a string representation of an integer representing the zoom level (from 4 to 22). When zoom < 8 only the trains are displayed for performance reasons.\
|
|
68
|
+
*
|
|
69
|
+
* - **mots**: A comma separated list of modes of transport. **Optional**.\
|
|
70
|
+
* Example: "mots=rail,subway".\
|
|
71
|
+
*
|
|
72
|
+
* - **gen_level**: An integer representing the generalization level. **Optional**.\
|
|
73
|
+
* Example: "gen_level=5"\
|
|
74
|
+
*
|
|
75
|
+
* - **tenant**: A string representing the tenant. **Optional**.\
|
|
76
|
+
* Example: "tenant=sbb"\
|
|
77
|
+
*
|
|
78
|
+
* - ...: Any other values added to the bbox will be send to the server
|
|
79
|
+
*
|
|
80
|
+
* @type {string[]}
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
get bbox() {
|
|
85
|
+
return this._bbox;
|
|
86
|
+
}
|
|
87
|
+
set bbox(newBbox) {
|
|
88
|
+
if (JSON.stringify(newBbox) !== JSON.stringify(this._bbox)) {
|
|
89
|
+
this._bbox = newBbox;
|
|
90
|
+
if (this.wsApi && this._bbox) {
|
|
91
|
+
this.wsApi.send(`BBOX ${this._bbox.join(' ')}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
get buffer() {
|
|
96
|
+
return this._buffer;
|
|
97
|
+
}
|
|
98
|
+
set buffer(newBuffer) {
|
|
99
|
+
if (JSON.stringify(newBuffer) !== JSON.stringify(this._buffer)) {
|
|
100
|
+
this._buffer = newBuffer;
|
|
101
|
+
if (this.wsApi && this._buffer) {
|
|
102
|
+
this.wsApi.send(`BUFFER ${this._buffer.join(' ')}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
get url() {
|
|
107
|
+
return this._url;
|
|
108
|
+
}
|
|
109
|
+
set url(newUrl) {
|
|
110
|
+
if (this._url !== newUrl) {
|
|
111
|
+
this._url = newUrl;
|
|
112
|
+
// Update the websocket only if the url has changed and the websocket is already open or is opening.
|
|
113
|
+
if (this.wsApi.open || this.wsApi.connecting) {
|
|
114
|
+
this.open();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
47
118
|
/**
|
|
48
119
|
* Constructor
|
|
49
120
|
*
|
|
@@ -422,7 +493,7 @@ class RealtimeAPI {
|
|
|
422
493
|
* @deprecated Use RealtimeAPI.unsubscribeTimetabe instead.
|
|
423
494
|
*/
|
|
424
495
|
unsubscribeDepartures(stationId, onMessage) {
|
|
425
|
-
this.
|
|
496
|
+
this.unsubscribeTimetable(stationId, onMessage);
|
|
426
497
|
}
|
|
427
498
|
/**
|
|
428
499
|
* Unsubscribe disruptions.
|
|
@@ -490,7 +561,7 @@ class RealtimeAPI {
|
|
|
490
561
|
* @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
491
562
|
* @public
|
|
492
563
|
*/
|
|
493
|
-
|
|
564
|
+
unsubscribeTimetable(stationId, onMessage) {
|
|
494
565
|
this.unsubscribe(`timetable_${stationId}`, '', onMessage);
|
|
495
566
|
}
|
|
496
567
|
/**
|
|
@@ -501,76 +572,5 @@ class RealtimeAPI {
|
|
|
501
572
|
unsubscribeTrajectory(onMessage) {
|
|
502
573
|
this.unsubscribe(`trajectory`, '', onMessage);
|
|
503
574
|
}
|
|
504
|
-
/**
|
|
505
|
-
* This callback type is called `requestCallback` and is displayed as a global symbol.
|
|
506
|
-
*
|
|
507
|
-
* @callback onFullTrajectoryMessageCallback
|
|
508
|
-
* @param {number} responseCode
|
|
509
|
-
* @param {string} responseMessage
|
|
510
|
-
*/
|
|
511
|
-
/**
|
|
512
|
-
* The bounding box to receive data from.\
|
|
513
|
-
* Example: [minX, minY, maxX, maxY, zoom, mots , gen_level, tenant, ...]\
|
|
514
|
-
* \
|
|
515
|
-
* Where:
|
|
516
|
-
* - **minX**: a string representation of an integer (not a float) representing the minimal X coordinate (in EPSG:3857) of a bounding box\
|
|
517
|
-
*
|
|
518
|
-
* - **minY**: a string representation of an integer (not a float) representing the minimal Y coordinate (in EPSG:3857) of a bounding box\
|
|
519
|
-
*
|
|
520
|
-
* - **maxX**: a string representation of an integer (not a float) representing the maximal X coordinate (in EPSG:3857) of a bounding box\
|
|
521
|
-
*
|
|
522
|
-
* - **maxY**: a string representation of an integer (not a float) representing the maximal Y coordinate (in EPSG:3857) of a bounding box\
|
|
523
|
-
*
|
|
524
|
-
* - **zoom**: a string representation of an integer representing the zoom level (from 4 to 22). When zoom < 8 only the trains are displayed for performance reasons.\
|
|
525
|
-
*
|
|
526
|
-
* - **mots**: A comma separated list of modes of transport. **Optional**.\
|
|
527
|
-
* Example: "mots=rail,subway".\
|
|
528
|
-
*
|
|
529
|
-
* - **gen_level**: An integer representing the generalization level. **Optional**.\
|
|
530
|
-
* Example: "gen_level=5"\
|
|
531
|
-
*
|
|
532
|
-
* - **tenant**: A string representing the tenant. **Optional**.\
|
|
533
|
-
* Example: "tenant=sbb"\
|
|
534
|
-
*
|
|
535
|
-
* - ...: Any other values added to the bbox will be send to the server
|
|
536
|
-
*
|
|
537
|
-
* @type {string[]}
|
|
538
|
-
*
|
|
539
|
-
* @public
|
|
540
|
-
*/
|
|
541
|
-
get bbox() {
|
|
542
|
-
return this._bbox;
|
|
543
|
-
}
|
|
544
|
-
set bbox(newBbox) {
|
|
545
|
-
if (JSON.stringify(newBbox) !== JSON.stringify(this._bbox)) {
|
|
546
|
-
this._bbox = newBbox;
|
|
547
|
-
if (this.wsApi && this._bbox) {
|
|
548
|
-
this.wsApi.send(`BBOX ${this._bbox.join(' ')}`);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
get buffer() {
|
|
553
|
-
return this._buffer;
|
|
554
|
-
}
|
|
555
|
-
set buffer(newBuffer) {
|
|
556
|
-
if (JSON.stringify(newBuffer) !== JSON.stringify(this._buffer)) {
|
|
557
|
-
this._buffer = newBuffer;
|
|
558
|
-
if (this.wsApi && this._buffer) {
|
|
559
|
-
this.wsApi.send(`BUFFER ${this._buffer.join(' ')}`);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
get url() {
|
|
564
|
-
return this._url;
|
|
565
|
-
}
|
|
566
|
-
set url(newUrl) {
|
|
567
|
-
if (this._url !== newUrl) {
|
|
568
|
-
this._url = newUrl;
|
|
569
|
-
// Update the websocket only if the url has changed and the websocket is already open or is opening.
|
|
570
|
-
if (this.wsApi.open || this.wsApi.connecting) {
|
|
571
|
-
this.open();
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
575
|
}
|
|
576
576
|
export default RealtimeAPI;
|
package/api/WebSocketAPI.js
CHANGED
|
@@ -30,7 +30,7 @@ declare class StopFinderControlCommon {
|
|
|
30
30
|
* @param {Object} options Options
|
|
31
31
|
* @param {HTMLElement} options.element HTML element where to attach input and suggestions.
|
|
32
32
|
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/). See StopsAPI.
|
|
33
|
-
* @param {string} [options.url='https://api.geops.io/
|
|
33
|
+
* @param {string} [options.url='https://api.geops.io/stops/v1/'] Stops service url. See StopsAPI.
|
|
34
34
|
* @param {string} [options.placeholder='Search for a stop...'] Input field placeholder.
|
|
35
35
|
* @param {StopsSearchParams} [options.apiParams={ limit: 20 }] Request parameters. See [Stops service documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
|
|
36
36
|
*/
|
|
@@ -13,7 +13,7 @@ class StopFinderControlCommon {
|
|
|
13
13
|
* @param {Object} options Options
|
|
14
14
|
* @param {HTMLElement} options.element HTML element where to attach input and suggestions.
|
|
15
15
|
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/). See StopsAPI.
|
|
16
|
-
* @param {string} [options.url='https://api.geops.io/
|
|
16
|
+
* @param {string} [options.url='https://api.geops.io/stops/v1/'] Stops service url. See StopsAPI.
|
|
17
17
|
* @param {string} [options.placeholder='Search for a stop...'] Input field placeholder.
|
|
18
18
|
* @param {StopsSearchParams} [options.apiParams={ limit: 20 }] Request parameters. See [Stops service documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
|
|
19
19
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import createCanvas from '../utils/createCanvas';
|
|
2
|
-
/** @private */
|
|
3
2
|
const cacheDelayBg = {};
|
|
4
3
|
/**
|
|
5
4
|
* Draw circle delay background
|
|
@@ -25,7 +24,6 @@ export const getDelayBgCanvas = (origin, radius, color) => {
|
|
|
25
24
|
}
|
|
26
25
|
return cacheDelayBg[key];
|
|
27
26
|
};
|
|
28
|
-
/** @private */
|
|
29
27
|
const cacheDelayText = {};
|
|
30
28
|
/**
|
|
31
29
|
* Draw delay text
|
|
@@ -55,7 +53,6 @@ export const getDelayTextCanvas = (text, fontSize, font, delayColor, delayOutlin
|
|
|
55
53
|
}
|
|
56
54
|
return cacheDelayText[key];
|
|
57
55
|
};
|
|
58
|
-
/** @private */
|
|
59
56
|
const cacheCircle = {};
|
|
60
57
|
/**
|
|
61
58
|
* Draw colored circle with black border
|
|
@@ -90,7 +87,6 @@ export const getCircleCanvas = (origin, radius, color, hasStroke, hasDash, pixel
|
|
|
90
87
|
}
|
|
91
88
|
return cacheCircle[key];
|
|
92
89
|
};
|
|
93
|
-
/** @private */
|
|
94
90
|
const cacheText = {};
|
|
95
91
|
/**
|
|
96
92
|
* Draw text in the circle
|
|
@@ -129,7 +125,6 @@ export const getTextCanvas = (text, origin, textSize, fillColor, strokeColor, ha
|
|
|
129
125
|
}
|
|
130
126
|
return cacheText[key];
|
|
131
127
|
};
|
|
132
|
-
/** @private */
|
|
133
128
|
const cache = {};
|
|
134
129
|
/**
|
|
135
130
|
* A tracker style that take in account the delay.
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import createCanvas from '../utils/createCanvas';
|
|
2
2
|
import { getBgColor } from '../utils/realtimeConfig';
|
|
3
3
|
import realtimeDefaultStyle from './realtimeDefaultStyle';
|
|
4
|
-
/** @private */
|
|
5
4
|
const rotateCanvas = (canvas, rotation) => {
|
|
6
5
|
const ctx = canvas.getContext('2d');
|
|
7
6
|
ctx === null || ctx === void 0 ? void 0 : ctx.translate(canvas.width / 2, canvas.height / 2);
|
|
8
7
|
ctx === null || ctx === void 0 ? void 0 : ctx.rotate(rotation);
|
|
9
8
|
ctx === null || ctx === void 0 ? void 0 : ctx.translate(-canvas.width / 2, -canvas.height / 2);
|
|
10
9
|
};
|
|
11
|
-
/** @private */
|
|
12
10
|
const arrowCache = {};
|
|
13
|
-
/** @private */
|
|
14
11
|
const getArrowCanvas = (fillColor) => {
|
|
15
12
|
const key = `${fillColor}`;
|
|
16
13
|
if (!arrowCache[key]) {
|
|
@@ -35,9 +32,7 @@ const getArrowCanvas = (fillColor) => {
|
|
|
35
32
|
}
|
|
36
33
|
return arrowCache[key];
|
|
37
34
|
};
|
|
38
|
-
/** @private */
|
|
39
35
|
const bufferArrowCache = {};
|
|
40
|
-
/** @private */
|
|
41
36
|
const getBufferArrowCanvas = (canvas, fillColor, rotation) => {
|
|
42
37
|
const margin = 20;
|
|
43
38
|
const bufferKey = `${fillColor},${canvas.width},${canvas.height},${rotation}`;
|
package/common/typedefs.d.ts
CHANGED
|
@@ -50,88 +50,6 @@ export type FeatureInfo = {
|
|
|
50
50
|
*/
|
|
51
51
|
coordinate: number[2];
|
|
52
52
|
};
|
|
53
|
-
export type MaplibreLayerOptions = {
|
|
54
|
-
/**
|
|
55
|
-
* Access key for [geOps apis](https://developer.geops.io/).
|
|
56
|
-
*/
|
|
57
|
-
apiKey: string;
|
|
58
|
-
/**
|
|
59
|
-
* geOps Maps api key name.
|
|
60
|
-
*/
|
|
61
|
-
apiKeyName: string;
|
|
62
|
-
/**
|
|
63
|
-
* Maplibre map options.
|
|
64
|
-
*/
|
|
65
|
-
mapLibreOptions: maplibregl.MapOptions;
|
|
66
|
-
/**
|
|
67
|
-
* geOps Maps api style.
|
|
68
|
-
*/
|
|
69
|
-
style: string;
|
|
70
|
-
/**
|
|
71
|
-
* geOps Maps api url.
|
|
72
|
-
*/
|
|
73
|
-
url: string;
|
|
74
|
-
};
|
|
75
|
-
export type ControlCommonOptions = {
|
|
76
|
-
/**
|
|
77
|
-
* Whether the control is active or not.
|
|
78
|
-
*/
|
|
79
|
-
active?: boolean | undefined;
|
|
80
|
-
/**
|
|
81
|
-
* The HTML element used to render the control.
|
|
82
|
-
*/
|
|
83
|
-
element: HTMLElement;
|
|
84
|
-
/**
|
|
85
|
-
* The HTML element where to render the element property. Default is the map's element.
|
|
86
|
-
*/
|
|
87
|
-
target: HTMLElement;
|
|
88
|
-
/**
|
|
89
|
-
* Render function called whenever the control needs to be rerendered.
|
|
90
|
-
*/
|
|
91
|
-
render: Function;
|
|
92
|
-
};
|
|
93
|
-
export type LayerCommonOptions = {
|
|
94
|
-
/**
|
|
95
|
-
* Identifier of the layer. Must be unique.
|
|
96
|
-
*/
|
|
97
|
-
key: string;
|
|
98
|
-
/**
|
|
99
|
-
* Name of the layer.
|
|
100
|
-
*/
|
|
101
|
-
name: string;
|
|
102
|
-
/**
|
|
103
|
-
* Group of the layer.
|
|
104
|
-
*/
|
|
105
|
-
group: string;
|
|
106
|
-
/**
|
|
107
|
-
* List of copyrights.
|
|
108
|
-
*/
|
|
109
|
-
copyrights: string[];
|
|
110
|
-
/**
|
|
111
|
-
* List of children layers.
|
|
112
|
-
*/
|
|
113
|
-
children: Layer[];
|
|
114
|
-
/**
|
|
115
|
-
* Define if the layer is currently display on the map.
|
|
116
|
-
*/
|
|
117
|
-
visible: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
|
|
120
|
-
*/
|
|
121
|
-
disabled: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
|
|
124
|
-
*/
|
|
125
|
-
hittolerance: number;
|
|
126
|
-
/**
|
|
127
|
-
* - Custom properties.
|
|
128
|
-
*/
|
|
129
|
-
properties: Object;
|
|
130
|
-
/**
|
|
131
|
-
* - The map used to display the layer.
|
|
132
|
-
*/
|
|
133
|
-
map: AnyMap;
|
|
134
|
-
};
|
|
135
53
|
export type VehiclePosition = {
|
|
136
54
|
/**
|
|
137
55
|
* Coordinate of the vehicle position in Mercator .
|
|
@@ -142,10 +60,6 @@ export type VehiclePosition = {
|
|
|
142
60
|
*/
|
|
143
61
|
rotation: number;
|
|
144
62
|
};
|
|
145
|
-
/**
|
|
146
|
-
* /Map~Map|maplibregl.Map} AnyMap
|
|
147
|
-
*/
|
|
148
|
-
type dummy = ol;
|
|
149
63
|
/**
|
|
150
64
|
* @typedef {function} FilterFunction
|
|
151
65
|
* @param {Vehicle} vehicle Vehicle to filter.
|
|
@@ -180,37 +94,6 @@ type dummy = ol;
|
|
|
180
94
|
* @property {Feature[]} features An array of features.
|
|
181
95
|
* @property {number[2]} coordinate The coordinate where to find the featue.
|
|
182
96
|
*/
|
|
183
|
-
/**
|
|
184
|
-
* @typedef {ol/Map~Map|maplibregl.Map} AnyMap
|
|
185
|
-
*/
|
|
186
|
-
/**
|
|
187
|
-
* @typedef {Object} MaplibreLayerOptions
|
|
188
|
-
* @property {string} apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
189
|
-
* @property {string} apiKeyName geOps Maps api key name.
|
|
190
|
-
* @property {maplibregl.MapOptions} options.mapLibreOptions Maplibre map options.
|
|
191
|
-
* @property {string} style geOps Maps api style.
|
|
192
|
-
* @property {string} url geOps Maps api url.
|
|
193
|
-
*/
|
|
194
|
-
/**
|
|
195
|
-
* @typedef {Object} ControlCommonOptions
|
|
196
|
-
* @property {boolean} [active = true] Whether the control is active or not.
|
|
197
|
-
* @property {HTMLElement} element The HTML element used to render the control.
|
|
198
|
-
* @property {HTMLElement} target The HTML element where to render the element property. Default is the map's element.
|
|
199
|
-
* @property {function} render Render function called whenever the control needs to be rerendered.
|
|
200
|
-
*/
|
|
201
|
-
/**
|
|
202
|
-
* @typedef {Object} LayerCommonOptions
|
|
203
|
-
* @property {string!} key Identifier of the layer. Must be unique.
|
|
204
|
-
* @property {string!} name Name of the layer.
|
|
205
|
-
* @property {string!} group Group of the layer.
|
|
206
|
-
* @property {string[]!} copyrights List of copyrights.
|
|
207
|
-
* @property {Layer[]!} children List of children layers.
|
|
208
|
-
* @property {boolean!} visible Define if the layer is currently display on the map.
|
|
209
|
-
* @property {boolean!} disabled Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
|
|
210
|
-
* @property {number!} hittolerance Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
|
|
211
|
-
* @property {Object!} properties - Custom properties.
|
|
212
|
-
* @property {AnyMap!} map - The map used to display the layer.
|
|
213
|
-
*/
|
|
214
97
|
/**
|
|
215
98
|
* @typedef {Object} VehiclePosition
|
|
216
99
|
* @property {number[2]} coord Coordinate of the vehicle position in Mercator .
|
package/common/typedefs.js
CHANGED
|
@@ -32,37 +32,6 @@
|
|
|
32
32
|
* @property {Feature[]} features An array of features.
|
|
33
33
|
* @property {number[2]} coordinate The coordinate where to find the featue.
|
|
34
34
|
*/
|
|
35
|
-
/**
|
|
36
|
-
* @typedef {ol/Map~Map|maplibregl.Map} AnyMap
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* @typedef {Object} MaplibreLayerOptions
|
|
40
|
-
* @property {string} apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
41
|
-
* @property {string} apiKeyName geOps Maps api key name.
|
|
42
|
-
* @property {maplibregl.MapOptions} options.mapLibreOptions Maplibre map options.
|
|
43
|
-
* @property {string} style geOps Maps api style.
|
|
44
|
-
* @property {string} url geOps Maps api url.
|
|
45
|
-
*/
|
|
46
|
-
/**
|
|
47
|
-
* @typedef {Object} ControlCommonOptions
|
|
48
|
-
* @property {boolean} [active = true] Whether the control is active or not.
|
|
49
|
-
* @property {HTMLElement} element The HTML element used to render the control.
|
|
50
|
-
* @property {HTMLElement} target The HTML element where to render the element property. Default is the map's element.
|
|
51
|
-
* @property {function} render Render function called whenever the control needs to be rerendered.
|
|
52
|
-
*/
|
|
53
|
-
/**
|
|
54
|
-
* @typedef {Object} LayerCommonOptions
|
|
55
|
-
* @property {string!} key Identifier of the layer. Must be unique.
|
|
56
|
-
* @property {string!} name Name of the layer.
|
|
57
|
-
* @property {string!} group Group of the layer.
|
|
58
|
-
* @property {string[]!} copyrights List of copyrights.
|
|
59
|
-
* @property {Layer[]!} children List of children layers.
|
|
60
|
-
* @property {boolean!} visible Define if the layer is currently display on the map.
|
|
61
|
-
* @property {boolean!} disabled Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
|
|
62
|
-
* @property {number!} hittolerance Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
|
|
63
|
-
* @property {Object!} properties - Custom properties.
|
|
64
|
-
* @property {AnyMap!} map - The map used to display the layer.
|
|
65
|
-
*/
|
|
66
35
|
/**
|
|
67
36
|
* @typedef {Object} VehiclePosition
|
|
68
37
|
* @property {number[2]} coord Coordinate of the vehicle position in Mercator .
|