mobility-toolbox-js 2.0.0-beta.45 → 2.0.0-beta.47

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 (201) hide show
  1. package/api/RealtimeAPI.d.ts +80 -64
  2. package/api/RealtimeAPI.d.ts.map +1 -1
  3. package/api/RealtimeAPI.js +58 -45
  4. package/api/RoutingAPI.d.ts +2 -2
  5. package/api/RoutingAPI.d.ts.map +1 -1
  6. package/api/RoutingAPI.js +1 -1
  7. package/api/StopsAPI.d.ts +14 -12
  8. package/api/StopsAPI.d.ts.map +1 -1
  9. package/api/StopsAPI.js +7 -9
  10. package/api/typedefs.d.ts +84 -10
  11. package/api/typedefs.d.ts.map +1 -1
  12. package/api/typedefs.js +3 -1
  13. package/common/api/WebSocketAPI.d.ts +80 -24
  14. package/common/api/WebSocketAPI.d.ts.map +1 -1
  15. package/common/api/WebSocketAPI.js +28 -16
  16. package/common/controls/{Control.d.ts → ControlCommon.d.ts} +21 -19
  17. package/common/controls/ControlCommon.d.ts.map +1 -0
  18. package/common/controls/{Control.js → ControlCommon.js} +21 -8
  19. package/common/controls/CopyrightControlCommon.d.ts +13 -0
  20. package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
  21. package/common/controls/CopyrightControlCommon.js +34 -0
  22. package/common/controls/StopFinderControlCommon.d.ts +54 -0
  23. package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
  24. package/common/{mixins/StopFinderMixin.js → controls/StopFinderControlCommon.js} +25 -38
  25. package/common/layers/{Layer.d.ts → LayerCommon.d.ts} +34 -21
  26. package/common/layers/LayerCommon.d.ts.map +1 -0
  27. package/common/layers/{Layer.js → LayerCommon.js} +15 -9
  28. package/common/mixins/RealtimeLayerMixin.d.ts +243 -19
  29. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
  30. package/common/mixins/RealtimeLayerMixin.js +598 -569
  31. package/common/mixins/UserInteractionsLayerMixin.d.ts +18 -8
  32. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -1
  33. package/common/mixins/UserInteractionsLayerMixin.js +170 -159
  34. package/common/styles/realtimeDefaultStyle.d.ts +30 -9
  35. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -1
  36. package/common/styles/realtimeDefaultStyle.js +41 -17
  37. package/common/styles/realtimeDelayStyle.d.ts +3 -2
  38. package/common/styles/realtimeDelayStyle.d.ts.map +1 -1
  39. package/common/styles/realtimeSimpleStyle.d.ts +1 -1
  40. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -1
  41. package/common/styles/realtimeSimpleStyle.js +9 -7
  42. package/common/typedefs.d.ts +64 -3
  43. package/common/typedefs.d.ts.map +1 -1
  44. package/common/typedefs.js +34 -4
  45. package/common/utils/cleanStopTime.d.ts +3 -2
  46. package/common/utils/cleanStopTime.d.ts.map +1 -1
  47. package/common/utils/cleanStopTime.js +0 -3
  48. package/common/utils/compareDepartures.d.ts +6 -4
  49. package/common/utils/compareDepartures.d.ts.map +1 -1
  50. package/common/utils/compareDepartures.js +3 -2
  51. package/common/utils/createCanvas.d.ts +3 -2
  52. package/common/utils/createCanvas.d.ts.map +1 -1
  53. package/common/utils/createTrackerFilters.d.ts +3 -2
  54. package/common/utils/createTrackerFilters.d.ts.map +1 -1
  55. package/common/utils/createTrackerFilters.js +3 -3
  56. package/common/utils/getLayersAsFlatArray.d.ts +1 -1
  57. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -1
  58. package/common/utils/getLayersAsFlatArray.js +1 -0
  59. package/common/utils/getMapboxMapCopyrights.d.ts +13 -3
  60. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -1
  61. package/common/utils/getMapboxMapCopyrights.js +10 -4
  62. package/common/utils/getMapboxRender.d.ts +3 -1
  63. package/common/utils/getMapboxRender.d.ts.map +1 -1
  64. package/common/utils/getMapboxRender.js +1 -2
  65. package/common/utils/getVehiclePosition.d.ts +1 -1
  66. package/common/utils/getVehiclePosition.d.ts.map +1 -1
  67. package/common/utils/removeDuplicate.d.ts +2 -2
  68. package/common/utils/removeDuplicate.d.ts.map +1 -1
  69. package/common/utils/renderTrajectories.d.ts +3 -6
  70. package/common/utils/renderTrajectories.d.ts.map +1 -1
  71. package/common/utils/renderTrajectories.js +17 -8
  72. package/common/utils/trackerConfig.d.ts.map +1 -1
  73. package/common/utils/trackerConfig.js +3 -0
  74. package/mapbox/controls/CopyrightControl.d.ts +6 -8
  75. package/mapbox/controls/CopyrightControl.d.ts.map +1 -1
  76. package/mapbox/controls/CopyrightControl.js +3 -8
  77. package/mapbox/layers/Layer.js +1 -1
  78. package/mapbox/layers/RealtimeLayer.d.ts +1 -1
  79. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -1
  80. package/mapbox/utils.d.ts +1 -1
  81. package/mapbox/utils.d.ts.map +1 -1
  82. package/mbt.js +825 -703
  83. package/mbt.js.map +3 -3
  84. package/mbt.min.js +84 -84
  85. package/mbt.min.js.map +3 -3
  86. package/ol/controls/CopyrightControl.d.ts +10 -10
  87. package/ol/controls/CopyrightControl.d.ts.map +1 -1
  88. package/ol/controls/CopyrightControl.js +8 -8
  89. package/ol/controls/RoutingControl.d.ts +10 -3
  90. package/ol/controls/RoutingControl.d.ts.map +1 -1
  91. package/ol/controls/RoutingControl.js +2 -2
  92. package/ol/controls/StopFinderControl.d.ts +5 -7
  93. package/ol/controls/StopFinderControl.d.ts.map +1 -1
  94. package/ol/controls/StopFinderControl.js +4 -8
  95. package/ol/layers/Layer.d.ts +57 -9
  96. package/ol/layers/Layer.d.ts.map +1 -1
  97. package/ol/layers/Layer.js +17 -8
  98. package/ol/layers/MapGlLayer.d.ts +67 -0
  99. package/ol/layers/MapGlLayer.d.ts.map +1 -0
  100. package/{common/mixins/MapboxLayerMixin.js → ol/layers/MapGlLayer.js} +66 -44
  101. package/ol/layers/MapboxLayer.d.ts +15 -17
  102. package/ol/layers/MapboxLayer.d.ts.map +1 -1
  103. package/ol/layers/MapboxLayer.js +11 -8
  104. package/ol/layers/MapboxStyleLayer.d.ts +6 -0
  105. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -1
  106. package/ol/layers/MaplibreLayer.d.ts +4 -4
  107. package/ol/layers/MaplibreLayer.d.ts.map +1 -1
  108. package/ol/layers/MaplibreLayer.js +2 -3
  109. package/ol/layers/RealtimeLayer.d.ts +106 -30
  110. package/ol/layers/RealtimeLayer.d.ts.map +1 -1
  111. package/ol/layers/RealtimeLayer.js +22 -14
  112. package/ol/styles/fullTrajectoryStyle.d.ts +3 -2
  113. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
  114. package/package.json +15 -9
  115. package/types/common.d.ts +111 -0
  116. package/types/index.d.ts +1 -0
  117. package/types/realtime.d.ts +290 -9
  118. package/api/RealtimeAPI.test.d.ts +0 -2
  119. package/api/RealtimeAPI.test.d.ts.map +0 -1
  120. package/api/RealtimeAPI.test.js +0 -67
  121. package/api/RoutingAPI.test.d.ts +0 -2
  122. package/api/RoutingAPI.test.d.ts.map +0 -1
  123. package/api/RoutingAPI.test.js +0 -29
  124. package/api/StopsAPI.test.d.ts +0 -2
  125. package/api/StopsAPI.test.d.ts.map +0 -1
  126. package/api/StopsAPI.test.js +0 -26
  127. package/common/api/HttpAPI.test.d.ts +0 -2
  128. package/common/api/HttpAPI.test.d.ts.map +0 -1
  129. package/common/api/HttpAPI.test.js +0 -54
  130. package/common/api/WebSocketAPI.test.d.ts +0 -2
  131. package/common/api/WebSocketAPI.test.d.ts.map +0 -1
  132. package/common/api/WebSocketAPI.test.js +0 -380
  133. package/common/controls/Control.d.ts.map +0 -1
  134. package/common/controls/Control.test.d.ts +0 -2
  135. package/common/controls/Control.test.d.ts.map +0 -1
  136. package/common/controls/Control.test.js +0 -89
  137. package/common/layers/Layer.d.ts.map +0 -1
  138. package/common/layers/Layer.test.d.ts +0 -2
  139. package/common/layers/Layer.test.d.ts.map +0 -1
  140. package/common/layers/Layer.test.js +0 -137
  141. package/common/mixins/CopyrightMixin.d.ts +0 -22
  142. package/common/mixins/CopyrightMixin.d.ts.map +0 -1
  143. package/common/mixins/CopyrightMixin.js +0 -43
  144. package/common/mixins/MapboxLayerMixin.d.ts +0 -27
  145. package/common/mixins/MapboxLayerMixin.d.ts.map +0 -1
  146. package/common/mixins/StopFinderMixin.d.ts +0 -40
  147. package/common/mixins/StopFinderMixin.d.ts.map +0 -1
  148. package/common/mixins/UserInteractionsLayerMixin.test.d.ts +0 -2
  149. package/common/mixins/UserInteractionsLayerMixin.test.d.ts.map +0 -1
  150. package/common/mixins/UserInteractionsLayerMixin.test.js +0 -214
  151. package/common/utils/createTrackerFilters.test.d.ts +0 -2
  152. package/common/utils/createTrackerFilters.test.d.ts.map +0 -1
  153. package/common/utils/createTrackerFilters.test.js +0 -79
  154. package/common/utils/getMapboxMapCopyrights.test.d.ts +0 -2
  155. package/common/utils/getMapboxMapCopyrights.test.d.ts.map +0 -1
  156. package/common/utils/getMapboxMapCopyrights.test.js +0 -40
  157. package/common/utils/removeDuplicate.test.d.ts +0 -2
  158. package/common/utils/removeDuplicate.test.d.ts.map +0 -1
  159. package/common/utils/removeDuplicate.test.js +0 -19
  160. package/common/utils/timeUtils.test.d.ts +0 -2
  161. package/common/utils/timeUtils.test.d.ts.map +0 -1
  162. package/common/utils/timeUtils.test.js +0 -10
  163. package/common/utils/trackerConfig.test.d.ts +0 -2
  164. package/common/utils/trackerConfig.test.d.ts.map +0 -1
  165. package/common/utils/trackerConfig.test.js +0 -23
  166. package/mapbox/layers/Layer.test.d.ts +0 -2
  167. package/mapbox/layers/Layer.test.d.ts.map +0 -1
  168. package/mapbox/layers/Layer.test.js +0 -204
  169. package/mapbox/layers/RealtimeLayer.test.d.ts +0 -2
  170. package/mapbox/layers/RealtimeLayer.test.d.ts.map +0 -1
  171. package/mapbox/layers/RealtimeLayer.test.js +0 -10
  172. package/ol/controls/CopyrightControl.test.d.ts +0 -2
  173. package/ol/controls/CopyrightControl.test.d.ts.map +0 -1
  174. package/ol/controls/CopyrightControl.test.js +0 -177
  175. package/ol/controls/RoutingControl.test.d.ts +0 -2
  176. package/ol/controls/RoutingControl.test.d.ts.map +0 -1
  177. package/ol/controls/RoutingControl.test.js +0 -150
  178. package/ol/controls/StopFinderControl.test.d.ts +0 -2
  179. package/ol/controls/StopFinderControl.test.d.ts.map +0 -1
  180. package/ol/controls/StopFinderControl.test.js +0 -49
  181. package/ol/layers/Layer.test.d.ts +0 -2
  182. package/ol/layers/Layer.test.d.ts.map +0 -1
  183. package/ol/layers/Layer.test.js +0 -196
  184. package/ol/layers/MapboxLayer.test.d.ts +0 -2
  185. package/ol/layers/MapboxLayer.test.d.ts.map +0 -1
  186. package/ol/layers/MapboxLayer.test.js +0 -164
  187. package/ol/layers/MapboxStyleLayer.test.d.ts +0 -2
  188. package/ol/layers/MapboxStyleLayer.test.d.ts.map +0 -1
  189. package/ol/layers/MapboxStyleLayer.test.js +0 -232
  190. package/ol/layers/RealtimeLayer.test.d.ts +0 -2
  191. package/ol/layers/RealtimeLayer.test.d.ts.map +0 -1
  192. package/ol/layers/RealtimeLayer.test.js +0 -71
  193. package/ol/layers/RoutingLayer.test.d.ts +0 -2
  194. package/ol/layers/RoutingLayer.test.d.ts.map +0 -1
  195. package/ol/layers/RoutingLayer.test.js +0 -39
  196. package/ol/layers/VectorLayer.test.d.ts +0 -2
  197. package/ol/layers/VectorLayer.test.d.ts.map +0 -1
  198. package/ol/layers/VectorLayer.test.js +0 -87
  199. package/ol/layers/WMSLayer.test.d.ts +0 -2
  200. package/ol/layers/WMSLayer.test.d.ts.map +0 -1
  201. package/ol/layers/WMSLayer.test.js +0 -66
package/mbt.js CHANGED
@@ -33912,7 +33912,7 @@ uniform ${i3} ${o3} u_${a3};
33912
33912
 
33913
33913
  // src/api/RoutingAPI.ts
33914
33914
  var RoutingAPI = class extends HttpAPI_default {
33915
- constructor(options) {
33915
+ constructor(options = {}) {
33916
33916
  super({ url: "https://api.geops.io/routing/v1/", ...options });
33917
33917
  }
33918
33918
  route(params, config) {
@@ -33921,20 +33921,18 @@ uniform ${i3} ${o3} u_${a3};
33921
33921
  };
33922
33922
  var RoutingAPI_default = RoutingAPI;
33923
33923
 
33924
- // src/api/StopsAPI.js
33924
+ // src/api/StopsAPI.ts
33925
33925
  var StopsAPI = class extends HttpAPI_default {
33926
33926
  constructor(options = {}) {
33927
33927
  super({ url: "https://api.geops.io/stops/v1/", ...options });
33928
33928
  }
33929
- search(params, abortController = {}) {
33930
- return this.fetch("", params, {
33931
- signal: abortController.signal
33932
- });
33929
+ search(params, config) {
33930
+ return this.fetch("", params, config);
33933
33931
  }
33934
33932
  };
33935
33933
  var StopsAPI_default = StopsAPI;
33936
33934
 
33937
- // src/common/api/WebSocketAPI.js
33935
+ // src/common/api/WebSocketAPI.ts
33938
33936
  var WebSocketAPI = class {
33939
33937
  constructor() {
33940
33938
  this.defineProperties();
@@ -33967,7 +33965,7 @@ uniform ${i3} ${o3} u_${a3};
33967
33965
  }
33968
33966
  });
33969
33967
  }
33970
- static getRequestString(method, params) {
33968
+ static getRequestString(method, params = {}) {
33971
33969
  let reqStr = `${method} ${params.channel}`;
33972
33970
  reqStr += params.args ? ` ${params.args}` : "";
33973
33971
  reqStr += params.id ? ` ${params.id}` : "";
@@ -33993,7 +33991,7 @@ uniform ${i3} ${o3} u_${a3};
33993
33991
  if (this.websocket) {
33994
33992
  this.websocket.onclose = null;
33995
33993
  this.websocket.close();
33996
- this.websocket = null;
33994
+ this.websocket = void 0;
33997
33995
  this.messagesOnOpen = [];
33998
33996
  }
33999
33997
  }
@@ -34002,7 +34000,7 @@ uniform ${i3} ${o3} u_${a3};
34002
34000
  return;
34003
34001
  }
34004
34002
  const send = () => {
34005
- this.websocket.send(message);
34003
+ this.websocket?.send(message);
34006
34004
  };
34007
34005
  if (!this.open) {
34008
34006
  if (!this.messagesOnOpen.includes(message)) {
@@ -34038,17 +34036,23 @@ uniform ${i3} ${o3} u_${a3};
34038
34036
  }
34039
34037
  }
34040
34038
  listen(params, cb, errorCb) {
34041
- this.unlisten(params, cb, errorCb);
34039
+ this.unlisten(params, cb);
34042
34040
  const onMessage = (evt) => {
34043
- let data = {};
34041
+ let data;
34044
34042
  try {
34045
34043
  data = JSON.parse(evt.data);
34046
34044
  } catch (err) {
34047
34045
  console.error("WebSocket: unable to parse JSON data", err, evt.data);
34046
+ return;
34048
34047
  }
34049
34048
  let source = params.channel;
34050
34049
  source += params.args ? ` ${params.args}` : "";
34051
- const contents = data.source === "buffer" ? data.content : [data];
34050
+ let contents;
34051
+ if (data.source === "buffer") {
34052
+ contents = data.content;
34053
+ } else {
34054
+ contents = [data];
34055
+ }
34052
34056
  contents.forEach((content) => {
34053
34057
  if (content?.source === source && (!params.id || params.id === data.client_reference)) {
34054
34058
  cb(content);
@@ -34073,7 +34077,7 @@ uniform ${i3} ${o3} u_${a3};
34073
34077
  this.removeEvents(onMessageCb2, onErrorCb2);
34074
34078
  this.requests.splice(index2, 1);
34075
34079
  };
34076
- const { onMessageCb, onErrorCb } = this.listen(params, once(cb), once(errorCb));
34080
+ const { onMessageCb, onErrorCb } = this.listen(params, once(cb), errorCb && once(errorCb));
34077
34081
  if (!this.requests) {
34078
34082
  this.requests = [];
34079
34083
  }
@@ -34132,11 +34136,8 @@ uniform ${i3} ${o3} u_${a3};
34132
34136
  };
34133
34137
  var WebSocketAPI_default = WebSocketAPI;
34134
34138
 
34135
- // src/common/utils/cleanStopTime.js
34139
+ // src/common/utils/cleanStopTime.ts
34136
34140
  var cleanStopTime = (content) => {
34137
- if (!content) {
34138
- return;
34139
- }
34140
34141
  content.stations.forEach((station) => {
34141
34142
  station.arrivalTimeWithDelay = station.arrivalTime;
34142
34143
  if (station.departureTime) {
@@ -34157,7 +34158,7 @@ uniform ${i3} ${o3} u_${a3};
34157
34158
  var getModeSuffix = (mode, modes) => mode === modes.SCHEMATIC ? "_schematic" : "";
34158
34159
  var getRealtimeModeSuffix_default = getModeSuffix;
34159
34160
 
34160
- // src/common/utils/compareDepartures.js
34161
+ // src/common/utils/compareDepartures.ts
34161
34162
  var compareDepartures = (a, b, sortByMinArrivalTime = false) => {
34162
34163
  const topStates = ["HIDDEN", "LEAVING", "BOARDING"];
34163
34164
  const aTop = a.has_fzo && topStates.indexOf(a.state) > -1;
@@ -34184,7 +34185,7 @@ uniform ${i3} ${o3} u_${a3};
34184
34185
  };
34185
34186
  var compareDepartures_default = compareDepartures;
34186
34187
 
34187
- // src/api/RealtimeAPI.js
34188
+ // src/api/RealtimeAPI.ts
34188
34189
  var RealtimeModes = {
34189
34190
  RAW: "raw",
34190
34191
  TOPOGRAPHIC: "topographic",
@@ -34193,8 +34194,8 @@ uniform ${i3} ${o3} u_${a3};
34193
34194
  var RealtimeAPI = class {
34194
34195
  constructor(options = {}) {
34195
34196
  this.defineProperties(options);
34196
- this.subscribedStationUic = null;
34197
- this.departureUpdateTimeout = null;
34197
+ this.subscribedStationUic = void 0;
34198
+ this.departureUpdateTimeout = void 0;
34198
34199
  this.maxDepartureAge = 30;
34199
34200
  this.extraGeoms = {};
34200
34201
  this.prefix = options.prefix || "";
@@ -34235,7 +34236,7 @@ uniform ${i3} ${o3} u_${a3};
34235
34236
  set: (newBbox) => {
34236
34237
  if (JSON.stringify(newBbox) !== JSON.stringify(bbox)) {
34237
34238
  bbox = newBbox;
34238
- if (this.wsApi) {
34239
+ if (this.wsApi && bbox) {
34239
34240
  this.wsApi.send(`BBOX ${bbox.join(" ")}`);
34240
34241
  }
34241
34242
  }
@@ -34269,9 +34270,11 @@ uniform ${i3} ${o3} u_${a3};
34269
34270
  open() {
34270
34271
  this.close();
34271
34272
  this.wsApi.connect(this.url, this.onOpen);
34272
- this.wsApi.websocket.onclose = () => {
34273
- this.onClose();
34274
- };
34273
+ if (this.wsApi.websocket) {
34274
+ this.wsApi.websocket.onclose = () => {
34275
+ this.onClose();
34276
+ };
34277
+ }
34275
34278
  }
34276
34279
  close() {
34277
34280
  this.wsApi.close();
@@ -34291,7 +34294,7 @@ uniform ${i3} ${o3} u_${a3};
34291
34294
  }
34292
34295
  if (this.pingIntervalMs) {
34293
34296
  window.clearInterval(this.pingInterval);
34294
- this.pingInterval = setInterval(() => {
34297
+ this.pingInterval = window.setInterval(() => {
34295
34298
  this.wsApi.send("PING");
34296
34299
  }, this.pingIntervalMs);
34297
34300
  }
@@ -34304,44 +34307,49 @@ uniform ${i3} ${o3} u_${a3};
34304
34307
  }
34305
34308
  }
34306
34309
  subscribe(channel, onSuccess, onError, quiet = false) {
34310
+ if (!channel || !onSuccess) {
34311
+ return;
34312
+ }
34307
34313
  this.wsApi.subscribe({ channel }, onSuccess, onError, quiet);
34308
34314
  }
34309
- unsubscribe(channel, suffix, cb) {
34315
+ unsubscribe(channel, suffix = "", cb) {
34310
34316
  this.wsApi.unsubscribe(`${channel}${getRealtimeModeSuffix_default(RealtimeModes.SCHEMATIC, RealtimeModes)}${suffix}`, cb);
34311
34317
  this.wsApi.unsubscribe(`${channel}${getRealtimeModeSuffix_default(RealtimeModes.TOPOGRAPHIC, RealtimeModes)}${suffix || ""}`, cb);
34312
34318
  }
34313
34319
  filterDepartures(depObject, sortByMinArrivalTime = false) {
34314
34320
  const departures = Object.keys(depObject).map((k) => depObject[k]);
34315
34321
  departures.sort((a, b) => compareDepartures_default(a, b, sortByMinArrivalTime));
34316
- let future = new Date();
34317
- future.setMinutes(future.getMinutes() + this.maxDepartureAge);
34318
- future = future.getTime();
34319
- let past = new Date();
34320
- past.setMinutes(past.getMinutes() - this.maxDepartureAge);
34321
- past = past.getTime();
34322
+ const futureDate = new Date();
34323
+ futureDate.setMinutes(futureDate.getMinutes() + this.maxDepartureAge);
34324
+ const future = futureDate.getTime();
34325
+ const pastDate = new Date();
34326
+ pastDate.setMinutes(pastDate.getMinutes() - this.maxDepartureAge);
34327
+ const past = pastDate.getTime();
34322
34328
  const departureArray = [];
34323
34329
  const platformsBoarding = [];
34324
34330
  let previousDeparture = null;
34325
34331
  for (let i = departures.length - 1; i >= 0; i -= 1) {
34326
- const d = departures[i];
34327
- const t = new Date(d.time).getTime();
34328
- if (t > past && t < future) {
34329
- if (d.state === "BOARDING") {
34330
- if (platformsBoarding.indexOf(d.platform) === -1) {
34331
- platformsBoarding.push(d.platform);
34332
+ const departure = {
34333
+ ...departures[i]
34334
+ };
34335
+ const time = new Date(departure.time).getTime();
34336
+ if (time > past && time < future) {
34337
+ if (departure.state === "BOARDING") {
34338
+ if (platformsBoarding.indexOf(departure.platform) === -1) {
34339
+ platformsBoarding.push(departure.platform);
34332
34340
  } else {
34333
- d.state = "HIDDEN";
34341
+ departure.state = "HIDDEN";
34334
34342
  }
34335
34343
  }
34336
- if (previousDeparture && d.to[0] === previousDeparture.to[0] && Math.abs(t - previousDeparture.time) < 1e3 && d.line.name === previousDeparture.line.name) {
34337
- d.state = "HIDDEN";
34344
+ if (previousDeparture && departure.to[0] === previousDeparture.to[0] && Math.abs(time - previousDeparture.time) < 1e3 && departure.line.name === previousDeparture.line.name) {
34345
+ departure.state = "HIDDEN";
34338
34346
  }
34339
- if (/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(d.state)) {
34340
- d.cancelled = true;
34347
+ if (/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(departure.state)) {
34348
+ departure.cancelled = true;
34341
34349
  }
34342
- previousDeparture = d;
34343
- previousDeparture.time = t;
34344
- departureArray.unshift(d);
34350
+ previousDeparture = departure;
34351
+ previousDeparture.time = time;
34352
+ departureArray.unshift(departure);
34345
34353
  }
34346
34354
  }
34347
34355
  return departureArray;
@@ -34352,26 +34360,29 @@ uniform ${i3} ${o3} u_${a3};
34352
34360
  this.subscribedStationUic = stationId;
34353
34361
  const channel = stationId ? `timetable_${stationId}` : null;
34354
34362
  const departureObject = {};
34355
- this.subscribe(channel, (data) => {
34363
+ if (!channel) {
34364
+ return;
34365
+ }
34366
+ const onSuccess = (data) => {
34356
34367
  if (data.source === channel) {
34357
34368
  const content = data.content || {};
34358
34369
  const tDiff = new Date(content.timestamp).getTime() - Date.now();
34359
- content.timediff = tDiff;
34360
- departureObject[content.call_id] = content;
34370
+ departureObject[content.call_id] = { ...content, timediff: tDiff };
34361
34371
  window.clearTimeout(this.departureUpdateTimeout);
34362
34372
  this.departureUpdateTimeout = window.setTimeout(() => {
34363
34373
  const departures = this.filterDepartures(departureObject, sortByMinArrivalTime || false);
34364
34374
  onMessage(departures);
34365
34375
  }, 100);
34366
34376
  }
34367
- }, () => {
34377
+ };
34378
+ this.subscribe(channel, onSuccess, () => {
34368
34379
  onMessage([]);
34369
34380
  });
34370
34381
  }
34371
34382
  unsubscribeDepartures(cb) {
34372
34383
  if (this.subscribedStationUic) {
34373
34384
  this.unsubscribe(`timetable_${this.subscribedStationUic}`, "", cb);
34374
- this.subscribedStationUic = null;
34385
+ this.subscribedStationUic = void 0;
34375
34386
  }
34376
34387
  }
34377
34388
  subscribeDisruptions(onMessage) {
@@ -34448,14 +34459,14 @@ uniform ${i3} ${o3} u_${a3};
34448
34459
  }
34449
34460
  subscribeTrajectory(mode, onMessage, quiet = false) {
34450
34461
  this.unsubscribeTrajectory(onMessage);
34451
- this.subscribe(`trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}`, onMessage, null, quiet);
34462
+ this.subscribe(`trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}`, onMessage, void 0, quiet);
34452
34463
  }
34453
34464
  unsubscribeTrajectory(cb) {
34454
34465
  this.unsubscribe(`trajectory`, "", cb);
34455
34466
  }
34456
34467
  subscribeDeletedVehicles(mode, onMessage, quiet = false) {
34457
34468
  this.unsubscribeDeletedVehicles(onMessage);
34458
- this.subscribe(`deleted_vehicles${getRealtimeModeSuffix_default(mode, RealtimeModes)}`, onMessage, null, quiet);
34469
+ this.subscribe(`deleted_vehicles${getRealtimeModeSuffix_default(mode, RealtimeModes)}`, onMessage, void 0, quiet);
34459
34470
  }
34460
34471
  unsubscribeDeletedVehicles(cb) {
34461
34472
  this.unsubscribe("deleted_vehicles", "", cb);
@@ -34500,9 +34511,10 @@ uniform ${i3} ${o3} u_${a3};
34500
34511
  };
34501
34512
  return new Promise((resolve, reject) => {
34502
34513
  this.wsApi.get(params, (data) => {
34503
- if (data.content && data.content.length) {
34504
- const content = data.content.map((stopSequence) => cleanStopTime_default(stopSequence));
34505
- resolve(content);
34514
+ const content = data.content;
34515
+ if (content && content.length) {
34516
+ const stopSequences = content.map((stopSequence) => cleanStopTime_default(stopSequence));
34517
+ resolve(stopSequences);
34506
34518
  }
34507
34519
  resolve([]);
34508
34520
  }, (err) => {
@@ -34518,9 +34530,10 @@ uniform ${i3} ${o3} u_${a3};
34518
34530
  window.clearTimeout(this.fullTrajectoryUpdateTimeout);
34519
34531
  this.unsubscribeStopSequence(id);
34520
34532
  this.subscribe(`stopsequence_${id}`, (data) => {
34521
- if (data.content && data.content.length) {
34522
- const content = data.content.map((stopSequence) => cleanStopTime_default(stopSequence));
34523
- onMessage(content);
34533
+ const content = data.content;
34534
+ if (content && content.length) {
34535
+ const stopSequences = content.map((stopSequence) => cleanStopTime_default(stopSequence));
34536
+ onMessage(stopSequences);
34524
34537
  }
34525
34538
  }, (err) => {
34526
34539
  console.log("subscribe stopsequence error", err);
@@ -34539,7 +34552,7 @@ uniform ${i3} ${o3} u_${a3};
34539
34552
  };
34540
34553
  var RealtimeAPI_default = RealtimeAPI;
34541
34554
 
34542
- // src/common/utils/removeDuplicate.js
34555
+ // src/common/utils/removeDuplicate.ts
34543
34556
  var removeDuplicate = (array) => {
34544
34557
  const arrWithoutEmptyValues = array.filter((val) => val !== void 0 && val !== null && val.trim && val.trim());
34545
34558
  const lowerCasesValues = arrWithoutEmptyValues.map((str) => str.toLowerCase());
@@ -34549,12 +34562,16 @@ uniform ${i3} ${o3} u_${a3};
34549
34562
  };
34550
34563
  var removeDuplicate_default = removeDuplicate;
34551
34564
 
34552
- // src/common/utils/getMapboxMapCopyrights.js
34565
+ // src/common/utils/getMapboxMapCopyrights.ts
34553
34566
  var getMapboxMapCopyrights = (map) => {
34554
- if (!map || !map.style) {
34567
+ if (!map) {
34555
34568
  return [];
34556
34569
  }
34557
- const { sourceCaches } = map.style;
34570
+ const { style } = map;
34571
+ if (!style) {
34572
+ return [];
34573
+ }
34574
+ const { sourceCaches } = style;
34558
34575
  let copyrights = [];
34559
34576
  Object.values(sourceCaches).forEach((sourceCache) => {
34560
34577
  if (sourceCache.used) {
@@ -34569,7 +34586,7 @@ uniform ${i3} ${o3} u_${a3};
34569
34586
  };
34570
34587
  var getMapboxMapCopyrights_default = getMapboxMapCopyrights;
34571
34588
 
34572
- // src/common/utils/createTrackerFilters.js
34589
+ // src/common/utils/createTrackerFilters.ts
34573
34590
  var createFilters = (line, route, operator, regexLine) => {
34574
34591
  const filterList = [];
34575
34592
  if (!line && !route && !operator && !regexLine) {
@@ -34610,15 +34627,15 @@ uniform ${i3} ${o3} u_${a3};
34610
34627
  }
34611
34628
  if (operator) {
34612
34629
  const operatorList = typeof operator === "string" ? [operator] : operator;
34613
- const operatorFilter = (item) => operatorList.some((op) => new RegExp(op, "i").test(item.properties.operator));
34630
+ const operatorFilter = (item) => operatorList.some((op) => new RegExp(op, "i").test(item.properties.operator || ""));
34614
34631
  filterList.push(operatorFilter);
34615
34632
  }
34616
34633
  if (!filterList.length) {
34617
34634
  return null;
34618
34635
  }
34619
- return (t) => {
34636
+ return (item) => {
34620
34637
  for (let i = 0; i < filterList.length; i += 1) {
34621
- if (!filterList[i](t)) {
34638
+ if (!filterList[i](item)) {
34622
34639
  return false;
34623
34640
  }
34624
34641
  }
@@ -34627,7 +34644,7 @@ uniform ${i3} ${o3} u_${a3};
34627
34644
  };
34628
34645
  var createTrackerFilters_default = createFilters;
34629
34646
 
34630
- // src/common/utils/getLayersAsFlatArray.js
34647
+ // src/common/utils/getLayersAsFlatArray.ts
34631
34648
  var getLayersAsFlatArray = (layersOrLayer) => {
34632
34649
  let layers = layersOrLayer;
34633
34650
  if (!Array.isArray(layers)) {
@@ -34888,10 +34905,10 @@ uniform ${i3} ${o3} u_${a3};
34888
34905
  };
34889
34906
  var getVehiclePosition_default = getVehiclePosition;
34890
34907
 
34891
- // src/common/utils/renderTrajectories.js
34908
+ // src/common/utils/renderTrajectories.ts
34892
34909
  var renderTrajectories = (canvas2, trajectories, style, viewState, options) => {
34893
34910
  if (!canvas2) {
34894
- return {};
34911
+ return { renderedTrajectories: [] };
34895
34912
  }
34896
34913
  const {
34897
34914
  time = Date.now(),
@@ -34899,11 +34916,14 @@ uniform ${i3} ${o3} u_${a3};
34899
34916
  center,
34900
34917
  resolution,
34901
34918
  rotation = 0,
34902
- pixelRatio
34919
+ pixelRatio = 1
34903
34920
  } = viewState;
34921
+ if (!resolution || !center) {
34922
+ return { renderedTrajectories: [] };
34923
+ }
34904
34924
  const { noInterpolate = false, hoverVehicleId, selectedVehicleId } = options;
34905
34925
  const context = canvas2.getContext("2d");
34906
- context.clearRect(0, 0, canvas2.width, canvas2.height);
34926
+ context?.clearRect(0, 0, canvas2.width, canvas2.height);
34907
34927
  const [width, height] = size;
34908
34928
  if (width && height && (canvas2.width !== width || canvas2.height !== height)) {
34909
34929
  [canvas2.width, canvas2.height] = [width * pixelRatio, height * pixelRatio];
@@ -34946,7 +34966,7 @@ uniform ${i3} ${o3} u_${a3};
34946
34966
  const imgWidth = vehicleImg.width;
34947
34967
  const imgHeight = vehicleImg.height;
34948
34968
  if (hoverVehicleId !== id && selectedVehicleId !== id) {
34949
- context.drawImage(vehicleImg, px[0] - imgWidth / 2, px[1] - imgHeight / 2, imgWidth, imgHeight);
34969
+ context?.drawImage(vehicleImg, px[0] - imgWidth / 2, px[1] - imgHeight / 2, imgWidth, imgHeight);
34950
34970
  }
34951
34971
  if (hoverVehicleId && hoverVehicleId === id) {
34952
34972
  hoverVehicleImg = vehicleImg;
@@ -34962,11 +34982,11 @@ uniform ${i3} ${o3} u_${a3};
34962
34982
  }
34963
34983
  renderedTrajectories.push(trajectory);
34964
34984
  }
34965
- if (selectedVehicleImg) {
34966
- context.drawImage(selectedVehicleImg, selectedVehiclePx[0] - selectedVehicleWidth / 2, selectedVehiclePx[1] - selectedVehicleHeight / 2, selectedVehicleWidth, selectedVehicleHeight);
34985
+ if (selectedVehicleImg && selectedVehiclePx && selectedVehicleWidth && selectedVehicleHeight) {
34986
+ context?.drawImage(selectedVehicleImg, selectedVehiclePx[0] - selectedVehicleWidth / 2, selectedVehiclePx[1] - selectedVehicleHeight / 2, selectedVehicleWidth, selectedVehicleHeight);
34967
34987
  }
34968
- if (hoverVehicleImg) {
34969
- context.drawImage(hoverVehicleImg, hoverVehiclePx[0] - hoverVehicleWidth / 2, hoverVehiclePx[1] - hoverVehicleHeight / 2, hoverVehicleWidth, hoverVehicleHeight);
34988
+ if (hoverVehicleImg && hoverVehiclePx && hoverVehicleWidth && hoverVehicleHeight) {
34989
+ context?.drawImage(hoverVehicleImg, hoverVehiclePx[0] - hoverVehicleWidth / 2, hoverVehiclePx[1] - hoverVehicleHeight / 2, hoverVehicleWidth, hoverVehicleHeight);
34970
34990
  }
34971
34991
  return {
34972
34992
  renderedTrajectories
@@ -35866,7 +35886,7 @@ uniform ${i3} ${o3} u_${a3};
35866
35886
  };
35867
35887
  }
35868
35888
 
35869
- // src/common/utils/getMapboxRender.js
35889
+ // src/common/utils/getMapboxRender.ts
35870
35890
  function getMapboxRender(mapoxLayer) {
35871
35891
  return (frameState) => {
35872
35892
  const { map, mbMap, renderState, olLayer } = mapoxLayer;
@@ -35905,7 +35925,7 @@ uniform ${i3} ${o3} u_${a3};
35905
35925
  renderState.zoom = viewState.zoom;
35906
35926
  renderState.center = viewState.center;
35907
35927
  }
35908
- const size = map.getSize();
35928
+ const size = map.getSize() || [0, 0];
35909
35929
  if (renderState.size[0] !== size[0] || renderState.size[1] !== size[1]) {
35910
35930
  changed = true;
35911
35931
  renderState.size = size;
@@ -36018,6 +36038,9 @@ uniform ${i3} ${o3} u_${a3};
36018
36038
  }
36019
36039
  };
36020
36040
  var getTextSize = (ctx, markerSize, text, fontSize) => {
36041
+ if (!ctx) {
36042
+ return 0;
36043
+ }
36021
36044
  ctx.font = `bold ${fontSize}px Arial`;
36022
36045
  let newText = ctx.measureText(text);
36023
36046
  const maxiter = 25;
@@ -36069,7 +36092,7 @@ uniform ${i3} ${o3} u_${a3};
36069
36092
  return "";
36070
36093
  };
36071
36094
 
36072
- // src/common/utils/createCanvas.js
36095
+ // src/common/utils/createCanvas.ts
36073
36096
  var createCanvas = (width, height) => {
36074
36097
  let canvas2 = null;
36075
36098
  if (typeof window === "undefined") {
@@ -36088,7 +36111,7 @@ uniform ${i3} ${o3} u_${a3};
36088
36111
  };
36089
36112
  var createCanvas_default = createCanvas;
36090
36113
 
36091
- // src/common/styles/realtimeDefaultStyle.js
36114
+ // src/common/styles/realtimeDefaultStyle.ts
36092
36115
  var cacheDelayBg = {};
36093
36116
  var getDelayBgCanvas = (origin, radius, color) => {
36094
36117
  const key = `${origin}, ${radius}, ${color}`;
@@ -36096,6 +36119,9 @@ uniform ${i3} ${o3} u_${a3};
36096
36119
  const canvas2 = createCanvas_default(origin * 2, origin * 2);
36097
36120
  if (canvas2) {
36098
36121
  const ctx = canvas2.getContext("2d");
36122
+ if (!ctx) {
36123
+ return null;
36124
+ }
36099
36125
  ctx.beginPath();
36100
36126
  ctx.arc(origin, origin, radius, 0, 2 * Math.PI, false);
36101
36127
  ctx.fillStyle = color;
@@ -36113,6 +36139,9 @@ uniform ${i3} ${o3} u_${a3};
36113
36139
  const canvas2 = createCanvas_default(width, fontSize + 8 * pixelRatio);
36114
36140
  if (canvas2) {
36115
36141
  const ctx = canvas2.getContext("2d");
36142
+ if (!ctx) {
36143
+ return null;
36144
+ }
36116
36145
  ctx.textAlign = "left";
36117
36146
  ctx.textBaseline = "middle";
36118
36147
  ctx.font = font;
@@ -36134,6 +36163,9 @@ uniform ${i3} ${o3} u_${a3};
36134
36163
  const canvas2 = createCanvas_default(origin * 2, origin * 2);
36135
36164
  if (canvas2) {
36136
36165
  const ctx = canvas2.getContext("2d");
36166
+ if (!ctx) {
36167
+ return null;
36168
+ }
36137
36169
  ctx.fillStyle = color;
36138
36170
  if (hasStroke) {
36139
36171
  ctx.lineWidth = 1 * pixelRatio;
@@ -36160,6 +36192,9 @@ uniform ${i3} ${o3} u_${a3};
36160
36192
  const canvas2 = createCanvas_default(origin * 2, origin * 2);
36161
36193
  if (canvas2) {
36162
36194
  const ctx = canvas2.getContext("2d");
36195
+ if (!ctx) {
36196
+ return null;
36197
+ }
36163
36198
  if (hasStroke) {
36164
36199
  ctx.save();
36165
36200
  ctx.textBaseline = "middle";
@@ -36189,14 +36224,14 @@ uniform ${i3} ${o3} u_${a3};
36189
36224
  useDelayStyle,
36190
36225
  delayOutlineColor = "#000",
36191
36226
  delayDisplay = 3e5,
36192
- getRadius: getRadius2,
36193
- getBgColor: getBgColor2,
36194
- getDelayColor: getDelayColor2,
36195
- getDelayText: getDelayText2,
36196
- getTextColor: getTextColor2,
36197
- getTextSize: getTextSize2
36227
+ getRadius: getRadius2 = () => 0,
36228
+ getBgColor: getBgColor2 = () => "#000",
36229
+ getDelayColor: getDelayColor2 = () => "#000",
36230
+ getDelayText: getDelayText2 = () => null,
36231
+ getTextColor: getTextColor2 = () => "#000",
36232
+ getTextSize: getTextSize2 = () => 0
36198
36233
  } = options;
36199
- const { zoom, pixelRatio } = viewState;
36234
+ const { zoom, pixelRatio = 1 } = viewState;
36200
36235
  let { type } = trajectory.properties;
36201
36236
  const {
36202
36237
  train_id: id,
@@ -36223,8 +36258,8 @@ uniform ${i3} ${o3} u_${a3};
36223
36258
  textColor = `#${textColor}`;
36224
36259
  }
36225
36260
  const z = Math.min(Math.floor(zoom || 1), 16);
36226
- const hover = hoverVehicleId && hoverVehicleId === id;
36227
- const selected = selectedVehicleId && selectedVehicleId === id;
36261
+ const hover = !!(hoverVehicleId && hoverVehicleId === id);
36262
+ const selected = !!(selectedVehicleId && selectedVehicleId === id);
36228
36263
  let radius = getRadius2(type, z) * pixelRatio;
36229
36264
  const isDisplayStrokeAndDelay = radius >= 7 * pixelRatio;
36230
36265
  if (hover || selected) {
@@ -36242,7 +36277,6 @@ uniform ${i3} ${o3} u_${a3};
36242
36277
  }
36243
36278
  if (!cache2[key]) {
36244
36279
  if (radius === 0) {
36245
- cache2[key] = null;
36246
36280
  return null;
36247
36281
  }
36248
36282
  const margin = 1 * pixelRatio;
@@ -36253,17 +36287,24 @@ uniform ${i3} ${o3} u_${a3};
36253
36287
  const canvas2 = createCanvas_default(size, size);
36254
36288
  if (canvas2) {
36255
36289
  const ctx = canvas2.getContext("2d");
36290
+ if (!ctx) {
36291
+ return null;
36292
+ }
36256
36293
  if (isDisplayStrokeAndDelay && delay !== null) {
36257
36294
  const delayBg = getDelayBgCanvas(origin, radiusDelay, getDelayColor2(delay, cancelled));
36258
- ctx.drawImage(delayBg, 0, 0);
36295
+ if (delayBg) {
36296
+ ctx.drawImage(delayBg, 0, 0);
36297
+ }
36259
36298
  }
36260
- if (isDisplayStrokeAndDelay && (hover || delay >= delayDisplay || cancelled)) {
36299
+ if (isDisplayStrokeAndDelay && (hover || (delay || 0) >= delayDisplay || cancelled)) {
36261
36300
  const fontSize = Math.max(cancelled ? 19 : 14, Math.min(cancelled ? 19 : 17, radius * 1.2)) * pixelRatio;
36262
36301
  const text = getDelayText2(delay, cancelled);
36263
36302
  if (text) {
36264
36303
  const textWidth = text.length * fontSize;
36265
36304
  const delayText = getDelayTextCanvas(textWidth, text, fontSize, `bold ${fontSize}px arial, sans-serif`, getDelayColor2(delay, cancelled, true), delayOutlineColor, pixelRatio);
36266
- ctx.drawImage(delayText, origin + radiusDelay + margin, origin - fontSize);
36305
+ if (delayText) {
36306
+ ctx.drawImage(delayText, origin + radiusDelay + margin, origin - fontSize);
36307
+ }
36267
36308
  }
36268
36309
  }
36269
36310
  let circleFillColor;
@@ -36273,16 +36314,20 @@ uniform ${i3} ${o3} u_${a3};
36273
36314
  circleFillColor = color || getBgColor2(type);
36274
36315
  }
36275
36316
  const hasStroke = isDisplayStrokeAndDelay || hover || selected;
36276
- const hasDash = isDisplayStrokeAndDelay && useDelayStyle && delay === null && operatorProvidesRealtime === "yes";
36317
+ const hasDash = !!isDisplayStrokeAndDelay && !!useDelayStyle && delay === null && operatorProvidesRealtime === "yes";
36277
36318
  const circle = getCircleCanvas(origin, radius, circleFillColor, hasStroke, hasDash, pixelRatio);
36278
- ctx.drawImage(circle, 0, 0);
36279
- if (mustDrawText) {
36319
+ if (circle) {
36320
+ ctx.drawImage(circle, 0, 0);
36321
+ }
36322
+ if (mustDrawText && ctx) {
36280
36323
  const fontSize = Math.max(radius, 10);
36281
36324
  const textSize = getTextSize2(ctx, markerSize, name, fontSize);
36282
36325
  const textColor2 = !useDelayStyle ? textColor || getTextColor2(type) : "#000000";
36283
- const hasStroke2 = useDelayStyle && delay === null && operatorProvidesRealtime === "yes";
36326
+ const hasStroke2 = !!useDelayStyle && delay === null && operatorProvidesRealtime === "yes";
36284
36327
  const text = getTextCanvas(name, origin, textSize, textColor2, circleFillColor, hasStroke2, pixelRatio);
36285
- ctx.drawImage(text, 0, 0);
36328
+ if (text) {
36329
+ ctx.drawImage(text, 0, 0);
36330
+ }
36286
36331
  }
36287
36332
  cache2[key] = canvas2;
36288
36333
  }
@@ -36291,7 +36336,7 @@ uniform ${i3} ${o3} u_${a3};
36291
36336
  };
36292
36337
  var realtimeDefaultStyle_default = realtimeDefaultStyle;
36293
36338
 
36294
- // src/common/styles/realtimeDelayStyle.js
36339
+ // src/common/styles/realtimeDelayStyle.ts
36295
36340
  var realtimeDelayStyle = (trajectory, viewState, options) => {
36296
36341
  return realtimeDefaultStyle_default(trajectory, viewState, {
36297
36342
  ...options,
@@ -36300,7 +36345,7 @@ uniform ${i3} ${o3} u_${a3};
36300
36345
  };
36301
36346
  var realtimeDelayStyle_default = realtimeDelayStyle;
36302
36347
 
36303
- // src/common/styles/realtimeSimpleStyle.js
36348
+ // src/common/styles/realtimeSimpleStyle.ts
36304
36349
  var canvas;
36305
36350
  var realtimeSimpleStyle = () => {
36306
36351
  if (!canvas) {
@@ -36308,13 +36353,15 @@ uniform ${i3} ${o3} u_${a3};
36308
36353
  canvas.width = 15;
36309
36354
  canvas.height = 15;
36310
36355
  const ctx = canvas.getContext("2d");
36311
- ctx.arc(8, 8, 5, 0, 2 * Math.PI, false);
36312
- ctx.fillStyle = "#8ED6FF";
36313
- ctx.fill();
36314
- ctx.lineWidth = 3;
36315
- ctx.strokeStyle = "black";
36316
- ctx.stroke();
36317
- ctx.lineWidth = 3;
36356
+ if (ctx) {
36357
+ ctx.arc(8, 8, 5, 0, 2 * Math.PI, false);
36358
+ ctx.fillStyle = "#8ED6FF";
36359
+ ctx.fill();
36360
+ ctx.lineWidth = 3;
36361
+ ctx.strokeStyle = "black";
36362
+ ctx.stroke();
36363
+ ctx.lineWidth = 3;
36364
+ }
36318
36365
  }
36319
36366
  return canvas;
36320
36367
  };
@@ -36675,8 +36722,8 @@ uniform ${i3} ${o3} u_${a3};
36675
36722
  }
36676
36723
  var Layer_default = Layer;
36677
36724
 
36678
- // src/common/controls/Control.js
36679
- var Control = class extends Object_default {
36725
+ // src/common/controls/ControlCommon.ts
36726
+ var ControlCommon = class extends Object_default {
36680
36727
  constructor(options = {}) {
36681
36728
  super(options);
36682
36729
  this.defineProperties(options);
@@ -36743,22 +36790,25 @@ uniform ${i3} ${o3} u_${a3};
36743
36790
  this.map = map;
36744
36791
  }
36745
36792
  detachFromMap() {
36746
- this.map = null;
36793
+ this.map = void 0;
36747
36794
  }
36748
36795
  activate() {
36749
36796
  this.deactivate();
36750
36797
  }
36751
36798
  deactivate() {
36799
+ console.error("This function must be implemented in subclasses");
36752
36800
  }
36753
- render() {
36801
+ render(options) {
36802
+ console.error("This function must be implemented in subclasses");
36754
36803
  }
36755
36804
  createDefaultElement() {
36805
+ console.error("This function must be implemented in subclasses");
36756
36806
  }
36757
36807
  };
36758
- var Control_default = Control;
36808
+ var ControlCommon_default = ControlCommon;
36759
36809
 
36760
- // src/common/mixins/CopyrightMixin.js
36761
- var CopyrightMixin = (Base) => class extends Base {
36810
+ // src/common/controls/CopyrightControlCommon.ts
36811
+ var CopyrightControlCommon = class extends ControlCommon_default {
36762
36812
  render() {
36763
36813
  if (!this.element) {
36764
36814
  return;
@@ -36776,11 +36826,15 @@ uniform ${i3} ${o3} u_${a3};
36776
36826
  padding: "0 10px"
36777
36827
  });
36778
36828
  }
36829
+ getCopyrights() {
36830
+ console.error("The getCopyrights() function must be implemented in subclasses.", this);
36831
+ return [];
36832
+ }
36779
36833
  };
36780
- var CopyrightMixin_default = CopyrightMixin;
36834
+ var CopyrightControlCommon_default = CopyrightControlCommon;
36781
36835
 
36782
- // src/ol/controls/CopyrightControl.js
36783
- var CopyrightControl = class extends CopyrightMixin_default(Control_default) {
36836
+ // src/ol/controls/CopyrightControl.ts
36837
+ var CopyrightControl = class extends CopyrightControlCommon_default {
36784
36838
  constructor(options) {
36785
36839
  super(options);
36786
36840
  this.onPostRender = this.onPostRender.bind(this);
@@ -36790,9 +36844,9 @@ uniform ${i3} ${o3} u_${a3};
36790
36844
  return [];
36791
36845
  }
36792
36846
  let copyrights = [];
36793
- this.frameState.layerStatesArray.forEach((layerState) => {
36847
+ this.frameState?.layerStatesArray.forEach((layerState) => {
36794
36848
  const { layer } = layerState;
36795
- if (inView(layerState, this.frameState.viewState) && layer && layer.getSource && layer.getSource() && layer.getSource().getAttributions()) {
36849
+ if (this.frameState && inView(layerState, this.frameState.viewState) && layer && layer.getSource && layer.getSource() && layer.getSource().getAttributions()) {
36796
36850
  copyrights = copyrights.concat(layer.getSource().getAttributions()(this.frameState));
36797
36851
  }
36798
36852
  });
@@ -36812,7 +36866,7 @@ uniform ${i3} ${o3} u_${a3};
36812
36866
  }
36813
36867
  onPostRender(evt) {
36814
36868
  if (this.map && this.element) {
36815
- this.frameState = evt.frameState;
36869
+ this.frameState = evt.frameState || void 0;
36816
36870
  this.render();
36817
36871
  }
36818
36872
  }
@@ -47788,12 +47842,14 @@ uniform ${i3} ${o3} u_${a3};
47788
47842
  }
47789
47843
  var v4_default = v4;
47790
47844
 
47791
- // src/common/layers/Layer.js
47845
+ // src/common/layers/LayerCommon.ts
47792
47846
  var Layer2 = class extends Object_default {
47793
47847
  constructor(options = {}) {
47794
47848
  super();
47795
47849
  this.defineProperties(options);
47796
- this.setProperties(options.properties);
47850
+ if (options.properties) {
47851
+ this.setProperties(options.properties);
47852
+ }
47797
47853
  this.visible = options.visible === void 0 ? true : !!options.visible;
47798
47854
  this.group = options.group;
47799
47855
  this.copyrights = options.copyrights;
@@ -47806,7 +47862,7 @@ uniform ${i3} ${o3} u_${a3};
47806
47862
  }
47807
47863
  });
47808
47864
  }
47809
- defineProperties(options) {
47865
+ defineProperties(options = {}) {
47810
47866
  const { name, key, properties, hitTolerance } = {
47811
47867
  ...options
47812
47868
  };
@@ -47858,10 +47914,9 @@ uniform ${i3} ${o3} u_${a3};
47858
47914
  while (higherParent.parent) {
47859
47915
  higherParent = higherParent.parent;
47860
47916
  }
47861
- higherParent.dispatchEvent({
47862
- type: `change:visible:group`,
47863
- target: this
47864
- });
47917
+ const evt = new Event_default(`change:visible:group`);
47918
+ evt.target = this;
47919
+ higherParent.dispatchEvent(evt);
47865
47920
  }
47866
47921
  } else if (!this.visible) {
47867
47922
  if (this.children) {
@@ -47869,7 +47924,7 @@ uniform ${i3} ${o3} u_${a3};
47869
47924
  child.visible = false;
47870
47925
  });
47871
47926
  }
47872
- if (this.parent && this.parent.visible && !this.parent.children.find((child) => child.visible)) {
47927
+ if (this.parent && this.parent.visible && this.parent.children && !this.parent.children.find((child) => child.visible)) {
47873
47928
  this.parent.visible = false;
47874
47929
  }
47875
47930
  }
@@ -47889,7 +47944,7 @@ uniform ${i3} ${o3} u_${a3};
47889
47944
  get: () => this.get("children") || [],
47890
47945
  set: (newValue) => {
47891
47946
  (this.children || []).forEach((child) => {
47892
- child.parent = null;
47947
+ child.parent = void 0;
47893
47948
  });
47894
47949
  if (Array.isArray(newValue)) {
47895
47950
  newValue.forEach((child) => {
@@ -47918,7 +47973,7 @@ uniform ${i3} ${o3} u_${a3};
47918
47973
  }
47919
47974
  }
47920
47975
  detachFromMap() {
47921
- this.map = null;
47976
+ this.map = void 0;
47922
47977
  }
47923
47978
  getFeatureInfoAtCoordinate(coordinate, options) {
47924
47979
  console.error("getFeatureInfoAtCoordinate must be implemented by inheriting layers", this.key);
@@ -47933,141 +47988,147 @@ uniform ${i3} ${o3} u_${a3};
47933
47988
  }
47934
47989
  };
47935
47990
 
47936
- // src/common/mixins/UserInteractionsLayerMixin.js
47937
- var UserInteractionsLayerMixin = (Base) => class extends Base {
47938
- constructor(options = {}) {
47939
- super(options);
47940
- const {
47941
- userInteractions = true,
47942
- userClickInteractions = true,
47943
- userHoverInteractions = true,
47944
- defaultUserInteractions = true
47945
- } = options;
47946
- this.userInteractions = userInteractions;
47947
- this.userClickInteractions = userClickInteractions;
47948
- this.userHoverInteractions = userHoverInteractions;
47949
- this.defaultUserInteractions = defaultUserInteractions;
47950
- this.userClickCallbacks = [];
47951
- this.userHoverCallbacks = [];
47952
- this.userClickEventsKeys = [];
47953
- this.userHoverEventsKeys = [];
47954
- this.onUserClickCallback = this.onUserClickCallback.bind(this);
47955
- this.onUserMoveCallback = this.onUserMoveCallback.bind(this);
47956
- const { onClick, onHover } = options;
47957
- if (this.userInteractions && this.userClickInteractions && onClick) {
47958
- this.onClick(onClick);
47959
- }
47960
- if (this.userInteractions && this.userHoverInteractions && onHover) {
47961
- this.onHover(onHover);
47962
- }
47963
- }
47964
- attachToMap(map, options) {
47965
- super.attachToMap(map, options);
47966
- if (this.userInteractions && this.defaultUserInteractions && this.userClickInteractions && this.onFeatureClick) {
47967
- this.onClick(this.onFeatureClick);
47968
- }
47969
- if (this.userInteractions && this.defaultUserInteractions && this.userHoverInteractions && this.onFeatureHover) {
47970
- this.onHover(this.onFeatureHover);
47971
- }
47972
- this.listenEvents();
47973
- }
47974
- detachFromMap() {
47975
- this.unlistenEvents();
47976
- super.detachFromMap();
47977
- }
47978
- listenEvents() {
47979
- this.unlistenEvents();
47980
- this.userClickCallbacks.forEach((callback) => {
47981
- this.userClickEventsKeys.push(this.on("user:click", ({ target: { features, layer, coordinate } }) => {
47982
- callback(features, layer, coordinate);
47983
- }));
47984
- });
47985
- this.userHoverCallbacks.forEach((callback) => {
47986
- this.userHoverEventsKeys.push(this.on("user:hover", ({ target: { features, layer, coordinate, event } }) => {
47987
- callback(features, layer, coordinate, event);
47988
- }));
47989
- });
47990
- }
47991
- unlistenEvents() {
47992
- unByKey(this.userClickEventsKeys);
47993
- unByKey(this.userHoverEventsKeys);
47994
- this.userClickEventsKeys = [];
47995
- this.userHoverEventsKeys = [];
47996
- }
47997
- onClick(callback) {
47998
- this.userClickCallbacks.push(callback);
47999
- this.activateUserInteractions();
48000
- if (this.map) {
47991
+ // src/common/mixins/UserInteractionsLayerMixin.ts
47992
+ function UserInteractionsLayerMixin(Base) {
47993
+ return class extends Base {
47994
+ constructor(options = {}) {
47995
+ super(options);
47996
+ const {
47997
+ userInteractions = true,
47998
+ userClickInteractions = true,
47999
+ userHoverInteractions = true,
48000
+ defaultUserInteractions = true
48001
+ } = options;
48002
+ this.userInteractions = userInteractions;
48003
+ this.userClickInteractions = userClickInteractions;
48004
+ this.userHoverInteractions = userHoverInteractions;
48005
+ this.defaultUserInteractions = defaultUserInteractions;
48006
+ this.userClickCallbacks = [];
48007
+ this.userHoverCallbacks = [];
48008
+ this.userClickEventsKeys = [];
48009
+ this.userHoverEventsKeys = [];
48010
+ this.onUserClickCallback = this.onUserClickCallback.bind(this);
48011
+ this.onUserMoveCallback = this.onUserMoveCallback.bind(this);
48012
+ const { onClick, onHover } = options;
48013
+ if (this.userInteractions && this.userClickInteractions && onClick) {
48014
+ this.onClick(onClick);
48015
+ }
48016
+ if (this.userInteractions && this.userHoverInteractions && onHover) {
48017
+ this.onHover(onHover);
48018
+ }
48019
+ }
48020
+ attachToMap(map) {
48021
+ super.attachToMap(map);
48022
+ if (this.userInteractions && this.defaultUserInteractions && this.userClickInteractions && this.onFeatureClick) {
48023
+ this.onClick(this.onFeatureClick);
48024
+ }
48025
+ if (this.userInteractions && this.defaultUserInteractions && this.userHoverInteractions && this.onFeatureHover) {
48026
+ this.onHover(this.onFeatureHover);
48027
+ }
48001
48028
  this.listenEvents();
48002
48029
  }
48003
- }
48004
- onHover(callback) {
48005
- this.userHoverCallbacks.push(callback);
48006
- this.activateUserInteractions();
48007
- if (this.map) {
48008
- this.listenEvents();
48030
+ detachFromMap() {
48031
+ this.unlistenEvents();
48032
+ super.detachFromMap();
48033
+ }
48034
+ listenEvents() {
48035
+ this.unlistenEvents();
48036
+ this.userClickCallbacks.forEach((callback) => {
48037
+ this.userClickEventsKeys.push(this.on("user:click", ({
48038
+ target: { features, layer, coordinate, event }
48039
+ }) => {
48040
+ callback(features, layer, coordinate, event);
48041
+ }));
48042
+ });
48043
+ this.userHoverCallbacks.forEach((callback) => {
48044
+ this.userHoverEventsKeys.push(this.on("user:hover", ({
48045
+ target: { features, layer, coordinate, event }
48046
+ }) => {
48047
+ callback(features, layer, coordinate, event);
48048
+ }));
48049
+ });
48009
48050
  }
48010
- }
48011
- unClick(callback) {
48012
- const index = this.userClickCallbacks.indexOf(callback);
48013
- if (index !== -1) {
48014
- return;
48051
+ unlistenEvents() {
48052
+ unByKey(this.userClickEventsKeys);
48053
+ unByKey(this.userHoverEventsKeys);
48054
+ this.userClickEventsKeys = [];
48055
+ this.userHoverEventsKeys = [];
48015
48056
  }
48016
- this.userClickCallbacks = this.userClickCallbacks.slice(index, 1);
48017
- if (this.map) {
48018
- this.listenEvents();
48057
+ onClick(callback) {
48058
+ this.userClickCallbacks.push(callback);
48059
+ this.activateUserInteractions();
48060
+ if (this.map) {
48061
+ this.listenEvents();
48062
+ }
48019
48063
  }
48020
- }
48021
- unHover(callback) {
48022
- const index = this.userHoverCallbacks.indexOf(callback);
48023
- if (index !== -1) {
48024
- return;
48064
+ onHover(callback) {
48065
+ this.userHoverCallbacks.push(callback);
48066
+ this.activateUserInteractions();
48067
+ if (this.map) {
48068
+ this.listenEvents();
48069
+ }
48025
48070
  }
48026
- this.userHoverCallbacks = this.userHoverCallbacks.slice(index, 1);
48027
- if (this.map) {
48028
- this.listenEvents();
48071
+ unClick(callback) {
48072
+ const index = this.userClickCallbacks.indexOf(callback);
48073
+ if (index !== -1) {
48074
+ return;
48075
+ }
48076
+ this.userClickCallbacks = this.userClickCallbacks.slice(index, 1);
48077
+ if (this.map) {
48078
+ this.listenEvents();
48079
+ }
48029
48080
  }
48030
- }
48031
- onUserClickCallback(evt) {
48032
- const coordinate = evt.coordinate || fromLonLat(evt.lngLat.toArray());
48033
- const emptyFeatureInfo = {
48034
- features: [],
48035
- layer: this,
48036
- coordinate,
48037
- event: evt
48038
- };
48039
- return this.getFeatureInfoAtCoordinate(coordinate).then((featureInfo) => {
48040
- this.dispatchEvent({
48041
- type: "user:click",
48042
- target: featureInfo
48043
- });
48044
- return featureInfo;
48045
- }).catch(() => emptyFeatureInfo);
48046
- }
48047
- onUserMoveCallback(evt) {
48048
- const coordinate = evt.coordinate || fromLonLat(evt.lngLat.toArray());
48049
- const emptyFeatureInfo = {
48050
- features: [],
48051
- layer: this,
48052
- coordinate,
48053
- event: evt
48054
- };
48055
- return this.getFeatureInfoAtCoordinate(coordinate).then((featureInfo) => {
48056
- this.dispatchEvent({
48057
- type: "user:hover",
48058
- target: featureInfo
48059
- });
48060
- return featureInfo;
48061
- }).catch(() => emptyFeatureInfo);
48062
- }
48063
- activateUserInteractions() {
48064
- }
48065
- deactivateUserInteractions() {
48066
- }
48067
- };
48081
+ unHover(callback) {
48082
+ const index = this.userHoverCallbacks.indexOf(callback);
48083
+ if (index !== -1) {
48084
+ return;
48085
+ }
48086
+ this.userHoverCallbacks = this.userHoverCallbacks.slice(index, 1);
48087
+ if (this.map) {
48088
+ this.listenEvents();
48089
+ }
48090
+ }
48091
+ onUserClickCallback(evt) {
48092
+ const coordinate = evt.coordinate || fromLonLat(evt.lngLat.toArray());
48093
+ const emptyFeatureInfo = {
48094
+ features: [],
48095
+ layer: this,
48096
+ coordinate,
48097
+ event: evt
48098
+ };
48099
+ return this.getFeatureInfoAtCoordinate(coordinate).then((featureInfo) => {
48100
+ this.dispatchEvent({
48101
+ type: "user:click",
48102
+ target: featureInfo
48103
+ });
48104
+ return featureInfo;
48105
+ }).catch(() => emptyFeatureInfo);
48106
+ }
48107
+ onUserMoveCallback(evt) {
48108
+ const coordinate = evt.coordinate || fromLonLat(evt.lngLat.toArray());
48109
+ const emptyFeatureInfo = {
48110
+ features: [],
48111
+ layer: this,
48112
+ coordinate,
48113
+ event: evt
48114
+ };
48115
+ return this.getFeatureInfoAtCoordinate(coordinate).then((featureInfo) => {
48116
+ this.dispatchEvent({
48117
+ type: "user:hover",
48118
+ target: featureInfo
48119
+ });
48120
+ return featureInfo;
48121
+ }).catch(() => emptyFeatureInfo);
48122
+ }
48123
+ activateUserInteractions() {
48124
+ }
48125
+ deactivateUserInteractions() {
48126
+ }
48127
+ };
48128
+ }
48068
48129
  var UserInteractionsLayerMixin_default = UserInteractionsLayerMixin;
48069
48130
 
48070
- // src/ol/layers/Layer.js
48131
+ // src/ol/layers/Layer.ts
48071
48132
  var Layer3 = class extends UserInteractionsLayerMixin_default(Layer2) {
48072
48133
  constructor(options) {
48073
48134
  super(options);
@@ -48108,7 +48169,9 @@ uniform ${i3} ${o3} u_${a3};
48108
48169
  const attributions = this.copyrights || [];
48109
48170
  if (this.olLayer.getLayers) {
48110
48171
  this.olLayer.getLayers().getArray().forEach((layer) => {
48111
- layer.getSource()?.setAttributions(attributions);
48172
+ if (layer.getSource) {
48173
+ layer.getSource()?.setAttributions(attributions);
48174
+ }
48112
48175
  });
48113
48176
  } else if (this.olLayer.getSource) {
48114
48177
  this.olLayer.getSource()?.setAttributions(attributions);
@@ -48125,11 +48188,11 @@ uniform ${i3} ${o3} u_${a3};
48125
48188
  }
48126
48189
  activateUserInteractions() {
48127
48190
  this.deactivateUserInteractions();
48128
- if (this.map && this.userInteractions && this.userClickInteractions && this.userClickCallbacks.length) {
48191
+ if (this.map && this.userInteractions && this.userClickInteractions && this.userClickCallbacks?.length) {
48129
48192
  this.singleClickListenerKey = this.map.on("singleclick", this.onUserClickCallback);
48130
48193
  this.olListenersKeys.push(this.singleClickListenerKey);
48131
48194
  }
48132
- if (this.map && this.userInteractions && this.userHoverInteractions && this.userHoverCallbacks.length) {
48195
+ if (this.map && this.userInteractions && this.userHoverInteractions && this.userHoverCallbacks?.length) {
48133
48196
  this.pointerMoveListenerKey = this.map.on("pointermove", this.onUserMoveCallback);
48134
48197
  }
48135
48198
  }
@@ -48220,7 +48283,7 @@ uniform ${i3} ${o3} u_${a3};
48220
48283
  });
48221
48284
  return coords;
48222
48285
  };
48223
- var RoutingControl = class extends Control_default {
48286
+ var RoutingControl = class extends ControlCommon_default {
48224
48287
  constructor(options = {}) {
48225
48288
  super(options);
48226
48289
  Object.defineProperties(this, {
@@ -48587,9 +48650,9 @@ uniform ${i3} ${o3} u_${a3};
48587
48650
  };
48588
48651
  var RoutingControl_default = RoutingControl;
48589
48652
 
48590
- // src/common/mixins/StopFinderMixin.js
48591
- var StopFinderMixin = (Base) => class extends Base {
48592
- constructor(options = {}) {
48653
+ // src/common/controls/StopFinderControlCommon.ts
48654
+ var StopFinderControlCommon = class extends ControlCommon_default {
48655
+ constructor(options) {
48593
48656
  super(options);
48594
48657
  const { apiParams, apiKey, url } = options;
48595
48658
  this.apiParams = { limit: 20, ...apiParams || {} };
@@ -48609,16 +48672,15 @@ uniform ${i3} ${o3} u_${a3};
48609
48672
  this.suggestionsElt.style.display = suggestions.length ? "block" : "none";
48610
48673
  this.suggestionsElt.innerHTML = "";
48611
48674
  suggestions.forEach((suggestion) => {
48612
- const { properties } = suggestion;
48613
48675
  const suggElt = document.createElement("div");
48614
- suggElt.innerHTML = properties.name;
48676
+ suggElt.innerHTML = suggestion?.properties?.name;
48615
48677
  suggElt.onclick = () => {
48616
48678
  this.onSuggestionClick(suggestion);
48617
48679
  };
48618
48680
  Object.assign(suggElt.style, {
48619
48681
  padding: "5px 12px"
48620
48682
  });
48621
- this.suggestionsElt.appendChild(suggElt);
48683
+ this.suggestionsElt?.appendChild(suggElt);
48622
48684
  });
48623
48685
  }
48624
48686
  createDefaultElement() {
@@ -48636,9 +48698,9 @@ uniform ${i3} ${o3} u_${a3};
48636
48698
  this.inputElt = document.createElement("input");
48637
48699
  this.inputElt.type = "text";
48638
48700
  this.inputElt.placeholder = this.placeholder;
48639
- this.inputElt.autoComplete = "off";
48701
+ this.inputElt.autocomplete = "off";
48640
48702
  this.inputElt.onkeyup = (evt) => {
48641
- this.abortController.abort();
48703
+ this.abortController?.abort();
48642
48704
  this.abortController = new AbortController();
48643
48705
  this.search(evt.target.value, this.abortController);
48644
48706
  };
@@ -48673,7 +48735,7 @@ uniform ${i3} ${o3} u_${a3};
48673
48735
  if (this.clearElt) {
48674
48736
  this.clearElt.style.display = "block";
48675
48737
  }
48676
- return this.api.search(this.apiParams, abortController).then((data) => {
48738
+ return this.api.search(this.apiParams, abortController && { signal: abortController.signal }).then((data) => {
48677
48739
  this.render(data);
48678
48740
  }).catch(() => {
48679
48741
  this.render();
@@ -48682,7 +48744,7 @@ uniform ${i3} ${o3} u_${a3};
48682
48744
  onSuggestionClick(suggestion) {
48683
48745
  }
48684
48746
  clear() {
48685
- if (!this.suggestionsElt) {
48747
+ if (!this.suggestionsElt || !this.inputElt || !this.clearElt) {
48686
48748
  return;
48687
48749
  }
48688
48750
  this.inputElt.value = "";
@@ -48690,27 +48752,27 @@ uniform ${i3} ${o3} u_${a3};
48690
48752
  this.clearElt.style.display = "none";
48691
48753
  }
48692
48754
  };
48693
- var StopFinderMixin_default = StopFinderMixin;
48755
+ var StopFinderControlCommon_default = StopFinderControlCommon;
48694
48756
 
48695
- // src/ol/controls/StopFinderControl.js
48696
- var StopFinderControl = class extends StopFinderMixin_default(Control_default) {
48697
- onSuggestionClick({ geometry }) {
48698
- const coord = fromLonLat(geometry.coordinates);
48757
+ // src/ol/controls/StopFinderControl.ts
48758
+ var StopFinderControl = class extends StopFinderControlCommon_default {
48759
+ onSuggestionClick(suggestion) {
48760
+ const coord = fromLonLat(suggestion.geometry.coordinates);
48699
48761
  this.map.getView().setCenter(coord);
48700
48762
  }
48701
48763
  };
48702
48764
  var StopFinderControl_default = StopFinderControl;
48703
48765
 
48704
- // src/ol/layers/MapboxLayer.js
48766
+ // src/ol/layers/MapboxLayer.ts
48705
48767
  var import_mapbox_gl = __toESM(require_mapbox_gl());
48706
48768
 
48707
- // src/common/mixins/MapboxLayerMixin.js
48708
- var MapboxLayerMixin = (Base) => class extends Base {
48709
- constructor(options = {}) {
48769
+ // src/ol/layers/MapGlLayer.ts
48770
+ var MapGlLayer = class extends Layer_default4 {
48771
+ constructor(options) {
48710
48772
  super(options);
48711
48773
  this.olLayer = new Layer_default({
48712
48774
  source: new Source_default({}),
48713
- render: this.getOlLayerRender(this)
48775
+ render: this.getOlLayerRender()
48714
48776
  });
48715
48777
  this.styleUrl = options.url;
48716
48778
  this.apiKey = options.apiKey;
@@ -48733,16 +48795,16 @@ uniform ${i3} ${o3} u_${a3};
48733
48795
  this.mbMap.triggerRepaint = () => {
48734
48796
  };
48735
48797
  this.mbMap.remove();
48736
- this.mbMap = null;
48798
+ this.mbMap = void 0;
48737
48799
  }
48738
48800
  this.loaded = false;
48739
48801
  super.detachFromMap();
48740
48802
  }
48741
48803
  loadMbMap() {
48742
- this.olListenersKeys.push(this.map.on("change:target", () => {
48804
+ this.olListenersKeys.push(this.map?.on("change:target", () => {
48743
48805
  this.loadMbMap();
48744
48806
  }));
48745
- if (!this.map.getTargetElement()) {
48807
+ if (!this.map?.getTargetElement()) {
48746
48808
  return;
48747
48809
  }
48748
48810
  if (!this.visible) {
@@ -48755,7 +48817,11 @@ uniform ${i3} ${o3} u_${a3};
48755
48817
  container.style.position = "absolute";
48756
48818
  container.style.width = "100%";
48757
48819
  container.style.height = "100%";
48758
- if (!this.apiKey && !this.styleUrl.includes(this.apiKeyName)) {
48820
+ if (!this.styleUrl) {
48821
+ console.error(`No styleUrl defined for mapbox layer: ${this.styleUrl}`);
48822
+ return;
48823
+ }
48824
+ if (!this.apiKey && !this.styleUrl?.includes(this.apiKeyName)) {
48759
48825
  console.error(`No apiKey defined for mapbox layer with style url to ${this.styleUrl}`);
48760
48826
  }
48761
48827
  const Map3 = this.getMapboxMapClass();
@@ -48782,22 +48848,29 @@ uniform ${i3} ${o3} u_${a3};
48782
48848
  const newAttributions = getMapboxMapCopyrights_default(evt.target) || [];
48783
48849
  if (this.copyrights?.toString() !== newAttributions.toString()) {
48784
48850
  this.copyrights = newAttributions;
48785
- this.olLayer.getSource()?.setAttributions(newAttributions);
48851
+ this.olLayer?.getSource()?.setAttributions(newAttributions);
48786
48852
  }
48787
48853
  }
48788
48854
  getFeatureInfoAtCoordinate(coordinate, options) {
48789
48855
  if (!options || !this.format || !this.mbMap || !this.mbMap.isStyleLoaded()) {
48790
48856
  return Promise.resolve({ coordinate, features: [], layer: this });
48791
48857
  }
48792
- let pixel = coordinate && this.mbMap.project(toLonLat(coordinate));
48858
+ const pixel = coordinate && this.mbMap.project(toLonLat(coordinate));
48859
+ let pixels;
48793
48860
  if (this.hitTolerance) {
48794
48861
  const { x, y } = pixel;
48795
- pixel = [
48796
- { x: x - this.hitTolerance, y: y - this.hitTolerance },
48797
- { x: x + this.hitTolerance, y: y + this.hitTolerance }
48862
+ pixels = [
48863
+ {
48864
+ x: x - this.hitTolerance,
48865
+ y: y - this.hitTolerance
48866
+ },
48867
+ {
48868
+ x: x + this.hitTolerance,
48869
+ y: y + this.hitTolerance
48870
+ }
48798
48871
  ];
48799
48872
  }
48800
- const features = this.mbMap.queryRenderedFeatures(pixel, options).map((feature2) => {
48873
+ const features = this.mbMap.queryRenderedFeatures(pixels || pixel, options).map((feature2) => {
48801
48874
  const olFeature = this.format.readFeature(feature2);
48802
48875
  if (olFeature) {
48803
48876
  olFeature.set("mapboxFeature", feature2);
@@ -48810,14 +48883,23 @@ uniform ${i3} ${o3} u_${a3};
48810
48883
  coordinate
48811
48884
  });
48812
48885
  }
48886
+ getOlLayerRender() {
48887
+ console.error("This function must be implemented in subclasses");
48888
+ const div = document.createElement("div");
48889
+ return () => div;
48890
+ }
48891
+ getMapboxMapClass() {
48892
+ console.error("This function must be implemented in subclasses");
48893
+ return null;
48894
+ }
48813
48895
  };
48814
- var MapboxLayerMixin_default = MapboxLayerMixin;
48896
+ var MapGlLayer_default = MapGlLayer;
48815
48897
 
48816
- // src/ol/layers/MapboxLayer.js
48817
- var MapboxLayer = class extends MapboxLayerMixin_default(Layer_default4) {
48898
+ // src/ol/layers/MapboxLayer.ts
48899
+ var MapboxLayer = class extends MapGlLayer_default {
48818
48900
  attachToMap(map) {
48819
48901
  super.attachToMap(map);
48820
- if (!this.map || this.mbMap) {
48902
+ if (!this.map) {
48821
48903
  return;
48822
48904
  }
48823
48905
  this.olListenersKeys.push(this.map.on("change:size", () => {
@@ -48831,7 +48913,7 @@ uniform ${i3} ${o3} u_${a3};
48831
48913
  }));
48832
48914
  }
48833
48915
  loadMbMap() {
48834
- let [x, y] = this.map.getView().getCenter();
48916
+ let [x, y] = this.map?.getView().getCenter() || [];
48835
48917
  if (!x || !y) {
48836
48918
  x = 0;
48837
48919
  y = 0;
@@ -48849,14 +48931,17 @@ uniform ${i3} ${o3} u_${a3};
48849
48931
  return;
48850
48932
  }
48851
48933
  this.mbMap.once("load", () => {
48934
+ if (!this.mbMap) {
48935
+ return;
48936
+ }
48852
48937
  this.mbMap.resize();
48853
48938
  this.copyrights = getMapboxMapCopyrights_default(this.mbMap) || [];
48854
- this.olLayer.getSource()?.setAttributions(this.copyrights);
48939
+ this.olLayer?.getSource()?.setAttributions(this.copyrights);
48855
48940
  });
48856
48941
  const mapboxCanvas = this.mbMap.getCanvas();
48857
48942
  if (mapboxCanvas) {
48858
48943
  if (this.options.tabIndex) {
48859
- mapboxCanvas.setAttribute("tabindex", this.options.tabIndex);
48944
+ mapboxCanvas.setAttribute("tabindex", `${this.options.tabIndex}`);
48860
48945
  } else {
48861
48946
  mapboxCanvas.removeAttribute("tabindex");
48862
48947
  }
@@ -48873,9 +48958,9 @@ uniform ${i3} ${o3} u_${a3};
48873
48958
  }
48874
48959
  };
48875
48960
 
48876
- // src/ol/layers/MaplibreLayer.js
48961
+ // src/ol/layers/MaplibreLayer.ts
48877
48962
  var import_maplibre_gl = __toESM(require_maplibre_gl());
48878
- var MaplibreLayer = class extends MapboxLayerMixin_default(Layer_default4) {
48963
+ var MaplibreLayer = class extends MapGlLayer_default {
48879
48964
  getOlLayerRender() {
48880
48965
  return getMaplibreRender(this);
48881
48966
  }
@@ -49075,419 +49160,454 @@ uniform ${i3} ${o3} u_${a3};
49075
49160
  };
49076
49161
  var MapboxStyleLayer_default = MapboxStyleLayer;
49077
49162
 
49078
- // src/common/mixins/RealtimeLayerMixin.js
49163
+ // src/common/mixins/RealtimeLayerMixin.ts
49079
49164
  var import_lodash = __toESM(require_lodash());
49080
49165
  var import_lodash2 = __toESM(require_lodash2());
49081
- var RealtimeLayerMixin = (Base) => class extends Base {
49082
- constructor(options = {}) {
49083
- super({
49084
- hitTolerance: 10,
49085
- ...options
49086
- });
49087
- this.debug = options.debug;
49088
- this.mode = options.mode || RealtimeModes.TOPOGRAPHIC;
49089
- this.api = options.api || new RealtimeAPI_default(options);
49090
- this.tenant = options.tenant || "";
49091
- this.minZoomNonTrain = options.minZoomNonTrain || 9;
49092
- this.minZoomInterpolation = options.minZoomInterpolation || 8;
49093
- this.format = new GeoJSON_default();
49094
- this.generalizationLevelByZoom = options.generalizationLevelByZoom || [
49095
- 5,
49096
- 5,
49097
- 5,
49098
- 5,
49099
- 5,
49100
- 5,
49101
- 5,
49102
- 5,
49103
- 10,
49104
- 30,
49105
- 30,
49106
- 100,
49107
- 100,
49108
- 100
49109
- ];
49110
- this.getGeneralizationLevelByZoom = (zoom) => {
49111
- return options.getGeneralizationLevelByZoom && options.getGeneralizationLevelByZoom(zoom, this.generalizationLevelByZoom) || this.generalizationLevelByZoom[zoom];
49112
- };
49113
- this.renderTimeIntervalByZoom = options.renderTimeIntervalByZoom || [
49114
- 1e5,
49115
- 5e4,
49116
- 4e4,
49117
- 3e4,
49118
- 2e4,
49119
- 15e3,
49120
- 1e4,
49121
- 5e3,
49122
- 2e3,
49123
- 1e3,
49124
- 400,
49125
- 300,
49126
- 250,
49127
- 180,
49128
- 90,
49129
- 60,
49130
- 50,
49131
- 50,
49132
- 50,
49133
- 50,
49134
- 50
49135
- ];
49136
- this.getRenderTimeIntervalByZoom = (zoom) => {
49137
- return options.getRenderTimeIntervalByZoom && options.getRenderTimeIntervalByZoom(zoom, this.renderTimeIntervalByZoom) || this.renderTimeIntervalByZoom[zoom];
49138
- };
49139
- this.isUpdateBboxOnMoveEnd = options.isUpdateBboxOnMoveEnd !== false;
49140
- this.throttleRenderTrajectories = (0, import_lodash2.default)(this.renderTrajectoriesInternal, 50, { leading: false, trailing: true });
49141
- this.debounceRenderTrajectories = (0, import_lodash.default)(this.renderTrajectoriesInternal, 50, { leading: true, trailing: true, maxWait: 5e3 });
49142
- this.onFeatureHover = this.onFeatureHover.bind(this);
49143
- this.onFeatureClick = this.onFeatureClick.bind(this);
49144
- this.renderTrajectoriesInternal = this.renderTrajectoriesInternal.bind(this);
49145
- this.onTrajectoryMessage = this.onTrajectoryMessage.bind(this);
49146
- this.onDeleteTrajectoryMessage = this.onDeleteTrajectoryMessage.bind(this);
49147
- this.onDocumentVisibilityChange = this.onDocumentVisibilityChange.bind(this);
49148
- }
49149
- defineProperties(options) {
49150
- const {
49151
- style,
49152
- speed,
49153
- pixelRatio,
49154
- hoverVehicleId,
49155
- selectedVehicleId,
49156
- filter,
49157
- sort,
49158
- time,
49159
- live,
49160
- canvas: canvas2,
49161
- styleOptions
49162
- } = options;
49163
- let currSpeed = speed || 1;
49164
- let currTime = time || new Date();
49165
- super.defineProperties(options);
49166
- Object.defineProperties(this, {
49167
- isTrackerLayer: { value: true },
49168
- canvas: {
49169
- value: canvas2 || document.createElement("canvas")
49170
- },
49171
- style: {
49172
- value: style || realtimeDefaultStyle_default
49173
- },
49174
- styleOptions: {
49175
- value: { ...trackerConfig_exports, ...styleOptions || {} }
49176
- },
49177
- speed: {
49178
- get: () => currSpeed,
49179
- set: (newSpeed) => {
49180
- currSpeed = newSpeed;
49181
- this.start();
49182
- }
49183
- },
49184
- filter: {
49185
- value: filter,
49186
- writable: true
49187
- },
49188
- sort: {
49189
- value: sort,
49190
- writable: true
49191
- },
49192
- live: {
49193
- value: live === false ? live : true,
49194
- writable: true
49195
- },
49196
- time: {
49197
- get: () => currTime,
49198
- set: (newTime) => {
49199
- currTime = newTime && newTime.getTime ? newTime : new Date(newTime);
49200
- this.renderTrajectories();
49166
+ function RealtimeLayerMixin(Base) {
49167
+ return class Mixin extends Base {
49168
+ constructor(options) {
49169
+ super({
49170
+ hitTolerance: 10,
49171
+ ...options
49172
+ });
49173
+ this.debug = options.debug || false;
49174
+ this.mode = options.mode || RealtimeModes.TOPOGRAPHIC;
49175
+ this.api = options.api || new RealtimeAPI_default(options);
49176
+ this.tenant = options.tenant || "";
49177
+ this.minZoomNonTrain = options.minZoomNonTrain || 9;
49178
+ this.minZoomInterpolation = options.minZoomInterpolation || 8;
49179
+ this.format = new GeoJSON_default();
49180
+ this.generalizationLevelByZoom = options.generalizationLevelByZoom || [
49181
+ 5,
49182
+ 5,
49183
+ 5,
49184
+ 5,
49185
+ 5,
49186
+ 5,
49187
+ 5,
49188
+ 5,
49189
+ 10,
49190
+ 30,
49191
+ 30,
49192
+ 100,
49193
+ 100,
49194
+ 100
49195
+ ];
49196
+ this.getGeneralizationLevelByZoom = (zoom) => {
49197
+ return options.getGeneralizationLevelByZoom && options.getGeneralizationLevelByZoom(zoom, this.generalizationLevelByZoom) || this.generalizationLevelByZoom[zoom];
49198
+ };
49199
+ this.renderTimeIntervalByZoom = options.renderTimeIntervalByZoom || [
49200
+ 1e5,
49201
+ 5e4,
49202
+ 4e4,
49203
+ 3e4,
49204
+ 2e4,
49205
+ 15e3,
49206
+ 1e4,
49207
+ 5e3,
49208
+ 2e3,
49209
+ 1e3,
49210
+ 400,
49211
+ 300,
49212
+ 250,
49213
+ 180,
49214
+ 90,
49215
+ 60,
49216
+ 50,
49217
+ 50,
49218
+ 50,
49219
+ 50,
49220
+ 50
49221
+ ];
49222
+ this.getRenderTimeIntervalByZoom = (zoom) => {
49223
+ return options.getRenderTimeIntervalByZoom && options.getRenderTimeIntervalByZoom(zoom, this.renderTimeIntervalByZoom) || this.renderTimeIntervalByZoom[zoom];
49224
+ };
49225
+ this.isUpdateBboxOnMoveEnd = options.isUpdateBboxOnMoveEnd !== false;
49226
+ this.throttleRenderTrajectories = (0, import_lodash2.default)(this.renderTrajectoriesInternal, 50, { leading: false, trailing: true });
49227
+ this.debounceRenderTrajectories = (0, import_lodash.default)(this.renderTrajectoriesInternal, 50, { leading: true, trailing: true, maxWait: 5e3 });
49228
+ this.onFeatureHover = this.onFeatureHover.bind(this);
49229
+ this.onFeatureClick = this.onFeatureClick.bind(this);
49230
+ this.renderTrajectoriesInternal = this.renderTrajectoriesInternal.bind(this);
49231
+ this.onTrajectoryMessage = this.onTrajectoryMessage.bind(this);
49232
+ this.onDeleteTrajectoryMessage = this.onDeleteTrajectoryMessage.bind(this);
49233
+ this.onDocumentVisibilityChange = this.onDocumentVisibilityChange.bind(this);
49234
+ }
49235
+ defineProperties(options) {
49236
+ const {
49237
+ style,
49238
+ speed,
49239
+ pixelRatio,
49240
+ hoverVehicleId,
49241
+ selectedVehicleId,
49242
+ filter,
49243
+ sort,
49244
+ time,
49245
+ live,
49246
+ canvas: canvas2,
49247
+ styleOptions
49248
+ } = options;
49249
+ let currSpeed = speed || 1;
49250
+ let currTime = time || new Date();
49251
+ super.defineProperties(options);
49252
+ Object.defineProperties(this, {
49253
+ isTrackerLayer: { value: true },
49254
+ canvas: {
49255
+ value: canvas2 || document.createElement("canvas")
49256
+ },
49257
+ style: {
49258
+ value: style || realtimeDefaultStyle_default
49259
+ },
49260
+ styleOptions: {
49261
+ value: { ...trackerConfig_exports, ...styleOptions || {} }
49262
+ },
49263
+ speed: {
49264
+ get: () => currSpeed,
49265
+ set: (newSpeed) => {
49266
+ currSpeed = newSpeed;
49267
+ this.start();
49268
+ }
49269
+ },
49270
+ filter: {
49271
+ value: filter,
49272
+ writable: true
49273
+ },
49274
+ sort: {
49275
+ value: sort,
49276
+ writable: true
49277
+ },
49278
+ live: {
49279
+ value: live === false ? live : true,
49280
+ writable: true
49281
+ },
49282
+ time: {
49283
+ get: () => currTime,
49284
+ set: (newTime) => {
49285
+ currTime = newTime && newTime.getTime ? newTime : new Date(newTime);
49286
+ this.renderTrajectories();
49287
+ }
49288
+ },
49289
+ trajectories: {
49290
+ value: {},
49291
+ writable: true
49292
+ },
49293
+ hoverVehicleId: {
49294
+ value: hoverVehicleId,
49295
+ writable: true
49296
+ },
49297
+ selectedVehicleId: {
49298
+ value: selectedVehicleId,
49299
+ writable: true
49300
+ },
49301
+ pixelRatio: {
49302
+ value: pixelRatio || (typeof window !== "undefined" ? window.devicePixelRatio : 1),
49303
+ writable: true
49304
+ },
49305
+ useRequestAnimationFrame: {
49306
+ value: options.useRequestAnimationFrame || false,
49307
+ writable: true
49308
+ },
49309
+ useThrottle: {
49310
+ value: options.useThrottle !== false,
49311
+ writable: true
49312
+ },
49313
+ useDebounce: {
49314
+ value: options.useDebounce || false,
49315
+ writable: true
49201
49316
  }
49202
- },
49203
- trajectories: {
49204
- value: {},
49205
- writable: true
49206
- },
49207
- hoverVehicleId: {
49208
- value: hoverVehicleId,
49209
- writable: true
49210
- },
49211
- selectedVehicleId: {
49212
- value: selectedVehicleId,
49213
- writable: true
49214
- },
49215
- pixelRatio: {
49216
- value: pixelRatio || (typeof window !== "undefined" ? window.devicePixelRatio : 1),
49217
- writable: true
49218
- },
49219
- useRequestAnimationFrame: {
49220
- value: options.useRequestAnimationFrame || false,
49221
- writable: true
49222
- },
49223
- useThrottle: {
49224
- value: options.useThrottle !== false,
49225
- writable: true
49226
- },
49227
- useDebounce: {
49228
- value: options.useDebounce || false,
49229
- writable: true
49230
- }
49231
- });
49232
- }
49233
- attachToMap(map) {
49234
- super.attachToMap(map);
49235
- if (this.visible) {
49236
- this.start();
49317
+ });
49237
49318
  }
49238
- this.visibilityRef = this.on("change:visible", (evt) => {
49239
- if (evt.target.visible) {
49319
+ attachToMap(map) {
49320
+ super.attachToMap(map);
49321
+ if (this.visible) {
49240
49322
  this.start();
49241
- } else {
49242
- this.stop();
49243
49323
  }
49244
- });
49245
- document.addEventListener("visibilitychange", this.onDocumentVisibilityChange);
49246
- }
49247
- detachFromMap() {
49248
- document.removeEventListener("visibilitychange", this.onDocumentVisibilityChange);
49249
- this.stop();
49250
- unByKey(this.visibilityRef);
49251
- const context = this.canvas.getContext("2d");
49252
- context.clearRect(0, 0, this.canvas.width, this.canvas.height);
49253
- super.detachFromMap();
49254
- }
49255
- start() {
49256
- this.stop();
49257
- this.renderTrajectories();
49258
- this.startUpdateTime();
49259
- this.api.open();
49260
- this.api.subscribeTrajectory(this.mode, this.onTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49261
- this.api.subscribeDeletedVehicles(this.mode, this.onDeleteTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49262
- if (this.isUpdateBboxOnMoveEnd) {
49263
- this.setBbox();
49264
- }
49265
- }
49266
- startUpdateTime() {
49267
- this.stopUpdateTime();
49268
- this.updateTimeDelay = this.getRefreshTimeInMs();
49269
- this.updateTimeInterval = setInterval(() => {
49270
- this.time = this.live ? new Date() : this.time.getTime() + this.updateTimeDelay * this.speed;
49271
- }, this.updateTimeDelay);
49272
- }
49273
- stop() {
49274
- this.api.unsubscribeTrajectory(this.onTrajectoryMessage);
49275
- this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage);
49276
- this.api.close();
49277
- }
49278
- stopUpdateTime() {
49279
- if (this.updateTimeInterval) {
49280
- clearInterval(this.updateTimeInterval);
49281
- }
49282
- }
49283
- renderTrajectoriesInternal(viewState, noInterpolate) {
49284
- if (!this.map) {
49285
- return false;
49286
- }
49287
- const time = this.live ? Date.now() : this.time;
49288
- const trajectories = Object.values(this.trajectories);
49289
- if (this.sort) {
49290
- trajectories.sort(this.sort);
49291
- }
49292
- this.renderState = renderTrajectories_default(this.canvas, trajectories, this.style, { ...viewState, pixelRatio: this.pixelRatio, time }, {
49293
- noInterpolate: viewState.zoom < this.minZoomInterpolation ? true : noInterpolate,
49294
- hoverVehicleId: this.hoverVehicleId,
49295
- selectedVehicleId: this.selectedVehicleId,
49296
- ...this.styleOptions
49297
- });
49298
- return true;
49299
- }
49300
- renderTrajectories(viewState, noInterpolate) {
49301
- if (this.requestId) {
49302
- cancelAnimationFrame(this.requestId);
49303
- this.requestId = null;
49304
- }
49305
- if (!noInterpolate && this.useRequestAnimationFrame) {
49306
- this.requestId = requestAnimationFrame(() => {
49307
- this.renderTrajectoriesInternal(viewState, noInterpolate);
49324
+ this.visibilityRef = this.on("change:visible", (evt) => {
49325
+ if (evt.target.visible) {
49326
+ this.start();
49327
+ } else {
49328
+ this.stop();
49329
+ }
49308
49330
  });
49309
- } else if (!noInterpolate && this.useDebounce) {
49310
- this.debounceRenderTrajectories(viewState, noInterpolate);
49311
- } else if (!noInterpolate && this.useThrottle) {
49312
- this.throttleRenderTrajectories(viewState, noInterpolate);
49313
- } else {
49314
- this.renderTrajectoriesInternal(viewState, noInterpolate);
49331
+ document.addEventListener("visibilitychange", this.onDocumentVisibilityChange);
49315
49332
  }
49316
- }
49317
- setBbox(extent, zoom) {
49318
- const keys = Object.keys(this.trajectories);
49319
- for (let i = keys.length - 1; i >= 0; i -= 1) {
49320
- this.purgeTrajectory(this.trajectories[keys[i]], extent, zoom);
49333
+ detachFromMap() {
49334
+ document.removeEventListener("visibilitychange", this.onDocumentVisibilityChange);
49335
+ this.stop();
49336
+ unByKey(this.visibilityRef);
49337
+ if (this.canvas) {
49338
+ const context = this.canvas.getContext("2d");
49339
+ context?.clearRect(0, 0, this.canvas.width, this.canvas.height);
49340
+ super.detachFromMap();
49341
+ }
49321
49342
  }
49322
- const bbox = [...extent];
49323
- if (this.isUpdateBboxOnMoveEnd) {
49324
- bbox.push(zoom);
49325
- if (this.tenant) {
49326
- bbox.push(`tenant=${this.tenant}`);
49343
+ start() {
49344
+ this.stop();
49345
+ this.renderTrajectories();
49346
+ this.startUpdateTime();
49347
+ this.api.open();
49348
+ this.api.subscribeTrajectory(this.mode, this.onTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49349
+ this.api.subscribeDeletedVehicles(this.mode, this.onDeleteTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49350
+ if (this.isUpdateBboxOnMoveEnd) {
49351
+ this.setBbox();
49352
+ }
49353
+ }
49354
+ startUpdateTime() {
49355
+ this.stopUpdateTime();
49356
+ this.updateTimeDelay = this.getRefreshTimeInMs() || 0;
49357
+ this.updateTimeInterval = window.setInterval(() => {
49358
+ if (this.live) {
49359
+ this.time = new Date();
49360
+ } else if (this.time && this.updateTimeDelay && this.speed) {
49361
+ this.time = new Date(this.time.getTime() + this.updateTimeDelay * this.speed);
49362
+ }
49363
+ }, this.updateTimeDelay);
49364
+ }
49365
+ stop() {
49366
+ this.api.unsubscribeTrajectory(this.onTrajectoryMessage);
49367
+ this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage);
49368
+ this.api.close();
49369
+ }
49370
+ stopUpdateTime() {
49371
+ if (this.updateTimeInterval) {
49372
+ clearInterval(this.updateTimeInterval);
49373
+ this.updateTimeInterval = void 0;
49374
+ }
49375
+ }
49376
+ renderTrajectoriesInternal(viewState, noInterpolate = false) {
49377
+ if (!this.map || !this.trajectories) {
49378
+ return false;
49327
49379
  }
49328
- this.generalizationLevel = this.getGeneralizationLevelByZoom(zoom);
49329
- if (this.generalizationLevel) {
49330
- bbox.push(`gen=${this.generalizationLevel}`);
49380
+ const time = this.live ? Date.now() : this.time?.getTime();
49381
+ const trajectories = Object.values(this.trajectories);
49382
+ if (this.sort) {
49383
+ trajectories.sort(this.sort);
49331
49384
  }
49332
- }
49333
- this.api.bbox = bbox;
49334
- }
49335
- setMode(mode) {
49336
- if (this.mode === mode) {
49337
- return;
49338
- }
49339
- this.mode = mode;
49340
- this.api.subscribeTrajectory(this.mode, this.onTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49341
- this.api.subscribeDeletedVehicles(this.mode, this.onDeleteTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49342
- }
49343
- getRefreshTimeInMs(zoom) {
49344
- const roundedZoom = Math.round(zoom);
49345
- const timeStep = this.getRenderTimeIntervalByZoom(roundedZoom) || 25;
49346
- const nextTick = Math.max(25, timeStep / this.speed);
49347
- const nextThrottleTick = Math.min(nextTick, 500);
49348
- if (this.useThrottle) {
49349
- this.throttleRenderTrajectories = (0, import_lodash2.default)(this.renderTrajectoriesInternal, nextThrottleTick, { leading: true, trailing: true });
49350
- } else if (this.useDebounce) {
49351
- this.debounceRenderTrajectories = (0, import_lodash.default)(this.renderTrajectoriesInternal, nextThrottleTick, { leading: true, trailing: true, maxWait: 5e3 });
49352
- }
49353
- if (this.api?.buffer) {
49354
- const [, size] = this.api.buffer;
49355
- this.api.buffer = [nextThrottleTick, size];
49356
- }
49357
- return nextTick;
49358
- }
49359
- getVehicle(filterFc) {
49360
- return Object.values(this.trajectories).filter(filterFc);
49361
- }
49362
- getFeatureInfoAtCoordinate(coordinate, options = {}) {
49363
- const { resolution, nb } = options;
49364
- const ext = buffer([...coordinate, ...coordinate], this.hitTolerance * resolution);
49365
- let trajectories = Object.values(this.trajectories);
49366
- if (this.sort) {
49367
- trajectories = trajectories.sort(this.sort);
49368
- }
49369
- const vehicles = [];
49370
- for (let i = 0; i < trajectories.length; i += 1) {
49371
- if (trajectories[i].properties.coordinate && containsCoordinate(ext, trajectories[i].properties.coordinate)) {
49372
- vehicles.push(trajectories[i]);
49373
- }
49374
- if (vehicles.length === nb) {
49375
- break;
49385
+ if (!this.canvas || !this.style) {
49386
+ return true;
49376
49387
  }
49377
- }
49378
- return Promise.resolve({
49379
- layer: this,
49380
- features: vehicles.map((vehicle) => this.format.readFeature(vehicle)),
49381
- coordinate
49382
- });
49383
- }
49384
- getTrajectoryInfos(id) {
49385
- const promises = [
49386
- this.api.getStopSequence(id, this.mode),
49387
- this.api.getFullTrajectory(id, this.mode, this.generalizationLevel)
49388
- ];
49389
- return Promise.all(promises).then(([stopSequence, fullTrajectory]) => {
49390
- const response = {
49391
- stopSequence,
49392
- fullTrajectory
49393
- };
49394
- return response;
49395
- });
49396
- }
49397
- purgeTrajectory(trajectory, extent, zoom) {
49398
- const { type, bounds, train_id: id } = trajectory.properties;
49399
- if (!intersects(extent, bounds) || type !== "rail" && zoom < (this.minZoomNonTrain || 9)) {
49400
- this.removeTrajectory(id);
49388
+ this.renderState = renderTrajectories_default(this.canvas, trajectories, this.style, {
49389
+ ...viewState,
49390
+ pixelRatio: this.pixelRatio || 1,
49391
+ time
49392
+ }, {
49393
+ noInterpolate: (viewState.zoom || 0) < this.minZoomInterpolation ? true : noInterpolate,
49394
+ hoverVehicleId: this.hoverVehicleId,
49395
+ selectedVehicleId: this.selectedVehicleId,
49396
+ ...this.styleOptions
49397
+ });
49401
49398
  return true;
49402
49399
  }
49403
- return false;
49404
- }
49405
- addTrajectory(trajectory) {
49406
- if (this.filter && !this.filter(trajectory)) {
49407
- return;
49400
+ renderTrajectories(viewState, noInterpolate) {
49401
+ if (this.requestId) {
49402
+ cancelAnimationFrame(this.requestId);
49403
+ this.requestId = void 0;
49404
+ }
49405
+ if (!viewState) {
49406
+ return;
49407
+ }
49408
+ if (!noInterpolate && this.useRequestAnimationFrame) {
49409
+ this.requestId = requestAnimationFrame(() => {
49410
+ this.renderTrajectoriesInternal(viewState, noInterpolate);
49411
+ });
49412
+ } else if (!noInterpolate && this.useDebounce) {
49413
+ this.debounceRenderTrajectories(viewState, noInterpolate);
49414
+ } else if (!noInterpolate && this.useThrottle) {
49415
+ this.throttleRenderTrajectories(viewState, noInterpolate);
49416
+ } else {
49417
+ this.renderTrajectoriesInternal(viewState, noInterpolate);
49418
+ }
49408
49419
  }
49409
- this.trajectories[trajectory.properties.train_id] = trajectory;
49410
- this.renderTrajectories();
49411
- }
49412
- removeTrajectory(id) {
49413
- delete this.trajectories[id];
49414
- }
49415
- onZoomEnd(evt) {
49416
- this.startUpdateTime();
49417
- }
49418
- onDocumentVisibilityChange() {
49419
- if (!this.visible) {
49420
- return;
49420
+ setBbox(extent, zoom) {
49421
+ if (this.trajectories && extent && zoom) {
49422
+ const keys = Object.keys(this.trajectories);
49423
+ for (let i = keys.length - 1; i >= 0; i -= 1) {
49424
+ this.purgeTrajectory(this.trajectories[keys[i]], extent, zoom);
49425
+ }
49426
+ }
49427
+ if (!extent) {
49428
+ return;
49429
+ }
49430
+ const bbox = [...extent];
49431
+ if (this.isUpdateBboxOnMoveEnd && zoom) {
49432
+ bbox.push(zoom);
49433
+ if (this.tenant) {
49434
+ bbox.push(`tenant=${this.tenant}`);
49435
+ }
49436
+ this.generalizationLevel = this.getGeneralizationLevelByZoom(zoom);
49437
+ if (this.generalizationLevel) {
49438
+ bbox.push(`gen=${this.generalizationLevel}`);
49439
+ }
49440
+ }
49441
+ this.api.bbox = bbox;
49421
49442
  }
49422
- if (document.hidden) {
49423
- this.stop();
49424
- } else {
49425
- this.start();
49443
+ setMode(mode) {
49444
+ if (this.mode === mode) {
49445
+ return;
49446
+ }
49447
+ this.mode = mode;
49448
+ this.api.subscribeTrajectory(this.mode, this.onTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49449
+ this.api.subscribeDeletedVehicles(this.mode, this.onDeleteTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49450
+ }
49451
+ getRefreshTimeInMs(zoom = 0) {
49452
+ const roundedZoom = zoom !== void 0 ? Math.round(zoom) : -1;
49453
+ const timeStep = this.getRenderTimeIntervalByZoom(roundedZoom) || 25;
49454
+ const nextTick = Math.max(25, timeStep / (this.speed || 1));
49455
+ const nextThrottleTick = Math.min(nextTick, 500);
49456
+ if (this.useThrottle) {
49457
+ this.throttleRenderTrajectories = (0, import_lodash2.default)(this.renderTrajectoriesInternal, nextThrottleTick, { leading: true, trailing: true });
49458
+ } else if (this.useDebounce) {
49459
+ this.debounceRenderTrajectories = (0, import_lodash.default)(this.renderTrajectoriesInternal, nextThrottleTick, { leading: true, trailing: true, maxWait: 5e3 });
49460
+ }
49461
+ if (this.api?.buffer) {
49462
+ const [, size] = this.api.buffer;
49463
+ this.api.buffer = [nextThrottleTick, size];
49464
+ }
49465
+ return nextTick;
49466
+ }
49467
+ getVehicle(filterFc) {
49468
+ return this.trajectories && Object.values(this.trajectories).filter(filterFc) || [];
49469
+ }
49470
+ getFeatureInfoAtCoordinate(coordinate, options) {
49471
+ const { resolution, nb } = options;
49472
+ const ext = buffer([...coordinate, ...coordinate], this.hitTolerance * resolution);
49473
+ let trajectories = Object.values(this.trajectories || {});
49474
+ if (this.sort) {
49475
+ trajectories = trajectories.sort(this.sort);
49476
+ }
49477
+ const vehicles = [];
49478
+ for (let i = 0; i < trajectories.length; i += 1) {
49479
+ if (trajectories[i].properties.coordinate && containsCoordinate(ext, trajectories[i].properties.coordinate)) {
49480
+ vehicles.push(trajectories[i]);
49481
+ }
49482
+ if (vehicles.length === nb) {
49483
+ break;
49484
+ }
49485
+ }
49486
+ return Promise.resolve({
49487
+ layer: this,
49488
+ features: vehicles.map((vehicle) => this.format.readFeature(vehicle)),
49489
+ coordinate
49490
+ });
49426
49491
  }
49427
- }
49428
- onTrajectoryMessage(data) {
49429
- if (!data.content) {
49430
- return;
49492
+ getTrajectoryInfos(id) {
49493
+ const promises = [
49494
+ this.api.getStopSequence(id),
49495
+ this.api.getFullTrajectory(id, this.mode, this.generalizationLevel)
49496
+ ];
49497
+ return Promise.all(promises).then(([stopSequence, fullTrajectory]) => {
49498
+ const response = {
49499
+ stopSequence,
49500
+ fullTrajectory
49501
+ };
49502
+ return response;
49503
+ });
49431
49504
  }
49432
- const trajectory = data.content;
49433
- const {
49434
- geometry,
49435
- properties: {
49436
- train_id: id,
49437
- time_since_update: timeSinceUpdate,
49438
- raw_coordinates: rawCoordinates
49505
+ purgeTrajectory(trajectory, extent, zoom) {
49506
+ const { type, bounds } = trajectory.properties;
49507
+ if (!intersects(extent, bounds) || type !== "rail" && zoom < (this.minZoomNonTrain || 9)) {
49508
+ this.removeTrajectory(trajectory);
49509
+ return true;
49439
49510
  }
49440
- } = trajectory;
49441
- if (timeSinceUpdate < 0) {
49442
- return;
49511
+ return false;
49443
49512
  }
49444
- if (this.purgeTrajectory(trajectory)) {
49445
- return;
49513
+ addTrajectory(trajectory) {
49514
+ if (this.filter && !this.filter(trajectory)) {
49515
+ return;
49516
+ }
49517
+ if (!this.trajectories) {
49518
+ this.trajectories = {};
49519
+ }
49520
+ this.trajectories[trajectory.properties.train_id] = trajectory;
49521
+ this.renderTrajectories();
49446
49522
  }
49447
- if (this.debug && this.mode === RealtimeModes.TOPOGRAPHIC && rawCoordinates) {
49448
- trajectory.properties.olGeometry = {
49449
- type: "Point",
49450
- coordinates: fromLonLat(rawCoordinates, this.map.getView().getProjection())
49451
- };
49452
- } else {
49453
- trajectory.properties.olGeometry = this.format.readGeometry(geometry);
49523
+ removeTrajectory(trajectoryOrId) {
49524
+ let id;
49525
+ if (typeof trajectoryOrId !== "string") {
49526
+ id = trajectoryOrId?.properties?.train_id;
49527
+ } else {
49528
+ id = trajectoryOrId;
49529
+ }
49530
+ if (this.trajectories) {
49531
+ delete this.trajectories[id];
49532
+ }
49454
49533
  }
49455
- trajectory.properties.timeOffset = Date.now() - data.timestamp;
49456
- this.addTrajectory(trajectory);
49457
- }
49458
- onDeleteTrajectoryMessage(data) {
49459
- if (!data.content) {
49460
- return;
49534
+ onZoomEnd() {
49535
+ this.startUpdateTime();
49461
49536
  }
49462
- this.removeTrajectory(data.content);
49463
- }
49464
- onFeatureHover(features, layer, coordinate) {
49465
- const [feature2] = features;
49466
- let id = null;
49467
- if (feature2) {
49468
- id = feature2.get("train_id");
49537
+ onDocumentVisibilityChange() {
49538
+ if (!this.visible) {
49539
+ return;
49540
+ }
49541
+ if (document.hidden) {
49542
+ this.stop();
49543
+ } else {
49544
+ this.start();
49545
+ }
49469
49546
  }
49470
- if (this.hoverVehicleId !== id) {
49471
- this.hoverVehicleId = id;
49472
- this.renderTrajectories(true);
49547
+ onTrajectoryMessage(data) {
49548
+ if (!data.content) {
49549
+ return;
49550
+ }
49551
+ const trajectory = data.content;
49552
+ const {
49553
+ geometry,
49554
+ properties: {
49555
+ train_id: id,
49556
+ time_since_update: timeSinceUpdate,
49557
+ raw_coordinates: rawCoordinates
49558
+ }
49559
+ } = trajectory;
49560
+ if (timeSinceUpdate < 0) {
49561
+ return;
49562
+ }
49563
+ if (this.purgeTrajectory(trajectory)) {
49564
+ return;
49565
+ }
49566
+ if (this.debug && this.mode === RealtimeModes.TOPOGRAPHIC && rawCoordinates) {
49567
+ trajectory.properties.olGeometry = {
49568
+ type: "Point",
49569
+ coordinates: fromLonLat(rawCoordinates, this.map.getView().getProjection())
49570
+ };
49571
+ } else {
49572
+ trajectory.properties.olGeometry = this.format.readGeometry(geometry);
49573
+ }
49574
+ trajectory.properties.timeOffset = Date.now() - data.timestamp;
49575
+ this.addTrajectory(trajectory);
49473
49576
  }
49474
- }
49475
- onFeatureClick(features, layer, coordinate) {
49476
- const [feature2] = features;
49477
- let id = null;
49478
- if (feature2) {
49479
- id = feature2.get("train_id");
49577
+ onDeleteTrajectoryMessage(data) {
49578
+ if (!data.content) {
49579
+ return;
49580
+ }
49581
+ this.removeTrajectory(data.content);
49480
49582
  }
49481
- if (this.selectedVehicleId !== id) {
49482
- this.selectedVehicleId = id;
49483
- this.selectedVehicle = feature2;
49484
- this.renderTrajectories(true);
49583
+ onFeatureHover(features, layer, coordinate) {
49584
+ const [feature2] = features;
49585
+ let id = null;
49586
+ if (feature2) {
49587
+ id = feature2.get("train_id");
49588
+ }
49589
+ if (this.hoverVehicleId !== id) {
49590
+ this.hoverVehicleId = id;
49591
+ this.renderTrajectories(true);
49592
+ }
49485
49593
  }
49486
- }
49487
- };
49594
+ onFeatureClick(features, layer, coordinate) {
49595
+ const [feature2] = features;
49596
+ let id = null;
49597
+ if (feature2) {
49598
+ id = feature2.get("train_id");
49599
+ }
49600
+ if (this.selectedVehicleId !== id) {
49601
+ this.selectedVehicleId = id;
49602
+ this.selectedVehicle = feature2;
49603
+ this.renderTrajectories(true);
49604
+ }
49605
+ }
49606
+ };
49607
+ }
49488
49608
  var RealtimeLayerMixin_default = RealtimeLayerMixin;
49489
49609
 
49490
- // src/ol/styles/fullTrajectoryStyle.js
49610
+ // src/ol/styles/fullTrajectoryStyle.ts
49491
49611
  var borderStyle = new Style_default({
49492
49612
  zIndex: 2,
49493
49613
  image: new Circle_default({
@@ -49562,10 +49682,10 @@ uniform ${i3} ${o3} u_${a3};
49562
49682
  };
49563
49683
  var fullTrajectoryDelayStyle_default = fullTrajectoryDelaystyle;
49564
49684
 
49565
- // src/ol/layers/RealtimeLayer.js
49685
+ // src/ol/layers/RealtimeLayer.ts
49566
49686
  var format = new GeoJSON_default();
49567
49687
  var RealtimeLayer = class extends RealtimeLayerMixin_default(Layer_default4) {
49568
- constructor(options = {}) {
49688
+ constructor(options) {
49569
49689
  super({
49570
49690
  ...options
49571
49691
  });
@@ -49590,11 +49710,13 @@ uniform ${i3} ${o3} u_${a3};
49590
49710
  this.transformContainer.style.width = "100%";
49591
49711
  this.transformContainer.style.height = "100%";
49592
49712
  this.container.appendChild(this.transformContainer);
49593
- this.canvas.style.position = "absolute";
49594
- this.canvas.style.top = "0";
49595
- this.canvas.style.left = "0";
49596
- this.canvas.style.transformOrigin = "top left";
49597
- this.transformContainer.appendChild(this.canvas);
49713
+ if (this.canvas) {
49714
+ this.canvas.style.position = "absolute";
49715
+ this.canvas.style.top = "0";
49716
+ this.canvas.style.left = "0";
49717
+ this.canvas.style.transformOrigin = "top left";
49718
+ this.transformContainer.appendChild(this.canvas);
49719
+ }
49598
49720
  }
49599
49721
  if (this.renderedViewState) {
49600
49722
  const { center, resolution, rotation } = frameState.viewState;
@@ -49604,8 +49726,8 @@ uniform ${i3} ${o3} u_${a3};
49604
49726
  rotation: renderedRotation
49605
49727
  } = this.renderedViewState;
49606
49728
  if (renderedResolution / resolution >= 3) {
49607
- const context = this.canvas.getContext("2d");
49608
- context.clearRect(0, 0, this.canvas.width, this.canvas.height);
49729
+ const context = this.canvas?.getContext("2d");
49730
+ context?.clearRect(0, 0, this.canvas?.width, this.canvas?.height);
49609
49731
  } else {
49610
49732
  const pixelCenterRendered = this.map.getPixelFromCoordinate(renderedCenter);
49611
49733
  const pixelCenter = this.map.getPixelFromCoordinate(center);
@@ -49620,7 +49742,7 @@ uniform ${i3} ${o3} u_${a3};
49620
49742
  this.vectorLayer = this.olLayer.getLayers().item(0);
49621
49743
  this.renderState = {
49622
49744
  center: [0, 0],
49623
- zoom: null,
49745
+ zoom: void 0,
49624
49746
  rotation: 0
49625
49747
  };
49626
49748
  }
@@ -49634,7 +49756,7 @@ uniform ${i3} ${o3} u_${a3};
49634
49756
  }
49635
49757
  const zoom = view.getZoom();
49636
49758
  if (this.currentZoom !== zoom) {
49637
- this.onZoomEnd(evt);
49759
+ this.onZoomEnd();
49638
49760
  }
49639
49761
  this.currentZoom = zoom;
49640
49762
  this.onMoveEnd(evt);
@@ -49649,7 +49771,7 @@ uniform ${i3} ${o3} u_${a3};
49649
49771
  if (this.map && this.canvas) {
49650
49772
  const context = this.canvas.getContext("2d");
49651
49773
  const pixel = this.map.getPixelFromCoordinate(coordinate);
49652
- return !!context.getImageData(pixel[0] * this.pixelRatio, pixel[1] * this.pixelRatio, 1, 1).data[3];
49774
+ return !!context?.getImageData(pixel[0] * (this.pixelRatio || 1), pixel[1] * (this.pixelRatio || 1), 1, 1).data[3];
49653
49775
  }
49654
49776
  return false;
49655
49777
  }
@@ -49693,7 +49815,7 @@ uniform ${i3} ${o3} u_${a3};
49693
49815
  ...options
49694
49816
  });
49695
49817
  }
49696
- onMoveEnd() {
49818
+ onMoveEnd(evt) {
49697
49819
  if (this.visible && this.isUpdateBboxOnMoveEnd) {
49698
49820
  this.setBbox();
49699
49821
  }
@@ -49701,8 +49823,8 @@ uniform ${i3} ${o3} u_${a3};
49701
49823
  this.highlightTrajectory(this.selectedVehicleId);
49702
49824
  }
49703
49825
  }
49704
- onZoomEnd(evt) {
49705
- super.onZoomEnd(evt);
49826
+ onZoomEnd() {
49827
+ super.onZoomEnd();
49706
49828
  }
49707
49829
  onFeatureHover(features, layer, coordinate) {
49708
49830
  super.onFeatureHover(features, layer, coordinate);
@@ -49840,8 +49962,8 @@ uniform ${i3} ${o3} u_${a3};
49840
49962
  trackerConfig: () => trackerConfig_exports
49841
49963
  });
49842
49964
 
49843
- // src/mapbox/controls/CopyrightControl.js
49844
- var CopyrightControl2 = class extends CopyrightMixin_default(Control_default) {
49965
+ // src/mapbox/controls/CopyrightControl.ts
49966
+ var CopyrightControl2 = class extends CopyrightControlCommon_default {
49845
49967
  constructor(options) {
49846
49968
  super(options);
49847
49969
  this.render = this.render.bind(this);