mobility-toolbox-js 2.0.0-beta.6 → 2.0.0-beta.60

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 (487) hide show
  1. package/README.md +29 -8
  2. package/api/RealtimeAPI.d.ts +279 -0
  3. package/api/RealtimeAPI.d.ts.map +1 -0
  4. package/api/RealtimeAPI.js +462 -0
  5. package/api/RoutingAPI.d.ts +37 -0
  6. package/api/RoutingAPI.d.ts.map +1 -0
  7. package/api/RoutingAPI.js +35 -0
  8. package/api/StopsAPI.d.ts +38 -0
  9. package/api/StopsAPI.d.ts.map +1 -0
  10. package/api/StopsAPI.js +36 -0
  11. package/api/index.d.ts +4 -0
  12. package/api/index.d.ts.map +1 -0
  13. package/api/index.js +3 -0
  14. package/api/typedefs.d.ts +179 -0
  15. package/api/typedefs.d.ts.map +1 -0
  16. package/{src/api/tralis → api}/typedefs.js +4 -10
  17. package/common/api/HttpAPI.d.ts +31 -0
  18. package/common/api/HttpAPI.d.ts.map +1 -0
  19. package/common/api/HttpAPI.js +57 -0
  20. package/common/api/WebSocketAPI.d.ts +153 -0
  21. package/common/api/WebSocketAPI.d.ts.map +1 -0
  22. package/common/api/WebSocketAPI.js +328 -0
  23. package/common/controls/ControlCommon.d.ts +76 -0
  24. package/common/controls/ControlCommon.d.ts.map +1 -0
  25. package/common/controls/ControlCommon.js +150 -0
  26. package/common/controls/CopyrightControlCommon.d.ts +13 -0
  27. package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
  28. package/common/controls/CopyrightControlCommon.js +34 -0
  29. package/common/controls/StopFinderControlCommon.d.ts +55 -0
  30. package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
  31. package/common/controls/StopFinderControlCommon.js +144 -0
  32. package/common/index.d.ts +3 -0
  33. package/common/index.d.ts.map +1 -0
  34. package/common/index.js +2 -0
  35. package/common/layers/LayerCommon.d.ts +94 -0
  36. package/common/layers/LayerCommon.d.ts.map +1 -0
  37. package/common/layers/LayerCommon.js +244 -0
  38. package/common/mixins/RealtimeLayerMixin.d.ts +289 -0
  39. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
  40. package/common/mixins/RealtimeLayerMixin.js +746 -0
  41. package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
  42. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
  43. package/common/mixins/UserInteractionsLayerMixin.js +241 -0
  44. package/common/styles/index.d.ts +5 -0
  45. package/common/styles/index.d.ts.map +1 -0
  46. package/common/styles/index.js +4 -0
  47. package/common/styles/realtimeDefaultStyle.d.ts +36 -0
  48. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
  49. package/common/styles/realtimeDefaultStyle.js +261 -0
  50. package/{src/common/styles/trackerDelayStyle.js → common/styles/realtimeDelayStyle.d.ts} +4 -9
  51. package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
  52. package/common/styles/realtimeDelayStyle.js +13 -0
  53. package/common/styles/realtimeSimpleStyle.d.ts +4 -0
  54. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
  55. package/common/styles/realtimeSimpleStyle.js +24 -0
  56. package/common/typedefs.d.ts +111 -0
  57. package/common/typedefs.d.ts.map +1 -0
  58. package/common/typedefs.js +52 -0
  59. package/common/utils/compareDepartures.d.ts +11 -0
  60. package/common/utils/compareDepartures.d.ts.map +1 -0
  61. package/common/utils/compareDepartures.js +35 -0
  62. package/common/utils/createCanvas.d.ts +10 -0
  63. package/common/utils/createCanvas.d.ts.map +1 -0
  64. package/common/utils/createCanvas.js +27 -0
  65. package/common/utils/createRealtimeFilters.d.ts +13 -0
  66. package/common/utils/createRealtimeFilters.d.ts.map +1 -0
  67. package/common/utils/createRealtimeFilters.js +74 -0
  68. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  69. package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
  70. package/common/utils/debounceDeparturesMessages.js +24 -0
  71. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  72. package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
  73. package/common/utils/debounceWebsocketMessages.js +29 -0
  74. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  75. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
  76. package/common/utils/getLayersAsFlatArray.js +15 -0
  77. package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
  78. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
  79. package/common/utils/getMapboxMapCopyrights.js +30 -0
  80. package/common/utils/getMapboxRender.d.ts +7 -0
  81. package/common/utils/getMapboxRender.d.ts.map +1 -0
  82. package/common/utils/getMapboxRender.js +87 -0
  83. package/common/utils/getMaplibreRender.d.ts +7 -0
  84. package/common/utils/getMaplibreRender.d.ts.map +1 -0
  85. package/common/utils/getMaplibreRender.js +38 -0
  86. package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
  87. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
  88. package/common/utils/getRealtimeModeSuffix.js +7 -0
  89. package/common/utils/getUrlWithParams.d.ts +9 -0
  90. package/common/utils/getUrlWithParams.d.ts.map +1 -0
  91. package/common/utils/getUrlWithParams.js +18 -0
  92. package/common/utils/getVehiclePosition.d.ts +16 -0
  93. package/common/utils/getVehiclePosition.d.ts.map +1 -0
  94. package/common/utils/getVehiclePosition.js +63 -0
  95. package/common/utils/index.d.ts +16 -0
  96. package/common/utils/index.d.ts.map +1 -0
  97. package/common/utils/index.js +16 -0
  98. package/common/utils/realtimeConfig.d.ts +49 -0
  99. package/common/utils/realtimeConfig.d.ts.map +1 -0
  100. package/common/utils/realtimeConfig.js +173 -0
  101. package/common/utils/removeDuplicate.d.ts +10 -0
  102. package/common/utils/removeDuplicate.d.ts.map +1 -0
  103. package/common/utils/removeDuplicate.js +15 -0
  104. package/common/utils/renderTrajectories.d.ts +17 -0
  105. package/common/utils/renderTrajectories.d.ts.map +1 -0
  106. package/common/utils/renderTrajectories.js +121 -0
  107. package/common/utils/sortAndFilterDepartures.d.ts +16 -0
  108. package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
  109. package/common/utils/sortAndFilterDepartures.js +58 -0
  110. package/common/utils/sortByDelay.d.ts +3 -0
  111. package/common/utils/sortByDelay.d.ts.map +1 -0
  112. package/common/utils/sortByDelay.js +20 -0
  113. package/common/utils/timeUtils.d.ts +24 -0
  114. package/common/utils/timeUtils.d.ts.map +1 -0
  115. package/{src/common → common}/utils/timeUtils.js +13 -18
  116. package/iife.d.ts +3 -0
  117. package/iife.d.ts.map +1 -0
  118. package/{src/iife.js → iife.js} +2 -4
  119. package/index.d.ts +10 -0
  120. package/index.d.ts.map +1 -0
  121. package/index.js +10 -0
  122. package/mapbox/controls/CopyrightControl.d.ts +29 -0
  123. package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
  124. package/mapbox/controls/CopyrightControl.js +48 -0
  125. package/mapbox/controls/index.d.ts +2 -0
  126. package/mapbox/controls/index.d.ts.map +1 -0
  127. package/mapbox/controls/index.js +2 -0
  128. package/mapbox/index.d.ts +6 -0
  129. package/mapbox/index.d.ts.map +1 -0
  130. package/mapbox/index.js +5 -0
  131. package/mapbox/layers/Layer.d.ts +59 -0
  132. package/mapbox/layers/Layer.d.ts.map +1 -0
  133. package/mapbox/layers/Layer.js +101 -0
  134. package/mapbox/layers/RealtimeLayer.d.ts +180 -0
  135. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
  136. package/mapbox/layers/RealtimeLayer.js +276 -0
  137. package/mapbox/layers/index.d.ts +3 -0
  138. package/mapbox/layers/index.d.ts.map +1 -0
  139. package/mapbox/layers/index.js +2 -0
  140. package/mapbox/utils/getMercatorResolution.d.ts +9 -0
  141. package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
  142. package/mapbox/utils/getMercatorResolution.js +18 -0
  143. package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
  144. package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
  145. package/mapbox/utils/getSourceCoordinates.js +27 -0
  146. package/mapbox/utils/index.d.ts +3 -0
  147. package/mapbox/utils/index.d.ts.map +1 -0
  148. package/mapbox/utils/index.js +2 -0
  149. package/mbt.js +50785 -0
  150. package/mbt.js.map +7 -0
  151. package/mbt.min.js +1083 -0
  152. package/mbt.min.js.map +7 -0
  153. package/ol/controls/CopyrightControl.d.ts +31 -0
  154. package/ol/controls/CopyrightControl.d.ts.map +1 -0
  155. package/ol/controls/CopyrightControl.js +68 -0
  156. package/ol/controls/RoutingControl.d.ts +193 -0
  157. package/ol/controls/RoutingControl.d.ts.map +1 -0
  158. package/ol/controls/RoutingControl.js +632 -0
  159. package/ol/controls/StopFinderControl.d.ts +30 -0
  160. package/ol/controls/StopFinderControl.d.ts.map +1 -0
  161. package/{src/ol → ol}/controls/StopFinderControl.js +10 -16
  162. package/ol/controls/index.d.ts +4 -0
  163. package/ol/controls/index.d.ts.map +1 -0
  164. package/ol/controls/index.js +3 -0
  165. package/ol/index.d.ts +6 -0
  166. package/ol/index.d.ts.map +1 -0
  167. package/ol/index.js +5 -0
  168. package/ol/layers/Layer.d.ts +86 -0
  169. package/ol/layers/Layer.d.ts.map +1 -0
  170. package/ol/layers/Layer.js +159 -0
  171. package/ol/layers/MapGlLayer.d.ts +67 -0
  172. package/ol/layers/MapGlLayer.d.ts.map +1 -0
  173. package/ol/layers/MapGlLayer.js +218 -0
  174. package/ol/layers/MapboxLayer.d.ts +50 -0
  175. package/ol/layers/MapboxLayer.d.ts.map +1 -0
  176. package/ol/layers/MapboxLayer.js +109 -0
  177. package/ol/layers/MapboxStyleLayer.d.ts +129 -0
  178. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
  179. package/ol/layers/MapboxStyleLayer.js +374 -0
  180. package/ol/layers/MaplibreLayer.d.ts +28 -0
  181. package/ol/layers/MaplibreLayer.d.ts.map +1 -0
  182. package/ol/layers/MaplibreLayer.js +34 -0
  183. package/ol/layers/RealtimeLayer.d.ts +201 -0
  184. package/ol/layers/RealtimeLayer.d.ts.map +1 -0
  185. package/ol/layers/RealtimeLayer.js +310 -0
  186. package/ol/layers/RoutingLayer.d.ts +34 -0
  187. package/ol/layers/RoutingLayer.d.ts.map +1 -0
  188. package/ol/layers/RoutingLayer.js +85 -0
  189. package/ol/layers/VectorLayer.d.ts +25 -0
  190. package/ol/layers/VectorLayer.d.ts.map +1 -0
  191. package/ol/layers/VectorLayer.js +38 -0
  192. package/ol/layers/WMSLayer.d.ts +42 -0
  193. package/ol/layers/WMSLayer.d.ts.map +1 -0
  194. package/ol/layers/WMSLayer.js +88 -0
  195. package/ol/layers/index.d.ts +9 -0
  196. package/ol/layers/index.d.ts.map +1 -0
  197. package/ol/layers/index.js +8 -0
  198. package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
  199. package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
  200. package/ol/styles/fullTrajectoryDelayStyle.js +33 -0
  201. package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
  202. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
  203. package/ol/styles/fullTrajectoryStyle.js +44 -0
  204. package/ol/styles/index.d.ts +3 -0
  205. package/ol/styles/index.d.ts.map +1 -0
  206. package/{src/ol → ol}/styles/index.js +0 -0
  207. package/package.json +71 -126
  208. package/setupTests.d.ts +2 -0
  209. package/setupTests.d.ts.map +1 -0
  210. package/{src/setupTests.js → setupTests.js} +0 -2
  211. package/types/common.d.ts +118 -0
  212. package/types/index.d.ts +11 -0
  213. package/types/realtime.d.ts +315 -0
  214. package/types/routing.d.ts +206 -0
  215. package/types/stops.d.ts +143 -0
  216. package/.babelrc +0 -6
  217. package/.esdoc.json +0 -17
  218. package/.eslintignore +0 -1
  219. package/.github/workflows/conventional-pr-title.yml +0 -21
  220. package/.github/workflows/cypress.yml +0 -29
  221. package/.github/workflows/nodejs.yml +0 -28
  222. package/.husky/commit-msg +0 -4
  223. package/.husky/post-checkout +0 -4
  224. package/.husky/post-merge +0 -4
  225. package/.husky/post-rebase +0 -4
  226. package/.husky/pre-commit +0 -4
  227. package/.neutrinorc.js +0 -176
  228. package/.nvmrc +0 -1
  229. package/CHANGELOG.md +0 -10
  230. package/LICENSE +0 -21
  231. package/Layer.js +0 -2
  232. package/Layer.js.map +0 -7
  233. package/__mocks__/mapbox-gl.js +0 -81
  234. package/__mocks__/maplibre-gl.js +0 -81
  235. package/commitlint.config.js +0 -1
  236. package/cypress/fixtures/example.json +0 -5
  237. package/cypress/integration/examples/api.spec.js +0 -7
  238. package/cypress/integration/examples/examples.spec.js +0 -7
  239. package/cypress/integration/examples/navigation.spec.js +0 -29
  240. package/cypress/plugins/index.js +0 -21
  241. package/cypress/support/commands.js +0 -25
  242. package/cypress/support/index.js +0 -20
  243. package/cypress.json +0 -4
  244. package/data/fetchRoute.json +0 -292
  245. package/data/fetchTrajectories.json +0 -18
  246. package/data/fetchTrajectoryById.json +0 -3
  247. package/data/fetchTrajectoryStations.json +0 -18
  248. package/data/stopsSearch.json +0 -15
  249. package/documentation.yml +0 -4
  250. package/esdoc/README.md +0 -27
  251. package/esdoc/plugins/MyPlugin.js +0 -69
  252. package/esdoc/plugins/dynamic-property-plugin/Plugin.js +0 -50
  253. package/esdoc/plugins/externals-plugin/Plugin.js +0 -45
  254. package/esdoc/plugins/externals-plugin/externals.js +0 -96
  255. package/global-setup.js +0 -3
  256. package/index.html +0 -0
  257. package/indexweb.html +0 -49
  258. package/jest.config.js +0 -5
  259. package/pull_request_template.md +0 -17
  260. package/renovate.json +0 -4
  261. package/scripts/read-pkg-json.js +0 -22
  262. package/src/api/index.js +0 -3
  263. package/src/api/routing/RoutingAPI.js +0 -44
  264. package/src/api/routing/RoutingAPI.test.js +0 -41
  265. package/src/api/stops/StopsAPI.js +0 -41
  266. package/src/api/stops/StopsAPI.test.js +0 -34
  267. package/src/api/tralis/TralisAPI.js +0 -731
  268. package/src/api/tralis/TralisAPI.test.js +0 -75
  269. package/src/api/tralis/TralisAPIUtils.js +0 -73
  270. package/src/api/tralis/WebSocketConnector.js +0 -338
  271. package/src/api/tralis/WebSocketConnector.test.js +0 -356
  272. package/src/assets/Lato-Black.ttf +0 -0
  273. package/src/assets/Lato-BlackItalic.ttf +0 -0
  274. package/src/assets/Lato-Bold.ttf +0 -0
  275. package/src/assets/Lato-BoldItalic.ttf +0 -0
  276. package/src/assets/Lato-Italic.ttf +0 -0
  277. package/src/assets/Lato-Light.ttf +0 -0
  278. package/src/assets/Lato-LightItalic.ttf +0 -0
  279. package/src/assets/Lato-Regular.ttf +0 -0
  280. package/src/assets/Lato-Thin.ttf +0 -0
  281. package/src/assets/Lato-ThinItalic.ttf +0 -0
  282. package/src/assets/OFL.txt +0 -93
  283. package/src/common/Tracker.js +0 -197
  284. package/src/common/api/api.js +0 -64
  285. package/src/common/api/api.test.js +0 -68
  286. package/src/common/controls/Control.js +0 -146
  287. package/src/common/controls/Control.test.js +0 -98
  288. package/src/common/layers/Layer.js +0 -404
  289. package/src/common/layers/Layer.test.js +0 -585
  290. package/src/common/mixins/CopyrightMixin.js +0 -48
  291. package/src/common/mixins/SearchMixin.js +0 -176
  292. package/src/common/mixins/TralisLayerMixin.js +0 -930
  293. package/src/common/styles/index.js +0 -4
  294. package/src/common/styles/trackerDefaultStyle.js +0 -333
  295. package/src/common/styles/trackerSimpleStyle.js +0 -22
  296. package/src/common/trackerConfig.js +0 -190
  297. package/src/common/trackerConfig.test.js +0 -25
  298. package/src/common/typedefs.js +0 -23
  299. package/src/common/utils/createTrackerFilters.js +0 -87
  300. package/src/common/utils/createTrackerFilters.test.js +0 -95
  301. package/src/common/utils/getMapboxMapCopyrights.js +0 -32
  302. package/src/common/utils/getMapboxMapCopyrights.test.js +0 -47
  303. package/src/common/utils/getMapboxStyleUrl.js +0 -32
  304. package/src/common/utils/getVehiclePosition.js +0 -72
  305. package/src/common/utils/index.js +0 -6
  306. package/src/common/utils/removeDuplicate.js +0 -22
  307. package/src/common/utils/removeDuplicate.test.js +0 -22
  308. package/src/common/utils/sortByDelay.js +0 -23
  309. package/src/common/utils/timeUtils.test.js +0 -16
  310. package/src/doc/App.js +0 -116
  311. package/src/doc/App.scss +0 -51
  312. package/src/doc/_redirects +0 -2
  313. package/src/doc/components/CodeSandboxButton.js +0 -103
  314. package/src/doc/components/Documentation.js +0 -40
  315. package/src/doc/components/Esdoc/Anchor.js +0 -57
  316. package/src/doc/components/Esdoc/ClassDoc.js +0 -272
  317. package/src/doc/components/Esdoc/DeprecatedHTML.js +0 -16
  318. package/src/doc/components/Esdoc/DetailDocs.js +0 -281
  319. package/src/doc/components/Esdoc/DetailHTML.js +0 -33
  320. package/src/doc/components/Esdoc/DirectSubclassHTML.js +0 -30
  321. package/src/doc/components/Esdoc/DocBuilderUtils.js +0 -694
  322. package/src/doc/components/Esdoc/DocLinkHTML.js +0 -62
  323. package/src/doc/components/Esdoc/DocsLinkHTML.js +0 -38
  324. package/src/doc/components/Esdoc/Esdoc.js +0 -63
  325. package/src/doc/components/Esdoc/EsdocContent.js +0 -51
  326. package/src/doc/components/Esdoc/EsdocNavigation.js +0 -13
  327. package/src/doc/components/Esdoc/EsdocSearch.js +0 -81
  328. package/src/doc/components/Esdoc/ExperimentalHTML.js +0 -17
  329. package/src/doc/components/Esdoc/ExtendsChainHTML.js +0 -32
  330. package/src/doc/components/Esdoc/FileDocLinkHTML.js +0 -60
  331. package/src/doc/components/Esdoc/IdentifiersDoc.js +0 -113
  332. package/src/doc/components/Esdoc/IndirectSubclassHTML.js +0 -30
  333. package/src/doc/components/Esdoc/InheritedSummaryDoc.js +0 -70
  334. package/src/doc/components/Esdoc/InheritedSummaryHTML.js +0 -38
  335. package/src/doc/components/Esdoc/MixinClassesHTML.js +0 -29
  336. package/src/doc/components/Esdoc/NavDoc.js +0 -112
  337. package/src/doc/components/Esdoc/OverrideMethod.js +0 -44
  338. package/src/doc/components/Esdoc/OverrideMethodDescription.js +0 -35
  339. package/src/doc/components/Esdoc/Properties.js +0 -89
  340. package/src/doc/components/Esdoc/README.md +0 -45
  341. package/src/doc/components/Esdoc/SignatureHTML.js +0 -123
  342. package/src/doc/components/Esdoc/SingleDoc.js +0 -31
  343. package/src/doc/components/Esdoc/SummaryDoc.js +0 -160
  344. package/src/doc/components/Esdoc/SummaryHTML.js +0 -96
  345. package/src/doc/components/Esdoc/TypeDocLinkHTML.js +0 -249
  346. package/src/doc/components/Esdoc/css/identifiers.css +0 -38
  347. package/src/doc/components/Esdoc/css/search.css +0 -76
  348. package/src/doc/components/Esdoc/css/style.css +0 -603
  349. package/src/doc/components/Esdoc/index.js +0 -7
  350. package/src/doc/components/Example.js +0 -153
  351. package/src/doc/components/Examples.js +0 -183
  352. package/src/doc/components/Home.js +0 -106
  353. package/src/doc/components/TrackerExample.js +0 -38
  354. package/src/doc/components/esm.min.js +0 -2
  355. package/src/doc/components/examples/assets/tralis-live-map/index.js +0 -11
  356. package/src/doc/components/examples/assets/tralis-live-map/s1kreis.svg +0 -105
  357. package/src/doc/components/examples/assets/tralis-live-map/s20kreis.svg +0 -101
  358. package/src/doc/components/examples/assets/tralis-live-map/s2kreis.svg +0 -95
  359. package/src/doc/components/examples/assets/tralis-live-map/s3kreis.svg +0 -95
  360. package/src/doc/components/examples/assets/tralis-live-map/s4kreis.svg +0 -95
  361. package/src/doc/components/examples/assets/tralis-live-map/s6kreis.svg +0 -95
  362. package/src/doc/components/examples/assets/tralis-live-map/s7kreis.svg +0 -95
  363. package/src/doc/components/examples/assets/tralis-live-map/s8kreis.svg +0 -93
  364. package/src/doc/components/examples/assets/tralis-live-map/unknown.svg +0 -107
  365. package/src/doc/components/examples/mb-copyright.html +0 -26
  366. package/src/doc/components/examples/mb-copyright.js +0 -37
  367. package/src/doc/components/examples/mb-tracker.html +0 -1
  368. package/src/doc/components/examples/mb-tracker.js +0 -39
  369. package/src/doc/components/examples/mb-tracker.md +0 -1
  370. package/src/doc/components/examples/mb-tralis.html +0 -1
  371. package/src/doc/components/examples/mb-tralis.js +0 -34
  372. package/src/doc/components/examples/ol-copyright.html +0 -26
  373. package/src/doc/components/examples/ol-copyright.js +0 -43
  374. package/src/doc/components/examples/ol-mapbox-layer.html +0 -1
  375. package/src/doc/components/examples/ol-mapbox-layer.js +0 -28
  376. package/src/doc/components/examples/ol-mapbox-layer.md +0 -0
  377. package/src/doc/components/examples/ol-mapbox-style-layer.html +0 -12
  378. package/src/doc/components/examples/ol-mapbox-style-layer.js +0 -44
  379. package/src/doc/components/examples/ol-query.html +0 -32
  380. package/src/doc/components/examples/ol-query.js +0 -83
  381. package/src/doc/components/examples/ol-routing.html +0 -26
  382. package/src/doc/components/examples/ol-routing.js +0 -59
  383. package/src/doc/components/examples/ol-routing.md +0 -1
  384. package/src/doc/components/examples/ol-stop-finder.html +0 -15
  385. package/src/doc/components/examples/ol-stop-finder.js +0 -31
  386. package/src/doc/components/examples/ol-stop-finder.md +0 -1
  387. package/src/doc/components/examples/ol-tracker.html +0 -1
  388. package/src/doc/components/examples/ol-tracker.js +0 -44
  389. package/src/doc/components/examples/ol-tracker.md +0 -1
  390. package/src/doc/components/examples/ol-tralis.html +0 -5
  391. package/src/doc/components/examples/ol-tralis.js +0 -57
  392. package/src/doc/components/examples/tralis-live-map.html +0 -1
  393. package/src/doc/components/examples/tralis-live-map.js +0 -51
  394. package/src/doc/components/examples/tralis-live-map.md +0 -3
  395. package/src/doc/examples/assets/tralis-live-map/index.js +0 -11
  396. package/src/doc/examples/assets/tralis-live-map/s1kreis.svg +0 -105
  397. package/src/doc/examples/assets/tralis-live-map/s20kreis.svg +0 -101
  398. package/src/doc/examples/assets/tralis-live-map/s2kreis.svg +0 -95
  399. package/src/doc/examples/assets/tralis-live-map/s3kreis.svg +0 -95
  400. package/src/doc/examples/assets/tralis-live-map/s4kreis.svg +0 -95
  401. package/src/doc/examples/assets/tralis-live-map/s6kreis.svg +0 -95
  402. package/src/doc/examples/assets/tralis-live-map/s7kreis.svg +0 -95
  403. package/src/doc/examples/assets/tralis-live-map/s8kreis.svg +0 -93
  404. package/src/doc/examples/assets/tralis-live-map/unknown.svg +0 -107
  405. package/src/doc/examples/mb-copyright.html +0 -26
  406. package/src/doc/examples/mb-copyright.js +0 -37
  407. package/src/doc/examples/mb-tracker.html +0 -1
  408. package/src/doc/examples/mb-tracker.js +0 -39
  409. package/src/doc/examples/mb-tracker.md +0 -1
  410. package/src/doc/examples/mb-tralis.html +0 -1
  411. package/src/doc/examples/mb-tralis.js +0 -34
  412. package/src/doc/examples/ol-copyright.html +0 -26
  413. package/src/doc/examples/ol-copyright.js +0 -43
  414. package/src/doc/examples/ol-mapbox-layer.html +0 -1
  415. package/src/doc/examples/ol-mapbox-layer.js +0 -28
  416. package/src/doc/examples/ol-mapbox-layer.md +0 -0
  417. package/src/doc/examples/ol-mapbox-style-layer.html +0 -12
  418. package/src/doc/examples/ol-mapbox-style-layer.js +0 -44
  419. package/src/doc/examples/ol-query.html +0 -32
  420. package/src/doc/examples/ol-query.js +0 -83
  421. package/src/doc/examples/ol-routing.html +0 -26
  422. package/src/doc/examples/ol-routing.js +0 -59
  423. package/src/doc/examples/ol-routing.md +0 -1
  424. package/src/doc/examples/ol-stop-finder.html +0 -15
  425. package/src/doc/examples/ol-stop-finder.js +0 -31
  426. package/src/doc/examples/ol-stop-finder.md +0 -1
  427. package/src/doc/examples/ol-tracker.html +0 -1
  428. package/src/doc/examples/ol-tracker.js +0 -44
  429. package/src/doc/examples/ol-tracker.md +0 -1
  430. package/src/doc/examples/ol-tralis.html +0 -5
  431. package/src/doc/examples/ol-tralis.js +0 -57
  432. package/src/doc/examples/tralis-live-map.html +0 -1
  433. package/src/doc/examples/tralis-live-map.js +0 -51
  434. package/src/doc/examples/tralis-live-map.md +0 -3
  435. package/src/doc/examples.js +0 -107
  436. package/src/doc/img/examples/live_tracker_mb.jpg +0 -0
  437. package/src/doc/img/examples/live_tracker_munich.jpg +0 -0
  438. package/src/doc/img/examples/live_tracker_ol.jpg +0 -0
  439. package/src/doc/img/examples/mapbox.jpg +0 -0
  440. package/src/doc/img/examples/mapbox_style.jpg +0 -0
  441. package/src/doc/img/examples/ol-copyright.png +0 -0
  442. package/src/doc/img/examples/query_objects.jpg +0 -0
  443. package/src/doc/img/examples/routing.jpg +0 -0
  444. package/src/doc/img/examples/simple_map.jpg +0 -0
  445. package/src/doc/img/examples/stops.jpg +0 -0
  446. package/src/doc/img/favico.ico +0 -0
  447. package/src/doc/index.js +0 -21
  448. package/src/index.js +0 -25
  449. package/src/mapbox/controls/CopyrightControl.js +0 -58
  450. package/src/mapbox/index.js +0 -3
  451. package/src/mapbox/layers/Layer.js +0 -118
  452. package/src/mapbox/layers/Layer.test.js +0 -202
  453. package/src/mapbox/layers/TralisLayer.js +0 -329
  454. package/src/mapbox/layers/TralisLayer.test.js +0 -40
  455. package/src/mapbox/utils.js +0 -46
  456. package/src/ol/README.md +0 -0
  457. package/src/ol/controls/CopyrightControl.js +0 -80
  458. package/src/ol/controls/CopyrightControl.test.js +0 -211
  459. package/src/ol/controls/RoutingControl.js +0 -752
  460. package/src/ol/controls/RoutingControl.test.js +0 -216
  461. package/src/ol/controls/StopFinderControl.test.js +0 -59
  462. package/src/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
  463. package/src/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
  464. package/src/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
  465. package/src/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
  466. package/src/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
  467. package/src/ol/controls/snapshots/RoutingControlStation1.json +0 -60
  468. package/src/ol/controls/snapshots/RoutingControlStation2.json +0 -49
  469. package/src/ol/index.js +0 -13
  470. package/src/ol/layers/Layer.js +0 -193
  471. package/src/ol/layers/Layer.test.js +0 -197
  472. package/src/ol/layers/MapboxLayer.js +0 -378
  473. package/src/ol/layers/MapboxLayer.test.js +0 -186
  474. package/src/ol/layers/MapboxStyleLayer.js +0 -417
  475. package/src/ol/layers/MapboxStyleLayer.test.js +0 -262
  476. package/src/ol/layers/MaplibreLayer.js +0 -280
  477. package/src/ol/layers/RoutingLayer.js +0 -91
  478. package/src/ol/layers/RoutingLayer.test.js +0 -49
  479. package/src/ol/layers/TralisLayer.js +0 -359
  480. package/src/ol/layers/TralisLayer.test.js +0 -97
  481. package/src/ol/layers/VectorLayer.js +0 -43
  482. package/src/ol/layers/VectorLayer.test.js +0 -98
  483. package/src/ol/layers/WMSLayer.js +0 -80
  484. package/src/ol/layers/WMSLayer.test.js +0 -84
  485. package/src/ol/styles/fullTrajectoryDelayStyle.js +0 -35
  486. package/src/ol/styles/fullTrajectoryStyle.js +0 -51
  487. package/webpack.config.js +0 -6
@@ -0,0 +1,462 @@
1
+ import WebSocketAPI from '../common/api/WebSocketAPI';
2
+ import debounceWebsocketMessages from '../common/utils/debounceWebsocketMessages';
3
+ import getModeSuffix from '../common/utils/getRealtimeModeSuffix';
4
+ /**
5
+ * Enum for Realtime modes.
6
+ * @readonly
7
+ * @typedef {string} RealtimeMode
8
+ * @property {string} RAW "raw"
9
+ * @property {string} SCHEMATIC "schematic"
10
+ * @property {string} TOPOGRAPHIC "topographic"
11
+ * @enum {RealtimeMode}
12
+ */
13
+ export const RealtimeModes = {
14
+ RAW: 'raw',
15
+ TOPOGRAPHIC: 'topographic',
16
+ SCHEMATIC: 'schematic',
17
+ };
18
+ /**
19
+ * This class provides convenience methods to access to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
20
+ *
21
+ * @example
22
+ * import { RealtimeAPI } from 'mobility-toolbox-js/api';
23
+ *
24
+ * const api = new RealtimeAPI({
25
+ * url: "yourUrl",
26
+ * apiKey: "yourApiKey"
27
+ * });
28
+ *
29
+ * @example
30
+ * import { RealtimeAPI } from 'mobility-toolbox-js/api';
31
+ *
32
+ * const api = new RealtimeAPI("yourUrl");
33
+ */
34
+ class RealtimeAPI {
35
+ /**
36
+ * Constructor
37
+ *
38
+ * @param {Object|string} options A string representing the url of the service or an object containing the url and the apiKey.
39
+ * @param {string} options.url Url to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
40
+ * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
41
+ * @param {string} [options.prefix=''] Service prefix to specify tenant.
42
+ * @param {string} [options.projection] The epsg code of the projection for features. Default to EPSG:3857.
43
+ * @param {number[4]} [options.bbox=[minX, minY, maxX, maxY, zoom, tenant] The bounding box to receive data from.
44
+ */
45
+ constructor(options = {}) {
46
+ this.defineProperties(options);
47
+ /** @ignore */
48
+ this.prefix = options.prefix || '';
49
+ /** @ignore */
50
+ this.onOpen = this.onOpen.bind(this);
51
+ }
52
+ /* @private */
53
+ defineProperties(options) {
54
+ let opt = options;
55
+ if (typeof options === 'string') {
56
+ opt = { url: options };
57
+ }
58
+ const { apiKey } = opt;
59
+ let { url, projection, bbox, buffer = [100, 100] } = opt;
60
+ const wsApi = new WebSocketAPI();
61
+ if (!url) {
62
+ url = 'wss://api.geops.io/tracker-ws/v1/';
63
+ }
64
+ if (apiKey) {
65
+ url = `${url}?key=${apiKey}`;
66
+ }
67
+ Object.defineProperties(this, {
68
+ url: {
69
+ get: () => url,
70
+ set: (newUrl) => {
71
+ url = newUrl;
72
+ this.open();
73
+ },
74
+ },
75
+ projection: {
76
+ get: () => projection,
77
+ set: (newProjection) => {
78
+ if (newProjection !== projection) {
79
+ projection = newProjection;
80
+ if (this.wsApi) {
81
+ this.wsApi.send(`PROJECTION ${projection}`);
82
+ }
83
+ }
84
+ },
85
+ },
86
+ bbox: {
87
+ get: () => bbox,
88
+ set: (newBbox) => {
89
+ if (JSON.stringify(newBbox) !== JSON.stringify(bbox)) {
90
+ bbox = newBbox;
91
+ if (this.wsApi && bbox) {
92
+ this.wsApi.send(`BBOX ${bbox.join(' ')}`);
93
+ }
94
+ }
95
+ },
96
+ },
97
+ buffer: {
98
+ get: () => buffer,
99
+ set: (newBuffer) => {
100
+ if (JSON.stringify(newBuffer) !== JSON.stringify(buffer)) {
101
+ buffer = newBuffer;
102
+ if (this.wsApi) {
103
+ this.wsApi.send(`BUFFER ${buffer.join(' ')}`);
104
+ }
105
+ }
106
+ },
107
+ },
108
+ /**
109
+ * The websocket helper class to connect the websocket.
110
+ *
111
+ * @private
112
+ */
113
+ wsApi: {
114
+ value: wsApi,
115
+ writable: true,
116
+ },
117
+ /**
118
+ * Interval between PING request in ms.
119
+ * If equal to 0, no PING request are sent.
120
+ * @type {number}
121
+ * @private
122
+ */
123
+ pingIntervalMs: {
124
+ value: options.pingIntervalMs || 10000,
125
+ writable: true,
126
+ },
127
+ /**
128
+ * Timeout in ms after an automatic reconnection when the websoscket has been closed by the server.
129
+ * @type {number}
130
+ */
131
+ reconnectTimeoutMs: {
132
+ value: options.pingIntervalMs || 100,
133
+ writable: true,
134
+ },
135
+ });
136
+ }
137
+ open() {
138
+ this.close();
139
+ // Register BBOX and PROJECTION messages must be send before previous subscriptions.
140
+ this.wsApi.connect(this.url, this.onOpen);
141
+ // Register reconnection on close.
142
+ if (this.wsApi.websocket) {
143
+ this.wsApi.websocket.onclose = () => {
144
+ this.onClose();
145
+ };
146
+ }
147
+ }
148
+ /**
149
+ * Close the websocket connection without reconnection.
150
+ */
151
+ close() {
152
+ this.wsApi.close();
153
+ }
154
+ /**
155
+ * Unsubscribe trajectory and deleted_vehicles channels. To resubscribe you have to set a new BBOX.
156
+ */
157
+ // eslint-disable-next-line class-methods-use-this
158
+ reset() {
159
+ this.wsApi.send('RESET');
160
+ }
161
+ /**
162
+ * Callback when the websocket is opened and ready.
163
+ * It applies the bbox and the projection.
164
+ */
165
+ onOpen() {
166
+ if (this.projection) {
167
+ this.wsApi.send(`PROJECTION ${this.projection}`);
168
+ }
169
+ if (this.bbox) {
170
+ this.wsApi.send(`BBOX ${this.bbox.join(' ')}`);
171
+ }
172
+ if (this.buffer) {
173
+ this.wsApi.send(`BUFFER ${this.buffer.join(' ')}`);
174
+ }
175
+ /**
176
+ * Keep websocket alive
177
+ */
178
+ if (this.pingIntervalMs) {
179
+ window.clearInterval(this.pingInterval);
180
+ /** @ignore */
181
+ this.pingInterval = window.setInterval(() => {
182
+ this.wsApi.send('PING');
183
+ }, this.pingIntervalMs);
184
+ }
185
+ }
186
+ /**
187
+ * Callback when the websocket is closed by the server.
188
+ * It auto reconnects after a timeout.
189
+ */
190
+ onClose() {
191
+ window.clearTimeout(this.pingInterval);
192
+ window.clearTimeout(this.reconnectTimeout);
193
+ if (this.reconnectTimeoutMs) {
194
+ /** @ignore */
195
+ this.reconnectTimeout = window.setTimeout(() => this.open(), this.reconnectTimeoutMs);
196
+ }
197
+ }
198
+ /**
199
+ * Subscribe to a channel.
200
+ *
201
+ * @param {string} channel Name of the websocket channel to subscribe.
202
+ * @param {function} onSuccess Callback when the subscription succeeds.
203
+ * @param {function} onError Callback when the subscription fails.
204
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
205
+ * @private
206
+ */
207
+ subscribe(channel, onSuccess, onError = () => { }, quiet = false) {
208
+ if (!channel || !onSuccess) {
209
+ return;
210
+ }
211
+ this.wsApi.subscribe({ channel }, onSuccess, onError, quiet);
212
+ }
213
+ /**
214
+ * Unsubscribe both modes of a channel.
215
+ *
216
+ * @param {string} channel Name of the websocket channel to unsubscribe.
217
+ * @param {string} suffix Suffix to add to the channel name.
218
+ * @param {function} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
219
+ * @private
220
+ */
221
+ unsubscribe(channel, suffix = '', onMessage) {
222
+ const suffixSchenatic = getModeSuffix(RealtimeModes.SCHEMATIC, RealtimeModes);
223
+ const suffixTopographic = getModeSuffix(RealtimeModes.TOPOGRAPHIC, RealtimeModes);
224
+ this.wsApi.unsubscribe(`${channel}${suffixSchenatic}${suffix || ''}`, onMessage);
225
+ this.wsApi.unsubscribe(`${channel}${suffixTopographic}${suffix || ''}`, onMessage);
226
+ }
227
+ /**
228
+ * Subscribe to departures channel of a given station.
229
+ *
230
+ * @param {number} stationId UIC of the station.
231
+ * @param {Boolean} sortByMinArrivalTime Sort by minimum arrival time
232
+ * @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
233
+ * @param {function} onError Callback when the subscription fails.
234
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
235
+ */
236
+ subscribeDepartures(stationId, onMessage, onError = () => { }, quiet = false) {
237
+ this.subscribe(`timetable_${stationId}`, onMessage, onError, quiet);
238
+ }
239
+ /**
240
+ * Unsubscribe from current departures channel.
241
+ * @param {RealtimeStationId} id Station's id
242
+ * @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
243
+ */
244
+ unsubscribeDepartures(id, onMessage) {
245
+ this.unsubscribe(`timetable_${id}`, '', onMessage);
246
+ }
247
+ /**
248
+ * Subscribe to the disruptions channel for tenant.
249
+ *
250
+ * @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
251
+ * @param {function} onError Callback when the subscription fails.
252
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
253
+ */
254
+ subscribeDisruptions(onMessage, onError = () => { }, quiet = false) {
255
+ this.subscribe(`${this.prefix}newsticker`, onMessage, onError, quiet);
256
+ }
257
+ /**
258
+ * Unsubscribe disruptions.
259
+ *
260
+ * @param {function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
261
+ */
262
+ unsubscribeDisruptions(onMessage) {
263
+ this.unsubscribe(`${this.prefix}newsticker`, '', onMessage);
264
+ }
265
+ /**
266
+ * Return a station with a given uic number and a mode.
267
+ *
268
+ * @param {number} uic UIC of the station.
269
+ * @param {RealtimeMode} mode Realtime mode.
270
+ * @return {Promise<{data: { content: RealtimeStation }}>} A station.
271
+ */
272
+ getStation(uic, mode) {
273
+ const params = {
274
+ channel: `station${getModeSuffix(mode, RealtimeModes)}`,
275
+ args: uic,
276
+ };
277
+ return new Promise((resolve, reject) => {
278
+ this.wsApi.get(params, resolve, reject);
279
+ });
280
+ }
281
+ /**
282
+ * Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
283
+ * @param {RealtimeMode} mode Realtime mode.
284
+ * @param {number} timeout = 100 Duration in ms between each promise resolve calls.
285
+ * @return {Promise<RealtimeStation[]>} An array of stations.
286
+ */
287
+ getStations(mode, timeout = 100) {
288
+ return new Promise((resolve) => {
289
+ this.wsApi.get({
290
+ channel: `station${getModeSuffix(mode, RealtimeModes)}`,
291
+ }, debounceWebsocketMessages(resolve, undefined, timeout));
292
+ });
293
+ }
294
+ /**
295
+ * Subscribe to stations channel.
296
+ * One message pro station.
297
+ *
298
+ * @param {RealtimeMode} mode Realtime mode.
299
+ * @param {function(data: { content: RealtimeStation })} onMessage Function called on each message of the channel.
300
+ * @param {function} onError Callback when the subscription fails.
301
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
302
+ */
303
+ subscribeStations(mode, onMessage, onError = () => { }, quiet = false) {
304
+ this.subscribe(`station${getModeSuffix(mode, RealtimeModes)}`, onMessage, onError, quiet);
305
+ }
306
+ /**
307
+ * Unsubscribe to stations channel.
308
+ * @param {function(data: { content: RealtimeStation })} onMessage The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
309
+ */
310
+ unsubscribeStations(onMessage) {
311
+ this.unsubscribe('station', '', onMessage);
312
+ }
313
+ /**
314
+ * Subscribe to extra_geoms channel.
315
+ *
316
+ * @param {function(data: { content: RealtimeExtraGeom })} onMessage Function called on each message of the channel.
317
+ * @param {function} onError Callback when the subscription fails.
318
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
319
+ */
320
+ subscribeExtraGeoms(onMessage, onError = () => { }, quiet = false) {
321
+ this.subscribe('extra_geoms', onMessage, onError, quiet);
322
+ }
323
+ /**
324
+ * Unsubscribe to extra_geoms channel.
325
+ * @param {function(data: { content: RealtimeExtraGeom })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
326
+ */
327
+ unsubscribeExtraGeoms(onMessage) {
328
+ this.unsubscribe('extra_geoms', '', onMessage);
329
+ }
330
+ /**
331
+ * Subscribe to trajectory channel.
332
+ *
333
+ * @param {RealtimeMode} mode Realtime mode.
334
+ * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Function called on each message of the channel.
335
+ * @param {function} onError Callback when the subscription fails.
336
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
337
+ */
338
+ subscribeTrajectory(mode, onMessage, onError = () => { }, quiet = false) {
339
+ this.unsubscribeTrajectory(onMessage);
340
+ this.subscribe(`trajectory${getModeSuffix(mode, RealtimeModes)}`, onMessage, onError, quiet);
341
+ }
342
+ /**
343
+ * Unsubscribe to trajectory channels.
344
+ * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
345
+ */
346
+ unsubscribeTrajectory(onMessage) {
347
+ this.unsubscribe(`trajectory`, '', onMessage);
348
+ }
349
+ /**
350
+ * Subscribe to deleted_vhicles channel.
351
+ *
352
+ * @param {RealtimeMode} mode Realtime mode.
353
+ * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
354
+ * @param {function} onError Callback when the subscription fails.
355
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
356
+ */
357
+ subscribeDeletedVehicles(mode, onMessage, onError = () => { }, quiet = false) {
358
+ this.unsubscribeDeletedVehicles(onMessage);
359
+ this.subscribe(`deleted_vehicles${getModeSuffix(mode, RealtimeModes)}`, onMessage, onError, quiet);
360
+ }
361
+ /**
362
+ * Unsubscribe to deleted_vhicles channels.
363
+ * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
364
+ */
365
+ unsubscribeDeletedVehicles(onMessage) {
366
+ this.unsubscribe('deleted_vehicles', '', onMessage);
367
+ }
368
+ /**
369
+ * Get a full trajectory of a vehicule .
370
+ *
371
+ * @param {string} id A vehicle id.
372
+ * @param {RealtimeMode} mode Realtime mode.
373
+ * @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
374
+ * @return {Promise<{ data: { content: FullTrajectory } }>} Return a full trajectory.
375
+ */
376
+ getFullTrajectory(id, mode, generalizationLevel) {
377
+ const channel = [`full_trajectory${getModeSuffix(mode, RealtimeModes)}`];
378
+ if (id) {
379
+ channel.push(id);
380
+ }
381
+ if ((!mode || mode === RealtimeModes.TOPOGRAPHIC) && generalizationLevel) {
382
+ channel.push(`gen${generalizationLevel}`);
383
+ }
384
+ const params = {
385
+ channel: channel.join('_'),
386
+ };
387
+ return new Promise((resolve, reject) => {
388
+ this.wsApi.get(params, resolve, reject);
389
+ });
390
+ }
391
+ /**
392
+ * Subscribe to full_trajectory channel of a given vehicle.
393
+ *
394
+ * @param {string} id A vehicle id.
395
+ * @param {RealtimeMode} mode Realtime mode.
396
+ * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Function called on each message of the channel.
397
+ * @param {function} onError Callback when the subscription fails.
398
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
399
+ */
400
+ subscribeFullTrajectory(id, mode, onMessage, onError = () => { }, quiet = false) {
401
+ this.subscribe(`full_trajectory${getModeSuffix(mode, RealtimeModes)}_${id}`, onMessage, onError, quiet);
402
+ }
403
+ /**
404
+ * Unsubscribe from full_trajectory channel
405
+ *
406
+ * @param {string} id A vehicle id.
407
+ * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
408
+ */
409
+ unsubscribeFullTrajectory(id, onMessage) {
410
+ this.unsubscribe('full_trajectory', `_${id}`, onMessage);
411
+ }
412
+ /**
413
+ * Get the list of stops for this vehicle.
414
+ *
415
+ * @param {string} id A vehicle id.
416
+ * @return {Promise<{ data: { content: StopSequence[] } }>} Returns a stop sequence object.
417
+ */
418
+ getStopSequence(id) {
419
+ return new Promise((resolve, reject) => {
420
+ this.wsApi.get({
421
+ channel: `stopsequence_${id}`,
422
+ }, resolve, reject);
423
+ });
424
+ }
425
+ /**
426
+ * Subscribe to stopsequence channel of a given vehicle.
427
+ *
428
+ * @param {string} id A vehicle id.
429
+ * @param {function(data: { content: StopSequence[] })} onMessage Function called on each message of the channel.
430
+ * @param {function} onError Callback when the subscription fails.
431
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
432
+ */
433
+ subscribeStopSequence(id, onMessage, onError = () => { }, quiet = false) {
434
+ this.subscribe(`stopsequence_${id}`, onMessage, onError, quiet);
435
+ }
436
+ /**
437
+ * Unsubscribe from stopsequence channel
438
+ *
439
+ * @param {string} id A vehicle id.
440
+ * @param {function(data: { content: StopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
441
+ */
442
+ unsubscribeStopSequence(id, onMessage) {
443
+ this.unsubscribe(`stopsequence`, `_${id}`, onMessage);
444
+ }
445
+ /**
446
+ * Subscribe to healthcheck channel.
447
+ * @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
448
+ * @param {function} onError Callback when the subscription fails.
449
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
450
+ */
451
+ subscribeHealthCheck(onMessage, onError = () => { }, quiet = false) {
452
+ this.subscribe('healthcheck', onMessage, onError, quiet);
453
+ }
454
+ /**
455
+ * Unsubscribe to healthcheck channel.
456
+ * @param {function(data: { content: string })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
457
+ */
458
+ unsubscribeHealthCheck(onMessage) {
459
+ this.unsubscribe('healthcheck', '', onMessage);
460
+ }
461
+ }
462
+ export default RealtimeAPI;
@@ -0,0 +1,37 @@
1
+ import HttpAPI from '../common/api/HttpAPI';
2
+ import { RoutingParameters, RoutingResponse } from '../types';
3
+ export declare type RoutingAPIOptions = {
4
+ url?: string;
5
+ apiKey?: string;
6
+ };
7
+ /**
8
+ * Access to the [geOps Routing service](https://developer.geops.io/apis/routing).
9
+ *
10
+ * @example
11
+ * import { RoutingAPI } from 'mobility-toolbox-js';
12
+ *
13
+ * const api = new RoutingAPI({
14
+ * apiKey: [yourApiKey]
15
+ * });
16
+ *
17
+ */
18
+ declare class RoutingAPI extends HttpAPI {
19
+ /**
20
+ * Constructor
21
+ *
22
+ * @param {RoutingAPIOptions} options Options.
23
+ * @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
24
+ * @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
25
+ */
26
+ constructor(options?: RoutingAPIOptions);
27
+ /**
28
+ * Route.
29
+ *
30
+ * @param {RoutingParameters} params Request parameters. See [Routing service documentation](https://developer.geops.io/apis/routing/).
31
+ * @param {RequestInit} config Options for the fetch request.
32
+ * @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
33
+ */
34
+ route(params: RoutingParameters, config: RequestInit): Promise<RoutingResponse>;
35
+ }
36
+ export default RoutingAPI;
37
+ //# 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,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"}
@@ -0,0 +1,35 @@
1
+ import HttpAPI from '../common/api/HttpAPI';
2
+ /**
3
+ * Access to the [geOps Routing service](https://developer.geops.io/apis/routing).
4
+ *
5
+ * @example
6
+ * import { RoutingAPI } from 'mobility-toolbox-js';
7
+ *
8
+ * const api = new RoutingAPI({
9
+ * apiKey: [yourApiKey]
10
+ * });
11
+ *
12
+ */
13
+ class RoutingAPI extends HttpAPI {
14
+ /**
15
+ * Constructor
16
+ *
17
+ * @param {RoutingAPIOptions} options Options.
18
+ * @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
19
+ * @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
20
+ */
21
+ constructor(options = {}) {
22
+ super(Object.assign({ url: 'https://api.geops.io/routing/v1/' }, options));
23
+ }
24
+ /**
25
+ * Route.
26
+ *
27
+ * @param {RoutingParameters} params Request parameters. See [Routing service documentation](https://developer.geops.io/apis/routing/).
28
+ * @param {RequestInit} config Options for the fetch request.
29
+ * @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
30
+ */
31
+ route(params, config) {
32
+ return this.fetch('', params, config);
33
+ }
34
+ }
35
+ export default RoutingAPI;
@@ -0,0 +1,38 @@
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
+ };
7
+ /**
8
+ * Access to the [Stops service](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
9
+ *
10
+ * @example
11
+ * import { StopsAPI } from 'mobility-toolbox-js/api';
12
+ *
13
+ * const api = new StopsAPI({
14
+ * url: 'https://api.geops.io/stops/v1/',
15
+ * apiKey: [yourApiKey]
16
+ * });
17
+ *
18
+ */
19
+ declare class StopsAPI extends HttpAPI {
20
+ /**
21
+ * Constructor
22
+ *
23
+ * @param {StopsAPIOptions} options Options.
24
+ * @param {string} [options.url='https://api.geops.io/stops/v1/'] Service url.
25
+ * @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
26
+ */
27
+ constructor(options?: StopsAPIOptions);
28
+ /**
29
+ * Search fo stops.
30
+ *
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).
34
+ */
35
+ search(params: StopsParameters, config: RequestInit): Promise<StopsResponse>;
36
+ }
37
+ export default StopsAPI;
38
+ //# sourceMappingURL=StopsAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StopsAPI.d.ts","sourceRoot":"","sources":["../../src/api/StopsAPI.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE1D,oBAAY,eAAe,GAAG;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,cAAM,QAAS,SAAQ,OAAO;IAC5B;;;;;;OAMG;gBACS,OAAO,GAAE,eAAoB;IAIzC;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAG7E;AAED,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,36 @@
1
+ import HttpAPI from '../common/api/HttpAPI';
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
+ class StopsAPI extends HttpAPI {
15
+ /**
16
+ * Constructor
17
+ *
18
+ * @param {StopsAPIOptions} 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
+ super(Object.assign({ url: 'https://api.geops.io/stops/v1/' }, options));
24
+ }
25
+ /**
26
+ * Search fo stops.
27
+ *
28
+ * @param {StopsParameters} params Request parameters. See [Stops service documentation](https://developer.geops.io/apis/stops).
29
+ * @param {RequestInit} config Options for the fetch request.
30
+ * @return {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
31
+ */
32
+ search(params, config) {
33
+ return this.fetch('', params, config);
34
+ }
35
+ }
36
+ export default StopsAPI;
package/api/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { default as RoutingAPI } from "./RoutingAPI";
2
+ export { default as StopsAPI } from "./StopsAPI";
3
+ export { default as RealtimeAPI, RealtimeModes } from "./RealtimeAPI";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.js"],"names":[],"mappings":""}
package/api/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { default as RoutingAPI } from './RoutingAPI';
2
+ export { default as StopsAPI } from './StopsAPI';
3
+ export { default as RealtimeAPI, RealtimeModes } from './RealtimeAPI';