@geops/rvf-mobility-web-component 0.1.54 → 0.1.55
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/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.55",
|
|
6
6
|
"homepage": "https://rvf-mobility-web-component-geops.vercel.app/",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "index.js",
|
|
@@ -22,9 +22,7 @@ import {
|
|
|
22
22
|
SOURCE_FREE_FLOAT_CAR,
|
|
23
23
|
SOURCE_FREE_FLOAT_CARGO_BIKE,
|
|
24
24
|
SOURCE_FREE_FLOAT_SCOOTER,
|
|
25
|
-
|
|
26
|
-
SOURCE_STATIONS_CAR,
|
|
27
|
-
SOURCE_STATIONS_CARGO_BIKE,
|
|
25
|
+
SOURCE_SHARING_STATIONS,
|
|
28
26
|
WFS_FREE_FLOAT_TYPE,
|
|
29
27
|
WFS_STATIONS_TYPE,
|
|
30
28
|
} from "../utils/constants";
|
|
@@ -82,11 +80,7 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
82
80
|
// const [scooterLayer, setScooterLayer] = useState<MaplibreStyleLayer>();
|
|
83
81
|
|
|
84
82
|
// GeoJSON data
|
|
85
|
-
const [
|
|
86
|
-
useState<FeatureCollection<Point, SharingStationWFS>>();
|
|
87
|
-
const [cargoBikeStationsData, setCargoBikeStationsData] =
|
|
88
|
-
useState<FeatureCollection<Point, SharingStationWFS>>();
|
|
89
|
-
const [carStationsData, setCarStationsData] =
|
|
83
|
+
const [stationsData, setStationsData] =
|
|
90
84
|
useState<FeatureCollection<Point, SharingStationWFS>>();
|
|
91
85
|
const [bikeFreeFloatData, setBikeFreeFloatData] =
|
|
92
86
|
useState<FeatureCollection<Point, SharingVehicleWFS>>();
|
|
@@ -111,46 +105,13 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
111
105
|
|
|
112
106
|
const fetchData = async () => {
|
|
113
107
|
// Fill stations data
|
|
108
|
+
// The stations are also loaded in the style to have them displayed during export
|
|
114
109
|
const stations = await fetchStations(
|
|
115
110
|
WFS_STATIONS_TYPE,
|
|
116
111
|
abortController,
|
|
117
112
|
extent,
|
|
118
113
|
);
|
|
119
|
-
|
|
120
|
-
features: [],
|
|
121
|
-
type: "FeatureCollection",
|
|
122
|
-
};
|
|
123
|
-
const cargoBikeStationsDatas: FeatureCollection<
|
|
124
|
-
Point,
|
|
125
|
-
SharingStationWFS
|
|
126
|
-
> = {
|
|
127
|
-
features: [],
|
|
128
|
-
type: "FeatureCollection",
|
|
129
|
-
};
|
|
130
|
-
const carStationsDatas: FeatureCollection<Point, SharingStationWFS> = {
|
|
131
|
-
features: [],
|
|
132
|
-
type: "FeatureCollection",
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
stations?.features.forEach((station) => {
|
|
136
|
-
if (station.properties.num_bicycles_available !== null) {
|
|
137
|
-
station.properties.num_vehicles_available =
|
|
138
|
-
station.properties.num_bicycles_available;
|
|
139
|
-
bikeStationsDatas.features.push(station);
|
|
140
|
-
} else if (station.properties.num_cargo_bicycles_available !== null) {
|
|
141
|
-
station.properties.num_vehicles_available =
|
|
142
|
-
station.properties.num_cargo_bicycles_available;
|
|
143
|
-
cargoBikeStationsDatas.features.push(station);
|
|
144
|
-
} else if (station.properties.num_cars_available !== null) {
|
|
145
|
-
station.properties.num_vehicles_available =
|
|
146
|
-
station.properties.num_cars_available;
|
|
147
|
-
carStationsDatas.features.push(station);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
setBikeStationsData(bikeStationsDatas);
|
|
152
|
-
setCargoBikeStationsData(cargoBikeStationsDatas);
|
|
153
|
-
setCarStationsData(carStationsDatas);
|
|
114
|
+
setStationsData(stations);
|
|
154
115
|
|
|
155
116
|
// Fill free float data
|
|
156
117
|
const freeFloatData = (await fetchSharingWFS(
|
|
@@ -219,28 +180,12 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
219
180
|
}, [map, updateData, mbMap]);
|
|
220
181
|
|
|
221
182
|
useEffect(() => {
|
|
222
|
-
if (!mbMap || !
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const source = mbMap.getSource(SOURCE_STATIONS_BIKE);
|
|
226
|
-
(source as GeoJSONSource)?.setData(bikeStationsData);
|
|
227
|
-
}, [bikeStationsData, mbMap]);
|
|
228
|
-
|
|
229
|
-
useEffect(() => {
|
|
230
|
-
if (!mbMap || !cargoBikeStationsData) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
const source = mbMap.getSource(SOURCE_STATIONS_CARGO_BIKE);
|
|
234
|
-
(source as GeoJSONSource)?.setData(cargoBikeStationsData);
|
|
235
|
-
}, [mbMap, cargoBikeStationsData]);
|
|
236
|
-
|
|
237
|
-
useEffect(() => {
|
|
238
|
-
if (!mbMap || !carStationsData) {
|
|
183
|
+
if (!mbMap || !stationsData) {
|
|
239
184
|
return;
|
|
240
185
|
}
|
|
241
|
-
const source = mbMap.getSource(
|
|
242
|
-
(source as GeoJSONSource)?.setData(
|
|
243
|
-
}, [
|
|
186
|
+
const source = mbMap.getSource(SOURCE_SHARING_STATIONS);
|
|
187
|
+
(source as GeoJSONSource)?.setData(stationsData);
|
|
188
|
+
}, [stationsData, mbMap]);
|
|
244
189
|
|
|
245
190
|
useEffect(() => {
|
|
246
191
|
if (!mbMap || !bikeFreeFloatData) {
|
|
@@ -289,7 +234,6 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
289
234
|
}
|
|
290
235
|
|
|
291
236
|
const bikeFrelo = new MaplibreStyleLayer({
|
|
292
|
-
isQueryable: true,
|
|
293
237
|
maplibreLayer: baseLayer,
|
|
294
238
|
name: RVF_LAYERS_NAMES.bikeFrelo,
|
|
295
239
|
styleLayersFilter: ({ metadata }) => {
|
|
@@ -306,7 +250,6 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
306
250
|
// setBikeFreloLayer(bikeFrelo);
|
|
307
251
|
|
|
308
252
|
const bikeOthers = new MaplibreStyleLayer({
|
|
309
|
-
isQueryable: true,
|
|
310
253
|
maplibreLayer: baseLayer,
|
|
311
254
|
name: RVF_LAYERS_NAMES.bikeOthers,
|
|
312
255
|
styleLayersFilter: ({ metadata }) => {
|
|
@@ -322,7 +265,6 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
322
265
|
// setBikeOthersLayer(bikeOthers);
|
|
323
266
|
|
|
324
267
|
const cargobikeFrelo = new MaplibreStyleLayer({
|
|
325
|
-
isQueryable: true,
|
|
326
268
|
layersFilter: ({ metadata }) => {
|
|
327
269
|
return metadata?.["rvf.filter"] === "cargo_bike.frelo";
|
|
328
270
|
},
|
|
@@ -338,7 +280,6 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
338
280
|
// setCargobikeFreloLayer(cargobikeFrelo);
|
|
339
281
|
|
|
340
282
|
const cargobikeOthers = new MaplibreStyleLayer({
|
|
341
|
-
isQueryable: true,
|
|
342
283
|
layersFilter: ({ metadata }) => {
|
|
343
284
|
return metadata?.["rvf.filter"] === "cargo_bike.other";
|
|
344
285
|
},
|
|
@@ -354,7 +295,6 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
354
295
|
// setCargobikeOthersLayer(cargobikeOthers);
|
|
355
296
|
|
|
356
297
|
const carGrf = new MaplibreStyleLayer({
|
|
357
|
-
isQueryable: true,
|
|
358
298
|
layersFilter: ({ metadata }) => {
|
|
359
299
|
return metadata?.["rvf.filter"] === "car.grueneflotte";
|
|
360
300
|
},
|
|
@@ -370,7 +310,6 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
370
310
|
// setCarGrfLayer(carGrf);
|
|
371
311
|
|
|
372
312
|
const carNatur = new MaplibreStyleLayer({
|
|
373
|
-
isQueryable: true,
|
|
374
313
|
layersFilter: ({ metadata }) => {
|
|
375
314
|
return metadata?.["rvf.filter"] === "car.naturenergy";
|
|
376
315
|
},
|
|
@@ -386,7 +325,6 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
386
325
|
// setCarNaturLayer(carNatur);
|
|
387
326
|
|
|
388
327
|
const carOthers = new MaplibreStyleLayer({
|
|
389
|
-
isQueryable: true,
|
|
390
328
|
layersFilter: ({ metadata }) => {
|
|
391
329
|
return metadata?.["rvf.filter"] === "car.other";
|
|
392
330
|
},
|
|
@@ -402,7 +340,6 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
402
340
|
// setCarOthersLayer(carOthers);
|
|
403
341
|
|
|
404
342
|
const scooter = new MaplibreStyleLayer({
|
|
405
|
-
isQueryable: true,
|
|
406
343
|
layersFilter: ({ metadata }) => {
|
|
407
344
|
return metadata?.["rvf.filter"] === "scooter";
|
|
408
345
|
},
|
|
@@ -418,7 +355,6 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
|
|
|
418
355
|
// setScooterLayer(scooter);
|
|
419
356
|
|
|
420
357
|
const hitchHiking = new MaplibreStyleLayer({
|
|
421
|
-
isQueryable: false,
|
|
422
358
|
layersFilter: ({ metadata }) => {
|
|
423
359
|
return metadata?.["rvf.filter"] === "hitchhiking";
|
|
424
360
|
},
|
package/src/utils/constants.ts
CHANGED
|
@@ -99,9 +99,7 @@ export const WFS_STATIONS_TYPE = "sharing_stations";
|
|
|
99
99
|
|
|
100
100
|
export const WFS_FREE_FLOAT_TYPE = "sharing_vehicles";
|
|
101
101
|
|
|
102
|
-
export const
|
|
103
|
-
export const SOURCE_STATIONS_CARGO_BIKE = WFS_CARGO_BIKE_TYPE;
|
|
104
|
-
export const SOURCE_STATIONS_CAR = WFS_CAR_TYPE;
|
|
102
|
+
export const SOURCE_SHARING_STATIONS = "sharing_stations";
|
|
105
103
|
|
|
106
104
|
export const SOURCE_FREE_FLOAT_BIKE = "sharing_freefloat_bicycle";
|
|
107
105
|
export const SOURCE_FREE_FLOAT_CARGO_BIKE = "sharing_freefloat_cargo_bicycle";
|
|
@@ -22,7 +22,7 @@ export type SharingStationWFS = {
|
|
|
22
22
|
num_cars_available: null | number;
|
|
23
23
|
num_mopeds_available: null | number;
|
|
24
24
|
num_scooters_standing_available: null | number;
|
|
25
|
-
// Backward compatibility
|
|
25
|
+
// Backward compatibility for the select style
|
|
26
26
|
num_vehicles_available: number;
|
|
27
27
|
rental_uris_android: string;
|
|
28
28
|
rental_uris_ios: string;
|
|
@@ -79,8 +79,6 @@ export const fetchSharingWFS = async (
|
|
|
79
79
|
|
|
80
80
|
// for select style we always set mot and num_vehicles_available
|
|
81
81
|
const formFactor = (feature.properties as SharingVehicleWFS).form_factor;
|
|
82
|
-
let numVehiclesAvailable = (feature.properties as SharingStationWFS)
|
|
83
|
-
.num_vehicles_available;
|
|
84
82
|
let mot = formFactor || wfsTypeName.split("_").pop();
|
|
85
83
|
if (mot === "bicycle") {
|
|
86
84
|
mot = "bike";
|
|
@@ -88,12 +86,26 @@ export const fetchSharingWFS = async (
|
|
|
88
86
|
mot = "cargo_bike";
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
if (
|
|
92
|
-
|
|
89
|
+
if (mot === "stations") {
|
|
90
|
+
const props: SharingStationWFS =
|
|
91
|
+
feature.properties as SharingStationWFS;
|
|
92
|
+
if (props.num_bicycles_available !== null) {
|
|
93
|
+
mot = "bike";
|
|
94
|
+
feature.properties.num_vehicles_available =
|
|
95
|
+
props.num_bicycles_available;
|
|
96
|
+
} else if (props.num_cars_available !== null) {
|
|
97
|
+
mot = "car";
|
|
98
|
+
feature.properties.num_vehicles_available = props.num_cars_available;
|
|
99
|
+
} else if (props.num_cargo_bicycles_available !== null) {
|
|
100
|
+
mot = "cargo_bike";
|
|
101
|
+
feature.properties.num_vehicles_available =
|
|
102
|
+
props.num_cargo_bicycles_available;
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
feature.properties.num_vehicles_available = 1;
|
|
93
106
|
}
|
|
94
|
-
|
|
107
|
+
// mot property is used for the select styles
|
|
95
108
|
feature.properties.mot = mot;
|
|
96
|
-
feature.properties.num_vehicles_available = numVehiclesAvailable;
|
|
97
109
|
feature.properties.display_num_vehicles_available = true;
|
|
98
110
|
},
|
|
99
111
|
);
|