mobility-toolbox-js 3.0.0-beta.0 → 3.0.0-beta.10
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/LICENSE +21 -0
- package/README.md +42 -0
- package/api/HttpAPI.d.ts +20 -0
- package/api/HttpAPI.js +1 -11
- package/api/RealtimeAPI.d.ts +365 -0
- package/api/RealtimeAPI.js +102 -89
- package/api/RoutingAPI.d.ts +37 -0
- package/api/StopsAPI.d.ts +44 -0
- package/api/StopsAPI.js +15 -9
- package/api/WebSocketAPI.d.ts +153 -0
- package/api/index.d.ts +3 -0
- package/api/typedefs.d.ts +178 -0
- package/common/controls/StopFinderControlCommon.d.ts +53 -0
- package/common/index.d.ts +2 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +273 -0
- package/common/styles/index.d.ts +4 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/typedefs.d.ts +212 -0
- package/common/utils/compareDepartures.d.ts +10 -0
- package/common/utils/constants.d.ts +5 -0
- package/common/utils/createCanvas.d.ts +10 -0
- package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
- package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
- package/common/utils/createRealtimeFilters.d.ts +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts +12 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.js +5 -1
- package/common/utils/getMapGlCopyrights.d.ts +17 -0
- package/common/utils/getRealtimeModeSuffix.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts +8 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- package/common/utils/index.d.ts +16 -0
- package/common/utils/realtimeConfig.d.ts +64 -0
- package/common/utils/removeDuplicate.d.ts +9 -0
- package/common/utils/renderTrajectories.d.ts +16 -0
- package/common/utils/sortAndFilterDepartures.d.ts +15 -0
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/timeUtils.d.ts +23 -0
- package/common/utils/toMercatorExtent.d.ts +5 -0
- package/iife.d.ts +2 -0
- package/index.d.ts +9 -0
- package/maplibre/controls/CopyrightControl.d.ts +35 -0
- package/maplibre/controls/index.d.ts +1 -0
- package/maplibre/index.d.ts +5 -0
- package/maplibre/layers/Layer.d.ts +28 -0
- package/maplibre/layers/RealtimeLayer.d.ts +160 -0
- package/maplibre/layers/RealtimeLayer.js +2 -2
- package/maplibre/layers/index.d.ts +2 -0
- package/maplibre/utils/getMercatorResolution.d.ts +7 -0
- package/maplibre/utils/getSourceCoordinates.d.ts +7 -0
- package/maplibre/utils/index.d.ts +2 -0
- package/mbt.js +1395 -1293
- package/mbt.js.map +4 -4
- package/mbt.min.js +42 -42
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.js +18 -8
- package/ol/controls/RoutingControl.d.ts +209 -0
- package/ol/controls/RoutingControl.js +3 -0
- package/ol/controls/StopFinderControl.d.ts +37 -0
- package/ol/controls/StopFinderControl.js +3 -0
- package/ol/controls/index.d.ts +3 -0
- package/ol/index.d.ts +6 -0
- package/ol/layers/MapGlLayer.d.ts +144 -0
- package/ol/layers/MapGlLayer.js +7 -7
- package/ol/layers/MaplibreLayer.d.ts +63 -0
- package/ol/layers/MaplibreStyleLayer.d.ts +235 -0
- package/ol/layers/MaplibreStyleLayer.js +24 -24
- package/ol/layers/RealtimeLayer.d.ts +285 -0
- package/ol/layers/RealtimeLayer.js +13 -7
- package/ol/layers/index.d.ts +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +98 -0
- package/ol/mixins/MobilityLayerMixin.js +1 -4
- package/ol/mixins/PropertiesLayerMixin.d.ts +127 -0
- package/ol/mixins/PropertiesLayerMixin.js +6 -65
- package/ol/renderers/MaplibreLayerRenderer.d.ts +20 -0
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
- package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
- package/ol/renderers/RealtimeLayerRenderer.js +9 -9
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/routingStyle.d.ts +4 -0
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
- package/ol/utils/getFeatureInfoAtCoordinate.js +2 -2
- package/ol/utils/index.d.ts +1 -0
- package/package.json +19 -20
- package/setupTests.d.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 geOps
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# mobility-toolbox-js
|
|
2
|
+
|
|
3
|
+
Toolbox for JavaScript applications in the domains of mobility and logistics.
|
|
4
|
+
The tools in this library have been inspired by many projects realized for public transport agencies, mobility providers and logistics companies.
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/mobility-toolbox-js)
|
|
7
|
+
[](https://github.com/geops/mobility-toolbox-js/actions?query=workflow%3ABuild)
|
|
8
|
+
[](https://github.com/geops/mobility-toolbox-js/actions?query=workflow%3ALint%20/%20Unit%20tests)
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Documentation and examples
|
|
12
|
+
|
|
13
|
+
Visit https://mobility-toolbox-js.vercel.app/
|
|
14
|
+
|
|
15
|
+
## Demos
|
|
16
|
+
|
|
17
|
+
* Display [real-time vehicle positions and prognosis data](https://mobility.portal.geops.io) on a map.
|
|
18
|
+
* Search for [stops and stations](https://maps.trafimage.ch) all over the world.
|
|
19
|
+
* Get [precise geographic courses](https://routing-demo.geops.io/) for all modes of transport.
|
|
20
|
+
* Generate beautiful [schematic](https://mobility.portal.geops.io/world.geops.networkplans) or [topographic](https://mobility.portal.geops.io) maps for public transport, mobility and logistics.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
Install the library and the peer dependencies:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
yarn add mobility-toolbox-js ol maplibre-gl
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Development
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
yarn install
|
|
34
|
+
yarn dev
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Deploy
|
|
38
|
+
|
|
39
|
+
This library website is deployed automatically using [Vercel](https://vercel.com/geops).
|
|
40
|
+
For Vercel we have to add the nextjs and raw-loader modules in the dev dependencies of the main package.json.
|
|
41
|
+
But those 2 librairies are not needed to build the library.
|
|
42
|
+
|
package/api/HttpAPI.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type HttpAPIOptions = {
|
|
2
|
+
url: string;
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Common class to access to a geOps api using http.
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
declare class HttpAPI {
|
|
10
|
+
url: string;
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
constructor(options: HttpAPIOptions);
|
|
13
|
+
/**
|
|
14
|
+
* Append the apiKey before sending the request.
|
|
15
|
+
*
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
fetch(path: string, params: Object, config: RequestInit): Promise<any>;
|
|
19
|
+
}
|
|
20
|
+
export default HttpAPI;
|
package/api/HttpAPI.js
CHANGED
|
@@ -10,17 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import getUrlWithParams from '../common/utils/getUrlWithParams';
|
|
11
11
|
/**
|
|
12
12
|
* Common class to access to a geOps api using http.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* import { API } from 'mobility-toolbox-js/api';
|
|
16
|
-
*
|
|
17
|
-
* const api = new HttpApi({
|
|
18
|
-
* url: [yourUrl],
|
|
19
|
-
* apiKey: [yourApiKey]
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* @classproperty {string} url Url of the service.
|
|
23
|
-
* @classproperty {string} apiKey Api key to access the service.
|
|
24
13
|
* @private
|
|
25
14
|
*/
|
|
26
15
|
class HttpAPI {
|
|
@@ -47,6 +36,7 @@ class HttpAPI {
|
|
|
47
36
|
// Clean requets parameters, removing undefined and null values.
|
|
48
37
|
const searchParams = params || {};
|
|
49
38
|
const url = getUrlWithParams(`${this.url}${path || ''}`, Object.assign({ key: this.apiKey }, searchParams));
|
|
39
|
+
fetch;
|
|
50
40
|
const response = yield fetch(url.toString(), config);
|
|
51
41
|
const data = yield response.json();
|
|
52
42
|
if (data.error) {
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import WebSocketAPI, { WebSocketAPIMessageCallback, WebSocketAPIMessageEventData, WebSocketAPIParameters } from './WebSocketAPI';
|
|
2
|
+
import type { RealtimeMode, RealtimeDeparture, RealtimeNews, RealtimeStation, RealtimeExtraGeom, RealtimeTrainId, RealtimeGeneralizationLevel, RealtimeFullTrajectory, RealtimeTrajectoryResponse, RealtimeStationId, RealtimeVersion, RealtimeTrajectory, RealtimeTenant, RealtimeBbox } from '../types';
|
|
3
|
+
import { StopSequence } from './typedefs';
|
|
4
|
+
/**
|
|
5
|
+
* @typedef RealtimeAPIOptions
|
|
6
|
+
*/
|
|
7
|
+
export type RealtimeAPIOptions = {
|
|
8
|
+
url?: string;
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
version?: RealtimeVersion;
|
|
11
|
+
bbox?: RealtimeBbox;
|
|
12
|
+
buffer?: number[];
|
|
13
|
+
pingIntervalMs?: number;
|
|
14
|
+
reconnectTimeoutMs?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare type RealtimeAPIExtraGeomsById = {
|
|
17
|
+
[index: string]: RealtimeExtraGeom;
|
|
18
|
+
};
|
|
19
|
+
export type RealtimeAPIDeparturesById = {
|
|
20
|
+
[index: string]: RealtimeDeparture;
|
|
21
|
+
};
|
|
22
|
+
export type RealtimeModesType = {
|
|
23
|
+
RAW: RealtimeMode;
|
|
24
|
+
TOPOGRAPHIC: RealtimeMode;
|
|
25
|
+
SCHEMATIC: RealtimeMode;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Enum for Realtime modes.
|
|
29
|
+
* @readonly
|
|
30
|
+
* @typedef {string} RealtimeMode
|
|
31
|
+
* @property {string} RAW "raw"
|
|
32
|
+
* @property {string} SCHEMATIC "schematic"
|
|
33
|
+
* @property {string} TOPOGRAPHIC "topographic"
|
|
34
|
+
* @enum {RealtimeMode}
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare const RealtimeModes: {
|
|
38
|
+
RAW: RealtimeMode;
|
|
39
|
+
TOPOGRAPHIC: RealtimeMode;
|
|
40
|
+
SCHEMATIC: RealtimeMode;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* This class provides convenience methods to use to the [geOps realtime API](https://developer.geops.io/apis/realtime/).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* import { RealtimeAPI } from 'mobility-toolbox-js/api';
|
|
47
|
+
*
|
|
48
|
+
* const api = new RealtimeAPI({
|
|
49
|
+
* apiKey: "yourApiKey",
|
|
50
|
+
* bbox: [782001, 5888803, 923410, 5923660, 11, "mots=rail"],
|
|
51
|
+
* // url: "wss://api.geops.io/tracker-ws/v1/",
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* // Open the websocket connection
|
|
55
|
+
* api.open();
|
|
56
|
+
*
|
|
57
|
+
* // Subscribe to channel
|
|
58
|
+
* api.subscribeTrajectory('topographic', (data) => {
|
|
59
|
+
* console.log('Log trajectories:', JSON.stringify(data.content));
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // Close the websocket connection
|
|
63
|
+
* // api.close();
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
declare class RealtimeAPI {
|
|
68
|
+
_url: string;
|
|
69
|
+
get url(): string;
|
|
70
|
+
set url(newUrl: string);
|
|
71
|
+
_bbox?: RealtimeBbox;
|
|
72
|
+
/**
|
|
73
|
+
* The bounding box to receive data from.\
|
|
74
|
+
* Example: [minX, minY, maxX, maxY, zoom, mots , gen_level, tenant, ...]\
|
|
75
|
+
* \
|
|
76
|
+
* Where:
|
|
77
|
+
* - **minX**: a string representation of an integer (not a float) representing the minimal X coordinate (in EPSG:3857) of a bounding box\
|
|
78
|
+
*
|
|
79
|
+
* - **minY**: a string representation of an integer (not a float) representing the minimal Y coordinate (in EPSG:3857) of a bounding box\
|
|
80
|
+
*
|
|
81
|
+
* - **maxX**: a string representation of an integer (not a float) representing the maximal X coordinate (in EPSG:3857) of a bounding box\
|
|
82
|
+
*
|
|
83
|
+
* - **maxY**: a string representation of an integer (not a float) representing the maximal Y coordinate (in EPSG:3857) of a bounding box\
|
|
84
|
+
*
|
|
85
|
+
* - **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.\
|
|
86
|
+
*
|
|
87
|
+
* - **mots**: A comma separated list of modes of transport. **Optional**.\
|
|
88
|
+
* Example: "mots=rail,subway".\
|
|
89
|
+
*
|
|
90
|
+
* - **gen_level**: An integer representing the generalization level. **Optional**.\
|
|
91
|
+
* Example: "gen_level=5"\
|
|
92
|
+
*
|
|
93
|
+
* - **tenant**: A string representing the tenant. **Optional**.\
|
|
94
|
+
* Example: "tenant=sbb"\
|
|
95
|
+
*
|
|
96
|
+
* - ...: Any other values added to the bbox will be send to the server
|
|
97
|
+
*
|
|
98
|
+
* @type {string[]}
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
get bbox(): RealtimeBbox | undefined;
|
|
103
|
+
set bbox(newBbox: RealtimeBbox | undefined);
|
|
104
|
+
_buffer?: number[];
|
|
105
|
+
get buffer(): number[] | undefined;
|
|
106
|
+
set buffer(newBuffer: number[] | undefined);
|
|
107
|
+
version: RealtimeVersion;
|
|
108
|
+
wsApi: WebSocketAPI;
|
|
109
|
+
private pingInterval;
|
|
110
|
+
private pingIntervalMs;
|
|
111
|
+
private reconnectTimeout?;
|
|
112
|
+
private reconnectTimeoutMs?;
|
|
113
|
+
/**
|
|
114
|
+
* Constructor
|
|
115
|
+
*
|
|
116
|
+
* @param {Object} options Options.
|
|
117
|
+
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
118
|
+
* @param {string[]} options.bbox The bounding box to receive data from.
|
|
119
|
+
* @param {string} [options.url='wss://api.geops.io/tracker-ws/v1/'] Url of the [geOps realtime API](https://developer.geops.io/apis/realtime/).
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
constructor(options?: RealtimeAPIOptions);
|
|
123
|
+
/**
|
|
124
|
+
* Open the websocket connection.
|
|
125
|
+
*
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
open(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Close the websocket connection without reconnection.
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
close(): void;
|
|
135
|
+
/**
|
|
136
|
+
* Unsubscribe trajectory and deleted_vehicles channels. To resubscribe you have to set a new BBOX.
|
|
137
|
+
*/
|
|
138
|
+
reset(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Callback when the websocket is opened and ready.
|
|
141
|
+
* It applies the bbox and the projection.
|
|
142
|
+
* @private
|
|
143
|
+
*/
|
|
144
|
+
onOpen(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Callback when the websocket is closed by the server.
|
|
147
|
+
* It auto reconnects after a timeout.
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
onClose(): void;
|
|
151
|
+
/**
|
|
152
|
+
* Send GET to a channel.
|
|
153
|
+
*
|
|
154
|
+
* @param {string | WebSocketAPIParameters} channelOrParams Name of the websocket channel to send GET or an object representing parameters to send
|
|
155
|
+
* @return {Promise<WebSocketAPIMessageEventData<?>>} A websocket response.
|
|
156
|
+
*/
|
|
157
|
+
get(channelOrParams: string | WebSocketAPIParameters): Promise<WebSocketAPIMessageEventData<any>>;
|
|
158
|
+
/**
|
|
159
|
+
* Subscribe to a channel.
|
|
160
|
+
*
|
|
161
|
+
* @param {string} channel Name of the websocket channel to subscribe.
|
|
162
|
+
* @param {function} onSuccess Callback when the subscription succeeds.
|
|
163
|
+
* @param {function} onError Callback when the subscription fails.
|
|
164
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
subscribe(channel: string, onSuccess: WebSocketAPIMessageCallback<any>, onError?: EventListener, quiet?: boolean): void;
|
|
168
|
+
/**
|
|
169
|
+
* Unsubscribe both modes of a channel.
|
|
170
|
+
*
|
|
171
|
+
* @param {string} channel Name of the websocket channel to unsubscribe.
|
|
172
|
+
* @param {string} suffix Suffix to add to the channel name.
|
|
173
|
+
* @param {function} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
174
|
+
* @private
|
|
175
|
+
*/
|
|
176
|
+
unsubscribe(channel: string, suffix?: string, onMessage?: WebSocketAPIMessageCallback<any>): void;
|
|
177
|
+
/**
|
|
178
|
+
* Subscribe to departures channel of a given station.
|
|
179
|
+
*
|
|
180
|
+
* @param {number} stationId UIC of the station.
|
|
181
|
+
* @param {Boolean} sortByMinArrivalTime Sort by minimum arrival time
|
|
182
|
+
* @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
|
|
183
|
+
* @param {function} onError Callback when the subscription fails.
|
|
184
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
subscribeDepartures(stationId: number, onMessage: WebSocketAPIMessageCallback<RealtimeDeparture>, onError?: EventListener, quiet?: boolean): void;
|
|
188
|
+
/**
|
|
189
|
+
* Unsubscribe from current departures channel.
|
|
190
|
+
* @param {RealtimeStationId} id Station's id
|
|
191
|
+
* @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
unsubscribeDepartures(id: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
|
|
195
|
+
/**
|
|
196
|
+
* Subscribe to the disruptions channel for tenant.
|
|
197
|
+
*
|
|
198
|
+
* @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
|
|
199
|
+
* @param {function} onError Callback when the subscription fails.
|
|
200
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
201
|
+
* @public
|
|
202
|
+
*/
|
|
203
|
+
subscribeDisruptions(tenant: RealtimeTenant, onMessage: WebSocketAPIMessageCallback<RealtimeNews>, onError?: EventListener, quiet?: boolean): void;
|
|
204
|
+
/**
|
|
205
|
+
* Unsubscribe disruptions.
|
|
206
|
+
*
|
|
207
|
+
* @param {function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
208
|
+
* @public
|
|
209
|
+
*/
|
|
210
|
+
unsubscribeDisruptions(tenant: RealtimeTenant, onMessage?: WebSocketAPIMessageCallback<RealtimeNews>): void;
|
|
211
|
+
/**
|
|
212
|
+
* Return a station with a given uic number and a mode.
|
|
213
|
+
*
|
|
214
|
+
* @param {number} uic UIC of the station.
|
|
215
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
216
|
+
* @return {Promise<{data: { content: RealtimeStation }}>} A station.
|
|
217
|
+
* @public
|
|
218
|
+
*/
|
|
219
|
+
getStation(uic: RealtimeStationId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeStation>>;
|
|
220
|
+
/**
|
|
221
|
+
* Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
|
|
222
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
223
|
+
* @param {number} timeout = 100 Duration in ms between each promise resolve calls.
|
|
224
|
+
* @return {Promise<RealtimeStation[]>} An array of stations.
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
getStations(mode: RealtimeMode, timeout?: number): Promise<RealtimeStation[]>;
|
|
228
|
+
/**
|
|
229
|
+
* Subscribe to stations channel.
|
|
230
|
+
* One message pro station.
|
|
231
|
+
*
|
|
232
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
233
|
+
* @param {function(data: { content: RealtimeStation })} onMessage Function called on each message of the channel.
|
|
234
|
+
* @param {function} onError Callback when the subscription fails.
|
|
235
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
238
|
+
subscribeStations(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeStation>, onError?: EventListener, quiet?: boolean): void;
|
|
239
|
+
/**
|
|
240
|
+
* Unsubscribe to stations channel.
|
|
241
|
+
* @param {function(data: { content: RealtimeStation })} onMessage The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
unsubscribeStations(onMessage?: WebSocketAPIMessageCallback<RealtimeStation>): void;
|
|
245
|
+
/**
|
|
246
|
+
* Subscribe to extra_geoms channel.
|
|
247
|
+
*
|
|
248
|
+
* @param {function(data: { content: RealtimeExtraGeom })} onMessage Function called on each message of the channel.
|
|
249
|
+
* @param {function} onError Callback when the subscription fails.
|
|
250
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
251
|
+
*/
|
|
252
|
+
subscribeExtraGeoms(onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>, onError?: EventListener, quiet?: boolean): void;
|
|
253
|
+
/**
|
|
254
|
+
* Unsubscribe to extra_geoms channel.
|
|
255
|
+
* @param {function(data: { content: RealtimeExtraGeom })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
256
|
+
*/
|
|
257
|
+
unsubscribeExtraGeoms(onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>): void;
|
|
258
|
+
/**
|
|
259
|
+
* Return a partial trajectory with a given id and a mode.
|
|
260
|
+
*
|
|
261
|
+
* @param {number} trainId The identifier of a trajectory.
|
|
262
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
263
|
+
* @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
|
|
264
|
+
* @public
|
|
265
|
+
*/
|
|
266
|
+
getTrajectory(id: RealtimeTrainId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeTrajectory>>;
|
|
267
|
+
/**
|
|
268
|
+
* Subscribe to trajectory channel.
|
|
269
|
+
*
|
|
270
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
271
|
+
* @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Function called on each message of the channel.
|
|
272
|
+
* @param {function} onError Callback when the subscription fails.
|
|
273
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
274
|
+
* @public
|
|
275
|
+
*/
|
|
276
|
+
subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrajectoryResponse[] | RealtimeTrajectoryResponse>, onError?: EventListener, quiet?: boolean): void;
|
|
277
|
+
/**
|
|
278
|
+
* Unsubscribe to trajectory channels.
|
|
279
|
+
* @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
280
|
+
* @public
|
|
281
|
+
*/
|
|
282
|
+
unsubscribeTrajectory(onMessage: WebSocketAPIMessageCallback<RealtimeTrajectoryResponse[]>): void;
|
|
283
|
+
/**
|
|
284
|
+
* Subscribe to deleted_vhicles channel.
|
|
285
|
+
*
|
|
286
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
287
|
+
* @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
288
|
+
* @param {function} onError Callback when the subscription fails.
|
|
289
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
290
|
+
*/
|
|
291
|
+
subscribeDeletedVehicles(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>, onError?: EventListener, quiet?: boolean): void;
|
|
292
|
+
/**
|
|
293
|
+
* Unsubscribe to deleted_vhicles channels.
|
|
294
|
+
* @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
295
|
+
*/
|
|
296
|
+
unsubscribeDeletedVehicles(onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>): void;
|
|
297
|
+
/**
|
|
298
|
+
* Get a full trajectory of a vehicule .
|
|
299
|
+
*
|
|
300
|
+
* @param {string} id A vehicle id.
|
|
301
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
302
|
+
* @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
|
|
303
|
+
* @return {Promise<{ data: { content: RealtimeFullTrajectory } }>} Return a full trajectory.
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
306
|
+
getFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, generalizationLevel: RealtimeGeneralizationLevel | undefined): Promise<WebSocketAPIMessageEventData<RealtimeFullTrajectory>>;
|
|
307
|
+
/**
|
|
308
|
+
* Subscribe to full_trajectory channel of a given vehicle.
|
|
309
|
+
*
|
|
310
|
+
* @param {string} id A vehicle id.
|
|
311
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
312
|
+
* @param {function(data: { content: RealtimeFullTrajectory })} onMessage Function called on each message of the channel.
|
|
313
|
+
* @param {function} onError Callback when the subscription fails.
|
|
314
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
315
|
+
* @public
|
|
316
|
+
*/
|
|
317
|
+
subscribeFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeFullTrajectory>, onError?: EventListener, quiet?: boolean): void;
|
|
318
|
+
/**
|
|
319
|
+
* Unsubscribe from full_trajectory channel
|
|
320
|
+
*
|
|
321
|
+
* @param {string} id A vehicle id.
|
|
322
|
+
* @param {function(data: { content: RealtimeFullTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
323
|
+
* @public
|
|
324
|
+
*/
|
|
325
|
+
unsubscribeFullTrajectory(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeFullTrajectory>): void;
|
|
326
|
+
/**
|
|
327
|
+
* Get the list of stops for this vehicle.
|
|
328
|
+
*
|
|
329
|
+
* @param {string} id A vehicle id.
|
|
330
|
+
* @return {Promise<{ data: { content: StopSequence[] } }>} Returns a stop sequence object.
|
|
331
|
+
* @public
|
|
332
|
+
*/
|
|
333
|
+
getStopSequence(id: RealtimeTrainId): Promise<WebSocketAPIMessageEventData<StopSequence[]>>;
|
|
334
|
+
/**
|
|
335
|
+
* Subscribe to stopsequence channel of a given vehicle.
|
|
336
|
+
*
|
|
337
|
+
* @param {string} id A vehicle id.
|
|
338
|
+
* @param {function(data: { content: StopSequence[] })} onMessage Function called on each message of the channel.
|
|
339
|
+
* @param {function} onError Callback when the subscription fails.
|
|
340
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
341
|
+
* @public
|
|
342
|
+
*/
|
|
343
|
+
subscribeStopSequence(id: RealtimeTrainId, onMessage: WebSocketAPIMessageCallback<StopSequence[]>, onError?: EventListener, quiet?: boolean): void;
|
|
344
|
+
/**
|
|
345
|
+
* Unsubscribe from stopsequence channel
|
|
346
|
+
*
|
|
347
|
+
* @param {string} id A vehicle id.
|
|
348
|
+
* @param {function(data: { content: StopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
349
|
+
* @public
|
|
350
|
+
*/
|
|
351
|
+
unsubscribeStopSequence(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<StopSequence[]>): void;
|
|
352
|
+
/**
|
|
353
|
+
* Subscribe to healthcheck channel.
|
|
354
|
+
* @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
|
|
355
|
+
* @param {function} onError Callback when the subscription fails.
|
|
356
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
357
|
+
*/
|
|
358
|
+
subscribeHealthCheck(onMessage: WebSocketAPIMessageCallback<string>, onError?: EventListener, quiet?: boolean): void;
|
|
359
|
+
/**
|
|
360
|
+
* Unsubscribe to healthcheck channel.
|
|
361
|
+
* @param {function(data: { content: string })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
362
|
+
*/
|
|
363
|
+
unsubscribeHealthCheck(onMessage?: WebSocketAPIMessageCallback<string>): void;
|
|
364
|
+
}
|
|
365
|
+
export default RealtimeAPI;
|