mobility-toolbox-js 2.0.0 → 2.0.1-beta.13
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/RoutingAPI.js +15 -0
- package/api/RoutingAPI.test.js +25 -0
- package/api/StopsAPI.js +12 -0
- package/api/StopsAPI.test.js +22 -0
- package/api/TralisAPI.js +359 -0
- package/api/TralisAPI.test.js +67 -0
- package/api/{tralis/TralisAPIUtils.js → TralisAPIUtils.js} +2 -32
- package/api/index.js +3 -3
- package/{ol/README.md → api/typedefs.js} +0 -0
- package/common/Tracker.js +14 -118
- package/common/api/HttpAPI.js +30 -0
- package/common/api/HttpAPI.test.js +50 -0
- package/common/api/WebSocketAPI.js +175 -0
- package/{api/tralis/WebSocketConnector.test.js → common/api/WebSocketAPI.test.js} +100 -145
- package/common/controls/Control.js +26 -91
- package/common/controls/Control.test.js +32 -43
- package/common/index.js +4 -0
- package/common/layers/Layer.js +53 -244
- package/common/layers/Layer.test.js +185 -244
- package/common/mixins/CopyrightMixin.js +20 -44
- package/common/mixins/SearchMixin.js +100 -166
- package/common/mixins/TralisLayerMixin.js +443 -894
- package/common/styles/index.js +4 -4
- package/common/styles/trackerDefaultStyle.js +39 -175
- package/common/styles/trackerDelayStyle.js +2 -11
- package/common/styles/trackerSimpleStyle.js +4 -8
- package/common/trackerConfig.js +61 -99
- package/common/trackerConfig.test.js +15 -17
- package/common/typedefs.js +0 -23
- package/common/utils/createTrackerFilters.js +10 -41
- package/common/utils/createTrackerFilters.test.js +40 -56
- package/common/utils/getMapboxMapCopyrights.js +3 -16
- package/common/utils/getMapboxMapCopyrights.test.js +32 -39
- package/common/utils/getMapboxStyleUrl.js +3 -13
- package/common/utils/getVehiclePosition.js +3 -33
- package/common/utils/index.js +5 -6
- package/common/utils/removeDuplicate.js +3 -17
- package/common/utils/removeDuplicate.test.js +17 -20
- package/common/utils/sortByDelay.js +2 -7
- package/common/utils/timeUtils.js +8 -32
- package/common/utils/timeUtils.test.js +7 -13
- package/index.js +8 -2
- package/mapbox/controls/CopyrightControl.js +9 -38
- package/mapbox/controls/index.js +1 -0
- package/mapbox/index.js +4 -3
- package/mapbox/layers/Layer.js +15 -76
- package/mapbox/layers/Layer.test.js +81 -101
- package/mapbox/layers/TralisLayer.js +46 -193
- package/mapbox/layers/TralisLayer.test.js +12 -14
- package/mapbox/layers/index.js +2 -0
- package/mapbox/utils.js +7 -21
- package/mbt.js +50444 -0
- package/mbt.js.map +7 -0
- package/mbt.min.js +1005 -0
- package/mbt.min.js.map +7 -0
- package/ol/controls/CopyrightControl.js +8 -46
- package/ol/controls/CopyrightControl.test.js +75 -121
- package/ol/controls/RoutingControl.js +167 -532
- package/ol/controls/RoutingControl.test.js +99 -164
- package/ol/controls/StopFinderControl.js +3 -31
- package/ol/controls/StopFinderControl.test.js +18 -29
- package/ol/controls/index.js +3 -0
- package/ol/index.js +5 -13
- package/ol/layers/Layer.js +23 -128
- package/ol/layers/Layer.test.js +79 -102
- package/ol/layers/MapboxLayer.js +62 -237
- package/ol/layers/MapboxLayer.test.js +58 -84
- package/ol/layers/MapboxStyleLayer.js +38 -268
- package/ol/layers/MapboxStyleLayer.test.js +97 -128
- package/ol/layers/MaplibreLayer.js +46 -187
- package/ol/layers/RoutingLayer.js +21 -51
- package/ol/layers/RoutingLayer.test.js +15 -24
- package/ol/layers/TralisLayer.js +102 -276
- package/ol/layers/TralisLayer.test.js +32 -50
- package/ol/layers/VectorLayer.js +3 -24
- package/ol/layers/VectorLayer.test.js +34 -45
- package/ol/layers/WMSLayer.js +15 -57
- package/ol/layers/WMSLayer.test.js +35 -43
- package/ol/layers/index.js +8 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +11 -15
- package/ol/styles/fullTrajectoryStyle.js +17 -25
- package/ol/styles/index.js +2 -2
- package/package.json +35 -62
- package/api/routing/RoutingAPI.js +0 -44
- package/api/routing/RoutingAPI.test.js +0 -41
- package/api/stops/StopsAPI.js +0 -41
- package/api/stops/StopsAPI.test.js +0 -34
- package/api/tralis/TralisAPI.js +0 -731
- package/api/tralis/TralisAPI.test.js +0 -75
- package/api/tralis/WebSocketConnector.js +0 -338
- package/api/tralis/typedefs.js +0 -81
- package/common/api/api.js +0 -64
- package/common/api/api.test.js +0 -68
- package/index.js.map +0 -1
- package/module.js +0 -23
- package/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
- package/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
- package/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
- package/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
- package/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
- package/ol/controls/snapshots/RoutingControlStation1.json +0 -60
- package/ol/controls/snapshots/RoutingControlStation2.json +0 -49
|
@@ -1,80 +1,70 @@
|
|
|
1
|
-
import OLVectorLayer from
|
|
2
|
-
import VectorSource from
|
|
3
|
-
import View from
|
|
4
|
-
import Feature from
|
|
5
|
-
import Point from
|
|
6
|
-
import Map from
|
|
7
|
-
import VectorLayer from
|
|
8
|
-
|
|
1
|
+
import OLVectorLayer from "ol/layer/Vector";
|
|
2
|
+
import VectorSource from "ol/source/Vector";
|
|
3
|
+
import View from "ol/View";
|
|
4
|
+
import Feature from "ol/Feature";
|
|
5
|
+
import Point from "ol/geom/Point";
|
|
6
|
+
import Map from "ol/Map";
|
|
7
|
+
import VectorLayer from "./VectorLayer";
|
|
9
8
|
const feature1 = new Feature({
|
|
10
|
-
attribute:
|
|
11
|
-
geometry: new Point([500, 500])
|
|
9
|
+
attribute: "bar",
|
|
10
|
+
geometry: new Point([500, 500])
|
|
12
11
|
});
|
|
13
12
|
const olLayer = new OLVectorLayer({
|
|
14
13
|
source: new VectorSource({
|
|
15
14
|
features: [
|
|
16
15
|
feature1,
|
|
17
16
|
new Feature({
|
|
18
|
-
attribute:
|
|
19
|
-
geometry: new Point([50, 50])
|
|
20
|
-
})
|
|
21
|
-
]
|
|
22
|
-
})
|
|
17
|
+
attribute: "foo",
|
|
18
|
+
geometry: new Point([50, 50])
|
|
19
|
+
})
|
|
20
|
+
]
|
|
21
|
+
})
|
|
23
22
|
});
|
|
24
|
-
|
|
25
23
|
let layer;
|
|
26
24
|
let map;
|
|
27
25
|
let onClick;
|
|
28
|
-
|
|
29
|
-
describe('VectorLayer', () => {
|
|
26
|
+
describe("VectorLayer", () => {
|
|
30
27
|
beforeEach(() => {
|
|
31
28
|
onClick = jest.fn();
|
|
32
29
|
layer = new VectorLayer({
|
|
33
|
-
name:
|
|
30
|
+
name: "Layer",
|
|
34
31
|
olLayer,
|
|
35
|
-
onClick
|
|
32
|
+
onClick
|
|
36
33
|
});
|
|
37
34
|
map = new Map({
|
|
38
35
|
view: new View({ resolution: 5 }),
|
|
39
|
-
target: document.body
|
|
36
|
+
target: document.body
|
|
40
37
|
});
|
|
41
38
|
});
|
|
42
|
-
|
|
43
|
-
test('should be instanced.', () => {
|
|
39
|
+
test("should be instanced.", () => {
|
|
44
40
|
expect(layer).toBeInstanceOf(VectorLayer);
|
|
45
41
|
expect(layer.clickCallbacks[0]).toBe(onClick);
|
|
46
42
|
expect(layer.hitTolerance).toBe(5);
|
|
47
43
|
});
|
|
48
|
-
|
|
49
|
-
test('should add onClick callback.', () => {
|
|
44
|
+
test("should add onClick callback.", () => {
|
|
50
45
|
const onClick2 = jest.fn();
|
|
51
46
|
layer.onClick(onClick2);
|
|
52
47
|
expect(layer.clickCallbacks[1]).toBe(onClick2);
|
|
53
48
|
});
|
|
54
|
-
|
|
55
|
-
test('should onClick throw error.', () => {
|
|
49
|
+
test("should onClick throw error.", () => {
|
|
56
50
|
expect(() => {
|
|
57
|
-
layer.onClick(
|
|
51
|
+
layer.onClick("not of type function");
|
|
58
52
|
}).toThrow(Error);
|
|
59
53
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
layer.init();
|
|
54
|
+
test("should called terminate on initalization.", () => {
|
|
55
|
+
const spy = jest.spyOn(layer, "detachFromMap");
|
|
56
|
+
layer.attachToMap();
|
|
64
57
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
65
58
|
});
|
|
66
|
-
|
|
67
|
-
test('should call getFeatureInfoAtCoordinate on click then the callback', async () => {
|
|
59
|
+
test("should call getFeatureInfoAtCoordinate on click then the callback", async () => {
|
|
68
60
|
const coordinate = [500, 500];
|
|
69
61
|
const px = [10, 10];
|
|
70
62
|
const features = [feature1];
|
|
71
|
-
const evt = { type:
|
|
72
|
-
const spy = jest.spyOn(layer,
|
|
73
|
-
const spy2 = jest.spyOn(map,
|
|
74
|
-
const spy3 = jest
|
|
75
|
-
|
|
76
|
-
.mockReturnValue(features);
|
|
77
|
-
layer.init(map);
|
|
63
|
+
const evt = { type: "singleclick", map, coordinate };
|
|
64
|
+
const spy = jest.spyOn(layer, "getFeatureInfoAtCoordinate");
|
|
65
|
+
const spy2 = jest.spyOn(map, "getPixelFromCoordinate").mockReturnValue(px);
|
|
66
|
+
const spy3 = jest.spyOn(map, "getFeaturesAtPixel").mockReturnValue(features);
|
|
67
|
+
layer.attachToMap(map);
|
|
78
68
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
79
69
|
await map.dispatchEvent(evt);
|
|
80
70
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
@@ -88,11 +78,10 @@ describe('VectorLayer', () => {
|
|
|
88
78
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
89
79
|
expect(onClick).toHaveBeenCalledWith(features, layer, coordinate);
|
|
90
80
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const clone = layer.clone({ name: 'clone' });
|
|
81
|
+
test("should clone", () => {
|
|
82
|
+
const clone = layer.clone({ name: "clone" });
|
|
94
83
|
expect(clone).not.toBe(layer);
|
|
95
|
-
expect(clone.name).toBe(
|
|
84
|
+
expect(clone.name).toBe("clone");
|
|
96
85
|
expect(clone).toBeInstanceOf(VectorLayer);
|
|
97
86
|
});
|
|
98
87
|
});
|
package/ol/layers/WMSLayer.js
CHANGED
|
@@ -1,80 +1,38 @@
|
|
|
1
|
-
import GeoJSON from
|
|
2
|
-
import Layer from
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Class use to display a WMS layer.
|
|
6
|
-
*
|
|
7
|
-
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
8
|
-
* @extends {Layer}
|
|
9
|
-
*/
|
|
1
|
+
import GeoJSON from "ol/format/GeoJSON";
|
|
2
|
+
import Layer from "./Layer";
|
|
10
3
|
class WMSLayer extends Layer {
|
|
11
|
-
/**
|
|
12
|
-
* @override
|
|
13
|
-
*/
|
|
14
4
|
constructor(options = {}) {
|
|
15
5
|
super(options);
|
|
16
|
-
|
|
17
|
-
/** @ignore */
|
|
18
6
|
this.abortController = new AbortController();
|
|
19
|
-
/** @ignore */
|
|
20
7
|
this.format = new GeoJSON();
|
|
21
8
|
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get features infos' Url.
|
|
25
|
-
* @param {ol/coordinate~Coordinate} coord
|
|
26
|
-
* @return {ol/layer/Layer~Layer}
|
|
27
|
-
*/
|
|
28
9
|
getFeatureInfoUrl(coord) {
|
|
29
10
|
const projection = this.map.getView().getProjection();
|
|
30
11
|
const resolution = this.map.getView().getResolution();
|
|
31
|
-
|
|
32
12
|
if (this.olLayer.getSource().getFeatureInfoUrl) {
|
|
33
|
-
return this.olLayer
|
|
34
|
-
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
query_layers: this.olLayer.getSource().getParams().layers,
|
|
38
|
-
});
|
|
13
|
+
return this.olLayer.getSource().getFeatureInfoUrl(coord, resolution, projection, {
|
|
14
|
+
info_format: "application/json",
|
|
15
|
+
query_layers: this.olLayer.getSource().getParams().layers
|
|
16
|
+
});
|
|
39
17
|
}
|
|
40
18
|
return false;
|
|
41
19
|
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Request feature information for a given coordinate.
|
|
45
|
-
* @param {ol/coordinate~Coordinate} coordinate to request the information at.
|
|
46
|
-
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
|
|
47
|
-
*/
|
|
48
20
|
getFeatureInfoAtCoordinate(coordinate) {
|
|
49
21
|
this.abortController.abort();
|
|
50
22
|
this.abortController = new AbortController();
|
|
51
23
|
const { signal } = this.abortController;
|
|
52
|
-
return fetch(this.getFeatureInfoUrl(coordinate), { signal })
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// resolve an empty feature array something fails
|
|
62
|
-
Promise.resolve({
|
|
63
|
-
features: [],
|
|
64
|
-
coordinate,
|
|
65
|
-
layer: this,
|
|
66
|
-
}),
|
|
67
|
-
);
|
|
24
|
+
return fetch(this.getFeatureInfoUrl(coordinate), { signal }).then((resp) => resp.json()).then((r) => r.features).then((data) => ({
|
|
25
|
+
layer: this,
|
|
26
|
+
coordinate,
|
|
27
|
+
features: data.map((d) => this.format.readFeature(d))
|
|
28
|
+
})).catch(() => Promise.resolve({
|
|
29
|
+
features: [],
|
|
30
|
+
coordinate,
|
|
31
|
+
layer: this
|
|
32
|
+
}));
|
|
68
33
|
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Create a copy of the WMSLayer.
|
|
72
|
-
* @param {Object} newOptions Options to override
|
|
73
|
-
* @return {WMSLayer} A WMSLayer
|
|
74
|
-
*/
|
|
75
34
|
clone(newOptions) {
|
|
76
35
|
return new WMSLayer({ ...this.options, ...newOptions });
|
|
77
36
|
}
|
|
78
37
|
}
|
|
79
|
-
|
|
80
38
|
export default WMSLayer;
|
|
@@ -1,65 +1,59 @@
|
|
|
1
|
-
import OLView from
|
|
2
|
-
import ImageLayer from
|
|
3
|
-
import ImageWMS from
|
|
4
|
-
import fetch from
|
|
5
|
-
import qs from
|
|
6
|
-
import Map from
|
|
7
|
-
import WMSLayer from
|
|
8
|
-
|
|
9
|
-
describe('WMSLayer', () => {
|
|
1
|
+
import OLView from "ol/View";
|
|
2
|
+
import ImageLayer from "ol/layer/Image";
|
|
3
|
+
import ImageWMS from "ol/source/ImageWMS";
|
|
4
|
+
import fetch from "jest-fetch-mock";
|
|
5
|
+
import qs from "query-string";
|
|
6
|
+
import Map from "ol/Map";
|
|
7
|
+
import WMSLayer from "./WMSLayer";
|
|
8
|
+
describe("WMSLayer", () => {
|
|
10
9
|
let map;
|
|
11
10
|
let layer;
|
|
12
11
|
beforeEach(() => {
|
|
13
12
|
map = new Map({
|
|
14
13
|
view: new OLView({ resolution: 5 }),
|
|
15
|
-
target: document.body
|
|
14
|
+
target: document.body
|
|
16
15
|
});
|
|
17
|
-
|
|
18
16
|
layer = new WMSLayer({
|
|
19
17
|
olLayer: new ImageLayer({
|
|
20
18
|
source: new ImageWMS({
|
|
21
|
-
url:
|
|
22
|
-
params: { LAYERS:
|
|
23
|
-
})
|
|
24
|
-
})
|
|
19
|
+
url: "dummy",
|
|
20
|
+
params: { LAYERS: "layers" }
|
|
21
|
+
})
|
|
22
|
+
})
|
|
25
23
|
});
|
|
26
|
-
layer.
|
|
24
|
+
layer.attachToMap(map);
|
|
27
25
|
fetch.mockResponseOnce(JSON.stringify({ features: [] }));
|
|
28
26
|
global.fetch = fetch;
|
|
29
27
|
});
|
|
30
|
-
|
|
31
28
|
afterEach(() => {
|
|
32
|
-
layer.
|
|
29
|
+
layer.detachFromMap();
|
|
33
30
|
});
|
|
34
|
-
|
|
35
|
-
test('should initialize.', () => {
|
|
31
|
+
test("should initialize.", () => {
|
|
36
32
|
expect(layer).toBeInstanceOf(WMSLayer);
|
|
37
33
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
layer.init();
|
|
34
|
+
test("should called terminate on initalization.", () => {
|
|
35
|
+
const spy = jest.spyOn(layer, "detachFromMap");
|
|
36
|
+
layer.attachToMap();
|
|
42
37
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
43
38
|
});
|
|
44
|
-
|
|
45
|
-
test('should return a promise resolving features.', async () => {
|
|
39
|
+
test("should return a promise resolving features.", async () => {
|
|
46
40
|
const data = await layer.getFeatureInfoAtCoordinate([50, 50]);
|
|
47
|
-
const params = qs.parse(fetch.mock.calls[0][0].split(
|
|
48
|
-
expect(params.REQUEST).toBe(
|
|
49
|
-
expect(params.I).toBe(
|
|
50
|
-
expect(params.J).toBe(
|
|
41
|
+
const params = qs.parse(fetch.mock.calls[0][0].split("?")[1]);
|
|
42
|
+
expect(params.REQUEST).toBe("GetFeatureInfo");
|
|
43
|
+
expect(params.I).toBe("50");
|
|
44
|
+
expect(params.J).toBe("50");
|
|
51
45
|
expect(data.features).toEqual([]);
|
|
52
46
|
});
|
|
53
|
-
|
|
54
|
-
test('should return a layer instance and a coordinate.', async () => {
|
|
47
|
+
test("should return a layer instance and a coordinate.", async () => {
|
|
55
48
|
const data = await layer.getFeatureInfoAtCoordinate([50, 50]);
|
|
56
49
|
expect(data.coordinate).toEqual([50, 50]);
|
|
57
50
|
expect(data.layer).toBeInstanceOf(WMSLayer);
|
|
58
51
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const f2 = () => {
|
|
52
|
+
test("#onClick", () => {
|
|
53
|
+
const f = () => {
|
|
54
|
+
};
|
|
55
|
+
const f2 = () => {
|
|
56
|
+
};
|
|
63
57
|
layer.onClick(f);
|
|
64
58
|
expect(layer.clickCallbacks[0]).toBe(f);
|
|
65
59
|
expect(layer.clickCallbacks.length).toBe(1);
|
|
@@ -68,17 +62,15 @@ describe('WMSLayer', () => {
|
|
|
68
62
|
layer.onClick(f2);
|
|
69
63
|
expect(layer.clickCallbacks.length).toBe(2);
|
|
70
64
|
});
|
|
71
|
-
|
|
72
|
-
test('should onClick throw error.', () => {
|
|
65
|
+
test("should onClick throw error.", () => {
|
|
73
66
|
expect(() => {
|
|
74
|
-
layer.onClick(
|
|
67
|
+
layer.onClick("not of type function");
|
|
75
68
|
}).toThrow(Error);
|
|
76
69
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const clone = layer.clone({ name: 'clone' });
|
|
70
|
+
test("should clone", () => {
|
|
71
|
+
const clone = layer.clone({ name: "clone" });
|
|
80
72
|
expect(clone).not.toBe(layer);
|
|
81
|
-
expect(clone.name).toBe(
|
|
73
|
+
expect(clone.name).toBe("clone");
|
|
82
74
|
expect(clone).toBeInstanceOf(WMSLayer);
|
|
83
75
|
});
|
|
84
76
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as Layer } from "./Layer";
|
|
2
|
+
export { default as MapboxLayer } from "./MapboxLayer";
|
|
3
|
+
export { default as MaplibreLayer } from "./MaplibreLayer";
|
|
4
|
+
export { default as MapboxStyleLayer } from "./MapboxStyleLayer";
|
|
5
|
+
export { default as RoutingLayer } from "./RoutingLayer";
|
|
6
|
+
export { default as TralisLayer } from "./TralisLayer";
|
|
7
|
+
export { default as VectorLayer } from "./VectorLayer";
|
|
8
|
+
export { default as WMSLayer } from "./WMSLayer";
|
|
@@ -1,35 +1,31 @@
|
|
|
1
|
-
import { Style, Fill, Stroke, Circle } from
|
|
2
|
-
|
|
1
|
+
import { Style, Fill, Stroke, Circle } from "ol/style";
|
|
3
2
|
const stroke = new Style({
|
|
4
3
|
zIndex: 2,
|
|
5
4
|
image: new Circle({
|
|
6
5
|
radius: 5,
|
|
7
6
|
fill: new Fill({
|
|
8
|
-
color:
|
|
9
|
-
})
|
|
7
|
+
color: "#000000"
|
|
8
|
+
})
|
|
10
9
|
}),
|
|
11
10
|
stroke: new Stroke({
|
|
12
|
-
color:
|
|
13
|
-
width: 6
|
|
14
|
-
})
|
|
11
|
+
color: "#000000",
|
|
12
|
+
width: 6
|
|
13
|
+
})
|
|
15
14
|
});
|
|
16
|
-
|
|
17
15
|
const fill = new Style({
|
|
18
16
|
zIndex: 3,
|
|
19
17
|
image: new Circle({
|
|
20
18
|
radius: 4,
|
|
21
19
|
fill: new Fill({
|
|
22
|
-
color:
|
|
23
|
-
})
|
|
20
|
+
color: "#a0a0a0"
|
|
21
|
+
})
|
|
24
22
|
}),
|
|
25
23
|
stroke: new Stroke({
|
|
26
|
-
color:
|
|
27
|
-
width: 4
|
|
28
|
-
})
|
|
24
|
+
color: "#a0a0a0",
|
|
25
|
+
width: 4
|
|
26
|
+
})
|
|
29
27
|
});
|
|
30
|
-
|
|
31
28
|
const fullTrajectoryDelaystyle = () => {
|
|
32
29
|
return [stroke, fill];
|
|
33
30
|
};
|
|
34
|
-
|
|
35
31
|
export default fullTrajectoryDelaystyle;
|
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
import { Style, Fill, Stroke, Circle } from
|
|
2
|
-
import { getBgColor } from
|
|
3
|
-
|
|
1
|
+
import { Style, Fill, Stroke, Circle } from "ol/style";
|
|
2
|
+
import { getBgColor } from "../../common/trackerConfig";
|
|
4
3
|
const borderStyle = new Style({
|
|
5
4
|
zIndex: 2,
|
|
6
5
|
image: new Circle({
|
|
7
6
|
radius: 5,
|
|
8
7
|
fill: new Fill({
|
|
9
|
-
color:
|
|
10
|
-
})
|
|
8
|
+
color: "#000000"
|
|
9
|
+
})
|
|
11
10
|
}),
|
|
12
11
|
stroke: new Stroke({
|
|
13
|
-
color:
|
|
14
|
-
width: 6
|
|
15
|
-
})
|
|
12
|
+
color: "#000000",
|
|
13
|
+
width: 6
|
|
14
|
+
})
|
|
16
15
|
});
|
|
17
|
-
|
|
18
16
|
const fullTrajectorystyle = (feature) => {
|
|
19
|
-
let lineColor =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (stroke && stroke[0] !== '#') {
|
|
17
|
+
let lineColor = "#ffffff";
|
|
18
|
+
const type = feature.get("type");
|
|
19
|
+
let stroke = feature.get("stroke");
|
|
20
|
+
if (stroke && stroke[0] !== "#") {
|
|
25
21
|
stroke = `#${stroke}`;
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
lineColor = stroke || getBgColor(type);
|
|
29
|
-
|
|
30
|
-
// Don't allow white lines, use red instead.
|
|
31
|
-
lineColor = /#ffffff/i.test(lineColor) ? '#ff0000' : lineColor;
|
|
32
|
-
|
|
24
|
+
lineColor = /#ffffff/i.test(lineColor) ? "#ff0000" : lineColor;
|
|
33
25
|
const style = [
|
|
34
26
|
borderStyle,
|
|
35
27
|
new Style({
|
|
@@ -37,14 +29,14 @@ const fullTrajectorystyle = (feature) => {
|
|
|
37
29
|
image: new Circle({
|
|
38
30
|
radius: 4,
|
|
39
31
|
fill: new Fill({
|
|
40
|
-
color: lineColor
|
|
41
|
-
})
|
|
32
|
+
color: lineColor
|
|
33
|
+
})
|
|
42
34
|
}),
|
|
43
35
|
stroke: new Stroke({
|
|
44
36
|
color: lineColor,
|
|
45
|
-
width: 4
|
|
46
|
-
})
|
|
47
|
-
})
|
|
37
|
+
width: 4
|
|
38
|
+
})
|
|
39
|
+
})
|
|
48
40
|
];
|
|
49
41
|
return style;
|
|
50
42
|
};
|
package/ol/styles/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as fullTrajectoryStyle } from
|
|
2
|
-
export { default as fullTrajectoryDelayStyle } from
|
|
1
|
+
export { default as fullTrajectoryStyle } from "./fullTrajectoryStyle";
|
|
2
|
+
export { default as fullTrajectoryDelayStyle } from "./fullTrajectoryDelayStyle";
|
package/package.json
CHANGED
|
@@ -2,33 +2,22 @@
|
|
|
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.
|
|
5
|
+
"version": "2.0.1-beta.13",
|
|
6
6
|
"main": "index.js",
|
|
7
|
-
"
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./api": "./api/index.js",
|
|
10
|
+
"./mapbox": "./mapbox/index.js",
|
|
11
|
+
"./ol": "./ol/index.js"
|
|
12
|
+
},
|
|
8
13
|
"dependencies": {
|
|
9
|
-
"@geops/geops-ui": "0.1.13",
|
|
10
|
-
"@material-ui/core": "4.12.3",
|
|
11
|
-
"@material-ui/icons": "4.11.2",
|
|
12
|
-
"@material-ui/styles": "4.11.4",
|
|
13
14
|
"@turf/helpers": "^6.5.0",
|
|
14
15
|
"@turf/transform-rotate": "^6.5.0",
|
|
15
|
-
"codesandbox": "2.2.3",
|
|
16
16
|
"lodash.debounce": "4.0.8",
|
|
17
17
|
"lodash.throttle": "4.1.1",
|
|
18
18
|
"path": "^0.12.7",
|
|
19
|
-
"prop-types": "15.8.1",
|
|
20
19
|
"query-string": "7.1.0",
|
|
21
|
-
"react": "18",
|
|
22
|
-
"react-app-polyfill": "^1.0.6",
|
|
23
|
-
"react-dom": "18",
|
|
24
|
-
"react-icons": "4.3.1",
|
|
25
|
-
"react-markdown": "8.0.0",
|
|
26
|
-
"react-router-dom": "6",
|
|
27
|
-
"react-scrollchor": "7.0.1",
|
|
28
|
-
"react-syntax-highlighter": "15.4.5",
|
|
29
|
-
"taffydb": "^2.7.3",
|
|
30
20
|
"turf": "^3.0.14",
|
|
31
|
-
"typeface-lato": "^0.0.75",
|
|
32
21
|
"uuid": "8.3.2"
|
|
33
22
|
},
|
|
34
23
|
"peerDependencies": {
|
|
@@ -44,13 +33,11 @@
|
|
|
44
33
|
"@babel/preset-react": "7.16.7",
|
|
45
34
|
"@commitlint/cli": "17.0.2",
|
|
46
35
|
"@commitlint/config-conventional": "17.0.2",
|
|
47
|
-
"@neutrinojs/copy": "9.5.0",
|
|
48
|
-
"@neutrinojs/jest": "^9.5.0",
|
|
49
|
-
"@neutrinojs/library": "9.5.0",
|
|
50
|
-
"@neutrinojs/react": "9.5.0",
|
|
51
36
|
"autoprefixer": "9.7.6",
|
|
52
37
|
"cypress": "9.4.1",
|
|
53
38
|
"deepmerge": "4.2.2",
|
|
39
|
+
"esbuild": "^0.14.47",
|
|
40
|
+
"esbuild-jest": "^0.5.0",
|
|
54
41
|
"esdoc": "1.1.0",
|
|
55
42
|
"esdoc-ecmascript-proposal-plugin": "1.0.0",
|
|
56
43
|
"esdoc-publish-html-plugin": "1.1.2",
|
|
@@ -58,25 +45,23 @@
|
|
|
58
45
|
"eslint": "8.8.0",
|
|
59
46
|
"eslint-config-airbnb": "19.0.4",
|
|
60
47
|
"eslint-config-prettier": "8.3.0",
|
|
61
|
-
"eslint-import-resolver-webpack": "0.13.2",
|
|
62
48
|
"eslint-plugin-cypress": "2.12.1",
|
|
63
49
|
"eslint-plugin-import": "2.25.4",
|
|
64
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
50
|
+
"eslint-plugin-jsx-a11y": "^6.6.0",
|
|
65
51
|
"eslint-plugin-prettier": "4.0.0",
|
|
66
|
-
"eslint-plugin-react": "7.
|
|
67
|
-
"eslint-plugin-react-hooks": "4.3.0",
|
|
52
|
+
"eslint-plugin-react": "^7.30.1",
|
|
68
53
|
"fixpack": "3.0.6",
|
|
69
54
|
"husky": "8.0.1",
|
|
70
55
|
"jest": "26.6.3",
|
|
71
56
|
"jest-canvas-mock": "2.3.1",
|
|
72
57
|
"jest-fetch-mock": "3.0.3",
|
|
73
58
|
"jest-serializer-html": "7.1.0",
|
|
59
|
+
"jest-transformer-svg": "^2.0.0",
|
|
74
60
|
"jest-websocket-mock": "2.3.0",
|
|
75
61
|
"lint-staged": "12.3.3",
|
|
76
62
|
"mapbox-gl": "1.13.2",
|
|
77
63
|
"maplibre-gl": "2.1.9",
|
|
78
64
|
"mock-socket": "9.1.2",
|
|
79
|
-
"neutrino": "9.5.0",
|
|
80
65
|
"ol": "6.12.0",
|
|
81
66
|
"postcss": "8.3.3",
|
|
82
67
|
"postcss-loader": "3.0.0",
|
|
@@ -89,34 +74,38 @@
|
|
|
89
74
|
"stylelint": "14.3.0",
|
|
90
75
|
"stylelint-config-recommended-scss": "5.0.2",
|
|
91
76
|
"stylelint-config-standard": "24.0.0",
|
|
92
|
-
"stylelint-scss": "4.1.0"
|
|
93
|
-
"webpack": "4.43.0",
|
|
94
|
-
"webpack-cli": "3.3.11",
|
|
95
|
-
"webpack-dev-server": "3.11.0",
|
|
96
|
-
"worker-loader": "3.0.8"
|
|
77
|
+
"stylelint-scss": "4.1.0"
|
|
97
78
|
},
|
|
98
79
|
"scripts": {
|
|
99
|
-
"apidoc": "esdoc",
|
|
100
|
-
"build": "yarn
|
|
80
|
+
"apidoc": "esdoc && cp apidoc/index.json doc/src/components/Esdoc",
|
|
81
|
+
"build": "yarn esbuild",
|
|
101
82
|
"coverage": "yarn test --watchAll=false --coverage --coverageDirectory=coverage",
|
|
102
83
|
"cy:open": "cypress open",
|
|
103
|
-
"cy:
|
|
104
|
-
"cy:test": "start-server-and-test start http://localhost:
|
|
105
|
-
"
|
|
106
|
-
"
|
|
84
|
+
"cy:test": "start-server-and-test dev http://localhost:3000 'cypress run --browser chrome'",
|
|
85
|
+
"cy:test:chrome": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser chrome'",
|
|
86
|
+
"cy:test:edge": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser edge'",
|
|
87
|
+
"cy:test:firefox": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser firefox'",
|
|
88
|
+
"dev": "yarn doc && yarn dev:examples",
|
|
89
|
+
"dev:examples": "cd doc && yarn dev",
|
|
90
|
+
"doc": "yarn apidoc && cd doc && yarn install --frozen-lockfile && yarn build",
|
|
91
|
+
"esbuild": "rm -rf build && yarn esbuild:all && yarn esbuild:iife && cp README.md build/ && cp package.json build/",
|
|
92
|
+
"esbuild:all": "esbuild src/index.js src/**/*.js src/**/**/*.js --target=chrome100 --outdir=build/ --loader:.js=jsx",
|
|
93
|
+
"esbuild:iife": "yarn esbuild:iife:unminify && yarn esbuild:iife:minify",
|
|
94
|
+
"esbuild:iife:base": "esbuild src/iife.js --bundle --sourcemap --target=chrome100",
|
|
95
|
+
"esbuild:iife:minify": "yarn esbuild:iife:base --minify --outfile=build/mbt.min.js",
|
|
96
|
+
"esbuild:iife:unminify": "yarn esbuild:iife:base --outfile=build/mbt.js",
|
|
107
97
|
"format": "prettier --write 'src/**/*.js' && eslint 'src/**/*.js' --fix && stylelint 'src/**/*.css' 'src/**/*.scss' --fix",
|
|
108
98
|
"lib": "REACT_APP_LIB_MODE=1 webpack --mode production",
|
|
109
99
|
"lib:dev": "REACT_APP_LIB_MODE=1 webpack --mode development",
|
|
110
100
|
"link2": "cmdToAdd=$(node ./scripts/read-pkg-json.js add) && $cmdToAdd && yarn build && cmdToRemove=$(node ./scripts/read-pkg-json.js remove) && $cmdToRemove && cd build && yarn link",
|
|
111
|
-
"lint": "eslint 'src/**/*.js' && stylelint 'src/**/*.css' 'src/**/*.scss'",
|
|
112
|
-
"publish:beta": "HUSKY=0 yarn release -- --prerelease beta --skip.changelog && git push origin HEAD && yarn run build && cd build &&
|
|
101
|
+
"lint": "eslint 'src/**/*.js' && stylelint 'src/**/*.css' 'src/**/*.scss' --allow-empty-input",
|
|
102
|
+
"publish:beta": "HUSKY=0 yarn release -- --prerelease beta --skip.changelog && git push origin HEAD && yarn run build && cd build && HUSKY=0 yarn publish --tag beta && git push --tags ",
|
|
113
103
|
"publish:beta:dryrun": "yarn release -- --prerelease beta --dry-run --skip.changelog",
|
|
114
|
-
"publish:public": "yarn release && git push origin HEAD && yarn run build && cd build && git push --tags && yarn publish",
|
|
115
104
|
"publish:public:dryrun": "yarn release --dry-run",
|
|
116
105
|
"release": "standard-version",
|
|
117
|
-
"start": "yarn doc &&
|
|
118
|
-
"start:examples": "
|
|
119
|
-
"test": "
|
|
106
|
+
"start": "yarn doc && cd doc && yarn start",
|
|
107
|
+
"start:examples": "cd doc && yarn build && yarn start",
|
|
108
|
+
"test": "TZ='UTC' jest",
|
|
120
109
|
"test:watch": "yarn test --watchAll"
|
|
121
110
|
},
|
|
122
111
|
"browserslist": {
|
|
@@ -143,7 +132,6 @@
|
|
|
143
132
|
"parser": "@babel/eslint-parser",
|
|
144
133
|
"extends": [
|
|
145
134
|
"airbnb",
|
|
146
|
-
"airbnb/hooks",
|
|
147
135
|
"prettier"
|
|
148
136
|
],
|
|
149
137
|
"plugins": [
|
|
@@ -162,23 +150,8 @@
|
|
|
162
150
|
}
|
|
163
151
|
],
|
|
164
152
|
"prettier/prettier": "error"
|
|
165
|
-
},
|
|
166
|
-
"settings": {
|
|
167
|
-
"import/resolver": "webpack",
|
|
168
|
-
"react": {
|
|
169
|
-
"version": "detect"
|
|
170
|
-
}
|
|
171
153
|
}
|
|
172
154
|
},
|
|
173
|
-
"exports": {
|
|
174
|
-
".": "./index.js",
|
|
175
|
-
"./module": "./module.js",
|
|
176
|
-
"./api": "./api/index.js",
|
|
177
|
-
"./common/trackerConfig": "./common/trackerConfig.js",
|
|
178
|
-
"./utils": "./common/utils/index.js",
|
|
179
|
-
"./mapbox": "./mapbox/index.js",
|
|
180
|
-
"./ol": "./ol/index.js"
|
|
181
|
-
},
|
|
182
155
|
"keywords": [
|
|
183
156
|
"mobility",
|
|
184
157
|
"toolbox"
|
|
@@ -191,10 +164,10 @@
|
|
|
191
164
|
"yarn test --bail --findRelatedTests"
|
|
192
165
|
],
|
|
193
166
|
"package.json": [
|
|
194
|
-
"fixpack --sortToTop name --sortToTop license --sortToTop description --sortToTop version --sortToTop author --sortToTop main --sortToTop module --sortToTop files --sortToTop proxy --sortToTop dependencies --sortToTop peerDependencies --sortToTop devDependencies --sortToTop resolutions --sortToTop scripts"
|
|
167
|
+
"fixpack --sortToTop name --sortToTop license --sortToTop description --sortToTop version --sortToTop author --sortToTop main --sortToTop module --sortToTop files --sortToTop exports --sortToTop proxy --sortToTop dependencies --sortToTop peerDependencies --sortToTop devDependencies --sortToTop resolutions --sortToTop scripts"
|
|
195
168
|
],
|
|
196
169
|
"src/**/*.{css,scss}": [
|
|
197
|
-
"stylelint --fix"
|
|
170
|
+
"stylelint --fix --allow-empty-input"
|
|
198
171
|
]
|
|
199
172
|
},
|
|
200
173
|
"prettier": {
|