@geops/rvf-mobility-web-component 0.1.46 → 0.1.47
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/.prettierrc.js +3 -1
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/doc/package.json +4 -3
- package/doc/postcss.config.mjs +1 -1
- package/doc/src/app/components/GeopsMobilityDoc.tsx +13 -224
- package/doc/src/app/components/GeopsMobilitySearchDoc.tsx +11 -107
- package/doc/src/app/components/WebComponentDoc.tsx +45 -56
- package/doc/src/app/geops-mobility/page.tsx +7 -2
- package/doc/src/app/geops-mobility-search/page.tsx +6 -2
- package/doc/src/app/globals.css +47 -27
- package/doc/src/app/layout.tsx +4 -2
- package/docutils.js +33 -17
- package/eslint.config.mjs +28 -34
- package/iframe.html +181 -207
- package/index.html +108 -88
- package/index.js +2345 -1976
- package/input.css +21 -3
- package/package.json +39 -41
- package/scripts/build.mjs +2 -2
- package/scripts/dev.mjs +3 -3
- package/search.html +70 -23
- package/src/BaseLayer/BaseLayer.tsx +2 -1
- package/src/Copyright/Copyright.tsx +4 -2
- package/src/DebugDeparture/DebugDeparture.tsx +16 -12
- package/src/DebugStop/DebugStop.tsx +2 -2
- package/src/Departure/Departure.tsx +2 -3
- package/src/EmbedNavigation/DragPanWarning.ts +125 -0
- package/src/EmbedNavigation/EmbedNavigation.tsx +52 -0
- package/src/EmbedNavigation/index.js +1 -0
- package/src/EmbedNavigation/index.tsx +1 -0
- package/src/GeolocationButton/GeolocationButton.tsx +11 -35
- package/src/GeolocationButton/index.tsx +1 -1
- package/src/Map/Map.tsx +5 -3
- package/src/MapDispatchEvents/MapDispatchEvents.tsx +78 -0
- package/src/MapDispatchEvents/index.tsx +1 -0
- package/src/MobilityMap/MobilityMap.tsx +117 -162
- package/src/MobilityMap/MobilityMapAttributes.test.ts +21 -0
- package/src/MobilityMap/MobilityMapAttributes.ts +252 -0
- package/src/MobilityMap/index.tsx +1 -0
- package/src/MobilitySearch/MobilitySearch.tsx +35 -0
- package/src/MobilitySearch/MobilitySearchAttributes.test.ts +21 -0
- package/src/MobilitySearch/MobilitySearchAttributes.ts +68 -0
- package/src/MobilitySearch/index.ts +2 -0
- package/src/NotificationLayer/NotificationLayer.tsx +36 -5
- package/src/Overlay/Overlay.tsx +24 -11
- package/src/Permalink/Permalink.tsx +77 -0
- package/src/Permalink/index.tsx +1 -0
- package/src/RealtimeLayer/RealtimeLayer.tsx +72 -33
- package/src/RouteDestination/RouteDestination.tsx +3 -3
- package/src/RouteIcon/RouteIcon.tsx +33 -25
- package/src/RouteIcon/index.tsx +1 -1
- package/src/RouteIdentifier/RouteIdentifer.tsx +6 -5
- package/src/RouteInfos/RouteInfos.tsx +7 -3
- package/src/RouteSchedule/RouteSchedule.tsx +3 -3
- package/src/RouteScheduleFooter/RouteScheduleFooter.tsx +1 -1
- package/src/RouteScheduleHeader/RouteScheduleHeader.tsx +7 -29
- package/src/RouteStop/RouteStop.tsx +8 -11
- package/src/RouteStopDelay/RouteStopDelay.tsx +2 -1
- package/src/RouteStopName/RouteStopName.tsx +2 -2
- package/src/RouteStopPlatform/RouteStopPlatform.tsx +2 -2
- package/src/RouteStopProgress/RouteStopProgress.tsx +2 -1
- package/src/RouteStopServices/RouteStopServices.tsx +2 -2
- package/src/RouteStopStation/RouteStopStation.tsx +8 -2
- package/src/RouteStopTime/RouteStopTime.tsx +2 -1
- package/src/RvfButton/RvfButton.tsx +14 -5
- package/src/RvfCheckbox/RvfCheckbox.tsx +8 -8
- package/src/RvfEmbedNavigation/DragPanWarning.ts +5 -5
- package/src/RvfEmbedNavigation/RvfEmbedNavigation.tsx +1 -0
- package/src/RvfExportMenu/RvfExportMenu.tsx +14 -12
- package/src/RvfExportMenuButton/RvfExportMenuButton.tsx +6 -7
- package/src/RvfFeatureDetails/RvfFeatureDetails.tsx +25 -21
- package/src/RvfFeatureDetails/RvfLineNetworkDetails/RvfLineNetworkDetails.tsx +131 -127
- package/src/RvfFeatureDetails/RvfNotificationDetails/RvfNotificationDetails.tsx +309 -111
- package/src/RvfFeatureDetails/RvfSellingPointDetails/RvfSellingPointDetails.tsx +2 -2
- package/src/RvfFeatureDetails/RvfSharedMobilityDetail/FloatingVehiclesDetails/FloatingVehiclesDetails.tsx +3 -3
- package/src/RvfFeatureDetails/RvfSharedMobilityDetail/RvfSharedMobilityDetails.tsx +8 -6
- package/src/RvfFeatureDetails/RvfSharedMobilityDetail/StationDetails/StationDetails.tsx +5 -4
- package/src/RvfFeatureDetailsFooter/RvfFeatureDetailsFooter.tsx +43 -0
- package/src/RvfFeatureDetailsFooter/index.tsx +1 -0
- package/src/RvfFeatureDetailsTitle/RvfFeatureDetailsTitle.tsx +81 -0
- package/src/RvfFeatureDetailsTitle/index.tsx +1 -0
- package/src/RvfFloatingMenu/RvfFloatingMenu.tsx +4 -4
- package/src/RvfGeolocationButton/GeolocationButton.tsx +98 -0
- package/src/RvfGeolocationButton/index.tsx +1 -0
- package/src/RvfIconButton/RvfIconButton.tsx +20 -9
- package/src/RvfInputCopy/RvfInputCopy.tsx +8 -8
- package/src/RvfLayerTree/RvfLayerTree.tsx +5 -2
- package/src/RvfLayerTree/TreeItem/TreeItem.tsx +13 -16
- package/src/RvfLayerTree/layersTreeReducer.ts +23 -18
- package/src/RvfLayerTreeButton/RvfLayerTreeButton.tsx +6 -6
- package/src/RvfLineNetworkPlanLayer/RvfLineNetworkPlanLayer.tsx +2 -1
- package/src/RvfLink/RvfLink.tsx +4 -3
- package/src/RvfMobilityMap/RvfMobilityMap.tsx +324 -320
- package/src/RvfModal/RvfModal.tsx +4 -3
- package/src/RvfOverlayContent/RvfOverlayContent.tsx +128 -0
- package/src/RvfOverlayContent/index.ts +0 -0
- package/src/RvfOverlayHeader/RvfOverlayHeader.tsx +13 -10
- package/src/RvfPermalink/RvfPermalink.tsx +2 -2
- package/src/RvfPoisLayer/RvfPoisLayer.tsx +2 -1
- package/src/RvfRadioButton/RvfRadioButton.tsx +1 -1
- package/src/RvfRouteIcon/RvfRouteIcon.tsx +10 -0
- package/src/RvfRouteIcon/index.tsx +1 -0
- package/src/RvfSearch/RvfSearch.tsx +4 -1
- package/src/RvfSearchButton/RvfSearchButton.tsx +27 -0
- package/src/RvfSearchButton/index.tsx +1 -0
- package/src/RvfSelect/RvfSelect.tsx +7 -5
- package/src/RvfSelectedFeatureHighlightLayer/RvfSelectedFeatureHighlightLayer.tsx +1 -2
- package/src/RvfSellingPointsLayer/RvfSellingPointsLayer.tsx +2 -1
- package/src/RvfShare/RvfPermalinkButton/RvfPermalinkButton.tsx +13 -12
- package/src/RvfShare/RvfShare.tsx +11 -10
- package/src/RvfShareMenuButton/RvfShareMenuButton.tsx +5 -5
- package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +25 -22
- package/src/RvfSingleClickListener/RvfSingleClickListener.tsx +102 -67
- package/src/RvfTarifZonenLayer/RvfTarifZonenLayer.tsx +2 -1
- package/src/RvfTopics/RvfTopics.tsx +6 -5
- package/src/RvfZoomButtons/RvfZoomButtons.tsx +3 -3
- package/src/ScaleLine/ScaleLine.tsx +5 -4
- package/src/ScrollableHandler/ScrollableHandler.tsx +2 -1
- package/src/ScrollableHandler/index.tsx +1 -1
- package/src/SingleClickListener/SingleClickListener.tsx +47 -4
- package/src/Station/Station.tsx +5 -5
- package/src/StationName/StationName.tsx +3 -3
- package/src/StationServices/StationServices.tsx +3 -3
- package/src/StationsLayer/StationsLayer.tsx +5 -4
- package/src/StopsSearch/StopsSearch.tsx +143 -88
- package/src/WindowMessageListener/WindowMessageListener.tsx +68 -0
- package/src/WindowMessageListener/index.tsx +1 -0
- package/src/icons/Airport/Airport.tsx +4 -4
- package/src/icons/ArrowDown/ArrowDown.tsx +1 -1
- package/src/icons/ArrowRight/ArrowRight.tsx +19 -0
- package/src/icons/ArrowRight/arrow-right.svg +16 -0
- package/src/icons/ArrowRight/index.tsx +1 -0
- package/src/icons/ArrowUp/ArrowUp.tsx +1 -1
- package/src/icons/ArrowUpRight/ArrowUpRight.tsx +1 -1
- package/src/icons/BarAndRestaurants/BarAndRestaurants.tsx +2 -2
- package/src/icons/Bathroom/Bathroom.tsx +1 -1
- package/src/icons/Copy/Copy.tsx +1 -1
- package/src/icons/Doc/Doc.tsx +1 -1
- package/src/icons/Email/Email.tsx +1 -1
- package/src/icons/FilePdf/FilePdf.tsx +1 -1
- package/src/icons/Geolocation/Geolocation.tsx +3 -5
- package/src/icons/Image/Image.tsx +1 -1
- package/src/icons/Menu/Menu.tsx +1 -1
- package/src/icons/Minus/Minus.tsx +1 -1
- package/src/icons/NoRealtime/NoRealtime.tsx +1 -1
- package/src/icons/Plus/Plus.tsx +1 -1
- package/src/icons/Police/Police.tsx +3 -3
- package/src/icons/Search/Search.tsx +0 -1
- package/src/icons/Share/Share.tsx +1 -1
- package/src/icons/Stack/Stack.tsx +1 -1
- package/src/icons/Tracking/Tracking.tsx +29 -0
- package/src/icons/Tracking/airport-14-svgrepo-com.svg +41 -0
- package/src/icons/Tracking/index.tsx +1 -0
- package/src/icons/WaitingAreas/WaitingAreas.tsx +1 -1
- package/src/icons/Warning/Warning.tsx +56 -0
- package/src/icons/Warning/index.tsx +1 -0
- package/src/icons/Warning/info-achtung-kreisrot-rot.svg +28 -0
- package/src/icons/WheelChair/WheelChair.tsx +1 -1
- package/src/index.tsx +8 -46
- package/src/indexDoc.ts +13 -0
- package/src/ui/Button/Button.tsx +57 -0
- package/src/ui/Button/index.tsx +1 -0
- package/src/ui/IconButton/IconButton.tsx +44 -0
- package/src/ui/IconButton/index.tsx +1 -0
- package/src/utils/MobilityEvent.ts +4 -3
- package/src/utils/applyInitialLayerVisibility.ts +3 -3
- package/src/utils/centerOnStation.ts +3 -2
- package/src/utils/centerOnVehicle.ts +5 -4
- package/src/utils/constants.ts +27 -3
- package/src/utils/exportPdf.ts +26 -20
- package/src/utils/fullTrajectoryStyle.ts +2 -2
- package/src/utils/getAllLayers.ts +4 -3
- package/src/utils/getDelayColor.test.ts +1 -0
- package/src/utils/getDelayColorForVehicle.test.ts +2 -0
- package/src/utils/getDelayString.test.ts +3 -0
- package/src/utils/getDelayTextForVehicle.test.ts +4 -0
- package/src/utils/getFullTrajectoryAndFit.ts +4 -3
- package/src/utils/getHoursAndMinutes.test.ts +1 -0
- package/src/utils/getLayersAsFlatArray.ts +2 -2
- package/src/utils/getLinkByDevice.ts +1 -1
- package/src/utils/getMainColorForVehicle.ts +3 -3
- package/src/utils/getPermalinkParameters.ts +2 -2
- package/src/utils/getStopStatus.test.ts +2 -1
- package/src/utils/getStopStatus.ts +1 -1
- package/src/utils/getTextForVehicle.ts +1 -1
- package/src/utils/hooks/useDeparture.tsx +6 -5
- package/src/utils/hooks/useI18n.tsx +6 -4
- package/src/utils/hooks/useInitialLayersVisiblity.tsx +2 -1
- package/src/utils/hooks/useLayerConfig.tsx +40 -0
- package/src/utils/hooks/useMapContext.tsx +30 -18
- package/src/utils/hooks/useRouteStop.tsx +3 -2
- package/src/utils/hooks/useRvfContext.tsx +11 -3
- package/src/utils/hooks/useStation.tsx +2 -1
- package/src/utils/hooks/useUpdatePermalink.tsx +25 -24
- package/src/utils/hooks/useZoom.tsx +4 -4
- package/src/utils/realtimeRVFStyle.ts +5 -4
- package/src/utils/sharingGraphqlUtils.ts +3 -2
- package/src/utils/sharingStylesUtils.ts +7 -7
- package/src/utils/sharingWFSUtils.ts +9 -15
- package/tailwind.config.mjs +1 -0
- package/tsconfig.json +1 -1
- package/doc/tailwind.config.ts +0 -20
- package/src/utils/getFeatureInformationTitle.tsx +0 -54
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Feature, MapBrowserEvent } from "ol";
|
|
1
|
+
import { getFeatureInfoAtCoordinate } from "mobility-toolbox-js/ol";
|
|
3
2
|
import { GeoJSON } from "ol/format";
|
|
4
3
|
import { unByKey } from "ol/Observable";
|
|
5
|
-
import { toLonLat } from "ol/proj";
|
|
6
4
|
import { useCallback, useEffect } from "preact/hooks";
|
|
7
5
|
|
|
8
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
LAYER_NAME_REALTIME,
|
|
8
|
+
LAYER_NAME_STATIONS,
|
|
9
|
+
PROVIDER_LOGOS_BY_FEED_ID,
|
|
10
|
+
} from "../utils/constants";
|
|
9
11
|
import useMapContext from "../utils/hooks/useMapContext";
|
|
10
12
|
import useRvfContext from "../utils/hooks/useRvfContext";
|
|
11
13
|
import MobilityEvent from "../utils/MobilityEvent";
|
|
12
14
|
import { fetchSharingStation } from "../utils/sharingGraphqlUtils";
|
|
13
15
|
|
|
16
|
+
import type { GeoJSONSource } from "maplibre-gl";
|
|
17
|
+
import type { Feature, MapBrowserEvent } from "ol";
|
|
18
|
+
|
|
14
19
|
const geojson = new GeoJSON();
|
|
15
20
|
|
|
16
|
-
function SingleClickListener() {
|
|
21
|
+
function SingleClickListener({ eventNode }: { eventNode: HTMLElement }) {
|
|
17
22
|
const {
|
|
18
23
|
baseLayer,
|
|
19
24
|
map,
|
|
25
|
+
queryablelayers,
|
|
20
26
|
realtimeLayer,
|
|
21
27
|
setStationId,
|
|
22
28
|
setTrainId,
|
|
@@ -30,22 +36,19 @@ function SingleClickListener() {
|
|
|
30
36
|
|
|
31
37
|
// Send the selctedFEature to the parent window
|
|
32
38
|
useEffect(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
map.getTargetElement().dispatchEvent(
|
|
38
|
-
new MobilityEvent("selectedfeature", {
|
|
39
|
+
eventNode?.dispatchEvent(
|
|
40
|
+
new MobilityEvent("mwc:selectedfeature", {
|
|
39
41
|
feature: selectedFeature
|
|
40
42
|
? geojson.writeFeatureObject(selectedFeature)
|
|
41
43
|
: null,
|
|
42
44
|
}),
|
|
43
45
|
);
|
|
44
|
-
}, [
|
|
46
|
+
}, [eventNode, selectedFeature]);
|
|
45
47
|
|
|
46
48
|
const onPointerMove = useCallback(
|
|
47
|
-
|
|
49
|
+
(evt: MapBrowserEvent<PointerEvent>) => {
|
|
48
50
|
const [realtimeFeature] = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
51
|
+
hitTolerance: 5,
|
|
49
52
|
layerFilter: (l) => {
|
|
50
53
|
return l === realtimeLayer;
|
|
51
54
|
},
|
|
@@ -65,7 +68,9 @@ function SingleClickListener() {
|
|
|
65
68
|
// Send all the features under the cursor
|
|
66
69
|
const features = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
67
70
|
layerFilter: (l) => {
|
|
68
|
-
return
|
|
71
|
+
return queryablelayers
|
|
72
|
+
? queryablelayers.split(",").includes(l.get("name"))
|
|
73
|
+
: l.get("isQueryable");
|
|
69
74
|
},
|
|
70
75
|
}) as Feature[];
|
|
71
76
|
|
|
@@ -74,19 +79,21 @@ function SingleClickListener() {
|
|
|
74
79
|
? "pointer"
|
|
75
80
|
: "default";
|
|
76
81
|
},
|
|
77
|
-
[realtimeLayer, stationsLayer, tenant],
|
|
82
|
+
[queryablelayers, realtimeLayer, stationsLayer, tenant],
|
|
78
83
|
);
|
|
79
84
|
|
|
80
85
|
const onSingleClick = useCallback(
|
|
81
86
|
async (evt: MapBrowserEvent<PointerEvent>) => {
|
|
82
|
-
if (!baseLayer
|
|
87
|
+
if (!baseLayer?.mapLibreMap) {
|
|
83
88
|
return;
|
|
84
89
|
}
|
|
85
90
|
const [realtimeFeature] = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
91
|
+
hitTolerance: 5,
|
|
86
92
|
layerFilter: (l) => {
|
|
87
93
|
return l === realtimeLayer;
|
|
88
94
|
},
|
|
89
|
-
});
|
|
95
|
+
}) as Feature[];
|
|
96
|
+
realtimeFeature?.set("layerName", LAYER_NAME_REALTIME);
|
|
90
97
|
|
|
91
98
|
const stationsFeatures = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
92
99
|
layerFilter: (l) => {
|
|
@@ -95,7 +102,8 @@ function SingleClickListener() {
|
|
|
95
102
|
});
|
|
96
103
|
const [stationFeature] = stationsFeatures.filter((feat) => {
|
|
97
104
|
return feat.get("tralis_network")?.includes(tenant);
|
|
98
|
-
});
|
|
105
|
+
}) as Feature[];
|
|
106
|
+
stationFeature?.set("layerName", LAYER_NAME_STATIONS);
|
|
99
107
|
|
|
100
108
|
const newStationId = stationFeature?.get("uid");
|
|
101
109
|
|
|
@@ -113,61 +121,87 @@ function SingleClickListener() {
|
|
|
113
121
|
}
|
|
114
122
|
|
|
115
123
|
// Send all the features under the cursor
|
|
116
|
-
const features = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
// const features = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
125
|
+
// hitTolerance: 5,
|
|
126
|
+
// layerFilter: (l) => {
|
|
127
|
+
// console.log(queryablelayers);
|
|
128
|
+
// return queryablelayers
|
|
129
|
+
// ? queryablelayers.split(",").includes(l.get("name"))
|
|
130
|
+
// : l.get("isQueryable");
|
|
131
|
+
// },
|
|
132
|
+
// }) as Feature[];
|
|
133
|
+
|
|
134
|
+
const queryableLayers = evt.map.getAllLayers().filter((l) => {
|
|
135
|
+
return queryablelayers
|
|
136
|
+
? queryablelayers.split(",").includes(l.get("name"))
|
|
137
|
+
: l.get("isQueryable");
|
|
138
|
+
});
|
|
139
|
+
const featuresInfos = await getFeatureInfoAtCoordinate(
|
|
140
|
+
evt.coordinate,
|
|
141
|
+
queryableLayers,
|
|
142
|
+
5,
|
|
143
|
+
true,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// Set the layerName as property of the feature
|
|
147
|
+
featuresInfos.forEach((f) => {
|
|
148
|
+
f.features.forEach((feat) => {
|
|
149
|
+
feat.set("layerName", f.layer.get("name"));
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const features = featuresInfos.flatMap((f) => {
|
|
154
|
+
return f.features;
|
|
155
|
+
});
|
|
121
156
|
|
|
122
157
|
// Append more infos about the features
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
);
|
|
152
|
-
}
|
|
158
|
+
for (const feature of features) {
|
|
159
|
+
const clusterId = feature.get("cluster_id");
|
|
160
|
+
if (clusterId) {
|
|
161
|
+
const vtFeat = feature.get("vectorTileFeature");
|
|
162
|
+
const sourceId = vtFeat.layer.source;
|
|
163
|
+
const leaves =
|
|
164
|
+
(await baseLayer.mapLibreMap
|
|
165
|
+
.getSource<GeoJSONSource>(sourceId)
|
|
166
|
+
?.getClusterLeaves(clusterId, 1000, 0)) || [];
|
|
167
|
+
|
|
168
|
+
feature.set(
|
|
169
|
+
"features",
|
|
170
|
+
leaves.map((l) => {
|
|
171
|
+
return geojson.readFeature(l);
|
|
172
|
+
}),
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Sharing station
|
|
177
|
+
const sharingStationId = selectedFeature?.get("station_id");
|
|
178
|
+
if (sharingStationId) {
|
|
179
|
+
const sharingStationInfo =
|
|
180
|
+
await fetchSharingStation(sharingStationId);
|
|
181
|
+
selectedFeature.setProperties(sharingStationInfo);
|
|
182
|
+
selectedFeature.set(
|
|
183
|
+
"provider_logo",
|
|
184
|
+
PROVIDER_LOGOS_BY_FEED_ID[selectedFeature?.get("feed_id")],
|
|
185
|
+
);
|
|
153
186
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (newStationId || newTrainId || !features.length) {
|
|
190
|
+
setSelectedFeature(null);
|
|
191
|
+
setSelectedFeatures([]);
|
|
192
|
+
} else {
|
|
193
|
+
setSelectedFeatures(features);
|
|
194
|
+
|
|
195
|
+
// We prioritize some layers like the notification one over the others
|
|
196
|
+
const notificationFeature = features.find((feat) => {
|
|
197
|
+
return feat.get("situation");
|
|
198
|
+
});
|
|
199
|
+
if (notificationFeature) {
|
|
200
|
+
setSelectedFeature(notificationFeature);
|
|
165
201
|
} else {
|
|
166
|
-
setSelectedFeatures(features);
|
|
167
202
|
setSelectedFeature(features[0]);
|
|
168
203
|
}
|
|
169
|
-
}
|
|
170
|
-
addMoreData(features);
|
|
204
|
+
}
|
|
171
205
|
},
|
|
172
206
|
[
|
|
173
207
|
baseLayer?.mapLibreMap,
|
|
@@ -178,6 +212,7 @@ function SingleClickListener() {
|
|
|
178
212
|
tenant,
|
|
179
213
|
setStationId,
|
|
180
214
|
setTrainId,
|
|
215
|
+
queryablelayers,
|
|
181
216
|
selectedFeature,
|
|
182
217
|
setSelectedFeature,
|
|
183
218
|
setSelectedFeatures,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { MaplibreStyleLayer } from "mobility-toolbox-js/ol";
|
|
2
|
-
import { MaplibreStyleLayerOptions } from "mobility-toolbox-js/ol/layers/MaplibreStyleLayer";
|
|
3
2
|
import { memo } from "preact/compat";
|
|
4
3
|
import { useEffect, useMemo } from "preact/hooks";
|
|
5
4
|
|
|
@@ -7,6 +6,8 @@ import { RVF_LAYERS_NAMES } from "../utils/constants";
|
|
|
7
6
|
import useMapContext from "../utils/hooks/useMapContext";
|
|
8
7
|
import useRvfContext from "../utils/hooks/useRvfContext";
|
|
9
8
|
|
|
9
|
+
import type { MaplibreStyleLayerOptions } from "mobility-toolbox-js/ol/layers/MaplibreStyleLayer";
|
|
10
|
+
|
|
10
11
|
function RvfTarifZonenLayer(props: MaplibreStyleLayerOptions) {
|
|
11
12
|
const { baseLayer, map } = useMapContext();
|
|
12
13
|
const { setTarifZonenLayer } = useRvfContext();
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { getUid } from "ol";
|
|
2
|
-
import { Group } from "ol/layer";
|
|
3
|
-
import BaseLayer from "ol/layer/Base";
|
|
4
2
|
import { unByKey } from "ol/Observable";
|
|
5
|
-
import { JSX, PreactDOMAttributes } from "preact";
|
|
6
3
|
import { memo, useEffect, useMemo, useState } from "preact/compat";
|
|
7
4
|
|
|
8
5
|
import RvfLayerTree from "../RvfLayerTree";
|
|
@@ -10,6 +7,10 @@ import { SelectionType } from "../RvfLayerTree/TreeItem/TreeItem";
|
|
|
10
7
|
import getLayersAsFlatArray from "../utils/getLayersAsFlatArray";
|
|
11
8
|
import useMapContext from "../utils/hooks/useMapContext";
|
|
12
9
|
|
|
10
|
+
import type { Group } from "ol/layer";
|
|
11
|
+
import type BaseLayer from "ol/layer/Base";
|
|
12
|
+
import type { JSX, PreactDOMAttributes } from "preact";
|
|
13
|
+
|
|
13
14
|
export interface RvfLayerTreeConfig {
|
|
14
15
|
childItems: RvfLayerTreeConfig[];
|
|
15
16
|
id: string;
|
|
@@ -62,8 +63,8 @@ function RvfTopics(props: RvfTopicsProps) {
|
|
|
62
63
|
// Force update of config when a layers`s visibility changes progammatically
|
|
63
64
|
useEffect(() => {
|
|
64
65
|
const keys = [];
|
|
65
|
-
const
|
|
66
|
-
|
|
66
|
+
const layerss = getLayersAsFlatArray(map.getLayers().getArray());
|
|
67
|
+
layerss.forEach((layer) => {
|
|
67
68
|
const key = layer.on("change:visible", () => {
|
|
68
69
|
setRevision((prev) => {
|
|
69
70
|
return prev + 1;
|
|
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useState } from "preact/hooks";
|
|
|
4
4
|
|
|
5
5
|
import Minus from "../icons/Minus";
|
|
6
6
|
import Plus from "../icons/Plus";
|
|
7
|
-
import
|
|
7
|
+
import IconButton from "../ui/IconButton";
|
|
8
8
|
import useMapContext from "../utils/hooks/useMapContext";
|
|
9
9
|
|
|
10
10
|
function RvfZoomButtons() {
|
|
@@ -56,12 +56,12 @@ function RvfZoomButtons() {
|
|
|
56
56
|
|
|
57
57
|
return (
|
|
58
58
|
<>
|
|
59
|
-
<
|
|
59
|
+
<IconButton
|
|
60
60
|
disabled={isZoomInDisabled}
|
|
61
61
|
Icon={Plus}
|
|
62
62
|
onClick={handleZoomIn}
|
|
63
63
|
/>
|
|
64
|
-
<
|
|
64
|
+
<IconButton
|
|
65
65
|
disabled={isZoomOutDisabled}
|
|
66
66
|
Icon={Minus}
|
|
67
67
|
onClick={handleZoomOut}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import ScaleLineControl
|
|
2
|
-
Options as ScaleLineOptions,
|
|
3
|
-
} from "ol/control/ScaleLine";
|
|
4
|
-
import { JSX, PreactDOMAttributes } from "preact";
|
|
1
|
+
import ScaleLineControl from "ol/control/ScaleLine";
|
|
5
2
|
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
6
3
|
|
|
7
4
|
import useMapContext from "../utils/hooks/useMapContext";
|
|
5
|
+
|
|
8
6
|
// @ts-expect-error bad type definition
|
|
9
7
|
import style from "./index.css";
|
|
10
8
|
|
|
9
|
+
import type { Options as ScaleLineOptions } from "ol/control/ScaleLine";
|
|
10
|
+
import type { JSX, PreactDOMAttributes } from "preact";
|
|
11
|
+
|
|
11
12
|
type ScaleLineProps = {
|
|
12
13
|
options?: ScaleLineOptions;
|
|
13
14
|
} & JSX.HTMLAttributes<HTMLDivElement> &
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { JSX, PreactDOMAttributes } from "preact";
|
|
2
1
|
import { useEffect, useState } from "preact/hooks";
|
|
3
2
|
|
|
3
|
+
import type { JSX, PreactDOMAttributes } from "preact";
|
|
4
|
+
|
|
4
5
|
export type ScrollableHandlerProps = JSX.HTMLAttributes<HTMLDivElement> &
|
|
5
6
|
PreactDOMAttributes;
|
|
6
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from "./ScrollableHandler";
|
|
1
|
+
export { default, ScrollableHandlerProps } from "./ScrollableHandler";
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { Feature, MapBrowserEvent } from "ol";
|
|
2
1
|
import { unByKey } from "ol/Observable";
|
|
3
2
|
import { useCallback, useEffect } from "preact/hooks";
|
|
4
3
|
|
|
5
4
|
import useMapContext from "../utils/hooks/useMapContext";
|
|
6
5
|
|
|
6
|
+
import type { Feature, MapBrowserEvent } from "ol";
|
|
7
|
+
|
|
7
8
|
function SingleClickListener() {
|
|
8
9
|
const {
|
|
9
10
|
map,
|
|
11
|
+
// queryablelayers,
|
|
10
12
|
realtimeLayer,
|
|
13
|
+
setSelectedFeature,
|
|
14
|
+
setSelectedFeatures,
|
|
11
15
|
setStationId,
|
|
12
16
|
setTrainId,
|
|
13
17
|
stationId,
|
|
@@ -17,8 +21,9 @@ function SingleClickListener() {
|
|
|
17
21
|
} = useMapContext();
|
|
18
22
|
|
|
19
23
|
const onPointerMove = useCallback(
|
|
20
|
-
|
|
24
|
+
(evt: MapBrowserEvent<PointerEvent>) => {
|
|
21
25
|
const [realtimeFeature] = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
26
|
+
hitTolerance: 5,
|
|
22
27
|
layerFilter: (l) => {
|
|
23
28
|
return l === realtimeLayer;
|
|
24
29
|
},
|
|
@@ -35,15 +40,35 @@ function SingleClickListener() {
|
|
|
35
40
|
return feat.get("tralis_network")?.includes(tenant);
|
|
36
41
|
});
|
|
37
42
|
|
|
43
|
+
// Send all the features under the cursor
|
|
44
|
+
const features = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
45
|
+
layerFilter: (l) => {
|
|
46
|
+
return l.get("isQueryable");
|
|
47
|
+
},
|
|
48
|
+
}) as Feature[];
|
|
49
|
+
|
|
38
50
|
evt.map.getTargetElement().style.cursor =
|
|
39
|
-
realtimeFeature || stationFeature
|
|
51
|
+
realtimeFeature || stationFeature || features?.length
|
|
52
|
+
? "pointer"
|
|
53
|
+
: "default";
|
|
40
54
|
},
|
|
41
55
|
[realtimeLayer, stationsLayer, tenant],
|
|
42
56
|
);
|
|
43
57
|
|
|
44
58
|
const onSingleClick = useCallback(
|
|
45
|
-
|
|
59
|
+
(evt: MapBrowserEvent<PointerEvent>) => {
|
|
60
|
+
// const qeryableLayers = queryablelayers?.split(",");
|
|
61
|
+
// const featuress = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
62
|
+
// layerFilter: (l) => {
|
|
63
|
+
// return qeryableLayers
|
|
64
|
+
// ? queryablelayers.includes(l.get("name"))
|
|
65
|
+
// : true;
|
|
66
|
+
// },
|
|
67
|
+
// });
|
|
68
|
+
// console.log("featursss", featuress);
|
|
69
|
+
|
|
46
70
|
const [realtimeFeature] = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
71
|
+
hitTolerance: 5,
|
|
47
72
|
layerFilter: (l) => {
|
|
48
73
|
return l === realtimeLayer;
|
|
49
74
|
},
|
|
@@ -72,8 +97,24 @@ function SingleClickListener() {
|
|
|
72
97
|
setTrainId(null);
|
|
73
98
|
setStationId(null);
|
|
74
99
|
}
|
|
100
|
+
|
|
101
|
+
// Send all the features under the cursor
|
|
102
|
+
const features = evt.map.getFeaturesAtPixel(evt.pixel, {
|
|
103
|
+
layerFilter: (l) => {
|
|
104
|
+
return l.get("isQueryable");
|
|
105
|
+
},
|
|
106
|
+
}) as Feature[];
|
|
107
|
+
|
|
108
|
+
if (newStationId || newTrainId || !features.length) {
|
|
109
|
+
setSelectedFeature(null);
|
|
110
|
+
setSelectedFeatures([]);
|
|
111
|
+
} else {
|
|
112
|
+
setSelectedFeatures(features);
|
|
113
|
+
setSelectedFeature(features[0]);
|
|
114
|
+
}
|
|
75
115
|
},
|
|
76
116
|
[
|
|
117
|
+
// queryablelayers,
|
|
77
118
|
stationId,
|
|
78
119
|
trainId,
|
|
79
120
|
realtimeLayer,
|
|
@@ -81,6 +122,8 @@ function SingleClickListener() {
|
|
|
81
122
|
tenant,
|
|
82
123
|
setStationId,
|
|
83
124
|
setTrainId,
|
|
125
|
+
setSelectedFeature,
|
|
126
|
+
setSelectedFeatures,
|
|
84
127
|
],
|
|
85
128
|
);
|
|
86
129
|
|
package/src/Station/Station.tsx
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { JSX, PreactDOMAttributes } from "preact";
|
|
2
|
-
|
|
3
1
|
import { debounceDeparturesMessages } from "mobility-toolbox-js/ol";
|
|
4
|
-
import { RealtimeDeparture } from "mobility-toolbox-js/types";
|
|
5
2
|
import { memo } from "preact/compat";
|
|
6
3
|
import { useEffect, useRef, useState } from "preact/hooks";
|
|
7
4
|
|
|
@@ -9,6 +6,9 @@ import Departure from "../Departure";
|
|
|
9
6
|
import StationHeader from "../StationHeader";
|
|
10
7
|
import useMapContext from "../utils/hooks/useMapContext";
|
|
11
8
|
|
|
9
|
+
import type { RealtimeDeparture } from "mobility-toolbox-js/types";
|
|
10
|
+
import type { JSX, PreactDOMAttributes } from "preact";
|
|
11
|
+
|
|
12
12
|
export type StationProps = JSX.HTMLAttributes<HTMLDivElement> &
|
|
13
13
|
PreactDOMAttributes;
|
|
14
14
|
|
|
@@ -24,8 +24,8 @@ function Station(props: StationProps) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const onMessage = debounceDeparturesMessages(
|
|
27
|
-
(
|
|
28
|
-
setDepartures(
|
|
27
|
+
(newDepartures: RealtimeDeparture[]) => {
|
|
28
|
+
setDepartures(newDepartures);
|
|
29
29
|
return null;
|
|
30
30
|
},
|
|
31
31
|
false,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { JSX, PreactDOMAttributes } from "preact";
|
|
2
|
-
|
|
3
|
-
import { RealtimeStation } from "mobility-toolbox-js/types";
|
|
4
1
|
import { memo } from "preact/compat";
|
|
5
2
|
|
|
3
|
+
import type { RealtimeStation } from "mobility-toolbox-js/types";
|
|
4
|
+
import type { JSX, PreactDOMAttributes } from "preact";
|
|
5
|
+
|
|
6
6
|
export type StationNameProps = {
|
|
7
7
|
station: RealtimeStation;
|
|
8
8
|
} & JSX.HTMLAttributes<HTMLDivElement> &
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type { JSX, PreactDOMAttributes } from "preact";
|
|
2
|
-
|
|
3
|
-
import { RealtimeStation } from "mobility-toolbox-js/types";
|
|
4
1
|
import { memo } from "preact/compat";
|
|
5
2
|
|
|
6
3
|
import Airport from "../icons/Airport";
|
|
@@ -12,6 +9,9 @@ import Police from "../icons/Police";
|
|
|
12
9
|
import WaitingAreas from "../icons/WaitingAreas";
|
|
13
10
|
import WheelChair from "../icons/WheelChair";
|
|
14
11
|
|
|
12
|
+
import type { RealtimeStation } from "mobility-toolbox-js/types";
|
|
13
|
+
import type { JSX, PreactDOMAttributes } from "preact";
|
|
14
|
+
|
|
15
15
|
export type StationServicesProps = {
|
|
16
16
|
accessibility?: boolean;
|
|
17
17
|
airport?: boolean;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { MaplibreStyleLayer } from "mobility-toolbox-js/ol";
|
|
2
|
-
import { MaplibreStyleLayerOptions } from "mobility-toolbox-js/ol/layers/MaplibreStyleLayer";
|
|
3
2
|
import { memo } from "preact/compat";
|
|
4
3
|
import { useEffect, useMemo } from "preact/hooks";
|
|
5
4
|
|
|
6
|
-
import {
|
|
5
|
+
import { LAYER_NAME_STATIONS } from "../utils/constants";
|
|
7
6
|
import useMapContext from "../utils/hooks/useMapContext";
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
import type { MaplibreStyleLayerOptions } from "mobility-toolbox-js/ol";
|
|
9
|
+
|
|
10
|
+
function StationsLayer(props: Partial<MaplibreStyleLayerOptions>) {
|
|
10
11
|
const { baseLayer, map, setStationsLayer } = useMapContext();
|
|
11
12
|
|
|
12
13
|
const layer = useMemo(() => {
|
|
@@ -18,7 +19,7 @@ function StationsLayer(props: MaplibreStyleLayerOptions) {
|
|
|
18
19
|
return metadata?.["general.filter"] === "stations";
|
|
19
20
|
},
|
|
20
21
|
maplibreLayer: baseLayer,
|
|
21
|
-
name:
|
|
22
|
+
name: LAYER_NAME_STATIONS,
|
|
22
23
|
...(props || {}),
|
|
23
24
|
});
|
|
24
25
|
}, [baseLayer, props]);
|