mobility-toolbox-js 3.0.0-beta.11 → 3.0.0-beta.13
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/RealtimeAPI.d.ts +28 -22
- package/api/RealtimeAPI.js +23 -16
- package/api/RoutingAPI.d.ts +16 -6
- package/api/RoutingAPI.js +16 -6
- package/api/StopsAPI.d.ts +3 -3
- package/api/StopsAPI.js +3 -3
- package/api/WebSocketAPI.d.ts +2 -2
- package/api/WebSocketAPI.js +2 -2
- package/api/typedefs.d.ts +0 -102
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +1 -1
- package/common/controls/StopFinderControlCommon.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +10 -11
- package/common/mixins/RealtimeLayerMixin.js +17 -9
- package/common/typedefs.d.ts +7 -0
- package/common/typedefs.js +6 -0
- package/common/utils/compareDepartures.d.ts +2 -2
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getVehiclePosition.d.ts +3 -2
- package/common/utils/getVehiclePosition.js +6 -1
- package/common/utils/renderTrajectories.d.ts +1 -1
- package/common/utils/renderTrajectories.js +1 -1
- package/common/utils/sortAndFilterDepartures.d.ts +1 -1
- package/common/utils/sortAndFilterDepartures.js +1 -1
- package/common/utils/sortByDelay.d.ts +2 -2
- package/common/utils/sortByDelay.js +5 -1
- package/maplibre/layers/Layer.d.ts +1 -1
- package/maplibre/layers/Layer.js +1 -1
- package/maplibre/layers/RealtimeLayer.d.ts +40 -11
- package/maplibre/layers/RealtimeLayer.js +27 -3
- package/mbt.js +86 -43
- package/mbt.js.map +4 -4
- package/mbt.min.js +13 -13
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +1 -1
- package/ol/controls/RoutingControl.js +1 -1
- package/ol/index.d.ts +1 -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 +3 -3
- package/ol/layers/MaplibreLayer.js +3 -3
- package/ol/layers/RealtimeLayer.d.ts +15 -12
- package/ol/layers/index.d.ts +1 -0
- package/ol/layers/index.js +1 -0
- package/ol/mixins/index.d.ts +1 -0
- package/ol/mixins/index.js +2 -0
- package/ol/renderers/RealtimeLayerRenderer.js +4 -1
- package/package.json +1 -1
package/api/RealtimeAPI.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import WebSocketAPI, { WebSocketAPIMessageCallback, WebSocketAPIMessageEventData, WebSocketAPIParameters } from './WebSocketAPI';
|
|
2
|
-
import type { RealtimeMode, RealtimeDeparture, RealtimeNews, RealtimeStation, RealtimeExtraGeom, RealtimeTrainId, RealtimeGeneralizationLevel, RealtimeFullTrajectory,
|
|
3
|
-
import { StopSequence } from './typedefs';
|
|
2
|
+
import type { RealtimeMode, RealtimeDeparture, RealtimeNews, RealtimeStation, RealtimeExtraGeom, RealtimeTrainId, RealtimeGeneralizationLevel, RealtimeFullTrajectory, RealtimeStationId, RealtimeVersion, RealtimeTrajectory, RealtimeTenant, RealtimeBbox, RealtimeStopSequence } from '../types';
|
|
4
3
|
/**
|
|
5
4
|
* @typedef RealtimeAPIOptions
|
|
6
5
|
*/
|
|
@@ -178,8 +177,7 @@ declare class RealtimeAPI {
|
|
|
178
177
|
* Subscribe to departures channel of a given station.
|
|
179
178
|
*
|
|
180
179
|
* @param {number} stationId UIC of the station.
|
|
181
|
-
* @param {
|
|
182
|
-
* @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
|
|
180
|
+
* @param {function(departures: RealtimeDeparture[])} onMessage Function called on each message of the channel.
|
|
183
181
|
* @param {function} onError Callback when the subscription fails.
|
|
184
182
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
185
183
|
* @public
|
|
@@ -187,14 +185,15 @@ declare class RealtimeAPI {
|
|
|
187
185
|
subscribeDepartures(stationId: number, onMessage: WebSocketAPIMessageCallback<RealtimeDeparture>, onError?: EventListener, quiet?: boolean): void;
|
|
188
186
|
/**
|
|
189
187
|
* Unsubscribe from current departures channel.
|
|
190
|
-
* @param {
|
|
188
|
+
* @param {number} stationId UIC of the station.
|
|
191
189
|
* @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
192
190
|
* @public
|
|
193
191
|
*/
|
|
194
|
-
unsubscribeDepartures(
|
|
192
|
+
unsubscribeDepartures(stationId: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
|
|
195
193
|
/**
|
|
196
194
|
* Subscribe to the disruptions channel for tenant.
|
|
197
195
|
*
|
|
196
|
+
* @param {RealtimeTenant} tenant Tenant's id
|
|
198
197
|
* @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
|
|
199
198
|
* @param {function} onError Callback when the subscription fails.
|
|
200
199
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
@@ -203,8 +202,8 @@ declare class RealtimeAPI {
|
|
|
203
202
|
subscribeDisruptions(tenant: RealtimeTenant, onMessage: WebSocketAPIMessageCallback<RealtimeNews>, onError?: EventListener, quiet?: boolean): void;
|
|
204
203
|
/**
|
|
205
204
|
* Unsubscribe disruptions.
|
|
206
|
-
*
|
|
207
|
-
* @param {
|
|
205
|
+
* @param {RealtimeTenant} tenant Tenant's id
|
|
206
|
+
* @param {Function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
208
207
|
* @public
|
|
209
208
|
*/
|
|
210
209
|
unsubscribeDisruptions(tenant: RealtimeTenant, onMessage?: WebSocketAPIMessageCallback<RealtimeNews>): void;
|
|
@@ -258,7 +257,7 @@ declare class RealtimeAPI {
|
|
|
258
257
|
/**
|
|
259
258
|
* Return a partial trajectory with a given id and a mode.
|
|
260
259
|
*
|
|
261
|
-
* @param {number}
|
|
260
|
+
* @param {number} id The identifier of a trajectory.
|
|
262
261
|
* @param {RealtimeMode} mode Realtime mode.
|
|
263
262
|
* @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
|
|
264
263
|
* @public
|
|
@@ -268,18 +267,18 @@ declare class RealtimeAPI {
|
|
|
268
267
|
* Subscribe to trajectory channel.
|
|
269
268
|
*
|
|
270
269
|
* @param {RealtimeMode} mode Realtime mode.
|
|
271
|
-
* @param {function(data: { content:
|
|
270
|
+
* @param {function(data: { content: RealtimeTrajectory })} onMessage Function called on each message of the channel.
|
|
272
271
|
* @param {function} onError Callback when the subscription fails.
|
|
273
272
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
274
273
|
* @public
|
|
275
274
|
*/
|
|
276
|
-
subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<
|
|
275
|
+
subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrajectory>, onError?: EventListener, quiet?: boolean): void;
|
|
277
276
|
/**
|
|
278
277
|
* Unsubscribe to trajectory channels.
|
|
279
|
-
* @param {function(data: { content:
|
|
278
|
+
* @param {function(data: { content: RealtimeTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
280
279
|
* @public
|
|
281
280
|
*/
|
|
282
|
-
unsubscribeTrajectory(onMessage: WebSocketAPIMessageCallback<
|
|
281
|
+
unsubscribeTrajectory(onMessage: WebSocketAPIMessageCallback<RealtimeTrajectory>): void;
|
|
283
282
|
/**
|
|
284
283
|
* Subscribe to deleted_vhicles channel.
|
|
285
284
|
*
|
|
@@ -300,7 +299,7 @@ declare class RealtimeAPI {
|
|
|
300
299
|
* @param {string} id A vehicle id.
|
|
301
300
|
* @param {RealtimeMode} mode Realtime mode.
|
|
302
301
|
* @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
|
|
303
|
-
* @return {Promise<{
|
|
302
|
+
* @return {Promise<{data: { content: RealtimeFullTrajectory }}>} Return a full trajectory.
|
|
304
303
|
* @public
|
|
305
304
|
*/
|
|
306
305
|
getFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, generalizationLevel: RealtimeGeneralizationLevel | undefined): Promise<WebSocketAPIMessageEventData<RealtimeFullTrajectory>>;
|
|
@@ -309,17 +308,24 @@ declare class RealtimeAPI {
|
|
|
309
308
|
*
|
|
310
309
|
* @param {string} id A vehicle id.
|
|
311
310
|
* @param {RealtimeMode} mode Realtime mode.
|
|
312
|
-
* @param {function(data:
|
|
311
|
+
* @param {function(data:{content: RealtimeFullTrajectory})} onMessage Function called on each message of the channel.
|
|
313
312
|
* @param {function} onError Callback when the subscription fails.
|
|
314
313
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
315
314
|
* @public
|
|
316
315
|
*/
|
|
317
316
|
subscribeFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeFullTrajectory>, onError?: EventListener, quiet?: boolean): void;
|
|
317
|
+
/**
|
|
318
|
+
* This callback type is called `requestCallback` and is displayed as a global symbol.
|
|
319
|
+
*
|
|
320
|
+
* @callback onFullTrajectoryMessageCallback
|
|
321
|
+
* @param {number} responseCode
|
|
322
|
+
* @param {string} responseMessage
|
|
323
|
+
*/
|
|
318
324
|
/**
|
|
319
325
|
* Unsubscribe from full_trajectory channel
|
|
320
326
|
*
|
|
321
327
|
* @param {string} id A vehicle id.
|
|
322
|
-
* @param {
|
|
328
|
+
* @param {onFullTrajectoryMessageCallback} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
323
329
|
* @public
|
|
324
330
|
*/
|
|
325
331
|
unsubscribeFullTrajectory(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeFullTrajectory>): void;
|
|
@@ -327,28 +333,28 @@ declare class RealtimeAPI {
|
|
|
327
333
|
* Get the list of stops for this vehicle.
|
|
328
334
|
*
|
|
329
335
|
* @param {string} id A vehicle id.
|
|
330
|
-
* @return {Promise<{
|
|
336
|
+
* @return {Promise<{data: { content: RealtimeStopSequence[] }}>} Returns a stop sequence object.
|
|
331
337
|
* @public
|
|
332
338
|
*/
|
|
333
|
-
getStopSequence(id: RealtimeTrainId): Promise<WebSocketAPIMessageEventData<
|
|
339
|
+
getStopSequence(id: RealtimeTrainId): Promise<WebSocketAPIMessageEventData<RealtimeStopSequence[]>>;
|
|
334
340
|
/**
|
|
335
341
|
* Subscribe to stopsequence channel of a given vehicle.
|
|
336
342
|
*
|
|
337
343
|
* @param {string} id A vehicle id.
|
|
338
|
-
* @param {function(data: { content:
|
|
344
|
+
* @param {function(data: { content: RealtimeStopSequence[] })} onMessage Function called on each message of the channel.
|
|
339
345
|
* @param {function} onError Callback when the subscription fails.
|
|
340
346
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
341
347
|
* @public
|
|
342
348
|
*/
|
|
343
|
-
subscribeStopSequence(id: RealtimeTrainId, onMessage: WebSocketAPIMessageCallback<
|
|
349
|
+
subscribeStopSequence(id: RealtimeTrainId, onMessage: WebSocketAPIMessageCallback<RealtimeStopSequence[]>, onError?: EventListener, quiet?: boolean): void;
|
|
344
350
|
/**
|
|
345
351
|
* Unsubscribe from stopsequence channel
|
|
346
352
|
*
|
|
347
353
|
* @param {string} id A vehicle id.
|
|
348
|
-
* @param {function(data: { content:
|
|
354
|
+
* @param {function(data: { content: RealtimeStopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
349
355
|
* @public
|
|
350
356
|
*/
|
|
351
|
-
unsubscribeStopSequence(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<
|
|
357
|
+
unsubscribeStopSequence(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeStopSequence[]>): void;
|
|
352
358
|
/**
|
|
353
359
|
* Subscribe to healthcheck channel.
|
|
354
360
|
* @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
|
package/api/RealtimeAPI.js
CHANGED
|
@@ -259,8 +259,7 @@ class RealtimeAPI {
|
|
|
259
259
|
* Subscribe to departures channel of a given station.
|
|
260
260
|
*
|
|
261
261
|
* @param {number} stationId UIC of the station.
|
|
262
|
-
* @param {
|
|
263
|
-
* @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
|
|
262
|
+
* @param {function(departures: RealtimeDeparture[])} onMessage Function called on each message of the channel.
|
|
264
263
|
* @param {function} onError Callback when the subscription fails.
|
|
265
264
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
266
265
|
* @public
|
|
@@ -270,16 +269,17 @@ class RealtimeAPI {
|
|
|
270
269
|
}
|
|
271
270
|
/**
|
|
272
271
|
* Unsubscribe from current departures channel.
|
|
273
|
-
* @param {
|
|
272
|
+
* @param {number} stationId UIC of the station.
|
|
274
273
|
* @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
275
274
|
* @public
|
|
276
275
|
*/
|
|
277
|
-
unsubscribeDepartures(
|
|
278
|
-
this.unsubscribe(`timetable_${
|
|
276
|
+
unsubscribeDepartures(stationId, onMessage) {
|
|
277
|
+
this.unsubscribe(`timetable_${stationId}`, '', onMessage);
|
|
279
278
|
}
|
|
280
279
|
/**
|
|
281
280
|
* Subscribe to the disruptions channel for tenant.
|
|
282
281
|
*
|
|
282
|
+
* @param {RealtimeTenant} tenant Tenant's id
|
|
283
283
|
* @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
|
|
284
284
|
* @param {function} onError Callback when the subscription fails.
|
|
285
285
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
@@ -290,8 +290,8 @@ class RealtimeAPI {
|
|
|
290
290
|
}
|
|
291
291
|
/**
|
|
292
292
|
* Unsubscribe disruptions.
|
|
293
|
-
*
|
|
294
|
-
* @param {
|
|
293
|
+
* @param {RealtimeTenant} tenant Tenant's id
|
|
294
|
+
* @param {Function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
295
295
|
* @public
|
|
296
296
|
*/
|
|
297
297
|
unsubscribeDisruptions(tenant, onMessage) {
|
|
@@ -365,7 +365,7 @@ class RealtimeAPI {
|
|
|
365
365
|
/**
|
|
366
366
|
* Return a partial trajectory with a given id and a mode.
|
|
367
367
|
*
|
|
368
|
-
* @param {number}
|
|
368
|
+
* @param {number} id The identifier of a trajectory.
|
|
369
369
|
* @param {RealtimeMode} mode Realtime mode.
|
|
370
370
|
* @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
|
|
371
371
|
* @public
|
|
@@ -377,7 +377,7 @@ class RealtimeAPI {
|
|
|
377
377
|
* Subscribe to trajectory channel.
|
|
378
378
|
*
|
|
379
379
|
* @param {RealtimeMode} mode Realtime mode.
|
|
380
|
-
* @param {function(data: { content:
|
|
380
|
+
* @param {function(data: { content: RealtimeTrajectory })} onMessage Function called on each message of the channel.
|
|
381
381
|
* @param {function} onError Callback when the subscription fails.
|
|
382
382
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
383
383
|
* @public
|
|
@@ -392,7 +392,7 @@ class RealtimeAPI {
|
|
|
392
392
|
}
|
|
393
393
|
/**
|
|
394
394
|
* Unsubscribe to trajectory channels.
|
|
395
|
-
* @param {function(data: { content:
|
|
395
|
+
* @param {function(data: { content: RealtimeTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
396
396
|
* @public
|
|
397
397
|
*/
|
|
398
398
|
unsubscribeTrajectory(onMessage) {
|
|
@@ -427,7 +427,7 @@ class RealtimeAPI {
|
|
|
427
427
|
* @param {string} id A vehicle id.
|
|
428
428
|
* @param {RealtimeMode} mode Realtime mode.
|
|
429
429
|
* @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
|
|
430
|
-
* @return {Promise<{
|
|
430
|
+
* @return {Promise<{data: { content: RealtimeFullTrajectory }}>} Return a full trajectory.
|
|
431
431
|
* @public
|
|
432
432
|
*/
|
|
433
433
|
getFullTrajectory(id, mode, generalizationLevel) {
|
|
@@ -449,7 +449,7 @@ class RealtimeAPI {
|
|
|
449
449
|
*
|
|
450
450
|
* @param {string} id A vehicle id.
|
|
451
451
|
* @param {RealtimeMode} mode Realtime mode.
|
|
452
|
-
* @param {function(data:
|
|
452
|
+
* @param {function(data:{content: RealtimeFullTrajectory})} onMessage Function called on each message of the channel.
|
|
453
453
|
* @param {function} onError Callback when the subscription fails.
|
|
454
454
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
455
455
|
* @public
|
|
@@ -461,11 +461,18 @@ class RealtimeAPI {
|
|
|
461
461
|
}
|
|
462
462
|
this.subscribe(`full_trajectory${suffix}_${id}`, onMessage, onError, quiet);
|
|
463
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* This callback type is called `requestCallback` and is displayed as a global symbol.
|
|
466
|
+
*
|
|
467
|
+
* @callback onFullTrajectoryMessageCallback
|
|
468
|
+
* @param {number} responseCode
|
|
469
|
+
* @param {string} responseMessage
|
|
470
|
+
*/
|
|
464
471
|
/**
|
|
465
472
|
* Unsubscribe from full_trajectory channel
|
|
466
473
|
*
|
|
467
474
|
* @param {string} id A vehicle id.
|
|
468
|
-
* @param {
|
|
475
|
+
* @param {onFullTrajectoryMessageCallback} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
469
476
|
* @public
|
|
470
477
|
*/
|
|
471
478
|
unsubscribeFullTrajectory(id, onMessage) {
|
|
@@ -475,7 +482,7 @@ class RealtimeAPI {
|
|
|
475
482
|
* Get the list of stops for this vehicle.
|
|
476
483
|
*
|
|
477
484
|
* @param {string} id A vehicle id.
|
|
478
|
-
* @return {Promise<{
|
|
485
|
+
* @return {Promise<{data: { content: RealtimeStopSequence[] }}>} Returns a stop sequence object.
|
|
479
486
|
* @public
|
|
480
487
|
*/
|
|
481
488
|
getStopSequence(id) {
|
|
@@ -485,7 +492,7 @@ class RealtimeAPI {
|
|
|
485
492
|
* Subscribe to stopsequence channel of a given vehicle.
|
|
486
493
|
*
|
|
487
494
|
* @param {string} id A vehicle id.
|
|
488
|
-
* @param {function(data: { content:
|
|
495
|
+
* @param {function(data: { content: RealtimeStopSequence[] })} onMessage Function called on each message of the channel.
|
|
489
496
|
* @param {function} onError Callback when the subscription fails.
|
|
490
497
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
491
498
|
* @public
|
|
@@ -497,7 +504,7 @@ class RealtimeAPI {
|
|
|
497
504
|
* Unsubscribe from stopsequence channel
|
|
498
505
|
*
|
|
499
506
|
* @param {string} id A vehicle id.
|
|
500
|
-
* @param {function(data: { content:
|
|
507
|
+
* @param {function(data: { content: RealtimeStopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
501
508
|
* @public
|
|
502
509
|
*/
|
|
503
510
|
unsubscribeStopSequence(id, onMessage) {
|
package/api/RoutingAPI.d.ts
CHANGED
|
@@ -11,26 +11,36 @@ export type RoutingAPIOptions = {
|
|
|
11
11
|
* import { RoutingAPI } from 'mobility-toolbox-js';
|
|
12
12
|
*
|
|
13
13
|
* const api = new RoutingAPI({
|
|
14
|
-
* apiKey: [yourApiKey]
|
|
14
|
+
* apiKey: [yourApiKey],
|
|
15
|
+
* // url: 'https://api.geops.io/routing/v1/',
|
|
15
16
|
* });
|
|
16
17
|
*
|
|
18
|
+
* const route = await api.route({
|
|
19
|
+
* via: "freiburg|basel%20sbb|bern",
|
|
20
|
+
* mot: "rail"
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* console.log('Log route:', JSON.stringify(route));
|
|
24
|
+
*
|
|
17
25
|
* @public
|
|
18
26
|
*/
|
|
19
27
|
declare class RoutingAPI extends HttpAPI {
|
|
20
28
|
/**
|
|
21
29
|
* Constructor
|
|
22
30
|
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
31
|
+
* @param {Object} options Options.
|
|
25
32
|
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
33
|
+
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
34
|
+
* @public
|
|
26
35
|
*/
|
|
27
36
|
constructor(options?: RoutingAPIOptions);
|
|
28
37
|
/**
|
|
29
|
-
*
|
|
38
|
+
* Calculate a route.
|
|
30
39
|
*
|
|
31
|
-
* @param {RoutingParameters} params Request parameters. See [Routing
|
|
32
|
-
* @param {
|
|
40
|
+
* @param {RoutingParameters} params Request parameters. See [geOps Routing API](https://developer.geops.io/apis/routing/).
|
|
41
|
+
* @param {FetchOptions} config Options for the fetch request.
|
|
33
42
|
* @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
43
|
+
* @public
|
|
34
44
|
*/
|
|
35
45
|
route(params: RoutingParameters, config: RequestInit): Promise<RoutingResponse>;
|
|
36
46
|
}
|
package/api/RoutingAPI.js
CHANGED
|
@@ -6,28 +6,38 @@ import HttpAPI from './HttpAPI';
|
|
|
6
6
|
* import { RoutingAPI } from 'mobility-toolbox-js';
|
|
7
7
|
*
|
|
8
8
|
* const api = new RoutingAPI({
|
|
9
|
-
* apiKey: [yourApiKey]
|
|
9
|
+
* apiKey: [yourApiKey],
|
|
10
|
+
* // url: 'https://api.geops.io/routing/v1/',
|
|
10
11
|
* });
|
|
11
12
|
*
|
|
13
|
+
* const route = await api.route({
|
|
14
|
+
* via: "freiburg|basel%20sbb|bern",
|
|
15
|
+
* mot: "rail"
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* console.log('Log route:', JSON.stringify(route));
|
|
19
|
+
*
|
|
12
20
|
* @public
|
|
13
21
|
*/
|
|
14
22
|
class RoutingAPI extends HttpAPI {
|
|
15
23
|
/**
|
|
16
24
|
* Constructor
|
|
17
25
|
*
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
26
|
+
* @param {Object} options Options.
|
|
20
27
|
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
28
|
+
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
29
|
+
* @public
|
|
21
30
|
*/
|
|
22
31
|
constructor(options = {}) {
|
|
23
32
|
super(Object.assign({ url: 'https://api.geops.io/routing/v1/' }, options));
|
|
24
33
|
}
|
|
25
34
|
/**
|
|
26
|
-
*
|
|
35
|
+
* Calculate a route.
|
|
27
36
|
*
|
|
28
|
-
* @param {RoutingParameters} params Request parameters. See [Routing
|
|
29
|
-
* @param {
|
|
37
|
+
* @param {RoutingParameters} params Request parameters. See [geOps Routing API](https://developer.geops.io/apis/routing/).
|
|
38
|
+
* @param {FetchOptions} config Options for the fetch request.
|
|
30
39
|
* @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
40
|
+
* @public
|
|
31
41
|
*/
|
|
32
42
|
route(params, config) {
|
|
33
43
|
return this.fetch('', params, config);
|
package/api/StopsAPI.d.ts
CHANGED
|
@@ -32,11 +32,11 @@ declare class StopsAPI extends HttpAPI {
|
|
|
32
32
|
*/
|
|
33
33
|
constructor(options?: StopsAPIOptions);
|
|
34
34
|
/**
|
|
35
|
-
* Search
|
|
35
|
+
* Search for stops.
|
|
36
36
|
*
|
|
37
|
-
* @param {
|
|
37
|
+
* @param {StopsParameters} params Request parameters. See [Stops API documentation](https://developer.geops.io/apis/stops).
|
|
38
38
|
* @param {FetchOptions} config Options for the fetch request.
|
|
39
|
-
* @returns {Promise<
|
|
39
|
+
* @returns {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326). See [Stops API documentation](https://developer.geops.io/apis/stops).
|
|
40
40
|
* @public
|
|
41
41
|
*/
|
|
42
42
|
search(params: StopsParameters, config: RequestInit): Promise<StopsResponse>;
|
package/api/StopsAPI.js
CHANGED
|
@@ -29,11 +29,11 @@ class StopsAPI extends HttpAPI {
|
|
|
29
29
|
super(Object.assign({ url: 'https://api.geops.io/stops/v1/' }, options));
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* Search
|
|
32
|
+
* Search for stops.
|
|
33
33
|
*
|
|
34
|
-
* @param {
|
|
34
|
+
* @param {StopsParameters} params Request parameters. See [Stops API documentation](https://developer.geops.io/apis/stops).
|
|
35
35
|
* @param {FetchOptions} config Options for the fetch request.
|
|
36
|
-
* @returns {Promise<
|
|
36
|
+
* @returns {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326). See [Stops API documentation](https://developer.geops.io/apis/stops).
|
|
37
37
|
* @public
|
|
38
38
|
*/
|
|
39
39
|
search(params, config) {
|
package/api/WebSocketAPI.d.ts
CHANGED
|
@@ -123,8 +123,8 @@ declare class WebSocketAPI {
|
|
|
123
123
|
* The callback is called only once, when the response is received or when the call returns an error.
|
|
124
124
|
*
|
|
125
125
|
* @param {Object} params Parameters for the websocket get request
|
|
126
|
-
* @param {function}
|
|
127
|
-
* @param {function}
|
|
126
|
+
* @param {function} cb callback on message event
|
|
127
|
+
* @param {function} errorCb Callback on error and close event
|
|
128
128
|
* @private
|
|
129
129
|
*/
|
|
130
130
|
get(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): void;
|
package/api/WebSocketAPI.js
CHANGED
|
@@ -234,8 +234,8 @@ class WebSocketAPI {
|
|
|
234
234
|
* The callback is called only once, when the response is received or when the call returns an error.
|
|
235
235
|
*
|
|
236
236
|
* @param {Object} params Parameters for the websocket get request
|
|
237
|
-
* @param {function}
|
|
238
|
-
* @param {function}
|
|
237
|
+
* @param {function} cb callback on message event
|
|
238
|
+
* @param {function} errorCb Callback on error and close event
|
|
239
239
|
* @private
|
|
240
240
|
*/
|
|
241
241
|
get(params, cb, errorCb) {
|
package/api/typedefs.d.ts
CHANGED
|
@@ -1,59 +1,4 @@
|
|
|
1
1
|
export default dummy;
|
|
2
|
-
export type Departure = {
|
|
3
|
-
/**
|
|
4
|
-
* Timestamp in ms.
|
|
5
|
-
*/
|
|
6
|
-
time: number;
|
|
7
|
-
no_stop_between: boolean;
|
|
8
|
-
train_number: number;
|
|
9
|
-
to: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Timestamp in ms.
|
|
12
|
-
*/
|
|
13
|
-
ris_aimed_time: number;
|
|
14
|
-
/**
|
|
15
|
-
* Timestamp in ms.
|
|
16
|
-
*/
|
|
17
|
-
updated_at: number;
|
|
18
|
-
new_to: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Timestamp in ms.
|
|
21
|
-
*/
|
|
22
|
-
min_arrival_time: number;
|
|
23
|
-
/**
|
|
24
|
-
* List of next stops. Like value in at_station_ds100.
|
|
25
|
-
*/
|
|
26
|
-
next_stoppoints: string[];
|
|
27
|
-
/**
|
|
28
|
-
* Timestamp in ms.
|
|
29
|
-
*/
|
|
30
|
-
ris_estimated_time: number;
|
|
31
|
-
line: NetworkLine;
|
|
32
|
-
/**
|
|
33
|
-
* if true this departure has realtime data.
|
|
34
|
-
*/
|
|
35
|
-
has_fzo: boolean;
|
|
36
|
-
train_id: number;
|
|
37
|
-
platform: string;
|
|
38
|
-
state: any | null;
|
|
39
|
-
/**
|
|
40
|
-
* Timestamp in ms.
|
|
41
|
-
*/
|
|
42
|
-
fzo_estimated_time: number;
|
|
43
|
-
formation: any | null;
|
|
44
|
-
no_stop_till: any | null;
|
|
45
|
-
train_type: number;
|
|
46
|
-
call_id: number;
|
|
47
|
-
/**
|
|
48
|
-
* Timestamp in ms.
|
|
49
|
-
*/
|
|
50
|
-
created_at: string;
|
|
51
|
-
at_station_ds100: string;
|
|
52
|
-
/**
|
|
53
|
-
* Timestamp in ms.
|
|
54
|
-
*/
|
|
55
|
-
timediff: number;
|
|
56
|
-
};
|
|
57
2
|
export type Station = GeoJSONFeature;
|
|
58
3
|
export type StationProperties = {
|
|
59
4
|
transfers: Transfer[];
|
|
@@ -98,38 +43,6 @@ export type Transfer = {
|
|
|
98
43
|
*/
|
|
99
44
|
lines: string[];
|
|
100
45
|
};
|
|
101
|
-
export type StopSequence = GeoJSONFeature;
|
|
102
|
-
export type RealtimeTrajectory = GeoJSONFeature;
|
|
103
|
-
export type FullTrajectory = GeoJSONFeature;
|
|
104
|
-
export type Vehicle = GeoJSONFeature;
|
|
105
|
-
export type ExtraGeom = GeoJSONFeature;
|
|
106
|
-
/**
|
|
107
|
-
* @typedef {Object} Departure
|
|
108
|
-
* @property {number} time Timestamp in ms.
|
|
109
|
-
* @property {boolean} no_stop_between
|
|
110
|
-
* @property {number} train_number
|
|
111
|
-
* @property {string[]} to
|
|
112
|
-
* @property {number} ris_aimed_time Timestamp in ms.
|
|
113
|
-
* @property {number} updated_at Timestamp in ms.
|
|
114
|
-
* @property {boolean} new_to
|
|
115
|
-
* @property {number} min_arrival_time Timestamp in ms.
|
|
116
|
-
* @property {string[]} next_stoppoints List of next stops. Like value in at_station_ds100.
|
|
117
|
-
* @property {number} ris_estimated_time Timestamp in ms.
|
|
118
|
-
* @property {NetworkLine} line
|
|
119
|
-
* @property {boolean} has_fzo if true this departure has realtime data.
|
|
120
|
-
* @property {number} train_id
|
|
121
|
-
* @property {string} platform
|
|
122
|
-
* @property {?*} state
|
|
123
|
-
* @property {number} fzo_estimated_time Timestamp in ms.
|
|
124
|
-
* @property {?*} formation
|
|
125
|
-
* @property {?*} no_stop_till
|
|
126
|
-
* @property {number} train_type
|
|
127
|
-
* @property {number} call_id
|
|
128
|
-
* @property {string} created_at Timestamp in ms.
|
|
129
|
-
* @property {string} at_station_ds100
|
|
130
|
-
* @property {number} timediff Timestamp in ms.
|
|
131
|
-
*
|
|
132
|
-
*/
|
|
133
46
|
/**
|
|
134
47
|
* @typedef {GeoJSONFeature} Station
|
|
135
48
|
* @property {StationProperties} properties Returns the station's properties.
|
|
@@ -160,19 +73,4 @@ export type ExtraGeom = GeoJSONFeature;
|
|
|
160
73
|
* @property {string} mot Mode of transportation (ex: U-Bahn).
|
|
161
74
|
* @property {string[]} lines Array of lines name (ex: ["U4", "U5"]).
|
|
162
75
|
*/
|
|
163
|
-
/**
|
|
164
|
-
* @typedef {GeoJSONFeature} StopSequence
|
|
165
|
-
*/
|
|
166
|
-
/**
|
|
167
|
-
* @typedef {GeoJSONFeature} RealtimeTrajectory
|
|
168
|
-
*/
|
|
169
|
-
/**
|
|
170
|
-
* @typedef {GeoJSONFeature} FullTrajectory
|
|
171
|
-
*/
|
|
172
|
-
/**
|
|
173
|
-
* @typedef {GeoJSONFeature} Vehicle
|
|
174
|
-
*/
|
|
175
|
-
/**
|
|
176
|
-
* @typedef {GeoJSONFeature} ExtraGeom
|
|
177
|
-
*/
|
|
178
76
|
declare function dummy(): void;
|
package/api/typedefs.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
// /**
|
|
2
|
+
// * @typedef {Object} Departure
|
|
3
|
+
// * @property {number} time Timestamp in ms.
|
|
4
|
+
// * @property {boolean} no_stop_between
|
|
5
|
+
// * @property {number} train_number
|
|
6
|
+
// * @property {string[]} to
|
|
7
|
+
// * @property {number} ris_aimed_time Timestamp in ms.
|
|
8
|
+
// * @property {number} updated_at Timestamp in ms.
|
|
9
|
+
// * @property {boolean} new_to
|
|
10
|
+
// * @property {number} min_arrival_time Timestamp in ms.
|
|
11
|
+
// * @property {string[]} next_stoppoints List of next stops. Like value in at_station_ds100.
|
|
12
|
+
// * @property {number} ris_estimated_time Timestamp in ms.
|
|
13
|
+
// * @property {NetworkLine} line
|
|
14
|
+
// * @property {boolean} has_fzo if true this departure has realtime data.
|
|
15
|
+
// * @property {number} train_id
|
|
16
|
+
// * @property {string} platform
|
|
17
|
+
// * @property {?*} state
|
|
18
|
+
// * @property {number} fzo_estimated_time Timestamp in ms.
|
|
19
|
+
// * @property {?*} formation
|
|
20
|
+
// * @property {?*} no_stop_till
|
|
21
|
+
// * @property {number} train_type
|
|
22
|
+
// * @property {number} call_id
|
|
23
|
+
// * @property {string} created_at Timestamp in ms.
|
|
24
|
+
// * @property {string} at_station_ds100
|
|
25
|
+
// * @property {number} timediff Timestamp in ms.
|
|
26
|
+
// *
|
|
27
|
+
// */
|
|
28
28
|
/**
|
|
29
29
|
* @typedef {GeoJSONFeature} Station
|
|
30
30
|
* @property {StationProperties} properties Returns the station's properties.
|
|
@@ -55,21 +55,6 @@
|
|
|
55
55
|
* @property {string} mot Mode of transportation (ex: U-Bahn).
|
|
56
56
|
* @property {string[]} lines Array of lines name (ex: ["U4", "U5"]).
|
|
57
57
|
*/
|
|
58
|
-
/**
|
|
59
|
-
* @typedef {GeoJSONFeature} StopSequence
|
|
60
|
-
*/
|
|
61
|
-
/**
|
|
62
|
-
* @typedef {GeoJSONFeature} RealtimeTrajectory
|
|
63
|
-
*/
|
|
64
|
-
/**
|
|
65
|
-
* @typedef {GeoJSONFeature} FullTrajectory
|
|
66
|
-
*/
|
|
67
|
-
/**
|
|
68
|
-
* @typedef {GeoJSONFeature} Vehicle
|
|
69
|
-
*/
|
|
70
|
-
/**
|
|
71
|
-
* @typedef {GeoJSONFeature} ExtraGeom
|
|
72
|
-
*/
|
|
73
58
|
// These lines is to block TypeScript to add "use strict;" in the outputed file.
|
|
74
59
|
const dummy = () => { };
|
|
75
60
|
export default dummy;
|
|
@@ -44,7 +44,7 @@ declare class StopFinderControlCommon {
|
|
|
44
44
|
/**
|
|
45
45
|
* Launch a search.
|
|
46
46
|
*
|
|
47
|
-
* @param {String}
|
|
47
|
+
* @param {String} q The query to search for.
|
|
48
48
|
* @param {AbortController} abortController Abort controller used to cancel the request.
|
|
49
49
|
* @return {Promise<Array<GeoJSONFeature>>} An array of GeoJSON features with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
50
50
|
*/
|
|
@@ -103,7 +103,7 @@ class StopFinderControlCommon {
|
|
|
103
103
|
/**
|
|
104
104
|
* Launch a search.
|
|
105
105
|
*
|
|
106
|
-
* @param {String}
|
|
106
|
+
* @param {String} q The query to search for.
|
|
107
107
|
* @param {AbortController} abortController Abort controller used to cancel the request.
|
|
108
108
|
* @return {Promise<Array<GeoJSONFeature>>} An array of GeoJSON features with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
109
109
|
*/
|