mobility-toolbox-js 2.0.0-beta.53 → 2.0.0-beta.55

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 (34) hide show
  1. package/api/RealtimeAPI.d.ts +71 -81
  2. package/api/RealtimeAPI.d.ts.map +1 -1
  3. package/api/RealtimeAPI.js +98 -265
  4. package/common/api/WebSocketAPI.d.ts +13 -15
  5. package/common/api/WebSocketAPI.d.ts.map +1 -1
  6. package/common/mixins/RealtimeLayerMixin.d.ts +11 -8
  7. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
  8. package/common/mixins/RealtimeLayerMixin.js +36 -7
  9. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  10. package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
  11. package/common/utils/debounceDeparturesMessages.js +24 -0
  12. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  13. package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
  14. package/common/utils/debounceWebsocketMessages.js +29 -0
  15. package/common/utils/index.d.ts +3 -0
  16. package/common/utils/index.js +3 -0
  17. package/common/utils/sortAndFilterDepartures.d.ts +16 -0
  18. package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
  19. package/common/utils/sortAndFilterDepartures.js +58 -0
  20. package/mapbox/layers/RealtimeLayer.d.ts +7 -5
  21. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -1
  22. package/mbt.js +203 -246
  23. package/mbt.js.map +3 -3
  24. package/mbt.min.js +11 -11
  25. package/mbt.min.js.map +3 -3
  26. package/ol/layers/RealtimeLayer.d.ts +9 -6
  27. package/ol/layers/RealtimeLayer.d.ts.map +1 -1
  28. package/ol/layers/RealtimeLayer.js +3 -3
  29. package/package.json +1 -1
  30. package/types/common.d.ts +1 -1
  31. package/types/realtime.d.ts +0 -2
  32. package/common/utils/cleanStopTime.d.ts +0 -8
  33. package/common/utils/cleanStopTime.d.ts.map +0 -1
  34. package/common/utils/cleanStopTime.js +0 -25
@@ -5,8 +5,9 @@ import { Coordinate } from 'ol/coordinate';
5
5
  import { ObjectEvent } from 'ol/Object';
6
6
  import Layer from './Layer';
7
7
  import { RealtimeLayerMixinOptions } from '../../common/mixins/RealtimeLayerMixin';
8
- import { AnyMap, LayerGetFeatureInfoResponse, RealtimeTrainId } from '../../types';
8
+ import { AnyMap, LayerGetFeatureInfoResponse, RealtimeFullTrajectory, RealtimeTrainId } from '../../types';
9
9
  import { RealtimeTrajectory } from '../../api/typedefs';
10
+ import { WebSocketAPIMessageEventData } from '../../common/api/WebSocketAPI';
10
11
  export declare type OlRealtimeLayerOptions = RealtimeLayerMixinOptions & {
11
12
  fullTrajectoryStyle: (feature: FeatureLike, resolution: number, options: any) => void;
12
13
  };
@@ -29,7 +30,6 @@ declare const RealtimeLayer_base: {
29
30
  style?: import("../../types").RealtimeStyleFunction | undefined;
30
31
  styleOptions?: import("../../types").RealtimeStyleOptions | undefined;
31
32
  pixelRatio?: number | undefined;
32
- minZoomNonTrain: number;
33
33
  minZoomInterpolation: number;
34
34
  isUpdateBboxOnMoveEnd: boolean;
35
35
  hoverVehicleId?: string | undefined;
@@ -38,6 +38,8 @@ declare const RealtimeLayer_base: {
38
38
  useRequestAnimationFrame?: boolean | undefined;
39
39
  useDebounce?: boolean | undefined;
40
40
  useThrottle?: boolean | undefined;
41
+ mots?: import("../../types").RealtimeMot[] | undefined;
42
+ motsByZoom: import("../../types").RealtimeMot[][];
41
43
  generalizationLevel?: import("../../types").RealtimeGeneralizationLevel | undefined;
42
44
  generalizationLevelByZoom: import("../../types").RealtimeGeneralizationLevel[];
43
45
  renderTimeIntervalByZoom: number[];
@@ -47,6 +49,7 @@ declare const RealtimeLayer_base: {
47
49
  updateTimeDelay?: number | undefined;
48
50
  visibilityRef: import("ol/events").EventsKey;
49
51
  selectedVehicle: GeoJSONFeature;
52
+ getMotsByZoom: (zoom: number) => import("../../types").RealtimeMot[];
50
53
  getGeneralizationLevelByZoom: (zoom: number) => import("../../types").RealtimeGeneralizationLevel;
51
54
  getRenderTimeIntervalByZoom: (zoom: number) => number;
52
55
  throttleRenderTrajectories: (viewState: import("../../types").ViewState, noInterpolate?: boolean | undefined) => void;
@@ -70,16 +73,16 @@ declare const RealtimeLayer_base: {
70
73
  coordinate: Coordinate;
71
74
  }>;
72
75
  getTrajectoryInfos(id: string): Promise<{
73
- stopSequence: unknown;
74
- fullTrajectory: unknown;
76
+ stopSequence: WebSocketAPIMessageEventData<RealtimeFullTrajectory> | WebSocketAPIMessageEventData<GeoJSONFeature[]>;
77
+ fullTrajectory: WebSocketAPIMessageEventData<RealtimeFullTrajectory> | WebSocketAPIMessageEventData<GeoJSONFeature[]>;
75
78
  }>;
76
79
  purgeTrajectory(trajectory: GeoJSONFeature, extent: [number, number, number, number], zoom: number): boolean;
77
80
  addTrajectory(trajectory: GeoJSONFeature): void;
78
81
  removeTrajectory(trajectoryOrId: any): void;
79
82
  onZoomEnd(): void;
80
83
  onDocumentVisibilityChange(): void;
81
- onTrajectoryMessage(data: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData): void;
82
- onDeleteTrajectoryMessage(data: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData): void;
84
+ onTrajectoryMessage(data: WebSocketAPIMessageEventData<GeoJSONFeature>): void;
85
+ onDeleteTrajectoryMessage(data: WebSocketAPIMessageEventData<string>): void;
83
86
  onFeatureHover(features: Feature<import("ol/geom/Geometry").default>[], layer: import("../../types").AnyRealtimeLayer, coordinate: Coordinate): void;
84
87
  onFeatureClick(features: Feature<import("ol/geom/Geometry").default>[], layer: import("../../types").AnyRealtimeLayer, coordinate: Coordinate): void;
85
88
  };
@@ -1 +1 @@
1
- {"version":3,"file":"RealtimeLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/RealtimeLayer.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAKxC,OAAO,OAAO,EAAE,EAAE,WAAW,EAAE,MAAM,YA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CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM;IAUhE;;;OAGG;IACH,mBAAmB,CAAC,EAAE,EAAE,eAAe;IAmBvC;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,sBAAsB;CAGzC;AAED,eAAe,aAAa,CAAC"}
@@ -281,9 +281,9 @@ class RealtimeLayer extends mixin(Layer) {
281
281
  highlightTrajectory(id) {
282
282
  this.api
283
283
  .getFullTrajectory(id, this.mode, this.generalizationLevel)
284
- .then((fullTrajectory) => {
285
- const vectorSource = this.vectorLayer.getSource();
286
- vectorSource.clear();
284
+ .then((data) => {
285
+ const fullTrajectory = data.content;
286
+ this.vectorLayer.getSource().clear();
287
287
  if (!fullTrajectory ||
288
288
  !fullTrajectory.features ||
289
289
  !fullTrajectory.features.length) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mobility-toolbox-js",
3
3
  "license": "MIT",
4
4
  "description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
5
- "version": "2.0.0-beta.53",
5
+ "version": "2.0.0-beta.55",
6
6
  "main": "index.js",
7
7
  "exports": {
8
8
  ".": "./index.js",
package/types/common.d.ts CHANGED
@@ -16,7 +16,7 @@ import type {
16
16
  } from '../ol';
17
17
  import { RealtimeTrajectory } from '../api/typedefs';
18
18
  import CommonLayer, { LayerCommonOptions } from '../common/layers/LayerCommon';
19
- import { RoutingParameters } from '.';
19
+ import type { RoutingParameters } from '.';
20
20
 
21
21
  export type StyleCache = { [key: string]: AnyCanvas };
22
22
 
@@ -132,8 +132,6 @@ export interface RealtimeStop {
132
132
  state?: RealtimeStopState;
133
133
  stationId: RealtimeStationId;
134
134
  stationName: string;
135
- arrivalTimeWithDelay: number; // TODO: add by cleanStopTime function
136
- departureTimeWithDelay: number; // TODO: add by cleanStopTime function
137
135
  }
138
136
 
139
137
  export interface RealtimeStopSequence {
@@ -1,8 +0,0 @@
1
- import { RealtimeStopSequence } from '../../types';
2
- /**
3
- * Remove the delay from arrivalTime and departureTime
4
- * @private
5
- */
6
- declare const cleanStopTime: (content: RealtimeStopSequence) => RealtimeStopSequence;
7
- export default cleanStopTime;
8
- //# sourceMappingURL=cleanStopTime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cleanStopTime.d.ts","sourceRoot":"","sources":["../../../src/common/utils/cleanStopTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD;;;GAGG;AACH,QAAA,MAAM,aAAa,YAAa,oBAAoB,KAAG,oBAmBtD,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,25 +0,0 @@
1
- /**
2
- * Remove the delay from arrivalTime and departureTime
3
- * @private
4
- */
5
- const cleanStopTime = (content) => {
6
- content.stations.forEach((station) => {
7
- // eslint-disable-next-line no-param-reassign
8
- station.arrivalTimeWithDelay = station.arrivalTime;
9
- if (station.departureTime) {
10
- // eslint-disable-next-line no-param-reassign
11
- station.departureTimeWithDelay = station.departureTime;
12
- }
13
- if (station.arrivalDelay) {
14
- // eslint-disable-next-line no-param-reassign
15
- station.arrivalTime -= station.arrivalDelay;
16
- if (station.departureTime) {
17
- // eslint-disable-next-line no-param-reassign
18
- station.departureTime -= station.arrivalDelay;
19
- }
20
- }
21
- });
22
- // eslint-disable-next-line consistent-return
23
- return content;
24
- };
25
- export default cleanStopTime;