mobility-toolbox-js 2.0.1-beta.13 → 2.2.0-beta.0
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/RealtimeAPI.d.ts +281 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +490 -0
- package/api/RoutingAPI.d.ts +37 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +32 -12
- package/api/StopsAPI.d.ts +38 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +33 -9
- package/api/index.d.ts +4 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +3 -3
- package/api/typedefs.d.ts +179 -0
- package/api/typedefs.d.ts.map +1 -0
- package/api/typedefs.js +75 -0
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +54 -27
- package/common/api/WebSocketAPI.d.ts +153 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +330 -164
- package/common/controls/ControlCommon.d.ts +76 -0
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/ControlCommon.js +150 -0
- package/common/controls/CopyrightControlCommon.d.ts +13 -0
- package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
- package/common/controls/CopyrightControlCommon.js +34 -0
- package/common/controls/StopFinderControlCommon.d.ts +55 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/controls/StopFinderControlCommon.js +144 -0
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/index.js +2 -4
- package/common/layers/LayerCommon.d.ts +94 -0
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/LayerCommon.js +244 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +286 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +779 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +241 -0
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/index.js +4 -4
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +275 -0
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +13 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
- package/common/styles/realtimeHeadingStyle.js +85 -0
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -0
- package/common/typedefs.d.ts +111 -0
- package/common/typedefs.d.ts.map +1 -0
- package/common/typedefs.js +52 -0
- package/common/utils/compareDepartures.d.ts +11 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +35 -0
- package/common/utils/createCanvas.d.ts +10 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +27 -0
- package/common/utils/createRealtimeFilters.d.ts +13 -0
- package/common/utils/createRealtimeFilters.d.ts.map +1 -0
- package/common/utils/createRealtimeFilters.js +74 -0
- package/common/utils/debounceDeparturesMessages.d.ts +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
- package/common/utils/debounceDeparturesMessages.js +24 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
- package/common/utils/debounceWebsocketMessages.js +29 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +15 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +26 -15
- package/common/utils/getMapboxRender.d.ts +7 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +87 -0
- package/common/utils/getMaplibreRender.d.ts +7 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +38 -0
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +7 -0
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +18 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +67 -37
- package/common/utils/index.d.ts +17 -0
- package/common/utils/index.d.ts.map +1 -0
- package/common/utils/index.js +17 -5
- package/common/utils/realtimeConfig.d.ts +49 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/realtimeConfig.js +173 -0
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +12 -5
- package/common/utils/renderTrajectories.d.ts +17 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +110 -0
- package/common/utils/sortAndFilterDepartures.d.ts +16 -0
- package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
- package/common/utils/sortAndFilterDepartures.js +58 -0
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +17 -15
- package/common/utils/timeUtils.d.ts +24 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +34 -15
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/iife.js +5 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +8 -6
- package/mapbox/controls/CopyrightControl.d.ts +29 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/mapbox/controls/CopyrightControl.js +44 -25
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/controls/index.js +2 -1
- package/mapbox/index.d.ts +6 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/index.js +5 -4
- package/mapbox/layers/Layer.d.ts +59 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +99 -55
- package/mapbox/layers/RealtimeLayer.d.ts +181 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +276 -0
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/layers/index.js +2 -2
- package/mapbox/utils/getMercatorResolution.d.ts +9 -0
- package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.js +18 -0
- package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
- package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
- package/mapbox/utils/getSourceCoordinates.js +27 -0
- package/mapbox/utils/index.d.ts +3 -0
- package/mapbox/utils/index.d.ts.map +1 -0
- package/mapbox/utils/index.js +2 -0
- package/mbt.js +26074 -16501
- package/mbt.js.map +4 -4
- package/mbt.min.js +205 -126
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +62 -36
- package/ol/controls/RoutingControl.d.ts +193 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +601 -357
- package/ol/controls/StopFinderControl.d.ts +30 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/ol/controls/StopFinderControl.js +30 -8
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/controls/index.js +3 -3
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/index.js +5 -5
- package/ol/layers/Layer.d.ts +86 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +163 -77
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/ol/layers/MapGlLayer.js +218 -0
- package/ol/layers/MapboxLayer.d.ts +50 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +99 -193
- package/ol/layers/MapboxStyleLayer.d.ts +129 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +362 -171
- package/ol/layers/MaplibreLayer.d.ts +28 -0
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +30 -135
- package/ol/layers/RealtimeLayer.d.ts +202 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +340 -0
- package/ol/layers/RoutingLayer.d.ts +34 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +72 -48
- package/ol/layers/VectorLayer.d.ts +25 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +34 -18
- package/ol/layers/WMSLayer.d.ts +42 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +84 -34
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/layers/index.js +8 -8
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +26 -24
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +40 -39
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/ol/styles/index.js +2 -2
- package/package.json +81 -133
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/setupTests.js +26 -0
- package/types/common.d.ts +122 -0
- package/types/index.d.ts +13 -0
- package/types/realtime.d.ts +320 -0
- package/types/routing.d.ts +206 -0
- package/types/stops.d.ts +143 -0
- package/README.md +0 -23
- package/api/RoutingAPI.test.js +0 -25
- package/api/StopsAPI.test.js +0 -22
- package/api/TralisAPI.js +0 -359
- package/api/TralisAPI.test.js +0 -67
- package/api/TralisAPIUtils.js +0 -43
- package/common/Tracker.js +0 -93
- package/common/api/HttpAPI.test.js +0 -50
- package/common/api/WebSocketAPI.test.js +0 -311
- package/common/controls/Control.js +0 -81
- package/common/controls/Control.test.js +0 -87
- package/common/layers/Layer.js +0 -213
- package/common/layers/Layer.test.js +0 -526
- package/common/mixins/CopyrightMixin.js +0 -24
- package/common/mixins/SearchMixin.js +0 -110
- package/common/mixins/TralisLayerMixin.js +0 -479
- package/common/styles/trackerDefaultStyle.js +0 -197
- package/common/styles/trackerDelayStyle.js +0 -8
- package/common/styles/trackerSimpleStyle.js +0 -18
- package/common/trackerConfig.js +0 -152
- package/common/trackerConfig.test.js +0 -23
- package/common/utils/createTrackerFilters.js +0 -56
- package/common/utils/createTrackerFilters.test.js +0 -79
- package/common/utils/getMapboxMapCopyrights.test.js +0 -40
- package/common/utils/getMapboxStyleUrl.js +0 -22
- package/common/utils/removeDuplicate.test.js +0 -19
- package/common/utils/timeUtils.test.js +0 -10
- package/mapbox/layers/Layer.test.js +0 -182
- package/mapbox/layers/TralisLayer.js +0 -182
- package/mapbox/layers/TralisLayer.test.js +0 -38
- package/mapbox/utils.js +0 -32
- package/ol/controls/CopyrightControl.test.js +0 -165
- package/ol/controls/RoutingControl.test.js +0 -151
- package/ol/controls/StopFinderControl.test.js +0 -48
- package/ol/layers/Layer.test.js +0 -174
- package/ol/layers/MapboxLayer.test.js +0 -160
- package/ol/layers/MapboxStyleLayer.test.js +0 -231
- package/ol/layers/RoutingLayer.test.js +0 -40
- package/ol/layers/TralisLayer.js +0 -185
- package/ol/layers/TralisLayer.test.js +0 -79
- package/ol/layers/VectorLayer.test.js +0 -87
- package/ol/layers/WMSLayer.test.js +0 -76
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function remove duplicates lower case string value of an array.
|
|
3
|
+
* It removes also null, undefined or non string values.
|
|
4
|
+
*
|
|
5
|
+
* @param {array} array Array of values.
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
declare const removeDuplicate: (array: any[]) => any[];
|
|
9
|
+
export default removeDuplicate;
|
|
10
|
+
//# sourceMappingURL=removeDuplicate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeDuplicate.d.ts","sourceRoot":"","sources":["../../../src/common/utils/removeDuplicate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,QAAA,MAAM,eAAe,UAAW,GAAG,EAAE,UAYpC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function remove duplicates lower case string value of an array.
|
|
3
|
+
* It removes also null, undefined or non string values.
|
|
4
|
+
*
|
|
5
|
+
* @param {array} array Array of values.
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
1
8
|
const removeDuplicate = (array) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
const arrWithoutEmptyValues = array.filter((val) => val !== undefined && val !== null && val.trim && val.trim());
|
|
10
|
+
const lowerCasesValues = arrWithoutEmptyValues.map((str) => str.toLowerCase());
|
|
11
|
+
const uniqueLowerCaseValues = [...new Set(lowerCasesValues)];
|
|
12
|
+
const uniqueValues = uniqueLowerCaseValues.map((uniqueStr) => arrWithoutEmptyValues.find((str) => str.toLowerCase() === uniqueStr));
|
|
13
|
+
return uniqueValues;
|
|
7
14
|
};
|
|
8
15
|
export default removeDuplicate;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnyCanvas, RealtimeRenderState, RealtimeStyleFunction, RealtimeStyleOptions, RealtimeTrajectories, ViewState } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Draw all the trajectories available in a canvas.
|
|
4
|
+
* @param {HTMLCanvas|HTMLOffscreenCanvas} The canvas where to draw the trajectories.
|
|
5
|
+
* @param {ViewState} trajectories An array of trajectories.
|
|
6
|
+
* @param {Function} style A function that returns a canvas representing a vehicle of a specific trajectory.
|
|
7
|
+
* @param {ViewState} viewState The view state of the map.
|
|
8
|
+
* @param {boolean} options.hoverVehicleId The id of the vehicle to highlight.
|
|
9
|
+
* @param {boolean} options.selectedVehicleId The id of the vehicle to select.
|
|
10
|
+
* @param {boolean} options.noInterpolate If true trajectories are not interpolated but
|
|
11
|
+
* drawn at the last known coordinate. Use this for performance optimization
|
|
12
|
+
* during map navigation.
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
declare const renderTrajectories: (canvas: AnyCanvas, trajectories: RealtimeTrajectories, style: RealtimeStyleFunction, viewState: ViewState, options: RealtimeStyleOptions) => RealtimeRenderState;
|
|
16
|
+
export default renderTrajectories;
|
|
17
|
+
//# sourceMappingURL=renderTrajectories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderTrajectories.d.ts","sourceRoot":"","sources":["../../../src/common/utils/renderTrajectories.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,SAAS,EACV,MAAM,aAAa,CAAC;AAGrB;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,kBAAkB,WACd,SAAS,gBACH,oBAAoB,SAC3B,qBAAqB,aACjB,SAAS,WACX,oBAAoB,KAC5B,mBA+JF,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { compose, apply, create } from 'ol/transform';
|
|
2
|
+
import getVehiclePosition from './getVehiclePosition';
|
|
3
|
+
/**
|
|
4
|
+
* Draw all the trajectories available in a canvas.
|
|
5
|
+
* @param {HTMLCanvas|HTMLOffscreenCanvas} The canvas where to draw the trajectories.
|
|
6
|
+
* @param {ViewState} trajectories An array of trajectories.
|
|
7
|
+
* @param {Function} style A function that returns a canvas representing a vehicle of a specific trajectory.
|
|
8
|
+
* @param {ViewState} viewState The view state of the map.
|
|
9
|
+
* @param {boolean} options.hoverVehicleId The id of the vehicle to highlight.
|
|
10
|
+
* @param {boolean} options.selectedVehicleId The id of the vehicle to select.
|
|
11
|
+
* @param {boolean} options.noInterpolate If true trajectories are not interpolated but
|
|
12
|
+
* drawn at the last known coordinate. Use this for performance optimization
|
|
13
|
+
* during map navigation.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
const renderTrajectories = (canvas, trajectories, style, viewState, options) => {
|
|
17
|
+
if (!canvas) {
|
|
18
|
+
return { renderedTrajectories: [] };
|
|
19
|
+
}
|
|
20
|
+
const { time = Date.now(), size = [], center, resolution, rotation = 0, pixelRatio = 1, } = viewState;
|
|
21
|
+
if (!resolution || !center) {
|
|
22
|
+
return { renderedTrajectories: [] };
|
|
23
|
+
}
|
|
24
|
+
const { noInterpolate = false, hoverVehicleId, selectedVehicleId, filter, getScreenPixel = (pixel, viewStat) => (viewStat.zoom || 0) < 12
|
|
25
|
+
? pixel.map((coord) => Math.floor(coord))
|
|
26
|
+
: pixel, } = options;
|
|
27
|
+
const context = canvas.getContext('2d');
|
|
28
|
+
context === null || context === void 0 ? void 0 : context.clearRect(0, 0, canvas.width, canvas.height);
|
|
29
|
+
const [width, height] = size;
|
|
30
|
+
if (width && height && (canvas.width !== width || canvas.height !== height)) {
|
|
31
|
+
[canvas.width, canvas.height] = [width * pixelRatio, height * pixelRatio];
|
|
32
|
+
}
|
|
33
|
+
const coordinateToPixelTransform = compose(create(), size[0] / 2, size[1] / 2, 1 / resolution, -1 / resolution, -rotation, -center[0], -center[1]);
|
|
34
|
+
// Offscreen canvas has not style attribute
|
|
35
|
+
if (canvas.style) {
|
|
36
|
+
canvas.style.width = `${canvas.width / pixelRatio}px`;
|
|
37
|
+
canvas.style.height = `${canvas.height / pixelRatio}px`;
|
|
38
|
+
}
|
|
39
|
+
let hoverVehicleImg;
|
|
40
|
+
let hoverVehiclePx;
|
|
41
|
+
let selectedVehicleImg;
|
|
42
|
+
let selectedVehiclePx;
|
|
43
|
+
const renderedTrajectories = [];
|
|
44
|
+
for (let i = trajectories.length - 1; i >= 0; i -= 1) {
|
|
45
|
+
const trajectory = trajectories[i];
|
|
46
|
+
// Filter out trajectories
|
|
47
|
+
if (filter && !filter(trajectory)) {
|
|
48
|
+
// eslint-disable-next-line no-continue
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
// We simplify the trajectory object
|
|
52
|
+
const { train_id: id, timeOffset } = trajectory.properties;
|
|
53
|
+
// We set the rotation and the timeFraction of the trajectory (used by tralis).
|
|
54
|
+
// if rotation === null that seems there is no rotation available.
|
|
55
|
+
const { coord, rotation: rotationIcon } = getVehiclePosition(time - (timeOffset || 0), trajectory, noInterpolate);
|
|
56
|
+
// We store the current vehicle position to the trajectory.
|
|
57
|
+
trajectories[i].properties.coordinate = coord;
|
|
58
|
+
trajectories[i].properties.rotation = rotationIcon;
|
|
59
|
+
if (!coord) {
|
|
60
|
+
// eslint-disable-next-line no-continue
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
let px = apply(coordinateToPixelTransform, [...coord]);
|
|
64
|
+
if (!px) {
|
|
65
|
+
// eslint-disable-next-line no-continue
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
px = px.map((p) => p * pixelRatio);
|
|
69
|
+
if (px[0] < 0 ||
|
|
70
|
+
px[0] > canvas.width ||
|
|
71
|
+
px[1] < 0 ||
|
|
72
|
+
px[1] > canvas.height) {
|
|
73
|
+
// eslint-disable-next-line no-continue
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const vehicleImg = style(trajectory, viewState, options);
|
|
77
|
+
if (!vehicleImg) {
|
|
78
|
+
// eslint-disable-next-line no-continue
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (hoverVehicleId !== id && selectedVehicleId !== id) {
|
|
82
|
+
// To optimize the performance we use integer as pixel coordinate
|
|
83
|
+
// to avoid an additional work by the browser on zoom level < 12.
|
|
84
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Optimizing_canvas?retiredLocale=de#avoid_floating-point_coordinates_and_use_integers_instead
|
|
85
|
+
const [x, y] = getScreenPixel([px[0] - vehicleImg.width / 2, px[1] - vehicleImg.height / 2], viewState);
|
|
86
|
+
context === null || context === void 0 ? void 0 : context.drawImage(vehicleImg, x, y);
|
|
87
|
+
}
|
|
88
|
+
if (hoverVehicleId && hoverVehicleId === id) {
|
|
89
|
+
// Store the canvas to draw it at the end
|
|
90
|
+
hoverVehicleImg = vehicleImg;
|
|
91
|
+
hoverVehiclePx = px;
|
|
92
|
+
}
|
|
93
|
+
if (selectedVehicleId && selectedVehicleId === id) {
|
|
94
|
+
// Store the canvas to draw it at the end
|
|
95
|
+
selectedVehicleImg = vehicleImg;
|
|
96
|
+
selectedVehiclePx = px;
|
|
97
|
+
}
|
|
98
|
+
renderedTrajectories.push(trajectory);
|
|
99
|
+
}
|
|
100
|
+
if (selectedVehicleImg && selectedVehiclePx) {
|
|
101
|
+
context === null || context === void 0 ? void 0 : context.drawImage(selectedVehicleImg, Math.floor(selectedVehiclePx[0] - selectedVehicleImg.width / 2), Math.floor(selectedVehiclePx[1] - selectedVehicleImg.height / 2));
|
|
102
|
+
}
|
|
103
|
+
if (hoverVehicleImg && hoverVehiclePx) {
|
|
104
|
+
context === null || context === void 0 ? void 0 : context.drawImage(hoverVehicleImg, Math.floor(hoverVehiclePx[0] - hoverVehicleImg.width / 2), Math.floor(hoverVehiclePx[1] - hoverVehicleImg.height / 2));
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
renderedTrajectories,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export default renderTrajectories;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RealtimeAPIDeparturesById } from '../../api/RealtimeAPI';
|
|
2
|
+
import type { RealtimeDepartureExtended } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* This function sort Departures by arrival time and filter out unwanted departures:
|
|
5
|
+
* - when dparture time is in the past
|
|
6
|
+
* - when departure are duplicated
|
|
7
|
+
* - when departure is not in the next 30 min
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} depObject The object containing departures by id.
|
|
10
|
+
* @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
|
|
11
|
+
* @return {Array<Departure>} Return departures array.
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
declare const sortAndfilterDepartures: (depObject: RealtimeAPIDeparturesById, sortByMinArrivalTime?: boolean, maxDepartureAge?: number) => RealtimeDepartureExtended[];
|
|
15
|
+
export default sortAndfilterDepartures;
|
|
16
|
+
//# sourceMappingURL=sortAndFilterDepartures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortAndFilterDepartures.d.ts","sourceRoot":"","sources":["../../../src/common/utils/sortAndFilterDepartures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAG7D;;;;;;;;;;GAUG;AACH,QAAA,MAAM,uBAAuB,cAChB,yBAAyB,yBACd,OAAO,oBACZ,MAAM,KACtB,yBAAyB,EAwD3B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import compareDepartures from './compareDepartures';
|
|
2
|
+
/**
|
|
3
|
+
* This function sort Departures by arrival time and filter out unwanted departures:
|
|
4
|
+
* - when dparture time is in the past
|
|
5
|
+
* - when departure are duplicated
|
|
6
|
+
* - when departure is not in the next 30 min
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} depObject The object containing departures by id.
|
|
9
|
+
* @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
|
|
10
|
+
* @return {Array<Departure>} Return departures array.
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
const sortAndfilterDepartures = (depObject, sortByMinArrivalTime = false, maxDepartureAge = 30) => {
|
|
14
|
+
const departures = Object.keys(depObject).map((k) => depObject[k]);
|
|
15
|
+
departures.sort((a, b) => compareDepartures(a, b, sortByMinArrivalTime));
|
|
16
|
+
const futureDate = new Date();
|
|
17
|
+
futureDate.setMinutes(futureDate.getMinutes() + maxDepartureAge);
|
|
18
|
+
const future = futureDate.getTime();
|
|
19
|
+
const pastDate = new Date();
|
|
20
|
+
pastDate.setMinutes(pastDate.getMinutes() - maxDepartureAge);
|
|
21
|
+
const past = pastDate.getTime();
|
|
22
|
+
const departureArray = [];
|
|
23
|
+
const platformsBoarding = [];
|
|
24
|
+
let previousDeparture = null;
|
|
25
|
+
for (let i = departures.length - 1; i >= 0; i -= 1) {
|
|
26
|
+
const departure = Object.assign({}, departures[i]);
|
|
27
|
+
const time = new Date(departure.time).getTime();
|
|
28
|
+
// Only show departures within the next 30 minutes
|
|
29
|
+
if (time > past && time < future) {
|
|
30
|
+
// If 2 trains are boarding at the same platform,
|
|
31
|
+
// remove the older one.
|
|
32
|
+
if (departure.state === 'BOARDING') {
|
|
33
|
+
if (!platformsBoarding.includes(departure.platform)) {
|
|
34
|
+
platformsBoarding.push(departure.platform);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
departure.state = 'HIDDEN';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// If two trains with the same line number and destinatin
|
|
41
|
+
// and a departure difference < 1 minute, hide the second one.
|
|
42
|
+
if (previousDeparture &&
|
|
43
|
+
departure.to[0] === previousDeparture.to[0] &&
|
|
44
|
+
Math.abs(time - previousDeparture.time) < 1000 &&
|
|
45
|
+
departure.line.name === previousDeparture.line.name) {
|
|
46
|
+
departure.state = 'HIDDEN';
|
|
47
|
+
}
|
|
48
|
+
if (/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(departure.state)) {
|
|
49
|
+
departure.cancelled = true;
|
|
50
|
+
}
|
|
51
|
+
previousDeparture = departure;
|
|
52
|
+
previousDeparture.time = time;
|
|
53
|
+
departureArray.unshift(departure);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return departureArray;
|
|
57
|
+
};
|
|
58
|
+
export default sortAndfilterDepartures;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortByDelay.d.ts","sourceRoot":"","sources":["../../../src/common/utils/sortByDelay.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW,oDAGd,MAoBF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
const sortByDelay = (traj1, traj2) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
const props1 = traj1.properties;
|
|
3
|
+
const props2 = traj2.properties;
|
|
4
|
+
if (props1.delay === null && props2.delay !== null) {
|
|
5
|
+
return 1;
|
|
6
|
+
}
|
|
7
|
+
if (props2.delay === null && props1.delay !== null) {
|
|
8
|
+
return -1;
|
|
9
|
+
}
|
|
10
|
+
// We put cancelled train inbetween green and yellow trains
|
|
11
|
+
// >=180000ms corresponds to yellow train
|
|
12
|
+
if (props1.cancelled && !props2.cancelled) {
|
|
13
|
+
return props2.delay < 180000 ? -1 : 1;
|
|
14
|
+
}
|
|
15
|
+
if (props2.cancelled && !props1.cancelled) {
|
|
16
|
+
return props1.delay < 180000 ? 1 : -1;
|
|
17
|
+
}
|
|
18
|
+
return props2.delay - props1.delay;
|
|
17
19
|
};
|
|
18
20
|
export default sortByDelay;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a Date object as UTC date string .
|
|
3
|
+
* ex: 2019 09 01
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export declare const getUTCDateString: (now?: Date) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Get the UTC time string of Date object.
|
|
9
|
+
* ex: 09:05:01.123
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
export declare const getUTCTimeString: (date: Date) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a string representation of a number, with a zero if the number is lower than 10.
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
17
|
+
export declare const pad: (integer: number) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a 'hh:mm' string from a time in ms.
|
|
20
|
+
* @param {Number} timeInMs Time in milliseconds.
|
|
21
|
+
* @ignore
|
|
22
|
+
*/
|
|
23
|
+
export declare const getHoursAndMinutes: (timeInMs: number) => string;
|
|
24
|
+
//# sourceMappingURL=timeUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeUtils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/timeUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,kBAAuB,MAOnD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SAAU,IAAI,KAAG,MAKjC,CAAC;AAEd;;;GAGG;AACH,eAAO,MAAM,GAAG,YAAa,MAAM,KAAG,MACO,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAAc,MAAM,KAAG,MAMrD,CAAC"}
|
|
@@ -1,20 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a Date object as UTC date string .
|
|
3
|
+
* ex: 2019 09 01
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
1
6
|
export const getUTCDateString = (now = new Date()) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
let month = (now.getUTCMonth() + 1).toString();
|
|
8
|
+
month = month.length === 1 ? `0${month}` : month;
|
|
9
|
+
let day = now.getUTCDate().toString();
|
|
10
|
+
day = day.length === 1 ? `0${day}` : day;
|
|
11
|
+
return [now.getUTCFullYear(), month, day].join('');
|
|
7
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Get the UTC time string of Date object.
|
|
15
|
+
* ex: 09:05:01.123
|
|
16
|
+
* @ignore
|
|
17
|
+
*/
|
|
8
18
|
export const getUTCTimeString = (date) => [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
].join(
|
|
13
|
-
|
|
19
|
+
date.getUTCHours(),
|
|
20
|
+
date.getUTCMinutes(),
|
|
21
|
+
`${date.getUTCSeconds()}.${date.getUTCMilliseconds()}`,
|
|
22
|
+
].join(':');
|
|
23
|
+
/**
|
|
24
|
+
* Returns a string representation of a number, with a zero if the number is lower than 10.
|
|
25
|
+
* @ignore
|
|
26
|
+
*/
|
|
27
|
+
export const pad = (integer) => integer < 10 ? `0${integer}` : `${integer}`;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a 'hh:mm' string from a time in ms.
|
|
30
|
+
* @param {Number} timeInMs Time in milliseconds.
|
|
31
|
+
* @ignore
|
|
32
|
+
*/
|
|
14
33
|
export const getHoursAndMinutes = (timeInMs) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
34
|
+
if (!timeInMs || timeInMs <= 0) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
const date = new Date(timeInMs);
|
|
38
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
20
39
|
};
|
package/iife.d.ts
ADDED
package/iife.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iife.d.ts","sourceRoot":"","sources":["../src/iife.js"],"names":[],"mappings":";gBAAgB,SAAS"}
|
package/iife.js
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * as ol from "./ol";
|
|
2
|
+
export * as mapbox from "./mapbox";
|
|
3
|
+
declare namespace _default {
|
|
4
|
+
export { ol };
|
|
5
|
+
export { mapbox };
|
|
6
|
+
}
|
|
7
|
+
export default _default;
|
|
8
|
+
import * as ol from './ol';
|
|
9
|
+
import * as mapbox from './mapbox';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;;;;;oBAAoB,MAAM;wBACF,UAAU"}
|
package/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import * as ol from
|
|
2
|
-
import * as mapbox from
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
import * as ol from './ol';
|
|
2
|
+
import * as mapbox from './mapbox';
|
|
3
|
+
import * as ol_1 from './ol';
|
|
4
|
+
export { ol_1 as ol };
|
|
5
|
+
import * as mapbox_1 from './mapbox';
|
|
6
|
+
export { mapbox_1 as mapbox };
|
|
5
7
|
export default {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
ol,
|
|
9
|
+
mapbox,
|
|
8
10
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import CopyrightControlCommon from '../../common/controls/CopyrightControlCommon';
|
|
2
|
+
/**
|
|
3
|
+
* Display layer's copyrights.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { Map } from 'mapbox-gl';
|
|
7
|
+
* import { CopyrightControl } from 'mobility-toolbox-js/mapbox';
|
|
8
|
+
*
|
|
9
|
+
* const map = new Map({
|
|
10
|
+
* container: 'map',
|
|
11
|
+
* style: `https://maps.geops.io/styles/travic_v2/style.json?key=${window.apiKey}`,
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* const control = new CopyrightControl();
|
|
15
|
+
* control.attachToMap(map);
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* @see <a href="/example/mb-copyright">Mapbox copyright example</a>
|
|
19
|
+
*
|
|
20
|
+
* @extends {CopyrightControlCommon}
|
|
21
|
+
*/
|
|
22
|
+
declare class CopyrightControl extends CopyrightControlCommon {
|
|
23
|
+
constructor(options: any);
|
|
24
|
+
activate(): void;
|
|
25
|
+
deactivate(): void;
|
|
26
|
+
getCopyrights(): any[];
|
|
27
|
+
}
|
|
28
|
+
export default CopyrightControl;
|
|
29
|
+
//# sourceMappingURL=CopyrightControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyrightControl.d.ts","sourceRoot":"","sources":["../../../src/mapbox/controls/CopyrightControl.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,MAAM,8CAA8C,CAAC;AAGlF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAM,gBAAiB,SAAQ,sBAAsB;gBACvC,OAAO,EAAE,GAAG;IAKxB,QAAQ;IASR,UAAU;IASV,aAAa;CAGd;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,29 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import CopyrightControlCommon from '../../common/controls/CopyrightControlCommon';
|
|
2
|
+
import { getMapboxMapCopyrights } from '../../common/utils';
|
|
3
|
+
/**
|
|
4
|
+
* Display layer's copyrights.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import { Map } from 'mapbox-gl';
|
|
8
|
+
* import { CopyrightControl } from 'mobility-toolbox-js/mapbox';
|
|
9
|
+
*
|
|
10
|
+
* const map = new Map({
|
|
11
|
+
* container: 'map',
|
|
12
|
+
* style: `https://maps.geops.io/styles/travic_v2/style.json?key=${window.apiKey}`,
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* const control = new CopyrightControl();
|
|
16
|
+
* control.attachToMap(map);
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
* @see <a href="/example/mb-copyright">Mapbox copyright example</a>
|
|
20
|
+
*
|
|
21
|
+
* @extends {CopyrightControlCommon}
|
|
22
|
+
*/
|
|
23
|
+
class CopyrightControl extends CopyrightControlCommon {
|
|
24
|
+
constructor(options) {
|
|
25
|
+
super(options);
|
|
26
|
+
this.render = this.render.bind(this);
|
|
15
27
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
activate() {
|
|
29
|
+
super.activate();
|
|
30
|
+
if (this.map) {
|
|
31
|
+
this.map.on('sourcedata', this.render);
|
|
32
|
+
this.map.on('styledata', this.render);
|
|
33
|
+
this.map.on('idle', this.render);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
deactivate() {
|
|
37
|
+
if (this.map) {
|
|
38
|
+
this.map.off('sourcedata', this.render);
|
|
39
|
+
this.map.off('styledata', this.render);
|
|
40
|
+
this.map.off('idle', this.render);
|
|
41
|
+
}
|
|
42
|
+
super.deactivate();
|
|
43
|
+
}
|
|
44
|
+
getCopyrights() {
|
|
45
|
+
return getMapboxMapCopyrights(this.map);
|
|
22
46
|
}
|
|
23
|
-
super.deactivate();
|
|
24
|
-
}
|
|
25
|
-
getCopyrights() {
|
|
26
|
-
return getMapboxMapCopyrights(this.map);
|
|
27
|
-
}
|
|
28
47
|
}
|
|
29
48
|
export default CopyrightControl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mapbox/controls/index.js"],"names":[],"mappings":""}
|
package/mapbox/controls/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
2
|
+
export { default as CopyrightControl } from './CopyrightControl';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mapbox/index.js"],"names":[],"mappings":""}
|
package/mapbox/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from '../api';
|
|
2
|
+
export * from '../common';
|
|
3
|
+
export * from './controls';
|
|
4
|
+
export * from './layers';
|
|
5
|
+
export * from './utils';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { EventsKey } from 'ol/events';
|
|
2
|
+
import LayerCommon, { LayerCommonOptions } from '../../common/layers/LayerCommon';
|
|
3
|
+
import { AnyMapboxMap, UserInteractionCallback } from '../../types';
|
|
4
|
+
declare const Layer_base: typeof LayerCommon;
|
|
5
|
+
/**
|
|
6
|
+
* A class representing a layer to display on an OpenLayers map.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { Layer } from 'mobility-toolbox-js/ol';
|
|
10
|
+
*
|
|
11
|
+
* const layer = new Layer({
|
|
12
|
+
* olLayer: ...,
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* @see <a href="/example/ol-map">Map example</a>
|
|
16
|
+
*
|
|
17
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
18
|
+
* @extends {Layer}
|
|
19
|
+
*/
|
|
20
|
+
declare class Layer extends Layer_base {
|
|
21
|
+
options: LayerCommonOptions;
|
|
22
|
+
onChangeVisibleKey?: EventsKey;
|
|
23
|
+
userInteractions?: boolean;
|
|
24
|
+
userClickInteractions?: boolean;
|
|
25
|
+
userHoverInteractions?: boolean;
|
|
26
|
+
userClickCallbacks?: UserInteractionCallback[];
|
|
27
|
+
userHoverCallbacks?: UserInteractionCallback[];
|
|
28
|
+
onUserClickCallback: () => void;
|
|
29
|
+
onUserMoveCallback: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Initialize the layer and listen to user events.
|
|
32
|
+
* @param {mapboxgl.Map|maplibregl.Map} map
|
|
33
|
+
*/
|
|
34
|
+
attachToMap(map: AnyMapboxMap): void;
|
|
35
|
+
detachFromMap(): void;
|
|
36
|
+
activateUserInteractions(): void;
|
|
37
|
+
deactivateUserInteractions(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Toggle listeners needed when a layer is avisible or not.
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
toggleVisibleListeners(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the current extent in mercator coordinates.
|
|
45
|
+
*/
|
|
46
|
+
getMercatorExtent(): import("ol/extent").Extent;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the equivalent zoom in Openlayers.
|
|
49
|
+
*/
|
|
50
|
+
getOlZoom(): any;
|
|
51
|
+
/**
|
|
52
|
+
* Create a copy of the Layer.
|
|
53
|
+
* @param {Object} newOptions Options to override
|
|
54
|
+
* @return {Layer} A Layer
|
|
55
|
+
*/
|
|
56
|
+
clone(newOptions: LayerCommonOptions): Layer;
|
|
57
|
+
}
|
|
58
|
+
export default Layer;
|
|
59
|
+
//# sourceMappingURL=Layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/mapbox/layers/Layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,WAAW,EAAE,EAClB,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;;AAEpE;;;;;;;;;;;;;;GAcG;AACH,cAAM,KAAM,SAAQ,UAAkC;IACpD,OAAO,EAAG,kBAAkB,CAAC;IAE7B,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAI/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,mBAAmB,EAAG,MAAM,IAAI,CAAC;IAEjC,kBAAkB,EAAG,MAAM,IAAI,CAAC;IAEhC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,YAAY;IAiB7B,aAAa;IASb,wBAAwB;IAqBxB,0BAA0B;IAO1B;;;OAGG;IACH,sBAAsB;IAQtB;;OAEG;IACH,iBAAiB;IASjB;;OAEG;IACH,SAAS;IAIT;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,kBAAkB;CAGrC;AACD,eAAe,KAAK,CAAC"}
|