@geops/rvf-mobility-web-component 0.1.42 → 0.1.44
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/.yarnrc.yml +1 -0
- package/CHANGELOG.md +18 -0
- package/README.md +31 -3
- package/docutils.js +1 -1
- package/iframe.html +221 -11
- package/index.html +16 -5
- package/index.js +111 -106
- package/package.json +2 -2
- package/src/MobilityMap/MobilityMap.tsx +2 -2
- package/src/NotificationLayer/NotificationLayer.tsx +11 -189
- package/src/RouteStopTime/RouteStopTime.tsx +2 -2
- package/src/RvfFeatureDetails/RvfFeatureDetails.tsx +4 -3
- package/src/RvfFeatureDetails/RvfLineNetworkDetails/RvfLineNetworkDetails.tsx +9 -3
- package/src/RvfFeatureDetails/RvfNotificationDetails/RvfNotificationDetails.tsx +1 -1
- package/src/RvfMobilityMap/RvfMobilityMap.tsx +69 -22
- package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +33 -21
- package/src/RvfTopics/RvfTopics.tsx +25 -1
- package/src/utils/constants.ts +7 -4
- package/src/utils/hooks/useMapContext.tsx +5 -0
- package/src/utils/sharingGraphqlUtils.ts +2 -2
- package/src/utils/sharingWFSUtils.ts +6 -0
- package/testNotification.json +103 -50641
- package/src/NotificationLayer/notificationUtils.ts +0 -437
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getUid } from "ol";
|
|
2
2
|
import { Group } from "ol/layer";
|
|
3
3
|
import BaseLayer from "ol/layer/Base";
|
|
4
|
+
import { unByKey } from "ol/Observable";
|
|
4
5
|
import { JSX, PreactDOMAttributes } from "preact";
|
|
5
6
|
import { memo, useEffect, useMemo, useState } from "preact/compat";
|
|
6
7
|
|
|
@@ -60,14 +61,37 @@ function RvfTopics(props: RvfTopicsProps) {
|
|
|
60
61
|
|
|
61
62
|
// Force update of config when a layers`s visibility changes progammatically
|
|
62
63
|
useEffect(() => {
|
|
64
|
+
const keys = [];
|
|
63
65
|
const layers = getLayersAsFlatArray(map.getLayers().getArray());
|
|
64
66
|
layers.forEach((layer) => {
|
|
65
|
-
layer.on("change:visible", () => {
|
|
67
|
+
const key = layer.on("change:visible", () => {
|
|
66
68
|
setRevision((prev) => {
|
|
67
69
|
return prev + 1;
|
|
68
70
|
});
|
|
69
71
|
});
|
|
72
|
+
keys.push(key);
|
|
70
73
|
});
|
|
74
|
+
keys.push(
|
|
75
|
+
map.on("change:layergroup", () => {
|
|
76
|
+
setRevision((prev) => {
|
|
77
|
+
return prev + 1;
|
|
78
|
+
});
|
|
79
|
+
}),
|
|
80
|
+
map.getLayers().on("add", () => {
|
|
81
|
+
setRevision((prev) => {
|
|
82
|
+
return prev + 1;
|
|
83
|
+
});
|
|
84
|
+
}),
|
|
85
|
+
map.getLayers().on("remove", () => {
|
|
86
|
+
setRevision((prev) => {
|
|
87
|
+
return prev + 1;
|
|
88
|
+
});
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
return () => {
|
|
92
|
+
// Clean up all listeners
|
|
93
|
+
unByKey(keys);
|
|
94
|
+
};
|
|
71
95
|
}, [map]);
|
|
72
96
|
|
|
73
97
|
return <RvfLayerTree layers={layers} {...props} />;
|
package/src/utils/constants.ts
CHANGED
|
@@ -32,6 +32,7 @@ export const RVF_LAYERS_TITLES = {
|
|
|
32
32
|
fahrrad: "Fahrrad",
|
|
33
33
|
haltestellen: "Haltestellen",
|
|
34
34
|
liniennetz: "Liniennetz",
|
|
35
|
+
meldungen: "Meldungen",
|
|
35
36
|
mitfahrpunkte: "Mitfahrpunkte",
|
|
36
37
|
pois: "POIs",
|
|
37
38
|
sharedMobility: "Shared Mobility",
|
|
@@ -60,6 +61,8 @@ export const RVF_LAYERS_NAMES = {
|
|
|
60
61
|
export const WFS_CARGO_BIKE_TYPE = "sharing_stations_cargo_bicycle";
|
|
61
62
|
export const WFS_CAR_TYPE = "sharing_stations_car";
|
|
62
63
|
export const WFS_BIKE_TYPE = "sharing_stations_bicycle";
|
|
64
|
+
export const WFS_STATIONS_TYPE = "sharing_stations";
|
|
65
|
+
|
|
63
66
|
export const WFS_FREE_FLOAT_TYPE = "sharing_vehicles";
|
|
64
67
|
|
|
65
68
|
export const SOURCE_STATIONS_BIKE = WFS_BIKE_TYPE;
|
|
@@ -85,10 +88,10 @@ export const API_REQUEST_FEATURE_TYPE = {
|
|
|
85
88
|
scooter: "sharing_vehicles",
|
|
86
89
|
},
|
|
87
90
|
stations: {
|
|
88
|
-
bike: "
|
|
89
|
-
car: "
|
|
90
|
-
cargoBike: "
|
|
91
|
-
scooter: "
|
|
91
|
+
bike: "sharing_stations",
|
|
92
|
+
car: "sharing_stations",
|
|
93
|
+
cargoBike: "sharing_stations",
|
|
94
|
+
scooter: "sharing_stations",
|
|
92
95
|
},
|
|
93
96
|
};
|
|
94
97
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
RealtimeLayer,
|
|
6
6
|
} from "mobility-toolbox-js/ol";
|
|
7
7
|
import {
|
|
8
|
+
MocoNotification,
|
|
8
9
|
RealtimeStation,
|
|
9
10
|
RealtimeStationId,
|
|
10
11
|
RealtimeStopSequence,
|
|
@@ -23,11 +24,13 @@ export type MapContextType = {
|
|
|
23
24
|
isTracking: boolean;
|
|
24
25
|
layers: string;
|
|
25
26
|
map: Map;
|
|
27
|
+
previewNotification?: MocoNotification;
|
|
26
28
|
realtimeLayer: RealtimeLayer;
|
|
27
29
|
setBaseLayer: (baseLayer: MaplibreLayer) => void;
|
|
28
30
|
setIsFollowing: (isFollowing: boolean) => void;
|
|
29
31
|
setIsTracking: (isTracking: boolean) => void;
|
|
30
32
|
setMap: (map?: Map) => void;
|
|
33
|
+
setPreviewNotification: (previewNotification?: MocoNotification) => void;
|
|
31
34
|
setRealtimeLayer: (realtimeLayer?: RealtimeLayer) => void;
|
|
32
35
|
setStation: (station?: RealtimeStation) => void;
|
|
33
36
|
setStationId: (stationId?: RealtimeStationId) => void;
|
|
@@ -47,11 +50,13 @@ export const MapContext = createContext<MapContextType>({
|
|
|
47
50
|
isTracking: false,
|
|
48
51
|
layers: null,
|
|
49
52
|
map: null,
|
|
53
|
+
previewNotification: null,
|
|
50
54
|
realtimeLayer: null,
|
|
51
55
|
setBaseLayer: (baseLayer?: MaplibreLayer) => {},
|
|
52
56
|
setIsFollowing: (isFollowing: boolean) => {},
|
|
53
57
|
setIsTracking: (isTracking: boolean) => {},
|
|
54
58
|
setMap: (map?: Map) => {},
|
|
59
|
+
setPreviewNotification: (previewNotification?: MocoNotification) => {},
|
|
55
60
|
setRealtimeLayer: (realtimeLayer?: RealtimeLayer) => {},
|
|
56
61
|
setStation: (station?: RealtimeStation) => {},
|
|
57
62
|
setStationId: (stationId?: RealtimeStationId) => {},
|
|
@@ -248,7 +248,7 @@ const queryStations = gql`
|
|
|
248
248
|
|
|
249
249
|
export const fetchSharingStation = async (id: string) => {
|
|
250
250
|
const client = new GraphQLClient(GQL_URL, {
|
|
251
|
-
method: "
|
|
251
|
+
method: "POST",
|
|
252
252
|
});
|
|
253
253
|
const { station }: { station: unknown } = await client
|
|
254
254
|
.request(queryStation, {
|
|
@@ -271,7 +271,7 @@ export const fetchSharingStations = async (
|
|
|
271
271
|
const client = new GraphQLClient(
|
|
272
272
|
"https://api.mobidata-bw.de/sharing/graphql",
|
|
273
273
|
{
|
|
274
|
-
method: "
|
|
274
|
+
method: "POST",
|
|
275
275
|
signal: abortController.signal,
|
|
276
276
|
},
|
|
277
277
|
);
|
|
@@ -17,6 +17,12 @@ export type SharingStationWFS = {
|
|
|
17
17
|
feed_id: string;
|
|
18
18
|
last_reported: string;
|
|
19
19
|
name: string;
|
|
20
|
+
num_bicycles_available: null | number;
|
|
21
|
+
num_cargo_bicycles_available: null | number;
|
|
22
|
+
num_cars_available: null | number;
|
|
23
|
+
num_mopeds_available: null | number;
|
|
24
|
+
num_scooters_standing_available: null | number;
|
|
25
|
+
// Backward compatibility with style
|
|
20
26
|
num_vehicles_available: number;
|
|
21
27
|
rental_uris_android: string;
|
|
22
28
|
rental_uris_ios: string;
|