@geops/rvf-mobility-web-component 0.1.27 → 0.1.29
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/.vscode/settings.json +2 -0
- package/CHANGELOG.md +17 -0
- package/docutils.js +1 -1
- package/index.html +1 -1
- package/index.js +119 -107
- package/package.json +1 -1
- package/src/NotificationLayer/NotificationLayer.tsx +2 -2
- package/src/RouteIcon/RouteIcon.tsx +21 -12
- package/src/RvfExportMenu/RvfExportMenu.tsx +2 -0
- package/src/RvfFeatureDetails/RVFSellingPointDetails/RVFSellingPointDetails.tsx +47 -0
- package/src/RvfFeatureDetails/RVFSellingPointDetails/index.js +1 -0
- package/src/RvfFeatureDetails/RvfFeatureDetails.tsx +4 -1
- package/src/RvfLineNetworkPlanLayer/RvfLineNetworkPlanLayer.tsx +4 -1
- package/src/RvfMobilityMap/RvfMobilityMap.tsx +55 -12
- package/src/RvfSelectedFeatureHighlightLayer/RvfSelectedFeatureHighlightLayer.tsx +58 -32
- package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +364 -123
- package/src/StationsLayer/StationsLayer.tsx +1 -1
- package/src/icons/NoRealtime/NoRealtime.tsx +44 -0
- package/src/icons/NoRealtime/index.tsx +1 -0
- package/src/icons/NoRealtime/norealtime.svg +6 -0
- package/src/utils/constants.ts +22 -1
- package/src/utils/exportPdf.ts +3 -3
- package/src/utils/fullTrajectoryStyle.ts +0 -1
- package/src/utils/getMainColorForVehicle.test.ts +21 -23
- package/src/utils/getRadius.ts +25 -24
- package/src/utils/hooks/useUpdatePermalink.tsx +5 -0
- package/src/utils/realtimeRVFStyle.ts +70 -8
- package/src/utils/sharingStylesUtils.ts +5 -5
- package/src/utils/sharingWFSUtils.ts +46 -16
- package/src/RvfSharedMobilityLayerGroup2/RvfSharedMobilityLayerGroup2.tsx +0 -740
- package/src/RvfSharedMobilityLayerGroup2/index.tsx +0 -1
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import getMainColorForVehicle from "./getMainColorForVehicle";
|
|
1
|
+
// import getMainColorForVehicle from "./getMainColorForVehicle";
|
|
2
2
|
|
|
3
|
-
describe("getTextForVehicle", () => {
|
|
3
|
+
describe.skip("getTextForVehicle", () => {
|
|
4
4
|
it("returns default rail color", () => {
|
|
5
|
-
expect(getMainColorForVehicle()).toBe("#ff8080");
|
|
6
|
-
expect(getMainColorForVehicle(null)).toBe("#ff8080");
|
|
7
|
-
expect(getMainColorForVehicle({ train_type: 178 })).toBe("#ff8080");
|
|
8
|
-
expect(getMainColorForVehicle({ vehicleType: 178 })).toBe("#ff8080");
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("returns color", () => {
|
|
12
|
-
expect(getMainColorForVehicle({ color: "foo" })).toBe("#foo");
|
|
13
|
-
expect(getMainColorForVehicle({ line: { color: "#foo" } })).toBe("#foo");
|
|
14
|
-
expect(
|
|
15
|
-
getMainColorForVehicle({ properties: { line: { color: "foo" } } }),
|
|
16
|
-
).toBe("#foo");
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("returns type color", () => {
|
|
20
|
-
expect(getMainColorForVehicle({ type: "tram" })).toBe("#ffb400");
|
|
21
|
-
expect(getMainColorForVehicle({ properties: { type: "tram" } })).toBe(
|
|
22
|
-
"#ffb400",
|
|
23
|
-
);
|
|
24
|
-
expect(getMainColorForVehicle({ vehicleType: 0 })).toBe("#ffb400");
|
|
25
|
-
expect(getMainColorForVehicle({ train_type: 0 })).toBe("#ffb400");
|
|
5
|
+
// expect(getMainColorForVehicle()).toBe("#ff8080");
|
|
6
|
+
// expect(getMainColorForVehicle(null)).toBe("#ff8080");
|
|
7
|
+
// expect(getMainColorForVehicle({ train_type: 178 })).toBe("#ff8080");
|
|
8
|
+
// expect(getMainColorForVehicle({ vehicleType: 178 })).toBe("#ff8080");
|
|
26
9
|
});
|
|
10
|
+
// it("returns color", () => {
|
|
11
|
+
// expect(getMainColorForVehicle({ color: "foo" })).toBe("#foo");
|
|
12
|
+
// expect(getMainColorForVehicle({ line: { color: "#foo" } })).toBe("#foo");
|
|
13
|
+
// expect(
|
|
14
|
+
// getMainColorForVehicle({ properties: { line: { color: "foo" } } }),
|
|
15
|
+
// ).toBe("#foo");
|
|
16
|
+
// });
|
|
17
|
+
// it("returns type color", () => {
|
|
18
|
+
// expect(getMainColorForVehicle({ type: "tram" })).toBe("#ffb400");
|
|
19
|
+
// expect(getMainColorForVehicle({ properties: { type: "tram" } })).toBe(
|
|
20
|
+
// "#ffb400",
|
|
21
|
+
// );
|
|
22
|
+
// expect(getMainColorForVehicle({ vehicleType: 0 })).toBe("#ffb400");
|
|
23
|
+
// expect(getMainColorForVehicle({ train_type: 0 })).toBe("#ffb400");
|
|
24
|
+
// // });
|
|
27
25
|
});
|
package/src/utils/getRadius.ts
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { realtimeConfig } from "mobility-toolbox-js/ol";
|
|
2
2
|
|
|
3
3
|
// mobility-portal config
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
const trackerRadiusMapping = {
|
|
5
|
+
0: [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 6, 7, 7, 7],
|
|
6
|
+
1: [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 6, 7, 7, 7],
|
|
7
|
+
2: [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 3, 7, 12, 12, 15],
|
|
8
|
+
3: [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 4, 6, 6, 6],
|
|
9
|
+
4: [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 3, 7, 12, 12, 15],
|
|
10
|
+
5: [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 4, 7, 7, 7],
|
|
11
|
+
6: [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 4, 7, 7, 7],
|
|
12
|
+
7: [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 4, 7, 7, 7],
|
|
13
|
+
8: [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 4, 6, 6, 6],
|
|
14
|
+
9: [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 3, 7, 12, 12, 15],
|
|
15
|
+
};
|
|
16
16
|
|
|
17
|
-
const radiusMapping: number[][] =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
]
|
|
17
|
+
const radiusMapping: number[][] = trackerRadiusMapping;
|
|
18
|
+
// [
|
|
19
|
+
// [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
20
|
+
// [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
21
|
+
// [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 7, 7, 7, 12, 12, 15], // [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15],
|
|
22
|
+
// [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
23
|
+
// [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
24
|
+
// [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
25
|
+
// [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
26
|
+
// [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
27
|
+
// [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
28
|
+
// [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 7, 7, 7, 12, 12, 15],
|
|
29
|
+
// ];
|
|
29
30
|
|
|
30
31
|
export const getRadius = (type = 0, zoom = 0, cancelled = false) => {
|
|
31
32
|
try {
|
|
@@ -4,6 +4,7 @@ import { EventsKey } from "ol/events";
|
|
|
4
4
|
import { unByKey } from "ol/Observable";
|
|
5
5
|
import { useEffect } from "preact/hooks";
|
|
6
6
|
|
|
7
|
+
import { LAYER_PROP_IS_EXPORTING } from "../constants";
|
|
7
8
|
import getLayersAsFlatArray from "../getLayersAsFlatArray";
|
|
8
9
|
import getPermalinkParameters from "../getPermalinkParameters";
|
|
9
10
|
|
|
@@ -48,6 +49,10 @@ const useUpdatePermalink = (map: Map, permalink: boolean) => {
|
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
const updatePermalink = (map: Map) => {
|
|
52
|
+
// No update when exporting
|
|
53
|
+
if (map.get(LAYER_PROP_IS_EXPORTING)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
51
56
|
const currentUrlParams = new URLSearchParams(window.location.search);
|
|
52
57
|
const urlParams = getPermalinkParameters(map, currentUrlParams);
|
|
53
58
|
urlParams.set("permalink", "true");
|
|
@@ -8,6 +8,43 @@ import {
|
|
|
8
8
|
ViewState,
|
|
9
9
|
} from "mobility-toolbox-js/types";
|
|
10
10
|
|
|
11
|
+
// @ts-expect-error - svg loaded as dataurl
|
|
12
|
+
import noRealtime from "../icons/NoRealtime/norealtime.svg";
|
|
13
|
+
const cacheNoRealtime: StyleCache = {};
|
|
14
|
+
|
|
15
|
+
const image = new Image(42, 42); // Using optional size for image
|
|
16
|
+
// image.onload = () => {
|
|
17
|
+
// [1, 2, 3].forEach((pixelRatio) => {
|
|
18
|
+
// const canvas = createCanvas(42, 42);
|
|
19
|
+
// const ctx = canvas.getContext("2d") as CanvasRenderingContext2D;
|
|
20
|
+
// if (!ctx) {
|
|
21
|
+
// return null;
|
|
22
|
+
// }
|
|
23
|
+
// ctx.drawImage(image, 0, 0, 16 * pixelRatio, 16 * pixelRatio);
|
|
24
|
+
// cacheNoRealtime[`${pixelRatio}`] = canvas;
|
|
25
|
+
// });
|
|
26
|
+
// };
|
|
27
|
+
// Draw when image has loaded
|
|
28
|
+
image.src = noRealtime;
|
|
29
|
+
|
|
30
|
+
export const getNoRealtimeCanvas = (radius, pixelRatio) => {
|
|
31
|
+
let size = 16;
|
|
32
|
+
if (radius > size) {
|
|
33
|
+
size = 22;
|
|
34
|
+
}
|
|
35
|
+
const key = `${size},${pixelRatio}`;
|
|
36
|
+
if (!cacheNoRealtime[key]) {
|
|
37
|
+
const canvas = createCanvas(size * pixelRatio, size * pixelRatio);
|
|
38
|
+
const ctx = canvas.getContext("2d") as CanvasRenderingContext2D;
|
|
39
|
+
if (!ctx) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
ctx.drawImage(image, 0, 0, size * pixelRatio, size * pixelRatio);
|
|
43
|
+
cacheNoRealtime[key] = canvas;
|
|
44
|
+
}
|
|
45
|
+
return cacheNoRealtime[key];
|
|
46
|
+
};
|
|
47
|
+
|
|
11
48
|
const cacheDelayBg: StyleCache = {};
|
|
12
49
|
|
|
13
50
|
/**
|
|
@@ -241,6 +278,7 @@ const realtimeRVFStyle: RealtimeStyleFunction = (
|
|
|
241
278
|
let { type } = trajectory.properties;
|
|
242
279
|
const {
|
|
243
280
|
delay,
|
|
281
|
+
has_realtime_journey: hasRealtimeJourney,
|
|
244
282
|
line,
|
|
245
283
|
operator_provides_realtime_journey: operatorProvidesRealtime,
|
|
246
284
|
state,
|
|
@@ -290,7 +328,7 @@ const realtimeRVFStyle: RealtimeStyleFunction = (
|
|
|
290
328
|
const isDisplayText = radius > getMaxRadiusForText() * pixelRatio;
|
|
291
329
|
|
|
292
330
|
// Optimize the cache key, very important in high zoom level
|
|
293
|
-
let key = `${radius}${hover || selected}`;
|
|
331
|
+
let key = `${radius}${hover || selected}${hasRealtimeJourney}`;
|
|
294
332
|
|
|
295
333
|
if (useDelayStyle) {
|
|
296
334
|
key += `${operatorProvidesRealtime}${delay}${cancelled}`;
|
|
@@ -354,6 +392,8 @@ const realtimeRVFStyle: RealtimeStyleFunction = (
|
|
|
354
392
|
}
|
|
355
393
|
}
|
|
356
394
|
|
|
395
|
+
let realtimeIconCanvas = null;
|
|
396
|
+
|
|
357
397
|
// Draw colored circle with black border
|
|
358
398
|
let circleFillColor;
|
|
359
399
|
if (useDelayStyle) {
|
|
@@ -370,6 +410,13 @@ const realtimeRVFStyle: RealtimeStyleFunction = (
|
|
|
370
410
|
delay === null &&
|
|
371
411
|
operatorProvidesRealtime === "yes";
|
|
372
412
|
|
|
413
|
+
const hasNoRealtimeIcon =
|
|
414
|
+
!!hasStroke && isDisplayText && !hasRealtimeJourney && !cancelled;
|
|
415
|
+
|
|
416
|
+
if (hasNoRealtimeIcon) {
|
|
417
|
+
realtimeIconCanvas = getNoRealtimeCanvas(radius, pixelRatio);
|
|
418
|
+
}
|
|
419
|
+
|
|
373
420
|
const circle = getCircleCanvas(
|
|
374
421
|
origin,
|
|
375
422
|
radius,
|
|
@@ -380,8 +427,14 @@ const realtimeRVFStyle: RealtimeStyleFunction = (
|
|
|
380
427
|
);
|
|
381
428
|
|
|
382
429
|
// Create the canvas
|
|
383
|
-
const
|
|
384
|
-
|
|
430
|
+
const extraWidth =
|
|
431
|
+
delayText?.width ||
|
|
432
|
+
(hasNoRealtimeIcon && realtimeIconCanvas.width / 2) ||
|
|
433
|
+
0;
|
|
434
|
+
const extraHeight =
|
|
435
|
+
(hasNoRealtimeIcon && realtimeIconCanvas.height / 2) || 0;
|
|
436
|
+
const width = size + extraWidth * 2;
|
|
437
|
+
const height = size + extraHeight * 2;
|
|
385
438
|
const canvas = createCanvas(width, height);
|
|
386
439
|
if (canvas) {
|
|
387
440
|
const ctx = canvas.getContext("2d") as CanvasRenderingContext2D;
|
|
@@ -390,14 +443,15 @@ const realtimeRVFStyle: RealtimeStyleFunction = (
|
|
|
390
443
|
}
|
|
391
444
|
|
|
392
445
|
// The renderTrajectories will center the image on the vehicle positions.
|
|
393
|
-
const originX =
|
|
446
|
+
const originX = extraWidth;
|
|
447
|
+
const originY = extraHeight;
|
|
394
448
|
|
|
395
449
|
if (delayBg) {
|
|
396
|
-
ctx.drawImage(delayBg, originX,
|
|
450
|
+
ctx.drawImage(delayBg, originX, originY);
|
|
397
451
|
}
|
|
398
452
|
|
|
399
453
|
if (circle) {
|
|
400
|
-
ctx.drawImage(circle, originX,
|
|
454
|
+
ctx.drawImage(circle, originX, originY);
|
|
401
455
|
}
|
|
402
456
|
|
|
403
457
|
// Draw text in the circle
|
|
@@ -432,14 +486,22 @@ const realtimeRVFStyle: RealtimeStyleFunction = (
|
|
|
432
486
|
}
|
|
433
487
|
|
|
434
488
|
if (circleText) {
|
|
435
|
-
ctx.drawImage(circleText, originX,
|
|
489
|
+
ctx.drawImage(circleText, originX, originY);
|
|
436
490
|
}
|
|
437
491
|
|
|
438
492
|
if (delayText) {
|
|
439
493
|
ctx.drawImage(
|
|
440
494
|
delayText,
|
|
441
495
|
originX + Math.ceil(origin + radiusDelay) + margin,
|
|
442
|
-
Math.ceil(origin - fontSize),
|
|
496
|
+
originY + Math.ceil(origin - fontSize),
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if (hasNoRealtimeIcon) {
|
|
501
|
+
ctx.drawImage(
|
|
502
|
+
realtimeIconCanvas,
|
|
503
|
+
originX - realtimeIconCanvas.width / 4,
|
|
504
|
+
originY - realtimeIconCanvas.height / 4,
|
|
443
505
|
);
|
|
444
506
|
}
|
|
445
507
|
|
|
@@ -6,7 +6,7 @@ export const getSharingStyleLayers = (
|
|
|
6
6
|
{
|
|
7
7
|
id: sourceId + "_circle",
|
|
8
8
|
maxZoom: 16,
|
|
9
|
-
minzoom:
|
|
9
|
+
minzoom: 14,
|
|
10
10
|
paint: {
|
|
11
11
|
"circle-color": "#00973b",
|
|
12
12
|
"circle-radius": 4,
|
|
@@ -39,7 +39,7 @@ export const getSharingStyleLayers = (
|
|
|
39
39
|
"text-size": 12,
|
|
40
40
|
visibility: "visible",
|
|
41
41
|
},
|
|
42
|
-
minzoom:
|
|
42
|
+
minzoom: 16,
|
|
43
43
|
paint: {
|
|
44
44
|
"text-color": "rgba(6, 76, 10, 1)",
|
|
45
45
|
"text-halo-blur": 0.5,
|
|
@@ -148,7 +148,7 @@ export const getSharingClusterStyleLayers = (
|
|
|
148
148
|
"text-size": 12,
|
|
149
149
|
visibility: "visible",
|
|
150
150
|
},
|
|
151
|
-
minzoom:
|
|
151
|
+
minzoom: 17,
|
|
152
152
|
paint: {
|
|
153
153
|
"text-color": "rgba(6, 76, 10, 1)",
|
|
154
154
|
"text-halo-blur": 0.5,
|
|
@@ -181,7 +181,7 @@ export const getSharingClusterStyleLayers = (
|
|
|
181
181
|
"text-size": 10,
|
|
182
182
|
visibility: "visible",
|
|
183
183
|
},
|
|
184
|
-
minzoom:
|
|
184
|
+
minzoom: 17,
|
|
185
185
|
paint: {
|
|
186
186
|
"text-color": "rgba(6, 76, 10, 1)",
|
|
187
187
|
},
|
|
@@ -211,7 +211,7 @@ export const getSharingClusterStyleLayers = (
|
|
|
211
211
|
"text-size": 10,
|
|
212
212
|
visibility: "visible",
|
|
213
213
|
},
|
|
214
|
-
minzoom:
|
|
214
|
+
minzoom: 17,
|
|
215
215
|
paint: {
|
|
216
216
|
"text-color": "rgba(6, 76, 10, 1)",
|
|
217
217
|
},
|
|
@@ -3,46 +3,48 @@ import { Extent } from "ol/extent";
|
|
|
3
3
|
|
|
4
4
|
import { PROVIDER_BY_FEED_ID, RVF_EXTENT_4326 } from "./constants";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// This info are added on each request
|
|
7
|
+
export interface SharingDynamicInfo {
|
|
8
|
+
display_num_vehicles_available: boolean; // added dynamically, used to avoid display this info when printing
|
|
9
|
+
id: string; // added dynamically station_id or vehicle_id
|
|
10
|
+
is_free_float: boolean; // added dynamically
|
|
11
|
+
mot: string; // added dynamically for select style
|
|
12
|
+
provider_name: string; // added dynamically for select style
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type SharingStationWFS = {
|
|
7
16
|
capacity: string;
|
|
8
17
|
feed_id: string;
|
|
9
|
-
id: string; // added dynamically same as station_id
|
|
10
|
-
is_free_float: false; // added dynamically
|
|
11
18
|
last_reported: string;
|
|
12
19
|
name: string;
|
|
13
20
|
num_vehicles_available: number;
|
|
14
|
-
provider_name: string; // added dynamically
|
|
15
21
|
rental_uris_android: string;
|
|
16
22
|
rental_uris_ios: string;
|
|
17
23
|
rental_uris_web: string;
|
|
18
24
|
station_id: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
25
|
+
} & SharingDynamicInfo;
|
|
26
|
+
|
|
27
|
+
export type SharingVehicleWFS = {
|
|
21
28
|
current_fuel_percent: number;
|
|
22
29
|
current_range_meters: number;
|
|
23
30
|
feed_id: string;
|
|
24
31
|
form_factor: string;
|
|
25
|
-
id: string; // added dynamically station_id or vehicle_id
|
|
26
|
-
is_free_float: true; // added dynamically
|
|
27
32
|
last_reported: string;
|
|
28
33
|
max_range_meters: number;
|
|
29
34
|
name: null;
|
|
30
35
|
propulsion_type: string;
|
|
31
|
-
provider_name: string; // added dynamically
|
|
32
36
|
rental_uris_android: null;
|
|
33
37
|
rental_uris_ios: null;
|
|
34
38
|
rental_uris_web: null;
|
|
35
39
|
station_id: string;
|
|
36
40
|
vehicle_id: string;
|
|
37
|
-
}
|
|
41
|
+
} & SharingDynamicInfo;
|
|
38
42
|
|
|
39
|
-
export const
|
|
43
|
+
export const getSharingWFSUrl = (
|
|
40
44
|
wfsTypeName: string,
|
|
41
|
-
abortController: AbortController,
|
|
42
45
|
extent4326: Extent = RVF_EXTENT_4326,
|
|
43
46
|
) => {
|
|
44
|
-
|
|
45
|
-
const url =
|
|
47
|
+
return (
|
|
46
48
|
"https://api.mobidata-bw.de/geoserver/MobiData-BW/" +
|
|
47
49
|
wfsTypeName +
|
|
48
50
|
"/ows" +
|
|
@@ -54,7 +56,17 @@ export const fetchSharingWFS = async (
|
|
|
54
56
|
"outputFormat=application/json&" +
|
|
55
57
|
"bbox=" +
|
|
56
58
|
extent4326.toString() +
|
|
57
|
-
",EPSG:4326"
|
|
59
|
+
",EPSG:4326"
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const fetchSharingWFS = async (
|
|
64
|
+
wfsTypeName: string,
|
|
65
|
+
abortController: AbortController,
|
|
66
|
+
extent4326: Extent = RVF_EXTENT_4326,
|
|
67
|
+
) => {
|
|
68
|
+
// use WFS
|
|
69
|
+
const url = getSharingWFSUrl(wfsTypeName, extent4326);
|
|
58
70
|
const response = await fetch(url, { signal: abortController.signal });
|
|
59
71
|
const data = await response.json();
|
|
60
72
|
|
|
@@ -62,9 +74,27 @@ export const fetchSharingWFS = async (
|
|
|
62
74
|
(feature: Feature<Point, SharingStationWFS | SharingVehicleWFS>) => {
|
|
63
75
|
const vehicleId = (feature.properties as SharingVehicleWFS).vehicle_id;
|
|
64
76
|
feature.properties.id = vehicleId || feature.properties.station_id;
|
|
65
|
-
feature.properties.is_free_float = !!vehicleId;
|
|
66
77
|
feature.properties.provider_name =
|
|
67
78
|
PROVIDER_BY_FEED_ID[feature.properties.feed_id];
|
|
79
|
+
|
|
80
|
+
// for select style we always set mot and num_vehicles_available
|
|
81
|
+
const formFactor = (feature.properties as SharingVehicleWFS).form_factor;
|
|
82
|
+
let numVehiclesAvailable = (feature.properties as SharingStationWFS)
|
|
83
|
+
.num_vehicles_available;
|
|
84
|
+
let mot = formFactor || wfsTypeName.split("_").pop();
|
|
85
|
+
if (mot === "bicycle") {
|
|
86
|
+
mot = "bike";
|
|
87
|
+
} else if (mot === "cargo_bicycle") {
|
|
88
|
+
mot = "cargo_bike";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if ((feature.properties as SharingVehicleWFS).vehicle_id) {
|
|
92
|
+
numVehiclesAvailable = 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
feature.properties.mot = mot;
|
|
96
|
+
feature.properties.num_vehicles_available = numVehiclesAvailable;
|
|
97
|
+
feature.properties.display_num_vehicles_available = true;
|
|
68
98
|
},
|
|
69
99
|
);
|
|
70
100
|
return data as FeatureCollection<
|