mobility-toolbox-js 2.0.0-beta.45 → 2.0.0-beta.47
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 +80 -64
- package/api/RealtimeAPI.d.ts.map +1 -1
- package/api/RealtimeAPI.js +58 -45
- package/api/RoutingAPI.d.ts +2 -2
- package/api/RoutingAPI.d.ts.map +1 -1
- package/api/RoutingAPI.js +1 -1
- package/api/StopsAPI.d.ts +14 -12
- package/api/StopsAPI.d.ts.map +1 -1
- package/api/StopsAPI.js +7 -9
- package/api/typedefs.d.ts +84 -10
- package/api/typedefs.d.ts.map +1 -1
- package/api/typedefs.js +3 -1
- package/common/api/WebSocketAPI.d.ts +80 -24
- package/common/api/WebSocketAPI.d.ts.map +1 -1
- package/common/api/WebSocketAPI.js +28 -16
- package/common/controls/{Control.d.ts → ControlCommon.d.ts} +21 -19
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/{Control.js → ControlCommon.js} +21 -8
- package/common/controls/CopyrightControlCommon.d.ts +13 -0
- package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
- package/common/controls/CopyrightControlCommon.js +34 -0
- package/common/controls/StopFinderControlCommon.d.ts +54 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/{mixins/StopFinderMixin.js → controls/StopFinderControlCommon.js} +25 -38
- package/common/layers/{Layer.d.ts → LayerCommon.d.ts} +34 -21
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/{Layer.js → LayerCommon.js} +15 -9
- package/common/mixins/RealtimeLayerMixin.d.ts +243 -19
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
- package/common/mixins/RealtimeLayerMixin.js +598 -569
- package/common/mixins/UserInteractionsLayerMixin.d.ts +18 -8
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -1
- package/common/mixins/UserInteractionsLayerMixin.js +170 -159
- package/common/styles/realtimeDefaultStyle.d.ts +30 -9
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -1
- package/common/styles/realtimeDefaultStyle.js +41 -17
- package/common/styles/realtimeDelayStyle.d.ts +3 -2
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -1
- package/common/styles/realtimeSimpleStyle.d.ts +1 -1
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -1
- package/common/styles/realtimeSimpleStyle.js +9 -7
- package/common/typedefs.d.ts +64 -3
- package/common/typedefs.d.ts.map +1 -1
- package/common/typedefs.js +34 -4
- package/common/utils/cleanStopTime.d.ts +3 -2
- package/common/utils/cleanStopTime.d.ts.map +1 -1
- package/common/utils/cleanStopTime.js +0 -3
- package/common/utils/compareDepartures.d.ts +6 -4
- package/common/utils/compareDepartures.d.ts.map +1 -1
- package/common/utils/compareDepartures.js +3 -2
- package/common/utils/createCanvas.d.ts +3 -2
- package/common/utils/createCanvas.d.ts.map +1 -1
- package/common/utils/createTrackerFilters.d.ts +3 -2
- package/common/utils/createTrackerFilters.d.ts.map +1 -1
- package/common/utils/createTrackerFilters.js +3 -3
- package/common/utils/getLayersAsFlatArray.d.ts +1 -1
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -1
- package/common/utils/getLayersAsFlatArray.js +1 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +13 -3
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -1
- package/common/utils/getMapboxMapCopyrights.js +10 -4
- package/common/utils/getMapboxRender.d.ts +3 -1
- package/common/utils/getMapboxRender.d.ts.map +1 -1
- package/common/utils/getMapboxRender.js +1 -2
- package/common/utils/getVehiclePosition.d.ts +1 -1
- package/common/utils/getVehiclePosition.d.ts.map +1 -1
- package/common/utils/removeDuplicate.d.ts +2 -2
- package/common/utils/removeDuplicate.d.ts.map +1 -1
- package/common/utils/renderTrajectories.d.ts +3 -6
- package/common/utils/renderTrajectories.d.ts.map +1 -1
- package/common/utils/renderTrajectories.js +17 -8
- package/common/utils/trackerConfig.d.ts.map +1 -1
- package/common/utils/trackerConfig.js +3 -0
- package/mapbox/controls/CopyrightControl.d.ts +6 -8
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -1
- package/mapbox/controls/CopyrightControl.js +3 -8
- package/mapbox/layers/Layer.js +1 -1
- package/mapbox/layers/RealtimeLayer.d.ts +1 -1
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -1
- package/mapbox/utils.d.ts +1 -1
- package/mapbox/utils.d.ts.map +1 -1
- package/mbt.js +825 -703
- package/mbt.js.map +3 -3
- package/mbt.min.js +84 -84
- package/mbt.min.js.map +3 -3
- package/ol/controls/CopyrightControl.d.ts +10 -10
- package/ol/controls/CopyrightControl.d.ts.map +1 -1
- package/ol/controls/CopyrightControl.js +8 -8
- package/ol/controls/RoutingControl.d.ts +10 -3
- package/ol/controls/RoutingControl.d.ts.map +1 -1
- package/ol/controls/RoutingControl.js +2 -2
- package/ol/controls/StopFinderControl.d.ts +5 -7
- package/ol/controls/StopFinderControl.d.ts.map +1 -1
- package/ol/controls/StopFinderControl.js +4 -8
- package/ol/layers/Layer.d.ts +57 -9
- package/ol/layers/Layer.d.ts.map +1 -1
- package/ol/layers/Layer.js +17 -8
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/{common/mixins/MapboxLayerMixin.js → ol/layers/MapGlLayer.js} +66 -44
- package/ol/layers/MapboxLayer.d.ts +15 -17
- package/ol/layers/MapboxLayer.d.ts.map +1 -1
- package/ol/layers/MapboxLayer.js +11 -8
- package/ol/layers/MapboxStyleLayer.d.ts +6 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -1
- package/ol/layers/MaplibreLayer.d.ts +4 -4
- package/ol/layers/MaplibreLayer.d.ts.map +1 -1
- package/ol/layers/MaplibreLayer.js +2 -3
- package/ol/layers/RealtimeLayer.d.ts +106 -30
- package/ol/layers/RealtimeLayer.d.ts.map +1 -1
- package/ol/layers/RealtimeLayer.js +22 -14
- package/ol/styles/fullTrajectoryStyle.d.ts +3 -2
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
- package/package.json +15 -9
- package/types/common.d.ts +111 -0
- package/types/index.d.ts +1 -0
- package/types/realtime.d.ts +290 -9
- package/api/RealtimeAPI.test.d.ts +0 -2
- package/api/RealtimeAPI.test.d.ts.map +0 -1
- package/api/RealtimeAPI.test.js +0 -67
- package/api/RoutingAPI.test.d.ts +0 -2
- package/api/RoutingAPI.test.d.ts.map +0 -1
- package/api/RoutingAPI.test.js +0 -29
- package/api/StopsAPI.test.d.ts +0 -2
- package/api/StopsAPI.test.d.ts.map +0 -1
- package/api/StopsAPI.test.js +0 -26
- package/common/api/HttpAPI.test.d.ts +0 -2
- package/common/api/HttpAPI.test.d.ts.map +0 -1
- package/common/api/HttpAPI.test.js +0 -54
- package/common/api/WebSocketAPI.test.d.ts +0 -2
- package/common/api/WebSocketAPI.test.d.ts.map +0 -1
- package/common/api/WebSocketAPI.test.js +0 -380
- package/common/controls/Control.d.ts.map +0 -1
- package/common/controls/Control.test.d.ts +0 -2
- package/common/controls/Control.test.d.ts.map +0 -1
- package/common/controls/Control.test.js +0 -89
- package/common/layers/Layer.d.ts.map +0 -1
- package/common/layers/Layer.test.d.ts +0 -2
- package/common/layers/Layer.test.d.ts.map +0 -1
- package/common/layers/Layer.test.js +0 -137
- package/common/mixins/CopyrightMixin.d.ts +0 -22
- package/common/mixins/CopyrightMixin.d.ts.map +0 -1
- package/common/mixins/CopyrightMixin.js +0 -43
- package/common/mixins/MapboxLayerMixin.d.ts +0 -27
- package/common/mixins/MapboxLayerMixin.d.ts.map +0 -1
- package/common/mixins/StopFinderMixin.d.ts +0 -40
- package/common/mixins/StopFinderMixin.d.ts.map +0 -1
- package/common/mixins/UserInteractionsLayerMixin.test.d.ts +0 -2
- package/common/mixins/UserInteractionsLayerMixin.test.d.ts.map +0 -1
- package/common/mixins/UserInteractionsLayerMixin.test.js +0 -214
- package/common/utils/createTrackerFilters.test.d.ts +0 -2
- package/common/utils/createTrackerFilters.test.d.ts.map +0 -1
- package/common/utils/createTrackerFilters.test.js +0 -79
- package/common/utils/getMapboxMapCopyrights.test.d.ts +0 -2
- package/common/utils/getMapboxMapCopyrights.test.d.ts.map +0 -1
- package/common/utils/getMapboxMapCopyrights.test.js +0 -40
- package/common/utils/removeDuplicate.test.d.ts +0 -2
- package/common/utils/removeDuplicate.test.d.ts.map +0 -1
- package/common/utils/removeDuplicate.test.js +0 -19
- package/common/utils/timeUtils.test.d.ts +0 -2
- package/common/utils/timeUtils.test.d.ts.map +0 -1
- package/common/utils/timeUtils.test.js +0 -10
- package/common/utils/trackerConfig.test.d.ts +0 -2
- package/common/utils/trackerConfig.test.d.ts.map +0 -1
- package/common/utils/trackerConfig.test.js +0 -23
- package/mapbox/layers/Layer.test.d.ts +0 -2
- package/mapbox/layers/Layer.test.d.ts.map +0 -1
- package/mapbox/layers/Layer.test.js +0 -204
- package/mapbox/layers/RealtimeLayer.test.d.ts +0 -2
- package/mapbox/layers/RealtimeLayer.test.d.ts.map +0 -1
- package/mapbox/layers/RealtimeLayer.test.js +0 -10
- package/ol/controls/CopyrightControl.test.d.ts +0 -2
- package/ol/controls/CopyrightControl.test.d.ts.map +0 -1
- package/ol/controls/CopyrightControl.test.js +0 -177
- package/ol/controls/RoutingControl.test.d.ts +0 -2
- package/ol/controls/RoutingControl.test.d.ts.map +0 -1
- package/ol/controls/RoutingControl.test.js +0 -150
- package/ol/controls/StopFinderControl.test.d.ts +0 -2
- package/ol/controls/StopFinderControl.test.d.ts.map +0 -1
- package/ol/controls/StopFinderControl.test.js +0 -49
- package/ol/layers/Layer.test.d.ts +0 -2
- package/ol/layers/Layer.test.d.ts.map +0 -1
- package/ol/layers/Layer.test.js +0 -196
- package/ol/layers/MapboxLayer.test.d.ts +0 -2
- package/ol/layers/MapboxLayer.test.d.ts.map +0 -1
- package/ol/layers/MapboxLayer.test.js +0 -164
- package/ol/layers/MapboxStyleLayer.test.d.ts +0 -2
- package/ol/layers/MapboxStyleLayer.test.d.ts.map +0 -1
- package/ol/layers/MapboxStyleLayer.test.js +0 -232
- package/ol/layers/RealtimeLayer.test.d.ts +0 -2
- package/ol/layers/RealtimeLayer.test.d.ts.map +0 -1
- package/ol/layers/RealtimeLayer.test.js +0 -71
- package/ol/layers/RoutingLayer.test.d.ts +0 -2
- package/ol/layers/RoutingLayer.test.d.ts.map +0 -1
- package/ol/layers/RoutingLayer.test.js +0 -39
- package/ol/layers/VectorLayer.test.d.ts +0 -2
- package/ol/layers/VectorLayer.test.d.ts.map +0 -1
- package/ol/layers/VectorLayer.test.js +0 -87
- package/ol/layers/WMSLayer.test.d.ts +0 -2
- package/ol/layers/WMSLayer.test.d.ts.map +0 -1
- package/ol/layers/WMSLayer.test.js +0 -66
package/api/RealtimeAPI.d.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
|
+
import WebSocketAPI, { WebSocketAPIDataCallback, WebSocketAPIMessageEventData } from '../common/api/WebSocketAPI';
|
|
2
|
+
import { RealtimeMode, RealtimeDeparture, RealtimeNews, RealtimeDepartureExtended, RealtimeStation, RealtimeExtraGeom, RealtimeTrainId, RealtimeGeneralizationLevel, RealtimeStopSequence, RealtimeFullTrajectory } from '../types';
|
|
3
|
+
export declare type RealtimeAPIOptions = {
|
|
4
|
+
url?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
prefix?: string;
|
|
7
|
+
projection?: string;
|
|
8
|
+
bbox?: (number | string)[];
|
|
9
|
+
buffer?: number[];
|
|
10
|
+
pingIntervalMs?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare type RealtimeAPIExtraGeomsById = {
|
|
13
|
+
[index: string]: RealtimeExtraGeom;
|
|
14
|
+
};
|
|
15
|
+
export declare type RealtimeAPIDeparturesById = {
|
|
16
|
+
[index: string]: RealtimeDeparture;
|
|
17
|
+
};
|
|
1
18
|
/**
|
|
2
19
|
* Enum for Realtime modes.
|
|
20
|
+
* @readonly
|
|
21
|
+
* @typedef {string} RealtimeMode
|
|
22
|
+
* @property {string} RAW "raw"
|
|
23
|
+
* @property {string} SCHEMATIC "schematic"
|
|
24
|
+
* @property {string} TOPOGRAPHIC "topographic"
|
|
25
|
+
* @enum {RealtimeMode}
|
|
3
26
|
*/
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export default RealtimeAPI;
|
|
11
|
-
/**
|
|
12
|
-
* Enum for Realtime modes.
|
|
13
|
-
*/
|
|
14
|
-
export type RealtimeMode = string;
|
|
27
|
+
export declare const RealtimeModes: {
|
|
28
|
+
RAW: string;
|
|
29
|
+
TOPOGRAPHIC: string;
|
|
30
|
+
SCHEMATIC: string;
|
|
31
|
+
};
|
|
15
32
|
/**
|
|
16
33
|
* This class provides convenience methods to access to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
|
|
17
34
|
*
|
|
@@ -29,6 +46,22 @@ export type RealtimeMode = string;
|
|
|
29
46
|
* const api = new RealtimeAPI("yourUrl");
|
|
30
47
|
*/
|
|
31
48
|
declare class RealtimeAPI {
|
|
49
|
+
url: string;
|
|
50
|
+
wsApi: WebSocketAPI;
|
|
51
|
+
projection?: string;
|
|
52
|
+
bbox?: (number | string)[];
|
|
53
|
+
buffer?: number[];
|
|
54
|
+
subscribedStationUic?: number;
|
|
55
|
+
maxDepartureAge: number;
|
|
56
|
+
prefix: string;
|
|
57
|
+
extraGeoms: RealtimeAPIExtraGeomsById;
|
|
58
|
+
departureUpdateTimeout?: number;
|
|
59
|
+
pingInterval: number;
|
|
60
|
+
pingIntervalMs: number;
|
|
61
|
+
reconnectTimeout?: number;
|
|
62
|
+
reconnectTimeoutMs?: number;
|
|
63
|
+
stationUpdateTimeout?: number;
|
|
64
|
+
fullTrajectoryUpdateTimeout?: number;
|
|
32
65
|
/**
|
|
33
66
|
* Constructor
|
|
34
67
|
*
|
|
@@ -39,23 +72,8 @@ declare class RealtimeAPI {
|
|
|
39
72
|
* @param {string} [options.projection] The epsg code of the projection for features. Default to EPSG:3857.
|
|
40
73
|
* @param {number[4]} [options.bbox=[minX, minY, maxX, maxY, zoom, tenant] The bounding box to receive data from.
|
|
41
74
|
*/
|
|
42
|
-
constructor(options?:
|
|
43
|
-
|
|
44
|
-
subscribedStationUic: number | null;
|
|
45
|
-
/** @ignore */
|
|
46
|
-
departureUpdateTimeout: number | null;
|
|
47
|
-
/** @ignore */
|
|
48
|
-
maxDepartureAge: number;
|
|
49
|
-
/** @ignore */
|
|
50
|
-
extraGeoms: {};
|
|
51
|
-
/** @ignore */
|
|
52
|
-
prefix: any;
|
|
53
|
-
/**
|
|
54
|
-
* Callback when the websocket is opened and ready.
|
|
55
|
-
* It applies the bbox and the projection.
|
|
56
|
-
*/
|
|
57
|
-
onOpen(): void;
|
|
58
|
-
defineProperties(options: any): void;
|
|
75
|
+
constructor(options?: RealtimeAPIOptions);
|
|
76
|
+
defineProperties(options: RealtimeAPIOptions): void;
|
|
59
77
|
open(): void;
|
|
60
78
|
/**
|
|
61
79
|
* Close the websocket connection without reconnection.
|
|
@@ -65,15 +83,16 @@ declare class RealtimeAPI {
|
|
|
65
83
|
* Unsubscribe trajectory and deleted_vehicles channels. To resubscribe you have to set a new BBOX.
|
|
66
84
|
*/
|
|
67
85
|
reset(): void;
|
|
68
|
-
/**
|
|
69
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Callback when the websocket is opened and ready.
|
|
88
|
+
* It applies the bbox and the projection.
|
|
89
|
+
*/
|
|
90
|
+
onOpen(): void;
|
|
70
91
|
/**
|
|
71
92
|
* Callback when the websocket is closed by the server.
|
|
72
93
|
* It auto reconnects after a timeout.
|
|
73
94
|
*/
|
|
74
95
|
onClose(): void;
|
|
75
|
-
/** @ignore */
|
|
76
|
-
reconnectTimeout: number | undefined;
|
|
77
96
|
/**
|
|
78
97
|
* Subscribe to a channel.
|
|
79
98
|
*
|
|
@@ -83,7 +102,7 @@ declare class RealtimeAPI {
|
|
|
83
102
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
84
103
|
* @private
|
|
85
104
|
*/
|
|
86
|
-
|
|
105
|
+
subscribe(channel: string, onSuccess: WebSocketAPIDataCallback, onError?: EventListener, quiet?: boolean): void;
|
|
87
106
|
/**
|
|
88
107
|
* Unsubscribe both modes of a channel.
|
|
89
108
|
*
|
|
@@ -92,16 +111,16 @@ declare class RealtimeAPI {
|
|
|
92
111
|
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
93
112
|
* @private
|
|
94
113
|
*/
|
|
95
|
-
|
|
114
|
+
unsubscribe(channel: string, suffix?: string, cb?: WebSocketAPIDataCallback): void;
|
|
96
115
|
/**
|
|
97
116
|
* Filter departures and return an array.
|
|
98
117
|
*
|
|
99
118
|
* @param {Object} depObject The object containing departures by id.
|
|
100
119
|
* @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
|
|
101
|
-
* @return {Array<
|
|
120
|
+
* @return {Array<Departure>} Return departures array.
|
|
102
121
|
* @private
|
|
103
122
|
*/
|
|
104
|
-
|
|
123
|
+
filterDepartures(depObject: RealtimeAPIDeparturesById, sortByMinArrivalTime?: boolean): RealtimeDepartureExtended[];
|
|
105
124
|
/**
|
|
106
125
|
* Subscribe to departures channel of a given station.
|
|
107
126
|
*
|
|
@@ -109,23 +128,23 @@ declare class RealtimeAPI {
|
|
|
109
128
|
* @param {Boolean} sortByMinArrivalTime Sort by minimum arrival time
|
|
110
129
|
* @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
|
|
111
130
|
*/
|
|
112
|
-
subscribeDepartures(stationId: number, sortByMinArrivalTime: boolean, onMessage: (
|
|
131
|
+
subscribeDepartures(stationId: number, sortByMinArrivalTime: boolean, onMessage: (departures: RealtimeDepartureExtended[]) => void): void;
|
|
113
132
|
/**
|
|
114
133
|
* Unsubscribe from current departures channel.
|
|
115
134
|
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
116
135
|
*/
|
|
117
|
-
unsubscribeDepartures(cb
|
|
136
|
+
unsubscribeDepartures(cb?: WebSocketAPIDataCallback): void;
|
|
118
137
|
/**
|
|
119
138
|
* Subscribe to the disruptions channel for tenant.
|
|
120
139
|
*
|
|
121
|
-
* @param {function} onMessage Function called on each message of the channel.
|
|
140
|
+
* @param {function(news: RealtimeNews)} onMessage Function called on each message of the channel.
|
|
122
141
|
*/
|
|
123
|
-
subscribeDisruptions(onMessage:
|
|
142
|
+
subscribeDisruptions(onMessage: (news: RealtimeNews[]) => void): void;
|
|
124
143
|
/**
|
|
125
144
|
* Unsubscribe disruptions.
|
|
126
145
|
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
127
146
|
*/
|
|
128
|
-
unsubscribeDisruptions(cb
|
|
147
|
+
unsubscribeDisruptions(cb?: WebSocketAPIDataCallback): void;
|
|
129
148
|
/**
|
|
130
149
|
* Return a station with a given uic number and a mode.
|
|
131
150
|
*
|
|
@@ -133,16 +152,14 @@ declare class RealtimeAPI {
|
|
|
133
152
|
* @param {RealtimeMode} mode Realtime mode.
|
|
134
153
|
* @return {Promise<Station>} A station.
|
|
135
154
|
*/
|
|
136
|
-
getStation(uic: number, mode: RealtimeMode): Promise<
|
|
155
|
+
getStation(uic: number, mode: RealtimeMode): Promise<unknown>;
|
|
137
156
|
/**
|
|
138
157
|
* Update the model's station list for a given mode and a bbox.
|
|
139
158
|
*
|
|
140
159
|
* @param {RealtimeMode} mode Realtime mode.
|
|
141
160
|
* @return {Promise<Array<Station>>} An array of stations.
|
|
142
161
|
*/
|
|
143
|
-
getStations(mode: RealtimeMode): Promise<
|
|
144
|
-
/** @ignore */
|
|
145
|
-
stationUpdateTimeout: number | undefined;
|
|
162
|
+
getStations(mode: RealtimeMode): Promise<unknown>;
|
|
146
163
|
/**
|
|
147
164
|
* Subscribe to stations channel.
|
|
148
165
|
* One message pro station.
|
|
@@ -150,23 +167,23 @@ declare class RealtimeAPI {
|
|
|
150
167
|
* @param {RealtimeMode} mode Realtime mode.
|
|
151
168
|
* @param {function(station: Station)} onMessage Function called on each message of the channel.
|
|
152
169
|
*/
|
|
153
|
-
subscribeStations(mode: RealtimeMode, onMessage: (
|
|
170
|
+
subscribeStations(mode: RealtimeMode, onMessage: (station: RealtimeStation) => void): void;
|
|
154
171
|
/**
|
|
155
172
|
* Unsubscribe to stations channel.
|
|
156
173
|
* @param {function} cb The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
|
|
157
174
|
*/
|
|
158
|
-
unsubscribeStations(cb
|
|
175
|
+
unsubscribeStations(cb?: WebSocketAPIDataCallback): void;
|
|
159
176
|
/**
|
|
160
177
|
* Subscribe to extra_geoms channel.
|
|
161
178
|
*
|
|
162
179
|
* @param {function(extraGeoms: GeosJSONFeature[])} onMessage Function called on each message of the channel.
|
|
163
180
|
*/
|
|
164
|
-
subscribeExtraGeoms(onMessage: (
|
|
181
|
+
subscribeExtraGeoms(onMessage: (extraGeoms: RealtimeExtraGeom[]) => void): void;
|
|
165
182
|
/**
|
|
166
183
|
* Unsubscribe to extra_geoms channel.
|
|
167
184
|
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
168
185
|
*/
|
|
169
|
-
unsubscribeExtraGeoms(cb:
|
|
186
|
+
unsubscribeExtraGeoms(cb: WebSocketAPIDataCallback): void;
|
|
170
187
|
/**
|
|
171
188
|
* Subscribe to trajectory channel.
|
|
172
189
|
*
|
|
@@ -174,12 +191,12 @@ declare class RealtimeAPI {
|
|
|
174
191
|
* @param {function(trajectory: RealtimeTrajectory)} onMessage Function called on each message of the channel.
|
|
175
192
|
* @param {boolean} quiet If true, the subscription will not send GET and SUB requests to the websocket.
|
|
176
193
|
*/
|
|
177
|
-
subscribeTrajectory(mode: RealtimeMode, onMessage: (
|
|
194
|
+
subscribeTrajectory(mode: RealtimeMode, onMessage: (response: WebSocketAPIMessageEventData) => void, quiet?: boolean): void;
|
|
178
195
|
/**
|
|
179
196
|
* Unsubscribe to trajectory channels.
|
|
180
197
|
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
181
198
|
*/
|
|
182
|
-
unsubscribeTrajectory(cb:
|
|
199
|
+
unsubscribeTrajectory(cb: WebSocketAPIDataCallback): void;
|
|
183
200
|
/**
|
|
184
201
|
* Subscribe to deleted_vhicles channel.
|
|
185
202
|
*
|
|
@@ -187,14 +204,12 @@ declare class RealtimeAPI {
|
|
|
187
204
|
* @param {function(response: { content: Vehicle })} onMessage Function called on each message of the channel.
|
|
188
205
|
* @param {boolean} quiet If true, the subscription will not send GET and SUB requests to the websocket.
|
|
189
206
|
*/
|
|
190
|
-
subscribeDeletedVehicles(mode: RealtimeMode, onMessage: (
|
|
191
|
-
content: Vehicle;
|
|
192
|
-
}) => any, quiet?: boolean): void;
|
|
207
|
+
subscribeDeletedVehicles(mode: RealtimeMode, onMessage: (response: WebSocketAPIMessageEventData) => void, quiet?: boolean): void;
|
|
193
208
|
/**
|
|
194
209
|
* Unsubscribe to deleted_vhicles channels.
|
|
195
210
|
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
196
211
|
*/
|
|
197
|
-
unsubscribeDeletedVehicles(cb:
|
|
212
|
+
unsubscribeDeletedVehicles(cb: WebSocketAPIDataCallback): void;
|
|
198
213
|
/**
|
|
199
214
|
* Get a full trajectory of a vehicule .
|
|
200
215
|
*
|
|
@@ -203,7 +218,7 @@ declare class RealtimeAPI {
|
|
|
203
218
|
* @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
|
|
204
219
|
* @return {Promise<FullTrajectory>} Return a full trajectory.
|
|
205
220
|
*/
|
|
206
|
-
getFullTrajectory(id:
|
|
221
|
+
getFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, generalizationLevel: RealtimeGeneralizationLevel | undefined): Promise<RealtimeFullTrajectory>;
|
|
207
222
|
/**
|
|
208
223
|
* Get full trajectories of a vehicules .
|
|
209
224
|
*
|
|
@@ -212,57 +227,58 @@ declare class RealtimeAPI {
|
|
|
212
227
|
* @param {string} generalizationLevel The generalization level to request. Can be one of '', 'gen5', 'gen10', 'gen30', 'gen100'.
|
|
213
228
|
* @return {Promise<Array<FullTrajectory>>} Return an array of full trajectories.
|
|
214
229
|
*/
|
|
215
|
-
getFullTrajectories(ids:
|
|
230
|
+
getFullTrajectories(ids: RealtimeTrainId[], mode: RealtimeMode, generalizationLevel: RealtimeGeneralizationLevel): Promise<RealtimeFullTrajectory[]>;
|
|
216
231
|
/**
|
|
217
232
|
* Subscribe to full_trajectory channel of a given vehicle.
|
|
218
233
|
*
|
|
219
234
|
* @param {string} id A vehicle id.
|
|
220
235
|
* @param {RealtimeMode} mode Realtime mode.
|
|
221
236
|
*/
|
|
222
|
-
subscribeFullTrajectory(id:
|
|
237
|
+
subscribeFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode): void;
|
|
223
238
|
/**
|
|
224
239
|
* Unsubscribe from full_trajectory channel
|
|
225
240
|
*
|
|
226
241
|
* @param {string} id A vehicle id.
|
|
227
242
|
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
228
243
|
*/
|
|
229
|
-
unsubscribeFullTrajectory(id:
|
|
244
|
+
unsubscribeFullTrajectory(id: RealtimeTrainId, cb?: WebSocketAPIDataCallback): void;
|
|
230
245
|
/**
|
|
231
246
|
* Get the list of stops for this vehicle.
|
|
232
247
|
*
|
|
233
248
|
* @param {string} id A vehicle id.
|
|
234
249
|
* @return {Promise<StopSequence>} Returns a stop sequence object.
|
|
235
250
|
*/
|
|
236
|
-
getStopSequence(id:
|
|
251
|
+
getStopSequence(id: RealtimeTrainId): Promise<unknown>;
|
|
237
252
|
/**
|
|
238
253
|
* Get a list of stops for a list of vehicles.
|
|
239
254
|
*
|
|
240
255
|
* @param {string[]} ids List of vehicles ids.
|
|
241
256
|
* @return {Promise<Array<StopSequence>>} Return an array of stop sequences.
|
|
242
257
|
*/
|
|
243
|
-
getStopSequences(ids:
|
|
258
|
+
getStopSequences(ids: RealtimeTrainId[]): Promise<unknown[]>;
|
|
244
259
|
/**
|
|
245
260
|
* Subscribe to stopsequence channel of a given vehicle.
|
|
246
261
|
*
|
|
247
262
|
* @param {string} id A vehicle id.
|
|
248
263
|
* @param {function(stopSequence: StopSequence)} onMessage Function called on each message of the channel.
|
|
249
264
|
*/
|
|
250
|
-
subscribeStopSequence(id:
|
|
265
|
+
subscribeStopSequence(id: RealtimeTrainId, onMessage: (stopSequences: RealtimeStopSequence[]) => void): void;
|
|
251
266
|
/**
|
|
252
267
|
* Unsubscribe from stopsequence channel
|
|
253
268
|
*
|
|
254
269
|
* @param {string} id A vehicle id.
|
|
255
270
|
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
256
271
|
*/
|
|
257
|
-
unsubscribeStopSequence(id:
|
|
272
|
+
unsubscribeStopSequence(id: RealtimeTrainId, cb?: WebSocketAPIDataCallback): void;
|
|
258
273
|
/**
|
|
259
274
|
* Subscribe to healthcheck channel.
|
|
260
275
|
* @param {function} onMessage Callback when the subscribe to healthcheck channel succeeds.
|
|
261
276
|
*/
|
|
262
|
-
subscribeHealthCheck(onMessage:
|
|
277
|
+
subscribeHealthCheck(onMessage: WebSocketAPIDataCallback): void;
|
|
263
278
|
/**
|
|
264
279
|
* Unsubscribe to healthcheck channel.
|
|
265
280
|
*/
|
|
266
281
|
unsubscribeHealthCheck(): void;
|
|
267
282
|
}
|
|
283
|
+
export default RealtimeAPI;
|
|
268
284
|
//# sourceMappingURL=RealtimeAPI.d.ts.map
|
package/api/RealtimeAPI.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealtimeAPI.d.ts","sourceRoot":"","sources":["../../src/api/RealtimeAPI.
|
|
1
|
+
{"version":3,"file":"RealtimeAPI.d.ts","sourceRoot":"","sources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AAC,EAAE,wBAAwB;IAK/B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,EAAE,eAAe;IA0BnC;;;;;OAKG;IACH,gBAAgB,CAAC,GAAG,EAAE,eAAe,EAAE;IAKvC;;;;;OAKG;IACH,qBAAqB,CACnB,EAAE,EAAE,eAAe,EACnB,SAAS,EAAE,CAAC,aAAa,EAAE,oBAAoB,EAAE,KAAK,IAAI;IAyB5D;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,EAAE,wBAAwB;IAI1E;;;OAGG;IACH,oBAAoB,CAAC,SAAS,EAAE,wBAAwB;IAKxD;;OAEG;IACH,sBAAsB;CAGvB;AACD,eAAe,WAAW,CAAC"}
|
package/api/RealtimeAPI.js
CHANGED
|
@@ -46,9 +46,9 @@ class RealtimeAPI {
|
|
|
46
46
|
constructor(options = {}) {
|
|
47
47
|
this.defineProperties(options);
|
|
48
48
|
/** @ignore */
|
|
49
|
-
this.subscribedStationUic =
|
|
49
|
+
this.subscribedStationUic = undefined;
|
|
50
50
|
/** @ignore */
|
|
51
|
-
this.departureUpdateTimeout =
|
|
51
|
+
this.departureUpdateTimeout = undefined;
|
|
52
52
|
/** @ignore */
|
|
53
53
|
this.maxDepartureAge = 30;
|
|
54
54
|
/** @ignore */
|
|
@@ -58,6 +58,7 @@ class RealtimeAPI {
|
|
|
58
58
|
/** @ignore */
|
|
59
59
|
this.onOpen = this.onOpen.bind(this);
|
|
60
60
|
}
|
|
61
|
+
/* @private */
|
|
61
62
|
defineProperties(options) {
|
|
62
63
|
let opt = options;
|
|
63
64
|
if (typeof options === 'string') {
|
|
@@ -93,7 +94,7 @@ class RealtimeAPI {
|
|
|
93
94
|
set: (newBbox) => {
|
|
94
95
|
if (JSON.stringify(newBbox) !== JSON.stringify(bbox)) {
|
|
95
96
|
bbox = newBbox;
|
|
96
|
-
if (this.wsApi) {
|
|
97
|
+
if (this.wsApi && bbox) {
|
|
97
98
|
this.wsApi.send(`BBOX ${bbox.join(' ')}`);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
@@ -144,9 +145,11 @@ class RealtimeAPI {
|
|
|
144
145
|
// Register BBOX and PROJECTION messages must be send before previous subscriptions.
|
|
145
146
|
this.wsApi.connect(this.url, this.onOpen);
|
|
146
147
|
// Register reconnection on close.
|
|
147
|
-
this.wsApi.websocket
|
|
148
|
-
this.
|
|
149
|
-
|
|
148
|
+
if (this.wsApi.websocket) {
|
|
149
|
+
this.wsApi.websocket.onclose = () => {
|
|
150
|
+
this.onClose();
|
|
151
|
+
};
|
|
152
|
+
}
|
|
150
153
|
}
|
|
151
154
|
/**
|
|
152
155
|
* Close the websocket connection without reconnection.
|
|
@@ -181,7 +184,7 @@ class RealtimeAPI {
|
|
|
181
184
|
if (this.pingIntervalMs) {
|
|
182
185
|
window.clearInterval(this.pingInterval);
|
|
183
186
|
/** @ignore */
|
|
184
|
-
this.pingInterval = setInterval(() => {
|
|
187
|
+
this.pingInterval = window.setInterval(() => {
|
|
185
188
|
this.wsApi.send('PING');
|
|
186
189
|
}, this.pingIntervalMs);
|
|
187
190
|
}
|
|
@@ -208,6 +211,9 @@ class RealtimeAPI {
|
|
|
208
211
|
* @private
|
|
209
212
|
*/
|
|
210
213
|
subscribe(channel, onSuccess, onError, quiet = false) {
|
|
214
|
+
if (!channel || !onSuccess) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
211
217
|
this.wsApi.subscribe({ channel }, onSuccess, onError, quiet);
|
|
212
218
|
}
|
|
213
219
|
/**
|
|
@@ -218,7 +224,7 @@ class RealtimeAPI {
|
|
|
218
224
|
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
219
225
|
* @private
|
|
220
226
|
*/
|
|
221
|
-
unsubscribe(channel, suffix, cb) {
|
|
227
|
+
unsubscribe(channel, suffix = '', cb) {
|
|
222
228
|
this.wsApi.unsubscribe(`${channel}${getModeSuffix(RealtimeModes.SCHEMATIC, RealtimeModes)}${suffix}`, cb);
|
|
223
229
|
this.wsApi.unsubscribe(`${channel}${getModeSuffix(RealtimeModes.TOPOGRAPHIC, RealtimeModes)}${suffix || ''}`, cb);
|
|
224
230
|
}
|
|
@@ -227,50 +233,50 @@ class RealtimeAPI {
|
|
|
227
233
|
*
|
|
228
234
|
* @param {Object} depObject The object containing departures by id.
|
|
229
235
|
* @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
|
|
230
|
-
* @return {Array<
|
|
236
|
+
* @return {Array<Departure>} Return departures array.
|
|
231
237
|
* @private
|
|
232
238
|
*/
|
|
233
239
|
filterDepartures(depObject, sortByMinArrivalTime = false) {
|
|
234
240
|
const departures = Object.keys(depObject).map((k) => depObject[k]);
|
|
235
241
|
departures.sort((a, b) => compareDepartures(a, b, sortByMinArrivalTime));
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
future =
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
past =
|
|
242
|
+
const futureDate = new Date();
|
|
243
|
+
futureDate.setMinutes(futureDate.getMinutes() + this.maxDepartureAge);
|
|
244
|
+
const future = futureDate.getTime();
|
|
245
|
+
const pastDate = new Date();
|
|
246
|
+
pastDate.setMinutes(pastDate.getMinutes() - this.maxDepartureAge);
|
|
247
|
+
const past = pastDate.getTime();
|
|
242
248
|
const departureArray = [];
|
|
243
249
|
const platformsBoarding = [];
|
|
244
250
|
let previousDeparture = null;
|
|
245
251
|
for (let i = departures.length - 1; i >= 0; i -= 1) {
|
|
246
|
-
const
|
|
247
|
-
const
|
|
252
|
+
const departure = Object.assign({}, departures[i]);
|
|
253
|
+
const time = new Date(departure.time).getTime();
|
|
248
254
|
// Only show departures within the next 30 minutes
|
|
249
|
-
if (
|
|
255
|
+
if (time > past && time < future) {
|
|
250
256
|
// If 2 trains are boarding at the same platform,
|
|
251
257
|
// remove the older one.
|
|
252
|
-
if (
|
|
253
|
-
if (platformsBoarding.indexOf(
|
|
254
|
-
platformsBoarding.push(
|
|
258
|
+
if (departure.state === 'BOARDING') {
|
|
259
|
+
if (platformsBoarding.indexOf(departure.platform) === -1) {
|
|
260
|
+
platformsBoarding.push(departure.platform);
|
|
255
261
|
}
|
|
256
262
|
else {
|
|
257
|
-
|
|
263
|
+
departure.state = 'HIDDEN';
|
|
258
264
|
}
|
|
259
265
|
}
|
|
260
266
|
// If two trains with the same line number and destinatin
|
|
261
267
|
// and a departure difference < 1 minute, hide the second one.
|
|
262
268
|
if (previousDeparture &&
|
|
263
|
-
|
|
264
|
-
Math.abs(
|
|
265
|
-
|
|
266
|
-
|
|
269
|
+
departure.to[0] === previousDeparture.to[0] &&
|
|
270
|
+
Math.abs(time - previousDeparture.time) < 1000 &&
|
|
271
|
+
departure.line.name === previousDeparture.line.name) {
|
|
272
|
+
departure.state = 'HIDDEN';
|
|
267
273
|
}
|
|
268
|
-
if (/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(
|
|
269
|
-
|
|
274
|
+
if (/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(departure.state)) {
|
|
275
|
+
departure.cancelled = true;
|
|
270
276
|
}
|
|
271
|
-
previousDeparture =
|
|
272
|
-
previousDeparture.time =
|
|
273
|
-
departureArray.unshift(
|
|
277
|
+
previousDeparture = departure;
|
|
278
|
+
previousDeparture.time = time;
|
|
279
|
+
departureArray.unshift(departure);
|
|
274
280
|
}
|
|
275
281
|
}
|
|
276
282
|
return departureArray;
|
|
@@ -288,19 +294,24 @@ class RealtimeAPI {
|
|
|
288
294
|
this.subscribedStationUic = stationId;
|
|
289
295
|
const channel = stationId ? `timetable_${stationId}` : null;
|
|
290
296
|
const departureObject = {};
|
|
291
|
-
|
|
297
|
+
if (!channel) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const onSuccess = (data) => {
|
|
292
301
|
if (data.source === channel) {
|
|
293
302
|
const content = data.content || {};
|
|
303
|
+
// TODO: These lines seems useless because content.timestamp never exists
|
|
304
|
+
// we should check if actually the case
|
|
294
305
|
const tDiff = new Date(content.timestamp).getTime() - Date.now();
|
|
295
|
-
content.
|
|
296
|
-
departureObject[content.call_id] = content;
|
|
306
|
+
departureObject[content.call_id] = Object.assign(Object.assign({}, content), { timediff: tDiff });
|
|
297
307
|
window.clearTimeout(this.departureUpdateTimeout);
|
|
298
308
|
this.departureUpdateTimeout = window.setTimeout(() => {
|
|
299
309
|
const departures = this.filterDepartures(departureObject, sortByMinArrivalTime || false);
|
|
300
310
|
onMessage(departures);
|
|
301
311
|
}, 100);
|
|
302
312
|
}
|
|
303
|
-
}
|
|
313
|
+
};
|
|
314
|
+
this.subscribe(channel, onSuccess, () => {
|
|
304
315
|
onMessage([]);
|
|
305
316
|
});
|
|
306
317
|
}
|
|
@@ -311,13 +322,13 @@ class RealtimeAPI {
|
|
|
311
322
|
unsubscribeDepartures(cb) {
|
|
312
323
|
if (this.subscribedStationUic) {
|
|
313
324
|
this.unsubscribe(`timetable_${this.subscribedStationUic}`, '', cb);
|
|
314
|
-
this.subscribedStationUic =
|
|
325
|
+
this.subscribedStationUic = undefined;
|
|
315
326
|
}
|
|
316
327
|
}
|
|
317
328
|
/**
|
|
318
329
|
* Subscribe to the disruptions channel for tenant.
|
|
319
330
|
*
|
|
320
|
-
* @param {function} onMessage Function called on each message of the channel.
|
|
331
|
+
* @param {function(news: RealtimeNews)} onMessage Function called on each message of the channel.
|
|
321
332
|
*/
|
|
322
333
|
subscribeDisruptions(onMessage) {
|
|
323
334
|
this.subscribe(`${this.prefix}newsticker`, (data) => {
|
|
@@ -441,7 +452,7 @@ class RealtimeAPI {
|
|
|
441
452
|
*/
|
|
442
453
|
subscribeTrajectory(mode, onMessage, quiet = false) {
|
|
443
454
|
this.unsubscribeTrajectory(onMessage);
|
|
444
|
-
this.subscribe(`trajectory${getModeSuffix(mode, RealtimeModes)}`, onMessage,
|
|
455
|
+
this.subscribe(`trajectory${getModeSuffix(mode, RealtimeModes)}`, onMessage, undefined, quiet);
|
|
445
456
|
}
|
|
446
457
|
/**
|
|
447
458
|
* Unsubscribe to trajectory channels.
|
|
@@ -459,7 +470,7 @@ class RealtimeAPI {
|
|
|
459
470
|
*/
|
|
460
471
|
subscribeDeletedVehicles(mode, onMessage, quiet = false) {
|
|
461
472
|
this.unsubscribeDeletedVehicles(onMessage);
|
|
462
|
-
this.subscribe(`deleted_vehicles${getModeSuffix(mode, RealtimeModes)}`, onMessage,
|
|
473
|
+
this.subscribe(`deleted_vehicles${getModeSuffix(mode, RealtimeModes)}`, onMessage, undefined, quiet);
|
|
463
474
|
}
|
|
464
475
|
/**
|
|
465
476
|
* Unsubscribe to deleted_vhicles channels.
|
|
@@ -545,10 +556,11 @@ class RealtimeAPI {
|
|
|
545
556
|
};
|
|
546
557
|
return new Promise((resolve, reject) => {
|
|
547
558
|
this.wsApi.get(params, (data) => {
|
|
548
|
-
|
|
549
|
-
|
|
559
|
+
const content = data.content;
|
|
560
|
+
if (content && content.length) {
|
|
561
|
+
const stopSequences = content.map((stopSequence) => cleanStopTime(stopSequence));
|
|
550
562
|
// Remove the delay from arrivalTime and departureTime
|
|
551
|
-
resolve(
|
|
563
|
+
resolve(stopSequences);
|
|
552
564
|
}
|
|
553
565
|
resolve([]);
|
|
554
566
|
}, (err) => {
|
|
@@ -576,10 +588,11 @@ class RealtimeAPI {
|
|
|
576
588
|
window.clearTimeout(this.fullTrajectoryUpdateTimeout);
|
|
577
589
|
this.unsubscribeStopSequence(id);
|
|
578
590
|
this.subscribe(`stopsequence_${id}`, (data) => {
|
|
579
|
-
|
|
580
|
-
|
|
591
|
+
const content = data.content;
|
|
592
|
+
if (content && content.length) {
|
|
593
|
+
const stopSequences = content.map((stopSequence) => cleanStopTime(stopSequence));
|
|
581
594
|
// Remove the delay from arrivalTime and departureTime
|
|
582
|
-
onMessage(
|
|
595
|
+
onMessage(stopSequences);
|
|
583
596
|
}
|
|
584
597
|
}, (err) => {
|
|
585
598
|
// eslint-disable-next-line no-console
|
package/api/RoutingAPI.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import HttpAPI from '../common/api/HttpAPI';
|
|
2
|
-
import { RoutingParameters, RoutingResponse } from '
|
|
2
|
+
import { RoutingParameters, RoutingResponse } from '../types';
|
|
3
3
|
export declare type RoutingAPIOptions = {
|
|
4
4
|
url?: string;
|
|
5
5
|
apiKey?: string;
|
|
@@ -23,7 +23,7 @@ declare class RoutingAPI extends HttpAPI {
|
|
|
23
23
|
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
24
24
|
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
25
25
|
*/
|
|
26
|
-
constructor(options
|
|
26
|
+
constructor(options?: RoutingAPIOptions);
|
|
27
27
|
/**
|
|
28
28
|
* Route.
|
|
29
29
|
*
|
package/api/RoutingAPI.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutingAPI.d.ts","sourceRoot":"","sources":["../../src/api/RoutingAPI.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"RoutingAPI.d.ts","sourceRoot":"","sources":["../../src/api/RoutingAPI.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE9D,oBAAY,iBAAiB,GAAG;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,cAAM,UAAW,SAAQ,OAAO;IAC9B;;;;;;OAMG;gBACS,OAAO,GAAE,iBAAsB;IAI3C;;;;;;OAMG;IACH,KAAK,CACH,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,eAAe,CAAC;CAG5B;AAED,eAAe,UAAU,CAAC"}
|
package/api/RoutingAPI.js
CHANGED
|
@@ -18,7 +18,7 @@ class RoutingAPI extends HttpAPI {
|
|
|
18
18
|
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
19
19
|
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
20
20
|
*/
|
|
21
|
-
constructor(options) {
|
|
21
|
+
constructor(options = {}) {
|
|
22
22
|
super(Object.assign({ url: 'https://api.geops.io/routing/v1/' }, options));
|
|
23
23
|
}
|
|
24
24
|
/**
|
package/api/StopsAPI.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import HttpAPI from '../common/api/HttpAPI';
|
|
2
|
+
import { StopsParameters, StopsResponse } from '../types';
|
|
3
|
+
export declare type StopsAPIOptions = {
|
|
4
|
+
url?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
};
|
|
2
7
|
/**
|
|
3
8
|
* Access to the [Stops service](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
|
|
4
9
|
*
|
|
@@ -15,22 +20,19 @@ declare class StopsAPI extends HttpAPI {
|
|
|
15
20
|
/**
|
|
16
21
|
* Constructor
|
|
17
22
|
*
|
|
18
|
-
* @param {
|
|
23
|
+
* @param {StopsAPIOptions} options Options.
|
|
19
24
|
* @param {string} [options.url='https://api.geops.io/stops/v1/'] Service url.
|
|
20
25
|
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
21
26
|
*/
|
|
22
|
-
constructor(options?:
|
|
23
|
-
url?: string | undefined;
|
|
24
|
-
apiKey: string;
|
|
25
|
-
});
|
|
27
|
+
constructor(options?: StopsAPIOptions);
|
|
26
28
|
/**
|
|
27
|
-
* Search.
|
|
29
|
+
* Search fo stops.
|
|
28
30
|
*
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
31
|
-
* @return {Promise<
|
|
31
|
+
* @param {StopsParameters} params Request parameters. See [Stops service documentation](https://developer.geops.io/apis/stops).
|
|
32
|
+
* @param {RequestInit} config Options for the fetch request.
|
|
33
|
+
* @return {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
32
34
|
*/
|
|
33
|
-
search(params:
|
|
35
|
+
search(params: StopsParameters, config: RequestInit): Promise<StopsResponse>;
|
|
34
36
|
}
|
|
35
|
-
|
|
37
|
+
export default StopsAPI;
|
|
36
38
|
//# sourceMappingURL=StopsAPI.d.ts.map
|