mobility-toolbox-js 2.0.0-beta.33 → 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.
Files changed (69) hide show
  1. package/api/RealtimeAPI.js +640 -0
  2. package/api/RoutingAPI.js +65 -0
  3. package/api/StopsAPI.js +70 -0
  4. package/api/index.js +10 -0
  5. package/api/typedefs.js +72 -0
  6. package/common/api/HttpAPI.d.ts +2 -2
  7. package/common/api/HttpAPI.d.ts.map +1 -1
  8. package/common/api/HttpAPI.js +84 -0
  9. package/common/api/WebSocketAPI.js +320 -0
  10. package/common/controls/Control.js +170 -0
  11. package/common/index.js +18 -0
  12. package/common/layers/Layer.js +257 -0
  13. package/common/mixins/CopyrightMixin.js +72 -0
  14. package/common/mixins/MapboxLayerMixin.js +240 -0
  15. package/common/mixins/RealtimeLayerMixin.js +705 -0
  16. package/common/mixins/StopFinderMixin.js +198 -0
  17. package/common/mixins/UserInteractionsLayerMixin.js +225 -0
  18. package/common/styles/index.js +24 -0
  19. package/common/styles/realtimeDefaultStyle.js +248 -0
  20. package/common/styles/realtimeDelayStyle.js +26 -0
  21. package/common/styles/realtimeSimpleStyle.js +24 -0
  22. package/common/typedefs.js +21 -0
  23. package/common/utils/cleanStopTime.js +30 -0
  24. package/common/utils/compareDepartures.js +37 -0
  25. package/common/utils/createCanvas.js +29 -0
  26. package/common/utils/createTrackerFilters.js +77 -0
  27. package/common/utils/getLayersAsFlatArray.js +16 -0
  28. package/common/utils/getMapboxMapCopyrights.js +26 -0
  29. package/common/utils/getMapboxRender.js +77 -0
  30. package/common/utils/getMaplibreRender.js +38 -0
  31. package/common/utils/getRealtimeModeSuffix.js +11 -0
  32. package/common/utils/getUrlWithParams.js +21 -0
  33. package/common/utils/getVehiclePosition.js +66 -0
  34. package/common/utils/index.js +37 -0
  35. package/common/utils/removeDuplicate.js +30 -0
  36. package/common/utils/renderTrajectories.js +119 -0
  37. package/common/utils/sortByDelay.js +22 -0
  38. package/common/utils/timeUtils.js +49 -0
  39. package/common/utils/trackerConfig.js +182 -0
  40. package/iife.js +7 -0
  41. package/index.js +11 -0
  42. package/mapbox/controls/CopyrightControl.js +73 -0
  43. package/mapbox/controls/index.js +6 -0
  44. package/mapbox/index.js +20 -0
  45. package/mapbox/layers/Layer.js +139 -0
  46. package/mapbox/layers/RealtimeLayer.js +312 -0
  47. package/mapbox/layers/index.js +7 -0
  48. package/mapbox/utils.js +57 -0
  49. package/mbt.js.map +2 -2
  50. package/mbt.min.js.map +2 -2
  51. package/ol/controls/CopyrightControl.js +90 -0
  52. package/ol/controls/RoutingControl.js +683 -0
  53. package/ol/controls/StopFinderControl.js +59 -0
  54. package/ol/controls/index.js +9 -0
  55. package/ol/index.js +21 -0
  56. package/ol/layers/Layer.js +180 -0
  57. package/ol/layers/MapboxLayer.js +137 -0
  58. package/ol/layers/MapboxStyleLayer.js +383 -0
  59. package/ol/layers/MaplibreLayer.js +69 -0
  60. package/ol/layers/RealtimeLayer.js +330 -0
  61. package/ol/layers/RoutingLayer.js +116 -0
  62. package/ol/layers/VectorLayer.js +72 -0
  63. package/ol/layers/WMSLayer.js +106 -0
  64. package/ol/layers/index.js +19 -0
  65. package/ol/styles/fullTrajectoryDelayStyle.js +35 -0
  66. package/ol/styles/fullTrajectoryStyle.js +46 -0
  67. package/ol/styles/index.js +7 -0
  68. package/package.json +1 -1
  69. package/setupTests.js +15 -0
@@ -0,0 +1,90 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ var Layer_1 = require("ol/layer/Layer");
19
+ var Control_1 = require("../../common/controls/Control");
20
+ var CopyrightMixin_1 = require("../../common/mixins/CopyrightMixin");
21
+ var removeDuplicate_1 = require("../../common/utils/removeDuplicate");
22
+ /**
23
+ * Display layer's copyrights.
24
+ *
25
+ * @example
26
+ * import { Map } from 'ol';
27
+ * import { CopyrightControl } from 'mobility-toolbox-js/ol';
28
+ *
29
+ * const map = new Map({
30
+ * target: 'map',
31
+ * });
32
+ * const control = new CopyrightControl();
33
+ * control.attachToMap(map)
34
+ *
35
+ *
36
+ * @see <a href="/example/ol-copyright">Openlayers copyright example</a>
37
+ *
38
+ * @extends {Control}
39
+ * @implements {CopyrightInterface}
40
+ */
41
+ var CopyrightControl = /** @class */ (function (_super) {
42
+ __extends(CopyrightControl, _super);
43
+ function CopyrightControl(options) {
44
+ var _this = _super.call(this, options) || this;
45
+ _this.onPostRender = _this.onPostRender.bind(_this);
46
+ return _this;
47
+ }
48
+ CopyrightControl.prototype.getCopyrights = function () {
49
+ var _this = this;
50
+ if (!this.frameState) {
51
+ return [];
52
+ }
53
+ var copyrights = [];
54
+ // This code loop comes mainly from ol.
55
+ this.frameState.layerStatesArray.forEach(function (layerState) {
56
+ var layer = layerState.layer;
57
+ if ((0, Layer_1.inView)(layerState, _this.frameState.viewState) &&
58
+ layer &&
59
+ layer.getSource &&
60
+ layer.getSource() &&
61
+ layer.getSource().getAttributions()) {
62
+ copyrights = copyrights.concat(layer.getSource().getAttributions()(_this.frameState));
63
+ }
64
+ });
65
+ return (0, removeDuplicate_1.default)(copyrights);
66
+ };
67
+ CopyrightControl.prototype.activate = function () {
68
+ _super.prototype.activate.call(this);
69
+ if (this.map) {
70
+ this.map.on('postrender', this.onPostRender);
71
+ }
72
+ };
73
+ CopyrightControl.prototype.deactivate = function () {
74
+ if (this.map) {
75
+ this.map.un('postrender', this.onPostRender);
76
+ }
77
+ _super.prototype.deactivate.call(this);
78
+ };
79
+ CopyrightControl.prototype.onPostRender = function (evt) {
80
+ if (this.map && this.element) {
81
+ /**
82
+ * @ignore
83
+ */
84
+ this.frameState = evt.frameState;
85
+ this.render();
86
+ }
87
+ };
88
+ return CopyrightControl;
89
+ }((0, CopyrightMixin_1.default)(Control_1.default)));
90
+ exports.default = CopyrightControl;