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

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 (55) hide show
  1. package/common/controls/ControlCommon.d.ts.map +1 -1
  2. package/common/controls/ControlCommon.js +3 -3
  3. package/common/controls/StopFinderControlCommon.d.ts +1 -0
  4. package/common/controls/StopFinderControlCommon.d.ts.map +1 -1
  5. package/common/controls/StopFinderControlCommon.js +3 -2
  6. package/common/utils/getMapboxRender.d.ts +2 -2
  7. package/common/utils/getMapboxRender.d.ts.map +1 -1
  8. package/common/utils/getMapboxRender.js +20 -11
  9. package/mapbox/index.d.ts +1 -0
  10. package/mapbox/index.js +1 -0
  11. package/mapbox/layers/Layer.d.ts +19 -7
  12. package/mapbox/layers/Layer.d.ts.map +1 -1
  13. package/mapbox/layers/Layer.js +8 -4
  14. package/mapbox/layers/RealtimeLayer.d.ts +112 -53
  15. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -1
  16. package/mapbox/layers/RealtimeLayer.js +14 -8
  17. package/mapbox/utils/getMercatorResolution.d.ts +9 -0
  18. package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
  19. package/mapbox/utils/getMercatorResolution.js +18 -0
  20. package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
  21. package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
  22. package/mapbox/{utils.js → utils/getSourceCoordinates.js} +6 -22
  23. package/mapbox/utils/index.d.ts +3 -0
  24. package/mapbox/utils/index.d.ts.map +1 -0
  25. package/mapbox/utils/index.js +2 -0
  26. package/mbt.js +116 -84
  27. package/mbt.js.map +3 -3
  28. package/mbt.min.js +13 -13
  29. package/mbt.min.js.map +3 -3
  30. package/ol/controls/CopyrightControl.d.ts.map +1 -1
  31. package/ol/controls/CopyrightControl.js +0 -1
  32. package/ol/controls/RoutingControl.d.ts +1 -0
  33. package/ol/controls/RoutingControl.d.ts.map +1 -1
  34. package/ol/controls/RoutingControl.js +1 -1
  35. package/ol/controls/StopFinderControl.d.ts.map +1 -1
  36. package/ol/layers/Layer.d.ts +4 -16
  37. package/ol/layers/Layer.d.ts.map +1 -1
  38. package/ol/layers/MapboxLayer.d.ts +11 -1
  39. package/ol/layers/MapboxLayer.d.ts.map +1 -1
  40. package/ol/layers/MapboxLayer.js +4 -4
  41. package/ol/layers/MapboxStyleLayer.d.ts +55 -78
  42. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -1
  43. package/ol/layers/MapboxStyleLayer.js +63 -32
  44. package/ol/layers/VectorLayer.d.ts +6 -4
  45. package/ol/layers/VectorLayer.d.ts.map +1 -1
  46. package/ol/layers/WMSLayer.d.ts +15 -11
  47. package/ol/layers/WMSLayer.d.ts.map +1 -1
  48. package/ol/layers/WMSLayer.js +25 -9
  49. package/ol/styles/fullTrajectoryDelayStyle.d.ts +2 -2
  50. package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -1
  51. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
  52. package/package.json +1 -1
  53. package/types/common.d.ts +1 -0
  54. package/mapbox/utils.d.ts +0 -8
  55. package/mapbox/utils.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ControlCommon.d.ts","sourceRoot":"","sources":["../../../src/common/controls/ControlCommon.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,oBAAY,oBAAoB,GAAG;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,cAAM,aAAc,SAAQ,UAAU;IACpC,MAAM,EAAE,OAAO,CAAC;IAEhB,GAAG,CAAC,EAAE,MAAM,CAA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;OAKG;IAEH,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG;IAKpB;;;;;OAKG;IAEH,oBAAoB;CAMrB;AAED,eAAe,aAAa,CAAC"}
@@ -122,7 +122,7 @@ class ControlCommon extends BaseObject {
122
122
  // eslint-disable-next-line class-methods-use-this
123
123
  deactivate() {
124
124
  // eslint-disable-next-line no-console
125
- console.error('This function must be implemented in subclasses');
125
+ console.error('The function deactivate() must be implemented in subclasses');
126
126
  }
127
127
  /**
128
128
  * The default render function. It renders content in the HTML element.
@@ -133,7 +133,7 @@ class ControlCommon extends BaseObject {
133
133
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
134
134
  render(options) {
135
135
  // eslint-disable-next-line no-console
136
- console.error('This function must be implemented in subclasses');
136
+ console.error('The function render() must be implemented in subclasses');
137
137
  }
138
138
  /**
139
139
  * The default element to display if this.element is not defined.
@@ -144,7 +144,7 @@ class ControlCommon extends BaseObject {
144
144
  // eslint-disable-next-line class-methods-use-this
145
145
  createDefaultElement() {
146
146
  // eslint-disable-next-line no-console
147
- console.error('This function must be implemented in subclasses');
147
+ console.error('The function createDefaultElement() must be implemented in subclasses');
148
148
  }
149
149
  }
150
150
  export default ControlCommon;
@@ -31,6 +31,7 @@ declare class StopFinderControlCommon extends ControlCommon {
31
31
  * @param {StopsSearchParams} [options.apiParams={ limit: 20 }] Request parameters. See [Stops service documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
32
32
  */
33
33
  constructor(options: StopFinderControlCommonOptions);
34
+ deactivate(): void;
34
35
  render(featureCollection?: FeatureCollection): void;
35
36
  createDefaultElement(): void;
36
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"StopFinderControlCommon.d.ts","sourceRoot":"","sources":["../../../src/common/controls/StopFinderControlCommon.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,Q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,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,aAAa,EAAE,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEtE,oBAAY,8BAA8B,GAAG,oBAAoB,GAC/D,eAAe,GAAG;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;CAC5B,CAAC;AAEJ;;;;GAIG;AACH,cAAM,uBAAwB,SAAQ,aAAa;IACjD,SAAS,EAAE,eAAe,CAAC;IAE3B,WAAW,EAAE,MAAM,CAAC;IAEpB,GAAG,EAAE,QAAQ,CAAC;IAEd,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC,cAAc,CAAC,EAAE,WAAW,CAAC;IAE7B,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAE5B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B;;;;;;;;OAQG;gBACS,OAAO,EAAE,8BAA8B;IAenD,UAAU;IAEV,MAAM,CAAC,iBAAiB,CAAC,EAAE,iBAAiB;IAwB5C,oBAAoB;IAuDpB;;;;;;OAMG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe;IAsBlD;;OAEG;IAEH,iBAAiB,CAAC,UAAU,EAAE,OAAO;IAErC;;OAEG;IACH,KAAK;CASN;AAED,eAAe,uBAAuB,CAAC"}
@@ -17,9 +17,9 @@ class StopFinderControlCommon extends ControlCommon {
17
17
  */
18
18
  constructor(options) {
19
19
  super(options);
20
- const { apiParams, apiKey, url } = options;
20
+ const { apiParams, apiKey, url, placeholder } = options || {};
21
21
  this.apiParams = Object.assign({ limit: 20 }, (apiParams || {}));
22
- this.placeholder = options.placeholder || 'Search for a stop...';
22
+ this.placeholder = placeholder || 'Search for a stop...';
23
23
  const apiOptions = { apiKey };
24
24
  if (url) {
25
25
  apiOptions.url = url;
@@ -27,6 +27,7 @@ class StopFinderControlCommon extends ControlCommon {
27
27
  this.api = new StopsAPI(apiOptions);
28
28
  this.abortController = new AbortController();
29
29
  }
30
+ deactivate() { }
30
31
  render(featureCollection) {
31
32
  const suggestions = (featureCollection === null || featureCollection === void 0 ? void 0 : featureCollection.features) || [];
32
33
  if (!this.suggestionsElt) {
@@ -1,7 +1,7 @@
1
1
  import { FrameState } from 'ol/PluggableMap';
2
- import type { AnyMapboxLayer } from '../../types';
2
+ import { MapboxLayer } from '../../ol';
3
3
  /**
4
4
  * Return the render function fo the olLayer of a MaplibreLayer
5
5
  */
6
- export default function getMapboxRender(mapoxLayer: AnyMapboxLayer): (frameState: FrameState) => HTMLElement;
6
+ export default function getMapboxRender(mapoxLayer: MapboxLayer): (frameState: FrameState) => HTMLElement;
7
7
  //# sourceMappingURL=getMapboxRender.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getMapboxRender.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getMapboxRender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAU,EAAE,cAAc,GACzB,CAAC,UAAU,EAAE,UAAU,KAAK,WAAW,CA4EzC"}
1
+ {"version":3,"file":"getMapboxRender.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getMapboxRender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAU,EAAE,WAAW,GACtB,CAAC,UAAU,EAAE,UAAU,KAAK,WAAW,CAuFzC"}
@@ -6,59 +6,68 @@ export default function getMapboxRender(mapoxLayer) {
6
6
  return (frameState) => {
7
7
  const { map, mbMap, renderState, olLayer } = mapoxLayer;
8
8
  if (!map || !mbMap) {
9
- return null;
9
+ return document.createElement('div');
10
10
  }
11
11
  let changed = false;
12
12
  const canvas = mbMap.getCanvas();
13
13
  const { viewState } = frameState;
14
- const visible = olLayer.getVisible();
15
- if (renderState.visible !== visible) {
14
+ const visible = olLayer === null || olLayer === void 0 ? void 0 : olLayer.getVisible();
15
+ if (renderState && (renderState === null || renderState === void 0 ? void 0 : renderState.visible) !== visible) {
16
16
  canvas.style.display = visible ? 'block' : 'none';
17
17
  renderState.visible = visible;
18
18
  // Needed since mapbox-gl 1.9.0.
19
19
  // Without you don't see others ol layers on top.
20
20
  canvas.style.position = 'absolute';
21
21
  }
22
- const opacity = olLayer.getOpacity();
23
- if (renderState.opacity !== opacity) {
22
+ const opacity = olLayer === null || olLayer === void 0 ? void 0 : olLayer.getOpacity();
23
+ if (canvas && renderState && renderState.opacity !== opacity) {
24
+ // @ts-ignore
24
25
  canvas.style.opacity = opacity;
25
26
  renderState.opacity = opacity;
26
27
  }
27
28
  // adjust view parameters in mapbox
28
29
  const { rotation } = viewState;
29
- if (renderState.rotation !== rotation) {
30
+ if (renderState && renderState.rotation !== rotation) {
30
31
  mbMap.rotateTo((-(rotation || 0) * 180) / Math.PI, {
31
32
  animate: false,
32
33
  });
33
34
  changed = true;
34
35
  renderState.rotation = rotation;
35
36
  }
36
- if (renderState.zoom !== viewState.zoom ||
37
- renderState.center[0] !== viewState.center[0] ||
38
- renderState.center[1] !== viewState.center[1]) {
37
+ if (renderState &&
38
+ renderState.center &&
39
+ (renderState.zoom !== viewState.zoom ||
40
+ renderState.center[0] !== viewState.center[0] ||
41
+ renderState.center[1] !== viewState.center[1])) {
39
42
  mbMap.jumpTo({
40
43
  center: toLonLat(viewState.center),
41
44
  zoom: viewState.zoom - 1,
42
- animate: false,
43
45
  });
44
46
  changed = true;
45
47
  renderState.zoom = viewState.zoom;
46
48
  renderState.center = viewState.center;
47
49
  }
48
50
  const size = map.getSize() || [0, 0];
49
- if (renderState.size[0] !== size[0] || renderState.size[1] !== size[1]) {
51
+ if (renderState &&
52
+ renderState.size &&
53
+ (renderState.size[0] !== size[0] || renderState.size[1] !== size[1])) {
50
54
  changed = true;
51
55
  renderState.size = size;
52
56
  }
53
57
  // cancel the scheduled update & trigger synchronous redraw
54
58
  // see https://github.com/mapbox/mapbox-gl-js/issues/7893#issue-408992184
55
59
  // NOTE: THIS MIGHT BREAK WHEN UPDATING MAPBOX
60
+ // @ts-ignore
56
61
  if (mbMap && mbMap.style && mbMap.isStyleLoaded() && changed) {
57
62
  try {
63
+ // @ts-ignore
58
64
  if (mbMap._frame) {
65
+ // @ts-ignore
59
66
  mbMap._frame.cancel();
67
+ // @ts-ignore
60
68
  mbMap._frame = null;
61
69
  }
70
+ // @ts-ignore
62
71
  mbMap._render();
63
72
  }
64
73
  catch (err) {
package/mapbox/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export * from "../api";
2
2
  export * from "../common";
3
3
  export * from "./controls";
4
4
  export * from "./layers";
5
+ export * from "./utils";
5
6
  //# sourceMappingURL=index.d.ts.map
package/mapbox/index.js CHANGED
@@ -2,3 +2,4 @@ export * from '../api';
2
2
  export * from '../common';
3
3
  export * from './controls';
4
4
  export * from './layers';
5
+ export * from './utils';
@@ -1,4 +1,7 @@
1
- export default Layer;
1
+ import { EventsKey } from 'ol/events';
2
+ import LayerCommon, { LayerCommonOptions } from '../../common/layers/LayerCommon';
3
+ import { AnyMapboxMap, UserInteractionCallback } from '../../types';
4
+ declare const Layer_base: typeof LayerCommon;
2
5
  /**
3
6
  * A class representing a layer to display on an OpenLayers map.
4
7
  *
@@ -14,13 +17,21 @@ export default Layer;
14
17
  * @classproperty {ol/Map~Map} map - The map where the layer is displayed.
15
18
  * @extends {Layer}
16
19
  */
17
- declare class Layer {
20
+ declare class Layer extends Layer_base {
21
+ options: LayerCommonOptions;
22
+ onChangeVisibleKey?: EventsKey;
23
+ userInteractions?: boolean;
24
+ userClickInteractions?: boolean;
25
+ userHoverInteractions?: boolean;
26
+ userClickCallbacks?: UserInteractionCallback[];
27
+ userHoverCallbacks?: UserInteractionCallback[];
28
+ onUserClickCallback: () => void;
29
+ onUserMoveCallback: () => void;
18
30
  /**
19
31
  * Initialize the layer and listen to user events.
20
- * @param {ol/Map~Map} map
32
+ * @param {mapboxgl.Map|maplibregl.Map} map
21
33
  */
22
- attachToMap(map: any): void;
23
- onChangeVisibleKey: any;
34
+ attachToMap(map: AnyMapboxMap): void;
24
35
  detachFromMap(): void;
25
36
  activateUserInteractions(): void;
26
37
  deactivateUserInteractions(): void;
@@ -28,7 +39,7 @@ declare class Layer {
28
39
  * Toggle listeners needed when a layer is avisible or not.
29
40
  * @private
30
41
  */
31
- private toggleVisibleListeners;
42
+ toggleVisibleListeners(): void;
32
43
  /**
33
44
  * Returns the current extent in mercator coordinates.
34
45
  */
@@ -42,6 +53,7 @@ declare class Layer {
42
53
  * @param {Object} newOptions Options to override
43
54
  * @return {Layer} A Layer
44
55
  */
45
- clone(newOptions: Object): Layer;
56
+ clone(newOptions: LayerCommonOptions): Layer;
46
57
  }
58
+ export default Layer;
47
59
  //# sourceMappingURL=Layer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/mapbox/layers/Layer.js"],"names":[],"mappings":";AAKA;;;;;;;;;;;;;;GAcG;AACH;IACE;;;OAGG;IACH,4BAcC;IALG,wBAGC;IAIL,sBAMC;IAED,iCAmBC;IAED,mCAKC;IAED;;;OAGG;IACH,+BAMC;IAED;;OAEG;IACH,gDAOC;IAED;;OAEG;IACH,iBAEC;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACL,KAAK,CAIhB;CACF"}
1
+ {"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/mapbox/layers/Layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,WAAW,EAAE,EAClB,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;;AAEpE;;;;;;;;;;;;;;GAcG;AACH,cAAM,KAAM,SAAQ,UAAkC;IACpD,OAAO,EAAG,kBAAkB,CAAC;IAE7B,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAI/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,mBAAmB,EAAG,MAAM,IAAI,CAAC;IAEjC,kBAAkB,EAAG,MAAM,IAAI,CAAC;IAEhC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,YAAY;IAiB7B,aAAa;IASb,wBAAwB;IAqBxB,0BAA0B;IAO1B;;;OAGG;IACH,sBAAsB;IAQtB;;OAEG;IACH,iBAAiB;IASjB;;OAEG;IACH,SAAS;IAIT;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,kBAAkB;CAGrC;AACD,eAAe,KAAK,CAAC"}
@@ -20,7 +20,7 @@ import userInteractionsMixin from '../../common/mixins/UserInteractionsLayerMixi
20
20
  class Layer extends userInteractionsMixin(LayerCommon) {
21
21
  /**
22
22
  * Initialize the layer and listen to user events.
23
- * @param {ol/Map~Map} map
23
+ * @param {mapboxgl.Map|maplibregl.Map} map
24
24
  */
25
25
  attachToMap(map) {
26
26
  super.attachToMap(map);
@@ -29,28 +29,32 @@ class Layer extends userInteractionsMixin(LayerCommon) {
29
29
  }
30
30
  if (this.userInteractions) {
31
31
  this.toggleVisibleListeners();
32
- this.onChangeVisibleKey = this.on('change:visible', this.toggleVisibleListeners);
32
+ this.onChangeVisibleKey = this.on(
33
+ // @ts-ignore
34
+ 'change:visible', this.toggleVisibleListeners);
33
35
  }
34
36
  }
35
37
  detachFromMap() {
36
38
  if (this.map) {
37
39
  this.deactivateUserInteractions();
40
+ // @ts-ignore
38
41
  unByKey(this.onChangeVisibleKey);
39
42
  }
40
43
  super.detachFromMap();
41
44
  }
42
45
  activateUserInteractions() {
46
+ var _a, _b;
43
47
  this.deactivateUserInteractions();
44
48
  if (this.map &&
45
49
  this.userInteractions &&
46
50
  this.userClickInteractions &&
47
- this.userClickCallbacks.length) {
51
+ ((_a = this.userClickCallbacks) === null || _a === void 0 ? void 0 : _a.length)) {
48
52
  this.map.on('click', this.onUserClickCallback);
49
53
  }
50
54
  if (this.map &&
51
55
  this.userInteractions &&
52
56
  this.userHoverInteractions &&
53
- this.userHoverCallbacks.length) {
57
+ ((_b = this.userHoverCallbacks) === null || _b === void 0 ? void 0 : _b.length)) {
54
58
  this.map.on('mousemove', this.onUserMoveCallback);
55
59
  }
56
60
  }
@@ -1,4 +1,83 @@
1
- export default RealtimeLayer;
1
+ /// <reference types="mapbox-gl" />
2
+ import { Coordinate } from 'ol/coordinate';
3
+ import { Feature } from 'ol';
4
+ import Layer from './Layer';
5
+ import { AnyMapboxMap, LayerGetFeatureInfoOptions, LayerGetFeatureInfoResponse } from '../../types';
6
+ import { RealtimeTrajectory } from '../../api/typedefs';
7
+ declare const RealtimeLayer_base: {
8
+ new (options: import("../../common/mixins/RealtimeLayerMixin").RealtimeLayerMixinOptions): {
9
+ [x: string]: any;
10
+ debug: boolean;
11
+ trajectories?: {
12
+ [key: string]: GeoJSONFeature;
13
+ } | undefined;
14
+ canvas?: import("../../types").AnyCanvas | undefined;
15
+ mode: import("../../types").RealtimeMode;
16
+ api: import("../../api/RealtimeAPI").default;
17
+ tenant: string;
18
+ time?: Date | undefined;
19
+ live?: boolean | undefined;
20
+ speed?: number | undefined;
21
+ filter?: Function | undefined;
22
+ sort?: Function | undefined;
23
+ style?: import("../../types").RealtimeStyleFunction | undefined;
24
+ styleOptions?: import("../../types").RealtimeStyleOptions | undefined;
25
+ pixelRatio?: number | undefined;
26
+ minZoomNonTrain: number;
27
+ minZoomInterpolation: number;
28
+ isUpdateBboxOnMoveEnd: boolean;
29
+ hoverVehicleId?: string | undefined;
30
+ selectedVehicleId?: string | undefined;
31
+ renderState?: import("../../types").RealtimeRenderState | undefined;
32
+ useRequestAnimationFrame?: boolean | undefined;
33
+ useDebounce?: boolean | undefined;
34
+ useThrottle?: boolean | undefined;
35
+ generalizationLevel?: import("../../types").RealtimeGeneralizationLevel | undefined;
36
+ generalizationLevelByZoom: import("../../types").RealtimeGeneralizationLevel[];
37
+ renderTimeIntervalByZoom: number[];
38
+ format: import("ol/format/GeoJSON").default;
39
+ requestId?: number | undefined;
40
+ updateTimeInterval?: number | undefined;
41
+ updateTimeDelay?: number | undefined;
42
+ visibilityRef: import("ol/events").EventsKey;
43
+ selectedVehicle: GeoJSONFeature;
44
+ getGeneralizationLevelByZoom: (zoom: number) => import("../../types").RealtimeGeneralizationLevel;
45
+ getRenderTimeIntervalByZoom: (zoom: number) => number;
46
+ throttleRenderTrajectories: (viewState: import("../../types").ViewState, noInterpolate?: boolean | undefined) => void;
47
+ debounceRenderTrajectories: (viewState: import("../../types").ViewState, noInterpolate?: boolean | undefined) => void;
48
+ defineProperties(options: import("../../common/mixins/RealtimeLayerMixin").RealtimeLayerMixinOptions): void;
49
+ attachToMap(map: any): void;
50
+ detachFromMap(): void;
51
+ start(): void;
52
+ startUpdateTime(): void;
53
+ stop(): void;
54
+ stopUpdateTime(): void;
55
+ renderTrajectoriesInternal(viewState: import("../../types").ViewState, noInterpolate?: boolean): boolean;
56
+ renderTrajectories(viewState: import("../../types").ViewState | undefined, noInterpolate: boolean | undefined): void;
57
+ setBbox(extent?: [number, number, number, number] | undefined, zoom?: number | undefined): void;
58
+ setMode(mode: import("../../types").RealtimeMode): void;
59
+ getRefreshTimeInMs(zoom?: number | undefined): number;
60
+ getVehicle(filterFc: Function): GeoJSONFeature[];
61
+ getFeatureInfoAtCoordinate(coordinate: Coordinate, options: LayerGetFeatureInfoOptions): Promise<{
62
+ layer: any;
63
+ features: Feature<import("ol/geom/Geometry").default>[];
64
+ coordinate: Coordinate;
65
+ }>;
66
+ getTrajectoryInfos(id: string): Promise<{
67
+ stopSequence: unknown;
68
+ fullTrajectory: unknown;
69
+ }>;
70
+ purgeTrajectory(trajectory: GeoJSONFeature, extent: [number, number, number, number], zoom: number): boolean;
71
+ addTrajectory(trajectory: GeoJSONFeature): void;
72
+ removeTrajectory(trajectoryOrId: any): void;
73
+ onZoomEnd(): void;
74
+ onDocumentVisibilityChange(): void;
75
+ onTrajectoryMessage(data: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData): void;
76
+ onDeleteTrajectoryMessage(data: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData): void;
77
+ onFeatureHover(features: Feature<import("ol/geom/Geometry").default>[], layer: import("../../types").AnyRealtimeLayer, coordinate: Coordinate): void;
78
+ onFeatureClick(features: Feature<import("ol/geom/Geometry").default>[], layer: import("../../types").AnyRealtimeLayer, coordinate: Coordinate): void;
79
+ };
80
+ } & typeof Layer;
2
81
  /**
3
82
  * Responsible for loading and display data from a Realtime service.
4
83
  *
@@ -16,25 +95,8 @@ export default RealtimeLayer;
16
95
  * @extends {Layer}
17
96
  * @implements {RealtimeLayerInterface}
18
97
  */
19
- declare class RealtimeLayer extends Layer implements RealtimeLayerInterface {
98
+ declare class RealtimeLayer extends RealtimeLayer_base {
20
99
  constructor(options?: {});
21
- onLoad(): void;
22
- /**
23
- * Callback on 'move' event.
24
- *
25
- * @private
26
- */
27
- private onMove;
28
- /**
29
- * Send the new BBOX to the websocket.
30
- *
31
- * @private
32
- * @override
33
- */
34
- private override onMoveEnd;
35
- /** @ignore */
36
- onZoomEnd: any;
37
- onVisibilityChange(): void;
38
100
  /**
39
101
  * Initialize the layer.
40
102
  *
@@ -42,29 +104,11 @@ declare class RealtimeLayer extends Layer implements RealtimeLayerInterface {
42
104
  * @param {string} beforeId Layer's id before which we want to add the new layer.
43
105
  * @override
44
106
  */
45
- override attachToMap(map: mapboxgl.Map, beforeId: string): void;
46
- source: {
47
- type: string;
48
- canvas: any;
49
- coordinates: number[][];
50
- animate: boolean;
51
- attribution: any;
52
- } | undefined;
53
- beforeId: string | undefined;
54
- layer: {
55
- id: any;
56
- type: string;
57
- source: any;
58
- layout: {
59
- visibility: string;
60
- };
61
- paint: {
62
- 'raster-opacity': number;
63
- 'raster-fade-duration': number;
64
- 'raster-resampling': string;
65
- };
66
- } | undefined;
67
- listeners: any[] | undefined;
107
+ attachToMap(map: AnyMapboxMap, beforeId: string): void;
108
+ /**
109
+ * Remove listeners from the Mapbox Map.
110
+ */
111
+ detachFromMap(): void;
68
112
  /**
69
113
  * Start updating vehicles position.
70
114
  *
@@ -72,47 +116,62 @@ declare class RealtimeLayer extends Layer implements RealtimeLayerInterface {
72
116
  * @listens {mapboxgl.map.event:mousemove} Listen to mousemove end.
73
117
  * @override
74
118
  */
75
- override start(): void;
119
+ start(): void;
76
120
  /**
77
121
  * Stop updating vehicles position, and unlisten events.
78
122
  *
79
123
  * @override
80
124
  */
81
- override stop(): void;
125
+ stop(): void;
126
+ onLoad(): void;
82
127
  /**
83
128
  * Function triggered when the user moves the cursor over the map.
84
129
  * @override
85
130
  */
86
- override onUserMoveCallback(evt: any): void;
131
+ onUserMoveCallback(evt: mapboxgl.MapLayerMouseEvent | maplibregl.MapMouseEvent): void;
87
132
  /**
88
133
  * Render the trajectories using current map's size, resolution and rotation.
89
134
  * @param {boolean} noInterpolate if true, renders the vehicles without interpolating theirs positions.
90
135
  * @overrides
91
136
  */
92
- renderTrajectories(noInterpolate: boolean): void;
137
+ renderTrajectories(noInterpolate?: boolean): void;
93
138
  /**
94
139
  * Return the delay in ms before the next rendering.
95
140
  */
96
- getRefreshTimeInMs(): any;
97
- getFeatureInfoAtCoordinate(coordinate: any, options?: {}): any;
141
+ getRefreshTimeInMs(): number;
142
+ getFeatureInfoAtCoordinate(coordinate: Coordinate, options?: {}): Promise<LayerGetFeatureInfoResponse>;
143
+ onVisibilityChange(): void;
98
144
  /**
99
145
  * Remove the trajectory form the list if necessary.
100
146
  *
101
147
  * @private
102
148
  */
103
- private purgeTrajectory;
149
+ purgeTrajectory(trajectory: RealtimeTrajectory, extent: [number, number, number, number], zoom: number): boolean;
104
150
  /**
105
151
  * Send the current bbox to the websocket
106
152
  */
107
- setBbox(extent: any, zoom: any): void;
108
- renderTrajectoriesInternal(viewState: any, noInterpolate: any): any;
153
+ setBbox(extent?: [number, number, number, number], zoom?: number): void;
154
+ /**
155
+ * Callback on 'move' event.
156
+ *
157
+ * @private
158
+ */
159
+ onMove(): void;
160
+ renderTrajectoriesInternal(viewState: ViewState, noInterpolate?: boolean): boolean;
161
+ /**
162
+ * Send the new BBOX to the websocket.
163
+ *
164
+ * @private
165
+ * @override
166
+ */
167
+ onMoveEnd(): void;
109
168
  /**
110
169
  * Update the cursor style when hovering a vehicle.
111
170
  *
112
171
  * @private
113
172
  * @override
114
173
  */
115
- private override onFeatureHover;
174
+ onFeatureHover(features: Feature[], layer: RealtimeLayer, coordinate: Coordinate): void;
116
175
  }
117
- import Layer from "./Layer";
176
+ export default RealtimeLayer;
118
177
  //# sourceMappingURL=RealtimeLayer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RealtimeLayer.d.ts","sourceRoot":"","sources":["../../../src/mapbox/layers/RealtimeLayer.js"],"names":[],"mappings":";AASA;;;;;;;;;;;;;;;;GAgBG;AACH,qDAFgB,sBAAsB;IAGpC,0BAmBC;IAuGD,eAOC;IA0HD;;;;OAIG;IACH,eAEC;IAcD;;;;;OAKG;IACH,2BAMC;IA9QC,cAAc;IACd,eAA0C;IAoM5C,2BAYC;IA1MD;;;;;;OAMG;IACH,0BAJW,YAAY,YACZ,MAAM,QA8ChB;IA/BC;;;;;;kBAOC;IAED,6BAAwB;IACxB;;;;;;;;;;;;kBAYC;IAQD,6BAAqE;IAuBvE;;;;;;OAMG;IACH,uBAMC;IAED;;;;OAIG;IACH,sBAOC;IAWD;;;OAGG;IACH,4CAKC;IAED;;;;OAIG;IAC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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"}
@@ -23,6 +23,7 @@ import { getSourceCoordinates, getMercatorResolution } from '../utils';
23
23
  * @extends {Layer}
24
24
  * @implements {RealtimeLayerInterface}
25
25
  */
26
+ // @ts-ignore
26
27
  class RealtimeLayer extends mixin(Layer) {
27
28
  constructor(options = {}) {
28
29
  super(Object.assign({}, options));
@@ -44,15 +45,12 @@ class RealtimeLayer extends mixin(Layer) {
44
45
  * @param {string} beforeId Layer's id before which we want to add the new layer.
45
46
  * @override
46
47
  */
48
+ // @ts-ignore
47
49
  attachToMap(map, beforeId) {
48
50
  if (!map) {
49
51
  return;
50
52
  }
51
- const canvas = map.getCanvas();
52
- super.attachToMap(map, {
53
- width: canvas.width / this.pixelRatio,
54
- height: canvas.height / this.pixelRatio,
55
- });
53
+ super.attachToMap(map);
56
54
  this.source = {
57
55
  type: 'canvas',
58
56
  canvas: this.canvas,
@@ -87,6 +85,7 @@ class RealtimeLayer extends mixin(Layer) {
87
85
  detachFromMap() {
88
86
  if (this.map) {
89
87
  this.map.off('load', this.onLoad);
88
+ // @ts-ignore
90
89
  this.listeners.forEach((listener) => {
91
90
  unByKey(listener);
92
91
  });
@@ -145,10 +144,14 @@ class RealtimeLayer extends mixin(Layer) {
145
144
  * @param {boolean} noInterpolate if true, renders the vehicles without interpolating theirs positions.
146
145
  * @overrides
147
146
  */
148
- renderTrajectories(noInterpolate) {
147
+ // @ts-ignore
148
+ renderTrajectories(noInterpolate = false) {
149
149
  if (!this.map) {
150
150
  return;
151
151
  }
152
+ if (!this.pixelRatio) {
153
+ this.pixelRatio = 1;
154
+ }
152
155
  const { width, height } = this.map.getCanvas();
153
156
  const center = this.map.getCenter();
154
157
  // We use turf here to have good transform.
@@ -156,7 +159,10 @@ class RealtimeLayer extends mixin(Layer) {
156
159
  x: 0,
157
160
  y: height / this.pixelRatio,
158
161
  }); // southWest
159
- const rightTop = this.map.unproject({ x: width / this.pixelRatio, y: 0 }); // north east
162
+ const rightTop = this.map.unproject({
163
+ x: width / this.pixelRatio,
164
+ y: 0,
165
+ }); // north east
160
166
  const coord0 = transformRotate(point([leftBottom.lng, leftBottom.lat]), -this.map.getBearing(), {
161
167
  pivot: [center.lng, center.lat],
162
168
  }).geometry.coordinates;
@@ -231,7 +237,7 @@ class RealtimeLayer extends mixin(Layer) {
231
237
  onMove() {
232
238
  this.renderTrajectories();
233
239
  }
234
- renderTrajectoriesInternal(viewState, noInterpolate) {
240
+ renderTrajectoriesInternal(viewState, noInterpolate = false) {
235
241
  const render = super.renderTrajectoriesInternal(viewState, noInterpolate);
236
242
  if (render && this.map.style) {
237
243
  const extent = getSourceCoordinates(this.map, this.pixelRatio);
@@ -0,0 +1,9 @@
1
+ import { AnyMapboxMap } from '../../types';
2
+ /**
3
+ * Get the current resolution of a Mapbox map.
4
+ * @param {mapboxgl.Map} map A map object.
5
+ * @private
6
+ */
7
+ declare const getMercatorResolution: (map: AnyMapboxMap) => number;
8
+ export default getMercatorResolution;
9
+ //# sourceMappingURL=getMercatorResolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMercatorResolution.d.ts","sourceRoot":"","sources":["../../../src/mapbox/utils/getMercatorResolution.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;GAIG;AACH,QAAA,MAAM,qBAAqB,QAAS,YAAY,WAS/C,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { getWidth, getHeight } from 'ol/extent';
2
+ import { fromLonLat } from 'ol/proj';
3
+ /**
4
+ * Get the current resolution of a Mapbox map.
5
+ * @param {mapboxgl.Map} map A map object.
6
+ * @private
7
+ */
8
+ const getMercatorResolution = (map) => {
9
+ const bounds = map.getBounds().toArray();
10
+ const a = fromLonLat(bounds[0]);
11
+ const b = fromLonLat(bounds[1]);
12
+ const extent = [...a, ...b];
13
+ const { width, height } = map.getCanvas();
14
+ const xResolution = getWidth(extent) / width;
15
+ const yResolution = getHeight(extent) / height;
16
+ return Math.max(xResolution, yResolution);
17
+ };
18
+ export default getMercatorResolution;
@@ -0,0 +1,9 @@
1
+ import { AnyMapboxMap } from '../../types';
2
+ /**
3
+ * Get the canvas source coordinates of the current map's extent.
4
+ * @param {mapboxgl.Map} map A map object.
5
+ * @private
6
+ */
7
+ export declare const getSourceCoordinates: (map: AnyMapboxMap, pixelRatio?: number) => number[][];
8
+ export default getSourceCoordinates;
9
+ //# sourceMappingURL=getSourceCoordinates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSourceCoordinates.d.ts","sourceRoot":"","sources":["../../../src/mapbox/utils/getSourceCoordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAC1B,YAAY,eACL,MAAM,eAsBnB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}