mobility-toolbox-js 3.0.0-beta.36 → 3.0.0-beta.38

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/README.md CHANGED
@@ -10,7 +10,7 @@ The tools in this library have been inspired by many projects realized for publi
10
10
 
11
11
  ## Documentation and examples
12
12
 
13
- Visit https://mobility-toolbox-js.vercel.app/
13
+ Visit https://mobility-toolbox-js.geops.io/
14
14
 
15
15
  ## Demos
16
16
 
@@ -24,7 +24,7 @@ Visit https://mobility-toolbox-js.vercel.app/
24
24
  Install the library and the peer dependencies:
25
25
 
26
26
  ```bash
27
- yarn add mobility-toolbox-js ol maplibre-gl
27
+ yarn add ol maplibre-gl mobility-toolbox-js
28
28
  ```
29
29
 
30
30
  ## Development
@@ -34,9 +34,17 @@ yarn install
34
34
  yarn dev
35
35
  ```
36
36
 
37
+ `yarn dev` starts a vite server using the `index.html` file at the root of the project.
38
+ This html file loads the `dev.js` file. Use this file to develop the library.
39
+ Each time you modifiy the library code you have to run `yarn build:tsc` to see the changes.
40
+
41
+ ## Development documentation
42
+
43
+ The documentations website is located in the `doc/` folder.
44
+ It's a nextJS website that use the mobility-toolbox-js library built from the `build/` folder.
45
+
37
46
  ## Deploy
38
47
 
39
48
  This library website is deployed automatically using [Vercel](https://vercel.com/geops).
40
49
  For Vercel we have to add the nextjs and raw-loader modules in the dev dependencies of the main package.json.
41
50
  But those 2 librairies are not needed to build the library.
42
-
@@ -50,88 +50,6 @@ export type FeatureInfo = {
50
50
  */
51
51
  coordinate: number[2];
52
52
  };
53
- export type MaplibreLayerOptions = {
54
- /**
55
- * Access key for [geOps apis](https://developer.geops.io/).
56
- */
57
- apiKey: string;
58
- /**
59
- * geOps Maps api key name.
60
- */
61
- apiKeyName: string;
62
- /**
63
- * Maplibre map options.
64
- */
65
- mapLibreOptions: maplibregl.MapOptions;
66
- /**
67
- * geOps Maps api style.
68
- */
69
- style: string;
70
- /**
71
- * geOps Maps api url.
72
- */
73
- url: string;
74
- };
75
- export type ControlCommonOptions = {
76
- /**
77
- * Whether the control is active or not.
78
- */
79
- active?: boolean | undefined;
80
- /**
81
- * The HTML element used to render the control.
82
- */
83
- element: HTMLElement;
84
- /**
85
- * The HTML element where to render the element property. Default is the map's element.
86
- */
87
- target: HTMLElement;
88
- /**
89
- * Render function called whenever the control needs to be rerendered.
90
- */
91
- render: Function;
92
- };
93
- export type LayerCommonOptions = {
94
- /**
95
- * Identifier of the layer. Must be unique.
96
- */
97
- key: string;
98
- /**
99
- * Name of the layer.
100
- */
101
- name: string;
102
- /**
103
- * Group of the layer.
104
- */
105
- group: string;
106
- /**
107
- * List of copyrights.
108
- */
109
- copyrights: string[];
110
- /**
111
- * List of children layers.
112
- */
113
- children: Layer[];
114
- /**
115
- * Define if the layer is currently display on the map.
116
- */
117
- visible: boolean;
118
- /**
119
- * Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
120
- */
121
- disabled: boolean;
122
- /**
123
- * Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
124
- */
125
- hittolerance: number;
126
- /**
127
- * - Custom properties.
128
- */
129
- properties: Object;
130
- /**
131
- * - The map used to display the layer.
132
- */
133
- map: AnyMap;
134
- };
135
53
  export type VehiclePosition = {
136
54
  /**
137
55
  * Coordinate of the vehicle position in Mercator .
@@ -142,10 +60,6 @@ export type VehiclePosition = {
142
60
  */
143
61
  rotation: number;
144
62
  };
145
- /**
146
- * /Map~Map|maplibregl.Map} AnyMap
147
- */
148
- type dummy = ol;
149
63
  /**
150
64
  * @typedef {function} FilterFunction
151
65
  * @param {Vehicle} vehicle Vehicle to filter.
@@ -180,37 +94,6 @@ type dummy = ol;
180
94
  * @property {Feature[]} features An array of features.
181
95
  * @property {number[2]} coordinate The coordinate where to find the featue.
182
96
  */
183
- /**
184
- * @typedef {ol/Map~Map|maplibregl.Map} AnyMap
185
- */
186
- /**
187
- * @typedef {Object} MaplibreLayerOptions
188
- * @property {string} apiKey Access key for [geOps apis](https://developer.geops.io/).
189
- * @property {string} apiKeyName geOps Maps api key name.
190
- * @property {maplibregl.MapOptions} options.mapLibreOptions Maplibre map options.
191
- * @property {string} style geOps Maps api style.
192
- * @property {string} url geOps Maps api url.
193
- */
194
- /**
195
- * @typedef {Object} ControlCommonOptions
196
- * @property {boolean} [active = true] Whether the control is active or not.
197
- * @property {HTMLElement} element The HTML element used to render the control.
198
- * @property {HTMLElement} target The HTML element where to render the element property. Default is the map's element.
199
- * @property {function} render Render function called whenever the control needs to be rerendered.
200
- */
201
- /**
202
- * @typedef {Object} LayerCommonOptions
203
- * @property {string!} key Identifier of the layer. Must be unique.
204
- * @property {string!} name Name of the layer.
205
- * @property {string!} group Group of the layer.
206
- * @property {string[]!} copyrights List of copyrights.
207
- * @property {Layer[]!} children List of children layers.
208
- * @property {boolean!} visible Define if the layer is currently display on the map.
209
- * @property {boolean!} disabled Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
210
- * @property {number!} hittolerance Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
211
- * @property {Object!} properties - Custom properties.
212
- * @property {AnyMap!} map - The map used to display the layer.
213
- */
214
97
  /**
215
98
  * @typedef {Object} VehiclePosition
216
99
  * @property {number[2]} coord Coordinate of the vehicle position in Mercator .
@@ -32,37 +32,6 @@
32
32
  * @property {Feature[]} features An array of features.
33
33
  * @property {number[2]} coordinate The coordinate where to find the featue.
34
34
  */
35
- /**
36
- * @typedef {ol/Map~Map|maplibregl.Map} AnyMap
37
- */
38
- /**
39
- * @typedef {Object} MaplibreLayerOptions
40
- * @property {string} apiKey Access key for [geOps apis](https://developer.geops.io/).
41
- * @property {string} apiKeyName geOps Maps api key name.
42
- * @property {maplibregl.MapOptions} options.mapLibreOptions Maplibre map options.
43
- * @property {string} style geOps Maps api style.
44
- * @property {string} url geOps Maps api url.
45
- */
46
- /**
47
- * @typedef {Object} ControlCommonOptions
48
- * @property {boolean} [active = true] Whether the control is active or not.
49
- * @property {HTMLElement} element The HTML element used to render the control.
50
- * @property {HTMLElement} target The HTML element where to render the element property. Default is the map's element.
51
- * @property {function} render Render function called whenever the control needs to be rerendered.
52
- */
53
- /**
54
- * @typedef {Object} LayerCommonOptions
55
- * @property {string!} key Identifier of the layer. Must be unique.
56
- * @property {string!} name Name of the layer.
57
- * @property {string!} group Group of the layer.
58
- * @property {string[]!} copyrights List of copyrights.
59
- * @property {Layer[]!} children List of children layers.
60
- * @property {boolean!} visible Define if the layer is currently display on the map.
61
- * @property {boolean!} disabled Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
62
- * @property {number!} hittolerance Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
63
- * @property {Object!} properties - Custom properties.
64
- * @property {AnyMap!} map - The map used to display the layer.
65
- */
66
35
  /**
67
36
  * @typedef {Object} VehiclePosition
68
37
  * @property {number[2]} coord Coordinate of the vehicle position in Mercator .
@@ -2,7 +2,7 @@ import { FeatureCollection } from 'geojson';
2
2
  import GeoJSON from 'ol/format/GeoJSON';
3
3
  import { RealtimeAPI } from '../../api';
4
4
  import { WebSocketAPIMessageEventData } from '../../api/WebSocketAPI';
5
- import { AnyCanvas, AnyLayer, AnyRealtimeLayer, LayerGetFeatureInfoOptions, RealtimeGeneralizationLevel, RealtimeMode, RealtimeMot, RealtimeRenderState, RealtimeStyleFunction, RealtimeStyleOptions, RealtimeTenant, RealtimeTrainId, RealtimeTrajectory, ViewState } from '../../types';
5
+ import { AnyCanvas, LayerGetFeatureInfoOptions, RealtimeGeneralizationLevel, RealtimeMode, RealtimeMot, RealtimeRenderState, RealtimeStyleFunction, RealtimeStyleOptions, RealtimeTenant, RealtimeTrainId, RealtimeTrajectory, ViewState } from '../../types';
6
6
  import { FilterFunction, SortFunction } from '../typedefs';
7
7
  import type { Coordinate } from 'ol/coordinate';
8
8
  export interface RealtimeEngineOptions {
@@ -26,8 +26,8 @@ export interface RealtimeEngineOptions {
26
26
  mode?: RealtimeMode;
27
27
  motsByZoom?: RealtimeMot[][];
28
28
  onRender?: (renderState: RealtimeRenderState, viewState: ViewState) => void;
29
- onStart?: (realtimeLayer: AnyRealtimeLayer) => void;
30
- onStop?: (realtimeLayer: AnyRealtimeLayer) => void;
29
+ onStart?: (realtimeEngine: RealtimeEngine) => void;
30
+ onStop?: (realtimeEngine: RealtimeEngine) => void;
31
31
  pingIntervalMs?: number;
32
32
  pixelRatio?: number;
33
33
  prefix?: string;
@@ -76,8 +76,8 @@ declare class RealtimeEngine {
76
76
  mots?: RealtimeMot[];
77
77
  motsByZoom: RealtimeMot[][];
78
78
  onRender?: (renderState: RealtimeRenderState, viewState: ViewState) => void;
79
- onStart?: (realtimeLayer: AnyLayer) => void;
80
- onStop?: (realtimeLayer: AnyLayer) => void;
79
+ onStart?: (realtimeLayer: RealtimeEngine) => void;
80
+ onStop?: (realtimeLayer: RealtimeEngine) => void;
81
81
  pixelRatio?: number;
82
82
  renderState?: RealtimeRenderState;
83
83
  renderTimeIntervalByZoom: number[];
@@ -196,7 +196,6 @@ class RealtimeEngine {
196
196
  }
197
197
  const vehicles = [];
198
198
  for (let i = 0; i < trajectories.length; i += 1) {
199
- // @ts-expect-error coordinate is added by the RealtimeLayer
200
199
  const { coordinate: trajcoord } = trajectories[i].properties;
201
200
  if (trajcoord && containsCoordinate(ext, trajcoord)) {
202
201
  vehicles.push(trajectories[i]);
@@ -9,12 +9,9 @@ import { LineString } from 'ol/geom';
9
9
  * @private
10
10
  */
11
11
  const getVehiclePosition = (now, trajectory, noInterpolate) => {
12
- const {
13
- // @ts-expect-error coordinate is added by the RealtimeLayer
14
- coordinate,
12
+ const { coordinate,
15
13
  // @ts-expect-error olGeometry is added by the RealtimeLayer
16
14
  olGeometry, time_intervals: timeIntervals, } = trajectory.properties;
17
- // @ts-expect-error
18
15
  let { coordinates, type } = trajectory.geometry;
19
16
  let geometry = olGeometry;
20
17
  let coord;