mobility-toolbox-js 3.0.0-beta.2 → 3.0.0-beta.20
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/api/HttpAPI.d.ts +20 -0
- package/api/HttpAPI.js +0 -11
- package/api/RealtimeAPI.d.ts +404 -0
- package/api/RealtimeAPI.js +344 -276
- package/api/RoutingAPI.d.ts +47 -0
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +44 -0
- package/api/StopsAPI.js +16 -10
- package/api/WebSocketAPI.d.ts +147 -0
- package/api/WebSocketAPI.js +164 -164
- package/api/index.d.ts +3 -0
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +76 -0
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +53 -0
- package/common/controls/StopFinderControlCommon.js +31 -31
- package/common/index.d.ts +2 -0
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +267 -0
- package/common/mixins/RealtimeLayerMixin.js +401 -393
- package/common/styles/index.d.ts +4 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/typedefs.d.ts +219 -0
- package/common/typedefs.js +7 -1
- package/common/utils/compareDepartures.d.ts +10 -0
- package/common/utils/compareDepartures.js +2 -2
- 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/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getUrlWithParams.d.ts +8 -0
- package/common/utils/getVehiclePosition.d.ts +17 -0
- package/common/utils/getVehiclePosition.js +9 -3
- 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/renderTrajectories.js +6 -6
- package/common/utils/sortAndFilterDepartures.d.ts +15 -0
- package/common/utils/sortAndFilterDepartures.js +1 -1
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.js +5 -1
- 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/Layer.js +1 -1
- package/maplibre/layers/RealtimeLayer.d.ts +181 -0
- package/maplibre/layers/RealtimeLayer.js +29 -5
- 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/getSourceCoordinates.js +5 -5
- package/maplibre/utils/index.d.ts +2 -0
- package/mbt.js +22160 -14512
- package/mbt.js.map +4 -4
- package/mbt.min.js +61 -58
- 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 +202 -0
- package/ol/controls/RoutingControl.js +220 -219
- package/ol/controls/StopFinderControl.d.ts +37 -0
- package/ol/controls/StopFinderControl.js +4 -1
- package/ol/controls/index.d.ts +3 -0
- package/ol/index.d.ts +7 -0
- package/ol/index.js +1 -0
- package/ol/layers/Layer.d.ts +101 -0
- package/ol/layers/Layer.js +17 -0
- package/ol/layers/MaplibreLayer.d.ts +160 -0
- package/ol/layers/MaplibreLayer.js +88 -24
- package/ol/layers/MaplibreStyleLayer.d.ts +242 -0
- package/ol/layers/MaplibreStyleLayer.js +291 -265
- package/ol/layers/RealtimeLayer.d.ts +283 -0
- package/ol/layers/RealtimeLayer.js +143 -128
- package/ol/layers/VectorLayer.d.ts +18 -0
- package/ol/layers/VectorLayer.js +31 -0
- package/ol/layers/index.d.ts +5 -0
- package/ol/layers/index.js +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +98 -0
- package/ol/mixins/MobilityLayerMixin.js +1 -4
- package/ol/mixins/PropertiesLayerMixin.d.ts +135 -0
- package/ol/mixins/PropertiesLayerMixin.js +108 -140
- package/ol/mixins/index.d.ts +1 -0
- package/ol/mixins/index.js +2 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -0
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
- package/ol/renderers/RealtimeLayerRenderer.js +58 -53
- 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 +12 -18
- package/ol/utils/index.d.ts +1 -0
- package/package.json +31 -31
- package/setupTests.d.ts +1 -0
- package/setupTests.js +3 -4
- package/types/common.d.ts +55 -48
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +91 -93
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/ol/layers/MapGlLayer.js +0 -142
package/api/HttpAPI.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface HttpAPIOptions {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
url: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Common class to access to a geOps api using http.
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
declare class HttpAPI {
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
url: 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 {
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import WebSocketAPI, { WebSocketAPIMessageCallback, WebSocketAPIMessageEventData, WebSocketAPIParameters } from './WebSocketAPI';
|
|
2
|
+
import type { RealtimeBbox, RealtimeDeparture, RealtimeExtraGeom, RealtimeFullTrajectory, RealtimeGeneralizationLevel, RealtimeMode, RealtimeNews, RealtimeStation, RealtimeStationId, RealtimeStopSequence, RealtimeTenant, RealtimeTrainId, RealtimeTrajectory, RealtimeVersion } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @typedef RealtimeAPIOptions
|
|
5
|
+
*/
|
|
6
|
+
export interface RealtimeAPIOptions {
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
bbox?: RealtimeBbox;
|
|
9
|
+
buffer?: number[];
|
|
10
|
+
pingIntervalMs?: number;
|
|
11
|
+
reconnectTimeoutMs?: number;
|
|
12
|
+
url?: string;
|
|
13
|
+
version?: RealtimeVersion;
|
|
14
|
+
}
|
|
15
|
+
export type RealtimeAPIExtraGeomsById = Record<string, RealtimeExtraGeom>;
|
|
16
|
+
export type RealtimeAPIDeparturesById = Record<string, RealtimeDeparture>;
|
|
17
|
+
export interface RealtimeModesType {
|
|
18
|
+
RAW: RealtimeMode;
|
|
19
|
+
SCHEMATIC: RealtimeMode;
|
|
20
|
+
TOPOGRAPHIC: RealtimeMode;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Enum for Realtime modes.
|
|
24
|
+
* @readonly
|
|
25
|
+
* @typedef {string} RealtimeMode
|
|
26
|
+
* @property {string} RAW "raw"
|
|
27
|
+
* @property {string} SCHEMATIC "schematic"
|
|
28
|
+
* @property {string} TOPOGRAPHIC "topographic"
|
|
29
|
+
* @enum {RealtimeMode}
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare const RealtimeModes: {
|
|
33
|
+
RAW: RealtimeMode;
|
|
34
|
+
SCHEMATIC: RealtimeMode;
|
|
35
|
+
TOPOGRAPHIC: RealtimeMode;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* This class provides convenience methods to use to the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* import { RealtimeAPI } from 'mobility-toolbox-js/api';
|
|
42
|
+
*
|
|
43
|
+
* const api = new RealtimeAPI({
|
|
44
|
+
* apiKey: "yourApiKey",
|
|
45
|
+
* bbox: [782001, 5888803, 923410, 5923660, 11, "mots=rail"],
|
|
46
|
+
* // url: "wss://api.geops.io/tracker-ws/v1/",
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // Open the websocket connection
|
|
50
|
+
* api.open();
|
|
51
|
+
*
|
|
52
|
+
* // Subscribe to channel
|
|
53
|
+
* api.subscribeTrajectory('topographic', (data) => {
|
|
54
|
+
* console.log('Log trajectories:', JSON.stringify(data.content));
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* // Close the websocket connection
|
|
58
|
+
* // api.close();
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
declare class RealtimeAPI {
|
|
63
|
+
_bbox?: RealtimeBbox;
|
|
64
|
+
_buffer?: number[];
|
|
65
|
+
_url: string;
|
|
66
|
+
private pingInterval;
|
|
67
|
+
private pingIntervalMs;
|
|
68
|
+
private reconnectTimeout?;
|
|
69
|
+
private reconnectTimeoutMs?;
|
|
70
|
+
version: RealtimeVersion;
|
|
71
|
+
wsApi: WebSocketAPI;
|
|
72
|
+
/**
|
|
73
|
+
* Constructor
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} options Options.
|
|
76
|
+
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
77
|
+
* @param {string[]} options.bbox The bounding box to receive data from.
|
|
78
|
+
* @param {string} [options.url='wss://api.geops.io/tracker-ws/v1/'] Url of the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
constructor(options?: RealtimeAPIOptions);
|
|
82
|
+
/**
|
|
83
|
+
* Close the websocket connection without reconnection.
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
close(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Send GET to a channel.
|
|
90
|
+
*
|
|
91
|
+
* @param {string | WebSocketAPIParameters} channelOrParams Name of the websocket channel to send GET or an object representing parameters to send
|
|
92
|
+
* @return {Promise<WebSocketAPIMessageEventData<?>>} A websocket response.
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
get(channelOrParams: string | WebSocketAPIParameters): Promise<WebSocketAPIMessageEventData<any>>;
|
|
96
|
+
/**
|
|
97
|
+
* Get a full trajectory of a vehicule .
|
|
98
|
+
*
|
|
99
|
+
* @param {string} id A vehicle id.
|
|
100
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
101
|
+
* @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
|
|
102
|
+
* @return {Promise<{data: { content: RealtimeFullTrajectory }}>} Return a full trajectory.
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
getFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, generalizationLevel: RealtimeGeneralizationLevel | undefined): Promise<WebSocketAPIMessageEventData<RealtimeFullTrajectory>>;
|
|
106
|
+
/**
|
|
107
|
+
* Return a station with a given uic number and a mode.
|
|
108
|
+
*
|
|
109
|
+
* @param {number} uic UIC of the station.
|
|
110
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
111
|
+
* @return {Promise<{data: { content: RealtimeStation }}>} A station.
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
getStation(uic: RealtimeStationId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeStation>>;
|
|
115
|
+
/**
|
|
116
|
+
* Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
|
|
117
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
118
|
+
* @param {number} timeout = 100 Duration in ms between each promise resolve calls.
|
|
119
|
+
* @return {Promise<RealtimeStation[]>} An array of stations.
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
getStations(mode: RealtimeMode, timeout?: number): Promise<RealtimeStation[]>;
|
|
123
|
+
/**
|
|
124
|
+
* Get the list of stops for this vehicle.
|
|
125
|
+
*
|
|
126
|
+
* @param {string} id A vehicle id.
|
|
127
|
+
* @return {Promise<{data: { content: RealtimeStopSequence[] }}>} Returns a stop sequence object.
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
getStopSequence(id: RealtimeTrainId): Promise<WebSocketAPIMessageEventData<RealtimeStopSequence[]>>;
|
|
131
|
+
/**
|
|
132
|
+
* Return a partial trajectory with a given id and a mode.
|
|
133
|
+
*
|
|
134
|
+
* @param {number} id The identifier of a trajectory.
|
|
135
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
136
|
+
* @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
getTrajectory(id: RealtimeTrainId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeTrajectory>>;
|
|
140
|
+
/**
|
|
141
|
+
* Callback when the websocket is closed by the server.
|
|
142
|
+
* It auto reconnects after a timeout.
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
onClose(): void;
|
|
146
|
+
/**
|
|
147
|
+
* Callback when the websocket is opened and ready.
|
|
148
|
+
* It applies the bbox and the projection.
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
onOpen(): void;
|
|
152
|
+
/**
|
|
153
|
+
* Open the websocket connection.
|
|
154
|
+
*
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
open(): void;
|
|
158
|
+
/**
|
|
159
|
+
* Unsubscribe trajectory and deleted_vehicles channels. To resubscribe you have to set a new BBOX.
|
|
160
|
+
*/
|
|
161
|
+
reset(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Subscribe to a channel.
|
|
164
|
+
*
|
|
165
|
+
* @param {string} channel Name of the websocket channel to subscribe.
|
|
166
|
+
* @param {function} onSuccess Callback when the subscription succeeds.
|
|
167
|
+
* @param {function} onError Callback when the subscription fails.
|
|
168
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
subscribe(channel: string, onSuccess: WebSocketAPIMessageCallback<any>, onError?: EventListener, quiet?: boolean): void;
|
|
172
|
+
/**
|
|
173
|
+
* Subscribe to deleted_vhicles channel.
|
|
174
|
+
*
|
|
175
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
176
|
+
* @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
177
|
+
* @param {function} onError Callback when the subscription fails.
|
|
178
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
subscribeDeletedVehicles(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>, onError?: EventListener, quiet?: boolean): void;
|
|
182
|
+
/**
|
|
183
|
+
* Subscribe to departures channel of a given station.
|
|
184
|
+
*
|
|
185
|
+
* @param {number} stationId UIC of the station.
|
|
186
|
+
* @param {function(departures: RealtimeDeparture[])} onMessage Function called on each message of the channel.
|
|
187
|
+
* @param {function} onError Callback when the subscription fails.
|
|
188
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
189
|
+
* @deprecated Use subscribeTimetable instead.
|
|
190
|
+
*/
|
|
191
|
+
subscribeDepartures(stationId: number, onMessage: WebSocketAPIMessageCallback<RealtimeDeparture>, onError?: EventListener, quiet?: boolean): void;
|
|
192
|
+
/**
|
|
193
|
+
* Subscribe to the disruptions channel for tenant.
|
|
194
|
+
*
|
|
195
|
+
* @param {RealtimeTenant} tenant Tenant's id
|
|
196
|
+
* @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
|
|
197
|
+
* @param {function} onError Callback when the subscription fails.
|
|
198
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
199
|
+
* @deprecated Use subscribeNewsticker instead.
|
|
200
|
+
*/
|
|
201
|
+
subscribeDisruptions(tenant: RealtimeTenant, onMessage: WebSocketAPIMessageCallback<RealtimeNews>, onError?: EventListener, quiet?: boolean): void;
|
|
202
|
+
/**
|
|
203
|
+
* Subscribe to extra_geoms channel.
|
|
204
|
+
*
|
|
205
|
+
* @param {function(data: { content: RealtimeExtraGeom })} onMessage Function called on each message of the channel.
|
|
206
|
+
* @param {function} onError Callback when the subscription fails.
|
|
207
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
208
|
+
*/
|
|
209
|
+
subscribeExtraGeoms(onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>, onError?: EventListener, quiet?: boolean): void;
|
|
210
|
+
/**
|
|
211
|
+
* Subscribe to full_trajectory channel of a given vehicle.
|
|
212
|
+
*
|
|
213
|
+
* @param {string} id A vehicle id.
|
|
214
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
215
|
+
* @param {function(data:{content: RealtimeFullTrajectory})} onMessage Function called on each message of the channel.
|
|
216
|
+
* @param {function} onError Callback when the subscription fails.
|
|
217
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
218
|
+
* @public
|
|
219
|
+
*/
|
|
220
|
+
subscribeFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeFullTrajectory>, onError?: EventListener, quiet?: boolean): void;
|
|
221
|
+
/**
|
|
222
|
+
* Subscribe to healthcheck channel.
|
|
223
|
+
* @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
|
|
224
|
+
* @param {function} onError Callback when the subscription fails.
|
|
225
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
226
|
+
*/
|
|
227
|
+
subscribeHealthCheck(onMessage: WebSocketAPIMessageCallback<string>, onError?: EventListener, quiet?: boolean): void;
|
|
228
|
+
/**
|
|
229
|
+
* Subscribe to the newsticker channel for tenant.
|
|
230
|
+
*
|
|
231
|
+
* @param {RealtimeTenant} tenant Tenant's id
|
|
232
|
+
* @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
|
|
233
|
+
* @param {function} onError Callback when the subscription fails.
|
|
234
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
237
|
+
subscribeNewsticker(tenant: RealtimeTenant, onMessage: WebSocketAPIMessageCallback<RealtimeNews>, onError?: EventListener, quiet?: boolean): void;
|
|
238
|
+
/**
|
|
239
|
+
* Subscribe to stations channel.
|
|
240
|
+
* One message pro station.
|
|
241
|
+
*
|
|
242
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
243
|
+
* @param {function(data: { content: RealtimeStation })} onMessage Function called on each message of the channel.
|
|
244
|
+
* @param {function} onError Callback when the subscription fails.
|
|
245
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
subscribeStations(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeStation>, onError?: EventListener, quiet?: boolean): void;
|
|
249
|
+
/**
|
|
250
|
+
* Subscribe to stopsequence channel of a given vehicle.
|
|
251
|
+
*
|
|
252
|
+
* @param {string} id A vehicle id.
|
|
253
|
+
* @param {function(data: { content: RealtimeStopSequence[] })} onMessage Function called on each message of the channel.
|
|
254
|
+
* @param {function} onError Callback when the subscription fails.
|
|
255
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
256
|
+
* @public
|
|
257
|
+
*/
|
|
258
|
+
subscribeStopSequence(id: RealtimeTrainId, onMessage: WebSocketAPIMessageCallback<RealtimeStopSequence[]>, onError?: EventListener, quiet?: boolean): void;
|
|
259
|
+
/**
|
|
260
|
+
* Subscribe to timetable channel of a given station.
|
|
261
|
+
*
|
|
262
|
+
* @param {number} stationId UIC of the station.
|
|
263
|
+
* @param {function(departures: RealtimeDeparture[])} onMessage Function called on each message of the channel.
|
|
264
|
+
* @param {function} onError Callback when the subscription fails.
|
|
265
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
266
|
+
* @public
|
|
267
|
+
*/
|
|
268
|
+
subscribeTimetable(stationId: number, onMessage: WebSocketAPIMessageCallback<RealtimeDeparture>, onError?: EventListener, quiet?: boolean): void;
|
|
269
|
+
/**
|
|
270
|
+
* Subscribe to trajectory channel.
|
|
271
|
+
*
|
|
272
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
273
|
+
* @param {function(data: { content: RealtimeTrajectory })} onMessage Function called on each message of the channel.
|
|
274
|
+
* @param {function} onError Callback when the subscription fails.
|
|
275
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
276
|
+
* @public
|
|
277
|
+
*/
|
|
278
|
+
subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrajectory>, onError?: EventListener, quiet?: boolean): void;
|
|
279
|
+
/**
|
|
280
|
+
* Unsubscribe both modes of a channel.
|
|
281
|
+
*
|
|
282
|
+
* @param {string} channel Name of the websocket channel to unsubscribe.
|
|
283
|
+
* @param {string} suffix Suffix to add to the channel name.
|
|
284
|
+
* @param {function} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
285
|
+
* @public
|
|
286
|
+
*/
|
|
287
|
+
unsubscribe(channel: string, suffix?: string, onMessage?: WebSocketAPIMessageCallback<any>): void;
|
|
288
|
+
/**
|
|
289
|
+
* Unsubscribe to deleted_vhicles channels.
|
|
290
|
+
* @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
291
|
+
* @public
|
|
292
|
+
*/
|
|
293
|
+
unsubscribeDeletedVehicles(onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>): void;
|
|
294
|
+
/**
|
|
295
|
+
* Unsubscribe from current departures channel.
|
|
296
|
+
* @param {number} stationId UIC of the station.
|
|
297
|
+
* @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
298
|
+
* @deprecated Use unsubscribeTimetabe instead.
|
|
299
|
+
*/
|
|
300
|
+
unsubscribeDepartures(stationId: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
|
|
301
|
+
/**
|
|
302
|
+
* Unsubscribe disruptions.
|
|
303
|
+
* @param {RealtimeTenant} tenant Tenant's id
|
|
304
|
+
* @param {Function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
305
|
+
* @deprecated Use unsubscribeNewsticker instead.
|
|
306
|
+
*/
|
|
307
|
+
unsubscribeDisruptions(tenant: RealtimeTenant, onMessage?: WebSocketAPIMessageCallback<RealtimeNews>): void;
|
|
308
|
+
/**
|
|
309
|
+
* Unsubscribe to extra_geoms channel.
|
|
310
|
+
* @param {function(data: { content: RealtimeExtraGeom })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
311
|
+
*/
|
|
312
|
+
unsubscribeExtraGeoms(onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>): void;
|
|
313
|
+
/**
|
|
314
|
+
* Unsubscribe from full_trajectory channel
|
|
315
|
+
*
|
|
316
|
+
* @param {string} id A vehicle id.
|
|
317
|
+
* @param {onFullTrajectoryMessageCallback} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
318
|
+
* @public
|
|
319
|
+
*/
|
|
320
|
+
unsubscribeFullTrajectory(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeFullTrajectory>): void;
|
|
321
|
+
/**
|
|
322
|
+
* Unsubscribe to healthcheck channel.
|
|
323
|
+
* @param {function(data: { content: string })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
324
|
+
*/
|
|
325
|
+
unsubscribeHealthCheck(onMessage?: WebSocketAPIMessageCallback<string>): void;
|
|
326
|
+
/**
|
|
327
|
+
* Unsubscribe disruptions.
|
|
328
|
+
* @param {RealtimeTenant} tenant Tenant's id
|
|
329
|
+
* @param {Function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
330
|
+
* @public
|
|
331
|
+
*/
|
|
332
|
+
unsubscribeNewsticker(tenant: RealtimeTenant, onMessage?: WebSocketAPIMessageCallback<RealtimeNews>): void;
|
|
333
|
+
/**
|
|
334
|
+
* Unsubscribe to stations channel.
|
|
335
|
+
* @param {function(data: { content: RealtimeStation })} onMessage The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
|
|
336
|
+
* @public
|
|
337
|
+
*/
|
|
338
|
+
unsubscribeStations(onMessage?: WebSocketAPIMessageCallback<RealtimeStation>): void;
|
|
339
|
+
/**
|
|
340
|
+
* Unsubscribe from stopsequence channel
|
|
341
|
+
*
|
|
342
|
+
* @param {string} id A vehicle id.
|
|
343
|
+
* @param {function(data: { content: RealtimeStopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
344
|
+
* @public
|
|
345
|
+
*/
|
|
346
|
+
unsubscribeStopSequence(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeStopSequence[]>): void;
|
|
347
|
+
/**
|
|
348
|
+
* Unsubscribe from current departures channel.
|
|
349
|
+
* @param {number} stationId UIC of the station.
|
|
350
|
+
* @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
351
|
+
* @public
|
|
352
|
+
*/
|
|
353
|
+
unsubscribeTimetabe(stationId: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
|
|
354
|
+
/**
|
|
355
|
+
* Unsubscribe to trajectory channels.
|
|
356
|
+
* @param {function(data: { content: RealtimeTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
357
|
+
* @public
|
|
358
|
+
*/
|
|
359
|
+
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
|
+
}
|
|
404
|
+
export default RealtimeAPI;
|