@vcmap/viewshed 3.0.3 → 3.0.5
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/CHANGELOG.md +4 -0
- package/dist/index.js +550 -530
- package/package.json +5 -5
- package/src/util/toolboxHelper.js +84 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcmap/viewshed",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"description": "Tool to simulate a \"viewer\" and their field of vision from a certain standpoint in the map. It allows the user to see which areas and buildings can or can't be seen from a specific standpoint, regarding different viewing distances, viewers' sizes and orientations.Th",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"prettier": "@vcsuite/eslint-config/prettier.js",
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@vcmap-cesium/engine": "^11.0.2",
|
|
51
|
-
"@vcmap/core": "^6.0.
|
|
52
|
-
"@vcmap/ui": "^6.0.
|
|
51
|
+
"@vcmap/core": "^6.0.4",
|
|
52
|
+
"@vcmap/ui": "^6.0.6",
|
|
53
53
|
"ol": "^10.2.1",
|
|
54
54
|
"vue": "~3.4.38",
|
|
55
55
|
"vuetify": "^3.7.3"
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@vcmap/plugin-cli": "^4.0.1",
|
|
59
59
|
"@vcsuite/eslint-config": "^3.0.8",
|
|
60
|
-
"@vitest/coverage-v8": "^2.1.
|
|
60
|
+
"@vitest/coverage-v8": "^2.1.4",
|
|
61
61
|
"jest-canvas-mock": "^2.5.2",
|
|
62
62
|
"jsdom": "^22.1.0",
|
|
63
63
|
"resize-observer-polyfill": "^1.5.1",
|
|
64
|
-
"vitest": "^2.1.
|
|
64
|
+
"vitest": "^2.1.4"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@vcsuite/check": "^2.1.0",
|
|
@@ -21,52 +21,95 @@ import { ViewshedPluginModes } from '../viewshedManager.js';
|
|
|
21
21
|
* @returns {ViewshedToolbox} A select toolbox with buttons to create 360 and cone viewshed.
|
|
22
22
|
*/
|
|
23
23
|
function createViewshedToolbox(app, manager, name, tools) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @param {string} tool The tool to create.
|
|
26
|
+
* @returns {{name:ViewshedTypes, icon:string, title:string, } | undefined} A tool object.
|
|
27
|
+
*/
|
|
28
|
+
function parseTool(tool) {
|
|
29
|
+
if (tool === ViewshedTypes.CONE) {
|
|
30
|
+
return {
|
|
31
|
+
name: ViewshedTypes.CONE,
|
|
32
|
+
icon: ViewshedIcons[ViewshedTypes.CONE],
|
|
33
|
+
title: `viewshed.create.${ViewshedTypes.CONE}`,
|
|
34
|
+
};
|
|
35
|
+
} else if (tool === ViewshedTypes.THREESIXTY) {
|
|
36
|
+
return {
|
|
37
|
+
name: ViewshedTypes.THREESIXTY,
|
|
38
|
+
icon: ViewshedIcons[ViewshedTypes.THREESIXTY],
|
|
39
|
+
title: `viewshed.create.${ViewshedTypes.THREESIXTY}`,
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let toolbox;
|
|
47
|
+
let currentViewshedWatcher;
|
|
48
|
+
if (tools.length === 1) {
|
|
49
|
+
const tool = parseTool(tools[0]);
|
|
50
|
+
toolbox = {
|
|
51
|
+
type: ToolboxType.SINGLE,
|
|
52
|
+
action: reactive({
|
|
53
|
+
...tool,
|
|
54
|
+
active: false,
|
|
55
|
+
background: false,
|
|
56
|
+
disabled: !(app.maps.activeMap instanceof CesiumMap),
|
|
57
|
+
callback() {
|
|
58
|
+
if (this.active) {
|
|
59
|
+
if (this.background && manager.currentViewshed.value) {
|
|
60
|
+
manager.editViewshed(manager.currentViewshed.value);
|
|
61
|
+
} else {
|
|
62
|
+
manager.stop();
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
manager.createViewshed(tool.name);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
} else {
|
|
71
|
+
toolbox = {
|
|
72
|
+
type: ToolboxType.SELECT,
|
|
73
|
+
action: reactive({
|
|
74
|
+
name,
|
|
75
|
+
currentIndex: 0,
|
|
76
|
+
active: false,
|
|
77
|
+
background: false,
|
|
78
|
+
disabled: !(app.maps.activeMap instanceof CesiumMap),
|
|
79
|
+
callback() {
|
|
80
|
+
if (this.active) {
|
|
81
|
+
if (this.background && manager.currentViewshed.value) {
|
|
82
|
+
manager.editViewshed(manager.currentViewshed.value);
|
|
83
|
+
} else {
|
|
84
|
+
manager.stop();
|
|
85
|
+
}
|
|
36
86
|
} else {
|
|
37
|
-
|
|
87
|
+
const toolName = this.tools[this.currentIndex].name;
|
|
88
|
+
manager.createViewshed(toolName);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
selected(newIndex) {
|
|
92
|
+
if (newIndex !== this.currentIndex) {
|
|
93
|
+
this.currentIndex = newIndex;
|
|
38
94
|
}
|
|
39
|
-
} else {
|
|
40
95
|
const toolName = this.tools[this.currentIndex].name;
|
|
41
96
|
manager.createViewshed(toolName);
|
|
97
|
+
},
|
|
98
|
+
tools: tools.flatMap(parseTool),
|
|
99
|
+
}),
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
currentViewshedWatcher = watch(
|
|
103
|
+
manager.currentViewshed,
|
|
104
|
+
(currentViewshed) => {
|
|
105
|
+
if (currentViewshed) {
|
|
106
|
+
toolbox.action.currentIndex = toolbox.action.tools.findIndex(
|
|
107
|
+
(tool) => tool.name === currentViewshed.type,
|
|
108
|
+
);
|
|
42
109
|
}
|
|
43
110
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.currentIndex = newIndex;
|
|
47
|
-
}
|
|
48
|
-
const toolName = this.tools[this.currentIndex].name;
|
|
49
|
-
manager.createViewshed(toolName);
|
|
50
|
-
},
|
|
51
|
-
tools: tools.flatMap((tool) => {
|
|
52
|
-
if (tool === ViewshedTypes.CONE) {
|
|
53
|
-
return {
|
|
54
|
-
name: ViewshedTypes.CONE,
|
|
55
|
-
icon: ViewshedIcons[ViewshedTypes.CONE],
|
|
56
|
-
title: `viewshed.create.${ViewshedTypes.CONE}`,
|
|
57
|
-
};
|
|
58
|
-
} else if (tool === ViewshedTypes.THREESIXTY) {
|
|
59
|
-
return {
|
|
60
|
-
name: ViewshedTypes.THREESIXTY,
|
|
61
|
-
icon: ViewshedIcons[ViewshedTypes.THREESIXTY],
|
|
62
|
-
title: `viewshed.create.${ViewshedTypes.THREESIXTY}`,
|
|
63
|
-
};
|
|
64
|
-
} else {
|
|
65
|
-
return [];
|
|
66
|
-
}
|
|
67
|
-
}),
|
|
68
|
-
}),
|
|
69
|
-
};
|
|
111
|
+
);
|
|
112
|
+
}
|
|
70
113
|
|
|
71
114
|
const viewshedModeWatcher = watch(manager.mode, (mode) => {
|
|
72
115
|
if (mode === ViewshedPluginModes.VIEW) {
|
|
@@ -81,17 +124,6 @@ function createViewshedToolbox(app, manager, name, tools) {
|
|
|
81
124
|
}
|
|
82
125
|
});
|
|
83
126
|
|
|
84
|
-
const currentViewshedWatcher = watch(
|
|
85
|
-
manager.currentViewshed,
|
|
86
|
-
(currentViewshed) => {
|
|
87
|
-
if (currentViewshed) {
|
|
88
|
-
toolbox.action.currentIndex = toolbox.action.tools.findIndex(
|
|
89
|
-
(tool) => tool.name === currentViewshed.type,
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
);
|
|
94
|
-
|
|
95
127
|
const mapChangedListener = app.maps.mapActivated.addEventListener((map) => {
|
|
96
128
|
if (map instanceof CesiumMap) {
|
|
97
129
|
toolbox.action.disabled = false;
|
|
@@ -103,7 +135,7 @@ function createViewshedToolbox(app, manager, name, tools) {
|
|
|
103
135
|
return {
|
|
104
136
|
destroy() {
|
|
105
137
|
viewshedModeWatcher();
|
|
106
|
-
currentViewshedWatcher();
|
|
138
|
+
currentViewshedWatcher?.();
|
|
107
139
|
mapChangedListener();
|
|
108
140
|
},
|
|
109
141
|
toolbox,
|