mobility-toolbox-js 3.0.0-beta.9 → 3.0.1-beta.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 (87) hide show
  1. package/api/HttpAPI.d.ts +5 -16
  2. package/api/HttpAPI.js +0 -11
  3. package/api/RealtimeAPI.d.ts +221 -176
  4. package/api/RealtimeAPI.js +317 -258
  5. package/api/RoutingAPI.d.ts +21 -11
  6. package/api/RoutingAPI.js +17 -7
  7. package/api/StopsAPI.d.ts +20 -14
  8. package/api/StopsAPI.js +17 -11
  9. package/api/WebSocketAPI.d.ts +60 -66
  10. package/api/WebSocketAPI.js +164 -164
  11. package/api/index.js +1 -1
  12. package/api/typedefs.d.ts +0 -102
  13. package/api/typedefs.js +27 -42
  14. package/common/controls/StopFinderControlCommon.d.ts +12 -12
  15. package/common/controls/StopFinderControlCommon.js +31 -31
  16. package/common/index.d.ts +1 -1
  17. package/common/index.js +1 -1
  18. package/common/mixins/RealtimeLayerMixin.d.ts +157 -163
  19. package/common/mixins/RealtimeLayerMixin.js +401 -393
  20. package/common/styles/realtimeDefaultStyle.js +6 -6
  21. package/common/styles/realtimeHeadingStyle.js +5 -5
  22. package/common/typedefs.d.ts +13 -6
  23. package/common/typedefs.js +7 -1
  24. package/common/utils/compareDepartures.d.ts +2 -2
  25. package/common/utils/compareDepartures.js +2 -2
  26. package/common/utils/debounceWebsocketMessages.d.ts +1 -1
  27. package/common/utils/getMapGlCopyrights.d.ts +1 -1
  28. package/common/utils/getMapGlCopyrights.js +3 -3
  29. package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
  30. package/common/utils/getRealtimeModeSuffix.js +1 -0
  31. package/common/utils/getVehiclePosition.d.ts +5 -4
  32. package/common/utils/getVehiclePosition.js +9 -3
  33. package/common/utils/renderTrajectories.d.ts +1 -1
  34. package/common/utils/renderTrajectories.js +6 -6
  35. package/common/utils/sortAndFilterDepartures.d.ts +1 -1
  36. package/common/utils/sortAndFilterDepartures.js +1 -1
  37. package/common/utils/sortByDelay.d.ts +2 -2
  38. package/common/utils/sortByDelay.js +5 -1
  39. package/maplibre/layers/Layer.d.ts +1 -1
  40. package/maplibre/layers/Layer.js +1 -1
  41. package/maplibre/layers/RealtimeLayer.d.ts +87 -66
  42. package/maplibre/layers/RealtimeLayer.js +30 -6
  43. package/maplibre/utils/getSourceCoordinates.js +5 -5
  44. package/mbt.js +20988 -13287
  45. package/mbt.js.map +4 -4
  46. package/mbt.min.js +61 -58
  47. package/mbt.min.js.map +4 -4
  48. package/ol/controls/RoutingControl.d.ts +82 -89
  49. package/ol/controls/RoutingControl.js +217 -219
  50. package/ol/controls/StopFinderControl.d.ts +3 -3
  51. package/ol/controls/StopFinderControl.js +2 -2
  52. package/ol/index.d.ts +1 -0
  53. package/ol/index.js +1 -0
  54. package/ol/layers/Layer.d.ts +101 -0
  55. package/ol/layers/Layer.js +25 -0
  56. package/ol/layers/MaplibreLayer.d.ts +121 -24
  57. package/ol/layers/MaplibreLayer.js +98 -27
  58. package/ol/layers/MaplibreStyleLayer.d.ts +93 -91
  59. package/ol/layers/MaplibreStyleLayer.js +281 -257
  60. package/ol/layers/RealtimeLayer.d.ts +119 -121
  61. package/ol/layers/RealtimeLayer.js +143 -134
  62. package/ol/layers/VectorLayer.d.ts +18 -0
  63. package/ol/layers/VectorLayer.js +32 -0
  64. package/ol/layers/index.d.ts +2 -0
  65. package/ol/layers/index.js +3 -0
  66. package/ol/mixins/MobilityLayerMixin.d.ts +32 -34
  67. package/ol/mixins/PropertiesLayerMixin.d.ts +60 -51
  68. package/ol/mixins/PropertiesLayerMixin.js +114 -79
  69. package/ol/mixins/index.d.ts +1 -0
  70. package/ol/mixins/index.js +2 -0
  71. package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
  72. package/ol/renderers/MaplibreLayerRenderer.js +142 -114
  73. package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
  74. package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
  75. package/ol/renderers/RealtimeLayerRenderer.d.ts +6 -6
  76. package/ol/renderers/RealtimeLayerRenderer.js +56 -51
  77. package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
  78. package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
  79. package/package.json +31 -31
  80. package/setupTests.js +3 -4
  81. package/types/common.d.ts +55 -48
  82. package/types/index.d.ts +1 -1
  83. package/types/realtime.d.ts +91 -93
  84. package/types/routing.d.ts +60 -60
  85. package/types/stops.d.ts +62 -62
  86. package/ol/layers/MapGlLayer.d.ts +0 -144
  87. package/ol/layers/MapGlLayer.js +0 -144
@@ -1,37 +1,34 @@
1
1
  import { Feature } from 'ol';
2
- import type { Map, MapBrowserEvent } from 'ol';
2
+ import Control, { Options } from 'ol/control/Control';
3
+ import { EventsKey } from 'ol/events';
4
+ import { GeoJSON } from 'ol/format';
3
5
  import { Geometry, LineString, Point } from 'ol/geom';
4
6
  import { Modify } from 'ol/interaction';
5
- import { GeoJSON } from 'ol/format';
6
- import type { Coordinate } from 'ol/coordinate';
7
- import type { StyleLike } from 'ol/style/Style';
8
- import { EventsKey } from 'ol/events';
9
7
  import { ModifyEvent } from 'ol/interaction/Modify';
10
8
  import VectorLayer from 'ol/layer/Vector';
11
- import VectorSource from 'ol/source/Vector';
12
- import Control, { Options } from 'ol/control/Control';
13
9
  import { RoutingAPI } from '../../api';
10
+ import type { Map, MapBrowserEvent } from 'ol';
11
+ import type { Coordinate } from 'ol/coordinate';
12
+ import type { StyleLike } from 'ol/style/Style';
14
13
  import type { RoutingGraph, RoutingMot, RoutingParameters, RoutingViaPoint } from '../../types';
15
- export type RoutingControlOptions = Options & {
16
- apiKey?: string;
14
+ export type RoutingControlOptions = {
17
15
  active?: boolean;
18
- stopsApiKey?: string;
19
- stopsApiUrl?: string;
20
- routingLayer?: VectorLayer<VectorSource<Feature<Geometry>>>;
16
+ apiKey?: string;
21
17
  graphs?: RoutingGraph[];
22
- mot?: string;
23
18
  modify?: boolean;
19
+ mot?: string;
20
+ onRouteError?: () => void;
24
21
  routingApiParams?: RoutingParameters;
25
- useRawViaPoints?: boolean;
22
+ routingLayer?: VectorLayer<Feature>;
26
23
  snapToClosestStation?: boolean;
24
+ stopsApiKey?: string;
25
+ stopsApiUrl?: string;
27
26
  style?: StyleLike;
28
- onRouteError?: () => void;
29
- };
30
- export type AbotControllersByGraph = {
31
- [key: string]: AbortController;
32
- };
27
+ useRawViaPoints?: boolean;
28
+ } & Options;
29
+ export type AbotControllersByGraph = Record<string, AbortController>;
33
30
  /**
34
- * Display a route of a specified mean of transport.
31
+ * This OpenLayers control allows the user to add and modifiy via points to a map and request a route from the [geOps Routing API](https://developer.geops.io/apis/routing/).
35
32
  *
36
33
  * @example
37
34
  * import { Map } from 'ol';
@@ -63,42 +60,30 @@ export type AbotControllersByGraph = {
63
60
  * @public
64
61
  */
65
62
  declare class RoutingControl extends Control {
66
- map?: Map;
67
- viaPoints: RoutingViaPoint[];
68
- routingLayer?: VectorLayer<VectorSource<Feature<Geometry>>>;
69
- graphs: RoutingGraph[];
70
- routingApiParams?: RoutingParameters;
71
- useRawViaPoints: boolean;
72
- snapToClosestStation: boolean;
73
- cacheStationData: {
74
- [key: string]: Coordinate;
75
- };
76
- abortControllers: {
77
- [key: string]: AbortController;
78
- };
79
- apiKey?: string;
80
- stopsApiKey?: string;
81
- segments: Feature<LineString>[];
82
- stopsApiUrl?: string;
63
+ abortControllers: Record<string, AbortController>;
83
64
  api?: RoutingAPI;
65
+ apiKey?: string;
66
+ cacheStationData: Record<string, Coordinate>;
84
67
  format: GeoJSON;
68
+ graphs: RoutingGraph[];
85
69
  graphsResolutions?: [number, number][];
86
- onRouteError: (error?: Error, control?: RoutingControl) => void;
87
- onMapClickKey?: EventsKey;
88
- modifyInteraction?: Modify;
89
70
  initialRouteDrag?: {
90
- viaPoint?: Feature<Point>;
91
71
  oldRoute?: Feature<LineString>;
92
72
  segmentIndex?: number;
73
+ viaPoint?: Feature<Point>;
93
74
  };
94
- get active(): boolean;
95
- set active(newValue: boolean);
96
- get loading(): boolean;
97
- set loading(newValue: boolean);
98
- get modify(): any;
99
- set modify(newValue: any);
100
- get mot(): RoutingMot;
101
- set mot(newValue: RoutingMot);
75
+ map?: Map;
76
+ modifyInteraction?: Modify;
77
+ onMapClickKey?: EventsKey;
78
+ onRouteError: (error?: Error, control?: RoutingControl) => void;
79
+ routingApiParams?: RoutingParameters;
80
+ routingLayer?: VectorLayer<Feature>;
81
+ segments: Feature<LineString>[];
82
+ snapToClosestStation: boolean;
83
+ stopsApiKey?: string;
84
+ stopsApiUrl?: string;
85
+ useRawViaPoints: boolean;
86
+ viaPoints: RoutingViaPoint[];
102
87
  constructor(options?: RoutingControlOptions);
103
88
  /**
104
89
  * Calculate at which resolutions corresponds each generalizations.
@@ -107,10 +92,16 @@ declare class RoutingControl extends Control {
107
92
  */
108
93
  static getGraphsResolutions(graphs: RoutingGraph[], map: Map): [number, number][];
109
94
  /**
110
- * Activet7deactivate the control when activ eproperty changes
95
+ * Aborts viapoint and route requests
111
96
  * @private
112
97
  */
113
- onActiveChange(): void;
98
+ abortRequests(): void;
99
+ activate(): void;
100
+ /**
101
+ * Add click listener to map.
102
+ * @private
103
+ */
104
+ addListeners(): void;
114
105
  /**
115
106
  * Adds/Replaces a viaPoint to the viaPoints array and redraws route:
116
107
  * Adds a viaPoint at end of array by default.
@@ -124,28 +115,17 @@ declare class RoutingControl extends Control {
124
115
  */
125
116
  addViaPoint(coordinatesOrString: RoutingViaPoint, index?: number, overwrite?: number): void;
126
117
  /**
127
- * Removes a viaPoint at the passed array index and redraws route
128
- * By default the last viaPoint is removed.
129
- * @param {number} index Integer representing the index of the viaPoint to delete.
130
- * @public
131
- */
132
- removeViaPoint(index?: number): void;
133
- /**
134
- * Replaces the current viaPoints with a new coordinate array.
135
- * @param {Array<Array<number>>} coordinateArray Array of nested coordinates
136
- * @public
137
- */
138
- setViaPoints(coordinateArray: Coordinate[]): void;
139
- /**
140
- * Removes all viaPoints, clears the source and triggers a change event
141
- * @public
118
+ * Define a default element.
119
+ *
120
+ * @private
142
121
  */
143
- reset(): void;
122
+ createDefaultElement(): void;
144
123
  /**
145
- * Aborts viapoint and route requests
124
+ * Create the interaction used to modify vertexes of features.
146
125
  * @private
147
126
  */
148
- abortRequests(): void;
127
+ createModifyInteraction(): void;
128
+ deactivate(): void;
149
129
  /**
150
130
  * Draws route on map using an array of coordinates:
151
131
  * If a single coordinate is passed a single point feature is added to map.
@@ -160,6 +140,11 @@ declare class RoutingControl extends Control {
160
140
  * @private
161
141
  */
162
142
  drawViaPoint(viaPoint: RoutingViaPoint, idx: number, abortController: AbortController): Promise<void | Feature<Geometry>> | Promise<Feature<Geometry> | null>;
143
+ /**
144
+ * Activet7deactivate the control when activ eproperty changes
145
+ * @private
146
+ */
147
+ onActiveChange(): void;
163
148
  /**
164
149
  * Used on click on map while control is active:
165
150
  * By default adds a viaPoint to the end of array.
@@ -167,12 +152,6 @@ declare class RoutingControl extends Control {
167
152
  * @private
168
153
  */
169
154
  onMapClick(evt: MapBrowserEvent<MouseEvent>): void;
170
- /**
171
- * Used on start of the modify interaction. Stores relevant data
172
- * in this.initialRouteDrag object
173
- * @private
174
- */
175
- onModifyStart(evt: ModifyEvent): void;
176
155
  /**
177
156
  * Used on end of the modify interaction. Resolves feature modification:
178
157
  * Line drag creates new viaPoint at the final coordinate of drag.
@@ -181,29 +160,43 @@ declare class RoutingControl extends Control {
181
160
  */
182
161
  onModifyEnd(evt: ModifyEvent): void | Promise<never>;
183
162
  /**
184
- * Define a default element.
185
- *
163
+ * Used on start of the modify interaction. Stores relevant data
164
+ * in this.initialRouteDrag object
186
165
  * @private
187
166
  */
188
- createDefaultElement(): void;
167
+ onModifyStart(evt: ModifyEvent): void;
189
168
  /**
190
- * Create the interaction used to modify vertexes of features.
169
+ * Remove click listener from map.
191
170
  * @private
192
171
  */
193
- createModifyInteraction(): void;
172
+ removeListeners(): void;
194
173
  /**
195
- * Add click listener to map.
196
- * @private
174
+ * Removes a viaPoint at the passed array index and redraws route
175
+ * By default the last viaPoint is removed.
176
+ * @param {number} index Integer representing the index of the viaPoint to delete.
177
+ * @public
197
178
  */
198
- addListeners(): void;
179
+ removeViaPoint(index?: number): void;
180
+ render(): void;
199
181
  /**
200
- * Remove click listener from map.
201
- * @private
182
+ * Removes all viaPoints, clears the source and triggers a change event
183
+ * @public
202
184
  */
203
- removeListeners(): void;
185
+ reset(): void;
204
186
  setMap(map: Map): void;
205
- activate(): void;
206
- deactivate(): void;
207
- render(): void;
187
+ /**
188
+ * Replaces the current viaPoints with a new coordinate array.
189
+ * @param {Array<Array<number>>} coordinateArray Array of nested coordinates
190
+ * @public
191
+ */
192
+ setViaPoints(coordinateArray: Coordinate[]): void;
193
+ get active(): boolean;
194
+ set active(newValue: boolean);
195
+ get loading(): boolean;
196
+ set loading(newValue: boolean);
197
+ get modify(): any;
198
+ set modify(newValue: any);
199
+ get mot(): RoutingMot;
200
+ set mot(newValue: RoutingMot);
208
201
  }
209
202
  export default RoutingControl;