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.
@@ -91,8 +91,8 @@ class RoutingControl extends Control {
91
91
  view.getResolutionForZoom(maxZoom || minZoom + 1)
92
92
  ]);
93
93
  }
94
- addViaPoint(coordinatesOrString, index = this.viaPoints.length, overwrite = 0) {
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/SearchMixin";
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 tralisMixin from "../../common/mixins/TralisLayerMixin";
7
+ import mixin from "../../common/mixins/RealtimeLayerMixin";
8
8
  import { fullTrajectoryStyle } from "../styles";
9
9
  const format = new GeoJSON();
10
- class TralisLayer extends tralisMixin(Layer) {
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 TralisLayer({ ...this.options, ...newOptions });
180
+ return new RealtimeLayer({ ...this.options, ...newOptions });
181
181
  }
182
182
  }
183
- export default TralisLayer;
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 TralisLayer from "./TralisLayer";
5
+ import RealtimeLayer from "./RealtimeLayer";
6
6
  let layer;
7
7
  let onClick;
8
8
  let olMap;
9
9
  let server;
10
- describe("TralisLayer", () => {
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 TralisLayer({
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(TralisLayer);
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(TralisLayer);
45
+ expect(clone).toBeInstanceOf(RealtimeLayer);
46
46
  });
47
47
  test("should use the sort function.", () => {
48
48
  const fn = () => true;
49
- const laye = new TralisLayer({
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(TralisLayer);
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 TralisLayer({
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(TralisLayer);
64
+ expect(laye).toBeInstanceOf(RealtimeLayer);
65
65
  expect(laye.filter).toBe(fn);
66
66
  });
67
67
  });
@@ -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 TralisLayer } from "./TralisLayer";
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.24",
5
+ "version": "2.0.0-beta.27",
6
6
  "main": "index.js",
7
7
  "exports": {
8
8
  ".": "./index.js",
@@ -1,8 +0,0 @@
1
- import trackerDefaultStyle from "./trackerDefaultStyle";
2
- const style = (trajectory, viewState, options) => {
3
- return trackerDefaultStyle(trajectory, viewState, {
4
- ...options,
5
- useDelayStyle: true
6
- });
7
- };
8
- export default style;
@@ -1,10 +0,0 @@
1
- import TralisLayer from "./TralisLayer";
2
- let layer;
3
- describe("TralisLayer", () => {
4
- beforeEach(() => {
5
- layer = new TralisLayer();
6
- });
7
- test("should be instanced.", () => {
8
- expect(layer).toBeInstanceOf(TralisLayer);
9
- });
10
- });