mobility-toolbox-js 3.0.0-beta.8 → 3.0.0

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 (130) hide show
  1. package/README.md +11 -3
  2. package/api/HttpAPI.d.ts +20 -0
  3. package/api/HttpAPI.js +1 -14
  4. package/api/RealtimeAPI.d.ts +404 -0
  5. package/api/RealtimeAPI.js +265 -206
  6. package/api/RoutingAPI.d.ts +47 -0
  7. package/api/RoutingAPI.js +17 -7
  8. package/api/StopsAPI.d.ts +44 -0
  9. package/api/StopsAPI.js +17 -11
  10. package/api/WebSocketAPI.d.ts +147 -0
  11. package/api/WebSocketAPI.js +164 -165
  12. package/api/index.d.ts +3 -0
  13. package/api/index.js +1 -1
  14. package/api/typedefs.d.ts +76 -0
  15. package/api/typedefs.js +27 -42
  16. package/common/controls/StopFinderControlCommon.d.ts +53 -0
  17. package/common/controls/StopFinderControlCommon.js +32 -32
  18. package/common/index.d.ts +2 -0
  19. package/common/index.js +1 -1
  20. package/common/styles/index.d.ts +4 -0
  21. package/common/styles/realtimeDefaultStyle.d.ts +36 -0
  22. package/common/styles/realtimeDefaultStyle.js +6 -11
  23. package/common/styles/realtimeDelayStyle.d.ts +12 -0
  24. package/common/styles/realtimeHeadingStyle.d.ts +12 -0
  25. package/common/styles/realtimeHeadingStyle.js +5 -10
  26. package/common/styles/realtimeSimpleStyle.d.ts +3 -0
  27. package/common/styles/realtimeSimpleStyle.js +0 -1
  28. package/common/typedefs.d.ts +102 -0
  29. package/common/typedefs.js +6 -31
  30. package/common/utils/RealtimeEngine.d.ts +214 -0
  31. package/common/utils/RealtimeEngine.js +554 -0
  32. package/common/utils/compareDepartures.d.ts +10 -0
  33. package/common/utils/compareDepartures.js +2 -2
  34. package/common/utils/constants.d.ts +5 -0
  35. package/common/utils/createCanvas.d.ts +10 -0
  36. package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
  37. package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
  38. package/common/utils/createRealtimeFilters.d.ts +12 -0
  39. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  40. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  41. package/common/utils/getLayersAsFlatArray.d.ts +2 -0
  42. package/common/utils/getLayersAsFlatArray.js +0 -1
  43. package/common/utils/getMapGlCopyrights.d.ts +17 -0
  44. package/common/utils/getMapGlCopyrights.js +3 -3
  45. package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
  46. package/common/utils/getRealtimeModeSuffix.js +1 -0
  47. package/common/utils/getUrlWithParams.d.ts +8 -0
  48. package/common/utils/getVehiclePosition.d.ts +17 -0
  49. package/common/utils/getVehiclePosition.js +6 -3
  50. package/common/utils/index.d.ts +16 -0
  51. package/common/utils/realtimeConfig.d.ts +64 -0
  52. package/common/utils/realtimeConfig.js +0 -1
  53. package/common/utils/removeDuplicate.d.ts +9 -0
  54. package/common/utils/renderTrajectories.d.ts +17 -0
  55. package/common/utils/renderTrajectories.js +7 -6
  56. package/common/utils/sortAndFilterDepartures.d.ts +16 -0
  57. package/common/utils/sortAndFilterDepartures.js +2 -1
  58. package/common/utils/sortByDelay.d.ts +3 -0
  59. package/common/utils/sortByDelay.js +5 -1
  60. package/common/utils/timeUtils.d.ts +23 -0
  61. package/common/utils/toMercatorExtent.d.ts +5 -0
  62. package/iife.d.ts +2 -0
  63. package/index.d.ts +9 -0
  64. package/maplibre/controls/CopyrightControl.d.ts +38 -0
  65. package/maplibre/controls/CopyrightControl.js +11 -8
  66. package/maplibre/controls/index.d.ts +1 -0
  67. package/maplibre/index.d.ts +5 -0
  68. package/maplibre/layers/Layer.d.ts +29 -0
  69. package/maplibre/layers/Layer.js +2 -3
  70. package/maplibre/layers/RealtimeLayer.d.ts +124 -0
  71. package/maplibre/layers/RealtimeLayer.js +154 -118
  72. package/maplibre/layers/index.d.ts +2 -0
  73. package/maplibre/utils/getMercatorResolution.d.ts +7 -0
  74. package/maplibre/utils/getSourceCoordinates.d.ts +8 -0
  75. package/maplibre/utils/getSourceCoordinates.js +6 -5
  76. package/maplibre/utils/index.d.ts +2 -0
  77. package/mbt.js +14585 -14557
  78. package/mbt.js.map +4 -4
  79. package/mbt.min.js +75 -75
  80. package/mbt.min.js.map +4 -4
  81. package/ol/controls/CopyrightControl.d.ts +39 -0
  82. package/ol/controls/CopyrightControl.js +13 -5
  83. package/ol/controls/RoutingControl.d.ts +213 -0
  84. package/ol/controls/RoutingControl.js +250 -264
  85. package/ol/controls/StopFinderControl.d.ts +56 -0
  86. package/ol/controls/StopFinderControl.js +24 -5
  87. package/ol/controls/index.d.ts +3 -0
  88. package/ol/index.d.ts +6 -0
  89. package/ol/layers/Layer.d.ts +26 -0
  90. package/ol/layers/Layer.js +39 -0
  91. package/ol/layers/MaplibreLayer.d.ts +91 -0
  92. package/ol/layers/MaplibreLayer.js +154 -31
  93. package/ol/layers/MaplibreStyleLayer.d.ts +157 -0
  94. package/ol/layers/MaplibreStyleLayer.js +281 -210
  95. package/ol/layers/RealtimeLayer.d.ts +150 -0
  96. package/ol/layers/RealtimeLayer.js +210 -206
  97. package/ol/layers/VectorLayer.d.ts +17 -0
  98. package/ol/layers/VectorLayer.js +33 -0
  99. package/ol/layers/index.d.ts +5 -0
  100. package/ol/layers/index.js +3 -0
  101. package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -0
  102. package/ol/renderers/MaplibreLayerRenderer.js +142 -114
  103. package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
  104. package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
  105. package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
  106. package/ol/renderers/RealtimeLayerRenderer.js +50 -70
  107. package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
  108. package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
  109. package/ol/styles/fullTrajectoryStyle.d.ts +4 -0
  110. package/ol/styles/fullTrajectoryStyle.js +5 -7
  111. package/ol/styles/index.d.ts +3 -0
  112. package/ol/styles/routingStyle.d.ts +3 -0
  113. package/ol/styles/routingStyle.js +13 -10
  114. package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
  115. package/ol/utils/defineDeprecatedProperties.js +180 -0
  116. package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
  117. package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
  118. package/ol/utils/index.d.ts +1 -0
  119. package/package.json +44 -44
  120. package/setupTests.d.ts +1 -0
  121. package/setupTests.js +17 -4
  122. package/types/common.d.ts +53 -69
  123. package/types/index.d.ts +1 -1
  124. package/types/realtime.d.ts +98 -95
  125. package/types/routing.d.ts +60 -60
  126. package/types/stops.d.ts +62 -62
  127. package/common/mixins/RealtimeLayerMixin.js +0 -743
  128. package/ol/layers/MapGlLayer.js +0 -142
  129. package/ol/mixins/MobilityLayerMixin.js +0 -9
  130. package/ol/mixins/PropertiesLayerMixin.js +0 -142
@@ -13,12 +13,12 @@ class StopFinderControlCommon {
13
13
  * @param {Object} options Options
14
14
  * @param {HTMLElement} options.element HTML element where to attach input and suggestions.
15
15
  * @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/). See StopsAPI.
16
- * @param {string} [options.url='https://api.geops.io/tracker/v1'] Stops service url. See StopsAPI.
16
+ * @param {string} [options.url='https://api.geops.io/stops/v1/'] Stops service url. See StopsAPI.
17
17
  * @param {string} [options.placeholder='Search for a stop...'] Input field placeholder.
18
18
  * @param {StopsSearchParams} [options.apiParams={ limit: 20 }] Request parameters. See [Stops service documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
19
19
  */
20
20
  constructor(options) {
21
- const { apiParams, apiKey, url, placeholder } = options || {};
21
+ const { apiKey, apiParams, placeholder, url } = options || {};
22
22
  this.apiParams = Object.assign({ limit: 20 }, (apiParams || {}));
23
23
  this.placeholder = placeholder || 'Search for a stop...';
24
24
  const apiOptions = { apiKey };
@@ -30,26 +30,16 @@ class StopFinderControlCommon {
30
30
  this.createElement(options);
31
31
  this.options = options;
32
32
  }
33
- render(featureCollection) {
34
- const suggestions = (featureCollection === null || featureCollection === void 0 ? void 0 : featureCollection.features) || [];
35
- if (!this.suggestionsElt) {
33
+ /**
34
+ * Clear the search field and close the control.
35
+ */
36
+ clear() {
37
+ if (!this.suggestionsElt || !this.inputElt || !this.clearElt) {
36
38
  return;
37
39
  }
38
- this.suggestionsElt.style.display = suggestions.length ? 'block' : 'none';
40
+ this.inputElt.value = '';
39
41
  this.suggestionsElt.innerHTML = '';
40
- suggestions.forEach((suggestion) => {
41
- var _a, _b;
42
- const suggElt = document.createElement('div');
43
- suggElt.innerHTML = (_a = suggestion === null || suggestion === void 0 ? void 0 : suggestion.properties) === null || _a === void 0 ? void 0 : _a.name;
44
- suggElt.onclick = (evt) => {
45
- var _a, _b;
46
- (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.onSuggestionClick) === null || _b === void 0 ? void 0 : _b.call(_a, suggestion, evt);
47
- };
48
- Object.assign(suggElt.style, {
49
- padding: '5px 12px',
50
- });
51
- (_b = this.suggestionsElt) === null || _b === void 0 ? void 0 : _b.appendChild(suggElt);
52
- });
42
+ this.clearElt.style.display = 'none';
53
43
  }
54
44
  createElement({ element }) {
55
45
  // Create input element
@@ -61,7 +51,7 @@ class StopFinderControlCommon {
61
51
  var _a;
62
52
  (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
63
53
  this.abortController = new AbortController();
64
- // @ts-ignore
54
+ // @ts-expect-error - Improve ts
65
55
  this.search(evt.target.value, this.abortController);
66
56
  };
67
57
  Object.assign(this.inputElt.style, {
@@ -72,38 +62,48 @@ class StopFinderControlCommon {
72
62
  this.suggestionsElt = document.createElement('div');
73
63
  Object.assign(this.suggestionsElt.style, {
74
64
  backgroundColor: 'white',
75
- overflowY: 'auto',
76
65
  cursor: 'pointer',
66
+ overflowY: 'auto',
77
67
  });
78
68
  element.appendChild(this.suggestionsElt);
79
69
  this.clearElt = document.createElement('div');
80
70
  Object.assign(this.clearElt.style, {
71
+ cursor: 'pointer',
81
72
  display: 'none',
73
+ fontSize: '200%',
74
+ padding: '0 10px',
82
75
  position: 'absolute',
83
76
  right: '0',
84
- padding: '0 10px',
85
- fontSize: '200%',
86
- cursor: 'pointer',
87
77
  });
88
78
  this.clearElt.innerHTML = '×';
89
79
  this.clearElt.onclick = () => this.clear();
90
80
  element.appendChild(this.clearElt);
91
81
  }
92
- /**
93
- * Clear the search field and close the control.
94
- */
95
- clear() {
96
- if (!this.suggestionsElt || !this.inputElt || !this.clearElt) {
82
+ render(featureCollection) {
83
+ const suggestions = (featureCollection === null || featureCollection === void 0 ? void 0 : featureCollection.features) || [];
84
+ if (!this.suggestionsElt) {
97
85
  return;
98
86
  }
99
- this.inputElt.value = '';
87
+ this.suggestionsElt.style.display = suggestions.length ? 'block' : 'none';
100
88
  this.suggestionsElt.innerHTML = '';
101
- this.clearElt.style.display = 'none';
89
+ suggestions.forEach((suggestion) => {
90
+ var _a, _b;
91
+ const suggElt = document.createElement('div');
92
+ suggElt.innerHTML = (_a = suggestion === null || suggestion === void 0 ? void 0 : suggestion.properties) === null || _a === void 0 ? void 0 : _a.name;
93
+ suggElt.onclick = (evt) => {
94
+ var _a, _b;
95
+ (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.onSuggestionClick) === null || _b === void 0 ? void 0 : _b.call(_a, suggestion, evt);
96
+ };
97
+ Object.assign(suggElt.style, {
98
+ padding: '5px 12px',
99
+ });
100
+ (_b = this.suggestionsElt) === null || _b === void 0 ? void 0 : _b.appendChild(suggElt);
101
+ });
102
102
  }
103
103
  /**
104
104
  * Launch a search.
105
105
  *
106
- * @param {String} query The query to search for.
106
+ * @param {String} q The query to search for.
107
107
  * @param {AbortController} abortController Abort controller used to cancel the request.
108
108
  * @return {Promise<Array<GeoJSONFeature>>} An array of GeoJSON features with coordinates in [EPSG:4326](http://epsg.io/4326).
109
109
  */
@@ -0,0 +1,2 @@
1
+ export * from "./styles";
2
+ export * from "./utils";
package/common/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './utils';
2
1
  export * from './styles';
2
+ export * from './utils';
@@ -0,0 +1,4 @@
1
+ export { default as realtimeDefaultStyle } from "./realtimeDefaultStyle";
2
+ export { default as realtimeDelayStyle } from "./realtimeDelayStyle";
3
+ export { default as realtimeSimpleStyle } from "./realtimeSimpleStyle";
4
+ export * from "./realtimeDefaultStyle";
@@ -0,0 +1,36 @@
1
+ import type { RealtimeStyleFunction } from '../../types';
2
+ /**
3
+ * Draw circle delay background
4
+ *
5
+ * @private
6
+ */
7
+ export declare const getDelayBgCanvas: (origin: number, radius: number, color: string) => import("../../types").AnyCanvas | null;
8
+ /**
9
+ * Draw delay text
10
+ *
11
+ * @private
12
+ */
13
+ export declare const getDelayTextCanvas: (text: string, fontSize: number, font: string, delayColor: string, delayOutlineColor?: string, pixelRatio?: number) => import("../../types").AnyCanvas | null;
14
+ /**
15
+ * Draw colored circle with black border
16
+ *
17
+ * @private
18
+ */
19
+ export declare const getCircleCanvas: (origin: number, radius: number, color: string, hasStroke: boolean, hasDash: boolean, pixelRatio: number) => import("../../types").AnyCanvas | null;
20
+ /**
21
+ * Draw text in the circle
22
+ *
23
+ * @private
24
+ */
25
+ export declare const getTextCanvas: (text: string, origin: number, textSize: number, fillColor: string, strokeColor: string, hasStroke: boolean, pixelRatio: number, getTextFont: (fontSize: number, text?: string) => string) => import("../../types").AnyCanvas | null;
26
+ /**
27
+ * A tracker style that take in account the delay.
28
+ *
29
+ * @param {RealtimeTrajectory} trajectory The trajectory to render.
30
+ * @param {ViewState} viewState The view state of the map.
31
+ * @param {RealtimeStyleOptions} options Some options to change the rendering
32
+ * @return a canvas
33
+ * @private
34
+ */
35
+ declare const realtimeDefaultStyle: RealtimeStyleFunction;
36
+ export default realtimeDefaultStyle;
@@ -1,5 +1,4 @@
1
1
  import createCanvas from '../utils/createCanvas';
2
- /** @private */
3
2
  const cacheDelayBg = {};
4
3
  /**
5
4
  * Draw circle delay background
@@ -25,7 +24,6 @@ export const getDelayBgCanvas = (origin, radius, color) => {
25
24
  }
26
25
  return cacheDelayBg[key];
27
26
  };
28
- /** @private */
29
27
  const cacheDelayText = {};
30
28
  /**
31
29
  * Draw delay text
@@ -55,7 +53,6 @@ export const getDelayTextCanvas = (text, fontSize, font, delayColor, delayOutlin
55
53
  }
56
54
  return cacheDelayText[key];
57
55
  };
58
- /** @private */
59
56
  const cacheCircle = {};
60
57
  /**
61
58
  * Draw colored circle with black border
@@ -90,7 +87,6 @@ export const getCircleCanvas = (origin, radius, color, hasStroke, hasDash, pixel
90
87
  }
91
88
  return cacheCircle[key];
92
89
  };
93
- /** @private */
94
90
  const cacheText = {};
95
91
  /**
96
92
  * Draw text in the circle
@@ -129,7 +125,6 @@ export const getTextCanvas = (text, origin, textSize, fillColor, strokeColor, ha
129
125
  }
130
126
  return cacheText[key];
131
127
  };
132
- /** @private */
133
128
  const cache = {};
134
129
  /**
135
130
  * A tracker style that take in account the delay.
@@ -141,11 +136,11 @@ const cache = {};
141
136
  * @private
142
137
  */
143
138
  const realtimeDefaultStyle = (trajectory, viewState, options) => {
144
- const { hoverVehicleId, selectedVehicleId, useDelayStyle, delayOutlineColor = '#000', delayDisplay = 300000, getRadius = () => 0, getBgColor = () => '#000', getDelayColor = () => '#000', getDelayText = () => null, getDelayFont = (fontSize) => `bold ${fontSize}px arial, sans-serif`, getText = (text) => text, getTextFont = (fontSize) => `bold ${fontSize}px arial, sans-serif`, getTextColor = () => '#000', getTextSize = () => 14, getMaxRadiusForText = () => 10, getMaxRadiusForStrokeAndDelay = () => 7, } = options;
145
- const { zoom, pixelRatio = 1 } = viewState;
139
+ const { delayDisplay = 300000, delayOutlineColor = '#000', getBgColor = () => '#000', getDelayColor = () => '#000', getDelayFont = (fontSize) => `bold ${fontSize}px arial, sans-serif`, getDelayText = () => null, getMaxRadiusForStrokeAndDelay = () => 7, getMaxRadiusForText = () => 10, getRadius = () => 0, getText = (text) => text, getTextColor = () => '#000', getTextFont = (fontSize) => `bold ${fontSize}px arial, sans-serif`, getTextSize = () => 14, hoverVehicleId, selectedVehicleId, useDelayStyle, } = options;
140
+ const { pixelRatio = 1, zoom } = viewState;
146
141
  let { type } = trajectory.properties;
147
- const { train_id: id, line, delay, state, operator_provides_realtime_journey: operatorProvidesRealtime, } = trajectory.properties;
148
- let { name, text_color: textColor, color } = line || {};
142
+ const { delay, line, operator_provides_realtime_journey: operatorProvidesRealtime, state, train_id: id, } = trajectory.properties;
143
+ let { color, name, text_color: textColor } = line || {};
149
144
  name = getText(name);
150
145
  const cancelled = state === 'JOURNEY_CANCELLED';
151
146
  if (!type) {
@@ -157,10 +152,10 @@ const realtimeDefaultStyle = (trajectory, viewState, options) => {
157
152
  if (!textColor) {
158
153
  textColor = '#000000';
159
154
  }
160
- if (color && color[0] !== '#') {
155
+ if (color && !color.startsWith('#')) {
161
156
  color = `#${color}`;
162
157
  }
163
- if (textColor[0] !== '#') {
158
+ if (!textColor.startsWith('#')) {
164
159
  textColor = `#${textColor}`;
165
160
  }
166
161
  const z = Math.min(Math.floor(zoom || 1), 16);
@@ -0,0 +1,12 @@
1
+ import type { RealtimeStyleFunction } from '../../types';
2
+ /**
3
+ * A tracker style that display the delay as backgroundColor.
4
+ *
5
+ * @param {*} trajectory The trajectory to render.
6
+ * @param {*} viewState The view state of the map.
7
+ * @param {*} options Some options to change the rendering
8
+ * @return a canvas
9
+ * @private
10
+ */
11
+ declare const realtimeDelayStyle: RealtimeStyleFunction;
12
+ export default realtimeDelayStyle;
@@ -0,0 +1,12 @@
1
+ import type { RealtimeStyleFunction } from '../../types';
2
+ /**
3
+ * A tracker style that take in account the delay.
4
+ *
5
+ * @param {RealtimeTrajectory} trajectory The trajectory to render.
6
+ * @param {ViewState} viewState The view state of the map.
7
+ * @param {RealtimeStyleOptions} options Some options to change the rendering
8
+ * @return a canvas
9
+ * @private
10
+ */
11
+ declare const realtimeHeadingStyle: RealtimeStyleFunction;
12
+ export default realtimeHeadingStyle;
@@ -1,16 +1,13 @@
1
1
  import createCanvas from '../utils/createCanvas';
2
2
  import { getBgColor } from '../utils/realtimeConfig';
3
3
  import realtimeDefaultStyle from './realtimeDefaultStyle';
4
- /** @private */
5
4
  const rotateCanvas = (canvas, rotation) => {
6
5
  const ctx = canvas.getContext('2d');
7
6
  ctx === null || ctx === void 0 ? void 0 : ctx.translate(canvas.width / 2, canvas.height / 2);
8
7
  ctx === null || ctx === void 0 ? void 0 : ctx.rotate(rotation);
9
8
  ctx === null || ctx === void 0 ? void 0 : ctx.translate(-canvas.width / 2, -canvas.height / 2);
10
9
  };
11
- /** @private */
12
10
  const arrowCache = {};
13
- /** @private */
14
11
  const getArrowCanvas = (fillColor) => {
15
12
  const key = `${fillColor}`;
16
13
  if (!arrowCache[key]) {
@@ -35,9 +32,7 @@ const getArrowCanvas = (fillColor) => {
35
32
  }
36
33
  return arrowCache[key];
37
34
  };
38
- /** @private */
39
35
  const bufferArrowCache = {};
40
- /** @private */
41
36
  const getBufferArrowCanvas = (canvas, fillColor, rotation) => {
42
37
  const margin = 20;
43
38
  const bufferKey = `${fillColor},${canvas.width},${canvas.height},${rotation}`;
@@ -67,9 +62,8 @@ const getBufferArrowCanvas = (canvas, fillColor, rotation) => {
67
62
  * @private
68
63
  */
69
64
  const realtimeHeadingStyle = (trajectory, viewState, options) => {
70
- var _a, _b;
71
- // @ts-ignore
72
- const { rotation, type, line } = trajectory.properties;
65
+ // @ts-expect-error improve types
66
+ const { line, rotation, type } = trajectory.properties;
73
67
  const { color } = line || {};
74
68
  const canvas = realtimeDefaultStyle(trajectory, viewState, options);
75
69
  if (canvas && rotation !== null) {
@@ -78,8 +72,9 @@ const realtimeHeadingStyle = (trajectory, viewState, options) => {
78
72
  if (bufferArrow) {
79
73
  const bufferSize = (bufferArrow.width - canvas.width) / 2;
80
74
  const vehicleWithArrow = createCanvas(bufferArrow.width, bufferArrow.height);
81
- (_a = vehicleWithArrow === null || vehicleWithArrow === void 0 ? void 0 : vehicleWithArrow.getContext('2d')) === null || _a === void 0 ? void 0 : _a.drawImage(bufferArrow, 0, 0, bufferArrow.width, bufferArrow.height);
82
- (_b = vehicleWithArrow === null || vehicleWithArrow === void 0 ? void 0 : vehicleWithArrow.getContext('2d')) === null || _b === void 0 ? void 0 : _b.drawImage(canvas, bufferSize, bufferSize, canvas.width, canvas.height);
75
+ const context = vehicleWithArrow === null || vehicleWithArrow === void 0 ? void 0 : vehicleWithArrow.getContext('2d');
76
+ context === null || context === void 0 ? void 0 : context.drawImage(bufferArrow, 0, 0, bufferArrow.width, bufferArrow.height);
77
+ context === null || context === void 0 ? void 0 : context.drawImage(canvas, bufferSize, bufferSize, canvas.width, canvas.height);
83
78
  return vehicleWithArrow;
84
79
  }
85
80
  }
@@ -0,0 +1,3 @@
1
+ import type { RealtimeStyleFunction } from '../../types';
2
+ declare const realtimeSimpleStyle: RealtimeStyleFunction;
3
+ export default realtimeSimpleStyle;
@@ -4,7 +4,6 @@ import createCanvas from '../utils/createCanvas';
4
4
  * Display blue point for each train.
5
5
  */
6
6
  let canvas;
7
- /** @private */
8
7
  const realtimeSimpleStyle = () => {
9
8
  if (!canvas) {
10
9
  canvas = createCanvas(15, 15);
@@ -0,0 +1,102 @@
1
+ export default dummy;
2
+ export type FilterFunction = Function;
3
+ export type SortFunction = Function;
4
+ export type getMotsByZoomFunction = Function;
5
+ export type ViewState = {
6
+ /**
7
+ * A time in ms.
8
+ */
9
+ time: number | undefined;
10
+ /**
11
+ * A center in mercator coordinate.
12
+ */
13
+ center: number[2] | undefined;
14
+ /**
15
+ * An Extent in mercator coordinates.
16
+ */
17
+ extent: number[4];
18
+ /**
19
+ * A size ([width, height]).
20
+ */
21
+ size: number[2];
22
+ /**
23
+ * A rotation in radians.
24
+ */
25
+ rotation: number;
26
+ /**
27
+ * A resolution.
28
+ */
29
+ resolution: number;
30
+ /**
31
+ * A zoom level.
32
+ */
33
+ zoom: number;
34
+ /**
35
+ * A pixel ratio.
36
+ */
37
+ pixelRatio: number | undefined;
38
+ };
39
+ export type FeatureInfo = {
40
+ /**
41
+ * A layer.
42
+ */
43
+ layer: Layer;
44
+ /**
45
+ * An array of features.
46
+ */
47
+ features: Feature[];
48
+ /**
49
+ * The coordinate where to find the featue.
50
+ */
51
+ coordinate: number[2];
52
+ };
53
+ export type VehiclePosition = {
54
+ /**
55
+ * Coordinate of the vehicle position in Mercator .
56
+ */
57
+ coord: number[2];
58
+ /**
59
+ * An angle in radians representing the direction (from the true north) towards which the vehicle is facing.
60
+ */
61
+ rotation: number;
62
+ };
63
+ /**
64
+ * @typedef {function} FilterFunction
65
+ * @param {Vehicle} vehicle Vehicle to filter.
66
+ * @returns boolean
67
+ */
68
+ /**
69
+ * @typedef {function} SortFunction
70
+ * @param {any} a Object a to compare.
71
+ * @param {any} b Object b to compare.
72
+ * @returns number
73
+ */
74
+ /**
75
+ * @typedef {function} getMotsByZoomFunction
76
+ * @param {number} zoom Curent zoom level.
77
+ * @param {RealtimeMot[][]} motsByZoom Default array of mots by zoom.
78
+ * @returns number
79
+ */
80
+ /**
81
+ * @typedef {Object} ViewState
82
+ * @property {number|undefined} time A time in ms.
83
+ * @property {number[2]|undefined} center A center in mercator coordinate.
84
+ * @property {number[4]} extent An Extent in mercator coordinates.
85
+ * @property {number[2]} size A size ([width, height]).
86
+ * @property {number} rotation A rotation in radians.
87
+ * @property {number} resolution A resolution.
88
+ * @property {number} zoom A zoom level.
89
+ * @property {number|undefined} pixelRatio A pixel ratio.
90
+ */
91
+ /**
92
+ * @typedef {Object} FeatureInfo
93
+ * @property {Layer} layer A layer.
94
+ * @property {Feature[]} features An array of features.
95
+ * @property {number[2]} coordinate The coordinate where to find the featue.
96
+ */
97
+ /**
98
+ * @typedef {Object} VehiclePosition
99
+ * @property {number[2]} coord Coordinate of the vehicle position in Mercator .
100
+ * @property {number!} rotation An angle in radians representing the direction (from the true north) towards which the vehicle is facing.
101
+ */
102
+ declare function dummy(): void;
@@ -9,6 +9,12 @@
9
9
  * @param {any} b Object b to compare.
10
10
  * @returns number
11
11
  */
12
+ /**
13
+ * @typedef {function} getMotsByZoomFunction
14
+ * @param {number} zoom Curent zoom level.
15
+ * @param {RealtimeMot[][]} motsByZoom Default array of mots by zoom.
16
+ * @returns number
17
+ */
12
18
  /**
13
19
  * @typedef {Object} ViewState
14
20
  * @property {number|undefined} time A time in ms.
@@ -26,37 +32,6 @@
26
32
  * @property {Feature[]} features An array of features.
27
33
  * @property {number[2]} coordinate The coordinate where to find the featue.
28
34
  */
29
- /**
30
- * @typedef {ol/Map~Map|maplibregl.Map} AnyMap
31
- */
32
- /**
33
- * @typedef {Object} MaplibreLayerOptions
34
- * @property {string} apiKey Access key for [geOps apis](https://developer.geops.io/).
35
- * @property {string} apiKeyName geOps Maps api key name.
36
- * @property {maplibregl.MapOptions} options.mapOptions Maplibre map options.
37
- * @property {string} style geOps Maps api style.
38
- * @property {string} url geOps Maps api url.
39
- */
40
- /**
41
- * @typedef {Object} ControlCommonOptions
42
- * @property {boolean} [active = true] Whether the control is active or not.
43
- * @property {HTMLElement} element The HTML element used to render the control.
44
- * @property {HTMLElement} target The HTML element where to render the element property. Default is the map's element.
45
- * @property {function} render Render function called whenever the control needs to be rerendered.
46
- */
47
- /**
48
- * @typedef {Object} LayerCommonOptions
49
- * @property {string!} key Identifier of the layer. Must be unique.
50
- * @property {string!} name Name of the layer.
51
- * @property {string!} group Group of the layer.
52
- * @property {string[]!} copyrights List of copyrights.
53
- * @property {Layer[]!} children List of children layers.
54
- * @property {boolean!} visible Define if the layer is currently display on the map.
55
- * @property {boolean!} disabled Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
56
- * @property {number!} hittolerance Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
57
- * @property {Object!} properties - Custom properties.
58
- * @property {AnyMap!} map - The map used to display the layer.
59
- */
60
35
  /**
61
36
  * @typedef {Object} VehiclePosition
62
37
  * @property {number[2]} coord Coordinate of the vehicle position in Mercator .