mobility-toolbox-js 2.0.0-beta.30 → 2.0.0-beta.34

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 (225) hide show
  1. package/api/RealtimeAPI.d.ts +268 -0
  2. package/api/RealtimeAPI.d.ts.map +1 -0
  3. package/api/RealtimeAPI.js +626 -343
  4. package/api/RoutingAPI.d.ts +33 -0
  5. package/api/RoutingAPI.d.ts.map +1 -0
  6. package/api/RoutingAPI.js +65 -15
  7. package/api/StopsAPI.d.ts +36 -0
  8. package/api/StopsAPI.d.ts.map +1 -0
  9. package/api/StopsAPI.js +70 -12
  10. package/api/index.d.ts +5 -0
  11. package/api/index.d.ts.map +1 -0
  12. package/api/index.js +10 -3
  13. package/api/typedefs.d.ts +105 -0
  14. package/api/typedefs.d.ts.map +1 -0
  15. package/api/typedefs.js +72 -0
  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 +82 -30
  19. package/common/api/WebSocketAPI.d.ts +95 -0
  20. package/common/api/WebSocketAPI.d.ts.map +1 -0
  21. package/common/api/WebSocketAPI.js +313 -168
  22. package/common/controls/Control.d.ts +74 -0
  23. package/common/controls/Control.d.ts.map +1 -0
  24. package/common/controls/Control.js +167 -78
  25. package/common/index.d.ts +3 -0
  26. package/common/index.d.ts.map +1 -0
  27. package/common/index.js +18 -2
  28. package/common/layers/Layer.d.ts +80 -0
  29. package/common/layers/Layer.d.ts.map +1 -0
  30. package/common/layers/Layer.js +251 -134
  31. package/common/mixins/CopyrightMixin.d.ts +22 -0
  32. package/common/mixins/CopyrightMixin.d.ts.map +1 -0
  33. package/common/mixins/CopyrightMixin.js +70 -22
  34. package/common/mixins/MapboxLayerMixin.d.ts +27 -0
  35. package/common/mixins/MapboxLayerMixin.d.ts.map +1 -0
  36. package/common/mixins/MapboxLayerMixin.js +240 -0
  37. package/common/mixins/RealtimeLayerMixin.d.ts +58 -0
  38. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
  39. package/common/mixins/RealtimeLayerMixin.js +698 -429
  40. package/common/mixins/StopFinderMixin.d.ts +40 -0
  41. package/common/mixins/StopFinderMixin.d.ts.map +1 -0
  42. package/common/mixins/StopFinderMixin.js +195 -107
  43. package/common/mixins/UserInteractionsLayerMixin.d.ts +42 -0
  44. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
  45. package/common/mixins/UserInteractionsLayerMixin.js +222 -121
  46. package/common/styles/index.d.ts +5 -0
  47. package/common/styles/index.d.ts.map +1 -0
  48. package/common/styles/index.js +24 -4
  49. package/common/styles/realtimeDefaultStyle.d.ts +15 -0
  50. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
  51. package/common/styles/realtimeDefaultStyle.js +236 -190
  52. package/common/styles/realtimeDelayStyle.d.ts +11 -0
  53. package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
  54. package/common/styles/realtimeDelayStyle.js +25 -7
  55. package/common/styles/realtimeSimpleStyle.d.ts +3 -0
  56. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
  57. package/common/styles/realtimeSimpleStyle.js +23 -17
  58. package/common/typedefs.d.ts +50 -0
  59. package/common/typedefs.d.ts.map +1 -0
  60. package/common/typedefs.js +21 -0
  61. package/common/utils/cleanStopTime.d.ts +7 -0
  62. package/common/utils/cleanStopTime.d.ts.map +1 -0
  63. package/common/utils/cleanStopTime.js +28 -17
  64. package/common/utils/compareDepartures.d.ts +9 -0
  65. package/common/utils/compareDepartures.d.ts.map +1 -0
  66. package/common/utils/compareDepartures.js +34 -22
  67. package/common/utils/createCanvas.d.ts +9 -0
  68. package/common/utils/createCanvas.d.ts.map +1 -0
  69. package/common/utils/createCanvas.js +28 -16
  70. package/common/utils/createTrackerFilters.d.ts +12 -0
  71. package/common/utils/createTrackerFilters.d.ts.map +1 -0
  72. package/common/utils/createTrackerFilters.js +75 -54
  73. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  74. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
  75. package/common/utils/getLayersAsFlatArray.js +15 -13
  76. package/common/utils/getMapboxMapCopyrights.d.ts +8 -0
  77. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
  78. package/common/utils/getMapboxMapCopyrights.js +24 -17
  79. package/common/utils/getMapboxRender.d.ts +5 -0
  80. package/common/utils/getMapboxRender.d.ts.map +1 -0
  81. package/common/utils/getMapboxRender.js +77 -0
  82. package/common/utils/getMaplibreRender.d.ts +5 -0
  83. package/common/utils/getMaplibreRender.d.ts.map +1 -0
  84. package/common/utils/getMaplibreRender.js +38 -0
  85. package/common/utils/getRealtimeModeSuffix.d.ts +8 -0
  86. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
  87. package/common/utils/getRealtimeModeSuffix.js +11 -2
  88. package/common/utils/getUrlWithParams.d.ts +9 -0
  89. package/common/utils/getUrlWithParams.d.ts.map +1 -0
  90. package/common/utils/getUrlWithParams.js +20 -10
  91. package/common/utils/getVehiclePosition.d.ts +14 -0
  92. package/common/utils/getVehiclePosition.d.ts.map +1 -0
  93. package/common/utils/getVehiclePosition.js +63 -39
  94. package/common/utils/index.d.ts +12 -0
  95. package/common/utils/index.d.ts.map +1 -0
  96. package/common/utils/index.js +37 -9
  97. package/common/utils/removeDuplicate.d.ts +10 -0
  98. package/common/utils/removeDuplicate.d.ts.map +1 -0
  99. package/common/utils/removeDuplicate.js +29 -7
  100. package/common/utils/renderTrajectories.d.ts +20 -0
  101. package/common/utils/renderTrajectories.d.ts.map +1 -0
  102. package/common/utils/renderTrajectories.js +111 -78
  103. package/common/utils/sortByDelay.d.ts +3 -0
  104. package/common/utils/sortByDelay.d.ts.map +1 -0
  105. package/common/utils/sortByDelay.js +21 -17
  106. package/common/utils/timeUtils.d.ts +5 -0
  107. package/common/utils/timeUtils.d.ts.map +1 -0
  108. package/common/utils/timeUtils.js +47 -18
  109. package/common/utils/trackerConfig.d.ts +24 -0
  110. package/common/utils/trackerConfig.d.ts.map +1 -0
  111. package/common/utils/trackerConfig.js +171 -118
  112. package/iife.d.ts +3 -0
  113. package/iife.d.ts.map +1 -0
  114. package/iife.js +7 -0
  115. package/index.d.ts +6 -0
  116. package/index.d.ts.map +1 -0
  117. package/index.js +10 -7
  118. package/mapbox/controls/CopyrightControl.d.ts +32 -0
  119. package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
  120. package/mapbox/controls/CopyrightControl.js +72 -28
  121. package/mapbox/controls/index.d.ts +2 -0
  122. package/mapbox/controls/index.d.ts.map +1 -0
  123. package/mapbox/controls/index.js +6 -1
  124. package/mapbox/index.d.ts +5 -0
  125. package/mapbox/index.d.ts.map +1 -0
  126. package/mapbox/index.js +20 -4
  127. package/mapbox/layers/Layer.d.ts +47 -0
  128. package/mapbox/layers/Layer.d.ts.map +1 -0
  129. package/mapbox/layers/Layer.js +137 -54
  130. package/mapbox/layers/RealtimeLayer.d.ts +118 -0
  131. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
  132. package/mapbox/layers/RealtimeLayer.js +310 -183
  133. package/mapbox/layers/index.d.ts +3 -0
  134. package/mapbox/layers/index.d.ts.map +1 -0
  135. package/mapbox/layers/index.js +7 -2
  136. package/mapbox/utils.d.ts +8 -0
  137. package/mapbox/utils.d.ts.map +1 -0
  138. package/mapbox/utils.js +54 -29
  139. package/mbt.js +2052 -2109
  140. package/mbt.js.map +3 -3
  141. package/mbt.min.js +18 -18
  142. package/mbt.min.js.map +3 -3
  143. package/ol/controls/CopyrightControl.d.ts +31 -0
  144. package/ol/controls/CopyrightControl.d.ts.map +1 -0
  145. package/ol/controls/CopyrightControl.js +89 -41
  146. package/ol/controls/RoutingControl.d.ts +180 -0
  147. package/ol/controls/RoutingControl.d.ts.map +1 -0
  148. package/ol/controls/RoutingControl.js +666 -371
  149. package/ol/controls/StopFinderControl.d.ts +32 -0
  150. package/ol/controls/StopFinderControl.d.ts.map +1 -0
  151. package/ol/controls/StopFinderControl.js +59 -10
  152. package/ol/controls/index.d.ts +4 -0
  153. package/ol/controls/index.d.ts.map +1 -0
  154. package/ol/controls/index.js +9 -3
  155. package/ol/index.d.ts +6 -0
  156. package/ol/index.d.ts.map +1 -0
  157. package/ol/index.js +21 -5
  158. package/ol/layers/Layer.d.ts +49 -0
  159. package/ol/layers/Layer.d.ts.map +1 -0
  160. package/ol/layers/Layer.js +178 -81
  161. package/ol/layers/MapboxLayer.d.ts +42 -0
  162. package/ol/layers/MapboxLayer.d.ts.map +1 -0
  163. package/ol/layers/MapboxLayer.js +131 -198
  164. package/ol/layers/MapboxStyleLayer.d.ts +146 -0
  165. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
  166. package/ol/layers/MapboxStyleLayer.js +382 -186
  167. package/ol/layers/MaplibreLayer.d.ts +27 -0
  168. package/ol/layers/MaplibreLayer.d.ts.map +1 -0
  169. package/ol/layers/MaplibreLayer.js +67 -138
  170. package/ol/layers/RealtimeLayer.d.ts +119 -0
  171. package/ol/layers/RealtimeLayer.d.ts.map +1 -0
  172. package/ol/layers/RealtimeLayer.js +327 -184
  173. package/ol/layers/RoutingLayer.d.ts +24 -0
  174. package/ol/layers/RoutingLayer.d.ts.map +1 -0
  175. package/ol/layers/RoutingLayer.js +111 -56
  176. package/ol/layers/VectorLayer.d.ts +23 -0
  177. package/ol/layers/VectorLayer.d.ts.map +1 -0
  178. package/ol/layers/VectorLayer.js +71 -21
  179. package/ol/layers/WMSLayer.d.ts +38 -0
  180. package/ol/layers/WMSLayer.d.ts.map +1 -0
  181. package/ol/layers/WMSLayer.js +105 -37
  182. package/ol/layers/index.d.ts +9 -0
  183. package/ol/layers/index.d.ts.map +1 -0
  184. package/ol/layers/index.js +19 -8
  185. package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
  186. package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
  187. package/ol/styles/fullTrajectoryDelayStyle.js +32 -28
  188. package/ol/styles/fullTrajectoryStyle.d.ts +4 -0
  189. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
  190. package/ol/styles/fullTrajectoryStyle.js +44 -40
  191. package/ol/styles/index.d.ts +3 -0
  192. package/ol/styles/index.d.ts.map +1 -0
  193. package/ol/styles/index.js +7 -2
  194. package/package.json +14 -36
  195. package/setupTests.d.ts +2 -0
  196. package/setupTests.d.ts.map +1 -0
  197. package/setupTests.js +15 -0
  198. package/types/index.d.ts +7 -6
  199. package/types/routing.d.ts +25 -25
  200. package/types/stops.d.ts +19 -19
  201. package/api/RealtimeAPI.test.js +0 -67
  202. package/api/RoutingAPI.test.js +0 -25
  203. package/api/StopsAPI.test.js +0 -22
  204. package/common/api/HttpAPI.test.js +0 -50
  205. package/common/api/WebSocketAPI.test.js +0 -311
  206. package/common/controls/Control.test.js +0 -87
  207. package/common/layers/Layer.test.js +0 -134
  208. package/common/mixins/UserInteractionsLayerMixin.test.js +0 -199
  209. package/common/utils/createTrackerFilters.test.js +0 -79
  210. package/common/utils/getMapboxMapCopyrights.test.js +0 -40
  211. package/common/utils/removeDuplicate.test.js +0 -19
  212. package/common/utils/timeUtils.test.js +0 -10
  213. package/common/utils/trackerConfig.test.js +0 -23
  214. package/mapbox/layers/Layer.test.js +0 -182
  215. package/mapbox/layers/RealtimeLayer.test.js +0 -10
  216. package/ol/controls/CopyrightControl.test.js +0 -165
  217. package/ol/controls/RoutingControl.test.js +0 -146
  218. package/ol/controls/StopFinderControl.test.js +0 -48
  219. package/ol/layers/Layer.test.js +0 -175
  220. package/ol/layers/MapboxLayer.test.js +0 -160
  221. package/ol/layers/MapboxStyleLayer.test.js +0 -226
  222. package/ol/layers/RealtimeLayer.test.js +0 -67
  223. package/ol/layers/RoutingLayer.test.js +0 -39
  224. package/ol/layers/VectorLayer.test.js +0 -76
  225. package/ol/layers/WMSLayer.test.js +0 -57
@@ -1,19 +1,30 @@
1
- const cleanStopTime = (content) => {
2
- if (!content) {
3
- return;
4
- }
5
- content.stations.forEach((station) => {
6
- station.arrivalTimeWithDelay = station.arrivalTime;
7
- if (station.departureTime) {
8
- station.departureTimeWithDelay = station.departureTime;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Remove the delay from arrivalTime and departureTime
5
+ * @private
6
+ */
7
+ var cleanStopTime = function (content) {
8
+ if (!content) {
9
+ return;
9
10
  }
10
- if (station.arrivalDelay) {
11
- station.arrivalTime -= station.arrivalDelay;
12
- if (station.departureTime) {
13
- station.departureTime -= station.arrivalDelay;
14
- }
15
- }
16
- });
17
- return content;
11
+ content.stations.forEach(function (station) {
12
+ // eslint-disable-next-line no-param-reassign
13
+ station.arrivalTimeWithDelay = station.arrivalTime;
14
+ if (station.departureTime) {
15
+ // eslint-disable-next-line no-param-reassign
16
+ station.departureTimeWithDelay = station.departureTime;
17
+ }
18
+ if (station.arrivalDelay) {
19
+ // eslint-disable-next-line no-param-reassign
20
+ station.arrivalTime -= station.arrivalDelay;
21
+ if (station.departureTime) {
22
+ // eslint-disable-next-line no-param-reassign
23
+ station.departureTime -= station.arrivalDelay;
24
+ }
25
+ }
26
+ });
27
+ // eslint-disable-next-line consistent-return
28
+ return content;
18
29
  };
19
- export default cleanStopTime;
30
+ exports.default = cleanStopTime;
@@ -0,0 +1,9 @@
1
+ export default compareDepartures;
2
+ /**
3
+ * Compare two given departures for sort alogithm,
4
+ * @param {Object} a First departure.
5
+ * @param {Object} b Second departure.
6
+ * @private
7
+ */
8
+ declare function compareDepartures(a: any, b: any, sortByMinArrivalTime?: boolean): number;
9
+ //# sourceMappingURL=compareDepartures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compareDepartures.d.ts","sourceRoot":"","sources":["../../../src/common/utils/compareDepartures.js"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,2FA8BC"}
@@ -1,25 +1,37 @@
1
- const compareDepartures = (a, b, sortByMinArrivalTime = false) => {
2
- const topStates = ["HIDDEN", "LEAVING", "BOARDING"];
3
- const aTop = a.has_fzo && topStates.indexOf(a.state) > -1;
4
- const bTop = b.has_fzo && topStates.indexOf(b.state) > -1;
5
- if (aTop || bTop) {
6
- if (aTop !== bTop) {
7
- return aTop ? -1 : 1;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Compare two given departures for sort alogithm,
5
+ * @param {Object} a First departure.
6
+ * @param {Object} b Second departure.
7
+ * @private
8
+ */
9
+ var compareDepartures = function (a, b, sortByMinArrivalTime) {
10
+ if (sortByMinArrivalTime === void 0) { sortByMinArrivalTime = false; }
11
+ // First LEAVING and HIDDEN, then BOARDING and then sorted by time.
12
+ var topStates = ['HIDDEN', 'LEAVING', 'BOARDING'];
13
+ var aTop = a.has_fzo && topStates.indexOf(a.state) > -1;
14
+ var bTop = b.has_fzo && topStates.indexOf(b.state) > -1;
15
+ if (aTop || bTop) {
16
+ if (aTop !== bTop) {
17
+ return aTop ? -1 : 1;
18
+ }
19
+ if (a.state !== b.state) {
20
+ // one is leaving
21
+ return topStates.indexOf(a.state) - topStates.indexOf(b.state);
22
+ }
8
23
  }
9
- if (a.state !== b.state) {
10
- return topStates.indexOf(a.state) - topStates.indexOf(b.state);
24
+ var aDuration = null;
25
+ var bDuration = null;
26
+ var now = Date.now();
27
+ if (sortByMinArrivalTime) {
28
+ aDuration = new Date(a.min_arrival_time || a.time).getTime() - now;
29
+ bDuration = new Date(b.min_arrival_time || b.time).getTime() - now;
11
30
  }
12
- }
13
- let aDuration = null;
14
- let bDuration = null;
15
- const now = Date.now();
16
- if (sortByMinArrivalTime) {
17
- aDuration = new Date(a.min_arrival_time || a.time).getTime() - now;
18
- bDuration = new Date(b.min_arrival_time || b.time).getTime() - now;
19
- } else {
20
- aDuration = new Date(a.time).getTime() - now;
21
- bDuration = new Date(b.time).getTime() - now;
22
- }
23
- return aDuration - bDuration;
31
+ else {
32
+ aDuration = new Date(a.time).getTime() - now;
33
+ bDuration = new Date(b.time).getTime() - now;
34
+ }
35
+ return aDuration - bDuration;
24
36
  };
25
- export default compareDepartures;
37
+ exports.default = compareDepartures;
@@ -0,0 +1,9 @@
1
+ export default createCanvas;
2
+ /**
3
+ * This function try to create a canvas element and return it.
4
+ * it uses document.createElement('canvas') if document is available
5
+ * or new OffscreenCanvas(width, height) if OffscreenCanvas is avalaible (for web worker)
6
+ * or it returns null if neither is available.
7
+ */
8
+ declare function createCanvas(width: any, height: any): any;
9
+ //# sourceMappingURL=createCanvas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCanvas.d.ts","sourceRoot":"","sources":["../../../src/common/utils/createCanvas.js"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,4DAqBC"}
@@ -1,17 +1,29 @@
1
- const createCanvas = (width, height) => {
2
- let canvas = null;
3
- if (typeof window === "undefined") {
4
- return null;
5
- }
6
- if (document?.createElement) {
7
- canvas = document.createElement("canvas");
8
- canvas.width = width;
9
- canvas.height = height;
10
- } else if (OffscreenCanvas) {
11
- canvas = new OffscreenCanvas(width, height);
12
- } else {
13
- console.error("We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported");
14
- }
15
- return canvas;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * This function try to create a canvas element and return it.
5
+ * it uses document.createElement('canvas') if document is available
6
+ * or new OffscreenCanvas(width, height) if OffscreenCanvas is avalaible (for web worker)
7
+ * or it returns null if neither is available.
8
+ */
9
+ var createCanvas = function (width, height) {
10
+ var canvas = null;
11
+ // Prevent SSR errors
12
+ if (typeof window === 'undefined') {
13
+ return null;
14
+ }
15
+ if (document === null || document === void 0 ? void 0 : document.createElement) {
16
+ canvas = document.createElement('canvas');
17
+ canvas.width = width;
18
+ canvas.height = height;
19
+ }
20
+ else if (OffscreenCanvas) {
21
+ canvas = new OffscreenCanvas(width, height);
22
+ }
23
+ else {
24
+ // eslint-disable-next-line no-console
25
+ console.error("We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported");
26
+ }
27
+ return canvas;
16
28
  };
17
- export default createCanvas;
29
+ exports.default = createCanvas;
@@ -0,0 +1,12 @@
1
+ export default createFilters;
2
+ /**
3
+ * Return a filter functions based on some parameters of a vehicle.
4
+ *
5
+ * @param {string|Array<string>} line - A list of vehicle's name to filter. Names can be separated by a comma. Ex: 'S1,S2,S3'
6
+ * @param {string|Array<string} route - A list of vehicle's route (contained in routeIdentifier property) to filter. Indentifiers can be separated by a comma. Ex: 'id1,id2,id3'
7
+ * @param {string|Array<string} operator A list of vehicle's operator to filter. Operators can be separated by a comma. Ex: 'SBB,DB'
8
+ * @param {Regexp} regexLine - A regex aplly of vehcile's name.
9
+ * @private
10
+ */
11
+ declare function createFilters(line: string | Array<string>, route: string | Array<string>, operator: string | Array<string>, regexLine: Regexp): (t: any) => boolean;
12
+ //# sourceMappingURL=createTrackerFilters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTrackerFilters.d.ts","sourceRoot":"","sources":["../../../src/common/utils/createTrackerFilters.js"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AACH,qCANW,MAAM,GAAC,MAAM,MAAM,CAAC,SACpB,MAAM,GAAC,MAAM,MAAM,CAAA,YACnB,MAAM,GAAC,MAAM,MAAM,CAAA,0CA+E7B"}
@@ -1,56 +1,77 @@
1
- const createFilters = (line, route, operator, regexLine) => {
2
- const filterList = [];
3
- if (!line && !route && !operator && !regexLine) {
4
- return null;
5
- }
6
- if (regexLine) {
7
- const regexLineList = typeof regexLine === "string" ? [regexLine] : regexLine;
8
- const lineFilter = (item) => {
9
- const name = item.properties.name || item.properties.line && item.properties.line.name || "";
10
- if (!name) {
11
- return false;
12
- }
13
- return regexLineList.some((regexStr) => new RegExp(regexStr, "i").test(name));
14
- };
15
- filterList.push(lineFilter);
16
- }
17
- if (line) {
18
- const lineFiltersList = typeof line === "string" ? line.split(",") : line;
19
- const lineList = lineFiltersList.map((l) => l.replace(/\s+/g, "").toUpperCase());
20
- const lineFilter = (item) => {
21
- const { line: linee, name } = item.properties;
22
- const lineName = (name || linee && linee.name || "").toUpperCase();
23
- if (!lineName) {
24
- return false;
25
- }
26
- return lineList.includes(lineName);
27
- };
28
- filterList.push(lineFilter);
29
- }
30
- if (route) {
31
- const routes = typeof route === "string" ? route.split(",") : route;
32
- const routeList = routes.map((item) => parseInt(item, 10));
33
- const routeFilter = (item) => {
34
- const routeId = parseInt(item.properties.routeIdentifier.split(".")[0], 10);
35
- return routeList.includes(routeId);
36
- };
37
- filterList.push(routeFilter);
38
- }
39
- if (operator) {
40
- const operatorList = typeof operator === "string" ? [operator] : operator;
41
- const operatorFilter = (item) => operatorList.some((op) => new RegExp(op, "i").test(item.properties.operator));
42
- filterList.push(operatorFilter);
43
- }
44
- if (!filterList.length) {
45
- return null;
46
- }
47
- return (t) => {
48
- for (let i = 0; i < filterList.length; i += 1) {
49
- if (!filterList[i](t)) {
50
- return false;
51
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Return a filter functions based on some parameters of a vehicle.
5
+ *
6
+ * @param {string|Array<string>} line - A list of vehicle's name to filter. Names can be separated by a comma. Ex: 'S1,S2,S3'
7
+ * @param {string|Array<string} route - A list of vehicle's route (contained in routeIdentifier property) to filter. Indentifiers can be separated by a comma. Ex: 'id1,id2,id3'
8
+ * @param {string|Array<string} operator A list of vehicle's operator to filter. Operators can be separated by a comma. Ex: 'SBB,DB'
9
+ * @param {Regexp} regexLine - A regex aplly of vehcile's name.
10
+ * @private
11
+ */
12
+ var createFilters = function (line, route, operator, regexLine) {
13
+ var filterList = [];
14
+ if (!line && !route && !operator && !regexLine) {
15
+ return null;
16
+ }
17
+ if (regexLine) {
18
+ var regexLineList_1 = typeof regexLine === 'string' ? [regexLine] : regexLine;
19
+ var lineFilter = function (item) {
20
+ var name = item.properties.name ||
21
+ (item.properties.line && item.properties.line.name) ||
22
+ '';
23
+ if (!name) {
24
+ return false;
25
+ }
26
+ return regexLineList_1.some(function (regexStr) {
27
+ return new RegExp(regexStr, 'i').test(name);
28
+ });
29
+ };
30
+ filterList.push(lineFilter);
31
+ }
32
+ if (line) {
33
+ var lineFiltersList = typeof line === 'string' ? line.split(',') : line;
34
+ var lineList_1 = lineFiltersList.map(function (l) {
35
+ return l.replace(/\s+/g, '').toUpperCase();
36
+ });
37
+ var lineFilter = function (item) {
38
+ var _a = item.properties, linee = _a.line, name = _a.name;
39
+ var lineName = (name || (linee && linee.name) || '').toUpperCase();
40
+ if (!lineName) {
41
+ return false;
42
+ }
43
+ return lineList_1.includes(lineName);
44
+ };
45
+ filterList.push(lineFilter);
52
46
  }
53
- return true;
54
- };
47
+ if (route) {
48
+ var routes = typeof route === 'string' ? route.split(',') : route;
49
+ var routeList_1 = routes.map(function (item) { return parseInt(item, 10); });
50
+ var routeFilter = function (item) {
51
+ var routeId = parseInt(item.properties.routeIdentifier.split('.')[0], 10);
52
+ return routeList_1.includes(routeId);
53
+ };
54
+ filterList.push(routeFilter);
55
+ }
56
+ if (operator) {
57
+ var operatorList_1 = typeof operator === 'string' ? [operator] : operator;
58
+ var operatorFilter = function (item) {
59
+ return operatorList_1.some(function (op) {
60
+ return new RegExp(op, 'i').test(item.properties.operator);
61
+ });
62
+ };
63
+ filterList.push(operatorFilter);
64
+ }
65
+ if (!filterList.length) {
66
+ return null;
67
+ }
68
+ return function (t) {
69
+ for (var i = 0; i < filterList.length; i += 1) {
70
+ if (!filterList[i](t)) {
71
+ return false;
72
+ }
73
+ }
74
+ return true;
75
+ };
55
76
  };
56
- export default createFilters;
77
+ exports.default = createFilters;
@@ -0,0 +1,3 @@
1
+ export default getLayersAsFlatArray;
2
+ declare function getLayersAsFlatArray(layersOrLayer: any): any[];
3
+ //# sourceMappingURL=getLayersAsFlatArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLayersAsFlatArray.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getLayersAsFlatArray.js"],"names":[],"mappings":";AAAA,iEAYC"}
@@ -1,14 +1,16 @@
1
- const getLayersAsFlatArray = (layersOrLayer) => {
2
- let layers = layersOrLayer;
3
- if (!Array.isArray(layers)) {
4
- layers = [layersOrLayer];
5
- }
6
- let flatLayers = [];
7
- layers.forEach((layer) => {
8
- flatLayers.push(layer);
9
- const { children } = layer;
10
- flatLayers = flatLayers.concat(getLayersAsFlatArray(children || []));
11
- });
12
- return flatLayers;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var getLayersAsFlatArray = function (layersOrLayer) {
4
+ var layers = layersOrLayer;
5
+ if (!Array.isArray(layers)) {
6
+ layers = [layersOrLayer];
7
+ }
8
+ var flatLayers = [];
9
+ layers.forEach(function (layer) {
10
+ flatLayers.push(layer);
11
+ var children = layer.children;
12
+ flatLayers = flatLayers.concat(getLayersAsFlatArray(children || []));
13
+ });
14
+ return flatLayers;
13
15
  };
14
- export default getLayersAsFlatArray;
16
+ exports.default = getLayersAsFlatArray;
@@ -0,0 +1,8 @@
1
+ export default getMapboxMapCopyrights;
2
+ /**
3
+ * Return the copyright a Mapbox map.
4
+ * @param {mapboxgl.Map} map A Mapbox map
5
+ * @ignore
6
+ */
7
+ declare function getMapboxMapCopyrights(map: mapboxgl.Map): any[];
8
+ //# sourceMappingURL=getMapboxMapCopyrights.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMapboxMapCopyrights.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getMapboxMapCopyrights.js"],"names":[],"mappings":";AAEA;;;;GAIG;AACH,kEAsBC"}
@@ -1,19 +1,26 @@
1
- import removeDuplicate from "./removeDuplicate";
2
- const getMapboxMapCopyrights = (map) => {
3
- if (!map || !map.style) {
4
- return [];
5
- }
6
- const { sourceCaches } = map.style;
7
- let copyrights = [];
8
- Object.values(sourceCaches).forEach((sourceCache) => {
9
- if (sourceCache.used) {
10
- const source = sourceCache.getSource();
11
- const attribution = source.attribution || source.options && source.options.attribution;
12
- if (attribution) {
13
- copyrights = copyrights.concat(attribution.replace(/&copy;/g, "\xA9").split(/(<a.*?<\/a>)/));
14
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var removeDuplicate_1 = require("./removeDuplicate");
4
+ /**
5
+ * Return the copyright a Mapbox map.
6
+ * @param {mapboxgl.Map} map A Mapbox map
7
+ * @ignore
8
+ */
9
+ var getMapboxMapCopyrights = function (map) {
10
+ if (!map || !map.style) {
11
+ return [];
15
12
  }
16
- });
17
- return removeDuplicate(copyrights);
13
+ var sourceCaches = map.style.sourceCaches;
14
+ var copyrights = [];
15
+ Object.values(sourceCaches).forEach(function (sourceCache) {
16
+ if (sourceCache.used) {
17
+ var source = sourceCache.getSource();
18
+ var attribution = source.attribution || (source.options && source.options.attribution);
19
+ if (attribution) {
20
+ copyrights = copyrights.concat(attribution.replace(/&copy;/g, '©').split(/(<a.*?<\/a>)/));
21
+ }
22
+ }
23
+ });
24
+ return (0, removeDuplicate_1.default)(copyrights);
18
25
  };
19
- export default getMapboxMapCopyrights;
26
+ exports.default = getMapboxMapCopyrights;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Return the render function fo the olLayer of a MaplibreLayer
3
+ */
4
+ export default function getMapboxRender(mapoxLayer: any): (frameState: any) => any;
5
+ //# sourceMappingURL=getMapboxRender.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMapboxRender.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getMapboxRender.js"],"names":[],"mappings":"AAGA;;GAEG;AACH,mFA4EC"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable no-underscore-dangle */
4
+ var proj_1 = require("ol/proj");
5
+ /**
6
+ * Return the render function fo the olLayer of a MaplibreLayer
7
+ */
8
+ function getMapboxRender(mapoxLayer) {
9
+ return function (frameState) {
10
+ var map = mapoxLayer.map, mbMap = mapoxLayer.mbMap, renderState = mapoxLayer.renderState, olLayer = mapoxLayer.olLayer;
11
+ if (!map || !mbMap) {
12
+ return null;
13
+ }
14
+ var changed = false;
15
+ var canvas = mbMap.getCanvas();
16
+ var viewState = frameState.viewState;
17
+ var visible = olLayer.getVisible();
18
+ if (renderState.visible !== visible) {
19
+ canvas.style.display = visible ? 'block' : 'none';
20
+ renderState.visible = visible;
21
+ // Needed since mapbox-gl 1.9.0.
22
+ // Without you don't see others ol layers on top.
23
+ canvas.style.position = 'absolute';
24
+ }
25
+ var opacity = olLayer.getOpacity();
26
+ if (renderState.opacity !== opacity) {
27
+ canvas.style.opacity = opacity;
28
+ renderState.opacity = opacity;
29
+ }
30
+ // adjust view parameters in mapbox
31
+ var rotation = viewState.rotation;
32
+ if (renderState.rotation !== rotation) {
33
+ mbMap.rotateTo((-(rotation || 0) * 180) / Math.PI, {
34
+ animate: false,
35
+ });
36
+ changed = true;
37
+ renderState.rotation = rotation;
38
+ }
39
+ if (renderState.zoom !== viewState.zoom ||
40
+ renderState.center[0] !== viewState.center[0] ||
41
+ renderState.center[1] !== viewState.center[1]) {
42
+ mbMap.jumpTo({
43
+ center: (0, proj_1.toLonLat)(viewState.center),
44
+ zoom: viewState.zoom - 1,
45
+ animate: false,
46
+ });
47
+ changed = true;
48
+ renderState.zoom = viewState.zoom;
49
+ renderState.center = viewState.center;
50
+ }
51
+ var size = map.getSize();
52
+ if (renderState.size[0] !== size[0] || renderState.size[1] !== size[1]) {
53
+ changed = true;
54
+ renderState.size = size;
55
+ }
56
+ // cancel the scheduled update & trigger synchronous redraw
57
+ // see https://github.com/mapbox/mapbox-gl-js/issues/7893#issue-408992184
58
+ // NOTE: THIS MIGHT BREAK WHEN UPDATING MAPBOX
59
+ if (mbMap && mbMap.style && mbMap.isStyleLoaded() && changed) {
60
+ try {
61
+ if (mbMap._frame) {
62
+ mbMap._frame.cancel();
63
+ mbMap._frame = null;
64
+ }
65
+ mbMap._render();
66
+ }
67
+ catch (err) {
68
+ // ignore render errors because it's probably related to
69
+ // a render during an update of the style.
70
+ // eslint-disable-next-line no-console
71
+ console.warn(err);
72
+ }
73
+ }
74
+ return mbMap.getContainer();
75
+ };
76
+ }
77
+ exports.default = getMapboxRender;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Return the render function fo the olLayer of a MaplibreLayer
3
+ */
4
+ export default function getMaplibreRender(maplibreLayer: any): (frameState: any) => any;
5
+ //# sourceMappingURL=getMaplibreRender.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMaplibreRender.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getMaplibreRender.js"],"names":[],"mappings":"AAGA;;GAEG;AACH,wFAoCC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var proj_1 = require("ol/proj");
4
+ var math_1 = require("ol/math");
5
+ /**
6
+ * Return the render function fo the olLayer of a MaplibreLayer
7
+ */
8
+ function getMaplibreRender(maplibreLayer) {
9
+ return function (frameState) {
10
+ var map = maplibreLayer.map, mbMap = maplibreLayer.mbMap, olLayer = maplibreLayer.olLayer;
11
+ if (!map || !mbMap) {
12
+ return null;
13
+ }
14
+ var canvas = mbMap.getCanvas();
15
+ var viewState = frameState.viewState;
16
+ var opacity = olLayer.getOpacity();
17
+ canvas.style.opacity = opacity;
18
+ // adjust view parameters in mapbox
19
+ mbMap.jumpTo({
20
+ center: (0, proj_1.toLonLat)(viewState.center),
21
+ zoom: viewState.zoom - 1,
22
+ bearing: (0, math_1.toDegrees)(-viewState.rotation),
23
+ animate: false,
24
+ });
25
+ if (!canvas.isConnected) {
26
+ // The canvas is not connected to the DOM, request a map rendering at the next animation frame
27
+ // to set the canvas size.
28
+ map.render();
29
+ }
30
+ else if (canvas.width !== frameState.size[0] ||
31
+ canvas.height !== frameState.size[1]) {
32
+ mbMap.resize();
33
+ }
34
+ mbMap.redraw();
35
+ return mbMap.getContainer();
36
+ };
37
+ }
38
+ exports.default = getMaplibreRender;
@@ -0,0 +1,8 @@
1
+ export default getModeSuffix;
2
+ /**
3
+ * Get the websocket channel suffix, depending on the current mode.
4
+ * @param {String} mode Mode 'topographic' ou 'schematic'.
5
+ * @private
6
+ */
7
+ declare function getModeSuffix(mode: string, modes: any): "" | "_schematic";
8
+ //# sourceMappingURL=getRealtimeModeSuffix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRealtimeModeSuffix.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getRealtimeModeSuffix.js"],"names":[],"mappings":";AAAA;;;;GAIG;AACH,4EAC8C"}
@@ -1,2 +1,11 @@
1
- const getModeSuffix = (mode, modes) => mode === modes.SCHEMATIC ? "_schematic" : "";
2
- export default getModeSuffix;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Get the websocket channel suffix, depending on the current mode.
5
+ * @param {String} mode Mode 'topographic' ou 'schematic'.
6
+ * @private
7
+ */
8
+ var getModeSuffix = function (mode, modes) {
9
+ return mode === modes.SCHEMATIC ? '_schematic' : '';
10
+ };
11
+ exports.default = getModeSuffix;
@@ -0,0 +1,9 @@
1
+ export default getUrlWithParams;
2
+ /**
3
+ * Return the styleUrl with apiKey parameters set.
4
+ * @param {string} url a url.
5
+ * @param {Object<String,String>} params a list of key/value pair to add to the url.
6
+ * @ignore
7
+ */
8
+ declare function getUrlWithParams(url: string, params: any): URL;
9
+ //# sourceMappingURL=getUrlWithParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUrlWithParams.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getUrlWithParams.js"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,uCAJW,MAAM,oBAgBhB"}