mobility-toolbox-js 2.0.0-beta.24 → 2.0.0-beta.27
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/{TralisAPI.js → RealtimeAPI.js} +16 -18
- package/api/{TralisAPI.test.js → RealtimeAPI.test.js} +11 -11
- package/api/index.js +1 -1
- package/common/mixins/{TralisLayerMixin.js → RealtimeLayerMixin.js} +9 -9
- package/common/mixins/{SearchMixin.js → StopFinderMixin.js} +3 -3
- package/common/styles/index.js +4 -4
- package/common/styles/{trackerDefaultStyle.js → realtimeDefaultStyle.js} +7 -7
- package/common/styles/realtimeDelayStyle.js +8 -0
- package/common/styles/{trackerSimpleStyle.js → realtimeSimpleStyle.js} +2 -2
- package/common/utils/cleanStopTime.js +19 -0
- package/{api/TralisAPIUtils.js → common/utils/compareDepartures.js} +2 -20
- package/common/utils/getRealtimeModeSuffix.js +2 -0
- package/mapbox/layers/{TralisLayer.js → RealtimeLayer.js} +6 -3
- package/mapbox/layers/RealtimeLayer.test.js +10 -0
- package/mapbox/layers/index.js +1 -1
- package/mbt.js +219 -209
- package/mbt.js.map +3 -3
- package/mbt.min.js +6 -6
- package/mbt.min.js.map +3 -3
- package/ol/controls/RoutingControl.js +2 -2
- package/ol/controls/StopFinderControl.js +1 -1
- package/ol/layers/{TralisLayer.js → RealtimeLayer.js} +4 -4
- package/ol/layers/{TralisLayer.test.js → RealtimeLayer.test.js} +9 -9
- package/ol/layers/index.js +1 -1
- package/package.json +1 -1
- package/common/styles/trackerDelayStyle.js +0 -8
- package/mapbox/layers/TralisLayer.test.js +0 -10
|
@@ -91,8 +91,8 @@ class RoutingControl extends Control {
|
|
|
91
91
|
view.getResolutionForZoom(maxZoom || minZoom + 1)
|
|
92
92
|
]);
|
|
93
93
|
}
|
|
94
|
-
addViaPoint(coordinatesOrString, index =
|
|
95
|
-
this.viaPoints.splice(index, overwrite, coordinatesOrString);
|
|
94
|
+
addViaPoint(coordinatesOrString, index = -1, overwrite = 0) {
|
|
95
|
+
this.viaPoints.splice(index === -1 ? this.viaPoints.length : index, overwrite, coordinatesOrString);
|
|
96
96
|
this.drawRoute();
|
|
97
97
|
this.dispatchEvent({
|
|
98
98
|
type: "change:route",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fromLonLat } from "ol/proj";
|
|
2
2
|
import Control from "../../common/controls/Control";
|
|
3
|
-
import mixin from "../../common/mixins/
|
|
3
|
+
import mixin from "../../common/mixins/StopFinderMixin";
|
|
4
4
|
class StopFinderControl extends mixin(Control) {
|
|
5
5
|
onSuggestionClick({ geometry }) {
|
|
6
6
|
const coord = fromLonLat(geometry.coordinates);
|
|
@@ -4,10 +4,10 @@ import Source from "ol/source/Source";
|
|
|
4
4
|
import { composeCssTransform } from "ol/transform";
|
|
5
5
|
import { Vector as VectorSource } from "ol/source";
|
|
6
6
|
import Layer from "./Layer";
|
|
7
|
-
import
|
|
7
|
+
import mixin from "../../common/mixins/RealtimeLayerMixin";
|
|
8
8
|
import { fullTrajectoryStyle } from "../styles";
|
|
9
9
|
const format = new GeoJSON();
|
|
10
|
-
class
|
|
10
|
+
class RealtimeLayer extends mixin(Layer) {
|
|
11
11
|
constructor(options = {}) {
|
|
12
12
|
super({
|
|
13
13
|
...options
|
|
@@ -177,7 +177,7 @@ class TralisLayer extends tralisMixin(Layer) {
|
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
clone(newOptions) {
|
|
180
|
-
return new
|
|
180
|
+
return new RealtimeLayer({ ...this.options, ...newOptions });
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
export default
|
|
183
|
+
export default RealtimeLayer;
|
|
@@ -2,18 +2,18 @@ import fetch from "jest-fetch-mock";
|
|
|
2
2
|
import Map from "ol/Map";
|
|
3
3
|
import View from "ol/View";
|
|
4
4
|
import WS from "jest-websocket-mock";
|
|
5
|
-
import
|
|
5
|
+
import RealtimeLayer from "./RealtimeLayer";
|
|
6
6
|
let layer;
|
|
7
7
|
let onClick;
|
|
8
8
|
let olMap;
|
|
9
9
|
let server;
|
|
10
|
-
describe("
|
|
10
|
+
describe("RealtimeLayer", () => {
|
|
11
11
|
beforeEach(() => {
|
|
12
12
|
server = new WS("ws://localhost:1234");
|
|
13
13
|
global.fetch = fetch;
|
|
14
14
|
fetch.resetMocks();
|
|
15
15
|
onClick = jest.fn();
|
|
16
|
-
layer = new
|
|
16
|
+
layer = new RealtimeLayer({
|
|
17
17
|
url: "ws://localhost:1234",
|
|
18
18
|
apiKey: "apiKey",
|
|
19
19
|
onClick
|
|
@@ -30,7 +30,7 @@ describe("TralisLayer", () => {
|
|
|
30
30
|
WS.clean();
|
|
31
31
|
});
|
|
32
32
|
test("should be instanced.", () => {
|
|
33
|
-
expect(layer).toBeInstanceOf(
|
|
33
|
+
expect(layer).toBeInstanceOf(RealtimeLayer);
|
|
34
34
|
});
|
|
35
35
|
test("should called terminate on initalization.", () => {
|
|
36
36
|
const spy = jest.spyOn(layer, "detachFromMap");
|
|
@@ -42,26 +42,26 @@ describe("TralisLayer", () => {
|
|
|
42
42
|
const clone = layer.clone({ name: "clone" });
|
|
43
43
|
expect(clone).not.toBe(layer);
|
|
44
44
|
expect(clone.name).toBe("clone");
|
|
45
|
-
expect(clone).toBeInstanceOf(
|
|
45
|
+
expect(clone).toBeInstanceOf(RealtimeLayer);
|
|
46
46
|
});
|
|
47
47
|
test("should use the sort function.", () => {
|
|
48
48
|
const fn = () => true;
|
|
49
|
-
const laye = new
|
|
49
|
+
const laye = new RealtimeLayer({
|
|
50
50
|
url: "ws://localhost:1234",
|
|
51
51
|
apiKey: "apiKey",
|
|
52
52
|
sort: fn
|
|
53
53
|
});
|
|
54
|
-
expect(laye).toBeInstanceOf(
|
|
54
|
+
expect(laye).toBeInstanceOf(RealtimeLayer);
|
|
55
55
|
expect(laye.sort).toBe(fn);
|
|
56
56
|
});
|
|
57
57
|
test("should use filter function.", () => {
|
|
58
58
|
const fn = () => true;
|
|
59
|
-
const laye = new
|
|
59
|
+
const laye = new RealtimeLayer({
|
|
60
60
|
url: "ws://localhost:1234",
|
|
61
61
|
apiKey: "apiKey",
|
|
62
62
|
filter: fn
|
|
63
63
|
});
|
|
64
|
-
expect(laye).toBeInstanceOf(
|
|
64
|
+
expect(laye).toBeInstanceOf(RealtimeLayer);
|
|
65
65
|
expect(laye.filter).toBe(fn);
|
|
66
66
|
});
|
|
67
67
|
});
|
package/ol/layers/index.js
CHANGED
|
@@ -3,6 +3,6 @@ export { default as MapboxLayer } from "./MapboxLayer";
|
|
|
3
3
|
export { default as MaplibreLayer } from "./MaplibreLayer";
|
|
4
4
|
export { default as MapboxStyleLayer } from "./MapboxStyleLayer";
|
|
5
5
|
export { default as RoutingLayer } from "./RoutingLayer";
|
|
6
|
-
export { default as
|
|
6
|
+
export { default as RealtimeLayer } from "./RealtimeLayer";
|
|
7
7
|
export { default as VectorLayer } from "./VectorLayer";
|
|
8
8
|
export { default as WMSLayer } from "./WMSLayer";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "mobility-toolbox-js",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
|
|
5
|
-
"version": "2.0.0-beta.
|
|
5
|
+
"version": "2.0.0-beta.27",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.js",
|