mobility-toolbox-js 2.0.0-beta.54 → 2.0.0-beta.56

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.
@@ -3,7 +3,7 @@ import { EventsKey } from 'ol/events';
3
3
  import { Coordinate } from 'ol/coordinate';
4
4
  import { Feature } from 'ol';
5
5
  import { RealtimeAPI } from '../../api';
6
- import { AnyCanvas, AnyLayerClass, AnyMap, AnyRealtimeLayer, LayerGetFeatureInfoOptions, RealtimeGeneralizationLevel, RealtimeMode, RealtimeRenderState, RealtimeStyleFunction, RealtimeStyleOptions, RealtimeTenant, RealtimeTrainId, ViewState } from '../../types';
6
+ import { AnyCanvas, AnyLayerClass, AnyMap, AnyRealtimeLayer, LayerGetFeatureInfoOptions, RealtimeGeneralizationLevel, RealtimeMode, RealtimeMot, RealtimeRenderState, RealtimeStyleFunction, RealtimeStyleOptions, RealtimeTenant, RealtimeTrainId, ViewState } from '../../types';
7
7
  import { RealtimeTrajectory } from '../../api/typedefs';
8
8
  import { WebSocketAPIMessageEventData } from '../api/WebSocketAPI';
9
9
  import type { OlLayerOptions } from '../../ol/layers/Layer';
@@ -12,9 +12,9 @@ export declare type RealtimeLayerMixinOptions = OlLayerOptions & {
12
12
  mode?: RealtimeMode;
13
13
  api?: RealtimeAPI;
14
14
  tenant?: RealtimeTenant;
15
- minZoomNonTrain?: number;
16
15
  minZoomInterpolation?: number;
17
16
  isUpdateBboxOnMoveEnd?: boolean;
17
+ motsByZoom?: RealtimeMot[][];
18
18
  generalizationLevelByZoom?: RealtimeGeneralizationLevel[];
19
19
  renderTimeIntervalByZoom?: number[];
20
20
  style?: RealtimeStyleFunction;
@@ -31,6 +31,7 @@ export declare type RealtimeLayerMixinOptions = OlLayerOptions & {
31
31
  useRequestAnimationFrame?: boolean;
32
32
  useDebounce?: boolean;
33
33
  useThrottle?: boolean;
34
+ getMotsByZoom: (zoom: number, motsByZoom: RealtimeMot[][]) => RealtimeMot[];
34
35
  getGeneralizationLevelByZoom?: (zoom: number, generalizationLevelByZoom: RealtimeGeneralizationLevel[]) => RealtimeGeneralizationLevel;
35
36
  getRenderTimeIntervalByZoom?: (zoom: number, renderTimeIntervalByZoom: number[]) => number;
36
37
  url?: string;
@@ -105,7 +106,6 @@ declare function RealtimeLayerMixin<T extends AnyLayerClass>(Base: T): {
105
106
  style?: RealtimeStyleFunction | undefined;
106
107
  styleOptions?: RealtimeStyleOptions | undefined;
107
108
  pixelRatio?: number | undefined;
108
- minZoomNonTrain: number;
109
109
  minZoomInterpolation: number;
110
110
  isUpdateBboxOnMoveEnd: boolean;
111
111
  hoverVehicleId?: string | undefined;
@@ -114,6 +114,8 @@ declare function RealtimeLayerMixin<T extends AnyLayerClass>(Base: T): {
114
114
  useRequestAnimationFrame?: boolean | undefined;
115
115
  useDebounce?: boolean | undefined;
116
116
  useThrottle?: boolean | undefined;
117
+ mots?: RealtimeMot[] | undefined;
118
+ motsByZoom: RealtimeMot[][];
117
119
  generalizationLevel?: RealtimeGeneralizationLevel | undefined;
118
120
  generalizationLevelByZoom: RealtimeGeneralizationLevel[];
119
121
  renderTimeIntervalByZoom: number[];
@@ -123,6 +125,7 @@ declare function RealtimeLayerMixin<T extends AnyLayerClass>(Base: T): {
123
125
  updateTimeDelay?: number | undefined;
124
126
  visibilityRef: EventsKey;
125
127
  selectedVehicle: GeoJSONFeature;
128
+ getMotsByZoom: (zoom: number) => RealtimeMot[];
126
129
  getGeneralizationLevelByZoom: (zoom: number) => RealtimeGeneralizationLevel;
127
130
  getRenderTimeIntervalByZoom: (zoom: number) => number;
128
131
  throttleRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean) => void;
@@ -221,7 +224,7 @@ declare function RealtimeLayerMixin<T extends AnyLayerClass>(Base: T): {
221
224
  * Determine if the trajectory is useless and should be removed from the list or not.
222
225
  * By default, this function exclude vehicles:
223
226
  * - that have their trajectory outside the current extent and
224
- * - that are not a train and zoom level is lower than layer's minZoomNonTrain property.
227
+ * - that aren't in the MOT list.
225
228
  *
226
229
  * @param {RealtimeTrajectory} trajectory
227
230
  * @param {Array<number>} extent
@@ -1 +1 @@
1
- {"version":3,"file":"RealtimeLayerMixin.d.ts","sourceRoot":"","sources":["../../../src/common/mixins/RealtimeLayerMixin.ts"],"names":[],"mappings":"AAOA,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAIxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAiB,MAAM,WAAW,CAAC;AAGvD,OAAO,EACL,SAAS,EACT,aAAa,EACb,MAAM,EACN,gBAAgB,EAChB,0BAA0B,EAC1B,2BAA2B,EAC3B,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,oBAAY,yBAAyB,GAAG,cAAc,GAAG;IACvD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,yBAAyB,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAC1D,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IACpC,KAAK,CAAC,EAAE,qBAAqB,CAAC;IAC9B,KAA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AQG;oEAGQ,0BAA0B;;;;;QAkCrC;;;;;WAKG;+BACoB,eAAe;;;;QAiBtC;;;;;;;;;;;WAWG;4DAGO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,QAClC,MAAM;QAed;;;;WAIG;;yCAa8B,kBAAkB,GAAG,eAAe;QAYrE;;;;;WAKG;;;QAgBH;;;;;WAKG;kCAEK,6BAA6B,kBAAkB,CAAC;QAgDxD;;;;;;WAMG;wCAEK,6BAA6B,eAAe,CAAC;QAQrD;;;;;;WAMG;iCAES,OAAO,EAAE,SACZ,gBAAgB;QAgBzB;;;;;;WAMG;iCAES,OAAO,EAAE,SACZ,gBAAgB;;MAkB5B;AAED,eAAe,kBAAkB,CAAC"}
@@ -67,9 +67,29 @@ function RealtimeLayerMixin(Base) {
67
67
  this.mode = options.mode || RealtimeModes.TOPOGRAPHIC;
68
68
  this.api = options.api || new RealtimeAPI(options);
69
69
  this.tenant = options.tenant || ''; // sbb,sbh or sbm
70
- this.minZoomNonTrain = options.minZoomNonTrain || 9; // Min zoom level from which non trains are allowed to be displayed. Min value is 9 (as configured by the server
71
70
  this.minZoomInterpolation = options.minZoomInterpolation || 8; // Min zoom level from which trains positions are not interpolated.
72
71
  this.format = new GeoJSON();
72
+ // MOTs by zoom
73
+ const allMots = [
74
+ 'tram',
75
+ 'subway',
76
+ 'rail',
77
+ 'bus',
78
+ 'ferry',
79
+ 'cablecar',
80
+ 'gondola',
81
+ 'funicular',
82
+ 'coach',
83
+ ];
84
+ // Server will block non train before zoom 9
85
+ this.motsByZoom = options.motsByZoom || [allMots];
86
+ this.getMotsByZoom = (zoom) => {
87
+ return ((options.getMotsByZoom &&
88
+ options.getMotsByZoom(zoom, this.motsByZoom)) ||
89
+ this.motsByZoom[zoom] ||
90
+ this.motsByZoom[this.motsByZoom.length - 1]);
91
+ };
92
+ // Generalization levels by zoom
73
93
  this.generalizationLevelByZoom = options.generalizationLevelByZoom || [
74
94
  5, 5, 5, 5, 5, 5, 5, 5, 10, 30, 30, 100, 100, 100,
75
95
  ];
@@ -78,6 +98,7 @@ function RealtimeLayerMixin(Base) {
78
98
  options.getGeneralizationLevelByZoom(zoom, this.generalizationLevelByZoom)) ||
79
99
  this.generalizationLevelByZoom[zoom]);
80
100
  };
101
+ // Render time interval by zoom
81
102
  this.renderTimeIntervalByZoom = options.renderTimeIntervalByZoom || [
82
103
  100000, 50000, 40000, 30000, 20000, 15000, 10000, 5000, 2000, 1000, 400,
83
104
  300, 250, 180, 90, 60, 50, 50, 50, 50, 50,
@@ -112,6 +133,7 @@ function RealtimeLayerMixin(Base) {
112
133
  const { style, speed, pixelRatio, hoverVehicleId, selectedVehicleId, filter, sort, time, live, canvas, styleOptions, } = options;
113
134
  let currSpeed = speed || 1;
114
135
  let currTime = time || new Date();
136
+ let currStyle = style || realtimeDefaultStyle;
115
137
  super.defineProperties(options);
116
138
  Object.defineProperties(this, {
117
139
  isTrackerLayer: { value: true },
@@ -122,7 +144,12 @@ function RealtimeLayerMixin(Base) {
122
144
  * Style function used to render a vehicle.
123
145
  */
124
146
  style: {
125
- value: style || realtimeDefaultStyle,
147
+ get: () => currStyle,
148
+ set: (newStyle) => {
149
+ currStyle = newStyle;
150
+ // @ts-ignore function without parameters is defined in subclasses
151
+ this.renderTrajectories();
152
+ },
126
153
  },
127
154
  /**
128
155
  * Custom options to pass as last parameter of the style function.
@@ -413,6 +440,11 @@ function RealtimeLayerMixin(Base) {
413
440
  if (this.generalizationLevel) {
414
441
  bbox.push(`gen=${this.generalizationLevel}`);
415
442
  }
443
+ /* @ignore */
444
+ this.mots = this.getMotsByZoom(zoom);
445
+ if (this.mots) {
446
+ bbox.push(`mots=${this.mots}`);
447
+ }
416
448
  }
417
449
  this.api.bbox = bbox;
418
450
  }
@@ -518,7 +550,7 @@ function RealtimeLayerMixin(Base) {
518
550
  * Determine if the trajectory is useless and should be removed from the list or not.
519
551
  * By default, this function exclude vehicles:
520
552
  * - that have their trajectory outside the current extent and
521
- * - that are not a train and zoom level is lower than layer's minZoomNonTrain property.
553
+ * - that aren't in the MOT list.
522
554
  *
523
555
  * @param {RealtimeTrajectory} trajectory
524
556
  * @param {Array<number>} extent
@@ -529,7 +561,9 @@ function RealtimeLayerMixin(Base) {
529
561
  purgeTrajectory(trajectory, extent, zoom) {
530
562
  const { type, bounds } = trajectory.properties;
531
563
  if (!intersects(extent, bounds) ||
532
- (type !== 'rail' && zoom < (this.minZoomNonTrain || 9))) {
564
+ (this.mots && !this.mots.includes(type)) ||
565
+ (type !== 'rail' && zoom < 9) // zoom 9 is defined by the backend
566
+ ) {
533
567
  this.removeTrajectory(trajectory);
534
568
  return true;
535
569
  }
@@ -1,4 +1,4 @@
1
- import sortAndfilterDepartures from './sortAndFilterDepartures';
1
+ import sortAndFilterDepartures from './sortAndFilterDepartures';
2
2
  /**
3
3
  * This function returns a WebSocket api callback, and call the onDeparturesUpdate function with the list of current departures to display.
4
4
  * @param {function(departures: RealtimeDeparture[])} onDeparturesUpdate callback when list of departures changes, called after 100 ms
@@ -6,7 +6,7 @@ import sortAndfilterDepartures from './sortAndFilterDepartures';
6
6
  * @param {number} [maxDepartureAge = 30] max departure age of departures in minutes
7
7
  * @param {number} [timeout = 100] debounce timeout in ms
8
8
  */
9
- const debounceDeparturesMessages = (onDeparturesUpdate, sortByMinArrivalTime = true, maxDepartureAge = 30, timeout = 100) => {
9
+ const debounceDeparturesMessages = (onDeparturesUpdate, sortByMinArrivalTime = false, maxDepartureAge = 30, timeout = 100) => {
10
10
  const departureUpdateTimeout = {};
11
11
  const departureObject = {};
12
12
  return (data) => {
@@ -16,7 +16,7 @@ const debounceDeparturesMessages = (onDeparturesUpdate, sortByMinArrivalTime = t
16
16
  }
17
17
  departureObject[departure.call_id] = departure;
18
18
  departureUpdateTimeout[source] = window.setTimeout(() => {
19
- const departures = sortAndfilterDepartures(departureObject, sortByMinArrivalTime || false, maxDepartureAge);
19
+ const departures = sortAndFilterDepartures(departureObject, sortByMinArrivalTime || false, maxDepartureAge);
20
20
  onDeparturesUpdate(departures);
21
21
  }, timeout);
22
22
  };
@@ -11,5 +11,6 @@ export { default as getMapboxRender } from "./getMapboxRender";
11
11
  export { default as debounceDeparturesMessages } from "./debounceDeparturesMessages";
12
12
  export { default as debounceWebsocketMessages } from "./debounceWebsocketMessages";
13
13
  export { default as sortAndFilterDepartures } from "./sortAndFilterDepartures";
14
+ export { default as compareDepartures } from "./compareDepartures";
14
15
  export * as realtimeConfig from "./realtimeConfig";
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -11,5 +11,6 @@ export { default as getMapboxRender } from './getMapboxRender';
11
11
  export { default as debounceDeparturesMessages } from './debounceDeparturesMessages';
12
12
  export { default as debounceWebsocketMessages } from './debounceWebsocketMessages';
13
13
  export { default as sortAndFilterDepartures } from './sortAndFilterDepartures';
14
+ export { default as compareDepartures } from './compareDepartures';
14
15
  import * as realtimeConfig_1 from './realtimeConfig';
15
16
  export { realtimeConfig_1 as realtimeConfig };
@@ -23,7 +23,6 @@ declare const RealtimeLayer_base: {
23
23
  style?: import("../../types").RealtimeStyleFunction | undefined;
24
24
  styleOptions?: import("../../types").RealtimeStyleOptions | undefined;
25
25
  pixelRatio?: number | undefined;
26
- minZoomNonTrain: number;
27
26
  minZoomInterpolation: number;
28
27
  isUpdateBboxOnMoveEnd: boolean;
29
28
  hoverVehicleId?: string | undefined;
@@ -32,6 +31,8 @@ declare const RealtimeLayer_base: {
32
31
  useRequestAnimationFrame?: boolean | undefined;
33
32
  useDebounce?: boolean | undefined;
34
33
  useThrottle?: boolean | undefined;
34
+ mots?: import("../../types").RealtimeMot[] | undefined;
35
+ motsByZoom: import("../../types").RealtimeMot[][];
35
36
  generalizationLevel?: import("../../types").RealtimeGeneralizationLevel | undefined;
36
37
  generalizationLevelByZoom: import("../../types").RealtimeGeneralizationLevel[];
37
38
  renderTimeIntervalByZoom: number[];
@@ -41,6 +42,7 @@ declare const RealtimeLayer_base: {
41
42
  updateTimeDelay?: number | undefined;
42
43
  visibilityRef: import("ol/events").EventsKey;
43
44
  selectedVehicle: GeoJSONFeature;
45
+ getMotsByZoom: (zoom: number) => import("../../types").RealtimeMot[];
44
46
  getGeneralizationLevelByZoom: (zoom: number) => import("../../types").RealtimeGeneralizationLevel;
45
47
  getRenderTimeIntervalByZoom: (zoom: number) => number;
46
48
  throttleRenderTrajectories: (viewState: import("../../types").ViewState, noInterpolate?: boolean | undefined) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"RealtimeLayer.d.ts","sourceRoot":"","sources":["../../../src/mapbox/layers/RealtimeLayer.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExD;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAM,aAAc,SAAQ,kBAAY;gBAC1B,OAAO,KAAK;IAqBxB;;;;;;OAMG;IAEH,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM;IAuC/C;;OAEG;IACH,aAAa;IAkBb;;;;;;OAMG;IACH,KAAK;IAQL;;;;OAIG;IACH,IAAI;IASJ,MAAM;IASN;;;OAGG;IACH,kBAAkB,CAChB,GAAG,EAAE,QAAQ,CAAC,kBAAkB,GAAG,UAAU,CAAC,aAAa;IAQ7D;;;;OAIG;IAEH,kBAAkB,CAAC,aAAa,CAAC,EAAE,OAAe;IAuDlD;;OAEG;IACH,kBAAkB;IAIlB,0BAA0B,CACxB,UAAU,EAAE,UAAU,EACtB,OAAO,KAAK,GAC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b;;;;;;OAMG;IACH,KAAK;IAQL;;;;OAIG;IACH,IAAI;IASJ,MAAM;IASN;;;OAGG;IACH,kBAAkB,CAChB,GAAG,EAAE,QAAQ,CAAC,kBAAkB,GAAG,UAAU,CAAC,aAAa;IAQ7D;;;;OAIG;IAEH,kBAAkB,CAAC,aAAa,CAAC,EAAE,OAAe;IAuDlD;;OAEG;IACH,kBAAkB;IAIlB,0BAA0B,CACxB,UAAU,EAAE,UAAU,EACtB,OAAO,KAAK,GACX,OAAO,CAAC,2BAA2B,CAAC;IAQvC,kBAAkB;IAclB;;;;OAIG;IACH,eAAe,CACb,UAAU,EAAE,kBAAkB,EAC9B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACxC,IAAI,EAAE,MAAM;IASd;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM;IAUhE;;;;OAIG;IACH,MAAM;IAIN,0BAA0B,CACxB,SAAS,EAAE,SAAS,EACpB,aAAa,GAAE,OAAe;IAahC;;;;;OAKG;IACH,SAAS;IAQT;;;;;OAKG;IACH,cAAc,CACZ,QAAQ,EAAE,OAAO,EAAE,EACnB,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,UAAU;CAOzB;AAED,eAAe,aAAa,CAAC"}
package/mbt.js CHANGED
@@ -33293,6 +33293,7 @@ uniform ${i3} ${o3} u_${a3};
33293
33293
  StopsAPI: () => StopsAPI_default,
33294
33294
  VectorLayer: () => VectorLayer_default2,
33295
33295
  WMSLayer: () => WMSLayer_default,
33296
+ compareDepartures: () => compareDepartures_default,
33296
33297
  createRealtimeFilters: () => createRealtimeFilters_default,
33297
33298
  debounceDeparturesMessages: () => debounceDeparturesMessages_default,
33298
33299
  debounceWebsocketMessages: () => debounceWebsocketMessages_default,
@@ -35879,7 +35880,7 @@ uniform ${i3} ${o3} u_${a3};
35879
35880
  var sortAndFilterDepartures_default = sortAndfilterDepartures;
35880
35881
 
35881
35882
  // src/common/utils/debounceDeparturesMessages.ts
35882
- var debounceDeparturesMessages = (onDeparturesUpdate, sortByMinArrivalTime = true, maxDepartureAge = 30, timeout = 100) => {
35883
+ var debounceDeparturesMessages = (onDeparturesUpdate, sortByMinArrivalTime = false, maxDepartureAge = 30, timeout = 100) => {
35883
35884
  const departureUpdateTimeout = {};
35884
35885
  const departureObject = {};
35885
35886
  return (data) => {
@@ -49135,9 +49136,23 @@ uniform ${i3} ${o3} u_${a3};
49135
49136
  this.mode = options.mode || RealtimeModes.TOPOGRAPHIC;
49136
49137
  this.api = options.api || new RealtimeAPI_default(options);
49137
49138
  this.tenant = options.tenant || "";
49138
- this.minZoomNonTrain = options.minZoomNonTrain || 9;
49139
49139
  this.minZoomInterpolation = options.minZoomInterpolation || 8;
49140
49140
  this.format = new GeoJSON_default();
49141
+ const allMots = [
49142
+ "tram",
49143
+ "subway",
49144
+ "rail",
49145
+ "bus",
49146
+ "ferry",
49147
+ "cablecar",
49148
+ "gondola",
49149
+ "funicular",
49150
+ "coach"
49151
+ ];
49152
+ this.motsByZoom = options.motsByZoom || [allMots];
49153
+ this.getMotsByZoom = (zoom) => {
49154
+ return options.getMotsByZoom && options.getMotsByZoom(zoom, this.motsByZoom) || this.motsByZoom[zoom] || this.motsByZoom[this.motsByZoom.length - 1];
49155
+ };
49141
49156
  this.generalizationLevelByZoom = options.generalizationLevelByZoom || [
49142
49157
  5,
49143
49158
  5,
@@ -49209,6 +49224,7 @@ uniform ${i3} ${o3} u_${a3};
49209
49224
  } = options;
49210
49225
  let currSpeed = speed || 1;
49211
49226
  let currTime = time || new Date();
49227
+ let currStyle = style || realtimeDefaultStyle_default;
49212
49228
  super.defineProperties(options);
49213
49229
  Object.defineProperties(this, {
49214
49230
  isTrackerLayer: { value: true },
@@ -49216,7 +49232,11 @@ uniform ${i3} ${o3} u_${a3};
49216
49232
  value: canvas2 || document.createElement("canvas")
49217
49233
  },
49218
49234
  style: {
49219
- value: style || realtimeDefaultStyle_default
49235
+ get: () => currStyle,
49236
+ set: (newStyle) => {
49237
+ currStyle = newStyle;
49238
+ this.renderTrajectories();
49239
+ }
49220
49240
  },
49221
49241
  styleOptions: {
49222
49242
  value: { ...realtimeConfig_exports, ...styleOptions || {} }
@@ -49399,6 +49419,10 @@ uniform ${i3} ${o3} u_${a3};
49399
49419
  if (this.generalizationLevel) {
49400
49420
  bbox.push(`gen=${this.generalizationLevel}`);
49401
49421
  }
49422
+ this.mots = this.getMotsByZoom(zoom);
49423
+ if (this.mots) {
49424
+ bbox.push(`mots=${this.mots}`);
49425
+ }
49402
49426
  }
49403
49427
  this.api.bbox = bbox;
49404
49428
  }
@@ -49466,7 +49490,7 @@ uniform ${i3} ${o3} u_${a3};
49466
49490
  }
49467
49491
  purgeTrajectory(trajectory, extent, zoom) {
49468
49492
  const { type, bounds } = trajectory.properties;
49469
- if (!intersects(extent, bounds) || type !== "rail" && zoom < (this.minZoomNonTrain || 9)) {
49493
+ if (!intersects(extent, bounds) || this.mots && !this.mots.includes(type) || type !== "rail" && zoom < 9) {
49470
49494
  this.removeTrajectory(trajectory);
49471
49495
  return true;
49472
49496
  }
@@ -49651,6 +49675,8 @@ uniform ${i3} ${o3} u_${a3};
49651
49675
  super({
49652
49676
  ...options
49653
49677
  });
49678
+ this.allowRenderWhenAnimating = false;
49679
+ this.allowRenderWhenAnimating = !!options.allowRenderWhenAnimating;
49654
49680
  this.olLayer = options.olLayer || new Group_default({
49655
49681
  layers: [
49656
49682
  new Vector_default({
@@ -49757,7 +49783,7 @@ uniform ${i3} ${o3} u_${a3};
49757
49783
  return false;
49758
49784
  }
49759
49785
  let isRendered = false;
49760
- const blockRendering = this.map.getView().getAnimating() || this.map.getView().getInteracting();
49786
+ const blockRendering = this.allowRenderWhenAnimating ? false : this.map.getView().getAnimating() || this.map.getView().getInteracting();
49761
49787
  isRendered = blockRendering ? false : super.renderTrajectoriesInternal(viewState, noInterpolate);
49762
49788
  if (isRendered) {
49763
49789
  this.renderedViewState = { ...viewState };
@@ -49912,6 +49938,7 @@ uniform ${i3} ${o3} u_${a3};
49912
49938
  RealtimeModes: () => RealtimeModes,
49913
49939
  RoutingAPI: () => RoutingAPI_default,
49914
49940
  StopsAPI: () => StopsAPI_default,
49941
+ compareDepartures: () => compareDepartures_default,
49915
49942
  createRealtimeFilters: () => createRealtimeFilters_default,
49916
49943
  debounceDeparturesMessages: () => debounceDeparturesMessages_default,
49917
49944
  debounceWebsocketMessages: () => debounceWebsocketMessages_default,