@vcmap/viewshed 3.0.2 → 3.0.3
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 +5 -0
- package/dist/index.js +445 -444
- package/package.json +3 -3
- package/src/index.js +9 -4
- package/src/viewshedManager.js +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcmap/viewshed",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
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.2",
|
|
52
|
+
"@vcmap/ui": "^6.0.4",
|
|
53
53
|
"ol": "^10.2.1",
|
|
54
54
|
"vue": "~3.4.38",
|
|
55
55
|
"vuetify": "^3.7.3"
|
package/src/index.js
CHANGED
|
@@ -74,9 +74,6 @@ export default function plugin(config) {
|
|
|
74
74
|
const { activeMap } = vcsUiApp.maps;
|
|
75
75
|
function activateCachedViewshed(map) {
|
|
76
76
|
if (state?.m && state.cv && map instanceof CesiumMap) {
|
|
77
|
-
if (state.cv.properties.title) {
|
|
78
|
-
delete state.cv.properties.title;
|
|
79
|
-
}
|
|
80
77
|
const activeViewshed = new Viewshed(state.cv);
|
|
81
78
|
if (state.m === ViewshedPluginModes.VIEW) {
|
|
82
79
|
viewshedManager.viewViewshed(activeViewshed);
|
|
@@ -141,9 +138,10 @@ export default function plugin(config) {
|
|
|
141
138
|
},
|
|
142
139
|
/**
|
|
143
140
|
* should return the plugins state
|
|
141
|
+
* @param {boolean} forUrl
|
|
144
142
|
* @returns {ViewshedPluginState}
|
|
145
143
|
*/
|
|
146
|
-
getState() {
|
|
144
|
+
getState(forUrl) {
|
|
147
145
|
const state = {};
|
|
148
146
|
const mode = viewshedManager.mode.value;
|
|
149
147
|
const currentViewshed = viewshedManager.currentViewshed.value?.toJSON();
|
|
@@ -151,6 +149,13 @@ export default function plugin(config) {
|
|
|
151
149
|
if (mode !== null && mode !== 'create' && currentViewshed) {
|
|
152
150
|
state.m = mode;
|
|
153
151
|
state.cv = currentViewshed;
|
|
152
|
+
if (forUrl && state.cv.properties?.title) {
|
|
153
|
+
if (Object.keys(state.properties).length === 1) {
|
|
154
|
+
delete state.cv.properties;
|
|
155
|
+
} else {
|
|
156
|
+
delete state.cv.properties.title;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
154
159
|
}
|
|
155
160
|
|
|
156
161
|
return state;
|
package/src/viewshedManager.js
CHANGED
|
@@ -24,6 +24,7 @@ import ViewshedInteraction from './viewshedInteraction.js';
|
|
|
24
24
|
* @property {import("vue").ShallowRef<import("./viewshed.js").default | null>} currentViewshed The current viewshed, that is displayed in the map.
|
|
25
25
|
* @property {import("vue").Ref<null | boolean>} currentIsPersisted Whether current viewshed is persisted or not.
|
|
26
26
|
* @property {import("vue").Ref<import("@vcmap/core").EditFeaturesSession | import("@vcmap/core").EditGeometrySession | null>} currentEditSession The current edit session, when in MOVE mode. Read only.
|
|
27
|
+
* @property {import("vue").ShallowRef<import("ol").Feature[]>} currentFeatures The feature that is created for feature/geometry editing in {@link moveCurrentViewshed}. Needed to match the EditorManager API from the UI.
|
|
27
28
|
* @property {function(import("./viewshed.js").ViewshedTypes): void} createViewshed Creates a new viewshed and stops a running create process.
|
|
28
29
|
* @property {function(import("./viewshed.js").default):void} viewViewshed Changes mode to VIEW for passed Viewshed.
|
|
29
30
|
* @property {function(import("./viewshed.js").default):void} editViewshed Changes mode to EDIT for passed Viewshed.
|
|
@@ -129,6 +130,11 @@ export default function createViewshedManager(app, config, categoryHelper) {
|
|
|
129
130
|
let removeInteraction = () => {};
|
|
130
131
|
/** @type {import("vue").Ref<import("@vcmap/core").EditFeaturesSession | import("@vcmap/core").EditGeometrySession | null>} */
|
|
131
132
|
const currentEditSession = shallowRef(null);
|
|
133
|
+
/**
|
|
134
|
+
* The feature that is created for feature/geometry editing in {@link moveCurrentViewshed}. Needed to match the EditorManager API from the UI.
|
|
135
|
+
* @type {import("vue").ShallowRef<import("ol").Feature[]>}
|
|
136
|
+
*/
|
|
137
|
+
const currentFeatures = shallowRef([]);
|
|
132
138
|
|
|
133
139
|
let shadowMapChangedListener = () => {};
|
|
134
140
|
|
|
@@ -242,6 +248,8 @@ export default function createViewshedManager(app, config, categoryHelper) {
|
|
|
242
248
|
} = createLayerWithFeature(currentViewshed.value.position);
|
|
243
249
|
app.layers.add(layer);
|
|
244
250
|
|
|
251
|
+
currentFeatures.value = [feature];
|
|
252
|
+
|
|
245
253
|
if (heightMode.value === HeightModes.ABSOLUTE) {
|
|
246
254
|
currentEditSession.value = startEditFeaturesSession(app, layer);
|
|
247
255
|
currentEditSession.value.setFeatures([feature]);
|
|
@@ -276,6 +284,7 @@ export default function createViewshedManager(app, config, categoryHelper) {
|
|
|
276
284
|
}
|
|
277
285
|
currentEditSession.value?.stop();
|
|
278
286
|
currentEditSession.value = null;
|
|
287
|
+
currentFeatures.value = [];
|
|
279
288
|
app.layers.remove(layer);
|
|
280
289
|
destroyLayerWithFeature();
|
|
281
290
|
mode.value = ViewshedPluginModes.EDIT;
|
|
@@ -382,6 +391,7 @@ export default function createViewshedManager(app, config, categoryHelper) {
|
|
|
382
391
|
currentViewshed,
|
|
383
392
|
currentIsPersisted,
|
|
384
393
|
currentEditSession,
|
|
394
|
+
currentFeatures,
|
|
385
395
|
createViewshed,
|
|
386
396
|
viewViewshed(viewshed) {
|
|
387
397
|
changeMode(ViewshedPluginModes.VIEW, viewshed);
|