@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
|
@@ -5,6 +5,7 @@ describe("getDelayColorForVehicle", () => {
|
|
|
5
5
|
expect(getDelayColorForVehicle(0, true, true)).toBe("#dc2626");
|
|
6
6
|
expect(getDelayColorForVehicle(0, true, false)).toBe("#a0a0a0");
|
|
7
7
|
});
|
|
8
|
+
|
|
8
9
|
it("returns null delay (no realtime train) color", () => {
|
|
9
10
|
expect(getDelayColorForVehicle(null)).toBe("transparent");
|
|
10
11
|
});
|
|
@@ -27,6 +28,7 @@ describe("getDelayColorForVehicle", () => {
|
|
|
27
28
|
expect(getDelayColorForVehicle(4.49 * 60 * 1000 - 1)).toBe("#ea580c");
|
|
28
29
|
expect(getDelayColorForVehicle(5 * 60 * 1000)).toBe("#ea580c");
|
|
29
30
|
});
|
|
31
|
+
|
|
30
32
|
it("returns red", () => {
|
|
31
33
|
expect(getDelayColorForVehicle(9.49 * 60 * 1000 - 1)).toBe("#dc2626");
|
|
32
34
|
expect(getDelayColorForVehicle(10 * 60 * 1000)).toBe("#dc2626");
|
|
@@ -5,15 +5,18 @@ describe("getDelayString", () => {
|
|
|
5
5
|
expect(getDelayString(7200000)).toBe("2h");
|
|
6
6
|
expect(getDelayString(7255555)).toBe("2h1m");
|
|
7
7
|
});
|
|
8
|
+
|
|
8
9
|
it("returns minutes (round)", () => {
|
|
9
10
|
expect(getDelayString(120000)).toBe("2m");
|
|
10
11
|
expect(getDelayString(151000)).toBe("3m");
|
|
11
12
|
});
|
|
13
|
+
|
|
12
14
|
it("doesn't display seconds", () => {
|
|
13
15
|
expect(getDelayString(1000)).toBe("0");
|
|
14
16
|
expect(getDelayString(30000)).toBe("1m");
|
|
15
17
|
expect(getDelayString(7255555)).toBe("2h1m");
|
|
16
18
|
});
|
|
19
|
+
|
|
17
20
|
it("returns defsult 0 value", () => {
|
|
18
21
|
expect(getDelayString(0)).toBe("0");
|
|
19
22
|
expect(getDelayString(null)).toBe("0");
|
|
@@ -6,19 +6,23 @@ describe("getDelayTextForVehicle", () => {
|
|
|
6
6
|
String.fromCodePoint(0x00d7),
|
|
7
7
|
);
|
|
8
8
|
});
|
|
9
|
+
|
|
9
10
|
it("returns hours (floor)", () => {
|
|
10
11
|
expect(getDelayTextForVehicle(7200000)).toBe("+2h");
|
|
11
12
|
expect(getDelayTextForVehicle(7255555)).toBe("+2h1m");
|
|
12
13
|
});
|
|
14
|
+
|
|
13
15
|
it("returns minutes (round)", () => {
|
|
14
16
|
expect(getDelayTextForVehicle(120000)).toBe("+2m");
|
|
15
17
|
expect(getDelayTextForVehicle(151000)).toBe("+3m");
|
|
16
18
|
});
|
|
19
|
+
|
|
17
20
|
it("doesn't display seconds", () => {
|
|
18
21
|
expect(getDelayTextForVehicle(1000)).toBe("");
|
|
19
22
|
expect(getDelayTextForVehicle(30000)).toBe("+1m");
|
|
20
23
|
expect(getDelayTextForVehicle(7255555)).toBe("+2h1m");
|
|
21
24
|
});
|
|
25
|
+
|
|
22
26
|
it("returns empty value", () => {
|
|
23
27
|
expect(getDelayTextForVehicle(1000)).toBe("");
|
|
24
28
|
expect(getDelayTextForVehicle(null)).toBe("");
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { RealtimeLayer } from "mobility-toolbox-js/ol";
|
|
2
|
-
import { RealtimeTrainId } from "mobility-toolbox-js/types";
|
|
3
|
-
import { Map } from "ol";
|
|
4
1
|
import { GeoJSON } from "ol/format";
|
|
5
2
|
import { Vector } from "ol/source";
|
|
6
3
|
|
|
4
|
+
import type { RealtimeLayer } from "mobility-toolbox-js/ol";
|
|
5
|
+
import type { RealtimeTrainId } from "mobility-toolbox-js/types";
|
|
6
|
+
import type { Map } from "ol";
|
|
7
|
+
|
|
7
8
|
const getFullTrajectoryAndFit = async (
|
|
8
9
|
map: Map,
|
|
9
10
|
realtimeLayer: RealtimeLayer,
|
|
@@ -5,6 +5,7 @@ describe("getHoursAndMinutes", () => {
|
|
|
5
5
|
expect(getHoursAndMinutes(7200000)).toBe("02:00");
|
|
6
6
|
expect(getHoursAndMinutes(72999999)).toBe("20:16");
|
|
7
7
|
});
|
|
8
|
+
|
|
8
9
|
it("returns empty string", () => {
|
|
9
10
|
expect(getHoursAndMinutes(null)).toBe("");
|
|
10
11
|
expect(getHoursAndMinutes(undefined)).toBe("");
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import getBgColor from "./getBgColor";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
2
4
|
RealtimeDeparture,
|
|
3
5
|
RealtimeLine,
|
|
4
6
|
RealtimeMot,
|
|
@@ -6,8 +8,6 @@ import {
|
|
|
6
8
|
RealtimeTrajectory,
|
|
7
9
|
} from "mobility-toolbox-js/types";
|
|
8
10
|
|
|
9
|
-
import getBgColor from "./getBgColor";
|
|
10
|
-
|
|
11
11
|
// This function returns the main color of a line using a line, trajectory, stopsequence or departure object.
|
|
12
12
|
const getMainColorForVehicle = (object: unknown = null): string => {
|
|
13
13
|
const line =
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getLayersAsFlatArray } from "mobility-toolbox-js/ol";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import type { Map } from "ol";
|
|
4
4
|
|
|
5
5
|
// This function return URL parameters representing a map.
|
|
6
6
|
const getPermalinkParameters = (
|
|
@@ -75,7 +75,8 @@ describe("getStopStatus", () => {
|
|
|
75
75
|
expect(isNextStop).toBe(true);
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
|
-
|
|
78
|
+
|
|
79
|
+
describe("when it's the first station and not a stop", () => {
|
|
79
80
|
it("returns a correct status", () => {
|
|
80
81
|
const stopSequence = {
|
|
81
82
|
stations: [{}],
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { RealtimeDeparture } from "mobility-toolbox-js/types";
|
|
2
1
|
import { createContext } from "preact";
|
|
3
2
|
import { useContext } from "preact/hooks";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import type { RealtimeDeparture } from "mobility-toolbox-js/types";
|
|
5
|
+
|
|
6
|
+
export interface DepartureContextType {
|
|
7
7
|
departure?: RealtimeDeparture;
|
|
8
|
-
|
|
8
|
+
index?: number;
|
|
9
|
+
}
|
|
9
10
|
|
|
10
11
|
export const DepartureContext = createContext({
|
|
11
|
-
index: null,
|
|
12
12
|
departure: null,
|
|
13
|
+
index: null,
|
|
13
14
|
} as DepartureContextType);
|
|
14
15
|
|
|
15
16
|
const useDeparture = (): DepartureContextType => {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { createContext } from "preact";
|
|
2
2
|
import { useContext } from "preact/hooks";
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
t: (id: string, templateValues?:
|
|
6
|
-
}
|
|
4
|
+
export interface I18NContextType {
|
|
5
|
+
t: (id: string, templateValues?: Record<string, string>) => string;
|
|
6
|
+
}
|
|
7
7
|
|
|
8
8
|
export const I18nContext = createContext({
|
|
9
|
-
t: (id, templateValues) =>
|
|
9
|
+
t: (id, templateValues) => {
|
|
10
|
+
return `${id} ${JSON.stringify(templateValues)}`;
|
|
11
|
+
},
|
|
10
12
|
} as I18NContextType);
|
|
11
13
|
|
|
12
14
|
const useI18n = (): I18NContextType => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Map } from "ol";
|
|
2
1
|
import { unByKey } from "ol/Observable";
|
|
3
2
|
import { useEffect } from "preact/hooks";
|
|
4
3
|
|
|
5
4
|
import applyInitialLayerVisibility from "../applyInitialLayerVisibility";
|
|
6
5
|
import getLayersAsFlatArray from "../getLayersAsFlatArray";
|
|
7
6
|
|
|
7
|
+
import type { Map } from "ol";
|
|
8
|
+
|
|
8
9
|
const useInitialLayersVisiblity = (map: Map, layers: string) => {
|
|
9
10
|
// Apply initial visibility of layers from layers attribute
|
|
10
11
|
useEffect(() => {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEffect, useState } from "preact/hooks";
|
|
2
|
+
|
|
3
|
+
import { RVF_LAYERS_TITLES } from "../constants";
|
|
4
|
+
|
|
5
|
+
import useMapContext from "./useMapContext";
|
|
6
|
+
|
|
7
|
+
export interface LayerConfig {
|
|
8
|
+
link?: {
|
|
9
|
+
href?: string;
|
|
10
|
+
show?: boolean;
|
|
11
|
+
text?: string;
|
|
12
|
+
};
|
|
13
|
+
title?: string;
|
|
14
|
+
}
|
|
15
|
+
export type LayersConfig = Record<string, LayerConfig>;
|
|
16
|
+
|
|
17
|
+
function useLayerConfig(layerName) {
|
|
18
|
+
const { layersconfig } = useMapContext();
|
|
19
|
+
const [layersConfig, setLayersConfig] = useState<LayersConfig>({});
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
try {
|
|
23
|
+
const config = JSON.parse(layersconfig || "{}");
|
|
24
|
+
setLayersConfig(config);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.error("Error parsing layersconfig:", error);
|
|
28
|
+
}
|
|
29
|
+
}, [layersconfig]);
|
|
30
|
+
|
|
31
|
+
// Set defaultstyle if not present in layersconfig
|
|
32
|
+
const layerConfig = layersConfig[layerName] || ({} as LayerConfig);
|
|
33
|
+
if (!layerConfig.title) {
|
|
34
|
+
layerConfig.title = RVF_LAYERS_TITLES[layerName];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return layerConfig;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default useLayerConfig;
|
|
@@ -1,37 +1,47 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-
|
|
2
|
-
import {
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { createContext } from "preact";
|
|
3
|
+
import { useContext } from "preact/hooks";
|
|
4
|
+
|
|
5
|
+
import type {
|
|
3
6
|
MaplibreLayer,
|
|
4
7
|
MaplibreStyleLayer,
|
|
5
8
|
RealtimeLayer,
|
|
6
9
|
} from "mobility-toolbox-js/ol";
|
|
7
|
-
import {
|
|
8
|
-
MocoNotification,
|
|
10
|
+
import type {
|
|
9
11
|
RealtimeStation,
|
|
10
12
|
RealtimeStationId,
|
|
11
13
|
RealtimeStopSequence,
|
|
12
14
|
RealtimeTrainId,
|
|
15
|
+
SituationType,
|
|
13
16
|
} from "mobility-toolbox-js/types";
|
|
14
|
-
import { Map } from "ol";
|
|
15
|
-
import { createContext } from "preact";
|
|
16
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
17
|
-
import { useContext } from "preact/hooks";
|
|
17
|
+
import type { Feature, Map } from "ol";
|
|
18
18
|
|
|
19
19
|
import type { MobilityMapProps } from "../../MobilityMap/MobilityMap";
|
|
20
20
|
|
|
21
21
|
export type MapContextType = {
|
|
22
22
|
baseLayer: MaplibreLayer;
|
|
23
|
+
isEmbed: boolean;
|
|
23
24
|
isFollowing: boolean;
|
|
24
25
|
isTracking: boolean;
|
|
25
26
|
layers: string;
|
|
26
27
|
map: Map;
|
|
27
|
-
|
|
28
|
+
permalinkUrlSearchParams: URLSearchParams;
|
|
29
|
+
previewNotifications?: SituationType[];
|
|
30
|
+
queryablelayers: string;
|
|
28
31
|
realtimeLayer: RealtimeLayer;
|
|
32
|
+
selectedFeature: Feature;
|
|
33
|
+
selectedFeatures: Feature[];
|
|
29
34
|
setBaseLayer: (baseLayer: MaplibreLayer) => void;
|
|
30
35
|
setIsFollowing: (isFollowing: boolean) => void;
|
|
31
36
|
setIsTracking: (isTracking: boolean) => void;
|
|
32
37
|
setMap: (map?: Map) => void;
|
|
33
|
-
|
|
38
|
+
setPermalinkUrlSearchParams: (
|
|
39
|
+
permalinkUrlSearchParams: URLSearchParams,
|
|
40
|
+
) => void;
|
|
41
|
+
setPreviewNotifications: (setPreviewNotifications?: SituationType[]) => void;
|
|
34
42
|
setRealtimeLayer: (realtimeLayer?: RealtimeLayer) => void;
|
|
43
|
+
setSelectedFeature: (feature: Feature) => void;
|
|
44
|
+
setSelectedFeatures: (features: Feature[]) => void;
|
|
35
45
|
setStation: (station?: RealtimeStation) => void;
|
|
36
46
|
setStationId: (stationId?: RealtimeStationId) => void;
|
|
37
47
|
setStationsLayer: (stationsLayer?: MaplibreStyleLayer) => void;
|
|
@@ -45,29 +55,31 @@ export type MapContextType = {
|
|
|
45
55
|
} & MobilityMapProps;
|
|
46
56
|
|
|
47
57
|
export const MapContext = createContext<MapContextType>({
|
|
48
|
-
|
|
58
|
+
isEmbed: false,
|
|
49
59
|
isFollowing: false,
|
|
50
60
|
isTracking: false,
|
|
51
61
|
layers: null,
|
|
52
62
|
map: null,
|
|
53
|
-
|
|
63
|
+
previewNotifications: null,
|
|
64
|
+
queryablelayers: null,
|
|
54
65
|
realtimeLayer: null,
|
|
66
|
+
selectedFeatures: [],
|
|
55
67
|
setBaseLayer: (baseLayer?: MaplibreLayer) => {},
|
|
56
68
|
setIsFollowing: (isFollowing: boolean) => {},
|
|
57
69
|
setIsTracking: (isTracking: boolean) => {},
|
|
58
70
|
setMap: (map?: Map) => {},
|
|
59
|
-
|
|
71
|
+
setPermalinkUrlSearchParams: (
|
|
72
|
+
permalinkUrlSearchParams: URLSearchParams,
|
|
73
|
+
) => {},
|
|
74
|
+
setPreviewNotifications: (previewNotifications?: SituationType[]) => {},
|
|
60
75
|
setRealtimeLayer: (realtimeLayer?: RealtimeLayer) => {},
|
|
76
|
+
setSelectedFeature: (feature: Feature) => {},
|
|
77
|
+
setSelectedFeatures: (features: Feature[]) => {},
|
|
61
78
|
setStation: (station?: RealtimeStation) => {},
|
|
62
79
|
setStationId: (stationId?: RealtimeStationId) => {},
|
|
63
80
|
setStationsLayer: (stationsLayer?: MaplibreStyleLayer) => {},
|
|
64
81
|
setStopSequence: (stopSequence?: RealtimeStopSequence) => {},
|
|
65
82
|
setTrainId: (trainId?: RealtimeTrainId) => {},
|
|
66
|
-
station: null,
|
|
67
|
-
stationId: null,
|
|
68
|
-
stationsLayer: null,
|
|
69
|
-
stopSequence: null,
|
|
70
|
-
trainId: null,
|
|
71
83
|
} as MapContextType);
|
|
72
84
|
|
|
73
85
|
const useMapContext = (): MapContextType => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { RealtimeStation, RealtimeStop } from "mobility-toolbox-js/types";
|
|
2
1
|
import { createContext } from "preact";
|
|
3
2
|
import { useContext } from "preact/hooks";
|
|
4
3
|
|
|
5
|
-
import {
|
|
4
|
+
import type { RealtimeStation, RealtimeStop } from "mobility-toolbox-js/types";
|
|
5
|
+
|
|
6
|
+
import type { StopStatus } from "../getStopStatus";
|
|
6
7
|
|
|
7
8
|
export interface RouteStopContextType {
|
|
8
9
|
index?: number;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import { Feature } from "ol";
|
|
3
|
-
import { Group } from "ol/layer";
|
|
1
|
+
/* eslint-disable no-console */
|
|
4
2
|
import { createContext } from "preact";
|
|
5
3
|
import { useContext } from "preact/hooks";
|
|
6
4
|
|
|
5
|
+
import type { MaplibreStyleLayer } from "mobility-toolbox-js/ol";
|
|
6
|
+
import type { Feature } from "ol";
|
|
7
|
+
import type { Group } from "ol/layer";
|
|
8
|
+
|
|
7
9
|
export interface RvfContextType {
|
|
8
10
|
isExportMenuOpen: boolean;
|
|
9
11
|
isLayerTreeOpen: boolean;
|
|
12
|
+
isSearchOpen: boolean;
|
|
10
13
|
isShareMenuOpen: boolean;
|
|
11
14
|
lineNetworkPlanLayer: MaplibreStyleLayer;
|
|
12
15
|
poisLayer: MaplibreStyleLayer;
|
|
@@ -15,6 +18,7 @@ export interface RvfContextType {
|
|
|
15
18
|
sellingPointsLayer: MaplibreStyleLayer;
|
|
16
19
|
setIsExportMenuOpen: (isOpen: boolean) => void;
|
|
17
20
|
setIsLayerTreeOpen: (isOpen: boolean) => void;
|
|
21
|
+
setIsSearchOpen: (isOpen: boolean) => void;
|
|
18
22
|
setIsShareMenuOpen: (isOpen: boolean) => void;
|
|
19
23
|
setLineNetworkPlanLayer: (layer: MaplibreStyleLayer) => void;
|
|
20
24
|
setPoisLayer: (layer: MaplibreStyleLayer) => void;
|
|
@@ -30,6 +34,7 @@ export interface RvfContextType {
|
|
|
30
34
|
export const RvfContext = createContext<RvfContextType>({
|
|
31
35
|
isExportMenuOpen: false,
|
|
32
36
|
isLayerTreeOpen: false,
|
|
37
|
+
isSearchOpen: false,
|
|
33
38
|
isShareMenuOpen: false,
|
|
34
39
|
lineNetworkPlanLayer: null,
|
|
35
40
|
poisLayer: null,
|
|
@@ -42,6 +47,9 @@ export const RvfContext = createContext<RvfContextType>({
|
|
|
42
47
|
setIsLayerTreeOpen: () => {
|
|
43
48
|
console.warn("setIsLayerTreeOpen is not implemented");
|
|
44
49
|
},
|
|
50
|
+
setIsSearchOpen: () => {
|
|
51
|
+
console.warn("setIsSearchOpen is not implemented");
|
|
52
|
+
},
|
|
45
53
|
setIsShareMenuOpen: () => {
|
|
46
54
|
console.warn("setIsShareMenuOpen is not implemented");
|
|
47
55
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RealtimeStation } from "mobility-toolbox-js/types";
|
|
2
1
|
import { createContext } from "preact";
|
|
3
2
|
import { useContext } from "preact/hooks";
|
|
4
3
|
|
|
4
|
+
import type { RealtimeStation } from "mobility-toolbox-js/types";
|
|
5
|
+
|
|
5
6
|
export interface StationContextType {
|
|
6
7
|
station?: RealtimeStation;
|
|
7
8
|
}
|
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
import debounce from "lodash.debounce";
|
|
2
|
-
import {
|
|
3
|
-
import { EventsKey } from "ol/events";
|
|
2
|
+
import { getLayersAsFlatArray } from "mobility-toolbox-js/ol";
|
|
4
3
|
import { unByKey } from "ol/Observable";
|
|
5
|
-
import {
|
|
4
|
+
import { useEffect } from "preact/hooks";
|
|
6
5
|
|
|
7
6
|
import { LAYER_PROP_IS_EXPORTING } from "../constants";
|
|
8
|
-
import getLayersAsFlatArray from "../getLayersAsFlatArray";
|
|
9
7
|
import getPermalinkParameters from "../getPermalinkParameters";
|
|
10
8
|
import MobilityEvent from "../MobilityEvent";
|
|
11
9
|
|
|
10
|
+
import type { Map } from "ol";
|
|
11
|
+
import type { EventsKey } from "ol/events";
|
|
12
|
+
import type { MutableRef } from "preact/hooks";
|
|
13
|
+
|
|
14
|
+
const updatePermalink = (
|
|
15
|
+
map: Map,
|
|
16
|
+
eventNodeRef: MutableRef<HTMLDivElement>,
|
|
17
|
+
) => {
|
|
18
|
+
// No update when exporting
|
|
19
|
+
if (map.get(LAYER_PROP_IS_EXPORTING)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const currentUrlParams = new URLSearchParams(window.location.search);
|
|
23
|
+
const urlParams = getPermalinkParameters(map, currentUrlParams);
|
|
24
|
+
urlParams.set("permalink", "true");
|
|
25
|
+
window.history.replaceState(null, null, `?${urlParams.toString()}`);
|
|
26
|
+
eventNodeRef?.current?.dispatchEvent(
|
|
27
|
+
new MobilityEvent<string>("mwc:permalink", window.location.href),
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const updatePermalinkDebounced = debounce(updatePermalink, 1000);
|
|
32
|
+
|
|
12
33
|
/**
|
|
13
34
|
* This hook only update parameters in the url, it does not apply the url parameters.
|
|
14
35
|
*/
|
|
15
|
-
|
|
16
36
|
const useUpdatePermalink = (
|
|
17
37
|
map: Map,
|
|
18
38
|
permalink: boolean,
|
|
@@ -53,23 +73,4 @@ const useUpdatePermalink = (
|
|
|
53
73
|
return null;
|
|
54
74
|
};
|
|
55
75
|
|
|
56
|
-
const updatePermalink = (
|
|
57
|
-
map: Map,
|
|
58
|
-
eventNodeRef: MutableRef<HTMLDivElement>,
|
|
59
|
-
) => {
|
|
60
|
-
// No update when exporting
|
|
61
|
-
if (map.get(LAYER_PROP_IS_EXPORTING)) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const currentUrlParams = new URLSearchParams(window.location.search);
|
|
65
|
-
const urlParams = getPermalinkParameters(map, currentUrlParams);
|
|
66
|
-
urlParams.set("permalink", "true");
|
|
67
|
-
window.history.replaceState(null, null, `?${urlParams.toString()}`);
|
|
68
|
-
eventNodeRef?.current?.dispatchEvent(
|
|
69
|
-
new MobilityEvent<string>("mwc:permalink", window.location.href),
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const updatePermalinkDebounced = debounce(updatePermalink, 1000);
|
|
74
|
-
|
|
75
76
|
export default useUpdatePermalink;
|
|
@@ -24,12 +24,12 @@ const useZoom = () => {
|
|
|
24
24
|
let zoomListener = view.on("change:resolution", onZoomChange);
|
|
25
25
|
|
|
26
26
|
const key = map.on("change:view", () => {
|
|
27
|
-
const
|
|
27
|
+
const vieww = map.getView();
|
|
28
28
|
unByKey(zoomListener);
|
|
29
|
-
if (
|
|
30
|
-
setZoom(
|
|
29
|
+
if (vieww) {
|
|
30
|
+
setZoom(vieww.getZoom());
|
|
31
31
|
}
|
|
32
|
-
zoomListener =
|
|
32
|
+
zoomListener = vieww.on("change:resolution", onZoomChange);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
return () => {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createCanvas } from "mobility-toolbox-js/ol";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// @ts-expect-error - svg loaded as dataurl
|
|
4
|
+
import noRealtime from "../icons/NoRealtime/norealtime.svg";
|
|
5
|
+
|
|
6
|
+
import type {
|
|
3
7
|
AnyCanvasContext,
|
|
4
8
|
RealtimeStyleFunction,
|
|
5
9
|
RealtimeStyleOptions,
|
|
@@ -7,9 +11,6 @@ import {
|
|
|
7
11
|
StyleCache,
|
|
8
12
|
ViewState,
|
|
9
13
|
} from "mobility-toolbox-js/types";
|
|
10
|
-
|
|
11
|
-
// @ts-expect-error - svg loaded as dataurl
|
|
12
|
-
import noRealtime from "../icons/NoRealtime/norealtime.svg";
|
|
13
14
|
const cacheNoRealtime: StyleCache = {};
|
|
14
15
|
|
|
15
16
|
const image = new Image(42, 42); // Using optional size for image
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { FeatureCollection, Point } from "geojson";
|
|
2
1
|
import { gql, GraphQLClient } from "graphql-request";
|
|
3
|
-
import { Extent } from "ol/extent";
|
|
4
2
|
|
|
5
3
|
import { RVF_EXTENT_4326 } from "./constants";
|
|
6
4
|
|
|
5
|
+
import type { FeatureCollection, Point } from "geojson";
|
|
6
|
+
import type { Extent } from "ol/extent";
|
|
7
|
+
|
|
7
8
|
const GQL_URL = "https://api.mobidata-bw.de/sharing/graphql";
|
|
8
9
|
|
|
9
10
|
export interface SharingStation {
|
|
@@ -4,7 +4,7 @@ export const getSharingStyleLayers = (
|
|
|
4
4
|
) => {
|
|
5
5
|
return [
|
|
6
6
|
{
|
|
7
|
-
id: sourceId
|
|
7
|
+
id: `${sourceId}_circle`,
|
|
8
8
|
maxZoom: 16,
|
|
9
9
|
minzoom: 14,
|
|
10
10
|
paint: {
|
|
@@ -17,7 +17,7 @@ export const getSharingStyleLayers = (
|
|
|
17
17
|
type: "circle",
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
|
-
id: sourceId
|
|
20
|
+
id: `${sourceId}_image_text`,
|
|
21
21
|
layout: {
|
|
22
22
|
"icon-image": image,
|
|
23
23
|
"icon-size": 1,
|
|
@@ -51,7 +51,7 @@ export const getSharingStyleLayers = (
|
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
filter: ["==", "is_free_float", false],
|
|
54
|
-
id: sourceId
|
|
54
|
+
id: `${sourceId}_availability`,
|
|
55
55
|
layout: {
|
|
56
56
|
"icon-allow-overlap": true,
|
|
57
57
|
"icon-anchor": "center",
|
|
@@ -86,7 +86,7 @@ export const getSharingStyleLayers = (
|
|
|
86
86
|
// freefloat style
|
|
87
87
|
{
|
|
88
88
|
filter: ["==", "is_free_float", true],
|
|
89
|
-
id: sourceId
|
|
89
|
+
id: `${sourceId}_availability_freefloat`,
|
|
90
90
|
layout: {
|
|
91
91
|
"icon-allow-overlap": true,
|
|
92
92
|
"icon-anchor": "center",
|
|
@@ -122,7 +122,7 @@ export const getSharingClusterStyleLayers = (
|
|
|
122
122
|
) => {
|
|
123
123
|
return [
|
|
124
124
|
{
|
|
125
|
-
id: sourceId
|
|
125
|
+
id: `${sourceId}_image_text`,
|
|
126
126
|
layout: {
|
|
127
127
|
"icon-allow-overlap": true,
|
|
128
128
|
"icon-ignore-placement": true,
|
|
@@ -161,7 +161,7 @@ export const getSharingClusterStyleLayers = (
|
|
|
161
161
|
// cluster style
|
|
162
162
|
{
|
|
163
163
|
filter: ["has", "point_count"],
|
|
164
|
-
id: sourceId
|
|
164
|
+
id: `${sourceId}_availability2`,
|
|
165
165
|
layout: {
|
|
166
166
|
"icon-allow-overlap": true,
|
|
167
167
|
"icon-anchor": "center",
|
|
@@ -191,7 +191,7 @@ export const getSharingClusterStyleLayers = (
|
|
|
191
191
|
// non cluster style
|
|
192
192
|
{
|
|
193
193
|
filter: ["!", ["has", "point_count"]],
|
|
194
|
-
id: sourceId
|
|
194
|
+
id: `${sourceId}_availability3`,
|
|
195
195
|
layout: {
|
|
196
196
|
"icon-allow-overlap": true,
|
|
197
197
|
"icon-anchor": "center",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Feature, FeatureCollection, Point } from "geojson";
|
|
2
|
-
import { Extent } from "ol/extent";
|
|
3
|
-
|
|
4
1
|
import { PROVIDER_BY_FEED_ID, RVF_EXTENT_4326 } from "./constants";
|
|
5
2
|
|
|
3
|
+
import type { Feature, FeatureCollection, Point } from "geojson";
|
|
4
|
+
import type { Extent } from "ol/extent";
|
|
5
|
+
|
|
6
6
|
// This info are added on each request
|
|
7
7
|
export interface SharingDynamicInfo {
|
|
8
8
|
display_num_vehicles_available: boolean; // added dynamically, used to avoid display this info when printing
|
|
@@ -51,18 +51,12 @@ export const getSharingWFSUrl = (
|
|
|
51
51
|
extent4326: Extent = RVF_EXTENT_4326,
|
|
52
52
|
) => {
|
|
53
53
|
return (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
wfsTypeName +
|
|
61
|
-
"&" +
|
|
62
|
-
"outputFormat=application/json&" +
|
|
63
|
-
"bbox=" +
|
|
64
|
-
extent4326.toString() +
|
|
65
|
-
",EPSG:4326"
|
|
54
|
+
`https://api.mobidata-bw.de/geoserver/MobiData-BW/${wfsTypeName}/ows` +
|
|
55
|
+
`?service=WFS&` +
|
|
56
|
+
`version=1.1.0&request=GetFeature&typename=` +
|
|
57
|
+
`MobiData-BW:${wfsTypeName}&` +
|
|
58
|
+
`outputFormat=application/json&` +
|
|
59
|
+
`bbox=${extent4326.toString()},EPSG:4326`
|
|
66
60
|
);
|
|
67
61
|
};
|
|
68
62
|
|
package/tailwind.config.mjs
CHANGED