mobility-toolbox-js 2.0.0-beta.3 → 2.0.0-beta.33

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.
Files changed (220) hide show
  1. package/README.md +4 -1
  2. package/api/RealtimeAPI.d.ts +268 -0
  3. package/api/RealtimeAPI.d.ts.map +1 -0
  4. package/api/RoutingAPI.d.ts +33 -0
  5. package/api/RoutingAPI.d.ts.map +1 -0
  6. package/api/StopsAPI.d.ts +36 -0
  7. package/api/StopsAPI.d.ts.map +1 -0
  8. package/api/index.d.ts +5 -0
  9. package/api/index.d.ts.map +1 -0
  10. package/api/typedefs.d.ts +105 -0
  11. package/api/typedefs.d.ts.map +1 -0
  12. package/common/api/HttpAPI.d.ts +31 -0
  13. package/common/api/HttpAPI.d.ts.map +1 -0
  14. package/common/api/WebSocketAPI.d.ts +95 -0
  15. package/common/api/WebSocketAPI.d.ts.map +1 -0
  16. package/common/controls/Control.d.ts +74 -0
  17. package/common/controls/Control.d.ts.map +1 -0
  18. package/common/index.d.ts +3 -0
  19. package/common/index.d.ts.map +1 -0
  20. package/common/layers/Layer.d.ts +80 -0
  21. package/common/layers/Layer.d.ts.map +1 -0
  22. package/common/mixins/CopyrightMixin.d.ts +22 -0
  23. package/common/mixins/CopyrightMixin.d.ts.map +1 -0
  24. package/common/mixins/MapboxLayerMixin.d.ts +27 -0
  25. package/common/mixins/MapboxLayerMixin.d.ts.map +1 -0
  26. package/common/mixins/RealtimeLayerMixin.d.ts +58 -0
  27. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
  28. package/common/mixins/StopFinderMixin.d.ts +40 -0
  29. package/common/mixins/StopFinderMixin.d.ts.map +1 -0
  30. package/common/mixins/UserInteractionsLayerMixin.d.ts +42 -0
  31. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
  32. package/common/styles/index.d.ts +5 -0
  33. package/common/styles/index.d.ts.map +1 -0
  34. package/common/styles/realtimeDefaultStyle.d.ts +15 -0
  35. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
  36. package/common/styles/{trackerDelayStyle.js → realtimeDelayStyle.d.ts} +3 -9
  37. package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
  38. package/common/styles/realtimeSimpleStyle.d.ts +3 -0
  39. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
  40. package/common/typedefs.d.ts +50 -0
  41. package/common/typedefs.d.ts.map +1 -0
  42. package/common/utils/cleanStopTime.d.ts +7 -0
  43. package/common/utils/cleanStopTime.d.ts.map +1 -0
  44. package/common/utils/compareDepartures.d.ts +9 -0
  45. package/common/utils/compareDepartures.d.ts.map +1 -0
  46. package/common/utils/createCanvas.d.ts +9 -0
  47. package/common/utils/createCanvas.d.ts.map +1 -0
  48. package/common/utils/createTrackerFilters.d.ts +12 -0
  49. package/common/utils/createTrackerFilters.d.ts.map +1 -0
  50. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  51. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
  52. package/common/utils/getMapboxMapCopyrights.d.ts +8 -0
  53. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
  54. package/common/utils/getMapboxRender.d.ts +5 -0
  55. package/common/utils/getMapboxRender.d.ts.map +1 -0
  56. package/common/utils/getMaplibreRender.d.ts +5 -0
  57. package/common/utils/getMaplibreRender.d.ts.map +1 -0
  58. package/common/utils/getRealtimeModeSuffix.d.ts +8 -0
  59. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
  60. package/common/utils/getUrlWithParams.d.ts +9 -0
  61. package/common/utils/getUrlWithParams.d.ts.map +1 -0
  62. package/common/utils/getVehiclePosition.d.ts +14 -0
  63. package/common/utils/getVehiclePosition.d.ts.map +1 -0
  64. package/common/utils/index.d.ts +12 -0
  65. package/common/utils/index.d.ts.map +1 -0
  66. package/common/utils/removeDuplicate.d.ts +10 -0
  67. package/common/utils/removeDuplicate.d.ts.map +1 -0
  68. package/common/utils/renderTrajectories.d.ts +20 -0
  69. package/common/utils/renderTrajectories.d.ts.map +1 -0
  70. package/common/utils/sortByDelay.d.ts +3 -0
  71. package/common/utils/sortByDelay.d.ts.map +1 -0
  72. package/common/utils/timeUtils.d.ts +5 -0
  73. package/common/utils/timeUtils.d.ts.map +1 -0
  74. package/common/utils/trackerConfig.d.ts +24 -0
  75. package/common/utils/trackerConfig.d.ts.map +1 -0
  76. package/iife.d.ts +3 -0
  77. package/iife.d.ts.map +1 -0
  78. package/index.d.ts +6 -0
  79. package/index.d.ts.map +1 -0
  80. package/mapbox/controls/CopyrightControl.d.ts +32 -0
  81. package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
  82. package/mapbox/controls/index.d.ts +2 -0
  83. package/mapbox/controls/index.d.ts.map +1 -0
  84. package/mapbox/index.d.ts +5 -0
  85. package/mapbox/index.d.ts.map +1 -0
  86. package/mapbox/layers/Layer.d.ts +47 -0
  87. package/mapbox/layers/Layer.d.ts.map +1 -0
  88. package/mapbox/layers/RealtimeLayer.d.ts +118 -0
  89. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
  90. package/mapbox/layers/index.d.ts +3 -0
  91. package/mapbox/layers/index.d.ts.map +1 -0
  92. package/mapbox/utils.d.ts +8 -0
  93. package/mapbox/utils.d.ts.map +1 -0
  94. package/mbt.js +50042 -0
  95. package/mbt.js.map +7 -0
  96. package/mbt.min.js +1008 -0
  97. package/mbt.min.js.map +7 -0
  98. package/ol/controls/CopyrightControl.d.ts +31 -0
  99. package/ol/controls/CopyrightControl.d.ts.map +1 -0
  100. package/ol/controls/RoutingControl.d.ts +180 -0
  101. package/ol/controls/RoutingControl.d.ts.map +1 -0
  102. package/ol/controls/StopFinderControl.d.ts +32 -0
  103. package/ol/controls/StopFinderControl.d.ts.map +1 -0
  104. package/ol/controls/index.d.ts +4 -0
  105. package/ol/controls/index.d.ts.map +1 -0
  106. package/ol/index.d.ts +6 -0
  107. package/ol/index.d.ts.map +1 -0
  108. package/ol/layers/Layer.d.ts +49 -0
  109. package/ol/layers/Layer.d.ts.map +1 -0
  110. package/ol/layers/MapboxLayer.d.ts +42 -0
  111. package/ol/layers/MapboxLayer.d.ts.map +1 -0
  112. package/ol/layers/MapboxStyleLayer.d.ts +146 -0
  113. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
  114. package/ol/layers/MaplibreLayer.d.ts +27 -0
  115. package/ol/layers/MaplibreLayer.d.ts.map +1 -0
  116. package/ol/layers/RealtimeLayer.d.ts +119 -0
  117. package/ol/layers/RealtimeLayer.d.ts.map +1 -0
  118. package/ol/layers/RoutingLayer.d.ts +24 -0
  119. package/ol/layers/RoutingLayer.d.ts.map +1 -0
  120. package/ol/layers/VectorLayer.d.ts +23 -0
  121. package/ol/layers/VectorLayer.d.ts.map +1 -0
  122. package/ol/layers/WMSLayer.d.ts +38 -0
  123. package/ol/layers/WMSLayer.d.ts.map +1 -0
  124. package/ol/layers/index.d.ts +9 -0
  125. package/ol/layers/index.d.ts.map +1 -0
  126. package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
  127. package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
  128. package/ol/styles/fullTrajectoryStyle.d.ts +4 -0
  129. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
  130. package/ol/styles/index.d.ts +3 -0
  131. package/ol/styles/index.d.ts.map +1 -0
  132. package/package.json +56 -95
  133. package/setupTests.d.ts +2 -0
  134. package/setupTests.d.ts.map +1 -0
  135. package/types/index.d.ts +10 -0
  136. package/types/realtime.d.ts +24 -0
  137. package/types/routing.d.ts +206 -0
  138. package/types/stops.d.ts +143 -0
  139. package/api/index.js +0 -3
  140. package/api/routing/RoutingAPI.js +0 -44
  141. package/api/routing/RoutingAPI.test.js +0 -41
  142. package/api/stops/StopsAPI.js +0 -41
  143. package/api/stops/StopsAPI.test.js +0 -34
  144. package/api/tralis/TralisAPI.js +0 -731
  145. package/api/tralis/TralisAPI.test.js +0 -75
  146. package/api/tralis/TralisAPIUtils.js +0 -73
  147. package/api/tralis/WebSocketConnector.js +0 -338
  148. package/api/tralis/WebSocketConnector.test.js +0 -356
  149. package/api/tralis/typedefs.js +0 -81
  150. package/common/Tracker.js +0 -197
  151. package/common/api/api.js +0 -64
  152. package/common/api/api.test.js +0 -68
  153. package/common/controls/Control.js +0 -146
  154. package/common/controls/Control.test.js +0 -98
  155. package/common/layers/Layer.js +0 -404
  156. package/common/layers/Layer.test.js +0 -585
  157. package/common/mixins/CopyrightMixin.js +0 -48
  158. package/common/mixins/SearchMixin.js +0 -176
  159. package/common/mixins/TralisLayerMixin.js +0 -930
  160. package/common/styles/index.js +0 -4
  161. package/common/styles/trackerDefaultStyle.js +0 -333
  162. package/common/styles/trackerSimpleStyle.js +0 -22
  163. package/common/trackerConfig.js +0 -190
  164. package/common/trackerConfig.test.js +0 -25
  165. package/common/typedefs.js +0 -23
  166. package/common/utils/createTrackerFilters.js +0 -87
  167. package/common/utils/createTrackerFilters.test.js +0 -95
  168. package/common/utils/getMapboxMapCopyrights.js +0 -32
  169. package/common/utils/getMapboxMapCopyrights.test.js +0 -47
  170. package/common/utils/getMapboxStyleUrl.js +0 -32
  171. package/common/utils/getVehiclePosition.js +0 -72
  172. package/common/utils/index.js +0 -6
  173. package/common/utils/removeDuplicate.js +0 -22
  174. package/common/utils/removeDuplicate.test.js +0 -22
  175. package/common/utils/sortByDelay.js +0 -23
  176. package/common/utils/timeUtils.js +0 -44
  177. package/common/utils/timeUtils.test.js +0 -16
  178. package/index.js +0 -2
  179. package/index.js.map +0 -1
  180. package/mapbox/controls/CopyrightControl.js +0 -58
  181. package/mapbox/index.js +0 -3
  182. package/mapbox/layers/Layer.js +0 -118
  183. package/mapbox/layers/Layer.test.js +0 -202
  184. package/mapbox/layers/TralisLayer.js +0 -329
  185. package/mapbox/layers/TralisLayer.test.js +0 -40
  186. package/mapbox/utils.js +0 -46
  187. package/module.js +0 -23
  188. package/ol/README.md +0 -0
  189. package/ol/controls/CopyrightControl.js +0 -80
  190. package/ol/controls/CopyrightControl.test.js +0 -211
  191. package/ol/controls/RoutingControl.js +0 -752
  192. package/ol/controls/RoutingControl.test.js +0 -216
  193. package/ol/controls/StopFinderControl.js +0 -38
  194. package/ol/controls/StopFinderControl.test.js +0 -59
  195. package/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
  196. package/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
  197. package/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
  198. package/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
  199. package/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
  200. package/ol/controls/snapshots/RoutingControlStation1.json +0 -60
  201. package/ol/controls/snapshots/RoutingControlStation2.json +0 -49
  202. package/ol/index.js +0 -13
  203. package/ol/layers/Layer.js +0 -193
  204. package/ol/layers/Layer.test.js +0 -197
  205. package/ol/layers/MapboxLayer.js +0 -378
  206. package/ol/layers/MapboxLayer.test.js +0 -186
  207. package/ol/layers/MapboxStyleLayer.js +0 -417
  208. package/ol/layers/MapboxStyleLayer.test.js +0 -262
  209. package/ol/layers/MaplibreLayer.js +0 -280
  210. package/ol/layers/RoutingLayer.js +0 -91
  211. package/ol/layers/RoutingLayer.test.js +0 -49
  212. package/ol/layers/TralisLayer.js +0 -359
  213. package/ol/layers/TralisLayer.test.js +0 -97
  214. package/ol/layers/VectorLayer.js +0 -43
  215. package/ol/layers/VectorLayer.test.js +0 -98
  216. package/ol/layers/WMSLayer.js +0 -80
  217. package/ol/layers/WMSLayer.test.js +0 -84
  218. package/ol/styles/fullTrajectoryDelayStyle.js +0 -35
  219. package/ol/styles/fullTrajectoryStyle.js +0 -51
  220. package/ol/styles/index.js +0 -2
package/README.md CHANGED
@@ -8,13 +8,16 @@ The tools in this library have been inspired by many projects realized for publi
8
8
  [![Netlify Status](https://api.netlify.com/api/v1/badges/b368ab18-9dbf-416c-91f6-a82076b02c10/deploy-status)](https://app.netlify.com/sites/mobility-toolbox-js/deploys)
9
9
 
10
10
  ## Main Features
11
+
11
12
  * Display [real-time vehicle positions and prognosis data](http://tracker.geops.ch/) on a map.
12
13
  * Search for [stops and stations](https://maps2.trafimage.ch) all over the world.
13
14
  * Get [precise geographic courses](https://geops.github.io/geops-routing-demo/) for all modes of transport.
14
15
  * Generate beautiful maps for public transport, mobility and logistics
15
16
 
16
17
  ## Documentation and examples
17
- Visit https://mobility-toolbox-js.geops.io
18
+
19
+ Visit https://master--mobility-toolbox-js.netlify.app/
18
20
 
19
21
  ## Version 1.x.x
22
+
20
23
  The master branch is now open for the version 2 development. The version 1 is still available in [1.x.x](https://github.com/geops/mobility-toolbox-js/tree/1.x.x) branch.
@@ -0,0 +1,268 @@
1
+ /**
2
+ * Enum for Realtime modes.
3
+ */
4
+ export type RealtimeModes = RealtimeMode;
5
+ export namespace RealtimeModes {
6
+ const RAW: string;
7
+ const TOPOGRAPHIC: string;
8
+ const SCHEMATIC: string;
9
+ }
10
+ export default RealtimeAPI;
11
+ /**
12
+ * Enum for Realtime modes.
13
+ */
14
+ export type RealtimeMode = string;
15
+ /**
16
+ * This class provides convenience methods to access to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
17
+ *
18
+ * @example
19
+ * import { RealtimeAPI } from 'mobility-toolbox-js/api';
20
+ *
21
+ * const api = new RealtimeAPI({
22
+ * url: "yourUrl",
23
+ * apiKey: "yourApiKey"
24
+ * });
25
+ *
26
+ * @example
27
+ * import { RealtimeAPI } from 'mobility-toolbox-js/api';
28
+ *
29
+ * const api = new RealtimeAPI("yourUrl");
30
+ */
31
+ declare class RealtimeAPI {
32
+ /**
33
+ * Constructor
34
+ *
35
+ * @param {Object|string} options A string representing the url of the service or an object containing the url and the apiKey.
36
+ * @param {string} options.url Url to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
37
+ * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
38
+ * @param {string} [options.prefix=''] Service prefix to specify tenant.
39
+ * @param {string} [options.projection] The epsg code of the projection for features. Default to EPSG:3857.
40
+ * @param {number[4]} [options.bbox=[minX, minY, maxX, maxY, zoom, tenant] The bounding box to receive data from.
41
+ */
42
+ constructor(options?: any | string);
43
+ /** @ignore */
44
+ subscribedStationUic: number;
45
+ /** @ignore */
46
+ departureUpdateTimeout: number;
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;
59
+ open(): void;
60
+ /**
61
+ * Close the websocket connection without reconnection.
62
+ */
63
+ close(): void;
64
+ /**
65
+ * Unsubscribe trajectory and deleted_vehicles channels. To resubscribe you have to set a new BBOX.
66
+ */
67
+ reset(): void;
68
+ /** @ignore */
69
+ pingInterval: NodeJS.Timer;
70
+ /**
71
+ * Callback when the websocket is closed by the server.
72
+ * It auto reconnects after a timeout.
73
+ */
74
+ onClose(): void;
75
+ /** @ignore */
76
+ reconnectTimeout: number;
77
+ /**
78
+ * Subscribe to a channel.
79
+ *
80
+ * @param {string} channel Name of the websocket channel to subscribe.
81
+ * @param {function} onSuccess Callback when the subscription succeeds.
82
+ * @param {function} onError Callback when the subscription fails.
83
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
84
+ * @private
85
+ */
86
+ private subscribe;
87
+ /**
88
+ * Unsubscribe both modes of a channel.
89
+ *
90
+ * @param {string} channel Name of the websocket channel to unsubscribe.
91
+ * @param {string} suffix Suffix to add to the channel name.
92
+ * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
93
+ * @private
94
+ */
95
+ private unsubscribe;
96
+ /**
97
+ * Filter departures and return an array.
98
+ *
99
+ * @param {Object} depObject The object containing departures by id.
100
+ * @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
101
+ * @return {Array<departure>} Return departures array.
102
+ * @private
103
+ */
104
+ private filterDepartures;
105
+ /**
106
+ * Subscribe to departures channel of a given station.
107
+ *
108
+ * @param {number} stationId UIC of the station.
109
+ * @param {Boolean} sortByMinArrivalTime Sort by minimum arrival time
110
+ * @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
111
+ */
112
+ subscribeDepartures(stationId: number, sortByMinArrivalTime: boolean, onMessage: (arg0: departures, arg1: Departure[]) => any): void;
113
+ /**
114
+ * Unsubscribe from current departures channel.
115
+ * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
116
+ */
117
+ unsubscribeDepartures(cb: Function): void;
118
+ /**
119
+ * Subscribe to the disruptions channel for tenant.
120
+ *
121
+ * @param {function} onMessage Function called on each message of the channel.
122
+ */
123
+ subscribeDisruptions(onMessage: Function): void;
124
+ /**
125
+ * Unsubscribe disruptions.
126
+ * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
127
+ */
128
+ unsubscribeDisruptions(cb: Function): void;
129
+ /**
130
+ * Return a station with a given uic number and a mode.
131
+ *
132
+ * @param {number} uic UIC of the station.
133
+ * @param {RealtimeMode} mode Realtime mode.
134
+ * @return {Promise<Station>} A station.
135
+ */
136
+ getStation(uic: number, mode: RealtimeMode): Promise<Station>;
137
+ /**
138
+ * Update the model's station list for a given mode and a bbox.
139
+ *
140
+ * @param {RealtimeMode} mode Realtime mode.
141
+ * @return {Promise<Array<Station>>} An array of stations.
142
+ */
143
+ getStations(mode: RealtimeMode): Promise<Array<Station>>;
144
+ /** @ignore */
145
+ stationUpdateTimeout: number;
146
+ /**
147
+ * Subscribe to stations channel.
148
+ * One message pro station.
149
+ *
150
+ * @param {RealtimeMode} mode Realtime mode.
151
+ * @param {function(station: Station)} onMessage Function called on each message of the channel.
152
+ */
153
+ subscribeStations(mode: RealtimeMode, onMessage: (arg0: station, arg1: Station) => any): void;
154
+ /**
155
+ * Unsubscribe to stations channel.
156
+ * @param {function} cb The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
157
+ */
158
+ unsubscribeStations(cb: Function): void;
159
+ /**
160
+ * Subscribe to extra_geoms channel.
161
+ *
162
+ * @param {function(extraGeoms: GeosJSONFeature[])} onMessage Function called on each message of the channel.
163
+ */
164
+ subscribeExtraGeoms(onMessage: (arg0: extraGeoms, arg1: GeosJSONFeature[]) => any): void;
165
+ /**
166
+ * Unsubscribe to extra_geoms channel.
167
+ * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
168
+ */
169
+ unsubscribeExtraGeoms(cb: Function): void;
170
+ /**
171
+ * Subscribe to trajectory channel.
172
+ *
173
+ * @param {RealtimeMode} mode Realtime mode.
174
+ * @param {function(trajectory: RealtimeTrajectory)} onMessage Function called on each message of the channel.
175
+ * @param {boolean} quiet If true, the subscription will not send GET and SUB requests to the websocket.
176
+ */
177
+ subscribeTrajectory(mode: RealtimeMode, onMessage: (arg0: trajectory, arg1: RealtimeTrajectory) => any, quiet?: boolean): void;
178
+ /**
179
+ * Unsubscribe to trajectory channels.
180
+ * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
181
+ */
182
+ unsubscribeTrajectory(cb: Function): void;
183
+ /**
184
+ * Subscribe to deleted_vhicles channel.
185
+ *
186
+ * @param {RealtimeMode} mode Realtime mode.
187
+ * @param {function(response: { content: Vehicle })} onMessage Function called on each message of the channel.
188
+ * @param {boolean} quiet If true, the subscription will not send GET and SUB requests to the websocket.
189
+ */
190
+ subscribeDeletedVehicles(mode: RealtimeMode, onMessage: (arg0: response, arg1: {
191
+ content: Vehicle;
192
+ }) => any, quiet?: boolean): void;
193
+ /**
194
+ * Unsubscribe to deleted_vhicles channels.
195
+ * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
196
+ */
197
+ unsubscribeDeletedVehicles(cb: Function): void;
198
+ /**
199
+ * Get a full trajectory of a vehicule .
200
+ *
201
+ * @param {string} id A vehicle id.
202
+ * @param {RealtimeMode} mode Realtime mode.
203
+ * @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
204
+ * @return {Promise<FullTrajectory>} Return a full trajectory.
205
+ */
206
+ getFullTrajectory(id: string, mode: RealtimeMode, generalizationLevel: string): Promise<FullTrajectory>;
207
+ /**
208
+ * Get full trajectories of a vehicules .
209
+ *
210
+ * @param {string[]} ids List of vehicles ids.
211
+ * @param {RealtimeMode} mode Realtime mode.
212
+ * @param {string} generalizationLevel The generalization level to request. Can be one of '', 'gen5', 'gen10', 'gen30', 'gen100'.
213
+ * @return {Promise<Array<FullTrajectory>>} Return an array of full trajectories.
214
+ */
215
+ getFullTrajectories(ids: string[], mode: RealtimeMode, generalizationLevel: string): Promise<Array<FullTrajectory>>;
216
+ /**
217
+ * Subscribe to full_trajectory channel of a given vehicle.
218
+ *
219
+ * @param {string} id A vehicle id.
220
+ * @param {RealtimeMode} mode Realtime mode.
221
+ */
222
+ subscribeFullTrajectory(id: string, mode: RealtimeMode): void;
223
+ /**
224
+ * Unsubscribe from full_trajectory channel
225
+ *
226
+ * @param {string} id A vehicle id.
227
+ * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
228
+ */
229
+ unsubscribeFullTrajectory(id: string, cb: Function): void;
230
+ /**
231
+ * Get the list of stops for this vehicle.
232
+ *
233
+ * @param {string} id A vehicle id.
234
+ * @return {Promise<StopSequence>} Returns a stop sequence object.
235
+ */
236
+ getStopSequence(id: string): Promise<StopSequence>;
237
+ /**
238
+ * Get a list of stops for a list of vehicles.
239
+ *
240
+ * @param {string[]} ids List of vehicles ids.
241
+ * @return {Promise<Array<StopSequence>>} Return an array of stop sequences.
242
+ */
243
+ getStopSequences(ids: string[]): Promise<Array<StopSequence>>;
244
+ /**
245
+ * Subscribe to stopsequence channel of a given vehicle.
246
+ *
247
+ * @param {string} id A vehicle id.
248
+ * @param {function(stopSequence: StopSequence)} onMessage Function called on each message of the channel.
249
+ */
250
+ subscribeStopSequence(id: string, onMessage: (arg0: stopSequence, arg1: StopSequence) => any): void;
251
+ /**
252
+ * Unsubscribe from stopsequence channel
253
+ *
254
+ * @param {string} id A vehicle id.
255
+ * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
256
+ */
257
+ unsubscribeStopSequence(id: string, cb: Function): void;
258
+ /**
259
+ * Subscribe to healthcheck channel.
260
+ * @param {function} onMessage Callback when the subscribe to healthcheck channel succeeds.
261
+ */
262
+ subscribeHealthCheck(onMessage: Function): void;
263
+ /**
264
+ * Unsubscribe to healthcheck channel.
265
+ */
266
+ unsubscribeHealthCheck(): void;
267
+ }
268
+ //# sourceMappingURL=RealtimeAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RealtimeAPI.d.ts","sourceRoot":"","sources":["../../src/api/RealtimeAPI.js"],"names":[],"mappings":";;;4BAYU,YAAY;;;;;;;;;;2BAJT,MAAM;AAYnB;;;;;;;;;;;;;;;GAeG;AACH;IACE;;;;;;;;;OASG;IACH,sBAPW,MAAO,MAAM,EA2BvB;IAjBC,cAAc;IACd,6BAAgC;IAEhC,cAAc;IACd,+BAAkC;IAElC,cAAc;IACd,wBAAyB;IAEzB,cAAc;IACd,eAAoB;IAEpB,cAAc;IACd,YAAkC;IAsHpC;;;OAGG;IACH,eAuBC;IA3ID,qCAoFC;IAED,aASC;IAED;;OAEG;IACH,cAEC;IAED;;OAEG;IAEH,cAEC;IAwBG,cAAc;IACd,2BAEuB;IAI3B;;;OAGG;IACH,gBAWC;IANG,cAAc;IACd,yBAGC;IAIL;;;;;;;;OAQG;IACH,kBAEC;IAED;;;;;;;OAOG;IACH,oBAcC;IAED;;;;;;;OAOG;IACH,yBAsDC;IAED;;;;;;OAMG;IACH,+BAJW,MAAM,qEAEc,SAAS,EAAE,gBA+BzC;IAED;;;OAGG;IACH,0CAKC;IAED;;;;OAIG;IACH,gDAIC;IAED;;;OAGG;IACH,2CAEC;IAED;;;;;;OAMG;IACH,gBAJW,MAAM,QACN,YAAY,GACX,QAAQ,OAAO,CAAC,CAiB3B;IAED;;;;;OAKG;IACH,kBAHW,YAAY,GACX,QAAQ,MAAM,OAAO,CAAC,CAAC,CAsBlC;IATO,cAAc;IACd,6BAEM;IAQd;;;;;;OAMG;IACH,wBAHW,YAAY,mCACM,OAAO,gBASnC;IAED;;;OAGG;IACH,wCAGC;IAED;;;;OAIG;IACH,wDAFgC,iBAAiB,gBAoBhD;IAED;;;OAGG;IACH,0CAEC;IAED;;;;;;OAMG;IACH,0BAJW,YAAY,sCACS,kBAAkB,kBACvC,OAAO,QAUjB;IAED;;;OAGG;IACH,0CAEC;IAED;;;;;;OAMG;IACH,+BAJW,YAAY,oCACO;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,kBACvC,OAAO,QAUjB;IAED;;;OAGG;IACH,+CAEC;IAED;;;;;;;OAOG;IACH,sBALW,MAAM,QACN,YAAY,uBACZ,MAAM,GACL,QAAQ,cAAc,CAAC,CAuBlC;IAED;;;;;;;OAOG;IACH,yBALW,MAAM,EAAE,QACR,YAAY,uBACZ,MAAM,GACL,QAAQ,MAAM,cAAc,CAAC,CAAC,CAOzC;IAED;;;;;OAKG;IACH,4BAHW,MAAM,QACN,YAAY,QAgBtB;IAED;;;;;OAKG;IACH,8BAHW,MAAM,sBAKhB;IAED;;;;;OAKG;IACH,oBAHW,MAAM,GACL,QAAQ,YAAY,CAAC,CAyBhC;IAED;;;;;OAKG;IACH,sBAHW,MAAM,EAAE,GACP,QAAQ,MAAM,YAAY,CAAC,CAAC,CAKvC;IAED;;;;;OAKG;IACH,0BAHW,MAAM,wCACiB,YAAY,gBAuB7C;IAED;;;;;OAKG;IACH,4BAHW,MAAM,sBAKhB;IAED;;;OAGG;IACH,gDAGC;IAED;;OAEG;IACH,+BAEC;CACF"}
@@ -0,0 +1,33 @@
1
+ import HttpAPI, { HttpApiOptions } from '../common/api/HttpAPI';
2
+ import { RoutingParameters, RoutingResponse } from '../../types';
3
+ /**
4
+ * Access to the [geOps Routing service](https://developer.geops.io/apis/routing).
5
+ *
6
+ * @example
7
+ * import { RoutingAPI } from 'mobility-toolbox-js';
8
+ *
9
+ * const api = new RoutingAPI({
10
+ * apiKey: [yourApiKey]
11
+ * });
12
+ *
13
+ */
14
+ declare class RoutingAPI extends HttpAPI {
15
+ /**
16
+ * Constructor
17
+ *
18
+ * @param {RoutingAPIOptions} options Options.
19
+ * @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
20
+ * @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
21
+ */
22
+ constructor(options: HttpApiOptions);
23
+ /**
24
+ * Route.
25
+ *
26
+ * @param {RoutingParameters} params Request parameters. See [Routing service documentation](https://developer.geops.io/apis/routing/).
27
+ * @param {RequestInit} config Options for the fetch request.
28
+ * @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
29
+ */
30
+ route(params: RoutingParameters, config: RequestInit): Promise<RoutingResponse>;
31
+ }
32
+ export default RoutingAPI;
33
+ //# sourceMappingURL=RoutingAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoutingAPI.d.ts","sourceRoot":"","sources":["../../src/api/RoutingAPI.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,cAAM,UAAW,SAAQ,OAAO;IAC9B;;;;;;OAMG;gBACS,OAAO,EAAE,cAAc;IAOnC;;;;;;OAMG;IACH,KAAK,CACH,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,eAAe,CAAC;CAG5B;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,36 @@
1
+ export default StopsAPI;
2
+ /**
3
+ * Access to the [Stops service](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
4
+ *
5
+ * @example
6
+ * import { StopsAPI } from 'mobility-toolbox-js/api';
7
+ *
8
+ * const api = new StopsAPI({
9
+ * url: 'https://api.geops.io/stops/v1/',
10
+ * apiKey: [yourApiKey]
11
+ * });
12
+ *
13
+ */
14
+ declare class StopsAPI extends HttpAPI {
15
+ /**
16
+ * Constructor
17
+ *
18
+ * @param {Object} options Options.
19
+ * @param {string} [options.url='https://api.geops.io/stops/v1/'] Service url.
20
+ * @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
21
+ */
22
+ constructor(options?: {
23
+ url?: string;
24
+ apiKey: string;
25
+ });
26
+ /**
27
+ * Search.
28
+ *
29
+ * @param {StopsSearchParams} params Request parameters. See [Stops service documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
30
+ * @param {AbortController} abortController Abort controller used to cancel the request.
31
+ * @return {Promise<GeoJSONFeatureCollection>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
32
+ */
33
+ search(params: StopsSearchParams, abortController?: AbortController): Promise<GeoJSONFeatureCollection>;
34
+ }
35
+ import HttpAPI from "../common/api/HttpAPI";
36
+ //# sourceMappingURL=StopsAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StopsAPI.d.ts","sourceRoot":"","sources":["../../src/api/StopsAPI.js"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;AACH;IACE;;;;;;OAMG;IACH;QAH4B,GAAG,GAApB,MAAM;QACU,MAAM,EAAtB,MAAM;OAIhB;IAED;;;;;;OAMG;IACH,oDAHW,eAAe,GACd,iCAAiC,CAM5C;CACF"}
package/api/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ declare module '.';
2
+ export { default as RoutingAPI } from './RoutingAPI';
3
+ export { default as StopsAPI } from './StopsAPI';
4
+ export { default as RealtimeAPI, RealtimeModes } from './RealtimeAPI';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,GAAG,CAAC;AAEnB,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,105 @@
1
+ type Departure = {
2
+ /**
3
+ * Timestamp in ms.
4
+ */
5
+ time: number;
6
+ no_stop_between: boolean;
7
+ train_number: number;
8
+ to: string[];
9
+ /**
10
+ * Timestamp in ms.
11
+ */
12
+ ris_aimed_time: number;
13
+ /**
14
+ * Timestamp in ms.
15
+ */
16
+ updated_at: number;
17
+ new_to: boolean;
18
+ /**
19
+ * Timestamp in ms.
20
+ */
21
+ min_arrival_time: number;
22
+ /**
23
+ * List of next stops. Like value in at_station_ds100.
24
+ */
25
+ next_stoppoints: string[];
26
+ /**
27
+ * Timestamp in ms.
28
+ */
29
+ ris_estimated_time: number;
30
+ line: NetworkLine;
31
+ /**
32
+ * if true this departure has realtime data.
33
+ */
34
+ has_fzo: boolean;
35
+ train_id: number;
36
+ platform: string;
37
+ state: any | null;
38
+ /**
39
+ * Timestamp in ms.
40
+ */
41
+ fzo_estimated_time: number;
42
+ formation: any | null;
43
+ no_stop_till: any | null;
44
+ train_type: number;
45
+ call_id: number;
46
+ /**
47
+ * Timestamp in ms.
48
+ */
49
+ created_at: string;
50
+ at_station_ds100: string;
51
+ /**
52
+ * Timestamp in ms.
53
+ */
54
+ timediff: number;
55
+ };
56
+ type Station = GeoJSONFeature;
57
+ type StationProperties = {
58
+ transfers: Transfer[];
59
+ elevatorOutOfOrder: boolean;
60
+ uic: number;
61
+ name: string;
62
+ networkLines: NetworkLine[];
63
+ hasElevator: boolean;
64
+ hasZOB: boolean;
65
+ hasAccessibility: boolean;
66
+ type: string;
67
+ };
68
+ type NetworkLine = {
69
+ /**
70
+ * Identifier of the line.
71
+ */
72
+ id: number;
73
+ /**
74
+ * Color of the line (CSS color string).
75
+ */
76
+ color: string;
77
+ /**
78
+ * Stroke color of the line (CSS color string).
79
+ */
80
+ stroke: string;
81
+ /**
82
+ * Name of the line.
83
+ */
84
+ name: string;
85
+ /**
86
+ * Text color of the line (CSS color string).
87
+ */
88
+ text_color: string;
89
+ };
90
+ type Transfer = {
91
+ /**
92
+ * Mode of transportation (ex: U-Bahn).
93
+ */
94
+ mot: string;
95
+ /**
96
+ * Array of lines name (ex: ["U4", "U5"]).
97
+ */
98
+ lines: string[];
99
+ };
100
+ type StopSequence = GeoJSONFeature;
101
+ type RealtimeTrajectory = GeoJSONFeature;
102
+ type FullTrajectory = GeoJSONFeature;
103
+ type Vehicle = GeoJSONFeature;
104
+ type ExtraGeom = GeoJSONFeature;
105
+ //# sourceMappingURL=typedefs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../../src/api/typedefs.js"],"names":[],"mappings":";;;;UAEc,MAAM;qBACN,OAAO;kBACP,MAAM;QACN,MAAM,EAAE;;;;oBACR,MAAM;;;;gBACN,MAAM;YACN,OAAO;;;;sBACP,MAAM;;;;qBACN,MAAM,EAAE;;;;wBACR,MAAM;UACN,WAAW;;;;aACX,OAAO;cACP,MAAM;cACN,MAAM;;;;;wBAEN,MAAM;;;gBAGN,MAAM;aACN,MAAM;;;;gBACN,MAAM;sBACN,MAAM;;;;cACN,MAAM;;;;eAYN,QAAQ,EAAE;wBACV,OAAO;SACP,MAAM;UACN,MAAM;kBACN,WAAW,EAAE;iBACb,OAAO;YACP,OAAO;sBACP,OAAO;UACP,MAAM;;;;;;QAKN,MAAM;;;;WACN,MAAM;;;;YACN,MAAM;;;;UACN,MAAM;;;;gBACN,MAAM;;;;;;SAKN,MAAM;;;;WACN,MAAM,EAAE"}
@@ -0,0 +1,31 @@
1
+ import BaseObject from 'ol/Object';
2
+ export declare type HttpApiOptions = {
3
+ url?: string;
4
+ apiKey?: string;
5
+ };
6
+ /**
7
+ * Common class to access to a geOps api using http.
8
+ *
9
+ * @example
10
+ * import { API } from 'mobility-toolbox-js/api';
11
+ *
12
+ * const api = new HttpApi({
13
+ * url: [yourUrl],
14
+ * apiKey: [yourApiKey]
15
+ * });
16
+ *
17
+ * @classproperty {string} url Url of the service.
18
+ * @classproperty {string} apiKey Api key to access the service.
19
+ */
20
+ declare class HttpAPI extends BaseObject {
21
+ url?: string;
22
+ apiKey?: string;
23
+ constructor(options: HttpApiOptions);
24
+ /**
25
+ * Append the apiKey before sending the request.
26
+ * @ignore
27
+ */
28
+ fetch(path: string, params: Object, config: RequestInit): Promise<any>;
29
+ }
30
+ export default HttpAPI;
31
+ //# sourceMappingURL=HttpAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpAPI.d.ts","sourceRoot":"","sources":["../../../src/common/api/HttpAPI.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,WAAW,CAAC;AAGnC,oBAAY,cAAc,GAAG;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF;;;;;;;;;;;;;GAaG;AACH,cAAM,OAAQ,SAAQ,UAAU;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEJ,OAAO,EAAE,cAAc;IASnC;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;CA6BvE;AAED,eAAe,OAAO,CAAC"}
@@ -0,0 +1,95 @@
1
+ export default WebSocketAPI;
2
+ /**
3
+ * Class used to facilitate connection to a WebSocket and
4
+ * also to manage properly messages send to the WebSocket.
5
+ * This class must not contain any specific implementation.
6
+ */
7
+ declare class WebSocketAPI {
8
+ /**
9
+ * Get the websocket request string.
10
+ *
11
+ * @param {string} method Request mehtod {GET, SUB}.
12
+ * @param {Object} params Request parameters.
13
+ * @param {string} params.channel Channel name
14
+ * @param {string} [params.args] Request arguments
15
+ * @param {Number} [params.id] Request identifier
16
+ * @return {string} request string
17
+ * @private
18
+ */
19
+ private static getRequestString;
20
+ defineProperties(): void;
21
+ /**
22
+ * (Re)connect the websocket.
23
+ *
24
+ * @param {strin} url Websocket url.
25
+ * @param {function} onOpen Callback called when the websocket connection is opened and before subscriptions of previous subscriptions.
26
+ * @private
27
+ */
28
+ private connect;
29
+ /** @ignore */
30
+ websocket: WebSocket;
31
+ /**
32
+ * Close the websocket definitively.
33
+ *
34
+ * @private
35
+ */
36
+ private close;
37
+ messagesOnOpen: any[];
38
+ /**
39
+ * Sends a message to the websocket.
40
+ *
41
+ * @param {message} message Message to send.
42
+ * @private
43
+ */
44
+ private send;
45
+ /**
46
+ * Listen to websocket messages.
47
+ *
48
+ * @param {Object} params Parameters for the websocket get request
49
+ * @param {function} cb callback on listen
50
+ * @param {function} errorCb Callback on error
51
+ * @return {{onMessage: function, errorCb: function}} Object with onMessage and error callbacks
52
+ * @private
53
+ */
54
+ private listen;
55
+ /**
56
+ * Unlisten websocket messages.
57
+ *
58
+ * @param {Object} params Parameters for the websocket get request.
59
+ * @param {function} cb Callback used when listen.
60
+ * @private
61
+ */
62
+ private unlisten;
63
+ /**
64
+ * Sends a get request to the websocket.
65
+ *
66
+ * @param {Object} params Parameters for the websocket get request
67
+ * @param {function} cb callback on listen
68
+ * @param {function} errorCb Callback on error
69
+ * @private
70
+ */
71
+ private get;
72
+ /**
73
+ * Subscribe to a given channel.
74
+ *
75
+ * @param {Object} params Parameters for the websocket get request
76
+ * @param {function} cb callback on listen
77
+ * @param {function} errorCb Callback on error
78
+ * @param {boolean} quiet if false, no GET or SUB requests are send, only the callback is registered.
79
+ * @private
80
+ */
81
+ private subscribe;
82
+ /**
83
+ * Unsubscribe from a channel.
84
+ * @param {string} source source to unsubscribe from
85
+ * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
86
+ * @private
87
+ */
88
+ private unsubscribe;
89
+ subscriptions: any;
90
+ /**
91
+ * After an auto reconnection we need to re-subscribe to the channels.
92
+ */
93
+ subscribePreviousSubscriptions(): void;
94
+ }
95
+ //# sourceMappingURL=WebSocketAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketAPI.d.ts","sourceRoot":"","sources":["../../../src/common/api/WebSocketAPI.js"],"names":[],"mappings":";AAAA;;;;GAIG;AACH;IAiEE;;;;;;;;;;OAUG;IACH,gCAKC;IA5ED,yBA0DC;IAoBD;;;;;;OAMG;IACH,gBAiBC;IAZC,cAAc;IACd,qBAAmC;IAarC;;;;OAIG;IACH,cAOC;IAFG,sBAAwB;IAI5B;;;;;OAKG;IACH,aAsBC;IAED;;;;;;;;OAQG;IACH,eAsCC;IAED;;;;;;OAMG;IACH,iBAiBC;IAED;;;;;;;OAOG;IACH,YAIC;IAED;;;;;;;;OAQG;IACH,kBAqBC;IAED;;;;;OAKG;IACH,oBA8BC;IAfC,mBAEC;IAeH;;OAEG;IACH,uCAYC;CACF"}