mobility-toolbox-js 3.0.0-beta.8 → 3.0.0-beta.9
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.
- package/api/HttpAPI.d.ts +31 -0
- package/api/RealtimeAPI.d.ts +359 -0
- package/api/RoutingAPI.d.ts +37 -0
- package/api/StopsAPI.d.ts +38 -0
- package/api/WebSocketAPI.d.ts +153 -0
- package/api/index.d.ts +3 -0
- package/api/typedefs.d.ts +178 -0
- package/common/controls/StopFinderControlCommon.d.ts +53 -0
- package/common/index.d.ts +2 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +273 -0
- package/common/styles/index.d.ts +4 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/typedefs.d.ts +212 -0
- package/common/utils/compareDepartures.d.ts +10 -0
- package/common/utils/constants.d.ts +5 -0
- package/common/utils/createCanvas.d.ts +10 -0
- package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
- package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
- package/common/utils/createRealtimeFilters.d.ts +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts +12 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getMapGlCopyrights.d.ts +17 -0
- package/common/utils/getRealtimeModeSuffix.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts +8 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- package/common/utils/index.d.ts +16 -0
- package/common/utils/realtimeConfig.d.ts +64 -0
- package/common/utils/removeDuplicate.d.ts +9 -0
- package/common/utils/renderTrajectories.d.ts +16 -0
- package/common/utils/sortAndFilterDepartures.d.ts +15 -0
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/timeUtils.d.ts +23 -0
- package/common/utils/toMercatorExtent.d.ts +5 -0
- package/iife.d.ts +2 -0
- package/index.d.ts +9 -0
- package/maplibre/controls/CopyrightControl.d.ts +35 -0
- package/maplibre/controls/index.d.ts +1 -0
- package/maplibre/index.d.ts +5 -0
- package/maplibre/layers/Layer.d.ts +28 -0
- package/maplibre/layers/RealtimeLayer.d.ts +160 -0
- package/maplibre/layers/index.d.ts +2 -0
- package/maplibre/utils/getMercatorResolution.d.ts +7 -0
- package/maplibre/utils/getSourceCoordinates.d.ts +7 -0
- package/maplibre/utils/index.d.ts +2 -0
- package/mbt.js +32 -24
- package/mbt.js.map +2 -2
- package/mbt.min.js +1 -1
- package/mbt.min.js.map +3 -3
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/RoutingControl.d.ts +209 -0
- package/ol/controls/StopFinderControl.d.ts +37 -0
- package/ol/controls/index.d.ts +3 -0
- package/ol/index.d.ts +6 -0
- package/ol/layers/MapGlLayer.d.ts +144 -0
- package/ol/layers/MapGlLayer.js +3 -1
- package/ol/layers/MaplibreLayer.d.ts +63 -0
- package/ol/layers/MaplibreStyleLayer.d.ts +235 -0
- package/ol/layers/MaplibreStyleLayer.js +1 -1
- package/ol/layers/RealtimeLayer.d.ts +285 -0
- package/ol/layers/RealtimeLayer.js +11 -5
- package/ol/layers/index.d.ts +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +98 -0
- package/ol/mixins/MobilityLayerMixin.js +1 -4
- package/ol/mixins/PropertiesLayerMixin.d.ts +127 -0
- package/ol/mixins/PropertiesLayerMixin.js +5 -4
- package/ol/renderers/MaplibreLayerRenderer.d.ts +20 -0
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
- package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
- package/ol/renderers/RealtimeLayerRenderer.js +9 -9
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/routingStyle.d.ts +4 -0
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
- package/ol/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/setupTests.d.ts +1 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
export default dummy;
|
|
2
|
+
export type FilterFunction = Function;
|
|
3
|
+
export type SortFunction = Function;
|
|
4
|
+
export type ViewState = {
|
|
5
|
+
/**
|
|
6
|
+
* A time in ms.
|
|
7
|
+
*/
|
|
8
|
+
time: number | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* A center in mercator coordinate.
|
|
11
|
+
*/
|
|
12
|
+
center: number[2] | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* An Extent in mercator coordinates.
|
|
15
|
+
*/
|
|
16
|
+
extent: any;
|
|
17
|
+
/**
|
|
18
|
+
* A size ([width, height]).
|
|
19
|
+
*/
|
|
20
|
+
size: any;
|
|
21
|
+
/**
|
|
22
|
+
* A rotation in radians.
|
|
23
|
+
*/
|
|
24
|
+
rotation: number;
|
|
25
|
+
/**
|
|
26
|
+
* A resolution.
|
|
27
|
+
*/
|
|
28
|
+
resolution: number;
|
|
29
|
+
/**
|
|
30
|
+
* A zoom level.
|
|
31
|
+
*/
|
|
32
|
+
zoom: number;
|
|
33
|
+
/**
|
|
34
|
+
* A pixel ratio.
|
|
35
|
+
*/
|
|
36
|
+
pixelRatio: number | undefined;
|
|
37
|
+
};
|
|
38
|
+
export type FeatureInfo = {
|
|
39
|
+
/**
|
|
40
|
+
* A layer.
|
|
41
|
+
*/
|
|
42
|
+
layer: Layer;
|
|
43
|
+
/**
|
|
44
|
+
* An array of features.
|
|
45
|
+
*/
|
|
46
|
+
features: Feature[];
|
|
47
|
+
/**
|
|
48
|
+
* The coordinate where to find the featue.
|
|
49
|
+
*/
|
|
50
|
+
coordinate: any;
|
|
51
|
+
};
|
|
52
|
+
export type MaplibreLayerOptions = {
|
|
53
|
+
/**
|
|
54
|
+
* Access key for [geOps apis](https://developer.geops.io/).
|
|
55
|
+
*/
|
|
56
|
+
apiKey: string;
|
|
57
|
+
/**
|
|
58
|
+
* geOps Maps api key name.
|
|
59
|
+
*/
|
|
60
|
+
apiKeyName: string;
|
|
61
|
+
/**
|
|
62
|
+
* Maplibre map options.
|
|
63
|
+
*/
|
|
64
|
+
mapOptions: maplibregl.MapOptions;
|
|
65
|
+
/**
|
|
66
|
+
* geOps Maps api style.
|
|
67
|
+
*/
|
|
68
|
+
style: string;
|
|
69
|
+
/**
|
|
70
|
+
* geOps Maps api url.
|
|
71
|
+
*/
|
|
72
|
+
url: string;
|
|
73
|
+
};
|
|
74
|
+
export type ControlCommonOptions = {
|
|
75
|
+
/**
|
|
76
|
+
* Whether the control is active or not.
|
|
77
|
+
*/
|
|
78
|
+
active?: boolean | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* The HTML element used to render the control.
|
|
81
|
+
*/
|
|
82
|
+
element: HTMLElement;
|
|
83
|
+
/**
|
|
84
|
+
* The HTML element where to render the element property. Default is the map's element.
|
|
85
|
+
*/
|
|
86
|
+
target: HTMLElement;
|
|
87
|
+
/**
|
|
88
|
+
* Render function called whenever the control needs to be rerendered.
|
|
89
|
+
*/
|
|
90
|
+
render: Function;
|
|
91
|
+
};
|
|
92
|
+
export type LayerCommonOptions = {
|
|
93
|
+
/**
|
|
94
|
+
* Identifier of the layer. Must be unique.
|
|
95
|
+
*/
|
|
96
|
+
key: string;
|
|
97
|
+
/**
|
|
98
|
+
* Name of the layer.
|
|
99
|
+
*/
|
|
100
|
+
name: string;
|
|
101
|
+
/**
|
|
102
|
+
* Group of the layer.
|
|
103
|
+
*/
|
|
104
|
+
group: string;
|
|
105
|
+
/**
|
|
106
|
+
* List of copyrights.
|
|
107
|
+
*/
|
|
108
|
+
copyrights: string[];
|
|
109
|
+
/**
|
|
110
|
+
* List of children layers.
|
|
111
|
+
*/
|
|
112
|
+
children: Layer[];
|
|
113
|
+
/**
|
|
114
|
+
* Define if the layer is currently display on the map.
|
|
115
|
+
*/
|
|
116
|
+
visible: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
|
|
119
|
+
*/
|
|
120
|
+
disabled: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
|
|
123
|
+
*/
|
|
124
|
+
hittolerance: number;
|
|
125
|
+
/**
|
|
126
|
+
* - Custom properties.
|
|
127
|
+
*/
|
|
128
|
+
properties: Object;
|
|
129
|
+
/**
|
|
130
|
+
* - The map used to display the layer.
|
|
131
|
+
*/
|
|
132
|
+
map: AnyMap;
|
|
133
|
+
};
|
|
134
|
+
export type VehiclePosition = {
|
|
135
|
+
/**
|
|
136
|
+
* Coordinate of the vehicle position in Mercator .
|
|
137
|
+
*/
|
|
138
|
+
coord: any;
|
|
139
|
+
/**
|
|
140
|
+
* An angle in radians representing the direction (from the true north) towards which the vehicle is facing.
|
|
141
|
+
*/
|
|
142
|
+
rotation: number;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* /Map~Map|maplibregl.Map} AnyMap
|
|
146
|
+
*/
|
|
147
|
+
type dummy = ol;
|
|
148
|
+
/**
|
|
149
|
+
* @typedef {function} FilterFunction
|
|
150
|
+
* @param {Vehicle} vehicle Vehicle to filter.
|
|
151
|
+
* @returns boolean
|
|
152
|
+
*/
|
|
153
|
+
/**
|
|
154
|
+
* @typedef {function} SortFunction
|
|
155
|
+
* @param {any} a Object a to compare.
|
|
156
|
+
* @param {any} b Object b to compare.
|
|
157
|
+
* @returns number
|
|
158
|
+
*/
|
|
159
|
+
/**
|
|
160
|
+
* @typedef {Object} ViewState
|
|
161
|
+
* @property {number|undefined} time A time in ms.
|
|
162
|
+
* @property {number[2]|undefined} center A center in mercator coordinate.
|
|
163
|
+
* @property {number[4]} extent An Extent in mercator coordinates.
|
|
164
|
+
* @property {number[2]} size A size ([width, height]).
|
|
165
|
+
* @property {number} rotation A rotation in radians.
|
|
166
|
+
* @property {number} resolution A resolution.
|
|
167
|
+
* @property {number} zoom A zoom level.
|
|
168
|
+
* @property {number|undefined} pixelRatio A pixel ratio.
|
|
169
|
+
*/
|
|
170
|
+
/**
|
|
171
|
+
* @typedef {Object} FeatureInfo
|
|
172
|
+
* @property {Layer} layer A layer.
|
|
173
|
+
* @property {Feature[]} features An array of features.
|
|
174
|
+
* @property {number[2]} coordinate The coordinate where to find the featue.
|
|
175
|
+
*/
|
|
176
|
+
/**
|
|
177
|
+
* @typedef {ol/Map~Map|maplibregl.Map} AnyMap
|
|
178
|
+
*/
|
|
179
|
+
/**
|
|
180
|
+
* @typedef {Object} MaplibreLayerOptions
|
|
181
|
+
* @property {string} apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
182
|
+
* @property {string} apiKeyName geOps Maps api key name.
|
|
183
|
+
* @property {maplibregl.MapOptions} options.mapOptions Maplibre map options.
|
|
184
|
+
* @property {string} style geOps Maps api style.
|
|
185
|
+
* @property {string} url geOps Maps api url.
|
|
186
|
+
*/
|
|
187
|
+
/**
|
|
188
|
+
* @typedef {Object} ControlCommonOptions
|
|
189
|
+
* @property {boolean} [active = true] Whether the control is active or not.
|
|
190
|
+
* @property {HTMLElement} element The HTML element used to render the control.
|
|
191
|
+
* @property {HTMLElement} target The HTML element where to render the element property. Default is the map's element.
|
|
192
|
+
* @property {function} render Render function called whenever the control needs to be rerendered.
|
|
193
|
+
*/
|
|
194
|
+
/**
|
|
195
|
+
* @typedef {Object} LayerCommonOptions
|
|
196
|
+
* @property {string!} key Identifier of the layer. Must be unique.
|
|
197
|
+
* @property {string!} name Name of the layer.
|
|
198
|
+
* @property {string!} group Group of the layer.
|
|
199
|
+
* @property {string[]!} copyrights List of copyrights.
|
|
200
|
+
* @property {Layer[]!} children List of children layers.
|
|
201
|
+
* @property {boolean!} visible Define if the layer is currently display on the map.
|
|
202
|
+
* @property {boolean!} disabled Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
|
|
203
|
+
* @property {number!} hittolerance Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
|
|
204
|
+
* @property {Object!} properties - Custom properties.
|
|
205
|
+
* @property {AnyMap!} map - The map used to display the layer.
|
|
206
|
+
*/
|
|
207
|
+
/**
|
|
208
|
+
* @typedef {Object} VehiclePosition
|
|
209
|
+
* @property {number[2]} coord Coordinate of the vehicle position in Mercator .
|
|
210
|
+
* @property {number!} rotation An angle in radians representing the direction (from the true north) towards which the vehicle is facing.
|
|
211
|
+
*/
|
|
212
|
+
declare function dummy(): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RealtimeDeparture } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Compare two given departures for sort alogithm,
|
|
4
|
+
* @param {Departure} a First departure.
|
|
5
|
+
* @param {Departure} b Second departure.
|
|
6
|
+
* @param {boolean} [sortByMinArrivalTime=false] Sort departures by arrival time.
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
declare const compareDepartures: (a: RealtimeDeparture, b: RealtimeDeparture, sortByMinArrivalTime?: boolean) => number;
|
|
10
|
+
export default compareDepartures;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AnyCanvas } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* This function try to create a canvas element and return it.
|
|
4
|
+
* it uses document.createElement('canvas') if document is available
|
|
5
|
+
* or new OffscreenCanvas(width, height) if OffscreenCanvas is avalaible (for web worker)
|
|
6
|
+
* or it returns null if neither is available.
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
declare const createCanvas: (width: number, height: number) => AnyCanvas | null;
|
|
10
|
+
export default createCanvas;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RealtimeTrajectory } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Return a filter functions based on some parameters of a vehicle.
|
|
4
|
+
*
|
|
5
|
+
* @param {string|Array<string>} line - A list of vehicle's name to filter. Names can be separated by a comma. Ex: 'S1,S2,S3'
|
|
6
|
+
* @param {string|Array<string} route - A list of vehicle's route (contained in route_identifier property) to filter. Indentifiers can be separated by a comma. Ex: 'id1,id2,id3'
|
|
7
|
+
* @param {string|Array<string} operator A list of vehicle's operator to filter. Operators can be separated by a comma. Ex: 'SBB,DB'
|
|
8
|
+
* @param {Regexp} regexLine - A regex aplly of vehcile's name.
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
declare const createRealtimeFilters: (line: string | string[], route: string | string[], operator: string | string[], regexLine: string | string[]) => ((trajectory: RealtimeTrajectory) => boolean) | null;
|
|
12
|
+
export default createRealtimeFilters;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RealtimeDeparture, RealtimeDepartureExtended } from '../../types';
|
|
2
|
+
import type { WebSocketAPIMessageCallback } from '../../api/WebSocketAPI';
|
|
3
|
+
/**
|
|
4
|
+
* This function returns a WebSocket api callback, and call the onDeparturesUpdate function with the list of current departures to display.
|
|
5
|
+
* @param {function(departures: RealtimeDeparture[])} onDeparturesUpdate callback when list of departures changes, called after 100 ms
|
|
6
|
+
* @param {boolean} [sortByMinArrivalTime = true] Sort departures by arrival time
|
|
7
|
+
* @param {number} [maxDepartureAge = 30] max departure age of departures in minutes
|
|
8
|
+
* @param {number} [timeout = 100] debounce timeout in ms
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
declare const debounceDeparturesMessages: (onDeparturesUpdate: (departures: RealtimeDepartureExtended[]) => {}, sortByMinArrivalTime?: boolean, maxDepartureAge?: number, timeout?: number) => WebSocketAPIMessageCallback<RealtimeDeparture>;
|
|
12
|
+
export default debounceDeparturesMessages;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WebSocketAPIMessageCallback } from '../../api/WebSocketAPI';
|
|
2
|
+
/**
|
|
3
|
+
* This function returns a WebSocket api callback, and call the onUpdate function with the list of of subscribed objects changes.
|
|
4
|
+
*
|
|
5
|
+
* @param {function(objects: any[])} onUpdate callback when list of subscribed objects changes, called after 100 ms
|
|
6
|
+
* @param {function(object: any)} [getObjectId = true] function returning the id of an object
|
|
7
|
+
* @param {number} [timeout = 100] debounce timeout in ms
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
declare const debounceWebsocketMessages: (onUpdate: (objects: any[]) => void, getObjectId?: ((object: any) => string) | undefined, timeout?: number) => WebSocketAPIMessageCallback<any>;
|
|
11
|
+
export default debounceWebsocketMessages;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Source {
|
|
2
|
+
attribution: string;
|
|
3
|
+
options: {
|
|
4
|
+
attribution: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export interface SourceCache {
|
|
8
|
+
used: boolean;
|
|
9
|
+
getSource: () => Source;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Return the copyright a Maplibre map.
|
|
13
|
+
* @param {maplibregl.Map} map A Maplibre map
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
declare const getMapGlCopyrights: (map: maplibregl.Map) => any[];
|
|
17
|
+
export default getMapGlCopyrights;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RealtimeMode } from '../../types';
|
|
2
|
+
import type { RealtimeModesType } from '../../api/RealtimeAPI';
|
|
3
|
+
/**
|
|
4
|
+
* Get the websocket channel suffix, depending on the current mode.
|
|
5
|
+
* @param {String} mode Mode 'topographic' ou 'schematic'.
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
declare const getModeSuffix: (mode: RealtimeMode, modes: RealtimeModesType) => string;
|
|
9
|
+
export default getModeSuffix;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the styleUrl with apiKey parameters set.
|
|
3
|
+
* @param {string} url a url.
|
|
4
|
+
* @param {Object<String,String>} params a list of key/value pair to add to the url.
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
declare const getUrlWithParams: (url: string, params: Object) => URL;
|
|
8
|
+
export default getUrlWithParams;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Coordinate } from 'ol/coordinate';
|
|
2
|
+
export type VehiclePosition = {
|
|
3
|
+
coord: Coordinate;
|
|
4
|
+
rotation: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Interpolate or not the vehicle position from a trajectory at a specific date.
|
|
8
|
+
*
|
|
9
|
+
* @param {number} now Current date to interpolate a position with. In ms.
|
|
10
|
+
* @param {RealtimeTrajectory} trajectory The trajectory to interpolate.
|
|
11
|
+
* @param {boolean} noInterpolate If true, the vehicle position is not interpolated on each render but only once.
|
|
12
|
+
* @returns {VehiclePosition}
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
declare const getVehiclePosition: (now: number, trajectory: GeoJSONFeature, noInterpolate: boolean) => VehiclePosition;
|
|
16
|
+
export default getVehiclePosition;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { default as getUrlWithParams } from "./getUrlWithParams";
|
|
2
|
+
export { default as getMapGlCopyrights } from "./getMapGlCopyrights";
|
|
3
|
+
export { default as removeDuplicate } from "./removeDuplicate";
|
|
4
|
+
export { default as createRealtimeFilters } from "./createRealtimeFilters";
|
|
5
|
+
export { default as getLayersAsFlatArray } from "./getLayersAsFlatArray";
|
|
6
|
+
export * from "./timeUtils";
|
|
7
|
+
export * from "./constants";
|
|
8
|
+
export { default as sortByDelay } from "./sortByDelay";
|
|
9
|
+
export { default as renderTrajectories } from "./renderTrajectories";
|
|
10
|
+
export { default as debounceDeparturesMessages } from "./debounceDeparturesMessages";
|
|
11
|
+
export { default as debounceWebsocketMessages } from "./debounceWebsocketMessages";
|
|
12
|
+
export { default as sortAndFilterDepartures } from "./sortAndFilterDepartures";
|
|
13
|
+
export { default as compareDepartures } from "./compareDepartures";
|
|
14
|
+
export { default as createCanvas } from "./createCanvas";
|
|
15
|
+
export { default as getVehiclePosition } from "./getVehiclePosition";
|
|
16
|
+
export * as realtimeConfig from "./realtimeConfig";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AnyCanvasContext, RealtimeMot } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
*/
|
|
5
|
+
export declare const MOTS_ONLY_RAIL: RealtimeMot[];
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
export declare const MOTS_WITH_CABLE: RealtimeMot[];
|
|
10
|
+
/**
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
export declare const MOTS_WITHOUT_CABLE: RealtimeMot[];
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
export declare const MOTS_ALL: RealtimeMot[];
|
|
18
|
+
/**
|
|
19
|
+
* Trajserv value: 'Tram', 'Subway / Metro / S-Bahn', 'Train', 'Bus', 'Ferry', 'Cable Car', 'Gondola', 'Funicular', 'Long distance bus', 'Rail',
|
|
20
|
+
* New endpoint use Rail instead of Train.
|
|
21
|
+
* New tracker values: null, "tram", "subway", "rail", "bus", "ferry", "cablecar", "gondola", "funicular", "coach".
|
|
22
|
+
*
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
export declare const types: RegExp[];
|
|
26
|
+
/**
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
export declare const bgColors: string[];
|
|
30
|
+
/**
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
export declare const textColors: string[];
|
|
34
|
+
/**
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
export declare const getTypeIndex: (type: RealtimeMot) => number;
|
|
38
|
+
/**
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
export declare const getRadius: (type: RealtimeMot, zoom: number) => number;
|
|
42
|
+
/**
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
export declare const getBgColor: (type: RealtimeMot) => string;
|
|
46
|
+
/**
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
export declare const getTextColor: (type: RealtimeMot) => string;
|
|
50
|
+
/**
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
export declare const getTextSize: (ctx: AnyCanvasContext, markerSize: number, text: string, fontSize: number, getTextFont: (fontSize: number, text?: string) => string) => number;
|
|
54
|
+
/**
|
|
55
|
+
* @private
|
|
56
|
+
* @param {number} delayInMs Delay in milliseconds.
|
|
57
|
+
* @param {boolean} cancelled true if the journey is cancelled.
|
|
58
|
+
* @param {boolean} isDelayText true if the color is used for delay text of the symbol.
|
|
59
|
+
*/
|
|
60
|
+
export declare const getDelayColor: (delayInMs: number | null, cancelled?: boolean, isDelayText?: boolean) => string;
|
|
61
|
+
/**
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
export declare const getDelayText: (delayInMs: number, cancelled: boolean) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function remove duplicates lower case string value of an array.
|
|
3
|
+
* It removes also null, undefined or non string values.
|
|
4
|
+
*
|
|
5
|
+
* @param {array} array Array of values.
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
declare const removeDuplicate: (array: any[]) => any[];
|
|
9
|
+
export default removeDuplicate;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AnyCanvas, RealtimeRenderState, RealtimeStyleFunction, RealtimeStyleOptions, RealtimeTrajectories, ViewState } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Draw all the trajectories available in a canvas.
|
|
4
|
+
* @param {HTMLCanvas|HTMLOffscreenCanvas} The canvas where to draw the trajectories.
|
|
5
|
+
* @param {ViewState} trajectories An array of trajectories.
|
|
6
|
+
* @param {Function} style A function that returns a canvas representing a vehicle of a specific trajectory.
|
|
7
|
+
* @param {ViewState} viewState The view state of the map.
|
|
8
|
+
* @param {boolean} options.hoverVehicleId The id of the vehicle to highlight.
|
|
9
|
+
* @param {boolean} options.selectedVehicleId The id of the vehicle to select.
|
|
10
|
+
* @param {boolean} options.noInterpolate If true trajectories are not interpolated but
|
|
11
|
+
* drawn at the last known coordinate. Use this for performance optimization
|
|
12
|
+
* during map navigation.
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
declare const renderTrajectories: (canvas: AnyCanvas, trajectories: RealtimeTrajectories, style: RealtimeStyleFunction, viewState: ViewState, options: RealtimeStyleOptions) => RealtimeRenderState;
|
|
16
|
+
export default renderTrajectories;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RealtimeAPIDeparturesById } from '../../api/RealtimeAPI';
|
|
2
|
+
import type { RealtimeDepartureExtended } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* This function sort Departures by arrival time and filter out unwanted departures:
|
|
5
|
+
* - when dparture time is in the past
|
|
6
|
+
* - when departure are duplicated
|
|
7
|
+
* - when departure is not in the next 30 min
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} depObject The object containing departures by id.
|
|
10
|
+
* @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
|
|
11
|
+
* @return {Array<Departure>} Return departures array.
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
declare const sortAndfilterDepartures: (depObject: RealtimeAPIDeparturesById, sortByMinArrivalTime?: boolean, maxDepartureAge?: number) => RealtimeDepartureExtended[];
|
|
15
|
+
export default sortAndfilterDepartures;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a Date object as UTC date string .
|
|
3
|
+
* ex: 2019 09 01
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
export declare const getUTCDateString: (now?: Date) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Get the UTC time string of Date object.
|
|
9
|
+
* ex: 09:05:01.123
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export declare const getUTCTimeString: (date: Date) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a string representation of a number, with a zero if the number is lower than 10.
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
export declare const pad: (integer: number) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a 'hh:mm' string from a time in ms.
|
|
20
|
+
* @param {Number} timeInMs Time in milliseconds.
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
export declare const getHoursAndMinutes: (timeInMs: number) => string;
|
package/iife.d.ts
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ControlPosition, IControl } from 'maplibre-gl';
|
|
2
|
+
/**
|
|
3
|
+
* Display layer's copyrights.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { Map } from 'Maplibre-gl';
|
|
7
|
+
* import { CopyrightControl } from 'mobility-toolbox-js/Maplibre';
|
|
8
|
+
*
|
|
9
|
+
* const map = new Map({
|
|
10
|
+
* container: 'map',
|
|
11
|
+
* style: `https://maps.geops.io/styles/travic_v2/style.json?key=${window.apiKey}`,
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* const control = new CopyrightControl();
|
|
15
|
+
* map.addControl(control);
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* @see <a href="/example/mb-copyright">Maplibre copyright example</a>
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
declare class CopyrightControl implements IControl {
|
|
22
|
+
map?: maplibregl.Map;
|
|
23
|
+
container?: HTMLElement;
|
|
24
|
+
content?: string;
|
|
25
|
+
options?: {
|
|
26
|
+
customAttribution?: string | string[];
|
|
27
|
+
separator?: string;
|
|
28
|
+
};
|
|
29
|
+
constructor(options?: {});
|
|
30
|
+
onAdd(map: maplibregl.Map): HTMLElement;
|
|
31
|
+
onRemove(): HTMLElement | undefined;
|
|
32
|
+
getDefaultPosition(): ControlPosition;
|
|
33
|
+
render(): void;
|
|
34
|
+
}
|
|
35
|
+
export default CopyrightControl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CopyrightControl } from "./CopyrightControl";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CustomLayerInterface, Evented } from 'maplibre-gl';
|
|
2
|
+
import type { AnyMapGlMap } from '../../types';
|
|
3
|
+
export type LayerOptions = {
|
|
4
|
+
id?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* A class representing a layer to display on an Maplibre map.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import { Layer } from 'mobility-toolbox-js/Maplibre';
|
|
11
|
+
*
|
|
12
|
+
* const layer = new Layer({ id:'MyLayer' });
|
|
13
|
+
*
|
|
14
|
+
* @implements {maplibregl.CustomLayer}
|
|
15
|
+
* @extends {maplibregl.Evented}
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
declare class Layer extends Evented implements CustomLayerInterface {
|
|
19
|
+
id: string;
|
|
20
|
+
map: AnyMapGlMap | undefined;
|
|
21
|
+
options: LayerOptions;
|
|
22
|
+
type: 'custom';
|
|
23
|
+
constructor(options?: LayerOptions);
|
|
24
|
+
onAdd(map: AnyMapGlMap, gl: WebGLRenderingContext | WebGL2RenderingContext): void;
|
|
25
|
+
onRemove(map: AnyMapGlMap, gl: WebGLRenderingContext | WebGL2RenderingContext): void;
|
|
26
|
+
render(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
|
|
27
|
+
}
|
|
28
|
+
export default Layer;
|