mobility-toolbox-js 3.0.0-beta.2 → 3.0.0-beta.20
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/api/HttpAPI.d.ts +20 -0
- package/api/HttpAPI.js +0 -11
- package/api/RealtimeAPI.d.ts +404 -0
- package/api/RealtimeAPI.js +344 -276
- package/api/RoutingAPI.d.ts +47 -0
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +44 -0
- package/api/StopsAPI.js +16 -10
- package/api/WebSocketAPI.d.ts +147 -0
- package/api/WebSocketAPI.js +164 -164
- package/api/index.d.ts +3 -0
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +76 -0
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +53 -0
- package/common/controls/StopFinderControlCommon.js +31 -31
- package/common/index.d.ts +2 -0
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +267 -0
- package/common/mixins/RealtimeLayerMixin.js +401 -393
- package/common/styles/index.d.ts +4 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/typedefs.d.ts +219 -0
- package/common/typedefs.js +7 -1
- package/common/utils/compareDepartures.d.ts +10 -0
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/constants.d.ts +5 -0
- package/common/utils/createCanvas.d.ts +10 -0
- package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
- package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
- package/common/utils/createRealtimeFilters.d.ts +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts +12 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.js +5 -1
- package/common/utils/getMapGlCopyrights.d.ts +17 -0
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getUrlWithParams.d.ts +8 -0
- package/common/utils/getVehiclePosition.d.ts +17 -0
- package/common/utils/getVehiclePosition.js +9 -3
- package/common/utils/index.d.ts +16 -0
- package/common/utils/realtimeConfig.d.ts +64 -0
- package/common/utils/removeDuplicate.d.ts +9 -0
- package/common/utils/renderTrajectories.d.ts +16 -0
- package/common/utils/renderTrajectories.js +6 -6
- package/common/utils/sortAndFilterDepartures.d.ts +15 -0
- package/common/utils/sortAndFilterDepartures.js +1 -1
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.js +5 -1
- package/common/utils/timeUtils.d.ts +23 -0
- package/common/utils/toMercatorExtent.d.ts +5 -0
- package/iife.d.ts +2 -0
- package/index.d.ts +9 -0
- package/maplibre/controls/CopyrightControl.d.ts +35 -0
- package/maplibre/controls/index.d.ts +1 -0
- package/maplibre/index.d.ts +5 -0
- package/maplibre/layers/Layer.d.ts +28 -0
- package/maplibre/layers/Layer.js +1 -1
- package/maplibre/layers/RealtimeLayer.d.ts +181 -0
- package/maplibre/layers/RealtimeLayer.js +29 -5
- package/maplibre/layers/index.d.ts +2 -0
- package/maplibre/utils/getMercatorResolution.d.ts +7 -0
- package/maplibre/utils/getSourceCoordinates.d.ts +7 -0
- package/maplibre/utils/getSourceCoordinates.js +5 -5
- package/maplibre/utils/index.d.ts +2 -0
- package/mbt.js +22160 -14512
- package/mbt.js.map +4 -4
- package/mbt.min.js +61 -58
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.js +18 -8
- package/ol/controls/RoutingControl.d.ts +202 -0
- package/ol/controls/RoutingControl.js +220 -219
- package/ol/controls/StopFinderControl.d.ts +37 -0
- package/ol/controls/StopFinderControl.js +4 -1
- package/ol/controls/index.d.ts +3 -0
- package/ol/index.d.ts +7 -0
- package/ol/index.js +1 -0
- package/ol/layers/Layer.d.ts +101 -0
- package/ol/layers/Layer.js +17 -0
- package/ol/layers/MaplibreLayer.d.ts +160 -0
- package/ol/layers/MaplibreLayer.js +88 -24
- package/ol/layers/MaplibreStyleLayer.d.ts +242 -0
- package/ol/layers/MaplibreStyleLayer.js +291 -265
- package/ol/layers/RealtimeLayer.d.ts +283 -0
- package/ol/layers/RealtimeLayer.js +143 -128
- package/ol/layers/VectorLayer.d.ts +18 -0
- package/ol/layers/VectorLayer.js +31 -0
- package/ol/layers/index.d.ts +5 -0
- package/ol/layers/index.js +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +98 -0
- package/ol/mixins/MobilityLayerMixin.js +1 -4
- package/ol/mixins/PropertiesLayerMixin.d.ts +135 -0
- package/ol/mixins/PropertiesLayerMixin.js +108 -140
- package/ol/mixins/index.d.ts +1 -0
- package/ol/mixins/index.js +2 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -0
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
- package/ol/renderers/RealtimeLayerRenderer.js +58 -53
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/routingStyle.d.ts +4 -0
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
- package/ol/utils/getFeatureInfoAtCoordinate.js +12 -18
- package/ol/utils/index.d.ts +1 -0
- package/package.json +31 -31
- package/setupTests.d.ts +1 -0
- package/setupTests.js +3 -4
- package/types/common.d.ts +55 -48
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +91 -93
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/ol/layers/MapGlLayer.js +0 -142
|
@@ -19,11 +19,11 @@ const format = new GeoJSON();
|
|
|
19
19
|
*/
|
|
20
20
|
const getFeaturesFromWMS = (source, options, abortController) => {
|
|
21
21
|
let url;
|
|
22
|
-
const { coordinate,
|
|
22
|
+
const { coordinate, params, projection, resolution } = options;
|
|
23
23
|
if (source && resolution && projection) {
|
|
24
24
|
url = source.getFeatureInfoUrl(coordinate, resolution, projection, Object.assign({ info_format: 'application/json', query_layers: source.getParams().layers }, params));
|
|
25
25
|
}
|
|
26
|
-
// @ts-
|
|
26
|
+
// @ts-expect-error
|
|
27
27
|
return fetch(url, { signal: abortController.signal })
|
|
28
28
|
.then((resp) => resp.json())
|
|
29
29
|
.then((featureCollection) => format.readFeatures(featureCollection))
|
|
@@ -36,7 +36,7 @@ let abortControllers = {};
|
|
|
36
36
|
/**
|
|
37
37
|
* @private
|
|
38
38
|
*/
|
|
39
|
-
const getFeatureInfoAtCoordinate = (
|
|
39
|
+
const getFeatureInfoAtCoordinate = (coordinate_1, layers_1, ...args_1) => __awaiter(void 0, [coordinate_1, layers_1, ...args_1], void 0, function* (coordinate, layers, hitTolerance = 5) {
|
|
40
40
|
// Kill all previous requests
|
|
41
41
|
Object.values(abortControllers).forEach((abortController) => {
|
|
42
42
|
abortController === null || abortController === void 0 ? void 0 : abortController.abort();
|
|
@@ -47,48 +47,44 @@ const getFeatureInfoAtCoordinate = (coordinate, layers, hitTolerance = 5) => __a
|
|
|
47
47
|
var _a, _b, _c, _d;
|
|
48
48
|
const map = layer.getMapInternal();
|
|
49
49
|
const projection = (_b = (_a = map === null || map === void 0 ? void 0 : map.getView()) === null || _a === void 0 ? void 0 : _a.getProjection()) === null || _b === void 0 ? void 0 : _b.getCode();
|
|
50
|
-
const emptyResponse = { features: [], layer
|
|
50
|
+
const emptyResponse = { coordinate, features: [], layer };
|
|
51
51
|
if (!projection) {
|
|
52
52
|
return Promise.resolve(emptyResponse);
|
|
53
53
|
}
|
|
54
54
|
// For backward compatibility
|
|
55
|
-
// @ts-ignore
|
|
56
55
|
if (layer.getFeatureInfoAtCoordinate) {
|
|
57
|
-
return (
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
.getFeatureInfoAtCoordinate(coordinate));
|
|
56
|
+
return layer.getFeatureInfoAtCoordinate(coordinate);
|
|
60
57
|
}
|
|
61
58
|
// WMS sources
|
|
62
59
|
// Here we don't use instanceof, to be able to use this function if a layer comes from 2 different ol versions.
|
|
63
60
|
const source = layer === null || layer === void 0 ? void 0 : layer.getSource();
|
|
64
|
-
// @ts-ignore
|
|
65
61
|
if (source === null || source === void 0 ? void 0 : source.getFeatureInfoUrl) {
|
|
66
|
-
const id = getUid(
|
|
62
|
+
const id = getUid(layer);
|
|
67
63
|
// Abort and recreates one controller per layer
|
|
68
64
|
(_c = abortControllers[id]) === null || _c === void 0 ? void 0 : _c.abort();
|
|
69
65
|
abortControllers[id] = new AbortController();
|
|
70
66
|
const resolution = (_d = map === null || map === void 0 ? void 0 : map.getView()) === null || _d === void 0 ? void 0 : _d.getResolution();
|
|
71
67
|
return getFeaturesFromWMS(source, {
|
|
72
68
|
coordinate,
|
|
73
|
-
resolution,
|
|
74
|
-
projection,
|
|
75
69
|
params: {
|
|
76
70
|
info_format: 'application/json',
|
|
77
71
|
query_layers: source.getParams().layers,
|
|
78
72
|
},
|
|
73
|
+
projection,
|
|
74
|
+
resolution,
|
|
79
75
|
}, abortControllers[id])
|
|
80
76
|
.then((features) => {
|
|
81
77
|
return {
|
|
78
|
+
coordinate,
|
|
82
79
|
features,
|
|
83
80
|
layer,
|
|
84
|
-
coordinate,
|
|
85
81
|
};
|
|
86
82
|
})
|
|
87
83
|
.catch(() => {
|
|
88
84
|
return {
|
|
85
|
+
coordinate,
|
|
89
86
|
features: [],
|
|
90
87
|
layer,
|
|
91
|
-
coordinate,
|
|
92
88
|
};
|
|
93
89
|
});
|
|
94
90
|
}
|
|
@@ -99,15 +95,13 @@ const getFeatureInfoAtCoordinate = (coordinate, layers, hitTolerance = 5) => __a
|
|
|
99
95
|
return Promise.resolve(emptyResponse);
|
|
100
96
|
}
|
|
101
97
|
const features = map === null || map === void 0 ? void 0 : map.getFeaturesAtPixel(pixel, {
|
|
98
|
+
hitTolerance: layer.get('hitTolerance') || hitTolerance || 5,
|
|
102
99
|
layerFilter: (l) => l === layer,
|
|
103
|
-
hitTolerance:
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
layer.get('hitTolerance') || hitTolerance || 5,
|
|
106
100
|
});
|
|
107
101
|
return Promise.resolve({
|
|
102
|
+
coordinate,
|
|
108
103
|
features,
|
|
109
104
|
layer,
|
|
110
|
-
coordinate,
|
|
111
105
|
});
|
|
112
106
|
});
|
|
113
107
|
return Promise.all(promises);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as getFeatureInfoAtCoordinate } from "./getFeatureInfoAtCoordinate";
|
package/package.json
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
"name": "mobility-toolbox-js",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
|
|
5
|
-
"version": "3.0.0-beta.
|
|
5
|
+
"version": "3.0.0-beta.20",
|
|
6
6
|
"homepage": "https://mobility-toolbox-js.geops.io/",
|
|
7
|
-
"module": "index.js",
|
|
8
7
|
"exports": {
|
|
9
8
|
".": "./index.js",
|
|
10
9
|
"./api": "./api/index.js",
|
|
@@ -13,32 +12,34 @@
|
|
|
13
12
|
"./types": "./types/index.d.ts"
|
|
14
13
|
},
|
|
15
14
|
"dependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"@turf/
|
|
15
|
+
"@geoblocks/ol-maplibre-layer": "^1.0.0",
|
|
16
|
+
"@turf/helpers": "7.0.0",
|
|
17
|
+
"@turf/transform-rotate": "7.0.0",
|
|
18
18
|
"lodash.debounce": "4.0.8",
|
|
19
19
|
"lodash.throttle": "4.1.1",
|
|
20
|
-
"uuid": "
|
|
20
|
+
"uuid": "10.0.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"maplibre-gl": ">=1",
|
|
24
24
|
"ol": ">=7"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@babel/preset-env": "^7.24.
|
|
28
|
-
"@babel/preset-typescript": "^7.
|
|
29
|
-
"@commitlint/cli": "19.0
|
|
30
|
-
"@commitlint/config-conventional": "19.
|
|
27
|
+
"@babel/preset-env": "^7.24.7",
|
|
28
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
29
|
+
"@commitlint/cli": "19.3.0",
|
|
30
|
+
"@commitlint/config-conventional": "19.2.2",
|
|
31
|
+
"@geops/eslint-config-react": "^1.0.2",
|
|
31
32
|
"@types/geojson": "7946.0.14",
|
|
32
33
|
"@types/lodash.debounce": "4.0.9",
|
|
33
34
|
"@types/lodash.throttle": "4.1.9",
|
|
34
35
|
"@types/mapbox-gl": "3.1.0",
|
|
35
36
|
"@types/offscreencanvas": "2019.7.3",
|
|
36
37
|
"@types/topojson": "3.2.6",
|
|
37
|
-
"@types/uuid": "
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "7.1
|
|
39
|
-
"@typescript-eslint/parser": "7.1
|
|
40
|
-
"cypress": "13.
|
|
41
|
-
"esbuild": "0.
|
|
38
|
+
"@types/uuid": "10.0.0",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "7.14.1",
|
|
40
|
+
"@typescript-eslint/parser": "7.14.1",
|
|
41
|
+
"cypress": "13.12.0",
|
|
42
|
+
"esbuild": "0.21.5",
|
|
42
43
|
"esdoc": "1.1.0",
|
|
43
44
|
"esdoc-ecmascript-proposal-plugin": "1.0.0",
|
|
44
45
|
"esdoc-publish-html-plugin": "1.1.2",
|
|
@@ -46,13 +47,13 @@
|
|
|
46
47
|
"esdoc-typescript-plugin": "1.0.1",
|
|
47
48
|
"eslint": "8.57.0",
|
|
48
49
|
"eslint-config-airbnb": "19.0.4",
|
|
49
|
-
"eslint-config-airbnb-typescript": "
|
|
50
|
+
"eslint-config-airbnb-typescript": "18.0.0",
|
|
50
51
|
"eslint-config-prettier": "9.1.0",
|
|
51
|
-
"eslint-plugin-cypress": "
|
|
52
|
+
"eslint-plugin-cypress": "3.3.0",
|
|
52
53
|
"eslint-plugin-import": "2.29.1",
|
|
53
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
54
|
+
"eslint-plugin-jsx-a11y": "6.9.0",
|
|
54
55
|
"eslint-plugin-prettier": "5.1.3",
|
|
55
|
-
"eslint-plugin-react": "7.
|
|
56
|
+
"eslint-plugin-react": "7.34.3",
|
|
56
57
|
"fixpack": "4.0.0",
|
|
57
58
|
"husky": "9.0.11",
|
|
58
59
|
"is-ci": "3.0.1",
|
|
@@ -63,24 +64,23 @@
|
|
|
63
64
|
"jest-serializer-html": "7.1.0",
|
|
64
65
|
"jest-transformer-svg": "2.0.2",
|
|
65
66
|
"jest-websocket-mock": "2.5.0",
|
|
66
|
-
"lint-staged": "15.2.
|
|
67
|
-
"maplibre-gl": "4.0
|
|
67
|
+
"lint-staged": "15.2.7",
|
|
68
|
+
"maplibre-gl": "4.5.0",
|
|
68
69
|
"mock-socket": "9.3.1",
|
|
69
|
-
"next": "14.
|
|
70
|
+
"next": "14.2.4",
|
|
70
71
|
"next-transpile-modules": "10.0.1",
|
|
71
|
-
"ol": "9.
|
|
72
|
-
"openapi-typescript": "6.7.
|
|
73
|
-
"prettier": "3.2
|
|
72
|
+
"ol": "9.2.4",
|
|
73
|
+
"openapi-typescript": "6.7.5",
|
|
74
|
+
"prettier": "3.3.2",
|
|
74
75
|
"raw-loader": "4.0.2",
|
|
75
76
|
"sort-json": "2.0.1",
|
|
76
77
|
"standard-version": "9.5.0",
|
|
77
|
-
"start-server-and-test": "2.0.
|
|
78
|
-
"stylelint": "16.
|
|
78
|
+
"start-server-and-test": "2.0.4",
|
|
79
|
+
"stylelint": "16.6.1",
|
|
79
80
|
"stylelint-config-recommended-scss": "14.0.0",
|
|
80
|
-
"stylelint-config-standard": "36.0.
|
|
81
|
-
"stylelint-scss": "6.
|
|
82
|
-
"
|
|
83
|
-
"typescript": "5.3.3"
|
|
81
|
+
"stylelint-config-standard": "36.0.1",
|
|
82
|
+
"stylelint-scss": "6.3.2",
|
|
83
|
+
"typescript": "5.5.2"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"apidoc": "esdoc && cp apidoc/index.json doc/src/components/Esdoc",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"esbuild:iife:base": "esbuild src/iife.js --bundle --sourcemap --target=chrome100",
|
|
103
103
|
"esbuild:iife:minify": "yarn esbuild:iife:base --minify --outfile=build/mbt.min.js",
|
|
104
104
|
"esbuild:iife:unminify": "yarn esbuild:iife:base --outfile=build/mbt.js",
|
|
105
|
-
"format": "prettier --write 'src/**/*.js' && eslint
|
|
105
|
+
"format": "prettier --write 'src/**/*.js' && eslint src/**/*.js src/**/*.ts --fix && stylelint 'src/**/*.css' 'src/**/*.scss' --fix --allow-empty-input",
|
|
106
106
|
"lib": "REACT_APP_LIB_MODE=1 webpack --mode production",
|
|
107
107
|
"lib:dev": "REACT_APP_LIB_MODE=1 webpack --mode development",
|
|
108
108
|
"link2": "cmdToAdd=$(node ./scripts/read-pkg-json.js add) && $cmdToAdd && yarn build && cmdToRemove=$(node ./scripts/read-pkg-json.js remove) && $cmdToRemove && cd build && yarn link",
|
package/setupTests.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/setupTests.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import 'jest-canvas-mock';
|
|
3
|
-
import fetchTrajectoryByIdResponse from '../data/fetchTrajectoryById.json';
|
|
1
|
+
import fetchRouteResponse from '../data/fetchRoute.json';
|
|
4
2
|
import fetchTrajectoriesResponse from '../data/fetchTrajectories.json';
|
|
3
|
+
import fetchTrajectoryByIdResponse from '../data/fetchTrajectoryById.json';
|
|
5
4
|
import fetchTrajectoryStationsResponse from '../data/fetchTrajectoryStations.json';
|
|
6
5
|
import stopsSearchResponse from '../data/stopsSearch.json';
|
|
7
|
-
import
|
|
6
|
+
import 'jest-canvas-mock';
|
|
8
7
|
global.fetchTrajectoryByIdResponse = fetchTrajectoryByIdResponse;
|
|
9
8
|
global.fetchTrajectoriesResponse = fetchTrajectoriesResponse;
|
|
10
9
|
global.fetchTrajectoryStationsResponse = fetchTrajectoryStationsResponse;
|
package/types/common.d.ts
CHANGED
|
@@ -2,55 +2,58 @@ import { Feature } from 'ol';
|
|
|
2
2
|
import { Coordinate } from 'ol/coordinate';
|
|
3
3
|
import { ObjectEvent } from 'ol/Object';
|
|
4
4
|
import { Pixel } from 'ol/pixel';
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import { RealtimeTrajectory } from '../api/typedefs';
|
|
7
|
+
import CommonLayer, {
|
|
8
|
+
LayerCommonOptions,
|
|
9
|
+
} from '../ol/mixins/PropertiesLayerMixin';
|
|
10
|
+
|
|
6
11
|
import type {
|
|
7
12
|
CopyrightControl as MbCopyrightControl,
|
|
8
|
-
RealtimeLayer as MbRealtimeLayer,
|
|
9
13
|
layer as MbLayer,
|
|
14
|
+
RealtimeLayer as MbRealtimeLayer,
|
|
10
15
|
} from '../maplibre';
|
|
11
16
|
import type {
|
|
12
|
-
CopyrightControl as OlCopyrightControl,
|
|
13
17
|
MapboxLayer,
|
|
14
18
|
MaplibreLayer,
|
|
15
|
-
|
|
19
|
+
CopyrightControl as OlCopyrightControl,
|
|
16
20
|
layer as OlLayer,
|
|
21
|
+
RealtimeLayer as OlRealtimeLayer,
|
|
17
22
|
} from '../ol';
|
|
18
|
-
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
} from '../ol/mixins/PropertiesLayerMixin';
|
|
23
|
+
|
|
24
|
+
import type { RealtimeMot, RealtimeTrainId } from './realtime';
|
|
25
|
+
|
|
22
26
|
import type { RoutingParameters } from '.';
|
|
23
27
|
|
|
24
|
-
export type StyleCache =
|
|
28
|
+
export type StyleCache = Record<string, AnyCanvas>;
|
|
25
29
|
|
|
26
|
-
export
|
|
27
|
-
time?: number;
|
|
30
|
+
export interface ViewState {
|
|
28
31
|
center?: number[];
|
|
29
32
|
extent?: number[];
|
|
30
|
-
|
|
31
|
-
rotation?: number;
|
|
33
|
+
pixelRatio?: number;
|
|
32
34
|
resolution?: number;
|
|
35
|
+
rotation?: number;
|
|
36
|
+
size?: number[];
|
|
37
|
+
time?: number;
|
|
33
38
|
zoom?: number;
|
|
34
|
-
|
|
35
|
-
};
|
|
39
|
+
}
|
|
36
40
|
|
|
37
|
-
export
|
|
38
|
-
hoverVehicleId?: RealtimeTrainId;
|
|
39
|
-
selectedVehicleId?: RealtimeTrainId;
|
|
40
|
-
useDelayStyle?: boolean;
|
|
41
|
-
delayOutlineColor?: string;
|
|
41
|
+
export interface RealtimeStyleOptions {
|
|
42
42
|
delayDisplay?: number;
|
|
43
|
-
|
|
43
|
+
delayOutlineColor?: string;
|
|
44
44
|
filter?: FilterFunction;
|
|
45
|
-
getRadius?: (type: RealtimeMot, z: number) => number;
|
|
46
45
|
getBgColor?: (type: RealtimeMot) => string;
|
|
47
46
|
getDelayColor?: (
|
|
48
|
-
delay:
|
|
47
|
+
delay: null | number,
|
|
49
48
|
cancelled?: boolean,
|
|
50
49
|
isDelayText?: boolean,
|
|
51
50
|
) => string;
|
|
52
51
|
getDelayFont?: (fontSize: number, text?: string) => string;
|
|
53
|
-
getDelayText?: (delay:
|
|
52
|
+
getDelayText?: (delay: null | number, cancelled?: boolean) => string;
|
|
53
|
+
getMaxRadiusForStrokeAndDelay?: () => number;
|
|
54
|
+
getMaxRadiusForText?: () => number;
|
|
55
|
+
getRadius?: (type: RealtimeMot, z: number) => number;
|
|
56
|
+
getScreenPixel?: (pixel: Pixel, viewState: ViewState) => Pixel;
|
|
54
57
|
getText?: (text?: string) => string;
|
|
55
58
|
getTextColor?: (type: RealtimeMot) => string;
|
|
56
59
|
getTextFont?: (fontSize: number, text?: string) => string;
|
|
@@ -61,14 +64,13 @@ export type RealtimeStyleOptions = {
|
|
|
61
64
|
fontSize: number,
|
|
62
65
|
getFont: (fontSize: number, text?: string) => string,
|
|
63
66
|
) => number;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
hoverVehicleId?: RealtimeTrainId;
|
|
68
|
+
noInterpolate?: boolean;
|
|
69
|
+
selectedVehicleId?: RealtimeTrainId;
|
|
70
|
+
useDelayStyle?: boolean;
|
|
71
|
+
}
|
|
68
72
|
|
|
69
|
-
export type RealtimeTrajectories =
|
|
70
|
-
[key: RealtimeTrainId]: RealtimeTrajectory;
|
|
71
|
-
};
|
|
73
|
+
export type RealtimeTrajectories = Record<RealtimeTrainId, RealtimeTrajectory>;
|
|
72
74
|
|
|
73
75
|
export type RealtimeStyleFunction = (
|
|
74
76
|
trajectory: RealtimeTrajectory,
|
|
@@ -76,46 +78,51 @@ export type RealtimeStyleFunction = (
|
|
|
76
78
|
options: RealtimeStyleOptions,
|
|
77
79
|
) => AnyCanvas | null;
|
|
78
80
|
|
|
79
|
-
export
|
|
81
|
+
export interface RealtimeRenderState {
|
|
80
82
|
center?: Coordinate;
|
|
81
|
-
zoom?: number;
|
|
82
|
-
rotation?: number;
|
|
83
83
|
renderedTrajectories?: RealtimeTrajectory[];
|
|
84
|
-
|
|
84
|
+
rotation?: number;
|
|
85
|
+
zoom?: number;
|
|
86
|
+
}
|
|
85
87
|
|
|
86
|
-
export type AnyMap =
|
|
87
|
-
export type AnyLayer =
|
|
88
|
+
export type AnyMap = MapboxMap | MaplibreMap | OlMap;
|
|
89
|
+
export type AnyLayer = MbLayer | OlLayer;
|
|
88
90
|
export type AnyOlLayer = OlLayer;
|
|
89
91
|
export type AnyMapboxLayer = MapboxLayer | MaplibreLayer;
|
|
90
92
|
export type AnyRealtimeLayer = MbRealtimeLayer | OlRealtimeLayer;
|
|
91
93
|
export type AnyCopyrightControl = MbCopyrightControl | OlCopyrightControl;
|
|
92
|
-
export type AnyMapGlMap = maplibregl.Map
|
|
93
|
-
export type AnyMapGlMapOptions = maplibregl.MapOptions
|
|
94
|
+
export type AnyMapGlMap = maplibregl.Map;
|
|
95
|
+
export type AnyMapGlMapOptions = maplibregl.MapOptions;
|
|
94
96
|
export type AnyCanvas = HTMLCanvasElement | OffscreenCanvas;
|
|
95
97
|
export type AnyCanvasContext =
|
|
96
98
|
| CanvasRenderingContext2D
|
|
97
|
-
|
|
|
99
|
+
| null
|
|
100
|
+
| OffscreenCanvasRenderingContext2D
|
|
101
|
+
| undefined;
|
|
98
102
|
export type GConstructor<T extends CommonLayer> = new (options?: any) => T;
|
|
99
103
|
export type CommonLayerClass = GConstructor<CommonLayer>;
|
|
100
104
|
export type GConstructor2<T extends OlLayer> = new (options?: any) => T;
|
|
101
105
|
export type OlLayerClass = GConstructor<AnyOlLayer>;
|
|
102
106
|
export type AnyLayerClass = GConstructor<AnyLayer>;
|
|
103
107
|
|
|
108
|
+
type GConstructor3<T = object> = new (...args: any[]) => T;
|
|
109
|
+
export type AnyLayerable = GConstructor3<Omit<AnyLayer, keyof string>>;
|
|
110
|
+
|
|
104
111
|
export type AnyMapboxLayerClass = GConstructor<AnyMapboxLayer>;
|
|
105
112
|
export type AnyRealtimeLayerClass = GConstructor<AnyRealtimeLayer>;
|
|
106
113
|
export type AnyMapGlMapClass = GConstructor<AnyMapGlMap>;
|
|
107
114
|
export type AnyCopyrightControlClass = GConstructor<AnyCopyrightControl>;
|
|
108
115
|
|
|
109
|
-
export
|
|
110
|
-
layer: Layer;
|
|
111
|
-
features: Feature[];
|
|
116
|
+
export interface LayerGetFeatureInfoResponse {
|
|
112
117
|
coordinate: Coordinate;
|
|
113
|
-
|
|
118
|
+
features: Feature[];
|
|
119
|
+
layer: Layer;
|
|
120
|
+
}
|
|
114
121
|
|
|
115
|
-
export
|
|
116
|
-
resolution: number;
|
|
122
|
+
export interface LayerGetFeatureInfoOptions {
|
|
117
123
|
nb?: number;
|
|
118
|
-
|
|
124
|
+
resolution: number;
|
|
125
|
+
}
|
|
119
126
|
|
|
120
127
|
export type UserInteractionCallback = (
|
|
121
128
|
features: Feature[],
|
|
@@ -126,4 +133,4 @@ export type UserInteractionCallback = (
|
|
|
126
133
|
|
|
127
134
|
export type RoutingGraph = [RoutingParameters.graph, number, number];
|
|
128
135
|
export type RoutingMot = RoutingParameters.mot;
|
|
129
|
-
export type RoutingViaPoint =
|
|
136
|
+
export type RoutingViaPoint = Coordinate | string;
|
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Paths as Routing } from './routing';
|
|
2
2
|
import { Paths as Stops } from './stops';
|
|
3
3
|
|
|
4
|
-
export * from './realtime';
|
|
5
4
|
export * from './common';
|
|
5
|
+
export * from './realtime';
|
|
6
6
|
|
|
7
7
|
export type RoutingParameters = Routing['/']['get']['parameters']['query'];
|
|
8
8
|
export type RoutingResponse = Routing['/']['get']['responses']['200']['schema'];
|