mobility-toolbox-js 2.0.0-beta.30 → 2.0.0-beta.34
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 +268 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +626 -343
- package/api/RoutingAPI.d.ts +33 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +65 -15
- package/api/StopsAPI.d.ts +36 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +70 -12
- package/api/index.d.ts +5 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +10 -3
- package/api/typedefs.d.ts +105 -0
- package/api/typedefs.d.ts.map +1 -0
- package/api/typedefs.js +72 -0
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +82 -30
- package/common/api/WebSocketAPI.d.ts +95 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +313 -168
- package/common/controls/Control.d.ts +74 -0
- package/common/controls/Control.d.ts.map +1 -0
- package/common/controls/Control.js +167 -78
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/index.js +18 -2
- package/common/layers/Layer.d.ts +80 -0
- package/common/layers/Layer.d.ts.map +1 -0
- package/common/layers/Layer.js +251 -134
- package/common/mixins/CopyrightMixin.d.ts +22 -0
- package/common/mixins/CopyrightMixin.d.ts.map +1 -0
- package/common/mixins/CopyrightMixin.js +70 -22
- package/common/mixins/MapboxLayerMixin.d.ts +27 -0
- package/common/mixins/MapboxLayerMixin.d.ts.map +1 -0
- package/common/mixins/MapboxLayerMixin.js +240 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +58 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +698 -429
- package/common/mixins/StopFinderMixin.d.ts +40 -0
- package/common/mixins/StopFinderMixin.d.ts.map +1 -0
- package/common/mixins/StopFinderMixin.js +195 -107
- package/common/mixins/UserInteractionsLayerMixin.d.ts +42 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +222 -121
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/index.js +24 -4
- package/common/styles/realtimeDefaultStyle.d.ts +15 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +236 -190
- package/common/styles/realtimeDelayStyle.d.ts +11 -0
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +25 -7
- package/common/styles/realtimeSimpleStyle.d.ts +3 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -17
- package/common/typedefs.d.ts +50 -0
- package/common/typedefs.d.ts.map +1 -0
- package/common/typedefs.js +21 -0
- package/common/utils/cleanStopTime.d.ts +7 -0
- package/common/utils/cleanStopTime.d.ts.map +1 -0
- package/common/utils/cleanStopTime.js +28 -17
- package/common/utils/compareDepartures.d.ts +9 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +34 -22
- package/common/utils/createCanvas.d.ts +9 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +28 -16
- package/common/utils/createTrackerFilters.d.ts +12 -0
- package/common/utils/createTrackerFilters.d.ts.map +1 -0
- package/common/utils/createTrackerFilters.js +75 -54
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +15 -13
- package/common/utils/getMapboxMapCopyrights.d.ts +8 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +24 -17
- package/common/utils/getMapboxRender.d.ts +5 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +77 -0
- package/common/utils/getMaplibreRender.d.ts +5 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +38 -0
- package/common/utils/getRealtimeModeSuffix.d.ts +8 -0
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +11 -2
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +20 -10
- package/common/utils/getVehiclePosition.d.ts +14 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +63 -39
- package/common/utils/index.d.ts +12 -0
- package/common/utils/index.d.ts.map +1 -0
- package/common/utils/index.js +37 -9
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +29 -7
- package/common/utils/renderTrajectories.d.ts +20 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +111 -78
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +21 -17
- package/common/utils/timeUtils.d.ts +5 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +47 -18
- package/common/utils/trackerConfig.d.ts +24 -0
- package/common/utils/trackerConfig.d.ts.map +1 -0
- package/common/utils/trackerConfig.js +171 -118
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/iife.js +7 -0
- package/index.d.ts +6 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -7
- package/mapbox/controls/CopyrightControl.d.ts +32 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/mapbox/controls/CopyrightControl.js +72 -28
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/controls/index.js +6 -1
- package/mapbox/index.d.ts +5 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/index.js +20 -4
- package/mapbox/layers/Layer.d.ts +47 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +137 -54
- package/mapbox/layers/RealtimeLayer.d.ts +118 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +310 -183
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/layers/index.js +7 -2
- package/mapbox/utils.d.ts +8 -0
- package/mapbox/utils.d.ts.map +1 -0
- package/mapbox/utils.js +54 -29
- package/mbt.js +2052 -2109
- package/mbt.js.map +3 -3
- package/mbt.min.js +18 -18
- package/mbt.min.js.map +3 -3
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +89 -41
- package/ol/controls/RoutingControl.d.ts +180 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +666 -371
- package/ol/controls/StopFinderControl.d.ts +32 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/ol/controls/StopFinderControl.js +59 -10
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/controls/index.js +9 -3
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/index.js +21 -5
- package/ol/layers/Layer.d.ts +49 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +178 -81
- package/ol/layers/MapboxLayer.d.ts +42 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +131 -198
- package/ol/layers/MapboxStyleLayer.d.ts +146 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +382 -186
- package/ol/layers/MaplibreLayer.d.ts +27 -0
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +67 -138
- package/ol/layers/RealtimeLayer.d.ts +119 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +327 -184
- package/ol/layers/RoutingLayer.d.ts +24 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +111 -56
- package/ol/layers/VectorLayer.d.ts +23 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +71 -21
- package/ol/layers/WMSLayer.d.ts +38 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +105 -37
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/layers/index.js +19 -8
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +32 -28
- package/ol/styles/fullTrajectoryStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +44 -40
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/ol/styles/index.js +7 -2
- package/package.json +14 -36
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/setupTests.js +15 -0
- package/types/index.d.ts +7 -6
- package/types/routing.d.ts +25 -25
- package/types/stops.d.ts +19 -19
- package/api/RealtimeAPI.test.js +0 -67
- package/api/RoutingAPI.test.js +0 -25
- package/api/StopsAPI.test.js +0 -22
- package/common/api/HttpAPI.test.js +0 -50
- package/common/api/WebSocketAPI.test.js +0 -311
- package/common/controls/Control.test.js +0 -87
- package/common/layers/Layer.test.js +0 -134
- package/common/mixins/UserInteractionsLayerMixin.test.js +0 -199
- package/common/utils/createTrackerFilters.test.js +0 -79
- package/common/utils/getMapboxMapCopyrights.test.js +0 -40
- package/common/utils/removeDuplicate.test.js +0 -19
- package/common/utils/timeUtils.test.js +0 -10
- package/common/utils/trackerConfig.test.js +0 -23
- package/mapbox/layers/Layer.test.js +0 -182
- package/mapbox/layers/RealtimeLayer.test.js +0 -10
- package/ol/controls/CopyrightControl.test.js +0 -165
- package/ol/controls/RoutingControl.test.js +0 -146
- package/ol/controls/StopFinderControl.test.js +0 -48
- package/ol/layers/Layer.test.js +0 -175
- package/ol/layers/MapboxLayer.test.js +0 -160
- package/ol/layers/MapboxStyleLayer.test.js +0 -226
- package/ol/layers/RealtimeLayer.test.js +0 -67
- package/ol/layers/RoutingLayer.test.js +0 -39
- package/ol/layers/VectorLayer.test.js +0 -76
- package/ol/layers/WMSLayer.test.js +0 -57
|
@@ -1,187 +1,330 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
var GeoJSON_1 = require("ol/format/GeoJSON");
|
|
30
|
+
var layer_1 = require("ol/layer");
|
|
31
|
+
var Source_1 = require("ol/source/Source");
|
|
32
|
+
var transform_1 = require("ol/transform");
|
|
33
|
+
var source_1 = require("ol/source");
|
|
34
|
+
var Layer_1 = require("./Layer");
|
|
35
|
+
var RealtimeLayerMixin_1 = require("../../common/mixins/RealtimeLayerMixin");
|
|
36
|
+
var styles_1 = require("../styles");
|
|
37
|
+
/** @private */
|
|
38
|
+
var format = new GeoJSON_1.default();
|
|
39
|
+
/**
|
|
40
|
+
* Responsible for loading and display data from a Realtime service.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* import { RealtimeLayer } from 'mobility-toolbox-js/ol';
|
|
44
|
+
*
|
|
45
|
+
* const layer = new RealtimeLayer({
|
|
46
|
+
* url: [yourUrl],
|
|
47
|
+
* apiKey: [yourApiKey],
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
*
|
|
51
|
+
* @see <a href="/api/class/src/api/RealtimeAPI%20js~RealtimeAPI%20html">RealtimeAPI</a>
|
|
52
|
+
*
|
|
53
|
+
* @extends {Layer}
|
|
54
|
+
* @implements {UserInteractionsLayerInterface}
|
|
55
|
+
* @implements {RealtimeLayerInterface}
|
|
56
|
+
*/
|
|
57
|
+
var RealtimeLayer = /** @class */ (function (_super) {
|
|
58
|
+
__extends(RealtimeLayer, _super);
|
|
59
|
+
/**
|
|
60
|
+
* Constructor.
|
|
61
|
+
*
|
|
62
|
+
* @param {Object} options
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
function RealtimeLayer(options) {
|
|
66
|
+
if (options === void 0) { options = {}; }
|
|
67
|
+
var _this =
|
|
68
|
+
// We use a group to be able to add custom vector layer in extended class.
|
|
69
|
+
// For example TrajservLayer use a vectorLayer to display the complete trajectory.
|
|
70
|
+
_super.call(this, __assign({}, options)) || this;
|
|
71
|
+
/** @ignore */
|
|
72
|
+
_this.olLayer =
|
|
73
|
+
options.olLayer ||
|
|
74
|
+
new layer_1.Group({
|
|
75
|
+
layers: [
|
|
76
|
+
new layer_1.Vector({
|
|
77
|
+
source: new source_1.Vector({ features: [] }),
|
|
78
|
+
style: function (feature, resolution) {
|
|
79
|
+
return (options.fullTrajectoryStyle || styles_1.fullTrajectoryStyle)(feature, resolution, _this.styleOptions);
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
new layer_1.Layer({
|
|
83
|
+
source: new Source_1.default({}),
|
|
84
|
+
render: function (frameState) {
|
|
85
|
+
if (!_this.container) {
|
|
86
|
+
_this.container = document.createElement('div');
|
|
87
|
+
_this.container.style.position = 'absolute';
|
|
88
|
+
_this.container.style.width = '100%';
|
|
89
|
+
_this.container.style.height = '100%';
|
|
90
|
+
_this.transformContainer = document.createElement('div');
|
|
91
|
+
_this.transformContainer.style.position = 'absolute';
|
|
92
|
+
_this.transformContainer.style.width = '100%';
|
|
93
|
+
_this.transformContainer.style.height = '100%';
|
|
94
|
+
_this.container.appendChild(_this.transformContainer);
|
|
95
|
+
_this.canvas.style.position = 'absolute';
|
|
96
|
+
_this.canvas.style.top = '0';
|
|
97
|
+
_this.canvas.style.left = '0';
|
|
98
|
+
_this.canvas.style.transformOrigin = 'top left';
|
|
99
|
+
_this.transformContainer.appendChild(_this.canvas);
|
|
100
|
+
}
|
|
101
|
+
if (_this.renderedViewState) {
|
|
102
|
+
var _a = frameState.viewState, center = _a.center, resolution = _a.resolution, rotation = _a.rotation;
|
|
103
|
+
var _b = _this.renderedViewState, renderedCenter = _b.center, renderedResolution = _b.resolution, renderedRotation = _b.rotation;
|
|
104
|
+
if (renderedResolution / resolution >= 3) {
|
|
105
|
+
// Avoid having really big points when zooming fast.
|
|
106
|
+
var context = _this.canvas.getContext('2d');
|
|
107
|
+
context.clearRect(0, 0, _this.canvas.width, _this.canvas.height);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
var pixelCenterRendered = _this.map.getPixelFromCoordinate(renderedCenter);
|
|
111
|
+
var pixelCenter = _this.map.getPixelFromCoordinate(center);
|
|
112
|
+
_this.transformContainer.style.transform = (0, transform_1.composeCssTransform)(pixelCenterRendered[0] - pixelCenter[0], pixelCenterRendered[1] - pixelCenter[1], renderedResolution / resolution, renderedResolution / resolution, rotation - renderedRotation, 0, 0);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return _this.container;
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
118
|
+
],
|
|
119
|
+
});
|
|
120
|
+
// We store the layer used to highlight the full Trajectory
|
|
121
|
+
_this.vectorLayer = _this.olLayer.getLayers().item(0);
|
|
122
|
+
// Options the last render run did happen. If something changes
|
|
123
|
+
// we have to render again
|
|
124
|
+
/** @ignore */
|
|
125
|
+
_this.renderState = {
|
|
126
|
+
center: [0, 0],
|
|
127
|
+
zoom: null,
|
|
128
|
+
rotation: 0,
|
|
129
|
+
};
|
|
130
|
+
return _this;
|
|
131
|
+
}
|
|
132
|
+
RealtimeLayer.prototype.attachToMap = function (map) {
|
|
133
|
+
var _this = this;
|
|
134
|
+
_super.prototype.attachToMap.call(this, map);
|
|
135
|
+
if (this.map) {
|
|
136
|
+
this.olListenersKeys.push(this.map.on(['moveend', 'change:target'], function (evt) {
|
|
137
|
+
var view = _this.map.getView();
|
|
138
|
+
if (view.getAnimating() || view.getInteracting()) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
var zoom = view.getZoom();
|
|
142
|
+
// Update the interval between render updates
|
|
143
|
+
if (_this.currentZoom !== zoom) {
|
|
144
|
+
_this.onZoomEnd(evt);
|
|
145
|
+
}
|
|
146
|
+
_this.currentZoom = zoom;
|
|
147
|
+
_this.onMoveEnd(evt);
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Destroy the container of the tracker.
|
|
153
|
+
*/
|
|
154
|
+
RealtimeLayer.prototype.detachFromMap = function () {
|
|
155
|
+
_super.prototype.detachFromMap.call(this);
|
|
156
|
+
this.container = null;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Detect in the canvas if there is data to query at a specific coordinate.
|
|
160
|
+
* @param {ol/coordinate~Coordinate} coordinate The coordinate to test
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
RealtimeLayer.prototype.hasFeatureInfoAtCoordinate = function (coordinate) {
|
|
164
|
+
if (this.map && this.canvas) {
|
|
165
|
+
var context = this.canvas.getContext('2d');
|
|
166
|
+
var pixel = this.map.getPixelFromCoordinate(coordinate);
|
|
167
|
+
return !!context.getImageData(pixel[0] * this.pixelRatio, pixel[1] * this.pixelRatio, 1, 1).data[3];
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Render the trajectories using current map's size, resolution and rotation.
|
|
173
|
+
* @param {boolean} noInterpolate if true, renders the vehicles without interpolating theirs positions.
|
|
174
|
+
* @overrides
|
|
175
|
+
*/
|
|
176
|
+
RealtimeLayer.prototype.renderTrajectories = function (noInterpolate) {
|
|
177
|
+
var view = this.map.getView();
|
|
178
|
+
_super.prototype.renderTrajectories.call(this, {
|
|
179
|
+
size: this.map.getSize(),
|
|
180
|
+
center: this.map.getView().getCenter(),
|
|
181
|
+
extent: view.calculateExtent(),
|
|
182
|
+
resolution: view.getResolution(),
|
|
183
|
+
rotation: view.getRotation(),
|
|
184
|
+
zoom: view.getZoom(),
|
|
185
|
+
pixelRatio: this.pixelRatio,
|
|
186
|
+
}, noInterpolate);
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Launch renderTrajectories. it avoids duplicating code in renderTrajectories methhod.
|
|
190
|
+
* @private
|
|
191
|
+
* @override
|
|
192
|
+
*/
|
|
193
|
+
RealtimeLayer.prototype.renderTrajectoriesInternal = function (viewState, noInterpolate) {
|
|
194
|
+
if (!this.map) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
var isRendered = false;
|
|
198
|
+
var blockRendering = this.map.getView().getAnimating() || this.map.getView().getInteracting();
|
|
199
|
+
// Don't render the map when the map is animating or interacting.
|
|
200
|
+
isRendered = blockRendering
|
|
201
|
+
? false
|
|
202
|
+
: _super.prototype.renderTrajectoriesInternal.call(this, viewState, noInterpolate);
|
|
203
|
+
// We update the current render state.
|
|
204
|
+
if (isRendered) {
|
|
205
|
+
this.renderedViewState = __assign({}, viewState);
|
|
206
|
+
if (this.transformContainer) {
|
|
207
|
+
this.transformContainer.style.transform = '';
|
|
57
208
|
}
|
|
58
|
-
return this.container;
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
]
|
|
62
|
-
});
|
|
63
|
-
this.vectorLayer = this.olLayer.getLayers().item(0);
|
|
64
|
-
this.renderState = {
|
|
65
|
-
center: [0, 0],
|
|
66
|
-
zoom: null,
|
|
67
|
-
rotation: 0
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
attachToMap(map) {
|
|
71
|
-
super.attachToMap(map);
|
|
72
|
-
if (this.map) {
|
|
73
|
-
this.olListenersKeys.push(this.map.on(["moveend", "change:target"], (evt) => {
|
|
74
|
-
const view = this.map.getView();
|
|
75
|
-
if (view.getAnimating() || view.getInteracting()) {
|
|
76
|
-
return;
|
|
77
209
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
210
|
+
return isRendered;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Return the delay in ms before the next rendering.
|
|
214
|
+
*/
|
|
215
|
+
RealtimeLayer.prototype.getRefreshTimeInMs = function () {
|
|
216
|
+
return _super.prototype.getRefreshTimeInMs.call(this, this.map.getView().getZoom());
|
|
217
|
+
};
|
|
218
|
+
RealtimeLayer.prototype.getFeatureInfoAtCoordinate = function (coordinate, options) {
|
|
219
|
+
if (options === void 0) { options = {}; }
|
|
220
|
+
var resolution = this.map.getView().getResolution();
|
|
221
|
+
return _super.prototype.getFeatureInfoAtCoordinate.call(this, coordinate, __assign({ resolution: resolution }, options));
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* On move end we update the websocket with the new bbox.
|
|
225
|
+
*
|
|
226
|
+
* @private
|
|
227
|
+
* @override
|
|
228
|
+
*/
|
|
229
|
+
RealtimeLayer.prototype.onMoveEnd = function () {
|
|
230
|
+
if (this.visible && this.isUpdateBboxOnMoveEnd) {
|
|
231
|
+
this.setBbox();
|
|
81
232
|
}
|
|
82
|
-
this.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
this.vectorLayer.getSource().addFeatures(features);
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
clone(newOptions) {
|
|
184
|
-
return new RealtimeLayer({ ...this.options, ...newOptions });
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
export default RealtimeLayer;
|
|
233
|
+
if (this.visible &&
|
|
234
|
+
this.isUpdateBboxOnMoveEnd &&
|
|
235
|
+
this.userClickInteractions &&
|
|
236
|
+
this.selectedVehicleId) {
|
|
237
|
+
this.highlightTrajectory(this.selectedVehicleId);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Function called on moveend event only when the zoom has changed.
|
|
242
|
+
*
|
|
243
|
+
* @param {ol/MapEvent~MapEvent} evt Moveend event.
|
|
244
|
+
* @private
|
|
245
|
+
* @override
|
|
246
|
+
*/
|
|
247
|
+
// eslint-disable-next-line no-unused-vars
|
|
248
|
+
RealtimeLayer.prototype.onZoomEnd = function (evt) {
|
|
249
|
+
_super.prototype.onZoomEnd.call(this, evt);
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Update the cursor style when hovering a vehicle.
|
|
253
|
+
*
|
|
254
|
+
* @private
|
|
255
|
+
* @override
|
|
256
|
+
*/
|
|
257
|
+
RealtimeLayer.prototype.onFeatureHover = function (features, layer, coordinate) {
|
|
258
|
+
_super.prototype.onFeatureHover.call(this, features, layer, coordinate);
|
|
259
|
+
this.map.getTargetElement().style.cursor = features.length
|
|
260
|
+
? 'pointer'
|
|
261
|
+
: 'auto';
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Display the complete trajectory of the vehicle.
|
|
265
|
+
*
|
|
266
|
+
* @private
|
|
267
|
+
* @override
|
|
268
|
+
*/
|
|
269
|
+
RealtimeLayer.prototype.onFeatureClick = function (features, layer, coordinate) {
|
|
270
|
+
_super.prototype.onFeatureClick.call(this, features, layer, coordinate);
|
|
271
|
+
if (!features.length && this.vectorLayer) {
|
|
272
|
+
this.vectorLayer.getSource().clear();
|
|
273
|
+
}
|
|
274
|
+
if (this.selectedVehicleId) {
|
|
275
|
+
this.highlightTrajectory(this.selectedVehicleId);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Remove the trajectory form the list if necessary.
|
|
280
|
+
*
|
|
281
|
+
* @private
|
|
282
|
+
*/
|
|
283
|
+
RealtimeLayer.prototype.purgeTrajectory = function (trajectory, extent, zoom) {
|
|
284
|
+
return _super.prototype.purgeTrajectory.call(this, trajectory, extent || this.map.getView().calculateExtent(), zoom || this.map.getView().getZoom());
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Send the current bbox to the websocket
|
|
288
|
+
*
|
|
289
|
+
* @private
|
|
290
|
+
*/
|
|
291
|
+
RealtimeLayer.prototype.setBbox = function (extent, zoom) {
|
|
292
|
+
var newExtent = extent;
|
|
293
|
+
var newZoom = zoom;
|
|
294
|
+
if (!newExtent && this.isUpdateBboxOnMoveEnd) {
|
|
295
|
+
newExtent = extent || this.map.getView().calculateExtent();
|
|
296
|
+
newZoom = Math.floor(this.map.getView().getZoom());
|
|
297
|
+
}
|
|
298
|
+
_super.prototype.setBbox.call(this, newExtent, newZoom);
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Highlight the trajectory of journey.
|
|
302
|
+
* @private
|
|
303
|
+
*/
|
|
304
|
+
RealtimeLayer.prototype.highlightTrajectory = function (id) {
|
|
305
|
+
var _this = this;
|
|
306
|
+
this.api
|
|
307
|
+
.getFullTrajectory(id, this.mode, this.generalizationLevel)
|
|
308
|
+
.then(function (fullTrajectory) {
|
|
309
|
+
var vectorSource = _this.vectorLayer.getSource();
|
|
310
|
+
vectorSource.clear();
|
|
311
|
+
if (!fullTrajectory ||
|
|
312
|
+
!fullTrajectory.features ||
|
|
313
|
+
!fullTrajectory.features.length) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
var features = format.readFeatures(fullTrajectory);
|
|
317
|
+
_this.vectorLayer.getSource().addFeatures(features);
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Create a copy of the RealtimeLayer.
|
|
322
|
+
* @param {Object} newOptions Options to override
|
|
323
|
+
* @return {RealtimeLayer} A RealtimeLayer
|
|
324
|
+
*/
|
|
325
|
+
RealtimeLayer.prototype.clone = function (newOptions) {
|
|
326
|
+
return new RealtimeLayer(__assign(__assign({}, this.options), newOptions));
|
|
327
|
+
};
|
|
328
|
+
return RealtimeLayer;
|
|
329
|
+
}((0, RealtimeLayerMixin_1.default)(Layer_1.default)));
|
|
330
|
+
exports.default = RealtimeLayer;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default RoutingLayer;
|
|
2
|
+
/**
|
|
3
|
+
* A class use to display vector data.
|
|
4
|
+
*
|
|
5
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
6
|
+
* @extends {Layer}
|
|
7
|
+
*/
|
|
8
|
+
declare class RoutingLayer extends Layer {
|
|
9
|
+
/**
|
|
10
|
+
* Constructor.
|
|
11
|
+
* @param {Object} [options]
|
|
12
|
+
* @param {ol/style/Style~StyleLike} [options.style] Style to be used for routes, uses (ol/StyleLike) [https://openlayers.org/en/latest/apidoc/module-ol_style_Style.html#~StyleLike] instances
|
|
13
|
+
*/
|
|
14
|
+
constructor(options?: any);
|
|
15
|
+
olLayer: any;
|
|
16
|
+
/**
|
|
17
|
+
* Create a copy of the RoutingLayer.
|
|
18
|
+
* @param {Object} newOptions Options to override
|
|
19
|
+
* @return {RoutingLayer} A RoutingLayer
|
|
20
|
+
*/
|
|
21
|
+
clone(newOptions: any): RoutingLayer;
|
|
22
|
+
}
|
|
23
|
+
import Layer from "./Layer";
|
|
24
|
+
//# sourceMappingURL=RoutingLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoutingLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/RoutingLayer.js"],"names":[],"mappings":";AA8DA;;;;;GAKG;AACH;IACE;;;;OAIG;IACH,2BASC;IANC,aAKI;IAGN;;;;OAIG;IACH,wBAFY,YAAY,CAIvB;CACF"}
|