@geops/rvf-mobility-web-component 0.1.75 → 0.1.76
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/CHANGELOG.md +7 -0
- package/index.js +82 -82
- package/package.json +2 -2
- package/src/LinesNetworkPlanLayerHighlight/LinesNetworkPlanLayerHighlight.tsx +10 -2
- package/src/NotificationsLayer/NotificationsLayer.tsx +1 -1
- package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +95 -84
- package/src/SingleClickListener/SingleClickListener.tsx +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@geops/rvf-mobility-web-component",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
4
|
"description": "Web components for rvf in the domains of mobility and logistics.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.76",
|
|
6
6
|
"homepage": "https://rvf-mobility-web-component-geops.vercel.app/",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"jspdf": "^3.0.3",
|
|
13
13
|
"lodash.debounce": "^4.0.8",
|
|
14
14
|
"maplibre-gl": "^5.9.0",
|
|
15
|
-
"mobility-toolbox-js": "3.4.
|
|
15
|
+
"mobility-toolbox-js": "3.4.6-beta.1",
|
|
16
16
|
"ol": "^10.6.1",
|
|
17
17
|
"preact": "^10.27.2",
|
|
18
18
|
"preact-custom-element": "^4.5.1",
|
|
@@ -15,7 +15,6 @@ function LinesNetworkPlanLayerHighlight(props: MaplibreStyleLayerOptions) {
|
|
|
15
15
|
const {
|
|
16
16
|
baseLayer,
|
|
17
17
|
featuresInfos,
|
|
18
|
-
lines,
|
|
19
18
|
linesIds,
|
|
20
19
|
linesNetworkPlanLayer,
|
|
21
20
|
map,
|
|
@@ -58,6 +57,11 @@ function LinesNetworkPlanLayerHighlight(props: MaplibreStyleLayerOptions) {
|
|
|
58
57
|
return featuresInfo.layer === linesNetworkPlanLayer;
|
|
59
58
|
})?.features || [];
|
|
60
59
|
|
|
60
|
+
if (!features.length) {
|
|
61
|
+
setLinesIds(null);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
61
65
|
const ids = [
|
|
62
66
|
...new Set(
|
|
63
67
|
(features || []).map((f) => {
|
|
@@ -65,6 +69,10 @@ function LinesNetworkPlanLayerHighlight(props: MaplibreStyleLayerOptions) {
|
|
|
65
69
|
}),
|
|
66
70
|
),
|
|
67
71
|
];
|
|
72
|
+
if (!ids.length) {
|
|
73
|
+
setLinesIds(null);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
68
76
|
setLinesIds(ids?.length ? ids : null);
|
|
69
77
|
}, [featuresInfos, layer, linesNetworkPlanLayer, setLinesIds]);
|
|
70
78
|
|
|
@@ -81,7 +89,7 @@ function LinesNetworkPlanLayerHighlight(props: MaplibreStyleLayerOptions) {
|
|
|
81
89
|
// Reset the filter
|
|
82
90
|
highlightLinesNetworkPlan(undefined, baseLayer);
|
|
83
91
|
};
|
|
84
|
-
}, [baseLayer, baseLayer?.loaded, layer,
|
|
92
|
+
}, [baseLayer, baseLayer?.loaded, layer, linesIds]);
|
|
85
93
|
|
|
86
94
|
return null;
|
|
87
95
|
}
|
|
@@ -28,9 +28,9 @@ function NotificationsLayer(props?: Partial<MocoLayerOptions>) {
|
|
|
28
28
|
apiParameters: {
|
|
29
29
|
contentMedium: true,
|
|
30
30
|
},
|
|
31
|
-
date: notificationat ? new Date(notificationat) : undefined,
|
|
32
31
|
maplibreLayer: baseLayer,
|
|
33
32
|
name: LAYER_NAME_NOTIFICATIONS,
|
|
33
|
+
publicAt: notificationat ? new Date(notificationat) : undefined,
|
|
34
34
|
situations: previewNotifications,
|
|
35
35
|
tenant: notificationtenant,
|
|
36
36
|
url: notificationurl,
|
|
@@ -95,90 +95,6 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
95
95
|
return baseLayer?.mapLibreMap;
|
|
96
96
|
}, [baseLayer?.mapLibreMap]);
|
|
97
97
|
|
|
98
|
-
const updateData = useCallback(() => {
|
|
99
|
-
const abortController = new AbortController();
|
|
100
|
-
const extent = transformExtent(
|
|
101
|
-
map.getView().calculateExtent(),
|
|
102
|
-
"EPSG:3857",
|
|
103
|
-
"EPSG:4326",
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const fetchData = async () => {
|
|
107
|
-
// Fill stations data
|
|
108
|
-
// The stations are also loaded in the style to have them displayed during export
|
|
109
|
-
const stations = await fetchStations(
|
|
110
|
-
WFS_STATIONS_TYPE,
|
|
111
|
-
abortController,
|
|
112
|
-
extent,
|
|
113
|
-
);
|
|
114
|
-
setStationsData(stations);
|
|
115
|
-
|
|
116
|
-
// Fill free float data
|
|
117
|
-
const freeFloatData = (await fetchSharingWFS(
|
|
118
|
-
WFS_FREE_FLOAT_TYPE,
|
|
119
|
-
abortController,
|
|
120
|
-
extent,
|
|
121
|
-
)) as FeatureCollection<Point, SharingVehicleWFS>;
|
|
122
|
-
|
|
123
|
-
const bikes: FeatureCollection<Point, SharingVehicleWFS> = {
|
|
124
|
-
features: [],
|
|
125
|
-
type: "FeatureCollection",
|
|
126
|
-
};
|
|
127
|
-
const cargoBikes: FeatureCollection<Point, SharingVehicleWFS> = {
|
|
128
|
-
features: [],
|
|
129
|
-
type: "FeatureCollection",
|
|
130
|
-
};
|
|
131
|
-
const cars: FeatureCollection<Point, SharingVehicleWFS> = {
|
|
132
|
-
features: [],
|
|
133
|
-
type: "FeatureCollection",
|
|
134
|
-
};
|
|
135
|
-
const scooter: FeatureCollection<Point, SharingVehicleWFS> = {
|
|
136
|
-
features: [],
|
|
137
|
-
type: "FeatureCollection",
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
freeFloatData.features.forEach((feature) => {
|
|
141
|
-
if (feature.properties.form_factor === BIKE_FORM_FACTOR) {
|
|
142
|
-
bikes.features.push(feature);
|
|
143
|
-
} else if (feature.properties.form_factor === CARGOBIKE_FORM_FACTOR) {
|
|
144
|
-
cargoBikes.features.push(feature);
|
|
145
|
-
} else if (feature.properties.form_factor === CAR_FORM_FACTOR) {
|
|
146
|
-
cars.features.push(feature);
|
|
147
|
-
} else if (feature.properties.form_factor === SCOOTER_FORM_FACTOR) {
|
|
148
|
-
scooter.features.push(feature);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
setBikeFreeFloatData(bikes);
|
|
153
|
-
setCargoBikeFreeFloatData(cargoBikes);
|
|
154
|
-
setCarFreeFloatData(cars);
|
|
155
|
-
setScooterFreeFloatData(scooter);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
void fetchData();
|
|
159
|
-
|
|
160
|
-
return () => {
|
|
161
|
-
abortController.abort();
|
|
162
|
-
};
|
|
163
|
-
}, [map]);
|
|
164
|
-
|
|
165
|
-
// Request all stations and vehicleson each moveend event
|
|
166
|
-
useEffect(() => {
|
|
167
|
-
const key = map?.on("moveend", updateData);
|
|
168
|
-
|
|
169
|
-
// @ts-expect-error - change property can have custom values
|
|
170
|
-
const key2 = map?.on(`change:${LAYER_PROP_IS_EXPORTING}`, (evt) => {
|
|
171
|
-
// Reupdate the data after finishing eporting the map
|
|
172
|
-
if (!evt.target.get(LAYER_PROP_IS_EXPORTING)) {
|
|
173
|
-
updateData();
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
const key3 = map?.once("rendercomplete", updateData);
|
|
177
|
-
return () => {
|
|
178
|
-
unByKey([key, key2, key3]);
|
|
179
|
-
};
|
|
180
|
-
}, [map, updateData, mbMap]);
|
|
181
|
-
|
|
182
98
|
useEffect(() => {
|
|
183
99
|
if (!mbMap?.style || !stationsData) {
|
|
184
100
|
return;
|
|
@@ -402,6 +318,101 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
402
318
|
} as GroupOptions);
|
|
403
319
|
}, [baseLayer, props, t]);
|
|
404
320
|
|
|
321
|
+
const updateData = useCallback(() => {
|
|
322
|
+
// Only update when layers are visible
|
|
323
|
+
if (map?.getView()?.getZoom() < 15.5 || !group.getVisible()) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const abortController = new AbortController();
|
|
327
|
+
const extent = transformExtent(
|
|
328
|
+
map.getView().calculateExtent(),
|
|
329
|
+
"EPSG:3857",
|
|
330
|
+
"EPSG:4326",
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
const fetchData = async () => {
|
|
334
|
+
// Fill stations data
|
|
335
|
+
// The stations are also loaded in the style to have them displayed during export
|
|
336
|
+
const stations = await fetchStations(
|
|
337
|
+
WFS_STATIONS_TYPE,
|
|
338
|
+
abortController,
|
|
339
|
+
extent,
|
|
340
|
+
);
|
|
341
|
+
setStationsData(stations);
|
|
342
|
+
|
|
343
|
+
// Fill free float data
|
|
344
|
+
const freeFloatData = (await fetchSharingWFS(
|
|
345
|
+
WFS_FREE_FLOAT_TYPE,
|
|
346
|
+
abortController,
|
|
347
|
+
extent,
|
|
348
|
+
)) as FeatureCollection<Point, SharingVehicleWFS>;
|
|
349
|
+
|
|
350
|
+
const bikes: FeatureCollection<Point, SharingVehicleWFS> = {
|
|
351
|
+
features: [],
|
|
352
|
+
type: "FeatureCollection",
|
|
353
|
+
};
|
|
354
|
+
const cargoBikes: FeatureCollection<Point, SharingVehicleWFS> = {
|
|
355
|
+
features: [],
|
|
356
|
+
type: "FeatureCollection",
|
|
357
|
+
};
|
|
358
|
+
const cars: FeatureCollection<Point, SharingVehicleWFS> = {
|
|
359
|
+
features: [],
|
|
360
|
+
type: "FeatureCollection",
|
|
361
|
+
};
|
|
362
|
+
const scooter: FeatureCollection<Point, SharingVehicleWFS> = {
|
|
363
|
+
features: [],
|
|
364
|
+
type: "FeatureCollection",
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
freeFloatData.features.forEach((feature) => {
|
|
368
|
+
if (feature.properties.form_factor === BIKE_FORM_FACTOR) {
|
|
369
|
+
bikes.features.push(feature);
|
|
370
|
+
} else if (feature.properties.form_factor === CARGOBIKE_FORM_FACTOR) {
|
|
371
|
+
cargoBikes.features.push(feature);
|
|
372
|
+
} else if (feature.properties.form_factor === CAR_FORM_FACTOR) {
|
|
373
|
+
cars.features.push(feature);
|
|
374
|
+
} else if (feature.properties.form_factor === SCOOTER_FORM_FACTOR) {
|
|
375
|
+
scooter.features.push(feature);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
setBikeFreeFloatData(bikes);
|
|
380
|
+
setCargoBikeFreeFloatData(cargoBikes);
|
|
381
|
+
setCarFreeFloatData(cars);
|
|
382
|
+
setScooterFreeFloatData(scooter);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
void fetchData();
|
|
386
|
+
|
|
387
|
+
return () => {
|
|
388
|
+
abortController.abort();
|
|
389
|
+
};
|
|
390
|
+
}, [map, group]);
|
|
391
|
+
|
|
392
|
+
// Request all stations and vehicleson each moveend event
|
|
393
|
+
useEffect(() => {
|
|
394
|
+
const key = map?.on("moveend", () => {
|
|
395
|
+
return updateData();
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// @ts-expect-error - change property can have custom values
|
|
399
|
+
const key2 = map?.on(`change:${LAYER_PROP_IS_EXPORTING}`, (evt) => {
|
|
400
|
+
// Reupdate the data after finishing eporting the map
|
|
401
|
+
if (!evt.target.get(LAYER_PROP_IS_EXPORTING)) {
|
|
402
|
+
updateData();
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
const key3 = map?.once("rendercomplete", updateData);
|
|
406
|
+
const key4 = group?.on("change:visible", (evt) => {
|
|
407
|
+
if (evt.target.getVisible()) {
|
|
408
|
+
updateData();
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
return () => {
|
|
412
|
+
unByKey([key, key2, key3, key4]);
|
|
413
|
+
};
|
|
414
|
+
}, [map, updateData, mbMap, group]);
|
|
415
|
+
|
|
405
416
|
// Reload features every minute
|
|
406
417
|
useEffect(() => {
|
|
407
418
|
const interval = window.setInterval(() => {
|