@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/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import './src/cesium/entity.js';
|
|
|
10
10
|
export { default as Category } from './src/category/category.js';
|
|
11
11
|
export { default as CategoryCollection } from './src/category/categoryCollection.js';
|
|
12
12
|
export { layerClassRegistry, tileProviderClassRegistry, featureProviderClassRegistry, mapClassRegistry, styleClassRegistry, categoryClassRegistry, getObjectFromClassRegistry, default as ClassRegistry } from './src/classRegistry.js';
|
|
13
|
-
export { volatileContextId, markVolatile, default as Context } from './src/context.js';
|
|
14
13
|
export { default as AbstractFeatureProvider } from './src/featureProvider/abstractFeatureProvider.js';
|
|
15
14
|
export { isProvidedFeature, showProvidedFeature } from './src/featureProvider/featureProviderSymbols.js';
|
|
16
15
|
export { default as TileProviderFeatureProvider } from './src/featureProvider/tileProviderFeatureProvider.js';
|
|
@@ -122,7 +121,7 @@ export { default as startEditFeaturesSession } from './src/util/editor/editFeatu
|
|
|
122
121
|
export { default as startEditGeometrySession } from './src/util/editor/editGeometrySession.js';
|
|
123
122
|
export { createVertex, getClosestPointOn2DLine, pointOnLine3D, pointOnLine2D, createCameraVerticalPlane, createHorizontalPlane, getCartographicFromPlane, drapeGeometryOnTerrain, placeGeometryOnTerrain, ensureFeatureAbsolute, clampFeature } from './src/util/editor/editorHelpers.js';
|
|
124
123
|
export { SessionType, setupScratchLayer, GeometryType } from './src/util/editor/editorSessionHelpers.js';
|
|
125
|
-
export { vertexSymbol, vertexIndex, handlerSymbol } from './src/util/editor/editorSymbols.js';
|
|
124
|
+
export { vertexSymbol, vertexIndex, handlerSymbol, mouseOverSymbol } from './src/util/editor/editorSymbols.js';
|
|
126
125
|
export { default as CreateBBoxInteraction } from './src/util/editor/interactions/createBBoxInteraction.js';
|
|
127
126
|
export { default as CreateCircleInteraction } from './src/util/editor/interactions/createCircleInteraction.js';
|
|
128
127
|
export { default as CreateLineStringInteraction } from './src/util/editor/interactions/createLineStringInteraction.js';
|
|
@@ -134,9 +133,11 @@ export { default as EnsureHandlerSelectionInteraction } from './src/util/editor/
|
|
|
134
133
|
export { default as InsertVertexInteraction } from './src/util/editor/interactions/insertVertexInteraction.js';
|
|
135
134
|
export { default as MapInteractionController } from './src/util/editor/interactions/mapInteractionController.js';
|
|
136
135
|
export { default as RemoveVertexInteraction } from './src/util/editor/interactions/removeVertexInteraction.js';
|
|
136
|
+
export { SelectionMode, default as SelectFeatureMouseOverInteraction } from './src/util/editor/interactions/selectFeatureMouseOverInteraction.js';
|
|
137
137
|
export { default as SelectMultiFeatureInteraction } from './src/util/editor/interactions/selectMultiFeatureInteraction.js';
|
|
138
138
|
export { default as SelectSingleFeatureInteraction } from './src/util/editor/interactions/selectSingleFeatureInteraction.js';
|
|
139
139
|
export { default as TranslateVertexInteraction } from './src/util/editor/interactions/translateVertexInteraction.js';
|
|
140
|
+
export { getDefaultHighlightStyle, default as startSelectFeaturesSession } from './src/util/editor/selectFeaturesSession.js';
|
|
140
141
|
export { default as create2DHandlers } from './src/util/editor/transformation/create2DHandlers.js';
|
|
141
142
|
export { default as create3DHandlers } from './src/util/editor/transformation/create3DHandlers.js';
|
|
142
143
|
export { default as ExtrudeInteraction } from './src/util/editor/transformation/extrudeInteraction.js';
|
|
@@ -169,7 +170,8 @@ export { isOverrideCollection, default as makeOverrideCollection } from './src/u
|
|
|
169
170
|
export { wgs84ToMercatorTransformer, mercatorToWgs84Transformer, setDefaultProjectionOptions, getDefaultProjection, wgs84Projection, mercatorProjection, default as Projection } from './src/util/projection.js';
|
|
170
171
|
export { isSameOrigin } from './src/util/urlHelpers.js';
|
|
171
172
|
export { propertyEqualsEpsilon, angleEqualsEpsilon, coordinateEqualsEpsilon, default as Viewpoint } from './src/util/viewpoint.js';
|
|
172
|
-
export {
|
|
173
|
-
export { contextIdSymbol, deserializeMap, deserializeViewpoint, deserializeLayer, serializeLayer, getLayerIndex, destroyCollection } from './src/vcsAppContextHelpers.js';
|
|
173
|
+
export { defaultDynamicModuleId, getVcsAppById, default as VcsApp } from './src/vcsApp.js';
|
|
174
174
|
export { default as VcsEvent } from './src/vcsEvent.js';
|
|
175
|
+
export { volatileModuleId, markVolatile, default as VcsModule } from './src/vcsModule.js';
|
|
176
|
+
export { moduleIdSymbol, deserializeMap, deserializeViewpoint, deserializeLayer, serializeLayer, getLayerIndex, destroyCollection } from './src/vcsModuleHelpers.js';
|
|
175
177
|
export { default as VcsObject } from './src/vcsObject.js';
|
package/package.json
CHANGED
package/src/category/category.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { check } from '@vcsuite/check';
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
import { Feature } from 'ol';
|
|
4
|
-
import {
|
|
4
|
+
import { moduleIdSymbol, destroyCollection } from '../vcsModuleHelpers.js';
|
|
5
5
|
import makeOverrideCollection, { isOverrideCollection } from '../util/overrideCollection.js';
|
|
6
6
|
import VcsObject from '../vcsObject.js';
|
|
7
7
|
import VectorLayer from '../layer/vectorLayer.js';
|
|
@@ -25,7 +25,7 @@ import VcsEvent from '../vcsEvent.js';
|
|
|
25
25
|
/**
|
|
26
26
|
* @type {*|string}
|
|
27
27
|
*/
|
|
28
|
-
const
|
|
28
|
+
const categoryModuleId = uuidv4();
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @param {import("@vcmap/core").VectorLayer} layer
|
|
@@ -69,7 +69,7 @@ function checkMergeOptionOverride(key, value, defaultOption, option) {
|
|
|
69
69
|
/**
|
|
70
70
|
* A category contains user based items and is a special container. The container should not be created directly, but via
|
|
71
71
|
* the requestCategory API on the categories collection. Do not use toJSON to retrieve the state of a category, since
|
|
72
|
-
* categories outlive
|
|
72
|
+
* categories outlive modules and may be changed with mergeOptions to no longer reflect your initial state. Requestors
|
|
73
73
|
* should keep track of the requested options themselves.
|
|
74
74
|
* @class
|
|
75
75
|
* @extends {VcsObject}
|
|
@@ -128,7 +128,7 @@ class Category extends VcsObject {
|
|
|
128
128
|
this._layer = null;
|
|
129
129
|
if (this._featureProperty) {
|
|
130
130
|
this._layer = new VectorLayer(this._layerOptions);
|
|
131
|
-
this._layer[
|
|
131
|
+
this._layer[moduleIdSymbol] = categoryModuleId;
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* @type {string}
|
|
@@ -156,7 +156,7 @@ class Category extends VcsObject {
|
|
|
156
156
|
* @type {function():void}
|
|
157
157
|
* @private
|
|
158
158
|
*/
|
|
159
|
-
this.
|
|
159
|
+
this._moduleRemovedListener = () => {};
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
/**
|
|
@@ -246,11 +246,11 @@ class Category extends VcsObject {
|
|
|
246
246
|
* @returns {string}
|
|
247
247
|
* @private
|
|
248
248
|
*/
|
|
249
|
-
|
|
249
|
+
_getDynamicModuleId() {
|
|
250
250
|
if (!this._app) {
|
|
251
|
-
throw new Error('Cannot get dynamic
|
|
251
|
+
throw new Error('Cannot get dynamic module id, before setting the vcApp');
|
|
252
252
|
}
|
|
253
|
-
return this._app.
|
|
253
|
+
return this._app.dynamicModuleId;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
/**
|
|
@@ -305,7 +305,7 @@ class Category extends VcsObject {
|
|
|
305
305
|
/** @type {OverrideCollection} */ (collection) :
|
|
306
306
|
makeOverrideCollection(
|
|
307
307
|
collection,
|
|
308
|
-
this.
|
|
308
|
+
this._getDynamicModuleId.bind(this),
|
|
309
309
|
this._serializeItem.bind(this),
|
|
310
310
|
this._deserializeItem.bind(this),
|
|
311
311
|
);
|
|
@@ -337,8 +337,8 @@ class Category extends VcsObject {
|
|
|
337
337
|
throw new Error('Cannot switch apps');
|
|
338
338
|
}
|
|
339
339
|
this._app = app;
|
|
340
|
-
this.
|
|
341
|
-
this._collection.
|
|
340
|
+
this._moduleRemovedListener = this._app.moduleRemoved.addEventListener((module) => {
|
|
341
|
+
this._collection.removeModule(module._id);
|
|
342
342
|
});
|
|
343
343
|
if (this._layer) {
|
|
344
344
|
this._app.layers.add(this._layer);
|
|
@@ -378,17 +378,17 @@ class Category extends VcsObject {
|
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
/**
|
|
381
|
-
* @param {string}
|
|
381
|
+
* @param {string} moduleId
|
|
382
382
|
* @returns {{ name: string, items: Array<Object>}|null}
|
|
383
383
|
*/
|
|
384
|
-
|
|
384
|
+
serializeModule(moduleId) {
|
|
385
385
|
if (this._collection.size === 0) {
|
|
386
386
|
return null;
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
return {
|
|
390
390
|
name: this.name,
|
|
391
|
-
items: this.collection.
|
|
391
|
+
items: this.collection.serializeModule(moduleId),
|
|
392
392
|
};
|
|
393
393
|
}
|
|
394
394
|
|
|
@@ -431,8 +431,8 @@ class Category extends VcsObject {
|
|
|
431
431
|
|
|
432
432
|
this._collectionListeners.forEach((cb) => { cb(); });
|
|
433
433
|
this._collectionListeners.splice(0);
|
|
434
|
-
this.
|
|
435
|
-
this.
|
|
434
|
+
this._moduleRemovedListener();
|
|
435
|
+
this._moduleRemovedListener = () => {};
|
|
436
436
|
destroyCollection(this._collection);
|
|
437
437
|
this._collectionChanged.destroy();
|
|
438
438
|
this._app = null;
|
|
@@ -26,7 +26,7 @@ class CategoryCollection extends IndexedCollection {
|
|
|
26
26
|
*/
|
|
27
27
|
this._app = app;
|
|
28
28
|
/**
|
|
29
|
-
* Map of category names, where the value is a map of
|
|
29
|
+
* Map of category names, where the value is a map of moduleId and items.
|
|
30
30
|
* @type {Map<string, Map<string, Array<Object>>>}
|
|
31
31
|
* @private
|
|
32
32
|
*/
|
|
@@ -35,10 +35,10 @@ class CategoryCollection extends IndexedCollection {
|
|
|
35
35
|
* @type {Function}
|
|
36
36
|
* @private
|
|
37
37
|
*/
|
|
38
|
-
this.
|
|
39
|
-
this._cache.forEach((
|
|
40
|
-
|
|
41
|
-
if (
|
|
38
|
+
this._moduleRemovedListener = this._app.moduleRemoved.addEventListener((module) => {
|
|
39
|
+
this._cache.forEach((moduleMap, name) => {
|
|
40
|
+
moduleMap.delete(module._id);
|
|
41
|
+
if (moduleMap.size === 0) {
|
|
42
42
|
this._cache.delete(name);
|
|
43
43
|
}
|
|
44
44
|
});
|
|
@@ -60,8 +60,8 @@ class CategoryCollection extends IndexedCollection {
|
|
|
60
60
|
if (added != null && this._cache.has(category.name)) {
|
|
61
61
|
this._cache
|
|
62
62
|
.get(category.name)
|
|
63
|
-
.forEach((items,
|
|
64
|
-
this.parseCategoryItems(category.name, items,
|
|
63
|
+
.forEach((items, moduleId) => {
|
|
64
|
+
this.parseCategoryItems(category.name, items, moduleId);
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
this._cache.delete(category.name);
|
|
@@ -83,18 +83,18 @@ class CategoryCollection extends IndexedCollection {
|
|
|
83
83
|
* they will be cached, until such a category is requested.
|
|
84
84
|
* @param {string} name
|
|
85
85
|
* @param {Array<Object>} items
|
|
86
|
-
* @param {string}
|
|
86
|
+
* @param {string} moduleId
|
|
87
87
|
* @returns {Promise<void>}
|
|
88
88
|
*/
|
|
89
|
-
async parseCategoryItems(name, items,
|
|
89
|
+
async parseCategoryItems(name, items, moduleId) {
|
|
90
90
|
const category = this.getByKey(name);
|
|
91
91
|
|
|
92
92
|
if (category) {
|
|
93
|
-
await category.collection.parseItems(items,
|
|
93
|
+
await category.collection.parseItems(items, moduleId);
|
|
94
94
|
} else if (this._cache.has(name)) {
|
|
95
|
-
this._cache.get(name).set(
|
|
95
|
+
this._cache.get(name).set(moduleId, items);
|
|
96
96
|
} else {
|
|
97
|
-
this._cache.set(name, new Map([[
|
|
97
|
+
this._cache.set(name, new Map([[moduleId, items]]));
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -135,7 +135,7 @@ class CategoryCollection extends IndexedCollection {
|
|
|
135
135
|
|
|
136
136
|
destroy() {
|
|
137
137
|
super.destroy();
|
|
138
|
-
this.
|
|
138
|
+
this._moduleRemovedListener();
|
|
139
139
|
this._cache.clear();
|
|
140
140
|
this._app = null;
|
|
141
141
|
}
|
|
@@ -215,18 +215,18 @@ class EventHandler {
|
|
|
215
215
|
* Add a dynamic interaction to the interaction chain. This is the default methodology for
|
|
216
216
|
* user map interactions, such as drawing or measuring. If another exclusive interaction is added,
|
|
217
217
|
* this interaction is removed and a provided callback is called. Use the id parameter to add multiple interactions
|
|
218
|
-
* from the same source (if you don't wish to provide an {@link InteractionChain}
|
|
218
|
+
* from the same source (if you don't wish to provide an {@link InteractionChain})
|
|
219
219
|
* @param {AbstractInteraction} interaction
|
|
220
220
|
* @param {Function} removed - the callback for when the interaction is forcefully removed.
|
|
221
|
-
* @param {number=}
|
|
221
|
+
* @param {number=} index - the position at which to push the interaction. If no index is provided, the interaction is pushed at the end and therefore is executed last.
|
|
222
222
|
* @param {string=} id - an id to allow for multiple interactions to belong to the same exclusive registerer
|
|
223
223
|
* @returns {Function} function to remove the interaction with. returns number of removed interactions (0|1)
|
|
224
224
|
* @api
|
|
225
225
|
*/
|
|
226
|
-
addExclusiveInteraction(interaction, removed, index
|
|
226
|
+
addExclusiveInteraction(interaction, removed, index, id) {
|
|
227
227
|
check(interaction, AbstractInteraction);
|
|
228
228
|
check(removed, Function);
|
|
229
|
-
|
|
229
|
+
checkMaybe(index, Number);
|
|
230
230
|
checkMaybe(id, String);
|
|
231
231
|
|
|
232
232
|
if (this._exclusiveInteraction && this._exclusiveInteraction.id !== id) {
|
|
@@ -3,7 +3,6 @@ import Feature from 'ol/Feature.js';
|
|
|
3
3
|
import Style from 'ol/style/Style.js';
|
|
4
4
|
|
|
5
5
|
import VectorStyleItem, { fromCesiumColor } from '../style/vectorStyleItem.js';
|
|
6
|
-
import { emptyStyle } from '../style/styleHelpers.js';
|
|
7
6
|
import VcsEvent from '../vcsEvent.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -71,7 +70,7 @@ export function hideFeature(feature) {
|
|
|
71
70
|
) {
|
|
72
71
|
feature.show = false;
|
|
73
72
|
} else if (feature instanceof Feature) {
|
|
74
|
-
feature.
|
|
73
|
+
feature.changed();
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
|
|
@@ -106,7 +105,7 @@ export function resetOriginalStyle(feature) {
|
|
|
106
105
|
) {
|
|
107
106
|
feature.color = style;
|
|
108
107
|
} else if (feature instanceof Feature) {
|
|
109
|
-
feature.
|
|
108
|
+
feature.changed();
|
|
110
109
|
}
|
|
111
110
|
delete feature[originalStyle];
|
|
112
111
|
}
|
|
@@ -125,7 +124,7 @@ export function highlightFeature(feature) {
|
|
|
125
124
|
) {
|
|
126
125
|
feature.color = style.cesiumFillColor;
|
|
127
126
|
} else if (feature instanceof Feature) {
|
|
128
|
-
feature.
|
|
127
|
+
feature.changed();
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
130
|
}
|
package/src/layer/globalHider.js
CHANGED
|
@@ -17,7 +17,7 @@ import VcsEvent from '../vcsEvent.js';
|
|
|
17
17
|
* GlobalHider globally hides features existing within a layer of a {@link LayerCollection}.
|
|
18
18
|
* Features can be defined as hidden by {@link VcsAppConfig} or {@link LayerOptions}.
|
|
19
19
|
* Hiding will be performed, when a {@link Context} is loaded, a {@link Layer} is activated or GlobalHider API is called.
|
|
20
|
-
* A feature can be hidden multiple times by different actors, e.g.
|
|
20
|
+
* A feature can be hidden multiple times by different actors, e.g. modules, layers, which is handled by this class.
|
|
21
21
|
* A feature will be shown again, when a {@link Context} is removed, a {@link Layer} is deactivated or GlobalHider API is called.
|
|
22
22
|
* @class
|
|
23
23
|
*/
|
package/src/layer/layer.js
CHANGED
|
@@ -31,6 +31,7 @@ import GlobalHider from './globalHider.js';
|
|
|
31
31
|
* @property {number|undefined} screenSpaceError
|
|
32
32
|
* @property {*|undefined} flightOptions
|
|
33
33
|
* @property {string|undefined} baseUrl
|
|
34
|
+
* @property {Object|undefined} [layerProperties] - the layers properties bag
|
|
34
35
|
* @api
|
|
35
36
|
*/
|
|
36
37
|
|
|
@@ -86,7 +87,7 @@ import GlobalHider from './globalHider.js';
|
|
|
86
87
|
* @type {string}
|
|
87
88
|
* @const
|
|
88
89
|
*/
|
|
89
|
-
export const vcsMetaVersion = '2.
|
|
90
|
+
export const vcsMetaVersion = '2.1';
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
93
|
* Abstract base class for Layers.
|
package/src/layer/vectorLayer.js
CHANGED
|
@@ -288,6 +288,10 @@ class VectorLayer extends FeatureLayer {
|
|
|
288
288
|
// TODO embed icons here by running over all features? this is never used anywhere
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
if (Object.keys(this.properties).length !== 0) {
|
|
292
|
+
vcsMeta.layerProperties = { ...this.properties };
|
|
293
|
+
}
|
|
294
|
+
|
|
291
295
|
return vcsMeta;
|
|
292
296
|
}
|
|
293
297
|
|
|
@@ -297,6 +301,9 @@ class VectorLayer extends FeatureLayer {
|
|
|
297
301
|
*/
|
|
298
302
|
setVcsMeta(vcsMeta) { // XXX what about the style?
|
|
299
303
|
this.vectorProperties.setVcsMeta(vcsMeta);
|
|
304
|
+
if (vcsMeta.layerProperties) {
|
|
305
|
+
Object.assign(this.properties, vcsMeta.layerProperties);
|
|
306
|
+
}
|
|
300
307
|
}
|
|
301
308
|
|
|
302
309
|
/**
|
package/src/oblique/helpers.js
CHANGED
|
@@ -437,16 +437,14 @@ export async function transformFromImage(image, imageCoordinate, options = {}) {
|
|
|
437
437
|
* @returns {boolean}
|
|
438
438
|
*/
|
|
439
439
|
export function hasSameOrigin(url) {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
// data uri, return true
|
|
445
|
-
if (/^data:/.test(url)) {
|
|
440
|
+
const windowUrl = new URL(window.location.href);
|
|
441
|
+
const parsedUrl = new URL(url, window.location.href);
|
|
442
|
+
|
|
443
|
+
if (parsedUrl.protocol === 'data:') {
|
|
446
444
|
return true;
|
|
447
445
|
}
|
|
448
446
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
447
|
+
return windowUrl.origin === parsedUrl.origin &&
|
|
448
|
+
windowUrl.port === parsedUrl.port &&
|
|
449
|
+
windowUrl.protocol === parsedUrl.protocol;
|
|
452
450
|
}
|
package/src/ol/feature.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import Feature from 'ol/Feature.js';
|
|
2
|
+
import { Style } from 'ol/style.js';
|
|
3
|
+
import { globalHidden, hidden, highlighted } from '../layer/featureVisibility.js';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* To be used for cesium 3D style functions
|
|
@@ -43,5 +45,31 @@ Feature.prototype.getPropertyInherited = function getPropertyInherited(property)
|
|
|
43
45
|
return this.getProperty(property);
|
|
44
46
|
};
|
|
45
47
|
|
|
48
|
+
const originalStyleFunction = Feature.prototype.getStyleFunction;
|
|
49
|
+
Feature.prototype.getStyleFunction = function getStyleFunction() {
|
|
50
|
+
if (this[hidden] || this[globalHidden]) {
|
|
51
|
+
return () => [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (this[highlighted]) {
|
|
55
|
+
return () => [this[highlighted].style];
|
|
56
|
+
}
|
|
57
|
+
return originalStyleFunction.bind(this)();
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const originalGetStyle = Feature.prototype.getStyle;
|
|
61
|
+
Feature.prototype.getStyle = function getStyle() {
|
|
62
|
+
if (this[hidden] || this[globalHidden]) {
|
|
63
|
+
return new Style({});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (this[highlighted]) {
|
|
67
|
+
return this[highlighted].style;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return originalGetStyle.bind(this)();
|
|
71
|
+
};
|
|
72
|
+
|
|
46
73
|
// TODO implement getExactClassName, isClass & isExactClass
|
|
47
74
|
// TODO implement feature.content.tileset.timeSinceLoad
|
|
75
|
+
|
|
@@ -20,12 +20,12 @@ class OverrideClassRegistry {
|
|
|
20
20
|
constructor(coreClassRegistry) {
|
|
21
21
|
this._coreClassRegistry = coreClassRegistry;
|
|
22
22
|
/**
|
|
23
|
-
* @type {Map<string, {
|
|
23
|
+
* @type {Map<string, { moduleId: string, ctor: function(new: T, ...*) }>}
|
|
24
24
|
* @private
|
|
25
25
|
*/
|
|
26
26
|
this._classMap = new Map();
|
|
27
27
|
/**
|
|
28
|
-
* @type {Map<string, Array<{
|
|
28
|
+
* @type {Map<string, Array<{ moduleId: string, ctor: function(new: T, ...*) }>>}
|
|
29
29
|
* @private
|
|
30
30
|
*/
|
|
31
31
|
this._classShadows = new Map();
|
|
@@ -49,18 +49,18 @@ class OverrideClassRegistry {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Register a class for a given
|
|
53
|
-
* @param {string}
|
|
52
|
+
* Register a class for a given module by name. If the class already exists, it will be replaced and replaced called with the classeName.
|
|
53
|
+
* @param {string} moduleId
|
|
54
54
|
* @param {string} className
|
|
55
55
|
* @param {function(new: T, ...*)} ctor
|
|
56
56
|
*/
|
|
57
|
-
registerClass(
|
|
58
|
-
check(
|
|
57
|
+
registerClass(moduleId, className, ctor) {
|
|
58
|
+
check(moduleId, String);
|
|
59
59
|
check(className, String);
|
|
60
60
|
check(ctor, Function);
|
|
61
61
|
|
|
62
62
|
const entry = {
|
|
63
|
-
|
|
63
|
+
moduleId,
|
|
64
64
|
ctor,
|
|
65
65
|
};
|
|
66
66
|
|
|
@@ -83,16 +83,16 @@ class OverrideClassRegistry {
|
|
|
83
83
|
* Unregister a previously registered class. You can only unregister classes added to this registry, not the underlying core registry.
|
|
84
84
|
* If when registering this class you have replaced class, it will be re-instated and replaced called.
|
|
85
85
|
* If there is no previously registered class, it will be removed and removed will be called.
|
|
86
|
-
* @param {string}
|
|
86
|
+
* @param {string} moduleId
|
|
87
87
|
* @param {string} className
|
|
88
88
|
*/
|
|
89
|
-
unregisterClass(
|
|
90
|
-
check(
|
|
89
|
+
unregisterClass(moduleId, className) {
|
|
90
|
+
check(moduleId, String);
|
|
91
91
|
check(className, String);
|
|
92
92
|
|
|
93
93
|
if (this._classShadows.has(className)) {
|
|
94
94
|
const shadowsArray = this._classShadows.get(className);
|
|
95
|
-
const newShadowsArray = shadowsArray.filter(e => e.
|
|
95
|
+
const newShadowsArray = shadowsArray.filter(e => e.moduleId !== moduleId);
|
|
96
96
|
if (newShadowsArray.length === 0) {
|
|
97
97
|
this._classShadows.delete(className);
|
|
98
98
|
} else if (newShadowsArray.length !== shadowsArray.length) {
|
|
@@ -102,7 +102,7 @@ class OverrideClassRegistry {
|
|
|
102
102
|
|
|
103
103
|
if (
|
|
104
104
|
this._classMap.has(className) &&
|
|
105
|
-
this._classMap.get(className).
|
|
105
|
+
this._classMap.get(className).moduleId === moduleId
|
|
106
106
|
) {
|
|
107
107
|
this._classMap.delete(className);
|
|
108
108
|
if (this._classShadows.has(className)) {
|
|
@@ -177,15 +177,15 @@ class OverrideClassRegistry {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
|
-
* Removes all classes registered from within a certain
|
|
180
|
+
* Removes all classes registered from within a certain module. Will re-instate classes overwritten by the module
|
|
181
181
|
* and call the appropriate events, outlined in unregisterClass.
|
|
182
|
-
* @param {string}
|
|
182
|
+
* @param {string} moduleId
|
|
183
183
|
*/
|
|
184
|
-
|
|
185
|
-
check(
|
|
184
|
+
removeModule(moduleId) {
|
|
185
|
+
check(moduleId, String);
|
|
186
186
|
|
|
187
187
|
this._classMap.forEach((cb, className) => {
|
|
188
|
-
this.unregisterClass(
|
|
188
|
+
this.unregisterClass(moduleId, className);
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
191
|
|
|
@@ -11,7 +11,6 @@ import Fill from 'ol/style/Fill.js';
|
|
|
11
11
|
import StyleItem from './styleItem.js';
|
|
12
12
|
import {
|
|
13
13
|
cesiumColorToColor,
|
|
14
|
-
emptyStyle,
|
|
15
14
|
getDefaultCondition,
|
|
16
15
|
whiteColor,
|
|
17
16
|
} from './styleHelpers.js';
|
|
@@ -191,7 +190,7 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
191
190
|
_styleFunction(feature) {
|
|
192
191
|
const actualFeature = feature[originalFeatureSymbol] || feature;
|
|
193
192
|
if (!this.cesiumStyle.show.evaluate(actualFeature)) {
|
|
194
|
-
return
|
|
193
|
+
return undefined;
|
|
195
194
|
}
|
|
196
195
|
|
|
197
196
|
const geometryType = actualFeature.getGeometry().getType();
|
|
@@ -219,7 +218,7 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
219
218
|
}
|
|
220
219
|
|
|
221
220
|
this.getLogger().warning(`could not style geometry type: ${geometryType}`);
|
|
222
|
-
return
|
|
221
|
+
return undefined;
|
|
223
222
|
}
|
|
224
223
|
|
|
225
224
|
/**
|