@vcmap/core 5.0.0-rc.27 → 5.0.0-rc.28
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/index.d.ts +273 -125
- package/index.js +6 -4
- package/package.json +1 -1
- package/src/category/category.js +16 -16
- package/src/category/categoryCollection.js +13 -13
- package/src/interaction/eventHandler.js +4 -4
- package/src/layer/featureVisibility.js +3 -4
- package/src/layer/globalHider.js +1 -1
- package/src/layer/layer.js +2 -1
- package/src/layer/vectorLayer.js +7 -0
- package/src/oblique/helpers.js +7 -9
- package/src/ol/feature.js +28 -0
- package/src/overrideClassRegistry.js +17 -17
- package/src/style/declarativeStyleItem.js +2 -3
- package/src/util/editor/editFeaturesSession.js +150 -166
- package/src/util/editor/editGeometrySession.js +69 -47
- package/src/util/editor/editorHelpers.js +3 -1
- package/src/util/editor/editorSessionHelpers.js +11 -3
- package/src/util/editor/editorSymbols.js +5 -0
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +15 -49
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +16 -33
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +5 -5
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +143 -0
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +17 -11
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +27 -8
- package/src/util/editor/interactions/translateVertexInteraction.js +2 -3
- package/src/util/editor/selectFeaturesSession.js +287 -0
- package/src/util/editor/transformation/transformationHandler.js +4 -9
- package/src/util/editor/transformation/transformationTypes.js +1 -0
- package/src/util/featureconverter/convert.js +1 -1
- package/src/util/indexedCollection.js +19 -3
- package/src/util/layerCollection.js +4 -2
- package/src/util/overrideCollection.js +20 -20
- package/src/vcsApp.js +107 -85
- package/src/vcsModule.js +129 -0
- package/src/{vcsAppContextHelpers.js → vcsModuleHelpers.js} +5 -5
- package/src/context.js +0 -89
package/src/vcsModule.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { moduleIdSymbol } from './vcsModuleHelpers.js';
|
|
3
|
+
import Projection from './util/projection.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} VcsModuleConfig
|
|
7
|
+
* @property {string|undefined} [_id]
|
|
8
|
+
* @property {string|undefined} [name]
|
|
9
|
+
* @property {string|undefined} [description]
|
|
10
|
+
* @property {Array<LayerOptions>} [layers]
|
|
11
|
+
* @property {Array<VcsMapOptions>} [maps]
|
|
12
|
+
* @property {Array<StyleItemOptions>} [styles]
|
|
13
|
+
* @property {Array<ViewpointOptions>} [viewpoints]
|
|
14
|
+
* @property {string} [startingViewpointName]
|
|
15
|
+
* @property {string} [startingMapName]
|
|
16
|
+
* @property {ProjectionOptions} [projection]
|
|
17
|
+
* @property {Array<{ name: string, items: Array<Object> }>} [categories]
|
|
18
|
+
* @property {Array<ObliqueCollectionOptions>} [obliqueCollections]
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The id of the volatile module. Objects with this id shall never be serialized.
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
export const volatileModuleId = uuidv4();
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This marks an object as "volatile". This ensures, that an object added to the {@see VcsApp}
|
|
29
|
+
* will never be serialized into a module, regardless of the current dynamic module. Typical use case is a scratch layer
|
|
30
|
+
* which represents temporary features.
|
|
31
|
+
* @param {import("@vcmap/core").VcsObject|Object} object - the object to mark as volatile
|
|
32
|
+
*/
|
|
33
|
+
export function markVolatile(object) {
|
|
34
|
+
object[moduleIdSymbol] = volatileModuleId;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @class
|
|
39
|
+
*/
|
|
40
|
+
class VcsModule {
|
|
41
|
+
/**
|
|
42
|
+
* @param {VcsModuleConfig} config
|
|
43
|
+
*/
|
|
44
|
+
constructor(config) {
|
|
45
|
+
/**
|
|
46
|
+
* @type {string}
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
this._uuid = config._id || uuidv4();
|
|
50
|
+
/**
|
|
51
|
+
* @type {string}
|
|
52
|
+
*/
|
|
53
|
+
this.name = config.name;
|
|
54
|
+
/**
|
|
55
|
+
* @type {string}
|
|
56
|
+
*/
|
|
57
|
+
this.description = config.description;
|
|
58
|
+
/**
|
|
59
|
+
* @type {string}
|
|
60
|
+
*/
|
|
61
|
+
this.startingViewpointName = config.startingViewpointName;
|
|
62
|
+
/**
|
|
63
|
+
* @type {string}
|
|
64
|
+
*/
|
|
65
|
+
this.startingMapName = config.startingMapName;
|
|
66
|
+
/**
|
|
67
|
+
* @type {Projection|undefined}
|
|
68
|
+
*/
|
|
69
|
+
this.projection = config.projection ? new Projection(config.projection) : undefined;
|
|
70
|
+
/**
|
|
71
|
+
* @type {VcsModuleConfig}
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
this._config = config;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @type {string}
|
|
79
|
+
* @readonly
|
|
80
|
+
*/
|
|
81
|
+
get _id() {
|
|
82
|
+
return this._uuid;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @type {VcsModuleConfig}
|
|
87
|
+
* @readonly
|
|
88
|
+
*/
|
|
89
|
+
get config() {
|
|
90
|
+
return JSON.parse(JSON.stringify(this._config));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Sets the config object by serializing all runtime objects of the current app.
|
|
95
|
+
* @param {import("@vcmap/core").VcsApp} app
|
|
96
|
+
*/
|
|
97
|
+
setConfigFromApp(app) {
|
|
98
|
+
this._config = app.serializeModule(this._uuid);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @returns {VcsModuleConfig}
|
|
104
|
+
*/
|
|
105
|
+
toJSON() {
|
|
106
|
+
const config = {};
|
|
107
|
+
if (this._config._id) {
|
|
108
|
+
config._id = this._config._id;
|
|
109
|
+
}
|
|
110
|
+
if (this.name) {
|
|
111
|
+
config.name = this.name;
|
|
112
|
+
}
|
|
113
|
+
if (this.description) {
|
|
114
|
+
config.description = this.description;
|
|
115
|
+
}
|
|
116
|
+
if (this.startingViewpointName) {
|
|
117
|
+
config.startingViewpointName = this.startingViewpointName;
|
|
118
|
+
}
|
|
119
|
+
if (this.startingMapName) {
|
|
120
|
+
config.startingMapName = this.startingMapName;
|
|
121
|
+
}
|
|
122
|
+
if (this.projection) {
|
|
123
|
+
config.projection = this.projection.toJSON();
|
|
124
|
+
}
|
|
125
|
+
return config;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export default VcsModule;
|
|
@@ -12,10 +12,10 @@ function getLogger() {
|
|
|
12
12
|
/**
|
|
13
13
|
* @type {symbol}
|
|
14
14
|
*/
|
|
15
|
-
export const
|
|
15
|
+
export const moduleIdSymbol = Symbol('moduleId');
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @typedef {LayerOptions}
|
|
18
|
+
* @typedef {LayerOptions} ModuleLayerOptions
|
|
19
19
|
* @property {string|StyleItemOptions} [style]
|
|
20
20
|
* @property {TileProviderOptions} [tileProvider]
|
|
21
21
|
* @property {AbstractFeatureProviderOptions} [featureProvider]
|
|
@@ -49,7 +49,7 @@ export function deserializeViewpoint(viewpointObject) {
|
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* @param {import("@vcmap/core").VcsApp} vcsApp
|
|
52
|
-
* @param {
|
|
52
|
+
* @param {ModuleLayerOptions} layerConfig
|
|
53
53
|
* @returns {import("@vcmap/core").Layer|null}
|
|
54
54
|
*/
|
|
55
55
|
export function deserializeLayer(vcsApp, layerConfig) {
|
|
@@ -81,10 +81,10 @@ export function deserializeLayer(vcsApp, layerConfig) {
|
|
|
81
81
|
/**
|
|
82
82
|
* @param {import("@vcmap/core").VcsApp} vcsApp
|
|
83
83
|
* @param {import("@vcmap/core").Layer} layer
|
|
84
|
-
* @returns {
|
|
84
|
+
* @returns {ModuleLayerOptions}
|
|
85
85
|
*/
|
|
86
86
|
export function serializeLayer(vcsApp, layer) {
|
|
87
|
-
const serializedLayer = /** @type {
|
|
87
|
+
const serializedLayer = /** @type {ModuleLayerOptions} */ (layer.toJSON());
|
|
88
88
|
serializedLayer.zIndex = layer[vcsApp.layers.zIndexSymbol];
|
|
89
89
|
if (
|
|
90
90
|
/** @type {StyleItemOptions} */ (serializedLayer?.style)?.name &&
|
package/src/context.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { v5 as uuidv5, v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { contextIdSymbol } from './vcsAppContextHelpers.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {Object} VcsAppConfig
|
|
6
|
-
* @property {string|undefined} [id]
|
|
7
|
-
* @property {Array<LayerOptions>} [layers]
|
|
8
|
-
* @property {Array<VcsMapOptions>} [maps]
|
|
9
|
-
* @property {Array<StyleItemOptions>} [styles]
|
|
10
|
-
* @property {Array<ViewpointOptions>} [viewpoints]
|
|
11
|
-
* @property {string} [startingViewpointName]
|
|
12
|
-
* @property {string} [startingMapName]
|
|
13
|
-
* @property {ProjectionOptions} [projection]
|
|
14
|
-
* @property {Array<{ name: string, items: Array<Object> }>} [categories]
|
|
15
|
-
* @property {Array<ObliqueCollectionOptions>} [obliqueCollections]
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @type {string}
|
|
20
|
-
*/
|
|
21
|
-
const uniqueNamespace = '9c27cc2d-552f-4637-9194-09329ed4c1dc';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The id of the volatile context. Objects with this id shall never be serialized.
|
|
25
|
-
* @type {string}
|
|
26
|
-
*/
|
|
27
|
-
export const volatileContextId = uuidv4();
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* This marks an object as "volatile". This ensures, that an object added to the {@see VcsApp}
|
|
31
|
-
* will never be serialized into a context, regardless of the current dynamic context. Typical use case is a scratch layer
|
|
32
|
-
* which represents temporary features.
|
|
33
|
-
* @param {import("@vcmap/core").VcsObject|Object} object - the object to mark as volatile
|
|
34
|
-
*/
|
|
35
|
-
export function markVolatile(object) {
|
|
36
|
-
object[contextIdSymbol] = volatileContextId;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @class
|
|
41
|
-
*/
|
|
42
|
-
class Context {
|
|
43
|
-
/**
|
|
44
|
-
* @param {VcsAppConfig} config
|
|
45
|
-
*/
|
|
46
|
-
constructor(config) {
|
|
47
|
-
/**
|
|
48
|
-
* @type {VcsAppConfig}
|
|
49
|
-
* @private
|
|
50
|
-
*/
|
|
51
|
-
this._config = config;
|
|
52
|
-
/**
|
|
53
|
-
* @type {string}
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
this._checkSum = uuidv5(JSON.stringify(config), uniqueNamespace);
|
|
57
|
-
/**
|
|
58
|
-
* @type {string}
|
|
59
|
-
* @private
|
|
60
|
-
*/
|
|
61
|
-
this._id = config.id || this._checkSum;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @type {string}
|
|
66
|
-
* @readonly
|
|
67
|
-
*/
|
|
68
|
-
get id() {
|
|
69
|
-
return this._id;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @type {string}
|
|
74
|
-
* @readonly
|
|
75
|
-
*/
|
|
76
|
-
get checkSum() {
|
|
77
|
-
return this._checkSum;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @type {VcsAppConfig}
|
|
82
|
-
* @readonly
|
|
83
|
-
*/
|
|
84
|
-
get config() {
|
|
85
|
-
return JSON.parse(JSON.stringify(this._config));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export default Context;
|