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,359 +0,0 @@
1
- import GeoJSON from 'ol/format/GeoJSON';
2
- import { Layer as OLLayer, Group, Vector as VectorLayer } from 'ol/layer';
3
- import Source from 'ol/source/Source';
4
- import { composeCssTransform } from 'ol/transform';
5
- import { Vector as VectorSource } from 'ol/source';
6
- import Layer from './Layer';
7
- import mixin from '../../common/mixins/TralisLayerMixin';
8
- import { fullTrajectoryStyle } from '../styles';
9
-
10
- const format = new GeoJSON();
11
-
12
- /**
13
- * Responsible for loading and display data from a Tralis service.
14
- *
15
- * @example
16
- * import { TralisLayer } from 'mobility-toolbox-js/ol';
17
- *
18
- * const layer = new TralisLayer({
19
- * url: [yourUrl],
20
- * apiKey: [yourApiKey],
21
- * });
22
- *
23
- *
24
- * @see <a href="/api/class/src/api/tralis/TralisAPI%20js~TralisAPI%20html">TralisAPI</a>
25
- *
26
- * @extends {Layer}
27
- * @implements {TralisLayerInterface}
28
- */
29
- class TralisLayer extends mixin(Layer) {
30
- /**
31
- * Constructor.
32
- *
33
- * @param {Object} options
34
- * @private
35
- */
36
- constructor(options = {}) {
37
- // We use a group to be able to add custom vector layer in extended class.
38
- // For example TrajservLayer use a vectorLayer to display the complete trajectory.
39
- super({
40
- ...options,
41
- });
42
-
43
- /** @ignore */
44
- this.olLayer =
45
- options.olLayer ||
46
- new Group({
47
- layers: [
48
- new VectorLayer({
49
- source: new VectorSource({ features: [] }),
50
- style: options.fullTrajectoryStyle || fullTrajectoryStyle,
51
- }),
52
- new OLLayer({
53
- source: new Source({}),
54
- render: (frameState) => {
55
- if (!this.tracker || !this.tracker.canvas) {
56
- return null;
57
- }
58
-
59
- if (!this.container) {
60
- this.container = document.createElement('div');
61
- this.container.style.position = 'absolute';
62
- this.container.style.width = '100%';
63
- this.container.style.height = '100%';
64
- this.transformContainer = document.createElement('div');
65
- this.transformContainer.style.position = 'absolute';
66
- this.transformContainer.style.width = '100%';
67
- this.transformContainer.style.height = '100%';
68
- this.container.appendChild(this.transformContainer);
69
- this.tracker.canvas.style.position = 'absolute';
70
- this.tracker.canvas.style.top = '0';
71
- this.tracker.canvas.style.left = '0';
72
- this.tracker.canvas.style.transformOrigin = 'top left';
73
- this.transformContainer.appendChild(this.tracker.canvas);
74
- }
75
-
76
- if (this.renderedViewState) {
77
- const { center, resolution, rotation } = frameState.viewState;
78
- const {
79
- center: renderedCenter,
80
- resolution: renderedResolution,
81
- rotation: renderedRotation,
82
- } = this.renderedViewState;
83
-
84
- if (renderedResolution / resolution >= 3) {
85
- // Avoid having really big points when zooming fast.
86
- const { canvas } = this.tracker;
87
- const context = canvas.getContext('2d');
88
- context.clearRect(0, 0, canvas.width, canvas.height);
89
- } else {
90
- const pixelCenterRendered =
91
- this.map.getPixelFromCoordinate(renderedCenter);
92
- const pixelCenter = this.map.getPixelFromCoordinate(center);
93
- this.transformContainer.style.transform = composeCssTransform(
94
- pixelCenterRendered[0] - pixelCenter[0],
95
- pixelCenterRendered[1] - pixelCenter[1],
96
- renderedResolution / resolution,
97
- renderedResolution / resolution,
98
- rotation - renderedRotation,
99
- 0,
100
- 0,
101
- );
102
- }
103
- }
104
- return this.container;
105
- },
106
- }),
107
- ],
108
- });
109
-
110
- // We store the layer used to highlight the full Trajectory
111
- this.vectorLayer = this.olLayer.getLayers().item(0);
112
-
113
- // Options the last render run did happen. If something changes
114
- // we have to render again
115
- /** @ignore */
116
- this.renderState = {
117
- center: [0, 0],
118
- zoom: null,
119
- rotation: 0,
120
- };
121
- }
122
-
123
- init(map) {
124
- super.init(map);
125
- if (this.map) {
126
- this.olListenersKeys.push(
127
- this.map.on(['moveend', 'change:target'], (evt) => {
128
- const view = this.map.getView();
129
- if (view.getAnimating() || view.getInteracting()) {
130
- return;
131
- }
132
- const zoom = view.getZoom();
133
-
134
- // Update the interval between render updates
135
- if (this.currentZoom !== zoom) {
136
- this.onZoomEnd(evt);
137
- }
138
- this.currentZoom = zoom;
139
-
140
- this.onMoveEnd(evt);
141
- }),
142
- );
143
- }
144
- }
145
-
146
- /**
147
- * Destroy the container of the tracker.
148
- */
149
- terminate() {
150
- super.terminate();
151
- this.container = null;
152
- }
153
-
154
- /**
155
- * Detect in the canvas if there is data to query at a specific coordinate.
156
- * @param {ol/coordinate~Coordinate} coordinate The coordinate to test
157
- * @returns
158
- */
159
- hasFeatureInfoAtCoordinate(coordinate) {
160
- if (this.map && this.tracker && this.tracker.canvas) {
161
- const context = this.tracker.canvas.getContext('2d');
162
- const pixel = this.map.getPixelFromCoordinate(coordinate);
163
- return !!context.getImageData(
164
- pixel[0] * this.pixelRatio,
165
- pixel[1] * this.pixelRatio,
166
- 1,
167
- 1,
168
- ).data[3];
169
- }
170
- return false;
171
- }
172
-
173
- /**
174
- * Render the trajectories using current map's size, resolution and rotation.
175
- * @param {boolean} noInterpolate if true, renders the vehicles without interpolating theirs positions.
176
- * @overrides
177
- */
178
- renderTrajectories(noInterpolate) {
179
- const view = this.map.getView();
180
- super.renderTrajectories(
181
- {
182
- size: this.map.getSize(),
183
- center: this.map.getView().getCenter(),
184
- extent: view.calculateExtent(),
185
- resolution: view.getResolution(),
186
- rotation: view.getRotation(),
187
- zoom: view.getZoom(),
188
- pixelRatio: this.pixelRatio,
189
- },
190
- noInterpolate,
191
- );
192
- }
193
-
194
- /**
195
- * Launch renderTrajectories. it avoids duplicating code in renderTrajectories methhod.
196
- * @private
197
- * @override
198
- */
199
- renderTrajectoriesInternal(viewState, noInterpolate) {
200
- let isRendered = false;
201
-
202
- const blockRendering =
203
- this.map.getView().getAnimating() || this.map.getView().getInteracting();
204
-
205
- // Don't render the map when the map is animating or interacting.
206
- isRendered = blockRendering
207
- ? false
208
- : super.renderTrajectoriesInternal(viewState, noInterpolate);
209
-
210
- // We update the current render state.
211
- if (isRendered) {
212
- this.renderedViewState = { ...viewState };
213
-
214
- if (this.transformContainer) {
215
- this.transformContainer.style.transform = '';
216
- }
217
- }
218
- }
219
-
220
- /**
221
- * Return the delay in ms before the next rendering.
222
- */
223
- getRefreshTimeInMs() {
224
- return super.getRefreshTimeInMs(this.map.getView().getZoom());
225
- }
226
-
227
- getFeatureInfoAtCoordinate(coordinate, options = {}) {
228
- const resolution = this.map.getView().getResolution();
229
- return super.getFeatureInfoAtCoordinate(coordinate, {
230
- resolution,
231
- ...options,
232
- });
233
- }
234
-
235
- /**
236
- * On move end we update the websocket with the new bbox.
237
- *
238
- * @param {ol/MapEvent~MapEvent} evt Moveend event
239
- * @private
240
- * @override
241
- */
242
- onMoveEnd() {
243
- if (this.visible && this.isUpdateBboxOnMoveEnd) {
244
- this.setBbox();
245
- }
246
-
247
- if (
248
- this.visible &&
249
- this.isUpdateBboxOnMoveEnd &&
250
- this.isClickActive &&
251
- this.selectedVehicleId
252
- ) {
253
- this.highlightTrajectory(this.selectedVehicleId);
254
- }
255
- }
256
-
257
- /**
258
- * Function called on moveend event only when the zoom has changed.
259
- *
260
- * @param {ol/MapEvent~MapEvent} evt Moveend event.
261
- * @private
262
- * @override
263
- */
264
- // eslint-disable-next-line no-unused-vars
265
- onZoomEnd(evt) {
266
- super.onZoomEnd(evt);
267
- }
268
-
269
- /**
270
- * Update the cursor style when hovering a vehicle.
271
- *
272
- * @private
273
- * @override
274
- */
275
- onFeatureHover(features, layer, coordinate) {
276
- super.onFeatureHover(features, layer, coordinate);
277
- this.map.getTargetElement().style.cursor = features.length
278
- ? 'pointer'
279
- : 'auto';
280
- }
281
-
282
- /**
283
- * Display the complete trajectory of the vehicle.
284
- *
285
- * @private
286
- * @override
287
- */
288
- onFeatureClick(features, layer, coordinate) {
289
- super.onFeatureClick(features, layer, coordinate);
290
- if (!features.length && this.vectorLayer) {
291
- this.vectorLayer.getSource().clear();
292
- }
293
- if (this.selectedVehicleId) {
294
- this.highlightTrajectory(this.selectedVehicleId);
295
- }
296
- }
297
-
298
- /**
299
- * Remove the trajectory form the list if necessary.
300
- *
301
- * @private
302
- */
303
- purgeTrajectory(trajectory, extent, zoom) {
304
- return super.purgeTrajectory(
305
- trajectory,
306
- extent || this.map.getView().calculateExtent(),
307
- zoom || this.map.getView().getZoom(),
308
- );
309
- }
310
-
311
- /**
312
- * Send the current bbox to the websocket
313
- *
314
- * @private
315
- */
316
- setBbox(extent, zoom) {
317
- let newExtent = extent;
318
- let newZoom = zoom;
319
- if (!newExtent && this.isUpdateBboxOnMoveEnd) {
320
- newExtent = extent || this.map.getView().calculateExtent();
321
- newZoom = Math.floor(this.map.getView().getZoom());
322
- }
323
- super.setBbox(newExtent, newZoom);
324
- }
325
-
326
- /**
327
- * Highlight the trajectory of journey.
328
- * @private
329
- */
330
- highlightTrajectory(id) {
331
- this.api
332
- .getFullTrajectory(id, this.mode, this.generalizationLevel)
333
- .then((fullTrajectory) => {
334
- const vectorSource = this.vectorLayer.getSource();
335
- vectorSource.clear();
336
-
337
- if (
338
- !fullTrajectory ||
339
- !fullTrajectory.features ||
340
- !fullTrajectory.features.length
341
- ) {
342
- return;
343
- }
344
- const features = format.readFeatures(fullTrajectory);
345
- this.vectorLayer.getSource().addFeatures(features);
346
- });
347
- }
348
-
349
- /**
350
- * Create a copy of the TralisLayer.
351
- * @param {Object} newOptions Options to override
352
- * @return {TralisLayer} A TralisLayer
353
- */
354
- clone(newOptions) {
355
- return new TralisLayer({ ...this.options, ...newOptions });
356
- }
357
- }
358
-
359
- export default TralisLayer;
@@ -1,97 +0,0 @@
1
- import fetch from 'jest-fetch-mock';
2
- import Map from 'ol/Map';
3
- import View from 'ol/View';
4
- import WS from 'jest-websocket-mock';
5
- import TralisLayer from './TralisLayer';
6
-
7
- // create a WS instance, listening on port 1234 on localhost
8
- let layer;
9
- let onClick;
10
- let olMap;
11
- let server;
12
-
13
- describe('TralisLayer', () => {
14
- beforeEach(() => {
15
- server = new WS('ws://localhost:1234');
16
- global.fetch = fetch;
17
- fetch.resetMocks();
18
-
19
- onClick = jest.fn();
20
- layer = new TralisLayer({
21
- url: 'ws://localhost:1234',
22
- apiKey: 'apiKey',
23
- onClick,
24
- });
25
-
26
- olMap = new Map({
27
- view: new View({
28
- center: [831634, 5933959],
29
- zoom: 9,
30
- }),
31
- });
32
- });
33
-
34
- afterEach(() => {
35
- // ...or gracefully close the connection
36
- server.close();
37
-
38
- // The WS class also has a static "clean" method to gracefully close all open connections,
39
- // particularly useful to reset the environment between test runs.
40
- WS.clean();
41
- });
42
-
43
- test('should be instanced.', () => {
44
- expect(layer).toBeInstanceOf(TralisLayer);
45
- expect(layer.clickCallbacks[0]).toBe(onClick);
46
- });
47
-
48
- test('should called terminate on initalization.', () => {
49
- const spy = jest.spyOn(layer, 'terminate');
50
-
51
- fetch.mockResponseOnce(JSON.stringify(global.fetchTrajectoriesResponse));
52
-
53
- layer.init(olMap);
54
- expect(spy).toHaveBeenCalledTimes(1);
55
- });
56
-
57
- test('should clone', () => {
58
- const clone = layer.clone({ name: 'clone' });
59
- expect(clone).not.toBe(layer);
60
- expect(clone.name).toBe('clone');
61
- expect(clone).toBeInstanceOf(TralisLayer);
62
- });
63
-
64
- test('should use the sort function.', () => {
65
- const fn = () => true;
66
- const laye = new TralisLayer({
67
- url: 'ws://localhost:1234',
68
- apiKey: 'apiKey',
69
- sort: fn,
70
- });
71
- expect(laye).toBeInstanceOf(TralisLayer);
72
- expect(laye.sort).toBe(fn);
73
- });
74
-
75
- test('should use filter function.', () => {
76
- const fn = () => true;
77
- const laye = new TralisLayer({
78
- url: 'ws://localhost:1234',
79
- apiKey: 'apiKey',
80
- filter: fn, // reverse the array
81
- });
82
- expect(laye).toBeInstanceOf(TralisLayer);
83
- expect(laye.filter).toBe(fn);
84
- });
85
-
86
- test('should override filter function if operator, tripNumber, regexPublishedLineName is set.', () => {
87
- const fn = () => true;
88
- const laye = new TralisLayer({
89
- url: 'ws://localhost:1234',
90
- apiKey: 'apiKey',
91
- filter: fn, // reverse the array
92
- publishedLineName: '.*',
93
- });
94
- expect(laye).toBeInstanceOf(TralisLayer);
95
- expect(laye.filter).not.toBe(fn);
96
- });
97
- });
@@ -1,43 +0,0 @@
1
- import Layer from './Layer';
2
-
3
- /**
4
- * A class use to display vector data.
5
- *
6
- * @classproperty {ol/Map~Map} map - The map where the layer is displayed.
7
- * @extends {Layer}
8
- */
9
- class VectorLayer extends Layer {
10
- /**
11
- * Request feature information for a given coordinate.
12
- * @param {ol/coordinate~Coordinate} coordinate the coordinate to request the information at.
13
- * @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
14
- */
15
- getFeatureInfoAtCoordinate(coordinate) {
16
- let features = [];
17
-
18
- if (this.map) {
19
- const pixel = this.map.getPixelFromCoordinate(coordinate);
20
- features = this.map.getFeaturesAtPixel(pixel, {
21
- layerFilter: (l) => l === this.olLayer,
22
- hitTolerance: this.hitTolerance,
23
- });
24
- }
25
-
26
- return Promise.resolve({
27
- features,
28
- layer: this,
29
- coordinate,
30
- });
31
- }
32
-
33
- /**
34
- * Create a copy of the VectorLayer.
35
- * @param {Object} newOptions Options to override
36
- * @return {VectorLayer} A VectorLayer
37
- */
38
- clone(newOptions) {
39
- return new VectorLayer({ ...this.options, ...newOptions });
40
- }
41
- }
42
-
43
- export default VectorLayer;
@@ -1,98 +0,0 @@
1
- import OLVectorLayer from 'ol/layer/Vector';
2
- import VectorSource from 'ol/source/Vector';
3
- import View from 'ol/View';
4
- import Feature from 'ol/Feature';
5
- import Point from 'ol/geom/Point';
6
- import Map from 'ol/Map';
7
- import VectorLayer from './VectorLayer';
8
-
9
- const feature1 = new Feature({
10
- attribute: 'bar',
11
- geometry: new Point([500, 500]),
12
- });
13
- const olLayer = new OLVectorLayer({
14
- source: new VectorSource({
15
- features: [
16
- feature1,
17
- new Feature({
18
- attribute: 'foo',
19
- geometry: new Point([50, 50]),
20
- }),
21
- ],
22
- }),
23
- });
24
-
25
- let layer;
26
- let map;
27
- let onClick;
28
-
29
- describe('VectorLayer', () => {
30
- beforeEach(() => {
31
- onClick = jest.fn();
32
- layer = new VectorLayer({
33
- name: 'Layer',
34
- olLayer,
35
- onClick,
36
- });
37
- map = new Map({
38
- view: new View({ resolution: 5 }),
39
- target: document.body,
40
- });
41
- });
42
-
43
- test('should be instanced.', () => {
44
- expect(layer).toBeInstanceOf(VectorLayer);
45
- expect(layer.clickCallbacks[0]).toBe(onClick);
46
- expect(layer.hitTolerance).toBe(5);
47
- });
48
-
49
- test('should add onClick callback.', () => {
50
- const onClick2 = jest.fn();
51
- layer.onClick(onClick2);
52
- expect(layer.clickCallbacks[1]).toBe(onClick2);
53
- });
54
-
55
- test('should onClick throw error.', () => {
56
- expect(() => {
57
- layer.onClick('not of type function');
58
- }).toThrow(Error);
59
- });
60
-
61
- test('should called terminate on initalization.', () => {
62
- const spy = jest.spyOn(layer, 'terminate');
63
- layer.init();
64
- expect(spy).toHaveBeenCalledTimes(1);
65
- });
66
-
67
- test('should call getFeatureInfoAtCoordinate on click then the callback', async () => {
68
- const coordinate = [500, 500];
69
- const px = [10, 10];
70
- const features = [feature1];
71
- const evt = { type: 'singleclick', map, coordinate };
72
- const spy = jest.spyOn(layer, 'getFeatureInfoAtCoordinate');
73
- const spy2 = jest.spyOn(map, 'getPixelFromCoordinate').mockReturnValue(px);
74
- const spy3 = jest
75
- .spyOn(map, 'getFeaturesAtPixel')
76
- .mockReturnValue(features);
77
- layer.init(map);
78
- expect(onClick).toHaveBeenCalledTimes(0);
79
- await map.dispatchEvent(evt);
80
- expect(spy).toHaveBeenCalledTimes(1);
81
- expect(spy).toHaveBeenCalledWith(coordinate);
82
- expect(spy2).toHaveBeenCalledTimes(1);
83
- expect(spy2).toHaveBeenCalledWith(coordinate);
84
- expect(spy3).toHaveBeenCalledTimes(1);
85
- expect(spy3.mock.calls[0][0]).toBe(px);
86
- expect(spy3.mock.calls[0][1].layerFilter(layer.olLayer)).toBe(true);
87
- expect(spy3.mock.calls[0][1].layerFilter({})).toBe(false);
88
- expect(onClick).toHaveBeenCalledTimes(1);
89
- expect(onClick).toHaveBeenCalledWith(features, layer, coordinate);
90
- });
91
-
92
- test('should clone', () => {
93
- const clone = layer.clone({ name: 'clone' });
94
- expect(clone).not.toBe(layer);
95
- expect(clone.name).toBe('clone');
96
- expect(clone).toBeInstanceOf(VectorLayer);
97
- });
98
- });
@@ -1,80 +0,0 @@
1
- import GeoJSON from 'ol/format/GeoJSON';
2
- import Layer from './Layer';
3
-
4
- /**
5
- * Class use to display a WMS layer.
6
- *
7
- * @classproperty {ol/Map~Map} map - The map where the layer is displayed.
8
- * @extends {Layer}
9
- */
10
- class WMSLayer extends Layer {
11
- /**
12
- * @override
13
- */
14
- constructor(options = {}) {
15
- super(options);
16
-
17
- /** @ignore */
18
- this.abortController = new AbortController();
19
- /** @ignore */
20
- this.format = new GeoJSON();
21
- }
22
-
23
- /**
24
- * Get features infos' Url.
25
- * @param {ol/coordinate~Coordinate} coord
26
- * @return {ol/layer/Layer~Layer}
27
- */
28
- getFeatureInfoUrl(coord) {
29
- const projection = this.map.getView().getProjection();
30
- const resolution = this.map.getView().getResolution();
31
-
32
- if (this.olLayer.getSource().getFeatureInfoUrl) {
33
- return this.olLayer
34
- .getSource()
35
- .getFeatureInfoUrl(coord, resolution, projection, {
36
- info_format: 'application/json',
37
- query_layers: this.olLayer.getSource().getParams().layers,
38
- });
39
- }
40
- return false;
41
- }
42
-
43
- /**
44
- * Request feature information for a given coordinate.
45
- * @param {ol/coordinate~Coordinate} coordinate to request the information at.
46
- * @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
47
- */
48
- getFeatureInfoAtCoordinate(coordinate) {
49
- this.abortController.abort();
50
- this.abortController = new AbortController();
51
- const { signal } = this.abortController;
52
- return fetch(this.getFeatureInfoUrl(coordinate), { signal })
53
- .then((resp) => resp.json())
54
- .then((r) => r.features)
55
- .then((data) => ({
56
- layer: this,
57
- coordinate,
58
- features: data.map((d) => this.format.readFeature(d)),
59
- }))
60
- .catch(() =>
61
- // resolve an empty feature array something fails
62
- Promise.resolve({
63
- features: [],
64
- coordinate,
65
- layer: this,
66
- }),
67
- );
68
- }
69
-
70
- /**
71
- * Create a copy of the WMSLayer.
72
- * @param {Object} newOptions Options to override
73
- * @return {WMSLayer} A WMSLayer
74
- */
75
- clone(newOptions) {
76
- return new WMSLayer({ ...this.options, ...newOptions });
77
- }
78
- }
79
-
80
- export default WMSLayer;