index.js
1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* eslint-disable no-underscore-dangle */
export const state = () => ({
zoomLevel: 16,
boundary: {
northEast: {},
southWest: {},
},
stateChange: false,
});
export const getters = {
getZoomLevel: (state) => state.zoomLevel,
getBoundary: (state) => state.boundary,
getStateChange: (state) => state.stateChange,
isBoundary: (state) => (drone) => {
const checkLatBound = drone.latitude >= state.boundary.southWest.lat && drone.latitude <= state.boundary.northEast.lat;
const checkLngBound = drone.longitude >= state.boundary.southWest.lng && drone.longitude <= state.boundary.northEast.lng;
return checkLatBound && checkLngBound;
},
zoomToActivateTime: (state) => {
switch (state.zoomLevel) {
case 8:
return 30;
case 9:
return 15;
case 10:
return 10;
case 11:
return 6;
case 12:
return 4;
case 13:
return 3;
case 14:
return 2;
default:
return 1;
}
},
};
export const actions = {
setZoomLevel(context, data) {
context.commit('SET_ZOOM_LEVEL', data);
},
setBoundary(context, data) {
context.commit('SET_BOUNDARY', data);
},
clearZoomLevel(context) {
context.commit('DEL_ZOOM_LEVEL');
},
clearBoundary(context) {
context.commit('DEL_BOUNDARY');
},
clearStateChange(context) {
context.commit('RESET_STATE_CHANGE');
},
};
export const mutations = {
SET_ZOOM_LEVEL(state, payload) {
state.zoomLevel = payload;
state.stateChange = true;
},
SET_BOUNDARY(state, payload) {
state.boundary = { northEast: payload?._northEast, southWest: payload?._southWest };
state.stateChange = true;
},
DEL_ZOOM_LEVEL(state) {
state.zoomLevel = 16;
},
DEL_BOUNDARY(state) {
state.boundary = {
northEast: {},
southWest: {},
};
},
RESET_STATE_CHANGE(state) {
state.stateChange = false;
},
};