mobility-toolbox-js 2.0.0-beta.8 → 2.0.0-beta.80

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 (447) hide show
  1. package/api/RealtimeAPI.d.ts +279 -0
  2. package/api/RealtimeAPI.d.ts.map +1 -0
  3. package/api/RealtimeAPI.js +466 -0
  4. package/api/RoutingAPI.d.ts +37 -0
  5. package/api/RoutingAPI.d.ts.map +1 -0
  6. package/api/RoutingAPI.js +35 -0
  7. package/api/StopsAPI.d.ts +38 -0
  8. package/api/StopsAPI.d.ts.map +1 -0
  9. package/api/StopsAPI.js +36 -0
  10. package/api/index.d.ts +4 -0
  11. package/api/index.d.ts.map +1 -0
  12. package/api/index.js +3 -0
  13. package/api/typedefs.d.ts +179 -0
  14. package/api/typedefs.d.ts.map +1 -0
  15. package/{src/api/tralis → api}/typedefs.js +4 -10
  16. package/common/api/HttpAPI.d.ts +31 -0
  17. package/common/api/HttpAPI.d.ts.map +1 -0
  18. package/common/api/HttpAPI.js +57 -0
  19. package/common/api/WebSocketAPI.d.ts +153 -0
  20. package/common/api/WebSocketAPI.d.ts.map +1 -0
  21. package/common/api/WebSocketAPI.js +341 -0
  22. package/common/controls/ControlCommon.d.ts +76 -0
  23. package/common/controls/ControlCommon.d.ts.map +1 -0
  24. package/common/controls/ControlCommon.js +150 -0
  25. package/common/controls/CopyrightControlCommon.d.ts +13 -0
  26. package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
  27. package/common/controls/CopyrightControlCommon.js +34 -0
  28. package/common/controls/StopFinderControlCommon.d.ts +55 -0
  29. package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
  30. package/common/controls/StopFinderControlCommon.js +144 -0
  31. package/common/index.d.ts +3 -0
  32. package/common/index.d.ts.map +1 -0
  33. package/common/index.js +2 -0
  34. package/common/layers/LayerCommon.d.ts +94 -0
  35. package/common/layers/LayerCommon.d.ts.map +1 -0
  36. package/common/layers/LayerCommon.js +244 -0
  37. package/common/mixins/RealtimeLayerMixin.d.ts +286 -0
  38. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
  39. package/common/mixins/RealtimeLayerMixin.js +776 -0
  40. package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
  41. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
  42. package/common/mixins/UserInteractionsLayerMixin.js +241 -0
  43. package/common/styles/index.d.ts +5 -0
  44. package/common/styles/index.d.ts.map +1 -0
  45. package/common/styles/index.js +4 -0
  46. package/common/styles/realtimeDefaultStyle.d.ts +36 -0
  47. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
  48. package/common/styles/realtimeDefaultStyle.js +275 -0
  49. package/{src/common/styles/trackerDelayStyle.js → common/styles/realtimeDelayStyle.d.ts} +4 -9
  50. package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
  51. package/common/styles/realtimeDelayStyle.js +13 -0
  52. package/common/styles/realtimeHeadingStyle.d.ts +12 -0
  53. package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
  54. package/common/styles/realtimeHeadingStyle.js +85 -0
  55. package/common/styles/realtimeSimpleStyle.d.ts +4 -0
  56. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
  57. package/common/styles/realtimeSimpleStyle.js +23 -0
  58. package/common/typedefs.d.ts +111 -0
  59. package/common/typedefs.d.ts.map +1 -0
  60. package/common/typedefs.js +52 -0
  61. package/common/utils/compareDepartures.d.ts +11 -0
  62. package/common/utils/compareDepartures.d.ts.map +1 -0
  63. package/common/utils/compareDepartures.js +35 -0
  64. package/common/utils/createCanvas.d.ts +10 -0
  65. package/common/utils/createCanvas.d.ts.map +1 -0
  66. package/common/utils/createCanvas.js +27 -0
  67. package/common/utils/createRealtimeFilters.d.ts +13 -0
  68. package/common/utils/createRealtimeFilters.d.ts.map +1 -0
  69. package/common/utils/createRealtimeFilters.js +74 -0
  70. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  71. package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
  72. package/common/utils/debounceDeparturesMessages.js +24 -0
  73. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  74. package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
  75. package/common/utils/debounceWebsocketMessages.js +29 -0
  76. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  77. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
  78. package/common/utils/getLayersAsFlatArray.js +15 -0
  79. package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
  80. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
  81. package/common/utils/getMapboxMapCopyrights.js +30 -0
  82. package/common/utils/getMapboxRender.d.ts +7 -0
  83. package/common/utils/getMapboxRender.d.ts.map +1 -0
  84. package/common/utils/getMapboxRender.js +87 -0
  85. package/common/utils/getMaplibreRender.d.ts +7 -0
  86. package/common/utils/getMaplibreRender.d.ts.map +1 -0
  87. package/common/utils/getMaplibreRender.js +38 -0
  88. package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
  89. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
  90. package/common/utils/getRealtimeModeSuffix.js +7 -0
  91. package/common/utils/getUrlWithParams.d.ts +9 -0
  92. package/common/utils/getUrlWithParams.d.ts.map +1 -0
  93. package/common/utils/getUrlWithParams.js +18 -0
  94. package/common/utils/getVehiclePosition.d.ts +16 -0
  95. package/common/utils/getVehiclePosition.d.ts.map +1 -0
  96. package/common/utils/getVehiclePosition.js +72 -0
  97. package/common/utils/index.d.ts +17 -0
  98. package/common/utils/index.d.ts.map +1 -0
  99. package/common/utils/index.js +17 -0
  100. package/common/utils/realtimeConfig.d.ts +49 -0
  101. package/common/utils/realtimeConfig.d.ts.map +1 -0
  102. package/common/utils/realtimeConfig.js +173 -0
  103. package/common/utils/removeDuplicate.d.ts +10 -0
  104. package/common/utils/removeDuplicate.d.ts.map +1 -0
  105. package/common/utils/removeDuplicate.js +15 -0
  106. package/common/utils/renderTrajectories.d.ts +17 -0
  107. package/common/utils/renderTrajectories.d.ts.map +1 -0
  108. package/common/utils/renderTrajectories.js +110 -0
  109. package/common/utils/sortAndFilterDepartures.d.ts +16 -0
  110. package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
  111. package/common/utils/sortAndFilterDepartures.js +58 -0
  112. package/common/utils/sortByDelay.d.ts +3 -0
  113. package/common/utils/sortByDelay.d.ts.map +1 -0
  114. package/common/utils/sortByDelay.js +20 -0
  115. package/common/utils/timeUtils.d.ts +24 -0
  116. package/common/utils/timeUtils.d.ts.map +1 -0
  117. package/{src/common → common}/utils/timeUtils.js +13 -18
  118. package/iife.d.ts +3 -0
  119. package/iife.d.ts.map +1 -0
  120. package/{src/iife.js → iife.js} +1 -3
  121. package/index.d.ts +10 -0
  122. package/index.d.ts.map +1 -0
  123. package/index.js +10 -0
  124. package/mapbox/controls/CopyrightControl.d.ts +29 -0
  125. package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
  126. package/mapbox/controls/CopyrightControl.js +48 -0
  127. package/mapbox/controls/index.d.ts +2 -0
  128. package/mapbox/controls/index.d.ts.map +1 -0
  129. package/mapbox/index.d.ts +6 -0
  130. package/mapbox/index.d.ts.map +1 -0
  131. package/{src/mapbox → mapbox}/index.js +1 -0
  132. package/mapbox/layers/Layer.d.ts +59 -0
  133. package/mapbox/layers/Layer.d.ts.map +1 -0
  134. package/mapbox/layers/Layer.js +101 -0
  135. package/mapbox/layers/RealtimeLayer.d.ts +181 -0
  136. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
  137. package/mapbox/layers/RealtimeLayer.js +276 -0
  138. package/mapbox/layers/index.d.ts +3 -0
  139. package/mapbox/layers/index.d.ts.map +1 -0
  140. package/mapbox/layers/index.js +2 -0
  141. package/mapbox/utils/getMercatorResolution.d.ts +9 -0
  142. package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
  143. package/mapbox/utils/getMercatorResolution.js +18 -0
  144. package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
  145. package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
  146. package/mapbox/utils/getSourceCoordinates.js +27 -0
  147. package/mapbox/utils/index.d.ts +3 -0
  148. package/mapbox/utils/index.d.ts.map +1 -0
  149. package/mapbox/utils/index.js +2 -0
  150. package/mbt.js +59981 -0
  151. package/mbt.js.map +7 -0
  152. package/mbt.min.js +1084 -0
  153. package/mbt.min.js.map +7 -0
  154. package/ol/controls/CopyrightControl.d.ts +31 -0
  155. package/ol/controls/CopyrightControl.d.ts.map +1 -0
  156. package/ol/controls/CopyrightControl.js +68 -0
  157. package/ol/controls/RoutingControl.d.ts +193 -0
  158. package/ol/controls/RoutingControl.d.ts.map +1 -0
  159. package/ol/controls/RoutingControl.js +631 -0
  160. package/ol/controls/StopFinderControl.d.ts +30 -0
  161. package/ol/controls/StopFinderControl.d.ts.map +1 -0
  162. package/{src/ol → ol}/controls/StopFinderControl.js +10 -16
  163. package/ol/controls/index.d.ts +4 -0
  164. package/ol/controls/index.d.ts.map +1 -0
  165. package/ol/index.d.ts +6 -0
  166. package/ol/index.d.ts.map +1 -0
  167. package/ol/layers/Layer.d.ts +86 -0
  168. package/ol/layers/Layer.d.ts.map +1 -0
  169. package/ol/layers/Layer.js +160 -0
  170. package/ol/layers/MapGlLayer.d.ts +67 -0
  171. package/ol/layers/MapGlLayer.d.ts.map +1 -0
  172. package/ol/layers/MapGlLayer.js +218 -0
  173. package/ol/layers/MapboxLayer.d.ts +50 -0
  174. package/ol/layers/MapboxLayer.d.ts.map +1 -0
  175. package/ol/layers/MapboxLayer.js +109 -0
  176. package/ol/layers/MapboxStyleLayer.d.ts +129 -0
  177. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
  178. package/ol/layers/MapboxStyleLayer.js +374 -0
  179. package/ol/layers/MaplibreLayer.d.ts +28 -0
  180. package/ol/layers/MaplibreLayer.d.ts.map +1 -0
  181. package/ol/layers/MaplibreLayer.js +34 -0
  182. package/ol/layers/RealtimeLayer.d.ts +202 -0
  183. package/ol/layers/RealtimeLayer.d.ts.map +1 -0
  184. package/ol/layers/RealtimeLayer.js +340 -0
  185. package/ol/layers/RoutingLayer.d.ts +34 -0
  186. package/ol/layers/RoutingLayer.d.ts.map +1 -0
  187. package/ol/layers/RoutingLayer.js +85 -0
  188. package/ol/layers/VectorLayer.d.ts +25 -0
  189. package/ol/layers/VectorLayer.d.ts.map +1 -0
  190. package/ol/layers/VectorLayer.js +38 -0
  191. package/ol/layers/WMSLayer.d.ts +42 -0
  192. package/ol/layers/WMSLayer.d.ts.map +1 -0
  193. package/ol/layers/WMSLayer.js +88 -0
  194. package/ol/layers/index.d.ts +9 -0
  195. package/ol/layers/index.d.ts.map +1 -0
  196. package/{src/ol → ol}/layers/index.js +1 -1
  197. package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
  198. package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
  199. package/ol/styles/fullTrajectoryDelayStyle.js +33 -0
  200. package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
  201. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
  202. package/ol/styles/fullTrajectoryStyle.js +44 -0
  203. package/ol/styles/index.d.ts +3 -0
  204. package/ol/styles/index.d.ts.map +1 -0
  205. package/package.json +96 -189
  206. package/setupTests.d.ts +2 -0
  207. package/setupTests.d.ts.map +1 -0
  208. package/{src/setupTests.js → setupTests.js} +13 -2
  209. package/types/common.d.ts +122 -0
  210. package/types/index.d.ts +11 -0
  211. package/types/realtime.d.ts +320 -0
  212. package/types/routing.d.ts +206 -0
  213. package/types/stops.d.ts +143 -0
  214. package/.babelrc +0 -6
  215. package/.esdoc.json +0 -17
  216. package/.eslintignore +0 -1
  217. package/.github/workflows/conventional-pr-title.yml +0 -21
  218. package/.github/workflows/cypress.yml +0 -29
  219. package/.github/workflows/nodejs.yml +0 -28
  220. package/.husky/commit-msg +0 -4
  221. package/.husky/post-checkout +0 -4
  222. package/.husky/post-merge +0 -4
  223. package/.husky/post-rebase +0 -4
  224. package/.husky/pre-commit +0 -4
  225. package/.neutrinorc.js +0 -176
  226. package/.nvmrc +0 -1
  227. package/CHANGELOG.md +0 -10
  228. package/LICENSE +0 -21
  229. package/README.md +0 -23
  230. package/__mocks__/mapbox-gl.js +0 -81
  231. package/__mocks__/maplibre-gl.js +0 -81
  232. package/commitlint.config.js +0 -1
  233. package/cypress/fixtures/example.json +0 -5
  234. package/cypress/integration/examples/api.spec.js +0 -7
  235. package/cypress/integration/examples/examples.spec.js +0 -7
  236. package/cypress/integration/examples/navigation.spec.js +0 -29
  237. package/cypress/plugins/index.js +0 -21
  238. package/cypress/support/commands.js +0 -25
  239. package/cypress/support/index.js +0 -20
  240. package/cypress.json +0 -4
  241. package/data/fetchRoute.json +0 -292
  242. package/data/fetchTrajectories.json +0 -18
  243. package/data/fetchTrajectoryById.json +0 -3
  244. package/data/fetchTrajectoryStations.json +0 -18
  245. package/data/stopsSearch.json +0 -15
  246. package/documentation.yml +0 -4
  247. package/esdoc/README.md +0 -27
  248. package/esdoc/plugins/MyPlugin.js +0 -69
  249. package/esdoc/plugins/dynamic-property-plugin/Plugin.js +0 -50
  250. package/esdoc/plugins/externals-plugin/Plugin.js +0 -45
  251. package/esdoc/plugins/externals-plugin/externals.js +0 -96
  252. package/global-setup.js +0 -3
  253. package/index.html +0 -0
  254. package/indexweb.html +0 -49
  255. package/jest.config.js +0 -5
  256. package/pull_request_template.md +0 -17
  257. package/renovate.json +0 -4
  258. package/scripts/read-pkg-json.js +0 -22
  259. package/src/api/index.js +0 -3
  260. package/src/api/routing/RoutingAPI.js +0 -44
  261. package/src/api/routing/RoutingAPI.test.js +0 -41
  262. package/src/api/stops/StopsAPI.js +0 -41
  263. package/src/api/stops/StopsAPI.test.js +0 -34
  264. package/src/api/tralis/TralisAPI.js +0 -731
  265. package/src/api/tralis/TralisAPI.test.js +0 -75
  266. package/src/api/tralis/TralisAPIUtils.js +0 -73
  267. package/src/api/tralis/WebSocketConnector.js +0 -338
  268. package/src/api/tralis/WebSocketConnector.test.js +0 -356
  269. package/src/assets/Lato-Black.ttf +0 -0
  270. package/src/assets/Lato-BlackItalic.ttf +0 -0
  271. package/src/assets/Lato-Bold.ttf +0 -0
  272. package/src/assets/Lato-BoldItalic.ttf +0 -0
  273. package/src/assets/Lato-Italic.ttf +0 -0
  274. package/src/assets/Lato-Light.ttf +0 -0
  275. package/src/assets/Lato-LightItalic.ttf +0 -0
  276. package/src/assets/Lato-Regular.ttf +0 -0
  277. package/src/assets/Lato-Thin.ttf +0 -0
  278. package/src/assets/Lato-ThinItalic.ttf +0 -0
  279. package/src/assets/OFL.txt +0 -93
  280. package/src/common/Tracker.js +0 -197
  281. package/src/common/api/api.js +0 -64
  282. package/src/common/api/api.test.js +0 -68
  283. package/src/common/controls/Control.js +0 -146
  284. package/src/common/controls/Control.test.js +0 -98
  285. package/src/common/index.js +0 -5
  286. package/src/common/layers/Layer.js +0 -404
  287. package/src/common/layers/Layer.test.js +0 -585
  288. package/src/common/mixins/CopyrightMixin.js +0 -48
  289. package/src/common/mixins/SearchMixin.js +0 -176
  290. package/src/common/mixins/TralisLayerMixin.js +0 -930
  291. package/src/common/styles/index.js +0 -4
  292. package/src/common/styles/trackerDefaultStyle.js +0 -333
  293. package/src/common/styles/trackerSimpleStyle.js +0 -22
  294. package/src/common/trackerConfig.js +0 -190
  295. package/src/common/trackerConfig.test.js +0 -25
  296. package/src/common/typedefs.js +0 -23
  297. package/src/common/utils/createTrackerFilters.js +0 -87
  298. package/src/common/utils/createTrackerFilters.test.js +0 -95
  299. package/src/common/utils/getMapboxMapCopyrights.js +0 -32
  300. package/src/common/utils/getMapboxMapCopyrights.test.js +0 -47
  301. package/src/common/utils/getMapboxStyleUrl.js +0 -32
  302. package/src/common/utils/getVehiclePosition.js +0 -72
  303. package/src/common/utils/index.js +0 -5
  304. package/src/common/utils/removeDuplicate.js +0 -22
  305. package/src/common/utils/removeDuplicate.test.js +0 -22
  306. package/src/common/utils/sortByDelay.js +0 -23
  307. package/src/common/utils/timeUtils.test.js +0 -16
  308. package/src/doc/App.js +0 -116
  309. package/src/doc/App.scss +0 -51
  310. package/src/doc/_redirects +0 -2
  311. package/src/doc/components/CodeSandboxButton.js +0 -103
  312. package/src/doc/components/Documentation.js +0 -40
  313. package/src/doc/components/Esdoc/Anchor.js +0 -57
  314. package/src/doc/components/Esdoc/ClassDoc.js +0 -272
  315. package/src/doc/components/Esdoc/DeprecatedHTML.js +0 -16
  316. package/src/doc/components/Esdoc/DetailDocs.js +0 -281
  317. package/src/doc/components/Esdoc/DetailHTML.js +0 -33
  318. package/src/doc/components/Esdoc/DirectSubclassHTML.js +0 -30
  319. package/src/doc/components/Esdoc/DocBuilderUtils.js +0 -694
  320. package/src/doc/components/Esdoc/DocLinkHTML.js +0 -62
  321. package/src/doc/components/Esdoc/DocsLinkHTML.js +0 -38
  322. package/src/doc/components/Esdoc/Esdoc.js +0 -63
  323. package/src/doc/components/Esdoc/EsdocContent.js +0 -51
  324. package/src/doc/components/Esdoc/EsdocNavigation.js +0 -13
  325. package/src/doc/components/Esdoc/EsdocSearch.js +0 -81
  326. package/src/doc/components/Esdoc/ExperimentalHTML.js +0 -17
  327. package/src/doc/components/Esdoc/ExtendsChainHTML.js +0 -32
  328. package/src/doc/components/Esdoc/FileDocLinkHTML.js +0 -60
  329. package/src/doc/components/Esdoc/IdentifiersDoc.js +0 -113
  330. package/src/doc/components/Esdoc/IndirectSubclassHTML.js +0 -30
  331. package/src/doc/components/Esdoc/InheritedSummaryDoc.js +0 -70
  332. package/src/doc/components/Esdoc/InheritedSummaryHTML.js +0 -38
  333. package/src/doc/components/Esdoc/MixinClassesHTML.js +0 -29
  334. package/src/doc/components/Esdoc/NavDoc.js +0 -112
  335. package/src/doc/components/Esdoc/OverrideMethod.js +0 -44
  336. package/src/doc/components/Esdoc/OverrideMethodDescription.js +0 -35
  337. package/src/doc/components/Esdoc/Properties.js +0 -89
  338. package/src/doc/components/Esdoc/README.md +0 -45
  339. package/src/doc/components/Esdoc/SignatureHTML.js +0 -123
  340. package/src/doc/components/Esdoc/SingleDoc.js +0 -31
  341. package/src/doc/components/Esdoc/SummaryDoc.js +0 -160
  342. package/src/doc/components/Esdoc/SummaryHTML.js +0 -96
  343. package/src/doc/components/Esdoc/TypeDocLinkHTML.js +0 -249
  344. package/src/doc/components/Esdoc/css/identifiers.css +0 -38
  345. package/src/doc/components/Esdoc/css/search.css +0 -76
  346. package/src/doc/components/Esdoc/css/style.css +0 -603
  347. package/src/doc/components/Esdoc/index.js +0 -7
  348. package/src/doc/components/Example.js +0 -153
  349. package/src/doc/components/Examples.js +0 -183
  350. package/src/doc/components/Home.js +0 -106
  351. package/src/doc/components/TrackerExample.js +0 -38
  352. package/src/doc/examples/assets/tralis-live-map/index.js +0 -11
  353. package/src/doc/examples/assets/tralis-live-map/s1kreis.svg +0 -105
  354. package/src/doc/examples/assets/tralis-live-map/s20kreis.svg +0 -101
  355. package/src/doc/examples/assets/tralis-live-map/s2kreis.svg +0 -95
  356. package/src/doc/examples/assets/tralis-live-map/s3kreis.svg +0 -95
  357. package/src/doc/examples/assets/tralis-live-map/s4kreis.svg +0 -95
  358. package/src/doc/examples/assets/tralis-live-map/s6kreis.svg +0 -95
  359. package/src/doc/examples/assets/tralis-live-map/s7kreis.svg +0 -95
  360. package/src/doc/examples/assets/tralis-live-map/s8kreis.svg +0 -93
  361. package/src/doc/examples/assets/tralis-live-map/unknown.svg +0 -107
  362. package/src/doc/examples/mb-copyright.html +0 -26
  363. package/src/doc/examples/mb-copyright.js +0 -37
  364. package/src/doc/examples/mb-tracker.html +0 -1
  365. package/src/doc/examples/mb-tracker.js +0 -39
  366. package/src/doc/examples/mb-tracker.md +0 -1
  367. package/src/doc/examples/mb-tralis.html +0 -1
  368. package/src/doc/examples/mb-tralis.js +0 -34
  369. package/src/doc/examples/ol-copyright.html +0 -26
  370. package/src/doc/examples/ol-copyright.js +0 -43
  371. package/src/doc/examples/ol-mapbox-layer.html +0 -1
  372. package/src/doc/examples/ol-mapbox-layer.js +0 -28
  373. package/src/doc/examples/ol-mapbox-layer.md +0 -0
  374. package/src/doc/examples/ol-mapbox-style-layer.html +0 -12
  375. package/src/doc/examples/ol-mapbox-style-layer.js +0 -44
  376. package/src/doc/examples/ol-query.html +0 -32
  377. package/src/doc/examples/ol-query.js +0 -83
  378. package/src/doc/examples/ol-routing.html +0 -26
  379. package/src/doc/examples/ol-routing.js +0 -59
  380. package/src/doc/examples/ol-routing.md +0 -1
  381. package/src/doc/examples/ol-stop-finder.html +0 -15
  382. package/src/doc/examples/ol-stop-finder.js +0 -31
  383. package/src/doc/examples/ol-stop-finder.md +0 -1
  384. package/src/doc/examples/ol-tracker.html +0 -1
  385. package/src/doc/examples/ol-tracker.js +0 -44
  386. package/src/doc/examples/ol-tracker.md +0 -1
  387. package/src/doc/examples/ol-tralis.html +0 -5
  388. package/src/doc/examples/ol-tralis.js +0 -57
  389. package/src/doc/examples/tralis-live-map.html +0 -1
  390. package/src/doc/examples/tralis-live-map.js +0 -51
  391. package/src/doc/examples/tralis-live-map.md +0 -3
  392. package/src/doc/examples.js +0 -107
  393. package/src/doc/img/examples/live_tracker_mb.jpg +0 -0
  394. package/src/doc/img/examples/live_tracker_munich.jpg +0 -0
  395. package/src/doc/img/examples/live_tracker_ol.jpg +0 -0
  396. package/src/doc/img/examples/mapbox.jpg +0 -0
  397. package/src/doc/img/examples/mapbox_style.jpg +0 -0
  398. package/src/doc/img/examples/ol-copyright.png +0 -0
  399. package/src/doc/img/examples/query_objects.jpg +0 -0
  400. package/src/doc/img/examples/routing.jpg +0 -0
  401. package/src/doc/img/examples/simple_map.jpg +0 -0
  402. package/src/doc/img/examples/stops.jpg +0 -0
  403. package/src/doc/img/favico.ico +0 -0
  404. package/src/doc/index.js +0 -21
  405. package/src/index.js +0 -10
  406. package/src/mapbox/controls/CopyrightControl.js +0 -58
  407. package/src/mapbox/layers/Layer.js +0 -118
  408. package/src/mapbox/layers/Layer.test.js +0 -202
  409. package/src/mapbox/layers/TralisLayer.js +0 -329
  410. package/src/mapbox/layers/TralisLayer.test.js +0 -40
  411. package/src/mapbox/layers/index.js +0 -2
  412. package/src/mapbox/utils.js +0 -46
  413. package/src/ol/README.md +0 -0
  414. package/src/ol/controls/CopyrightControl.js +0 -80
  415. package/src/ol/controls/CopyrightControl.test.js +0 -211
  416. package/src/ol/controls/RoutingControl.js +0 -752
  417. package/src/ol/controls/RoutingControl.test.js +0 -216
  418. package/src/ol/controls/StopFinderControl.test.js +0 -59
  419. package/src/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
  420. package/src/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
  421. package/src/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
  422. package/src/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
  423. package/src/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
  424. package/src/ol/controls/snapshots/RoutingControlStation1.json +0 -60
  425. package/src/ol/controls/snapshots/RoutingControlStation2.json +0 -49
  426. package/src/ol/layers/Layer.js +0 -193
  427. package/src/ol/layers/Layer.test.js +0 -197
  428. package/src/ol/layers/MapboxLayer.js +0 -378
  429. package/src/ol/layers/MapboxLayer.test.js +0 -186
  430. package/src/ol/layers/MapboxStyleLayer.js +0 -417
  431. package/src/ol/layers/MapboxStyleLayer.test.js +0 -262
  432. package/src/ol/layers/MaplibreLayer.js +0 -280
  433. package/src/ol/layers/RoutingLayer.js +0 -91
  434. package/src/ol/layers/RoutingLayer.test.js +0 -49
  435. package/src/ol/layers/TralisLayer.js +0 -359
  436. package/src/ol/layers/TralisLayer.test.js +0 -97
  437. package/src/ol/layers/VectorLayer.js +0 -43
  438. package/src/ol/layers/VectorLayer.test.js +0 -98
  439. package/src/ol/layers/WMSLayer.js +0 -80
  440. package/src/ol/layers/WMSLayer.test.js +0 -84
  441. package/src/ol/styles/fullTrajectoryDelayStyle.js +0 -35
  442. package/src/ol/styles/fullTrajectoryStyle.js +0 -51
  443. package/webpack.config.js +0 -6
  444. /package/{src/mapbox → mapbox}/controls/index.js +0 -0
  445. /package/{src/ol → ol}/controls/index.js +0 -0
  446. /package/{src/ol → ol}/index.js +0 -0
  447. /package/{src/ol → ol}/styles/index.js +0 -0
@@ -1,930 +0,0 @@
1
- /* eslint-disable no-empty-function */
2
- /* eslint-disable no-useless-constructor */
3
- /* eslint-disable no-unused-vars */
4
- /* eslint-disable class-methods-use-this */
5
- /* eslint-disable max-classes-per-file */
6
- import qs from 'query-string';
7
- import { buffer, containsCoordinate, intersects } from 'ol/extent';
8
- import { unByKey } from 'ol/Observable';
9
- import GeoJSON from 'ol/format/GeoJSON';
10
- import Point from 'ol/geom/Point';
11
- import debounce from 'lodash.debounce';
12
- import throttle from 'lodash.throttle';
13
- import { fromLonLat } from 'ol/proj';
14
- import Tracker from '../Tracker';
15
- import { timeSteps } from '../trackerConfig';
16
- import createFilters from '../utils/createTrackerFilters';
17
- import trackerDefaultStyle from '../styles/trackerDefaultStyle';
18
- import { TralisAPI, TralisModes } from '../../api';
19
-
20
- /* Permalink parameter used to filters vehicles */
21
- const LINE_FILTER = 'publishedlinename';
22
- const ROUTE_FILTER = 'tripnumber';
23
- const OPERATOR_FILTER = 'operator';
24
-
25
- /**
26
- * TralisLayerInterface.
27
- */
28
- export class TralisLayerInterface {
29
- /*
30
- * Constructor
31
-
32
- * @param {Object} options Layer options.
33
- * @param {string} options.url Tralis service url.
34
- * @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
35
- * @param {boolean} [options.debug=false] Display additional debug informations.
36
- * @param {TralisMode} [options.mode=TralisMode.TOPOGRAPHIC] Tralis's Mode.
37
- * @param {number} [options.minZoomInterpolation=8] Minimal zoom when trains positions start to be interpolated.
38
- * @param {number} [options.minZoomNonTrain=9] Minimal zoom when non trains vehicles are allowed to be displayed.
39
- */
40
- constructor(options = {}) {}
41
-
42
- /**
43
- * Initialize the layer subscribing to the Tralis api.
44
- *
45
- * @param {ol/Map~Map} map
46
- */
47
- init(map) {}
48
-
49
- /**
50
- * Terminate the layer unsubscribing to the Tralis api.
51
- */
52
- terminate() {}
53
-
54
- /**
55
- * Start the clock.
56
- */
57
- start() {}
58
-
59
- /**
60
- * Stop the clock.
61
- */
62
- stop() {}
63
-
64
- /**
65
- * Set the Tralis api's bbox.
66
- *
67
- * @param {Array<number>} extent Extent to request, [minX, minY, maxX, maxY, zoom].
68
- * @param {number} zoom Zoom level to request. Must be an integer.
69
- */
70
- setBbox(extent, zoom) {}
71
-
72
- /**
73
- * Set the Tralis api's mode.
74
- *
75
- * @param {TralisMode} mode Tralis mode
76
- */
77
- setMode(mode) {}
78
-
79
- /**
80
- * Request the stopSequence and the fullTrajectory informations for a vehicle.
81
- *
82
- * @param {string} id The vehicle identifier (the train_id property).
83
- * @param {TralisMode} mode The mode to request. If not defined, the layer´s mode propetrty will be used.
84
- * @return {Promise<{stopSequence: StopSequence, fullTrajectory: FullTrajectory>} A promise that will be resolved with the trajectory informations.
85
- */
86
- getTrajectoryInfos(id, mode) {}
87
- }
88
-
89
- /**
90
- * Mixin for TralisLayerInterface.
91
- *
92
- * @param {Class} Base A class to extend with {TralisLayerInterface} functionnalities.
93
- * @return {Class} A class that implements {TralisLayerInterface} class and extends Base;
94
- * @private
95
- */
96
- const TralisLayerMixin = (Base) =>
97
- class extends Base {
98
- constructor(options = {}) {
99
- super({ hitTolerance: 10, ...options });
100
-
101
- this.debug = options.debug;
102
- this.mode = options.mode || TralisModes.TOPOGRAPHIC;
103
- this.api = options.api || new TralisAPI(options);
104
- this.tenant = options.tenant || ''; // sbb,sbh or sbm
105
- this.minZoomNonTrain = options.minZoomNonTrain || 9; // Min zoom level from which non trains are allowed to be displayed. Min value is 9 (as configured by the server
106
- this.minZoomInterpolation = options.minZoomInterpolation || 8; // Min zoom level from which trains positions are not interpolated.
107
- this.format = new GeoJSON();
108
- this.generalizationLevelByZoom = options.generalizationLevelByZoom || {
109
- 0: 5,
110
- 1: 5,
111
- 2: 5,
112
- 3: 5,
113
- 4: 5,
114
- 5: 5,
115
- 6: 5,
116
- 7: 5,
117
- 8: 10,
118
- 9: 30,
119
- 10: 30,
120
- 11: 100,
121
- 12: 100,
122
- 13: 100,
123
- };
124
-
125
- // This property will call api.setBbox on each movend event
126
- this.isUpdateBboxOnMoveEnd = options.isUpdateBboxOnMoveEnd !== false;
127
-
128
- // Define throttling nad debounce render function
129
- this.throttleRenderTrajectories = throttle(
130
- this.renderTrajectoriesInternal,
131
- 50,
132
- { leading: false, trailing: true },
133
- );
134
-
135
- this.debounceRenderTrajectories = debounce(
136
- this.renderTrajectoriesInternal,
137
- 50,
138
- { leading: true, trailing: true, maxWait: 5000 },
139
- );
140
-
141
- // Bind callbacks
142
- this.onFeatureHover = this.onFeatureHover.bind(this);
143
- this.onFeatureClick = this.onFeatureClick.bind(this);
144
- this.renderTrajectoriesInternal =
145
- this.renderTrajectoriesInternal.bind(this);
146
- this.onTrajectoryMessage = this.onTrajectoryMessage.bind(this);
147
- this.onDeleteTrajectoryMessage =
148
- this.onDeleteTrajectoryMessage.bind(this);
149
- this.onDocumentVisibilityChange =
150
- this.onDocumentVisibilityChange.bind(this);
151
- }
152
-
153
- /**
154
- * Define layer's properties.
155
- *
156
- * @ignore
157
- */
158
- defineProperties(options) {
159
- // Tracker options use to build the tracker.
160
- let { regexPublishedLineName, publishedLineName, tripNumber, operator } =
161
- options;
162
- const {
163
- style,
164
- speed,
165
- pixelRatio,
166
- hoverVehicleId,
167
- selectedVehicleId,
168
- filter,
169
- sort,
170
- time,
171
- live,
172
- } = options;
173
-
174
- const initTrackerOptions = {
175
- style,
176
- };
177
-
178
- Object.keys(initTrackerOptions).forEach(
179
- (key) =>
180
- initTrackerOptions[key] === undefined &&
181
- delete initTrackerOptions[key],
182
- );
183
-
184
- let currSpeed = speed || 1;
185
- let currTime = time || new Date();
186
-
187
- super.defineProperties(options);
188
-
189
- Object.defineProperties(this, {
190
- isTrackerLayer: { value: true },
191
-
192
- /**
193
- * Style function used to render a vehicle.
194
- */
195
- style: {
196
- value: (trajectory, viewState) =>
197
- (style || trackerDefaultStyle)(trajectory, viewState, this),
198
- },
199
-
200
- /**
201
- * Speed of the wheel of time.
202
- * If live property is true. The speed is ignored.
203
- */
204
- speed: {
205
- get: () => currSpeed,
206
- set: (newSpeed) => {
207
- currSpeed = newSpeed;
208
- this.start();
209
- },
210
- },
211
-
212
- /**
213
- * Function to filter which vehicles to display.
214
- */
215
- filter: {
216
- value: filter,
217
- writable: true,
218
- },
219
-
220
- /**
221
- * Function to sort the vehicles to display.
222
- */
223
- sort: {
224
- value: sort,
225
- writable: true,
226
- },
227
-
228
- /**
229
- * The tracker that renders the trajectories.
230
- */
231
- tracker: { value: null, writable: true },
232
-
233
- /**
234
- * Canvas cache object for trajectories drawn.
235
- */
236
- styleCache: { value: {} },
237
-
238
- /**
239
- * If true. The layer will always use Date.now() on the next tick to render the trajectories.
240
- * When true, setting the time property has no effect.
241
- */
242
- live: {
243
- value: live === false ? live : true,
244
- writable: true,
245
- },
246
-
247
- /**
248
- * Time used to display the trajectories. Can be a Date or a number in ms representing a Date.
249
- * If live property is true. The setter does nothing.
250
- */
251
- time: {
252
- get: () => currTime,
253
- set: (newTime) => {
254
- currTime = newTime && newTime.getTime ? newTime : new Date(newTime);
255
- this.renderTrajectories();
256
- },
257
- },
258
-
259
- /**
260
- * Keep track of which trajectories are stored.
261
- */
262
- trajectories: {
263
- value: {},
264
- writable: true,
265
- },
266
-
267
- /**
268
- * Keep track of which trajectories are currently drawn.
269
- */
270
- renderedTrajectories: {
271
- get: () => (this.tracker && this.tracker.renderedTrajectories) || [],
272
- },
273
-
274
- /**
275
- * Id of the hovered vehicle.
276
- */
277
- hoverVehicleId: {
278
- value: hoverVehicleId,
279
- writable: true,
280
- },
281
-
282
- /**
283
- * Id of the selected vehicle.
284
- */
285
- selectedVehicleId: {
286
- value: selectedVehicleId,
287
- writable: true,
288
- },
289
-
290
- /**
291
- * Id of the selected vehicle.
292
- */
293
- pixelRatio: {
294
- value:
295
- pixelRatio ||
296
- (typeof window !== 'undefined' ? window.devicePixelRatio : 1),
297
- writable: true,
298
- },
299
-
300
- /**
301
- * Options used by the constructor of the Tracker class.
302
- */
303
- initTrackerOptions: {
304
- value: initTrackerOptions,
305
- writable: false,
306
- },
307
-
308
- /**
309
- * If true, encapsulates the renderTrajectories calls in a requestAnimationFrame.
310
- */
311
- useRequestAnimationFrame: {
312
- value: options.useRequestAnimationFrame || false,
313
- writable: true,
314
- },
315
-
316
- /**
317
- * If true, encapsulates the renderTrajectories calls in a throttle function. Default to true.
318
- */
319
- useThrottle: {
320
- value: options.useThrottle || true,
321
- writable: true,
322
- },
323
-
324
- /**
325
- * If true, encapsulates the renderTrajectories calls in a debounce function.
326
- */
327
- useDebounce: {
328
- value: options.useDebounce || false,
329
- writable: true,
330
- },
331
-
332
- /**
333
- * Filter properties used in combination with permalink parameters.
334
- */
335
- publishedLineName: {
336
- get: () => publishedLineName,
337
- set: (newPublishedLineName) => {
338
- publishedLineName = newPublishedLineName;
339
- this.updateFilters();
340
- },
341
- },
342
- tripNumber: {
343
- get: () => tripNumber,
344
- set: (newTripNumber) => {
345
- tripNumber = newTripNumber;
346
- this.updateFilters();
347
- },
348
- },
349
- operator: {
350
- get: () => operator,
351
- set: (newOperator) => {
352
- operator = newOperator;
353
- this.updateFilters();
354
- },
355
- },
356
- regexPublishedLineName: {
357
- get: () => regexPublishedLineName,
358
- set: (newRegex) => {
359
- regexPublishedLineName = newRegex;
360
- this.updateFilters();
361
- },
362
- },
363
-
364
- /**
365
- * Style properties.
366
- */
367
- delayDisplay: {
368
- value: options.delayDisplay || 300000,
369
- writable: true,
370
- },
371
- delayOutlineColor: {
372
- value: options.delayOutlineColor || '#000000',
373
- writable: true,
374
- },
375
-
376
- /**
377
- * Debug properties.
378
- */
379
- // Not used anymore, but could be useful for debugging.
380
- // showVehicleTraj: {
381
- // value:
382
- // options.showVehicleTraj !== undefined
383
- // ? options.showVehicleTraj
384
- // : true,
385
- // writable: true,
386
- // },
387
- });
388
-
389
- // Update filter function based on convenient properties
390
- this.updateFilters();
391
- }
392
-
393
- init(map) {
394
- super.init(map);
395
-
396
- this.tracker = new Tracker({
397
- style: (...args) => this.style(...args),
398
- ...this.initTrackerOptions,
399
- });
400
-
401
- // If the layer is visible we start the rendering clock
402
- if (this.visible) {
403
- this.start();
404
- }
405
-
406
- // On change of visibility we start/stop the rendering clock
407
- this.visibilityRef = this.on('change:visible', (evt) => {
408
- if (evt.target.visible) {
409
- this.start();
410
- } else {
411
- this.stop();
412
- }
413
- });
414
-
415
- // To avoid browser hanging when the tab is not visible for a certain amount of time,
416
- // We stop the rendering and the websocket when hide and start again when show.
417
- document.addEventListener(
418
- 'visibilitychange',
419
- this.onDocumentVisibilityChange,
420
- );
421
- }
422
-
423
- terminate() {
424
- document.removeEventListener(
425
- 'visibilitychange',
426
- this.onDocumentVisibilityChange,
427
- );
428
-
429
- this.stop();
430
- unByKey(this.visibilityRef);
431
- if (this.tracker) {
432
- const { canvas } = this.tracker;
433
- const context = canvas.getContext('2d');
434
- context.clearRect(0, 0, canvas.width, canvas.height);
435
- this.tracker = null;
436
- }
437
- super.terminate();
438
- }
439
-
440
- start() {
441
- this.stop();
442
- this.renderTrajectories();
443
- this.startUpdateTime();
444
-
445
- if (this.isClickActive) {
446
- this.onClick(this.onFeatureClick);
447
- }
448
-
449
- if (this.isHoverActive) {
450
- this.onHover(this.onFeatureHover);
451
- }
452
-
453
- this.api.open();
454
- this.api.subscribeTrajectory(
455
- this.mode,
456
- this.onTrajectoryMessage,
457
- this.isUpdateBboxOnMoveEnd,
458
- );
459
- this.api.subscribeDeletedVehicles(
460
- this.mode,
461
- this.onDeleteTrajectoryMessage,
462
- this.isUpdateBboxOnMoveEnd,
463
- );
464
-
465
- if (this.isUpdateBboxOnMoveEnd) {
466
- // Update the bbox on each move end
467
- this.setBbox();
468
- }
469
- }
470
-
471
- /**
472
- * Start the clock.
473
- * @private
474
- */
475
- startUpdateTime() {
476
- this.stopUpdateTime();
477
- this.updateTimeDelay = this.getRefreshTimeInMs();
478
- this.updateTimeInterval = setInterval(() => {
479
- // When live=true, we update the time with new Date();
480
- this.time = this.live
481
- ? new Date()
482
- : this.time.getTime() + this.updateTimeDelay * this.speed;
483
- }, this.updateTimeDelay);
484
- }
485
-
486
- stop() {
487
- this.api.unsubscribeTrajectory(this.onTrajectoryMessage);
488
- this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage);
489
- this.api.close();
490
- }
491
-
492
- /**
493
- * Stop the clock.
494
- * @private
495
- */
496
- stopUpdateTime() {
497
- if (this.updateTimeInterval) {
498
- clearInterval(this.updateTimeInterval);
499
- }
500
- }
501
-
502
- /**
503
- * Launch renderTrajectories. it avoids duplicating code in renderTrajectories method.
504
- *
505
- * @param {object} viewState The view state of the map.
506
- * @param {number[2]} viewState.center Center coordinate of the map in mercator coordinate.
507
- * @param {number[4]} viewState.extent Extent of the map in mercator coordinates.
508
- * @param {number[2]} viewState.size Size ([width, height]) of the canvas to render.
509
- * @param {number} [viewState.rotation = 0] Rotation of the map to render.
510
- * @param {number} viewState.resolution Resolution of the map to render.
511
- * @param {boolean} noInterpolate If true trajectories are not interpolated but
512
- * drawn at the last known coordinate. Use this for performance optimization
513
- * during map navigation.
514
- * @private
515
- */
516
- renderTrajectoriesInternal(viewState, noInterpolate) {
517
- if (!this.tracker) {
518
- return false;
519
- }
520
-
521
- const time = this.live ? Date.now() : this.time;
522
-
523
- const trajectories = Object.values(this.trajectories);
524
-
525
- // console.time('sort');
526
- if (this.sort) {
527
- trajectories.sort(this.sort);
528
- }
529
- // console.timeEnd('sort');
530
-
531
- // console.time('render');
532
- this.renderState = this.tracker.renderTrajectories(
533
- trajectories,
534
- { ...viewState, pixelRatio: this.pixelRatio, time },
535
- {
536
- noInterpolate:
537
- viewState.zoom < this.minZoomInterpolation ? true : noInterpolate,
538
- hoverVehicleId: this.hoverVehicleId,
539
- selectedVehicleId: this.selectedVehicleId,
540
- iconScale: this.iconScale,
541
- delayDisplay: this.delayDisplay,
542
- delayOutlineColor: this.delayOutlineColor,
543
- },
544
- );
545
-
546
- // console.timeEnd('render');
547
- return true;
548
- }
549
-
550
- /**
551
- * Render the trajectories requesting an animation frame and cancelling the previous one.
552
- * This function must be overrided by children to provide the correct parameters.
553
- *
554
- * @param {object} viewState The view state of the map.
555
- * @param {number[2]} viewState.center Center coordinate of the map in mercator coordinate.
556
- * @param {number[4]} viewState.extent Extent of the map in mercator coordinates.
557
- * @param {number[2]} viewState.size Size ([width, height]) of the canvas to render.
558
- * @param {number} [viewState.rotation = 0] Rotation of the map to render.
559
- * @param {number} viewState.resolution Resolution of the map to render.
560
- * @param {boolean} noInterpolate If true trajectories are not interpolated but
561
- * drawn at the last known coordinate. Use this for performance optimization
562
- * during map navigation.
563
- * @private
564
- */
565
- renderTrajectories(viewState, noInterpolate) {
566
- if (this.requestId) {
567
- cancelAnimationFrame(this.requestId);
568
- this.requestId = null;
569
- }
570
-
571
- if (!noInterpolate && this.useRequestAnimationFrame) {
572
- this.requestId = requestAnimationFrame(() => {
573
- this.renderTrajectoriesInternal(viewState, noInterpolate);
574
- });
575
- } else if (!noInterpolate && this.useDebounce) {
576
- this.debounceRenderTrajectories(viewState, noInterpolate);
577
- } else if (!noInterpolate && this.useThrottle) {
578
- this.throttleRenderTrajectories(viewState, noInterpolate);
579
- } else {
580
- this.renderTrajectoriesInternal(viewState, noInterpolate);
581
- }
582
- }
583
-
584
- setBbox(extent, zoom) {
585
- // Clean trajectories before sending the new bbox
586
- // Purge trajectories:
587
- // - which are outside the extent
588
- // - when it's bus and zoom level is too low for them
589
- const keys = Object.keys(this.trajectories);
590
- for (let i = keys.length - 1; i >= 0; i -= 1) {
591
- this.purgeTrajectory(this.trajectories[keys[i]], extent, zoom);
592
- }
593
-
594
- const bbox = [...extent];
595
-
596
- if (this.isUpdateBboxOnMoveEnd) {
597
- bbox.push(zoom);
598
-
599
- if (this.tenant) {
600
- bbox.push(`tenant=${this.tenant}`);
601
- }
602
-
603
- /* @ignore */
604
- this.generalizationLevel = this.generalizationLevelByZoom[zoom];
605
- if (this.generalizationLevel) {
606
- bbox.push(`gen=${this.generalizationLevel}`);
607
- }
608
- }
609
-
610
- this.api.bbox = bbox;
611
- }
612
-
613
- setMode(mode) {
614
- if (this.mode === mode) {
615
- return;
616
- }
617
- this.mode = mode;
618
- this.api.subscribeTrajectory(
619
- this.mode,
620
- this.onTrajectoryMessage,
621
- this.isUpdateBboxOnMoveEnd,
622
- );
623
- this.api.subscribeDeletedVehicles(
624
- this.mode,
625
- this.onDeleteTrajectoryMessage,
626
- this.isUpdateBboxOnMoveEnd,
627
- );
628
- }
629
-
630
- /**
631
- * Get the duration before the next update depending on zoom level.
632
- *
633
- * @private
634
- * @param {number} zoom
635
- */
636
- getRefreshTimeInMs(zoom) {
637
- const roundedZoom = Math.round(zoom);
638
- const timeStep = timeSteps[roundedZoom] || 25;
639
- const nextTick = Math.max(25, timeStep / this.speed);
640
- const nextThrottleTick = Math.min(nextTick, 500);
641
- // TODO: see if this should go elsewhere.
642
- if (this.useThrottle) {
643
- this.throttleRenderTrajectories = throttle(
644
- this.renderTrajectoriesInternal,
645
- nextThrottleTick,
646
- { leading: true, trailing: true },
647
- );
648
- } else if (this.useDebounce) {
649
- this.debounceRenderTrajectories = debounce(
650
- this.renderTrajectoriesInternal,
651
- nextThrottleTick,
652
- { leading: true, trailing: true, maxWait: 5000 },
653
- );
654
- }
655
- if (this.api?.buffer) {
656
- const [, size] = this.api.buffer;
657
- this.api.buffer = [nextThrottleTick, size];
658
- }
659
- return nextTick;
660
- }
661
-
662
- /**
663
- * Get vehicle.
664
- * @param {function} filterFc A function use to filter results.
665
- * @return {Array<Object>} Array of vehicle.
666
- */
667
- getVehicle(filterFc) {
668
- return Object.values(this.trajectories).filter(filterFc);
669
- }
670
-
671
- /**
672
- * Request feature information for a given coordinate.
673
- *
674
- * @param {ol/coordinate~Coordinate} coordinate Coordinate.
675
- * @param {Object} options Options See child classes to see which options are supported.
676
- * @param {number} [options.resolution=1] The resolution of the map.
677
- * @param {number} [options.nb=Infinity] The max number of vehicles to return.
678
- * @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
679
- */
680
- getFeatureInfoAtCoordinate(coordinate, options = {}) {
681
- const { resolution, nb } = options;
682
- const ext = buffer(
683
- [...coordinate, ...coordinate],
684
- this.hitTolerance * resolution,
685
- );
686
- let trajectories = Object.values(this.trajectories);
687
-
688
- if (this.sort) {
689
- trajectories = trajectories.sort(this.sort);
690
- }
691
-
692
- const vehicles = [];
693
- for (let i = 0; i < trajectories.length; i += 1) {
694
- if (
695
- trajectories[i].properties.coordinate &&
696
- containsCoordinate(ext, trajectories[i].properties.coordinate)
697
- ) {
698
- vehicles.push(trajectories[i]);
699
- }
700
- if (vehicles.length === nb) {
701
- break;
702
- }
703
- }
704
-
705
- return Promise.resolve({
706
- layer: this,
707
- features: vehicles.map((vehicle) => this.format.readFeature(vehicle)),
708
- coordinate,
709
- });
710
- }
711
-
712
- /**
713
- * Request the stopSequence and the fullTrajectory informations for a vehicle.
714
- *
715
- * @param {string} id The vehicle identifier (the train_id property).
716
- * @return {Promise<{stopSequence: StopSequence, fullTrajectory: FullTrajectory>} A promise that will be resolved with the trajectory informations.
717
- */
718
- getTrajectoryInfos(id) {
719
- // When a vehicle is selected, we request the complete stop sequence and the complete full trajectory.
720
- // Then we combine them in one response and send them to inherited layers.
721
- const promises = [
722
- this.api.getStopSequence(id, this.mode),
723
- this.api.getFullTrajectory(id, this.mode, this.generalizationLevel),
724
- ];
725
-
726
- return Promise.all(promises).then(([stopSequence, fullTrajectory]) => {
727
- const response = {
728
- stopSequence,
729
- fullTrajectory,
730
- };
731
- return response;
732
- });
733
- }
734
-
735
- /**
736
- * Determine if the trajectory is useless and should be removed from the list or not.
737
- * By default, this function exclude vehicles:
738
- * - that have their trajectory outside the current extent and
739
- * - that are not a train and zoom level is lower than layer's minZoomNonTrain property.
740
- *
741
- * @param {TralisTrajectory} trajectory
742
- * @param {Array<number>} extent
743
- * @param {number} zoom
744
- * @return {boolean} if the trajectory must be displayed or not.
745
- * @ignore
746
- */
747
- purgeTrajectory(trajectory, extent, zoom) {
748
- const { type, bounds, train_id: id } = trajectory.properties;
749
- if (
750
- !intersects(extent, bounds) ||
751
- (type !== 'rail' && zoom < (this.minZoomNonTrain || 9))
752
- ) {
753
- this.removeTrajectory(id);
754
- return true;
755
- }
756
- return false;
757
- }
758
-
759
- /**
760
- * Add a trajectory to the tracker.
761
- * @param {TralisTrajectory} trajectory The trajectory to add.
762
- * @private
763
- */
764
- addTrajectory(trajectory) {
765
- if (this.filter && !this.filter(trajectory)) {
766
- return;
767
- }
768
- this.trajectories[trajectory.properties.train_id] = trajectory;
769
- this.renderTrajectories();
770
- }
771
-
772
- removeTrajectory(id) {
773
- delete this.trajectories[id];
774
- }
775
-
776
- /**
777
- * On zoomend we adjust the time interval of the update of vehicles positions.
778
- *
779
- * @param evt Event that triggered the function.
780
- * @private
781
- */
782
- // eslint-disable-next-line no-unused-vars
783
- onZoomEnd(evt) {
784
- this.startUpdateTime();
785
- }
786
-
787
- onDocumentVisibilityChange() {
788
- if (!this.visible) {
789
- return;
790
- }
791
- if (document.hidden) {
792
- this.stop();
793
- } else {
794
- this.start();
795
- }
796
- }
797
-
798
- /**
799
- * Callback on websocket's trajectory channel events.
800
- * It adds a trajectory to the list.
801
- *
802
- * @private
803
- */
804
- onTrajectoryMessage(data) {
805
- if (!data.content) {
806
- return;
807
- }
808
- const trajectory = data.content;
809
-
810
- const {
811
- geometry,
812
- properties: {
813
- train_id: id,
814
- time_since_update: timeSinceUpdate,
815
- raw_coordinates: rawCoordinates,
816
- },
817
- } = trajectory;
818
-
819
- // ignore old events [SBAHNM-97]
820
- if (timeSinceUpdate < 0) {
821
- return;
822
- }
823
-
824
- // console.time(`onTrajectoryMessage${data.content.properties.train_id}`);
825
- if (this.purgeTrajectory(trajectory)) {
826
- return;
827
- }
828
-
829
- if (
830
- this.debug &&
831
- this.mode === TralisModes.TOPOGRAPHIC &&
832
- rawCoordinates
833
- ) {
834
- trajectory.properties.olGeometry = {
835
- type: 'Point',
836
- coordinates: fromLonLat(
837
- rawCoordinates,
838
- this.map.getView().getProjection(),
839
- ),
840
- };
841
- } else {
842
- trajectory.properties.olGeometry = this.format.readGeometry(geometry);
843
- }
844
-
845
- // TODO Make sure the timeOffset is useful. May be we can remove it.
846
- trajectory.properties.timeOffset = Date.now() - data.timestamp;
847
- this.addTrajectory(trajectory);
848
- }
849
-
850
- /**
851
- * Callback on websocket's deleted_vehicles channel events.
852
- * It removes the trajectory from the list.
853
- *
854
- * @private
855
- * @override
856
- */
857
- onDeleteTrajectoryMessage(data) {
858
- if (!data.content) {
859
- return;
860
- }
861
-
862
- this.removeTrajectory(data.content);
863
- }
864
-
865
- /**
866
- * Callback when user moves the mouse/pointer over the map.
867
- * It sets the layer's hoverVehicleId property with the current hovered vehicle's id.
868
- *
869
- * @private
870
- * @override
871
- */
872
- onFeatureHover(features, layer, coordinate) {
873
- const [feature] = features;
874
- let id = null;
875
- if (feature) {
876
- id = feature.get('train_id');
877
- }
878
- if (this.hoverVehicleId !== id) {
879
- /** @ignore */
880
- this.hoverVehicleId = id;
881
- this.renderTrajectories(true);
882
- }
883
- }
884
-
885
- /**
886
- * Callback when user clicks on the map.
887
- * It sets the layer's selectedVehicleId property with the current selected vehicle's id.
888
- *
889
- * @private
890
- * @override
891
- */
892
- onFeatureClick(features, layer, coordinate) {
893
- const [feature] = features;
894
- let id = null;
895
- if (feature) {
896
- id = feature.get('train_id');
897
- }
898
- if (this.selectedVehicleId !== id) {
899
- /** @ignore */
900
- this.selectedVehicleId = id;
901
- this.selectedVehicle = feature;
902
- this.renderTrajectories(true);
903
- }
904
- }
905
-
906
- /**
907
- * Update filter provided by properties or permalink.
908
- */
909
- updateFilters() {
910
- // Setting filters from the permalink if no values defined by the layer.
911
- const parameters = qs.parse(window.location.search.toLowerCase());
912
- const publishedName = this.publishedLineName || parameters[LINE_FILTER];
913
- const tripNumber = this.tripNumber || parameters[ROUTE_FILTER];
914
- const operator = this.operator || parameters[OPERATOR_FILTER];
915
- const { regexPublishedLineName } = this;
916
-
917
- // Only overrides filter function if one of this property exists.
918
- if (publishedName || tripNumber || operator || regexPublishedLineName) {
919
- // filter is the property in TrackerLayerMixin.
920
- this.filter = createFilters(
921
- publishedName,
922
- tripNumber,
923
- operator,
924
- regexPublishedLineName,
925
- );
926
- }
927
- }
928
- };
929
-
930
- export default TralisLayerMixin;