@vcmap/core 5.0.0-rc.28 → 5.0.0-rc.29
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/README.md +9 -3
- package/build/postinstall.js +13 -2
- package/index.d.ts +155 -106
- package/package.json +9 -4
- package/src/category/category.js +71 -32
- package/src/category/categoryCollection.js +27 -18
- package/src/cesium/cesiumVcsCameraPrimitive.js +13 -5
- package/src/cesium/entity.js +3 -1
- package/src/cesium/wallpaperMaterial.js +4 -2
- package/src/classRegistry.js +11 -4
- package/src/featureProvider/abstractFeatureProvider.js +43 -22
- package/src/featureProvider/tileProviderFeatureProvider.js +11 -5
- package/src/featureProvider/wmsFeatureProvider.js +37 -15
- package/src/interaction/abstractInteraction.js +5 -1
- package/src/interaction/coordinateAtPixel.js +34 -12
- package/src/interaction/eventHandler.js +63 -23
- package/src/interaction/featureAtPixelInteraction.js +96 -32
- package/src/interaction/featureProviderInteraction.js +23 -8
- package/src/interaction/interactionChain.js +19 -9
- package/src/interaction/interactionType.js +23 -26
- package/src/layer/cesium/cesiumTilesetCesiumImpl.js +45 -15
- package/src/layer/cesium/clusterContext.js +10 -3
- package/src/layer/cesium/dataSourceCesiumImpl.js +13 -4
- package/src/layer/cesium/openStreetMapCesiumImpl.js +7 -3
- package/src/layer/cesium/rasterLayerCesiumImpl.js +6 -2
- package/src/layer/cesium/singleImageCesiumImpl.js +14 -3
- package/src/layer/cesium/terrainCesiumImpl.js +3 -2
- package/src/layer/cesium/tmsCesiumImpl.js +15 -3
- package/src/layer/cesium/vectorCesiumImpl.js +69 -25
- package/src/layer/cesium/vectorContext.js +25 -5
- package/src/layer/cesium/vectorRasterTileCesiumImpl.js +15 -5
- package/src/layer/cesium/vectorTileImageryProvider.js +51 -13
- package/src/layer/cesium/wmsCesiumImpl.js +15 -3
- package/src/layer/cesium/wmtsCesiumImpl.js +18 -6
- package/src/layer/cesium/x3dmHelper.js +4 -1
- package/src/layer/cesiumTilesetLayer.js +55 -26
- package/src/layer/czmlLayer.js +11 -5
- package/src/layer/dataSourceLayer.js +25 -17
- package/src/layer/featureLayer.js +33 -18
- package/src/layer/featureStoreLayer.js +161 -99
- package/src/layer/featureStoreLayerChanges.js +57 -17
- package/src/layer/featureVisibility.js +89 -59
- package/src/layer/geojsonHelpers.js +70 -29
- package/src/layer/geojsonLayer.js +17 -11
- package/src/layer/globalHider.js +14 -4
- package/src/layer/layer.js +77 -44
- package/src/layer/layerImplementation.js +12 -4
- package/src/layer/oblique/layerObliqueImpl.js +3 -1
- package/src/layer/oblique/obliqueHelpers.js +75 -30
- package/src/layer/oblique/vectorObliqueImpl.js +175 -69
- package/src/layer/openStreetMapLayer.js +34 -20
- package/src/layer/openlayers/layerOpenlayersImpl.js +37 -15
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/singleImageOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tileDebugOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tmsOpenlayersImpl.js +6 -3
- package/src/layer/openlayers/vectorOpenlayersImpl.js +14 -4
- package/src/layer/openlayers/vectorTileOpenlayersImpl.js +12 -5
- package/src/layer/openlayers/wmsOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/wmtsOpenlayersImpl.js +12 -5
- package/src/layer/pointCloudLayer.js +21 -10
- package/src/layer/rasterLayer.js +73 -22
- package/src/layer/singleImageLayer.js +10 -7
- package/src/layer/terrainHelpers.js +30 -19
- package/src/layer/terrainLayer.js +16 -7
- package/src/layer/tileLoadedHelper.js +9 -4
- package/src/layer/tileProvider/mvtTileProvider.js +10 -4
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +10 -4
- package/src/layer/tileProvider/tileProvider.js +163 -87
- package/src/layer/tileProvider/urlTemplateTileProvider.js +10 -4
- package/src/layer/tmsLayer.js +7 -6
- package/src/layer/vectorHelpers.js +34 -25
- package/src/layer/vectorLayer.js +77 -36
- package/src/layer/vectorProperties.js +245 -74
- package/src/layer/vectorSymbols.js +3 -1
- package/src/layer/vectorTileLayer.js +121 -70
- package/src/layer/wfsLayer.js +19 -8
- package/src/layer/wmsHelpers.js +11 -6
- package/src/layer/wmsLayer.js +36 -14
- package/src/layer/wmtsLayer.js +35 -20
- package/src/map/baseOLMap.js +57 -31
- package/src/map/cameraLimiter.js +67 -18
- package/src/map/cesiumMap.js +307 -95
- package/src/map/obliqueMap.js +84 -34
- package/src/map/openlayersMap.js +40 -19
- package/src/map/vcsMap.js +21 -8
- package/src/oblique/helpers.js +212 -64
- package/src/oblique/obliqueCollection.js +111 -48
- package/src/oblique/obliqueDataSet.js +53 -21
- package/src/oblique/obliqueImage.js +50 -17
- package/src/oblique/obliqueImageMeta.js +7 -6
- package/src/oblique/obliqueProvider.js +75 -27
- package/src/oblique/obliqueView.js +18 -7
- package/src/oblique/obliqueViewDirection.js +3 -2
- package/src/oblique/parseImageJson.js +57 -23
- package/src/ol/feature.js +8 -3
- package/src/ol/geom/circle.js +12 -3
- package/src/ol/geom/geometryCollection.js +11 -4
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -9
- package/src/overrideClassRegistry.js +13 -3
- package/src/style/arcStyle.js +129 -36
- package/src/style/arrowStyle.js +57 -22
- package/src/style/declarativeStyleItem.js +107 -62
- package/src/style/shapesCategory.js +8 -6
- package/src/style/styleFactory.js +4 -1
- package/src/style/styleHelpers.js +17 -8
- package/src/style/styleItem.js +28 -10
- package/src/style/vectorStyleItem.js +160 -74
- package/src/style/writeStyle.js +5 -7
- package/src/util/clipping/clippingObject.js +72 -38
- package/src/util/clipping/clippingObjectManager.js +53 -19
- package/src/util/clipping/clippingPlaneHelper.js +120 -53
- package/src/util/collection.js +12 -6
- package/src/util/editor/createFeatureSession.js +21 -6
- package/src/util/editor/editFeaturesSession.js +41 -15
- package/src/util/editor/editGeometrySession.js +55 -30
- package/src/util/editor/editorHelpers.js +114 -29
- package/src/util/editor/editorSessionHelpers.js +8 -3
- package/src/util/editor/interactions/createBBoxInteraction.js +11 -3
- package/src/util/editor/interactions/createCircleInteraction.js +7 -2
- package/src/util/editor/interactions/createLineStringInteraction.js +7 -2
- package/src/util/editor/interactions/createPolygonInteraction.js +7 -2
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +7 -5
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +8 -3
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +4 -2
- package/src/util/editor/interactions/insertVertexInteraction.js +17 -6
- package/src/util/editor/interactions/mapInteractionController.js +31 -14
- package/src/util/editor/interactions/removeVertexInteraction.js +4 -1
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +19 -10
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +33 -20
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +14 -8
- package/src/util/editor/selectFeaturesSession.js +37 -21
- package/src/util/editor/transformation/create2DHandlers.js +82 -37
- package/src/util/editor/transformation/create3DHandlers.js +187 -84
- package/src/util/editor/transformation/extrudeInteraction.js +20 -5
- package/src/util/editor/transformation/rotateInteraction.js +29 -16
- package/src/util/editor/transformation/scaleInteraction.js +31 -15
- package/src/util/editor/transformation/transformationHandler.js +23 -8
- package/src/util/editor/transformation/transformationTypes.js +8 -4
- package/src/util/editor/transformation/translateInteraction.js +86 -32
- package/src/util/editor/validateGeoemetry.js +3 -1
- package/src/util/exclusiveManager.js +6 -3
- package/src/util/extent.js +20 -10
- package/src/util/featureconverter/arcToCesium.js +46 -12
- package/src/util/featureconverter/circleToCesium.js +61 -27
- package/src/util/featureconverter/convert.js +85 -13
- package/src/util/featureconverter/extent3D.js +69 -28
- package/src/util/featureconverter/featureconverterHelper.js +232 -79
- package/src/util/featureconverter/lineStringToCesium.js +107 -35
- package/src/util/featureconverter/pointHelpers.js +117 -45
- package/src/util/featureconverter/pointToCesium.js +128 -31
- package/src/util/featureconverter/polygonToCesium.js +50 -16
- package/src/util/fetch.js +3 -1
- package/src/util/geometryHelpers.js +15 -10
- package/src/util/indexedCollection.js +7 -3
- package/src/util/isMobile.js +8 -2
- package/src/util/layerCollection.js +28 -12
- package/src/util/mapCollection.js +37 -18
- package/src/util/math.js +35 -19
- package/src/util/overrideCollection.js +57 -32
- package/src/util/projection.js +21 -5
- package/src/util/urlHelpers.js +5 -3
- package/src/util/viewpoint.js +66 -33
- package/src/vcsApp.js +133 -69
- package/src/vcsModule.js +3 -2
- package/src/vcsModuleHelpers.js +24 -9
- package/src/vcsObject.js +3 -2
- package/tests/data/dynamicPointCzml.json +24 -35
- package/tests/data/oblique/imageData/imagev34.json +56 -272
- package/tests/data/oblique/imageData/imagev35.json +272 -19
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +299 -19
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -1
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -1
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -1
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -1
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -1
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -1
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -1
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -1
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -1
- package/tests/data/oblique/tiledImageData/image.json +70 -1
- package/tests/data/terrain/layer.json +121 -130
- package/tests/data/testGeoJSON.json +4 -16
- package/tests/unit/helpers/cesiumHelpers.js +58 -33
- package/tests/unit/helpers/helpers.js +10 -2
- package/tests/unit/helpers/imageHelpers.js +8 -4
- package/tests/unit/helpers/obliqueData.js +39 -13
- package/tests/unit/helpers/obliqueHelpers.js +12 -9
- package/tests/unit/helpers/openlayersHelpers.js +4 -1
- package/tests/unit/helpers/terrain/terrainData.js +8 -7
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Color,
|
|
3
|
+
Cesium3DTileFeature,
|
|
4
|
+
Cesium3DTilePointFeature,
|
|
5
|
+
Entity as CesiumEntity,
|
|
6
|
+
} from '@vcmap-cesium/engine';
|
|
2
7
|
import Feature from 'ol/Feature.js';
|
|
3
8
|
import Style from 'ol/style/Style.js';
|
|
4
9
|
|
|
@@ -51,10 +56,12 @@ export const globalHidden = Symbol('globalHidden');
|
|
|
51
56
|
* @returns {boolean}
|
|
52
57
|
*/
|
|
53
58
|
export function featureExists(feature) {
|
|
54
|
-
return
|
|
59
|
+
return (
|
|
60
|
+
feature &&
|
|
55
61
|
feature.content &&
|
|
56
62
|
!feature.content.isDestroyed() &&
|
|
57
|
-
!feature.content.batchTable.isDestroyed()
|
|
63
|
+
!feature.content.batchTable.isDestroyed()
|
|
64
|
+
);
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
/**
|
|
@@ -63,10 +70,10 @@ export function featureExists(feature) {
|
|
|
63
70
|
*/
|
|
64
71
|
export function hideFeature(feature) {
|
|
65
72
|
if (
|
|
66
|
-
(
|
|
67
|
-
|
|
68
|
-
featureExists(feature)
|
|
69
|
-
|
|
73
|
+
((feature instanceof Cesium3DTileFeature ||
|
|
74
|
+
feature instanceof Cesium3DTilePointFeature) &&
|
|
75
|
+
featureExists(feature)) ||
|
|
76
|
+
feature instanceof CesiumEntity
|
|
70
77
|
) {
|
|
71
78
|
feature.show = false;
|
|
72
79
|
} else if (feature instanceof Feature) {
|
|
@@ -82,7 +89,8 @@ export function hideFeature(feature) {
|
|
|
82
89
|
export function cacheOriginalStyle(feature) {
|
|
83
90
|
if (!Reflect.has(feature, originalStyle)) {
|
|
84
91
|
if (
|
|
85
|
-
(feature instanceof Cesium3DTileFeature ||
|
|
92
|
+
(feature instanceof Cesium3DTileFeature ||
|
|
93
|
+
feature instanceof Cesium3DTilePointFeature) &&
|
|
86
94
|
featureExists(feature)
|
|
87
95
|
) {
|
|
88
96
|
feature[originalStyle] = feature.color.clone();
|
|
@@ -100,7 +108,8 @@ export function resetOriginalStyle(feature) {
|
|
|
100
108
|
if (!(feature[globalHidden] || feature[hidden] || feature[highlighted])) {
|
|
101
109
|
const style = feature[originalStyle];
|
|
102
110
|
if (
|
|
103
|
-
(feature instanceof Cesium3DTileFeature ||
|
|
111
|
+
(feature instanceof Cesium3DTileFeature ||
|
|
112
|
+
feature instanceof Cesium3DTilePointFeature) &&
|
|
104
113
|
featureExists(feature)
|
|
105
114
|
) {
|
|
106
115
|
feature.color = style;
|
|
@@ -119,7 +128,8 @@ export function highlightFeature(feature) {
|
|
|
119
128
|
if (!(feature[globalHidden] || feature[hidden])) {
|
|
120
129
|
const style = feature[highlighted];
|
|
121
130
|
if (
|
|
122
|
-
(feature instanceof Cesium3DTileFeature ||
|
|
131
|
+
(feature instanceof Cesium3DTileFeature ||
|
|
132
|
+
feature instanceof Cesium3DTilePointFeature) &&
|
|
123
133
|
featureExists(feature)
|
|
124
134
|
) {
|
|
125
135
|
feature.color = style.cesiumFillColor;
|
|
@@ -162,10 +172,10 @@ export function showFeature(feature, symbol) {
|
|
|
162
172
|
|
|
163
173
|
if (!(feature[hidden] || feature[globalHidden])) {
|
|
164
174
|
if (
|
|
165
|
-
(
|
|
166
|
-
|
|
167
|
-
featureExists(feature)
|
|
168
|
-
|
|
175
|
+
((feature instanceof Cesium3DTileFeature ||
|
|
176
|
+
feature instanceof Cesium3DTilePointFeature) &&
|
|
177
|
+
featureExists(feature)) ||
|
|
178
|
+
feature instanceof CesiumEntity
|
|
169
179
|
) {
|
|
170
180
|
feature.show = true;
|
|
171
181
|
}
|
|
@@ -258,41 +268,47 @@ class FeatureVisibility {
|
|
|
258
268
|
*/
|
|
259
269
|
highlight(toHighlight) {
|
|
260
270
|
const updatedIds = [];
|
|
261
|
-
Object.entries(toHighlight)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
// eslint-disable-next-line no-self-assign
|
|
275
|
-
usedStyle = /** @type {VectorStyleItem} */ (usedStyle);
|
|
276
|
-
|
|
277
|
-
if (!this.highlightedObjects[id]) {
|
|
278
|
-
this.highlightedObjects[id] = {
|
|
279
|
-
style: usedStyle,
|
|
280
|
-
features: new Set(),
|
|
281
|
-
};
|
|
282
|
-
updatedIds.push(id);
|
|
283
|
-
// @ts-ignore
|
|
284
|
-
} else if (this.highlightedObjects[id].style !== usedStyle) {
|
|
285
|
-
this.highlightedObjects[id].style = usedStyle;
|
|
286
|
-
this.highlightedObjects[id].features.forEach((s, feature) => {
|
|
287
|
-
feature[highlighted] = usedStyle;
|
|
288
|
-
highlightFeature(feature);
|
|
289
|
-
});
|
|
271
|
+
Object.entries(toHighlight).forEach(([id, style]) => {
|
|
272
|
+
let usedStyle = style;
|
|
273
|
+
if (style instanceof Color) {
|
|
274
|
+
usedStyle = fromCesiumColor(style);
|
|
275
|
+
} else if (style instanceof Style) {
|
|
276
|
+
usedStyle = new VectorStyleItem({});
|
|
277
|
+
if (
|
|
278
|
+
style.getText() &&
|
|
279
|
+
style.getText().getText() &&
|
|
280
|
+
!Array.isArray(style.getText().getText())
|
|
281
|
+
) {
|
|
282
|
+
// getText can return a rich Text Array<string> We do not support this at the moment.
|
|
283
|
+
usedStyle.label = String(style.getText().getText());
|
|
290
284
|
}
|
|
291
|
-
|
|
285
|
+
usedStyle.style = style;
|
|
286
|
+
}
|
|
287
|
+
// eslint-disable-next-line no-self-assign
|
|
288
|
+
usedStyle = /** @type {VectorStyleItem} */ (usedStyle);
|
|
289
|
+
|
|
290
|
+
if (!this.highlightedObjects[id]) {
|
|
291
|
+
this.highlightedObjects[id] = {
|
|
292
|
+
style: usedStyle,
|
|
293
|
+
features: new Set(),
|
|
294
|
+
};
|
|
295
|
+
updatedIds.push(id);
|
|
296
|
+
// @ts-ignore
|
|
297
|
+
} else if (this.highlightedObjects[id].style !== usedStyle) {
|
|
298
|
+
this.highlightedObjects[id].style = usedStyle;
|
|
299
|
+
this.highlightedObjects[id].features.forEach((s, feature) => {
|
|
300
|
+
feature[highlighted] = usedStyle;
|
|
301
|
+
highlightFeature(feature);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
});
|
|
292
305
|
|
|
293
306
|
if (updatedIds.length > 0) {
|
|
294
307
|
this.lastUpdated = Date.now();
|
|
295
|
-
this.changed.raiseEvent({
|
|
308
|
+
this.changed.raiseEvent({
|
|
309
|
+
action: FeatureVisibilityAction.HIGHLIGHT,
|
|
310
|
+
ids: updatedIds,
|
|
311
|
+
});
|
|
296
312
|
}
|
|
297
313
|
}
|
|
298
314
|
|
|
@@ -305,17 +321,19 @@ class FeatureVisibility {
|
|
|
305
321
|
const updatedIds = [];
|
|
306
322
|
toUnHighlight.forEach((id) => {
|
|
307
323
|
if (this.highlightedObjects[id]) {
|
|
308
|
-
this.highlightedObjects[id].features
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
});
|
|
324
|
+
this.highlightedObjects[id].features.forEach((f) => {
|
|
325
|
+
unhighlightFeature(f);
|
|
326
|
+
});
|
|
312
327
|
delete this.highlightedObjects[id];
|
|
313
328
|
updatedIds.push(id);
|
|
314
329
|
}
|
|
315
330
|
});
|
|
316
331
|
|
|
317
332
|
if (updatedIds.length > 0) {
|
|
318
|
-
this.changed.raiseEvent({
|
|
333
|
+
this.changed.raiseEvent({
|
|
334
|
+
action: FeatureVisibilityAction.UNHIGHLIGHT,
|
|
335
|
+
ids: updatedIds,
|
|
336
|
+
});
|
|
319
337
|
}
|
|
320
338
|
}
|
|
321
339
|
|
|
@@ -333,7 +351,10 @@ class FeatureVisibility {
|
|
|
333
351
|
* @returns {boolean}
|
|
334
352
|
*/
|
|
335
353
|
hasHighlightFeature(id, feature) {
|
|
336
|
-
return
|
|
354
|
+
return (
|
|
355
|
+
this.highlightedObjects[id] &&
|
|
356
|
+
this.highlightedObjects[id].features.has(feature)
|
|
357
|
+
);
|
|
337
358
|
}
|
|
338
359
|
|
|
339
360
|
/**
|
|
@@ -365,7 +386,10 @@ class FeatureVisibility {
|
|
|
365
386
|
|
|
366
387
|
if (updatedIds.length > 0) {
|
|
367
388
|
this.lastUpdated = Date.now();
|
|
368
|
-
this.changed.raiseEvent({
|
|
389
|
+
this.changed.raiseEvent({
|
|
390
|
+
action: FeatureVisibilityAction.HIDE,
|
|
391
|
+
ids: updatedIds,
|
|
392
|
+
});
|
|
369
393
|
}
|
|
370
394
|
}
|
|
371
395
|
|
|
@@ -378,17 +402,19 @@ class FeatureVisibility {
|
|
|
378
402
|
const updatedIds = [];
|
|
379
403
|
unHide.forEach((id) => {
|
|
380
404
|
if (this.hiddenObjects[id]) {
|
|
381
|
-
this.hiddenObjects[id]
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
});
|
|
405
|
+
this.hiddenObjects[id].forEach((f) => {
|
|
406
|
+
showFeature(f, hidden);
|
|
407
|
+
});
|
|
385
408
|
delete this.hiddenObjects[id];
|
|
386
409
|
updatedIds.push(id);
|
|
387
410
|
}
|
|
388
411
|
});
|
|
389
412
|
|
|
390
413
|
if (updatedIds.length > 0) {
|
|
391
|
-
this.changed.raiseEvent({
|
|
414
|
+
this.changed.raiseEvent({
|
|
415
|
+
action: FeatureVisibilityAction.SHOW,
|
|
416
|
+
ids: updatedIds,
|
|
417
|
+
});
|
|
392
418
|
}
|
|
393
419
|
}
|
|
394
420
|
|
|
@@ -426,9 +452,13 @@ class FeatureVisibility {
|
|
|
426
452
|
* Clears all caches and removes cesium events.
|
|
427
453
|
*/
|
|
428
454
|
destroy() {
|
|
429
|
-
Object.values(this.hiddenObjects).forEach((s) => {
|
|
455
|
+
Object.values(this.hiddenObjects).forEach((s) => {
|
|
456
|
+
s.clear();
|
|
457
|
+
});
|
|
430
458
|
this.hiddenObjects = {};
|
|
431
|
-
Object.values(this.highlightedObjects).forEach(({ features }) => {
|
|
459
|
+
Object.values(this.highlightedObjects).forEach(({ features }) => {
|
|
460
|
+
features.clear();
|
|
461
|
+
});
|
|
432
462
|
this.highlightedObjects = {};
|
|
433
463
|
this.changed.destroy();
|
|
434
464
|
}
|
|
@@ -6,8 +6,14 @@ import Point from 'ol/geom/Point.js';
|
|
|
6
6
|
import Circle from 'ol/geom/Circle.js';
|
|
7
7
|
|
|
8
8
|
import { getDistance as haversineDistance } from 'ol/sphere.js';
|
|
9
|
-
import Projection, {
|
|
10
|
-
|
|
9
|
+
import Projection, {
|
|
10
|
+
mercatorProjection,
|
|
11
|
+
wgs84Projection,
|
|
12
|
+
} from '../util/projection.js';
|
|
13
|
+
import VectorStyleItem, {
|
|
14
|
+
defaultVectorStyle,
|
|
15
|
+
vectorStyleSymbol,
|
|
16
|
+
} from '../style/vectorStyleItem.js';
|
|
11
17
|
import { parseColor } from '../style/styleHelpers.js';
|
|
12
18
|
import VectorLayer from './vectorLayer.js';
|
|
13
19
|
import { featureStoreStateSymbol } from './featureStoreLayerState.js';
|
|
@@ -15,7 +21,11 @@ import { embedIconsInStyle } from '../style/writeStyle.js';
|
|
|
15
21
|
import DeclarativeStyleItem from '../style/declarativeStyleItem.js';
|
|
16
22
|
import { vcsMetaVersion } from './layer.js';
|
|
17
23
|
import Extent3D from '../util/featureconverter/extent3D.js';
|
|
18
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
circleFromCenterRadius,
|
|
26
|
+
enforceEndingVertex,
|
|
27
|
+
removeEndingVertexFromGeometry,
|
|
28
|
+
} from '../util/geometryHelpers.js';
|
|
19
29
|
|
|
20
30
|
const featureProjection = 'EPSG:3857';
|
|
21
31
|
|
|
@@ -70,7 +80,6 @@ function getFormat() {
|
|
|
70
80
|
* @api
|
|
71
81
|
*/
|
|
72
82
|
|
|
73
|
-
|
|
74
83
|
/**
|
|
75
84
|
* @param {Object} geojson
|
|
76
85
|
* @returns {string|null}
|
|
@@ -107,7 +116,11 @@ export function updateLegacyFeature(feature) {
|
|
|
107
116
|
} else {
|
|
108
117
|
const extent = Extent3D.fromGeometry(feature.getGeometry());
|
|
109
118
|
const minHeight = Number.isFinite(extent.minZ) ? extent.minZ : 0;
|
|
110
|
-
feature.set(
|
|
119
|
+
feature.set(
|
|
120
|
+
'olcs_extrudedHeight',
|
|
121
|
+
feature.get('extrudedHeight') - minHeight,
|
|
122
|
+
true,
|
|
123
|
+
);
|
|
111
124
|
}
|
|
112
125
|
feature.unset('extrudedHeight', true);
|
|
113
126
|
}
|
|
@@ -142,11 +155,7 @@ function readGeometry(geometryObj, options) {
|
|
|
142
155
|
* @todo this could also be done for declarative styles image and conditions could be checked?
|
|
143
156
|
*/
|
|
144
157
|
function setEmbeddedIcons(object, options) {
|
|
145
|
-
if (
|
|
146
|
-
object.image &&
|
|
147
|
-
object.image.src &&
|
|
148
|
-
/^:\d+$/.test(object.image.src)
|
|
149
|
-
) {
|
|
158
|
+
if (object.image && object.image.src && /^:\d+$/.test(object.image.src)) {
|
|
150
159
|
if (options.embeddedIcons) {
|
|
151
160
|
object.image.src = options.embeddedIcons[object.image.src.substring(1)];
|
|
152
161
|
} else {
|
|
@@ -217,7 +226,10 @@ function readFeature(featureObj, options) {
|
|
|
217
226
|
return null;
|
|
218
227
|
}
|
|
219
228
|
const radius = featureObj.geometry.olcs_radius;
|
|
220
|
-
let geometry = getFormat().readGeometry(
|
|
229
|
+
let geometry = getFormat().readGeometry(
|
|
230
|
+
featureObj.geometry,
|
|
231
|
+
options.formatOptions,
|
|
232
|
+
);
|
|
221
233
|
|
|
222
234
|
if (featureObj.radius && geometry instanceof Point) {
|
|
223
235
|
const coordinates = geometry.getCoordinates();
|
|
@@ -243,7 +255,10 @@ function readFeature(featureObj, options) {
|
|
|
243
255
|
}
|
|
244
256
|
const { properties } = featureObj;
|
|
245
257
|
if (options.readLegacyStyleOptions && !featureObj.vcsMeta.style) {
|
|
246
|
-
featureObj.vcsMeta.style = parseLegacyStyleOptions(
|
|
258
|
+
featureObj.vcsMeta.style = parseLegacyStyleOptions(
|
|
259
|
+
properties,
|
|
260
|
+
geometry.getType(),
|
|
261
|
+
);
|
|
247
262
|
}
|
|
248
263
|
removeEndingVertexFromGeometry(geometry);
|
|
249
264
|
const feature = new Feature({ ...properties, geometry });
|
|
@@ -256,7 +271,10 @@ function readFeature(featureObj, options) {
|
|
|
256
271
|
}
|
|
257
272
|
|
|
258
273
|
if (featureObj.vcsMeta.style && !options.dontReadStyle) {
|
|
259
|
-
featureObj.vcsMeta.style = setEmbeddedIcons(
|
|
274
|
+
featureObj.vcsMeta.style = setEmbeddedIcons(
|
|
275
|
+
featureObj.vcsMeta.style,
|
|
276
|
+
options,
|
|
277
|
+
);
|
|
260
278
|
let styleItem;
|
|
261
279
|
if (options.defaultStyle) {
|
|
262
280
|
styleItem = options.defaultStyle
|
|
@@ -287,16 +305,18 @@ export function parseGeoJSON(input, readOptions = {}) {
|
|
|
287
305
|
const geoJSON = typeof input === 'string' ? JSON.parse(input) : input;
|
|
288
306
|
|
|
289
307
|
const epsgCode = getEPSGCodeFromGeojson(geoJSON);
|
|
290
|
-
const defaultDataProjection = epsgCode
|
|
308
|
+
const defaultDataProjection = epsgCode
|
|
309
|
+
? { epsg: epsgCode }
|
|
310
|
+
: readOptions.dataProjection;
|
|
291
311
|
/** @type {GeoJSONinternalReadOptions} */
|
|
292
312
|
const options = {
|
|
293
313
|
formatOptions: {
|
|
294
|
-
dataProjection: defaultDataProjection
|
|
295
|
-
defaultDataProjection.epsg
|
|
296
|
-
wgs84Projection.epsg,
|
|
297
|
-
featureProjection: readOptions.targetProjection
|
|
298
|
-
readOptions.targetProjection.epsg
|
|
299
|
-
mercatorProjection.epsg,
|
|
314
|
+
dataProjection: defaultDataProjection
|
|
315
|
+
? defaultDataProjection.epsg
|
|
316
|
+
: wgs84Projection.epsg,
|
|
317
|
+
featureProjection: readOptions.targetProjection
|
|
318
|
+
? readOptions.targetProjection.epsg
|
|
319
|
+
: mercatorProjection.epsg,
|
|
300
320
|
},
|
|
301
321
|
dontReadStyle: readOptions.dontReadStyle,
|
|
302
322
|
readLegacyStyleOptions: readOptions.readLegacyStyleOptions,
|
|
@@ -321,7 +341,10 @@ export function parseGeoJSON(input, readOptions = {}) {
|
|
|
321
341
|
if (geoJSON.vcsMeta.style.type === DeclarativeStyleItem.className) {
|
|
322
342
|
style = new DeclarativeStyleItem(geoJSON.vcsMeta.style);
|
|
323
343
|
} else {
|
|
324
|
-
geoJSON.vcsMeta.style = setEmbeddedIcons(
|
|
344
|
+
geoJSON.vcsMeta.style = setEmbeddedIcons(
|
|
345
|
+
geoJSON.vcsMeta.style,
|
|
346
|
+
options,
|
|
347
|
+
);
|
|
325
348
|
options.defaultStyle = options.defaultStyle
|
|
326
349
|
.clone()
|
|
327
350
|
.assign(new VectorStyleItem(geoJSON.vcsMeta.style));
|
|
@@ -329,13 +352,18 @@ export function parseGeoJSON(input, readOptions = {}) {
|
|
|
329
352
|
}
|
|
330
353
|
}
|
|
331
354
|
return {
|
|
332
|
-
features: geoJSON.features
|
|
355
|
+
features: geoJSON.features
|
|
356
|
+
.map((f) => readFeature(f, options))
|
|
357
|
+
.filter((f) => f),
|
|
333
358
|
style: geoJSON.vcsMeta.style ? style : undefined,
|
|
334
359
|
vcsMeta: geoJSON.vcsMeta ? geoJSON.vcsMeta : undefined,
|
|
335
360
|
};
|
|
336
361
|
} else if (geoJSON.type === 'Feature') {
|
|
337
362
|
const feature = readFeature(geoJSON, options);
|
|
338
|
-
return {
|
|
363
|
+
return {
|
|
364
|
+
features: feature ? [feature] : [],
|
|
365
|
+
vcsMeta: geoJSON.vcsMeta ? geoJSON.vcsMeta : undefined,
|
|
366
|
+
};
|
|
339
367
|
} else if (geoJSON.type != null) {
|
|
340
368
|
return { features: [readGeometry(geoJSON, options)] };
|
|
341
369
|
}
|
|
@@ -348,7 +376,11 @@ export function parseGeoJSON(input, readOptions = {}) {
|
|
|
348
376
|
* @param {Array=} embeddedIcons
|
|
349
377
|
* @returns {Object}
|
|
350
378
|
*/
|
|
351
|
-
export function writeGeoJSONFeature(
|
|
379
|
+
export function writeGeoJSONFeature(
|
|
380
|
+
feature,
|
|
381
|
+
options = {},
|
|
382
|
+
embeddedIcons = undefined,
|
|
383
|
+
) {
|
|
352
384
|
const featureObject = {
|
|
353
385
|
type: 'Feature',
|
|
354
386
|
properties: feature.getProperties(),
|
|
@@ -373,12 +405,16 @@ export function writeGeoJSONFeature(feature, options = {}, embeddedIcons) {
|
|
|
373
405
|
geometry = new Point(geometry.getCenter());
|
|
374
406
|
} else if (geometry instanceof Polygon) {
|
|
375
407
|
const coordinates = geometry.getCoordinates();
|
|
376
|
-
coordinates.forEach((ring) => {
|
|
408
|
+
coordinates.forEach((ring) => {
|
|
409
|
+
enforceEndingVertex(ring);
|
|
410
|
+
});
|
|
377
411
|
geometry.setCoordinates(coordinates);
|
|
378
412
|
} else if (geometry instanceof MultiPolygon) {
|
|
379
413
|
const coordinates = geometry.getCoordinates();
|
|
380
414
|
coordinates.forEach((poly) => {
|
|
381
|
-
poly.forEach((ring) => {
|
|
415
|
+
poly.forEach((ring) => {
|
|
416
|
+
enforceEndingVertex(ring);
|
|
417
|
+
});
|
|
382
418
|
});
|
|
383
419
|
geometry.setCoordinates(coordinates);
|
|
384
420
|
}
|
|
@@ -410,15 +446,20 @@ export function writeGeoJSONFeature(feature, options = {}, embeddedIcons) {
|
|
|
410
446
|
* @param {GeoJSONwriteOptions=} options
|
|
411
447
|
* @returns {string|Object}
|
|
412
448
|
*/
|
|
413
|
-
export function writeGeoJSON(data, options = {}) {
|
|
449
|
+
export function writeGeoJSON(data, options = {}) {
|
|
450
|
+
// how to handel embedded icons when they are not set on the vcsMeta but options is true?
|
|
414
451
|
const vcsMeta = data.vcsMeta || {};
|
|
415
452
|
vcsMeta.version = vcsMetaVersion;
|
|
416
|
-
const featureObjs = data.features.map(feature =>
|
|
453
|
+
const featureObjs = data.features.map((feature) =>
|
|
454
|
+
writeGeoJSONFeature(feature, options, vcsMeta.embeddedIcons),
|
|
455
|
+
);
|
|
417
456
|
const obj = {
|
|
418
457
|
type: 'FeatureCollection',
|
|
419
458
|
features: featureObjs,
|
|
420
459
|
vcsMeta,
|
|
421
460
|
};
|
|
422
461
|
|
|
423
|
-
return options.asObject
|
|
462
|
+
return options.asObject
|
|
463
|
+
? obj
|
|
464
|
+
: JSON.stringify(obj, null, options.prettyPrint ? 2 : null);
|
|
424
465
|
}
|
|
@@ -16,7 +16,6 @@ import { requestJson } from '../util/fetch.js';
|
|
|
16
16
|
*/
|
|
17
17
|
export const featureFromOptions = Symbol('featureFromOptions');
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
/**
|
|
21
20
|
* GeojsonLayer layer for Cesium, OpenlayersMap and ObliqueMap
|
|
22
21
|
* @class
|
|
@@ -24,7 +23,9 @@ export const featureFromOptions = Symbol('featureFromOptions');
|
|
|
24
23
|
* @api stable
|
|
25
24
|
*/
|
|
26
25
|
class GeoJSONLayer extends VectorLayer {
|
|
27
|
-
static get className() {
|
|
26
|
+
static get className() {
|
|
27
|
+
return 'GeoJSONLayer';
|
|
28
|
+
}
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* @returns {GeoJSONOptions}
|
|
@@ -75,7 +76,9 @@ class GeoJSONLayer extends VectorLayer {
|
|
|
75
76
|
*/
|
|
76
77
|
async reload() {
|
|
77
78
|
if (this._dataFetchedPromise) {
|
|
78
|
-
const configFeatures = this.getFeatures().filter(
|
|
79
|
+
const configFeatures = this.getFeatures().filter(
|
|
80
|
+
(f) => f[featureFromOptions],
|
|
81
|
+
);
|
|
79
82
|
this.removeAllFeatures();
|
|
80
83
|
this.source.addFeatures(configFeatures);
|
|
81
84
|
this._dataFetchedPromise = null;
|
|
@@ -100,10 +103,9 @@ class GeoJSONLayer extends VectorLayer {
|
|
|
100
103
|
features: this._featuresToLoad,
|
|
101
104
|
});
|
|
102
105
|
|
|
103
|
-
this.getFeatures()
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
106
|
+
this.getFeatures().forEach((f) => {
|
|
107
|
+
f[featureFromOptions] = true;
|
|
108
|
+
});
|
|
107
109
|
|
|
108
110
|
this._featuresToLoad.splice(0);
|
|
109
111
|
this._featuresToLoad = undefined;
|
|
@@ -111,9 +113,11 @@ class GeoJSONLayer extends VectorLayer {
|
|
|
111
113
|
|
|
112
114
|
if (this.url) {
|
|
113
115
|
this._dataFetchedPromise = requestJson(this.url)
|
|
114
|
-
.then(data => this._parseGeojsonData(data))
|
|
116
|
+
.then((data) => this._parseGeojsonData(data))
|
|
115
117
|
.catch((err) => {
|
|
116
|
-
this.getLogger().warning(
|
|
118
|
+
this.getLogger().warning(
|
|
119
|
+
`Could not send request for loading layer content (${err.message})`,
|
|
120
|
+
);
|
|
117
121
|
return Promise.reject(err);
|
|
118
122
|
});
|
|
119
123
|
} else {
|
|
@@ -160,9 +164,11 @@ class GeoJSONLayer extends VectorLayer {
|
|
|
160
164
|
if (Array.isArray(this._featuresToLoad)) {
|
|
161
165
|
config.features = this._featuresToLoad.slice();
|
|
162
166
|
} else {
|
|
163
|
-
const features = this.getFeatures().filter(f => f[featureFromOptions]);
|
|
167
|
+
const features = this.getFeatures().filter((f) => f[featureFromOptions]);
|
|
164
168
|
if (features.length > 0) {
|
|
165
|
-
config.features = features.map(f =>
|
|
169
|
+
config.features = features.map((f) =>
|
|
170
|
+
writeGeoJSONFeature(f, { writeStyle: true, writeId: true }),
|
|
171
|
+
);
|
|
166
172
|
}
|
|
167
173
|
}
|
|
168
174
|
|
package/src/layer/globalHider.js
CHANGED
|
@@ -65,7 +65,10 @@ class GlobalHider {
|
|
|
65
65
|
|
|
66
66
|
if (updatedIds.length > 0) {
|
|
67
67
|
this.lastUpdated = Date.now();
|
|
68
|
-
this.changed.raiseEvent({
|
|
68
|
+
this.changed.raiseEvent({
|
|
69
|
+
action: FeatureVisibilityAction.HIDE,
|
|
70
|
+
ids: updatedIds,
|
|
71
|
+
});
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
|
|
@@ -95,7 +98,10 @@ class GlobalHider {
|
|
|
95
98
|
});
|
|
96
99
|
|
|
97
100
|
if (updatedIds.length > 0) {
|
|
98
|
-
this.changed.raiseEvent({
|
|
101
|
+
this.changed.raiseEvent({
|
|
102
|
+
action: FeatureVisibilityAction.SHOW,
|
|
103
|
+
ids: updatedIds,
|
|
104
|
+
});
|
|
99
105
|
}
|
|
100
106
|
}
|
|
101
107
|
|
|
@@ -119,12 +125,16 @@ class GlobalHider {
|
|
|
119
125
|
* @returns {boolean}
|
|
120
126
|
*/
|
|
121
127
|
hasFeature(uuid, feature) {
|
|
122
|
-
return this._hiddenObjectFeatures[uuid]
|
|
128
|
+
return this._hiddenObjectFeatures[uuid]
|
|
129
|
+
? this._hiddenObjectFeatures[uuid].has(feature)
|
|
130
|
+
: false;
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
destroy() {
|
|
126
134
|
this.hiddenObjects = {};
|
|
127
|
-
Object.values(this._hiddenObjectFeatures).forEach((set) => {
|
|
135
|
+
Object.values(this._hiddenObjectFeatures).forEach((set) => {
|
|
136
|
+
set.clear();
|
|
137
|
+
});
|
|
128
138
|
this._hiddenObjectFeatures = {};
|
|
129
139
|
this.changed.destroy();
|
|
130
140
|
}
|