@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
package/src/layer/layer.js
CHANGED
|
@@ -100,14 +100,18 @@ export const vcsMetaVersion = '2.1';
|
|
|
100
100
|
*/
|
|
101
101
|
class Layer extends VcsObject {
|
|
102
102
|
/** @type {string} */
|
|
103
|
-
static get className() {
|
|
103
|
+
static get className() {
|
|
104
|
+
return 'Layer';
|
|
105
|
+
}
|
|
104
106
|
|
|
105
107
|
/**
|
|
106
108
|
* Symbol to declare a layers name on its visualizations, e.g. ol.layer.Layer, Cesium.Cesium3DTileset
|
|
107
109
|
* @type {symbol}
|
|
108
110
|
* @api
|
|
109
111
|
*/
|
|
110
|
-
static get vcsLayerNameSymbol() {
|
|
112
|
+
static get vcsLayerNameSymbol() {
|
|
113
|
+
return vcsLayerName;
|
|
114
|
+
}
|
|
111
115
|
|
|
112
116
|
/** @returns {LayerOptions} */
|
|
113
117
|
static getDefaultOptions() {
|
|
@@ -143,12 +147,18 @@ class Layer extends VcsObject {
|
|
|
143
147
|
* @type {boolean}
|
|
144
148
|
* @api
|
|
145
149
|
*/
|
|
146
|
-
this.activeOnStartup = parseBoolean(
|
|
150
|
+
this.activeOnStartup = parseBoolean(
|
|
151
|
+
options.activeOnStartup,
|
|
152
|
+
defaultOptions.activeOnStartup,
|
|
153
|
+
);
|
|
147
154
|
/**
|
|
148
155
|
* @type {boolean}
|
|
149
156
|
* @private
|
|
150
157
|
*/
|
|
151
|
-
this._allowPicking = parseBoolean(
|
|
158
|
+
this._allowPicking = parseBoolean(
|
|
159
|
+
options.allowPicking,
|
|
160
|
+
defaultOptions.allowPicking,
|
|
161
|
+
);
|
|
152
162
|
/**
|
|
153
163
|
* @type {LayerState}
|
|
154
164
|
* @private
|
|
@@ -205,9 +215,9 @@ class Layer extends VcsObject {
|
|
|
205
215
|
* @private
|
|
206
216
|
* @api
|
|
207
217
|
*/
|
|
208
|
-
this._hiddenObjectIds = Array.isArray(options.hiddenObjectIds)
|
|
209
|
-
options.hiddenObjectIds
|
|
210
|
-
defaultOptions.hiddenObjectIds;
|
|
218
|
+
this._hiddenObjectIds = Array.isArray(options.hiddenObjectIds)
|
|
219
|
+
? options.hiddenObjectIds
|
|
220
|
+
: defaultOptions.hiddenObjectIds;
|
|
211
221
|
|
|
212
222
|
/**
|
|
213
223
|
* @type {import("@vcmap/core").GlobalHider|null}
|
|
@@ -219,9 +229,9 @@ class Layer extends VcsObject {
|
|
|
219
229
|
* @type {Array<string|symbol>}
|
|
220
230
|
* @private
|
|
221
231
|
*/
|
|
222
|
-
this._exclusiveGroups = Array.isArray(options.exclusiveGroups)
|
|
223
|
-
options.exclusiveGroups.slice()
|
|
224
|
-
defaultOptions.exclusiveGroups;
|
|
232
|
+
this._exclusiveGroups = Array.isArray(options.exclusiveGroups)
|
|
233
|
+
? options.exclusiveGroups.slice()
|
|
234
|
+
: defaultOptions.exclusiveGroups;
|
|
225
235
|
|
|
226
236
|
/**
|
|
227
237
|
* event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
|
|
@@ -353,7 +363,9 @@ class Layer extends VcsObject {
|
|
|
353
363
|
/**
|
|
354
364
|
* @type {Array<string>}
|
|
355
365
|
*/
|
|
356
|
-
get hiddenObjectIds() {
|
|
366
|
+
get hiddenObjectIds() {
|
|
367
|
+
return this._hiddenObjectIds;
|
|
368
|
+
}
|
|
357
369
|
|
|
358
370
|
/**
|
|
359
371
|
* @param {Array<string>} hiddenObjectIds
|
|
@@ -367,12 +379,13 @@ class Layer extends VcsObject {
|
|
|
367
379
|
this._hiddenObjectIds = hiddenObjectIds;
|
|
368
380
|
}
|
|
369
381
|
|
|
370
|
-
|
|
371
382
|
/**
|
|
372
383
|
* @type {import("@vcmap/core").GlobalHider|null}
|
|
373
384
|
* @readonly
|
|
374
385
|
*/
|
|
375
|
-
get globalHider() {
|
|
386
|
+
get globalHider() {
|
|
387
|
+
return this._globalHider;
|
|
388
|
+
}
|
|
376
389
|
|
|
377
390
|
/**
|
|
378
391
|
* @param {import("@vcmap/core").GlobalHider} globalHider
|
|
@@ -414,7 +427,7 @@ class Layer extends VcsObject {
|
|
|
414
427
|
|
|
415
428
|
if (
|
|
416
429
|
groups.length !== this._exclusiveGroups.length ||
|
|
417
|
-
!groups.every(g => this._exclusiveGroups.includes(g))
|
|
430
|
+
!groups.every((g) => this._exclusiveGroups.includes(g))
|
|
418
431
|
) {
|
|
419
432
|
this._exclusiveGroups = groups.slice();
|
|
420
433
|
this.exclusiveGroupsChanged.raiseEvent(groups);
|
|
@@ -425,7 +438,9 @@ class Layer extends VcsObject {
|
|
|
425
438
|
* @type {number}
|
|
426
439
|
* @api
|
|
427
440
|
*/
|
|
428
|
-
get zIndex() {
|
|
441
|
+
get zIndex() {
|
|
442
|
+
return this._zIndex;
|
|
443
|
+
}
|
|
429
444
|
|
|
430
445
|
/**
|
|
431
446
|
* @param {number} index
|
|
@@ -456,7 +471,11 @@ class Layer extends VcsObject {
|
|
|
456
471
|
|
|
457
472
|
if (this._locale !== value) {
|
|
458
473
|
this._locale = value;
|
|
459
|
-
if (
|
|
474
|
+
if (
|
|
475
|
+
this._url &&
|
|
476
|
+
typeof this._url === 'object' &&
|
|
477
|
+
this._url[this._locale]
|
|
478
|
+
) {
|
|
460
479
|
this.reload();
|
|
461
480
|
}
|
|
462
481
|
}
|
|
@@ -573,7 +592,9 @@ class Layer extends VcsObject {
|
|
|
573
592
|
* @returns {Promise<void>}
|
|
574
593
|
*/
|
|
575
594
|
async mapActivated(map) {
|
|
576
|
-
this.getLogger().debug(
|
|
595
|
+
this.getLogger().debug(
|
|
596
|
+
`Layer: ${this.name} mapActivated is called from Map: ${map.name}`,
|
|
597
|
+
);
|
|
577
598
|
this._activeMaps.add(map);
|
|
578
599
|
if (this.active || (this.loading && this.initialized)) {
|
|
579
600
|
await this._activateImplsForMap(map);
|
|
@@ -586,13 +607,14 @@ class Layer extends VcsObject {
|
|
|
586
607
|
* @param {import("@vcmap/core").VcsMap} map
|
|
587
608
|
*/
|
|
588
609
|
mapDeactivated(map) {
|
|
589
|
-
this.getLogger().debug(
|
|
610
|
+
this.getLogger().debug(
|
|
611
|
+
`Layer: ${this.name} mapDeactivated is called from Map: ${map.name}`,
|
|
612
|
+
);
|
|
590
613
|
this._activeMaps.delete(map);
|
|
591
614
|
if (this.active || this.loading) {
|
|
592
|
-
this.getImplementationsForMap(map)
|
|
593
|
-
.
|
|
594
|
-
|
|
595
|
-
});
|
|
615
|
+
this.getImplementationsForMap(map).forEach((impl) => {
|
|
616
|
+
impl.deactivate();
|
|
617
|
+
});
|
|
596
618
|
}
|
|
597
619
|
}
|
|
598
620
|
|
|
@@ -603,10 +625,9 @@ class Layer extends VcsObject {
|
|
|
603
625
|
*/
|
|
604
626
|
removedFromMap(map) {
|
|
605
627
|
this._activeMaps.delete(map);
|
|
606
|
-
this.getImplementationsForMap(map)
|
|
607
|
-
.
|
|
608
|
-
|
|
609
|
-
});
|
|
628
|
+
this.getImplementationsForMap(map).forEach((impl) => {
|
|
629
|
+
impl.destroy();
|
|
630
|
+
});
|
|
610
631
|
this._implementations.delete(map);
|
|
611
632
|
}
|
|
612
633
|
|
|
@@ -617,9 +638,11 @@ class Layer extends VcsObject {
|
|
|
617
638
|
* @api stable
|
|
618
639
|
*/
|
|
619
640
|
isSupported(map) {
|
|
620
|
-
return
|
|
641
|
+
return (
|
|
642
|
+
map &&
|
|
621
643
|
this._supportedMaps.includes(map.className) &&
|
|
622
|
-
(this.mapNames.length === 0 || this.mapNames.indexOf(map.name) >= 0)
|
|
644
|
+
(this.mapNames.length === 0 || this.mapNames.indexOf(map.name) >= 0)
|
|
645
|
+
);
|
|
623
646
|
}
|
|
624
647
|
|
|
625
648
|
/**
|
|
@@ -630,12 +653,16 @@ class Layer extends VcsObject {
|
|
|
630
653
|
async _activateImplsForMap(map) {
|
|
631
654
|
const impls = this.getImplementationsForMap(map);
|
|
632
655
|
try {
|
|
633
|
-
await Promise.all(impls.map(i => i.activate()));
|
|
656
|
+
await Promise.all(impls.map((i) => i.activate()));
|
|
634
657
|
} catch (err) {
|
|
635
|
-
this.getLogger().error(
|
|
658
|
+
this.getLogger().error(
|
|
659
|
+
`Layer ${this.name} could not activate impl for map ${map.name}`,
|
|
660
|
+
);
|
|
636
661
|
this.getLogger().error(err);
|
|
637
662
|
this._implementations.set(map, []);
|
|
638
|
-
impls.forEach((i) => {
|
|
663
|
+
impls.forEach((i) => {
|
|
664
|
+
i.destroy();
|
|
665
|
+
});
|
|
639
666
|
}
|
|
640
667
|
}
|
|
641
668
|
|
|
@@ -648,14 +675,18 @@ class Layer extends VcsObject {
|
|
|
648
675
|
try {
|
|
649
676
|
this.stateChanged.raiseEvent(LayerState.LOADING);
|
|
650
677
|
} catch (e) {
|
|
651
|
-
this.getLogger().debug(
|
|
678
|
+
this.getLogger().debug(
|
|
679
|
+
`Error on raising LayerState.LOADING event for layer ${this.name} : ${e.message}`,
|
|
680
|
+
);
|
|
652
681
|
}
|
|
653
682
|
await this.initialize();
|
|
654
683
|
if (this._state !== LayerState.LOADING) {
|
|
655
684
|
return;
|
|
656
685
|
}
|
|
657
686
|
|
|
658
|
-
await Promise.all(
|
|
687
|
+
await Promise.all(
|
|
688
|
+
[...this._activeMaps].map((m) => this._activateImplsForMap(m)),
|
|
689
|
+
);
|
|
659
690
|
if (this._state !== LayerState.LOADING) {
|
|
660
691
|
return;
|
|
661
692
|
}
|
|
@@ -666,7 +697,9 @@ class Layer extends VcsObject {
|
|
|
666
697
|
try {
|
|
667
698
|
this.stateChanged.raiseEvent(LayerState.ACTIVE);
|
|
668
699
|
} catch (e) {
|
|
669
|
-
this.getLogger().debug(
|
|
700
|
+
this.getLogger().debug(
|
|
701
|
+
`Error on raising LayerState.ACTIVE event for layer ${this.name} : ${e.message}`,
|
|
702
|
+
);
|
|
670
703
|
}
|
|
671
704
|
this._loadingPromise = null;
|
|
672
705
|
}
|
|
@@ -685,11 +718,10 @@ class Layer extends VcsObject {
|
|
|
685
718
|
}
|
|
686
719
|
|
|
687
720
|
if (this._state === LayerState.INACTIVE) {
|
|
688
|
-
this._loadingPromise = this._activate()
|
|
689
|
-
.
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
});
|
|
721
|
+
this._loadingPromise = this._activate().catch((err) => {
|
|
722
|
+
this._state = LayerState.INACTIVE;
|
|
723
|
+
return Promise.reject(err);
|
|
724
|
+
});
|
|
693
725
|
return this._loadingPromise;
|
|
694
726
|
}
|
|
695
727
|
|
|
@@ -718,7 +750,9 @@ class Layer extends VcsObject {
|
|
|
718
750
|
try {
|
|
719
751
|
this.stateChanged.raiseEvent(LayerState.INACTIVE);
|
|
720
752
|
} catch (e) {
|
|
721
|
-
this.getLogger().debug(
|
|
753
|
+
this.getLogger().debug(
|
|
754
|
+
`Error on raising LayerState.INACTIVE event for layer ${this.name} : ${e.message}`,
|
|
755
|
+
);
|
|
722
756
|
}
|
|
723
757
|
}
|
|
724
758
|
}
|
|
@@ -777,10 +811,9 @@ class Layer extends VcsObject {
|
|
|
777
811
|
}
|
|
778
812
|
|
|
779
813
|
this._activeMaps.clear();
|
|
780
|
-
this.getImplementations()
|
|
781
|
-
.
|
|
782
|
-
|
|
783
|
-
});
|
|
814
|
+
this.getImplementations().forEach((impl) => {
|
|
815
|
+
impl.destroy();
|
|
816
|
+
});
|
|
784
817
|
|
|
785
818
|
this._initialized = false;
|
|
786
819
|
this._implementations.clear();
|
|
@@ -10,7 +10,9 @@ import LayerState from './layerState.js';
|
|
|
10
10
|
* @template {import("@vcmap/core").VcsMap} T
|
|
11
11
|
*/
|
|
12
12
|
class LayerImplementation extends VcsObject {
|
|
13
|
-
static get className() {
|
|
13
|
+
static get className() {
|
|
14
|
+
return 'LayerImplementation';
|
|
15
|
+
}
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* @param {T} map
|
|
@@ -42,19 +44,25 @@ class LayerImplementation extends VcsObject {
|
|
|
42
44
|
* @type {boolean}
|
|
43
45
|
* @readonly
|
|
44
46
|
*/
|
|
45
|
-
get initialized() {
|
|
47
|
+
get initialized() {
|
|
48
|
+
return this._initialized;
|
|
49
|
+
}
|
|
46
50
|
|
|
47
51
|
/**
|
|
48
52
|
* @type {boolean}
|
|
49
53
|
* @api
|
|
50
54
|
*/
|
|
51
|
-
get active() {
|
|
55
|
+
get active() {
|
|
56
|
+
return this._state === LayerState.ACTIVE;
|
|
57
|
+
}
|
|
52
58
|
|
|
53
59
|
/**
|
|
54
60
|
* @type {boolean}
|
|
55
61
|
* @api
|
|
56
62
|
*/
|
|
57
|
-
get loading() {
|
|
63
|
+
get loading() {
|
|
64
|
+
return this._state === LayerState.LOADING;
|
|
65
|
+
}
|
|
58
66
|
|
|
59
67
|
/**
|
|
60
68
|
* interface to initialize this implementation, is used to setup elements which have to be created only once.
|
|
@@ -59,7 +59,9 @@ class LayerObliqueImpl extends LayerImplementation {
|
|
|
59
59
|
* @returns {import("ol/layer").Layer<import("ol/source/Source").default>}
|
|
60
60
|
*/
|
|
61
61
|
// eslint-disable-next-line class-methods-use-this
|
|
62
|
-
getOLLayer() {
|
|
62
|
+
getOLLayer() {
|
|
63
|
+
throw new Error();
|
|
64
|
+
}
|
|
63
65
|
|
|
64
66
|
/**
|
|
65
67
|
* @inheritDoc
|
|
@@ -3,9 +3,19 @@ import { fromCircle } from 'ol/geom/Polygon.js';
|
|
|
3
3
|
import { getTransform } from 'ol/proj.js';
|
|
4
4
|
import { Cartographic, sampleTerrainMostDetailed } from '@vcmap-cesium/engine';
|
|
5
5
|
import { cartesian2DDistance } from '../../util/math.js';
|
|
6
|
-
import Projection, {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import Projection, {
|
|
7
|
+
mercatorProjection,
|
|
8
|
+
wgs84Projection,
|
|
9
|
+
} from '../../util/projection.js';
|
|
10
|
+
import {
|
|
11
|
+
actuallyIsCircle,
|
|
12
|
+
alreadyTransformedToImage,
|
|
13
|
+
obliqueGeometry,
|
|
14
|
+
} from '../vectorSymbols.js';
|
|
15
|
+
import {
|
|
16
|
+
convertGeometryToPolygon,
|
|
17
|
+
getFlatCoordinatesFromGeometry,
|
|
18
|
+
} from '../../util/geometryHelpers.js';
|
|
9
19
|
import { transformFromImage } from '../../oblique/helpers.js';
|
|
10
20
|
|
|
11
21
|
/**
|
|
@@ -76,7 +86,6 @@ export function getZoom(olMap, image, distance) {
|
|
|
76
86
|
return olMap.getView().getZoomForResolution(resolution);
|
|
77
87
|
}
|
|
78
88
|
|
|
79
|
-
|
|
80
89
|
/**
|
|
81
90
|
* converts a geometry in mercator format to image coordinates
|
|
82
91
|
* @param {import("ol/geom/Geometry").default} inputSourceGeometry
|
|
@@ -84,14 +93,25 @@ export function getZoom(olMap, image, distance) {
|
|
|
84
93
|
* @param {import("@vcmap/core").ObliqueImage} image
|
|
85
94
|
* @returns {Promise<import("ol/geom/Geometry").default>}
|
|
86
95
|
*/
|
|
87
|
-
export async function mercatorGeometryToImageGeometry(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
export async function mercatorGeometryToImageGeometry(
|
|
97
|
+
inputSourceGeometry,
|
|
98
|
+
destinationGeometry,
|
|
99
|
+
image,
|
|
100
|
+
) {
|
|
101
|
+
const sourceGeometry =
|
|
102
|
+
inputSourceGeometry instanceof Circle
|
|
103
|
+
? fromCircle(inputSourceGeometry)
|
|
104
|
+
: inputSourceGeometry;
|
|
91
105
|
const coordinates = sourceGeometry.getCoordinates();
|
|
92
106
|
/** type {Array.<import("ol/coordinate").Coordinate>} */
|
|
93
|
-
const flattenCoordinates = getFlatCoordinatesFromGeometry(
|
|
94
|
-
|
|
107
|
+
const flattenCoordinates = getFlatCoordinatesFromGeometry(
|
|
108
|
+
sourceGeometry,
|
|
109
|
+
coordinates,
|
|
110
|
+
);
|
|
111
|
+
let transformer = getTransform(
|
|
112
|
+
mercatorProjection.proj,
|
|
113
|
+
image.meta.projection.proj,
|
|
114
|
+
);
|
|
95
115
|
|
|
96
116
|
let updatedPositions = [];
|
|
97
117
|
if (image.meta.terrainProvider) {
|
|
@@ -99,14 +119,25 @@ export async function mercatorGeometryToImageGeometry(inputSourceGeometry, desti
|
|
|
99
119
|
Projection.mercatorToWgs84(coord, true);
|
|
100
120
|
return Cartographic.fromDegrees(coord[0], coord[1]);
|
|
101
121
|
});
|
|
102
|
-
transformer = getTransform(
|
|
103
|
-
|
|
122
|
+
transformer = getTransform(
|
|
123
|
+
wgs84Projection.proj,
|
|
124
|
+
image.meta.projection.proj,
|
|
125
|
+
);
|
|
126
|
+
updatedPositions = await sampleTerrainMostDetailed(
|
|
127
|
+
image.meta.terrainProvider,
|
|
128
|
+
cartographicCoordinates,
|
|
129
|
+
);
|
|
104
130
|
}
|
|
105
131
|
|
|
106
132
|
flattenCoordinates.forEach((coord, index) => {
|
|
107
133
|
transformer(coord, coord, 3);
|
|
108
|
-
const exactHeight = updatedPositions[index]
|
|
109
|
-
|
|
134
|
+
const exactHeight = updatedPositions[index]
|
|
135
|
+
? updatedPositions[index].height
|
|
136
|
+
: null;
|
|
137
|
+
const imageCoords = image.transformRealWorld2Image(
|
|
138
|
+
coord,
|
|
139
|
+
exactHeight || coord[2] || image.averageHeight,
|
|
140
|
+
);
|
|
110
141
|
flattenCoordinates[index][0] = imageCoords[0];
|
|
111
142
|
flattenCoordinates[index][1] = imageCoords[1];
|
|
112
143
|
});
|
|
@@ -122,21 +153,28 @@ export async function mercatorGeometryToImageGeometry(inputSourceGeometry, desti
|
|
|
122
153
|
* @param {import("@vcmap/core").ObliqueImage} image
|
|
123
154
|
* @returns {Promise<import("ol/geom/Geometry").default>}
|
|
124
155
|
*/
|
|
125
|
-
export function imageGeometryToMercatorGeometry(
|
|
156
|
+
export function imageGeometryToMercatorGeometry(
|
|
157
|
+
sourceGeometry,
|
|
158
|
+
destinationGeometry,
|
|
159
|
+
image,
|
|
160
|
+
) {
|
|
126
161
|
const coordinates = sourceGeometry.getCoordinates();
|
|
127
162
|
/** type {Array.<import("ol/coordinate").Coordinate>} */
|
|
128
|
-
const flattenCoordinates = getFlatCoordinatesFromGeometry(
|
|
129
|
-
|
|
130
|
-
|
|
163
|
+
const flattenCoordinates = getFlatCoordinatesFromGeometry(
|
|
164
|
+
sourceGeometry,
|
|
165
|
+
coordinates,
|
|
166
|
+
);
|
|
167
|
+
const promises = flattenCoordinates.map((coord) =>
|
|
168
|
+
transformFromImage(image, coord).then((coords) => {
|
|
131
169
|
coord[0] = coords.coords[0];
|
|
132
170
|
coord[1] = coords.coords[1];
|
|
133
171
|
coord[2] = coords.coords[2];
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
172
|
+
}),
|
|
173
|
+
);
|
|
174
|
+
return Promise.all(promises).then(() => {
|
|
175
|
+
destinationGeometry.setCoordinates(coordinates);
|
|
176
|
+
return destinationGeometry;
|
|
177
|
+
});
|
|
140
178
|
}
|
|
141
179
|
|
|
142
180
|
/**
|
|
@@ -146,7 +184,9 @@ export function imageGeometryToMercatorGeometry(sourceGeometry, destinationGeome
|
|
|
146
184
|
*/
|
|
147
185
|
export function getPolygonizedGeometry(feature, retainRectangle = false) {
|
|
148
186
|
const geom = feature.getGeometry();
|
|
149
|
-
const isRectangle =
|
|
187
|
+
const isRectangle =
|
|
188
|
+
geom.get('_vcsGeomType') === 'bbox' ||
|
|
189
|
+
geom.get('_vcsGeomType') === 'rectangle';
|
|
150
190
|
if (isRectangle && retainRectangle) {
|
|
151
191
|
return geom;
|
|
152
192
|
}
|
|
@@ -165,11 +205,16 @@ export function getPolygonizedGeometry(feature, retainRectangle = false) {
|
|
|
165
205
|
export function setNewGeometry(originalFeature, obliqueFeature) {
|
|
166
206
|
const originalGeometry = originalFeature.getGeometry();
|
|
167
207
|
const originalGeometryClone = originalFeature.getGeometry().clone();
|
|
168
|
-
obliqueFeature.setGeometry(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
208
|
+
obliqueFeature.setGeometry(
|
|
209
|
+
!originalGeometry[alreadyTransformedToImage]
|
|
210
|
+
? convertGeometryToPolygon(originalGeometryClone)
|
|
211
|
+
: originalGeometryClone,
|
|
212
|
+
);
|
|
213
|
+
if (originalGeometry[alreadyTransformedToImage]) {
|
|
214
|
+
// TODO handle UI for bbox and rectangle
|
|
215
|
+
obliqueFeature
|
|
216
|
+
.getGeometry()
|
|
217
|
+
.setProperties(originalFeature.getGeometry().getProperties(), false);
|
|
173
218
|
}
|
|
174
219
|
originalFeature[obliqueGeometry] = obliqueFeature.getGeometry();
|
|
175
220
|
}
|