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
|
@@ -0,0 +1,240 @@
|
|
|
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
|
+
exports.MapboxLayerInterface = void 0;
|
|
30
|
+
/* eslint-disable max-classes-per-file */
|
|
31
|
+
var proj_1 = require("ol/proj");
|
|
32
|
+
var Layer_1 = require("ol/layer/Layer");
|
|
33
|
+
var Source_1 = require("ol/source/Source");
|
|
34
|
+
var GeoJSON_1 = require("ol/format/GeoJSON");
|
|
35
|
+
var utils_1 = require("../utils");
|
|
36
|
+
/**
|
|
37
|
+
* MapboxLayerInterface
|
|
38
|
+
*/
|
|
39
|
+
var MapboxLayerInterface = /** @class */ (function () {
|
|
40
|
+
function MapboxLayerInterface() {
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Return the render function function for the ol layer.
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
// eslint-disable-next-line class-methods-use-this
|
|
47
|
+
MapboxLayerInterface.prototype.getOlLayerRender = function () { };
|
|
48
|
+
/**
|
|
49
|
+
* Return the Class to instanciate for the mapbox map.
|
|
50
|
+
*
|
|
51
|
+
* @return {mapboxgl.Map|maplibregl.Map} map
|
|
52
|
+
*/
|
|
53
|
+
// eslint-disable-next-line class-methods-use-this
|
|
54
|
+
MapboxLayerInterface.prototype.getMapboxMapClass = function () { };
|
|
55
|
+
return MapboxLayerInterface;
|
|
56
|
+
}());
|
|
57
|
+
exports.MapboxLayerInterface = MapboxLayerInterface;
|
|
58
|
+
/**
|
|
59
|
+
* Mixin for MapboxLayerLayerInterface.
|
|
60
|
+
* It's used to share code between Mapbox and Maplibre layers without importing both libs
|
|
61
|
+
*
|
|
62
|
+
* @param {Class} Base A class to extend with {MapboxLayerLayerInterface} functionnalities.
|
|
63
|
+
* @return {Class} A class that implements {MapboxLayerLayerInterface} class and extends Base;
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
var MapboxLayerMixin = function (Base) {
|
|
67
|
+
return /** @class */ (function (_super) {
|
|
68
|
+
__extends(class_1, _super);
|
|
69
|
+
function class_1(options) {
|
|
70
|
+
if (options === void 0) { options = {}; }
|
|
71
|
+
var _this = _super.call(this, options) || this;
|
|
72
|
+
_this.olLayer = new Layer_1.default({
|
|
73
|
+
source: new Source_1.default({}),
|
|
74
|
+
render: _this.getOlLayerRender(_this),
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Url of the mapbox style.
|
|
78
|
+
* @type {string}
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
_this.styleUrl = options.url;
|
|
82
|
+
/**
|
|
83
|
+
* Api key for the url of the mapbox style.
|
|
84
|
+
* If set to false, the apiKey is not required.
|
|
85
|
+
* @type {string}
|
|
86
|
+
* @private
|
|
87
|
+
*/
|
|
88
|
+
_this.apiKey = options.apiKey;
|
|
89
|
+
/**
|
|
90
|
+
* Name of the apiKey to set in the url request.
|
|
91
|
+
* Default is 'key'.
|
|
92
|
+
* @type {string}
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
_this.apiKeyName = options.apiKeyName || 'key';
|
|
96
|
+
/** @ignore */
|
|
97
|
+
_this.updateAttribution = _this.updateAttribution.bind(_this);
|
|
98
|
+
return _this;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Initialize the layer and listen to feature clicks.
|
|
102
|
+
* @param {ol/Map~Map} map
|
|
103
|
+
*/
|
|
104
|
+
class_1.prototype.attachToMap = function (map) {
|
|
105
|
+
_super.prototype.attachToMap.call(this, map);
|
|
106
|
+
if (!this.map) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The feature format.
|
|
111
|
+
* @type {ol/format/GeoJSON}
|
|
112
|
+
*/
|
|
113
|
+
this.format = new GeoJSON_1.default({
|
|
114
|
+
featureProjection: this.map.getView().getProjection(),
|
|
115
|
+
});
|
|
116
|
+
this.loadMbMap();
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
120
|
+
*/
|
|
121
|
+
class_1.prototype.detachFromMap = function () {
|
|
122
|
+
if (this.mbMap) {
|
|
123
|
+
this.mbMap.off('idle', this.updateAttribution);
|
|
124
|
+
// Some asynchrone repaints are triggered even if the mbMap has been removed,
|
|
125
|
+
// to avoid display of errors we set an empty function.
|
|
126
|
+
this.mbMap.triggerRepaint = function () { };
|
|
127
|
+
this.mbMap.remove();
|
|
128
|
+
this.mbMap = null;
|
|
129
|
+
}
|
|
130
|
+
this.loaded = false;
|
|
131
|
+
_super.prototype.detachFromMap.call(this);
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Create the mapbox map.
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
class_1.prototype.loadMbMap = function () {
|
|
138
|
+
var _a;
|
|
139
|
+
var _this = this;
|
|
140
|
+
this.olListenersKeys.push(this.map.on('change:target', function () {
|
|
141
|
+
_this.loadMbMap();
|
|
142
|
+
}));
|
|
143
|
+
if (!this.map.getTargetElement()) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (!this.visible) {
|
|
147
|
+
// On next change of visibility we load the map
|
|
148
|
+
this.olListenersKeys.push(this.once('change:visible', function () {
|
|
149
|
+
_this.loadMbMap();
|
|
150
|
+
}));
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
var container = document.createElement('div');
|
|
154
|
+
container.style.position = 'absolute';
|
|
155
|
+
container.style.width = '100%';
|
|
156
|
+
container.style.height = '100%';
|
|
157
|
+
if (!this.apiKey && !this.styleUrl.includes(this.apiKeyName)) {
|
|
158
|
+
// eslint-disable-next-line no-console
|
|
159
|
+
console.error("No apiKey defined for mapbox layer with style url to ".concat(this.styleUrl));
|
|
160
|
+
}
|
|
161
|
+
var Map = this.getMapboxMapClass();
|
|
162
|
+
/**
|
|
163
|
+
* A mapbox map
|
|
164
|
+
* @type {mapboxgl.Map}
|
|
165
|
+
*/
|
|
166
|
+
this.mbMap = new Map(__assign({ style: (0, utils_1.getUrlWithParams)(this.styleUrl, (_a = {},
|
|
167
|
+
_a[this.apiKeyName] = this.apiKey,
|
|
168
|
+
_a)).toString(), container: container, interactive: false, trackResize: false, attributionControl: false }, (this.options.mapOptions || {})));
|
|
169
|
+
this.mbMap.once('load', function () {
|
|
170
|
+
/**
|
|
171
|
+
* Is the map loaded.
|
|
172
|
+
* @type {boolean}
|
|
173
|
+
*/
|
|
174
|
+
_this.loaded = true;
|
|
175
|
+
_this.dispatchEvent({
|
|
176
|
+
type: 'load',
|
|
177
|
+
target: _this,
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
this.mbMap.on('idle', this.updateAttribution);
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Update attributions of the source.
|
|
184
|
+
* @private
|
|
185
|
+
*/
|
|
186
|
+
class_1.prototype.updateAttribution = function (evt) {
|
|
187
|
+
var _a, _b;
|
|
188
|
+
var newAttributions = (0, utils_1.getMapboxMapCopyrights)(evt.target) || [];
|
|
189
|
+
if (((_a = this.copyrights) === null || _a === void 0 ? void 0 : _a.toString()) !== newAttributions.toString()) {
|
|
190
|
+
this.copyrights = newAttributions;
|
|
191
|
+
(_b = this.olLayer.getSource()) === null || _b === void 0 ? void 0 : _b.setAttributions(newAttributions);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Request feature information for a given coordinate.
|
|
196
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
197
|
+
* @param {Object} options A [mapboxgl.Map#queryrenderedfeatures](https://docs.mapbox.com/mapbox-gl-js/api/map/#map#queryrenderedfeatures) options parameter.
|
|
198
|
+
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate. The original Mapbox feature is available as a property named 'mapboxFeature'.
|
|
199
|
+
*/
|
|
200
|
+
class_1.prototype.getFeatureInfoAtCoordinate = function (coordinate, options) {
|
|
201
|
+
var _this = this;
|
|
202
|
+
// Ignore the getFeatureInfo until the mapbox map is loaded
|
|
203
|
+
if (!options ||
|
|
204
|
+
!this.format ||
|
|
205
|
+
!this.mbMap ||
|
|
206
|
+
!this.mbMap.isStyleLoaded()) {
|
|
207
|
+
return Promise.resolve({ coordinate: coordinate, features: [], layer: this });
|
|
208
|
+
}
|
|
209
|
+
var pixel = coordinate && this.mbMap.project((0, proj_1.toLonLat)(coordinate));
|
|
210
|
+
if (this.hitTolerance) {
|
|
211
|
+
var x = pixel.x, y = pixel.y;
|
|
212
|
+
pixel = [
|
|
213
|
+
{ x: x - this.hitTolerance, y: y - this.hitTolerance },
|
|
214
|
+
{ x: x + this.hitTolerance, y: y + this.hitTolerance },
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
// At this point we get GeoJSON Mapbox feature, we transform it to an OpenLayers
|
|
218
|
+
// feature to be consistent with other layers.
|
|
219
|
+
var features = this.mbMap
|
|
220
|
+
.queryRenderedFeatures(pixel, options)
|
|
221
|
+
.map(function (feature) {
|
|
222
|
+
var olFeature = _this.format.readFeature(feature);
|
|
223
|
+
if (olFeature) {
|
|
224
|
+
// We save the original mapbox feature to avoid losing informations
|
|
225
|
+
// potentially needed for other functionnality like highlighting
|
|
226
|
+
// (id, layer id, source, sourceLayer ...)
|
|
227
|
+
olFeature.set('mapboxFeature', feature);
|
|
228
|
+
}
|
|
229
|
+
return olFeature;
|
|
230
|
+
});
|
|
231
|
+
return Promise.resolve({
|
|
232
|
+
layer: this,
|
|
233
|
+
features: features,
|
|
234
|
+
coordinate: coordinate,
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
return class_1;
|
|
238
|
+
}(Base));
|
|
239
|
+
};
|
|
240
|
+
exports.default = MapboxLayerMixin;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RealtimeLayerInterface.
|
|
3
|
+
*/
|
|
4
|
+
export class RealtimeLayerInterface {
|
|
5
|
+
constructor(options?: {});
|
|
6
|
+
/**
|
|
7
|
+
* Initialize the layer subscribing to the Realtime api.
|
|
8
|
+
*
|
|
9
|
+
* @param {ol/Map~Map} map
|
|
10
|
+
*/
|
|
11
|
+
attachToMap(map: any): void;
|
|
12
|
+
/**
|
|
13
|
+
* Terminate the layer unsubscribing to the Realtime api.
|
|
14
|
+
*/
|
|
15
|
+
detachFromMap(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Start the clock.
|
|
18
|
+
*/
|
|
19
|
+
start(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Stop the clock.
|
|
22
|
+
*/
|
|
23
|
+
stop(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Set the Realtime api's bbox.
|
|
26
|
+
*
|
|
27
|
+
* @param {Array<number>} extent Extent to request, [minX, minY, maxX, maxY, zoom].
|
|
28
|
+
* @param {number} zoom Zoom level to request. Must be an integer.
|
|
29
|
+
*/
|
|
30
|
+
setBbox(extent: Array<number>, zoom: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* Set the Realtime api's mode.
|
|
33
|
+
*
|
|
34
|
+
* @param {RealtimeMode} mode Realtime mode
|
|
35
|
+
*/
|
|
36
|
+
setMode(mode: RealtimeMode): void;
|
|
37
|
+
/**
|
|
38
|
+
* Request the stopSequence and the fullTrajectory informations for a vehicle.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} id The vehicle identifier (the train_id property).
|
|
41
|
+
* @param {RealtimeMode} mode The mode to request. If not defined, the layer´s mode propetrty will be used.
|
|
42
|
+
* @return {Promise<{stopSequence: StopSequence, fullTrajectory: FullTrajectory>} A promise that will be resolved with the trajectory informations.
|
|
43
|
+
*/
|
|
44
|
+
getTrajectoryInfos(id: string, mode: RealtimeMode): Promise<{
|
|
45
|
+
stopSequence: StopSequence;
|
|
46
|
+
fullTrajectory: FullTrajectory;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export default RealtimeLayerMixin;
|
|
50
|
+
/**
|
|
51
|
+
* Mixin for RealtimeLayerInterface.
|
|
52
|
+
*
|
|
53
|
+
* @param {Class} Base A class to extend with {RealtimeLayerInterface} functionnalities.
|
|
54
|
+
* @return {Class} A class that implements {RealtimeLayerInterface} class and extends Base;
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
declare function RealtimeLayerMixin(Base: Class): Class;
|
|
58
|
+
//# sourceMappingURL=RealtimeLayerMixin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RealtimeLayerMixin.d.ts","sourceRoot":"","sources":["../../../src/common/mixins/RealtimeLayerMixin.js"],"names":[],"mappings":"AAgBA;;GAEG;AACH;IAYE,0BAA4B;IAE5B;;;;OAIG;IACH,4BAAmB;IAEnB;;OAEG;IACH,sBAAkB;IAElB;;OAEG;IACH,cAAU;IAEV;;OAEG;IACH,aAAS;IAET;;;;;OAKG;IACH,gBAHW,MAAM,MAAM,CAAC,QACb,MAAM,QAEO;IAExB;;;;OAIG;IACH,kCAAgB;IAEhB;;;;;;OAMG;IACH,uBAJW,MAAM,uBAEL,QAAQ;QAAC,YAAY,EAAE,YAAY,CAAC;QAAC,cAAc,EAAE,cAAc,CAAA;KAAA,CAAC,CAEjD;CAChC;;AAED;;;;;;GAMG;AACH,wDA8tBG"}
|