@vcmap/core 5.0.3 → 5.1.0-rc.2
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/dist/geojson.d.ts +27 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/src/classRegistry.js +2 -2
- package/dist/src/classRegistry.js.map +1 -1
- package/dist/src/featureProvider/abstractFeatureProvider.d.ts +2 -1
- package/dist/src/featureProvider/abstractFeatureProvider.js +2 -1
- package/dist/src/featureProvider/abstractFeatureProvider.js.map +1 -1
- package/dist/src/featureProvider/tileProviderFeatureProvider.d.ts +1 -1
- package/dist/src/featureProvider/tileProviderFeatureProvider.js +2 -2
- package/dist/src/featureProvider/tileProviderFeatureProvider.js.map +1 -1
- package/dist/src/featureProvider/wmsFeatureProvider.d.ts +1 -1
- package/dist/src/featureProvider/wmsFeatureProvider.js +4 -3
- package/dist/src/featureProvider/wmsFeatureProvider.js.map +1 -1
- package/dist/src/interaction/eventHandler.js +3 -3
- package/dist/src/interaction/eventHandler.js.map +1 -1
- package/dist/src/interaction/featureProviderInteraction.js +1 -1
- package/dist/src/interaction/featureProviderInteraction.js.map +1 -1
- package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.d.ts +4 -1
- package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js +31 -2
- package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/resourceHelper.d.ts +2 -0
- package/dist/src/layer/cesium/resourceHelper.js +12 -0
- package/dist/src/layer/cesium/resourceHelper.js.map +1 -0
- package/dist/src/layer/cesium/singleImageCesiumImpl.js +2 -1
- package/dist/src/layer/cesium/singleImageCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/terrainCesiumImpl.js +1 -1
- package/dist/src/layer/cesium/terrainCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/tmsCesiumImpl.js +2 -1
- package/dist/src/layer/cesium/tmsCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/vectorRasterTileCesiumImpl.js +1 -0
- package/dist/src/layer/cesium/vectorRasterTileCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/vectorTileImageryProvider.d.ts +2 -0
- package/dist/src/layer/cesium/vectorTileImageryProvider.js +3 -1
- package/dist/src/layer/cesium/vectorTileImageryProvider.js.map +1 -1
- package/dist/src/layer/cesium/wmsCesiumImpl.js +2 -1
- package/dist/src/layer/cesium/wmsCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/wmtsCesiumImpl.js +2 -1
- package/dist/src/layer/cesium/wmtsCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesiumTilesetLayer.d.ts +5 -1
- package/dist/src/layer/cesiumTilesetLayer.js +17 -7
- package/dist/src/layer/cesiumTilesetLayer.js.map +1 -1
- package/dist/src/layer/czmlLayer.js +2 -1
- package/dist/src/layer/czmlLayer.js.map +1 -1
- package/dist/src/layer/featureLayer.js +2 -2
- package/dist/src/layer/featureLayer.js.map +1 -1
- package/dist/src/layer/featureStoreLayer.js +8 -5
- package/dist/src/layer/featureStoreLayer.js.map +1 -1
- package/dist/src/layer/featureStoreLayerChanges.d.ts +20 -8
- package/dist/src/layer/featureStoreLayerChanges.js +26 -26
- package/dist/src/layer/featureStoreLayerChanges.js.map +1 -1
- package/dist/src/layer/featureStoreLayerState.d.ts +1 -5
- package/dist/src/layer/featureStoreLayerState.js +0 -9
- package/dist/src/layer/featureStoreLayerState.js.map +1 -1
- package/dist/src/layer/geojsonLayer.js +3 -2
- package/dist/src/layer/geojsonLayer.js.map +1 -1
- package/dist/src/layer/layer.d.ts +15 -0
- package/dist/src/layer/layer.js +30 -4
- package/dist/src/layer/layer.js.map +1 -1
- package/dist/src/layer/layerImplementation.d.ts +1 -0
- package/dist/src/layer/layerImplementation.js +2 -0
- package/dist/src/layer/layerImplementation.js.map +1 -1
- package/dist/src/layer/oblique/vectorObliqueImpl.js +17 -7
- package/dist/src/layer/oblique/vectorObliqueImpl.js.map +1 -1
- package/dist/src/layer/openlayers/loadFunctionHelpers.d.ts +2 -0
- package/dist/src/layer/openlayers/loadFunctionHelpers.js +20 -0
- package/dist/src/layer/openlayers/loadFunctionHelpers.js.map +1 -0
- package/dist/src/layer/openlayers/singleImageOpenlayersImpl.js +25 -1
- package/dist/src/layer/openlayers/singleImageOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/openlayers/tmsOpenlayersImpl.js +9 -1
- package/dist/src/layer/openlayers/tmsOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/openlayers/vectorTileOpenlayersImpl.js +1 -1
- package/dist/src/layer/openlayers/vectorTileOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/openlayers/wmsOpenlayersImpl.d.ts +4 -1
- package/dist/src/layer/openlayers/wmsOpenlayersImpl.js +20 -1
- package/dist/src/layer/openlayers/wmsOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/openlayers/wmtsOpenlayersImpl.js +9 -1
- package/dist/src/layer/openlayers/wmtsOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/pointCloudLayer.js +2 -2
- package/dist/src/layer/pointCloudLayer.js.map +1 -1
- package/dist/src/layer/terrainHelpers.d.ts +3 -3
- package/dist/src/layer/terrainHelpers.js +12 -7
- package/dist/src/layer/terrainHelpers.js.map +1 -1
- package/dist/src/layer/terrainLayer.js +1 -1
- package/dist/src/layer/terrainLayer.js.map +1 -1
- package/dist/src/layer/tileProvider/mvtTileProvider.d.ts +1 -1
- package/dist/src/layer/tileProvider/mvtTileProvider.js +4 -3
- package/dist/src/layer/tileProvider/mvtTileProvider.js.map +1 -1
- package/dist/src/layer/tileProvider/staticGeojsonTileProvider.d.ts +1 -1
- package/dist/src/layer/tileProvider/staticGeojsonTileProvider.js +4 -3
- package/dist/src/layer/tileProvider/staticGeojsonTileProvider.js.map +1 -1
- package/dist/src/layer/tileProvider/tileProvider.d.ts +14 -11
- package/dist/src/layer/tileProvider/tileProvider.js +23 -20
- package/dist/src/layer/tileProvider/tileProvider.js.map +1 -1
- package/dist/src/layer/tileProvider/urlTemplateTileProvider.d.ts +1 -1
- package/dist/src/layer/tileProvider/urlTemplateTileProvider.js +4 -3
- package/dist/src/layer/tileProvider/urlTemplateTileProvider.js.map +1 -1
- package/dist/src/layer/vectorLayer.d.ts +1 -2
- package/dist/src/layer/vectorLayer.js +3 -3
- package/dist/src/layer/vectorLayer.js.map +1 -1
- package/dist/src/layer/vectorProperties.d.ts +11 -16
- package/dist/src/layer/vectorProperties.js +16 -13
- package/dist/src/layer/vectorProperties.js.map +1 -1
- package/dist/src/layer/wfsLayer.js +9 -6
- package/dist/src/layer/wfsLayer.js.map +1 -1
- package/dist/src/layer/wmsHelpers.d.ts +10 -0
- package/dist/src/layer/wmsHelpers.js +53 -12
- package/dist/src/layer/wmsHelpers.js.map +1 -1
- package/dist/src/layer/wmsLayer.d.ts +6 -0
- package/dist/src/layer/wmsLayer.js +5 -2
- package/dist/src/layer/wmsLayer.js.map +1 -1
- package/dist/src/map/cameraLimiter.d.ts +5 -0
- package/dist/src/map/cameraLimiter.js +11 -4
- package/dist/src/map/cameraLimiter.js.map +1 -1
- package/dist/src/map/cesiumMap.d.ts +20 -1
- package/dist/src/map/cesiumMap.js +51 -2
- package/dist/src/map/cesiumMap.js.map +1 -1
- package/dist/src/map/vcsMap.js +2 -2
- package/dist/src/map/vcsMap.js.map +1 -1
- package/dist/src/oblique/helpers.d.ts +1 -1
- package/dist/src/oblique/helpers.js +5 -9
- package/dist/src/oblique/helpers.js.map +1 -1
- package/dist/src/oblique/obliqueCollection.d.ts +1 -0
- package/dist/src/oblique/obliqueCollection.js +1 -1
- package/dist/src/oblique/obliqueCollection.js.map +1 -1
- package/dist/src/oblique/obliqueDataSet.d.ts +3 -1
- package/dist/src/oblique/obliqueDataSet.js +13 -6
- package/dist/src/oblique/obliqueDataSet.js.map +1 -1
- package/dist/src/oblique/obliqueImageMeta.d.ts +2 -0
- package/dist/src/oblique/obliqueImageMeta.js +2 -0
- package/dist/src/oblique/obliqueImageMeta.js.map +1 -1
- package/dist/src/oblique/obliqueView.d.ts +1 -0
- package/dist/src/oblique/obliqueView.js +12 -2
- package/dist/src/oblique/obliqueView.js.map +1 -1
- package/dist/src/oblique/parseImageJson.d.ts +6 -5
- package/dist/src/oblique/parseImageJson.js +7 -5
- package/dist/src/oblique/parseImageJson.js.map +1 -1
- package/dist/src/ol/geom/circle.js.map +1 -1
- package/dist/src/style/declarativeStyleItem.js +10 -2
- package/dist/src/style/declarativeStyleItem.js.map +1 -1
- package/dist/src/style/styleFactory.js +2 -2
- package/dist/src/style/styleFactory.js.map +1 -1
- package/dist/src/style/styleHelpers.js +13 -3
- package/dist/src/style/styleHelpers.js.map +1 -1
- package/dist/src/style/vectorStyleItem.js +29 -16
- package/dist/src/style/vectorStyleItem.js.map +1 -1
- package/dist/src/util/clipping/clippingPlaneHelper.js +3 -3
- package/dist/src/util/clipping/clippingPlaneHelper.js.map +1 -1
- package/dist/src/util/editor/createFeatureSession.d.ts +2 -2
- package/dist/src/util/editor/createFeatureSession.js +2 -2
- package/dist/src/util/editor/createFeatureSession.js.map +1 -1
- package/dist/src/util/editor/editFeaturesSession.d.ts +2 -2
- package/dist/src/util/editor/editGeometrySession.d.ts +2 -2
- package/dist/src/util/editor/editorSessionHelpers.d.ts +2 -2
- package/dist/src/util/editor/selectFeaturesSession.d.ts +2 -2
- package/dist/src/util/editor/selectFeaturesSession.js +2 -2
- package/dist/src/util/editor/selectFeaturesSession.js.map +1 -1
- package/dist/src/util/featureconverter/arcToCesium.d.ts +1 -1
- package/dist/src/util/featureconverter/arcToCesium.js +5 -2
- package/dist/src/util/featureconverter/arcToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/circleToCesium.d.ts +4 -2
- package/dist/src/util/featureconverter/circleToCesium.js +8 -3
- package/dist/src/util/featureconverter/circleToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/extent3D.js.map +1 -1
- package/dist/src/util/featureconverter/featureconverterHelper.js +2 -2
- package/dist/src/util/featureconverter/featureconverterHelper.js.map +1 -1
- package/dist/src/util/featureconverter/lineStringToCesium.d.ts +3 -1
- package/dist/src/util/featureconverter/lineStringToCesium.js +7 -2
- package/dist/src/util/featureconverter/lineStringToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/pointToCesium.js +1 -1
- package/dist/src/util/featureconverter/pointToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/polygonToCesium.d.ts +3 -3
- package/dist/src/util/featureconverter/polygonToCesium.js +9 -15
- package/dist/src/util/featureconverter/polygonToCesium.js.map +1 -1
- package/dist/src/util/fetch.d.ts +2 -0
- package/dist/src/util/fetch.js +16 -0
- package/dist/src/util/fetch.js.map +1 -1
- package/dist/src/util/flight/flightAnchor.d.ts +23 -0
- package/dist/src/util/flight/flightAnchor.js +152 -0
- package/dist/src/util/flight/flightAnchor.js.map +1 -0
- package/dist/src/util/flight/flightCollection.d.ts +25 -0
- package/dist/src/util/flight/flightCollection.js +63 -0
- package/dist/src/util/flight/flightCollection.js.map +1 -0
- package/dist/src/util/flight/flightHelpers.d.ts +29 -0
- package/dist/src/util/flight/flightHelpers.js +134 -0
- package/dist/src/util/flight/flightHelpers.js.map +1 -0
- package/dist/src/util/flight/flightInstance.d.ts +57 -0
- package/dist/src/util/flight/flightInstance.js +166 -0
- package/dist/src/util/flight/flightInstance.js.map +1 -0
- package/dist/src/util/flight/flightPlayer.d.ts +30 -0
- package/dist/src/util/flight/flightPlayer.js +247 -0
- package/dist/src/util/flight/flightPlayer.js.map +1 -0
- package/dist/src/util/flight/flightVisualizer.d.ts +18 -0
- package/dist/src/util/flight/flightVisualizer.js +151 -0
- package/dist/src/util/flight/flightVisualizer.js.map +1 -0
- package/dist/src/util/hiddenObjects.d.ts +8 -0
- package/dist/src/util/hiddenObjects.js +17 -0
- package/dist/src/util/hiddenObjects.js.map +1 -0
- package/dist/src/util/mapCollection.js +2 -2
- package/dist/src/util/mapCollection.js.map +1 -1
- package/dist/src/util/overrideCollection.d.ts +8 -3
- package/dist/src/util/overrideCollection.js +17 -0
- package/dist/src/util/overrideCollection.js.map +1 -1
- package/dist/src/util/projection.js +5 -2
- package/dist/src/util/projection.js.map +1 -1
- package/dist/src/util/viewpoint.d.ts +1 -0
- package/dist/src/util/viewpoint.js +24 -7
- package/dist/src/util/viewpoint.js.map +1 -1
- package/dist/src/vcsApp.d.ts +10 -3
- package/dist/src/vcsApp.js +34 -15
- package/dist/src/vcsApp.js.map +1 -1
- package/dist/src/vcsModule.d.ts +4 -0
- package/dist/src/vcsModule.js.map +1 -1
- package/dist/tests/unit/helpers/cesiumHelpers.d.ts +2 -2
- package/dist/tests/unit/helpers/cesiumHelpers.js +2 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
- package/dist/tests/unit/helpers/terrain/terrainData.d.ts +7 -0
- package/dist/tests/unit/helpers/terrain/terrainData.js +2 -2
- package/dist/tests/unit/helpers/terrain/terrainData.js.map +1 -1
- package/index.ts +39 -1
- package/package.json +3 -2
- package/src/classRegistry.ts +2 -2
- package/src/featureProvider/abstractFeatureProvider.ts +2 -0
- package/src/featureProvider/tileProviderFeatureProvider.ts +2 -0
- package/src/featureProvider/wmsFeatureProvider.ts +4 -2
- package/src/interaction/eventHandler.ts +3 -3
- package/src/interaction/featureProviderInteraction.ts +1 -0
- package/src/layer/cesium/cesiumTilesetCesiumImpl.ts +44 -5
- package/src/layer/cesium/resourceHelper.ts +15 -0
- package/src/layer/cesium/singleImageCesiumImpl.ts +2 -1
- package/src/layer/cesium/terrainCesiumImpl.ts +2 -1
- package/src/layer/cesium/tmsCesiumImpl.ts +2 -1
- package/src/layer/cesium/vectorRasterTileCesiumImpl.ts +1 -0
- package/src/layer/cesium/vectorTileImageryProvider.ts +10 -1
- package/src/layer/cesium/wmsCesiumImpl.ts +2 -1
- package/src/layer/cesium/wmtsCesiumImpl.ts +4 -2
- package/src/layer/cesiumTilesetLayer.ts +25 -7
- package/src/layer/czmlLayer.ts +2 -1
- package/src/layer/featureLayer.ts +2 -2
- package/src/layer/featureStoreLayer.ts +8 -8
- package/src/layer/featureStoreLayerChanges.ts +63 -45
- package/src/layer/featureStoreLayerState.ts +6 -5
- package/src/layer/geojsonLayer.ts +3 -3
- package/src/layer/layer.ts +41 -4
- package/src/layer/layerImplementation.ts +3 -0
- package/src/layer/oblique/vectorObliqueImpl.ts +18 -12
- package/src/layer/openlayers/loadFunctionHelpers.ts +24 -0
- package/src/layer/openlayers/singleImageOpenlayersImpl.ts +25 -1
- package/src/layer/openlayers/tmsOpenlayersImpl.ts +8 -1
- package/src/layer/openlayers/vectorTileOpenlayersImpl.ts +1 -0
- package/src/layer/openlayers/wmsOpenlayersImpl.ts +23 -2
- package/src/layer/openlayers/wmtsOpenlayersImpl.ts +8 -1
- package/src/layer/pointCloudLayer.ts +2 -2
- package/src/layer/terrainHelpers.ts +19 -6
- package/src/layer/terrainLayer.ts +8 -4
- package/src/layer/tileProvider/mvtTileProvider.ts +9 -3
- package/src/layer/tileProvider/staticGeojsonTileProvider.ts +9 -3
- package/src/layer/tileProvider/tileProvider.ts +49 -13
- package/src/layer/tileProvider/urlTemplateTileProvider.ts +10 -3
- package/src/layer/vectorLayer.ts +9 -9
- package/src/layer/vectorProperties.ts +46 -22
- package/src/layer/wfsLayer.ts +9 -6
- package/src/layer/wmsHelpers.ts +78 -10
- package/src/layer/wmsLayer.ts +11 -2
- package/src/map/cameraLimiter.ts +21 -2
- package/src/map/cesiumMap.ts +67 -2
- package/src/map/vcsMap.ts +2 -2
- package/src/oblique/helpers.ts +5 -13
- package/src/oblique/obliqueCollection.ts +2 -0
- package/src/oblique/obliqueDataSet.ts +16 -2
- package/src/oblique/obliqueImageMeta.ts +4 -0
- package/src/oblique/obliqueView.ts +12 -2
- package/src/oblique/parseImageJson.ts +7 -4
- package/src/ol/geojson.d.ts +1 -2
- package/src/ol/geom/circle.ts +1 -1
- package/src/style/declarativeStyleItem.ts +10 -2
- package/src/style/styleFactory.ts +2 -2
- package/src/style/styleHelpers.ts +13 -4
- package/src/style/vectorStyleItem.ts +32 -20
- package/src/util/clipping/clippingPlaneHelper.ts +3 -3
- package/src/util/editor/createFeatureSession.ts +9 -8
- package/src/util/editor/editFeaturesSession.ts +1 -1
- package/src/util/editor/editGeometrySession.ts +1 -1
- package/src/util/editor/editorSessionHelpers.ts +2 -2
- package/src/util/editor/selectFeaturesSession.ts +3 -3
- package/src/util/featureconverter/arcToCesium.ts +5 -1
- package/src/util/featureconverter/circleToCesium.ts +8 -2
- package/src/util/featureconverter/extent3D.ts +1 -1
- package/src/util/featureconverter/featureconverterHelper.ts +3 -5
- package/src/util/featureconverter/lineStringToCesium.ts +8 -1
- package/src/util/featureconverter/pointToCesium.ts +1 -1
- package/src/util/featureconverter/polygonToCesium.ts +6 -15
- package/src/util/fetch.ts +25 -0
- package/src/util/flight/flightAnchor.ts +195 -0
- package/src/util/flight/flightCollection.ts +78 -0
- package/src/util/flight/flightHelpers.ts +208 -0
- package/src/util/flight/flightInstance.ts +240 -0
- package/src/util/flight/flightPlayer.ts +326 -0
- package/src/util/flight/flightVisualizer.ts +202 -0
- package/src/util/hiddenObjects.ts +35 -0
- package/src/util/mapCollection.ts +2 -2
- package/src/util/overrideCollection.ts +26 -3
- package/src/util/projection.ts +5 -2
- package/src/util/viewpoint.ts +27 -7
- package/src/vcsApp.ts +56 -15
- package/src/vcsModule.ts +4 -0
package/src/layer/vectorLayer.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
} from '@vcmap-cesium/engine';
|
|
17
17
|
|
|
18
18
|
import { v4 as uuidv4 } from 'uuid';
|
|
19
|
-
import { check } from '@vcsuite/check';
|
|
19
|
+
import { check, oneOf } from '@vcsuite/check';
|
|
20
20
|
import { parseBoolean } from '@vcsuite/parsers';
|
|
21
21
|
import Projection, {
|
|
22
22
|
getDefaultProjection,
|
|
@@ -78,7 +78,12 @@ export type VectorOptions = FeatureLayerOptions & {
|
|
|
78
78
|
|
|
79
79
|
export type VectorGeometryFactoryType = {
|
|
80
80
|
getCoordinates(geom: SimpleGeometry[]): Coordinate[];
|
|
81
|
-
getGeometryOptions(
|
|
81
|
+
getGeometryOptions(
|
|
82
|
+
geom: SimpleGeometry,
|
|
83
|
+
num: number,
|
|
84
|
+
perPositionHeight: boolean,
|
|
85
|
+
groundLevelOrMinHeight: number,
|
|
86
|
+
): unknown;
|
|
82
87
|
createSolidGeometries(
|
|
83
88
|
obj: unknown,
|
|
84
89
|
num: number,
|
|
@@ -101,11 +106,6 @@ export type VectorGeometryFactoryType = {
|
|
|
101
106
|
style: Style,
|
|
102
107
|
): GroundPolylineGeometry[];
|
|
103
108
|
createLineGeometries(obj: unknown, style: Style): PolylineGeometry[];
|
|
104
|
-
createLineGeometries(
|
|
105
|
-
obj: unknown,
|
|
106
|
-
style: Style,
|
|
107
|
-
groundLevel?: number,
|
|
108
|
-
): PolylineGeometry[];
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
export type VectorHeightInfo = {
|
|
@@ -415,7 +415,7 @@ class VectorLayer
|
|
|
415
415
|
* sets the highlightstyle of this layer
|
|
416
416
|
*/
|
|
417
417
|
setHighlightStyle(style: Style | StyleFunction | VectorStyleItem): void {
|
|
418
|
-
check(style,
|
|
418
|
+
check(style, oneOf(Style, VectorStyleItem, Function));
|
|
419
419
|
if (style instanceof VectorStyleItem) {
|
|
420
420
|
this.highlightStyle = style;
|
|
421
421
|
} else {
|
|
@@ -500,7 +500,7 @@ class VectorLayer
|
|
|
500
500
|
* feature geometries are always in EPSG 3857 mercator coordinate system
|
|
501
501
|
*/
|
|
502
502
|
getFeaturesById(ids: (string | number)[]): Feature[] {
|
|
503
|
-
check(ids, [
|
|
503
|
+
check(ids, [oneOf(String, Number)]);
|
|
504
504
|
return ids
|
|
505
505
|
.map((id) => this.getFeatureById(id))
|
|
506
506
|
.filter((f) => f != null) as Feature[];
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
NearFarScalar,
|
|
11
11
|
type SphereGeometry,
|
|
12
12
|
} from '@vcmap-cesium/engine';
|
|
13
|
-
import { check,
|
|
13
|
+
import { check, maybe, ofEnum } from '@vcsuite/check';
|
|
14
14
|
import type { Coordinate } from 'ol/coordinate.js';
|
|
15
15
|
import type { Color } from 'ol/color.js';
|
|
16
16
|
import type { ColorLike } from 'ol/colorlike.js';
|
|
@@ -24,10 +24,12 @@ import { getLogger as getLoggerByName, type Logger } from '@vcsuite/logger';
|
|
|
24
24
|
import VcsEvent from '../vcsEvent.js';
|
|
25
25
|
import { DeclarativeStyleItemOptions } from '../style/declarativeStyleItem.js';
|
|
26
26
|
import { VectorStyleItemOptions } from '../style/vectorStyleItem.js';
|
|
27
|
+
import type { FlightInstanceMeta } from '../util/flight/flightInstance.js';
|
|
27
28
|
|
|
28
29
|
function getLogger(): Logger {
|
|
29
30
|
return getLoggerByName('VectorProperties');
|
|
30
31
|
}
|
|
32
|
+
|
|
31
33
|
export enum PrimitiveOptionsType {
|
|
32
34
|
CYLINDER = 'cylinder',
|
|
33
35
|
SPHERE = 'sphere',
|
|
@@ -72,11 +74,18 @@ export function vectorPropertiesOfType<T extends PrimitiveOptionsType>(
|
|
|
72
74
|
return options.type === type;
|
|
73
75
|
}
|
|
74
76
|
|
|
77
|
+
export type AltitudeModeType =
|
|
78
|
+
| 'absolute'
|
|
79
|
+
| 'relativeToGround'
|
|
80
|
+
| 'clampToGround';
|
|
81
|
+
|
|
82
|
+
export type ClassificationTypeType = 'both' | 'terrain' | 'cesium3DTile';
|
|
83
|
+
|
|
75
84
|
export type VectorPropertiesOptions = {
|
|
76
85
|
/**
|
|
77
86
|
* (3D) Either "relativeToGround", "clampToGround" or 'absolute'
|
|
78
87
|
*/
|
|
79
|
-
altitudeMode?:
|
|
88
|
+
altitudeMode?: AltitudeModeType;
|
|
80
89
|
/**
|
|
81
90
|
* if the features are pickable
|
|
82
91
|
*/
|
|
@@ -84,7 +93,7 @@ export type VectorPropertiesOptions = {
|
|
|
84
93
|
/**
|
|
85
94
|
* (3D) the cesium classification type for this layer. one of 'both', 'terrain' or 'cesium3DTile'
|
|
86
95
|
*/
|
|
87
|
-
classificationType?:
|
|
96
|
+
classificationType?: ClassificationTypeType;
|
|
88
97
|
/**
|
|
89
98
|
* (3D) Array with 4 numbers by which features are being scaled based on distance see <a href="https://cesium.com/docs/cesiumjs-ref-doc/Billboard.html#scaleByDistance"> here </a>
|
|
90
99
|
*/
|
|
@@ -152,7 +161,7 @@ export type VcsMeta = VectorPropertiesOptions & {
|
|
|
152
161
|
style?: VectorStyleItemOptions | DeclarativeStyleItemOptions;
|
|
153
162
|
embeddedIcons?: string[];
|
|
154
163
|
screenSpaceError?: number;
|
|
155
|
-
flightOptions?:
|
|
164
|
+
flightOptions?: FlightInstanceMeta;
|
|
156
165
|
baseUrl?: string;
|
|
157
166
|
/**
|
|
158
167
|
* the layers properties bag
|
|
@@ -181,13 +190,16 @@ export type VectorPropertiesPrimitive = VectorPropertiesBaseOptions & {
|
|
|
181
190
|
*/
|
|
182
191
|
export const vcsMetaVersion = '2.1';
|
|
183
192
|
|
|
184
|
-
export const AltitudeModeCesium = {
|
|
193
|
+
export const AltitudeModeCesium: Record<AltitudeModeType, HeightReference> = {
|
|
185
194
|
clampToGround: HeightReference.CLAMP_TO_GROUND,
|
|
186
195
|
absolute: HeightReference.NONE,
|
|
187
196
|
relativeToGround: HeightReference.RELATIVE_TO_GROUND,
|
|
188
197
|
};
|
|
189
198
|
|
|
190
|
-
export const ClassificationTypeCesium
|
|
199
|
+
export const ClassificationTypeCesium: Record<
|
|
200
|
+
ClassificationTypeType,
|
|
201
|
+
ClassificationType
|
|
202
|
+
> = {
|
|
191
203
|
both: ClassificationType.BOTH,
|
|
192
204
|
cesium3DTile: ClassificationType.CESIUM_3D_TILE,
|
|
193
205
|
terrain: ClassificationType.TERRAIN,
|
|
@@ -246,19 +258,27 @@ export function parseStoreyHeights(
|
|
|
246
258
|
return defaultStoreyHeights;
|
|
247
259
|
}
|
|
248
260
|
|
|
249
|
-
export function getAltitudeModeOptions(
|
|
250
|
-
|
|
261
|
+
export function getAltitudeModeOptions(
|
|
262
|
+
altitudeMode: HeightReference,
|
|
263
|
+
): AltitudeModeType {
|
|
264
|
+
for (const [key, mode] of Object.entries(AltitudeModeCesium) as [
|
|
265
|
+
AltitudeModeType,
|
|
266
|
+
HeightReference,
|
|
267
|
+
][]) {
|
|
251
268
|
if (mode === altitudeMode) {
|
|
252
269
|
return key;
|
|
253
270
|
}
|
|
254
271
|
}
|
|
255
|
-
throw new Error(`
|
|
272
|
+
throw new Error(`Unknown altitude mode ${altitudeMode}`);
|
|
256
273
|
}
|
|
257
274
|
|
|
258
275
|
export function getClassificationTypeOptions(
|
|
259
276
|
classificationType?: ClassificationType,
|
|
260
|
-
):
|
|
261
|
-
for (const [key, mode] of Object.entries(ClassificationTypeCesium)
|
|
277
|
+
): ClassificationTypeType | undefined {
|
|
278
|
+
for (const [key, mode] of Object.entries(ClassificationTypeCesium) as [
|
|
279
|
+
ClassificationTypeType,
|
|
280
|
+
ClassificationType,
|
|
281
|
+
][]) {
|
|
262
282
|
if (mode === classificationType) {
|
|
263
283
|
return key;
|
|
264
284
|
}
|
|
@@ -484,7 +504,7 @@ class VectorProperties {
|
|
|
484
504
|
|
|
485
505
|
set altitudeMode(altitudeMode: HeightReference) {
|
|
486
506
|
if (altitudeMode !== this._altitudeMode) {
|
|
487
|
-
check(altitudeMode,
|
|
507
|
+
check(altitudeMode, ofEnum(HeightReference));
|
|
488
508
|
this._altitudeMode = altitudeMode;
|
|
489
509
|
this.propertyChanged.raiseEvent(['altitudeMode']);
|
|
490
510
|
}
|
|
@@ -521,7 +541,7 @@ class VectorProperties {
|
|
|
521
541
|
|
|
522
542
|
set classificationType(classificationType: ClassificationType | undefined) {
|
|
523
543
|
if (classificationType !== this._classificationType) {
|
|
524
|
-
|
|
544
|
+
check(classificationType, maybe(ofEnum(ClassificationType)));
|
|
525
545
|
this._classificationType = classificationType;
|
|
526
546
|
this.propertyChanged.raiseEvent(['classificationType']);
|
|
527
547
|
}
|
|
@@ -541,7 +561,7 @@ class VectorProperties {
|
|
|
541
561
|
|
|
542
562
|
set scaleByDistance(value: NearFarScalar | undefined) {
|
|
543
563
|
if (!NearFarScalar.equals(value, this._scaleByDistance)) {
|
|
544
|
-
|
|
564
|
+
check(value, maybe(NearFarScalar));
|
|
545
565
|
this._scaleByDistance = value;
|
|
546
566
|
this.propertyChanged.raiseEvent(['scaleByDistance']);
|
|
547
567
|
}
|
|
@@ -560,7 +580,7 @@ class VectorProperties {
|
|
|
560
580
|
|
|
561
581
|
set eyeOffset(value: Cartesian3 | undefined) {
|
|
562
582
|
if (!Cartesian3.equals(this.eyeOffset, value)) {
|
|
563
|
-
|
|
583
|
+
check(value, maybe(Cartesian3));
|
|
564
584
|
this._eyeOffset = value;
|
|
565
585
|
this.propertyChanged.raiseEvent(['eyeOffset']);
|
|
566
586
|
}
|
|
@@ -624,7 +644,7 @@ class VectorProperties {
|
|
|
624
644
|
|
|
625
645
|
set groundLevel(value: number | undefined) {
|
|
626
646
|
if (value !== this._groundLevel) {
|
|
627
|
-
|
|
647
|
+
check(value, maybe(Number));
|
|
628
648
|
this._groundLevel = value;
|
|
629
649
|
this.propertyChanged.raiseEvent(['groundLevel']);
|
|
630
650
|
}
|
|
@@ -731,7 +751,7 @@ class VectorProperties {
|
|
|
731
751
|
}
|
|
732
752
|
|
|
733
753
|
set modelUrl(value: string | undefined) {
|
|
734
|
-
|
|
754
|
+
check(value, maybe(String));
|
|
735
755
|
|
|
736
756
|
if (this._modelUrl !== value) {
|
|
737
757
|
this._modelUrl = value;
|
|
@@ -855,7 +875,7 @@ class VectorProperties {
|
|
|
855
875
|
}
|
|
856
876
|
|
|
857
877
|
set modelOptions(modelOptions: Record<string, unknown> | undefined) {
|
|
858
|
-
|
|
878
|
+
check(modelOptions, maybe(Object));
|
|
859
879
|
|
|
860
880
|
if (this._modelOptions !== modelOptions) {
|
|
861
881
|
this._modelOptions = modelOptions;
|
|
@@ -885,7 +905,7 @@ class VectorProperties {
|
|
|
885
905
|
}
|
|
886
906
|
|
|
887
907
|
set modelAutoScale(value: boolean) {
|
|
888
|
-
|
|
908
|
+
check(value, maybe(Boolean));
|
|
889
909
|
|
|
890
910
|
const booleanValue = !!value;
|
|
891
911
|
if (this._modelAutoScale !== booleanValue) {
|
|
@@ -906,7 +926,7 @@ class VectorProperties {
|
|
|
906
926
|
}
|
|
907
927
|
|
|
908
928
|
set baseUrl(value: string | undefined) {
|
|
909
|
-
|
|
929
|
+
check(value, maybe(String));
|
|
910
930
|
|
|
911
931
|
if (this._baseUrl !== value) {
|
|
912
932
|
this._baseUrl = value;
|
|
@@ -924,7 +944,7 @@ class VectorProperties {
|
|
|
924
944
|
}
|
|
925
945
|
|
|
926
946
|
set primitiveOptions(value: VectorPropertiesPrimitiveOptions | undefined) {
|
|
927
|
-
|
|
947
|
+
check(value, maybe(Object));
|
|
928
948
|
|
|
929
949
|
if (this._primitiveOptions !== value) {
|
|
930
950
|
this._primitiveOptions = value;
|
|
@@ -1282,11 +1302,15 @@ class VectorProperties {
|
|
|
1282
1302
|
/**
|
|
1283
1303
|
* The common vector properties for the input features.
|
|
1284
1304
|
* @param features Features for which the vector property values should be returned.
|
|
1285
|
-
* @returns The common vector properties for the features. When a/all feature(s) does not has a property set, the layer or, if not set, the default value is returned. If features have different values for a property, the property key is not added to the returned obeject.
|
|
1305
|
+
* @returns The common vector properties for the features. When a/all feature(s) does not has a property set, the layer or, if not set, the default value is returned. If features have different values for a property, the property key is not added to the returned obeject. If feature array is empty, an empty object is returned.
|
|
1286
1306
|
*/
|
|
1287
1307
|
getValuesForFeatures(features: Feature[]): VectorPropertiesOptions {
|
|
1288
1308
|
const values: VectorPropertiesOptions = {};
|
|
1289
1309
|
|
|
1310
|
+
if (!features.length) {
|
|
1311
|
+
return values;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1290
1314
|
/**
|
|
1291
1315
|
* Checks if all the values of the array are equal using fast-deep-equal.
|
|
1292
1316
|
* @param propertyValues An array of values for a specific property from different features.
|
package/src/layer/wfsLayer.ts
CHANGED
|
@@ -2,7 +2,7 @@ import WFSFormat from 'ol/format/WFS.js';
|
|
|
2
2
|
import VectorLayer, { VectorOptions } from './vectorLayer.js';
|
|
3
3
|
import Projection from '../util/projection.js';
|
|
4
4
|
import { layerClassRegistry } from '../classRegistry.js';
|
|
5
|
-
import { requestUrl } from '../util/fetch.js';
|
|
5
|
+
import { getInitForUrl, requestUrl } from '../util/fetch.js';
|
|
6
6
|
|
|
7
7
|
export type WFSOptions = VectorOptions & {
|
|
8
8
|
/**
|
|
@@ -125,13 +125,16 @@ class WFSLayer extends VectorLayer {
|
|
|
125
125
|
...this.getFeaturesOptions,
|
|
126
126
|
});
|
|
127
127
|
const postData = new XMLSerializer().serializeToString(requestDocument);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
const init = getInitForUrl(this.url, this.headers);
|
|
129
|
+
init.method = 'POST';
|
|
130
|
+
init.body = postData;
|
|
131
|
+
init.headers = {
|
|
132
|
+
...init.headers,
|
|
133
|
+
...{
|
|
131
134
|
'Content-Type': 'application/text+xml',
|
|
132
135
|
},
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
};
|
|
137
|
+
this._dataFetchedPromise = requestUrl(this.url, init)
|
|
135
138
|
.then((response) => response.text())
|
|
136
139
|
.then((data) => this._parseWFSData(data))
|
|
137
140
|
.catch((err) => {
|
package/src/layer/wmsHelpers.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { TrustedServers } from '@vcmap-cesium/engine';
|
|
2
|
+
import { getLogger } from '@vcsuite/logger';
|
|
1
3
|
import type { Size } from 'ol/size.js';
|
|
2
4
|
import TileWMS, { type Options as TileWMSOptions } from 'ol/source/TileWMS.js';
|
|
5
|
+
import ImageWMS, {
|
|
6
|
+
type Options as ImageWMSOptions,
|
|
7
|
+
} from 'ol/source/ImageWMS.js';
|
|
8
|
+
|
|
3
9
|
import { getTopLeft, getWidth } from 'ol/extent.js';
|
|
4
10
|
import TileGrid, {
|
|
5
11
|
type Options as TileGridOptions,
|
|
@@ -8,6 +14,8 @@ import { mercatorProjection, wgs84Projection } from '../util/projection.js';
|
|
|
8
14
|
import { isSameOrigin } from '../util/urlHelpers.js';
|
|
9
15
|
import type Extent from '../util/extent.js';
|
|
10
16
|
import { TilingScheme } from './rasterLayer.js';
|
|
17
|
+
import { getTileLoadFunction } from './openlayers/loadFunctionHelpers.js';
|
|
18
|
+
import { getInitForUrl, requestObjectUrl } from '../util/fetch.js';
|
|
11
19
|
|
|
12
20
|
export type WMSSourceOptions = {
|
|
13
21
|
url: string;
|
|
@@ -18,9 +26,23 @@ export type WMSSourceOptions = {
|
|
|
18
26
|
extent?: Extent;
|
|
19
27
|
parameters: Record<string, string>;
|
|
20
28
|
version: string;
|
|
29
|
+
headers?: Record<string, string>;
|
|
21
30
|
};
|
|
22
31
|
|
|
23
|
-
|
|
32
|
+
export function getProjectionFromWMSSourceOptions(
|
|
33
|
+
tilingSchema: TilingScheme,
|
|
34
|
+
version: string,
|
|
35
|
+
): string {
|
|
36
|
+
if (tilingSchema === 'geographic') {
|
|
37
|
+
if (version === '1.3.0') {
|
|
38
|
+
return 'CRS:84';
|
|
39
|
+
} else {
|
|
40
|
+
return 'EPSG:4326';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return 'EPSG:3857';
|
|
44
|
+
}
|
|
45
|
+
|
|
24
46
|
export function getWMSSource(options: WMSSourceOptions): TileWMS {
|
|
25
47
|
const projection =
|
|
26
48
|
options.tilingSchema === 'geographic'
|
|
@@ -55,18 +77,64 @@ export function getWMSSource(options: WMSSourceOptions): TileWMS {
|
|
|
55
77
|
url: options.url,
|
|
56
78
|
tileGrid: new TileGrid(tilingOptions),
|
|
57
79
|
params: options.parameters,
|
|
80
|
+
projection: getProjectionFromWMSSourceOptions(
|
|
81
|
+
options.tilingSchema,
|
|
82
|
+
options.version,
|
|
83
|
+
),
|
|
58
84
|
};
|
|
59
|
-
|
|
85
|
+
|
|
86
|
+
if (TrustedServers.contains(options.url)) {
|
|
87
|
+
sourceOptions.crossOrigin = 'use-credentials';
|
|
88
|
+
} else if (!isSameOrigin(options.url)) {
|
|
60
89
|
sourceOptions.crossOrigin = 'anonymous';
|
|
61
90
|
}
|
|
62
|
-
if (options.
|
|
63
|
-
|
|
64
|
-
sourceOptions.projection = 'CRS:84';
|
|
65
|
-
} else {
|
|
66
|
-
sourceOptions.projection = 'EPSG:4326';
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
sourceOptions.projection = 'EPSG:3857';
|
|
91
|
+
if (options.headers) {
|
|
92
|
+
sourceOptions.tileLoadFunction = getTileLoadFunction(options.headers);
|
|
70
93
|
}
|
|
71
94
|
return new TileWMS(sourceOptions);
|
|
72
95
|
}
|
|
96
|
+
|
|
97
|
+
export function getImageWMSSource(options: {
|
|
98
|
+
url: string;
|
|
99
|
+
parameters: Record<string, string>;
|
|
100
|
+
tilingSchema: TilingScheme;
|
|
101
|
+
version: string;
|
|
102
|
+
headers?: Record<string, string>;
|
|
103
|
+
}): ImageWMS {
|
|
104
|
+
const sourceOptions: ImageWMSOptions = {
|
|
105
|
+
url: options.url,
|
|
106
|
+
params: options.parameters,
|
|
107
|
+
projection: getProjectionFromWMSSourceOptions(
|
|
108
|
+
options.tilingSchema,
|
|
109
|
+
options.version,
|
|
110
|
+
),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
if (TrustedServers.contains(options.url)) {
|
|
114
|
+
sourceOptions.crossOrigin = 'use-credentials';
|
|
115
|
+
} else if (!isSameOrigin(options.url)) {
|
|
116
|
+
sourceOptions.crossOrigin = 'anonymous';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (options.headers) {
|
|
120
|
+
sourceOptions.imageLoadFunction = function imageLoadFunction(
|
|
121
|
+
image,
|
|
122
|
+
src,
|
|
123
|
+
): void {
|
|
124
|
+
const img = image.getImage() as HTMLImageElement;
|
|
125
|
+
const init = getInitForUrl(src, options.headers);
|
|
126
|
+
requestObjectUrl(src, init)
|
|
127
|
+
.then((blobUrl) => {
|
|
128
|
+
img.src = blobUrl;
|
|
129
|
+
img.onload = (): void => {
|
|
130
|
+
URL.revokeObjectURL(blobUrl);
|
|
131
|
+
};
|
|
132
|
+
})
|
|
133
|
+
.catch(() => {
|
|
134
|
+
getLogger('ImageWMSSource').error(`Could not load image: ${src}`);
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return new ImageWMS(sourceOptions);
|
|
140
|
+
}
|
package/src/layer/wmsLayer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { check } from '@vcsuite/check';
|
|
1
|
+
import { check, oneOf } from '@vcsuite/check';
|
|
2
2
|
import { parseBoolean } from '@vcsuite/parsers';
|
|
3
3
|
import type { Size } from 'ol/size.js';
|
|
4
4
|
|
|
@@ -22,6 +22,7 @@ export type WMSImplementationOptions = RasterLayerImplementationOptions & {
|
|
|
22
22
|
highResolution: boolean;
|
|
23
23
|
tileSize: import('ol/size.js').Size;
|
|
24
24
|
version: string;
|
|
25
|
+
singleImage2d: boolean;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
export type WMSOptions = RasterLayerOptions & {
|
|
@@ -50,6 +51,10 @@ export type WMSOptions = RasterLayerOptions & {
|
|
|
50
51
|
* use higher resolution images (sofar only in 3D)
|
|
51
52
|
*/
|
|
52
53
|
highResolution?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Use a single image in 2D
|
|
56
|
+
*/
|
|
57
|
+
singleImage2d?: boolean;
|
|
53
58
|
};
|
|
54
59
|
|
|
55
60
|
/**
|
|
@@ -81,6 +86,8 @@ class WMSLayer extends RasterLayer<WmsCesiumImpl | WmsOpenlayersImpl> {
|
|
|
81
86
|
|
|
82
87
|
highResolution: boolean;
|
|
83
88
|
|
|
89
|
+
singleImage2d: boolean;
|
|
90
|
+
|
|
84
91
|
private _featureInfoOptions: Partial<WMSFeatureProviderOptions> | undefined;
|
|
85
92
|
|
|
86
93
|
/**
|
|
@@ -127,6 +134,7 @@ class WMSLayer extends RasterLayer<WmsCesiumImpl | WmsOpenlayersImpl> {
|
|
|
127
134
|
this._featureInfoOptions =
|
|
128
135
|
options.featureInfo || defaultOptions.featureInfo;
|
|
129
136
|
this._supportedMaps = [CesiumMap.className, OpenlayersMap.className];
|
|
137
|
+
this.singleImage2d = parseBoolean(options.singleImage2d, false);
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
initialize(): Promise<void> {
|
|
@@ -171,6 +179,7 @@ class WMSLayer extends RasterLayer<WmsCesiumImpl | WmsOpenlayersImpl> {
|
|
|
171
179
|
parameters: this.parameters,
|
|
172
180
|
highResolution: this.highResolution,
|
|
173
181
|
tileSize: this.tileSize,
|
|
182
|
+
singleImage2d: this.singleImage2d,
|
|
174
183
|
};
|
|
175
184
|
}
|
|
176
185
|
|
|
@@ -190,7 +199,7 @@ class WMSLayer extends RasterLayer<WmsCesiumImpl | WmsOpenlayersImpl> {
|
|
|
190
199
|
* @param layers - a layer name or an array of layer names
|
|
191
200
|
*/
|
|
192
201
|
async setLayers(layers: string | string[]): Promise<void> {
|
|
193
|
-
check(layers,
|
|
202
|
+
check(layers, oneOf(String, [String]));
|
|
194
203
|
const layersArray = Array.isArray(layers) ? layers : [layers];
|
|
195
204
|
this.parameters.LAYERS = layersArray.join(',');
|
|
196
205
|
await this.forceRedraw();
|
package/src/map/cameraLimiter.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import deepEqual from 'fast-deep-equal';
|
|
1
2
|
import {
|
|
2
3
|
Camera,
|
|
3
4
|
Cartographic,
|
|
@@ -6,7 +7,7 @@ import {
|
|
|
6
7
|
sampleTerrain,
|
|
7
8
|
sampleTerrainMostDetailed,
|
|
8
9
|
} from '@vcmap-cesium/engine';
|
|
9
|
-
import {
|
|
10
|
+
import { check, maybe } from '@vcsuite/check';
|
|
10
11
|
import { parseInteger, parseNumber, parseEnumValue } from '@vcsuite/parsers';
|
|
11
12
|
import {
|
|
12
13
|
getTerrainProviderForUrl,
|
|
@@ -26,6 +27,10 @@ export type CameraLimiterOptions = {
|
|
|
26
27
|
* required if mode is distance.
|
|
27
28
|
*/
|
|
28
29
|
terrainUrl?: string;
|
|
30
|
+
/**
|
|
31
|
+
* if mode is distance this can be used to send headers with each request to the terrainUrl
|
|
32
|
+
*/
|
|
33
|
+
terrainRequestHeaders?: Record<string, string>;
|
|
29
34
|
/**
|
|
30
35
|
* @default 'height'
|
|
31
36
|
*/
|
|
@@ -53,6 +58,7 @@ class CameraLimiter {
|
|
|
53
58
|
return {
|
|
54
59
|
mode: CameraLimiterMode.HEIGHT,
|
|
55
60
|
terrainUrl: undefined,
|
|
61
|
+
terrainRequestHeaders: undefined,
|
|
56
62
|
limit: 200,
|
|
57
63
|
level: 12,
|
|
58
64
|
};
|
|
@@ -80,6 +86,8 @@ class CameraLimiter {
|
|
|
80
86
|
*/
|
|
81
87
|
lastCheckedPosition = new Cartographic();
|
|
82
88
|
|
|
89
|
+
terrainRequestHeaders?: Record<string, string>;
|
|
90
|
+
|
|
83
91
|
/**
|
|
84
92
|
* last updated terrain height
|
|
85
93
|
*/
|
|
@@ -101,6 +109,7 @@ class CameraLimiter {
|
|
|
101
109
|
options.level === null
|
|
102
110
|
? null
|
|
103
111
|
: parseInteger(options.level, defaultOptions.level as number);
|
|
112
|
+
this.terrainRequestHeaders = options.terrainRequestHeaders;
|
|
104
113
|
}
|
|
105
114
|
|
|
106
115
|
/**
|
|
@@ -111,7 +120,7 @@ class CameraLimiter {
|
|
|
111
120
|
}
|
|
112
121
|
|
|
113
122
|
set terrainUrl(url: string | undefined) {
|
|
114
|
-
|
|
123
|
+
check(url, maybe(String));
|
|
115
124
|
|
|
116
125
|
if (this._terrainUrl !== url) {
|
|
117
126
|
this._terrainUrl = url;
|
|
@@ -124,6 +133,7 @@ class CameraLimiter {
|
|
|
124
133
|
const terrainProvider = await getTerrainProviderForUrl(
|
|
125
134
|
this.terrainUrl as string,
|
|
126
135
|
{},
|
|
136
|
+
this.terrainRequestHeaders,
|
|
127
137
|
);
|
|
128
138
|
if (
|
|
129
139
|
this.level &&
|
|
@@ -140,6 +150,7 @@ class CameraLimiter {
|
|
|
140
150
|
const terrainProvider = await getTerrainProviderForUrl(
|
|
141
151
|
this.terrainUrl as string,
|
|
142
152
|
{},
|
|
153
|
+
this.terrainRequestHeaders,
|
|
143
154
|
);
|
|
144
155
|
return sampleTerrainMostDetailed(terrainProvider, [cameraCartographic]);
|
|
145
156
|
}
|
|
@@ -222,6 +233,14 @@ class CameraLimiter {
|
|
|
222
233
|
if (this.level !== defaultOptions.level) {
|
|
223
234
|
config.level = this.level;
|
|
224
235
|
}
|
|
236
|
+
if (
|
|
237
|
+
!deepEqual(
|
|
238
|
+
this.terrainRequestHeaders,
|
|
239
|
+
defaultOptions.terrainRequestHeaders,
|
|
240
|
+
)
|
|
241
|
+
) {
|
|
242
|
+
config.terrainRequestHeaders = this.terrainRequestHeaders;
|
|
243
|
+
}
|
|
225
244
|
return config;
|
|
226
245
|
}
|
|
227
246
|
}
|
package/src/map/cesiumMap.ts
CHANGED
|
@@ -36,10 +36,11 @@ import {
|
|
|
36
36
|
type EntityCluster,
|
|
37
37
|
type DataSource,
|
|
38
38
|
type Visualizer,
|
|
39
|
+
type ShadowMap,
|
|
39
40
|
} from '@vcmap-cesium/engine';
|
|
40
41
|
import type { Coordinate } from 'ol/coordinate.js';
|
|
41
42
|
|
|
42
|
-
import {
|
|
43
|
+
import { check, maybe } from '@vcsuite/check';
|
|
43
44
|
import { parseBoolean, parseInteger, parseNumber } from '@vcsuite/parsers';
|
|
44
45
|
import VcsMap, { type VcsMapOptions } from './vcsMap.js';
|
|
45
46
|
import Viewpoint from '../util/viewpoint.js';
|
|
@@ -55,6 +56,7 @@ import CameraLimiter, { CameraLimiterOptions } from './cameraLimiter.js';
|
|
|
55
56
|
import { mapClassRegistry } from '../classRegistry.js';
|
|
56
57
|
import type LayerCollection from '../util/layerCollection.js';
|
|
57
58
|
import type Layer from '../layer/layer.js';
|
|
59
|
+
import VcsEvent from '../vcsEvent.js';
|
|
58
60
|
|
|
59
61
|
export type CesiumMapOptions = VcsMapOptions & {
|
|
60
62
|
/**
|
|
@@ -327,6 +329,18 @@ class CesiumMap extends VcsMap<CesiumVisualisationType> {
|
|
|
327
329
|
|
|
328
330
|
defaultJDate: JulianDate;
|
|
329
331
|
|
|
332
|
+
/**
|
|
333
|
+
* The defaultShadowMap which is created when calling the constructor of the CesiumWidet in {@link initialize}. This is a reference, not a clone.
|
|
334
|
+
*/
|
|
335
|
+
private _defaultShadowMap: ShadowMap | null;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* A cache of the shadowMap that is set, before {@link initialize} is called. It is applied as soon the instance is initialized.
|
|
339
|
+
*/
|
|
340
|
+
private _initialShadowMap: ShadowMap | null;
|
|
341
|
+
|
|
342
|
+
shadowMapChanged: VcsEvent<ShadowMap>;
|
|
343
|
+
|
|
330
344
|
webGLaa: boolean;
|
|
331
345
|
|
|
332
346
|
globeColor: Color;
|
|
@@ -383,6 +397,12 @@ class CesiumMap extends VcsMap<CesiumVisualisationType> {
|
|
|
383
397
|
|
|
384
398
|
this.defaultJDate = JulianDate.fromDate(new Date(2014, 6, 20, 13, 0, 0, 0));
|
|
385
399
|
|
|
400
|
+
this._defaultShadowMap = null;
|
|
401
|
+
|
|
402
|
+
this._initialShadowMap = null;
|
|
403
|
+
|
|
404
|
+
this.shadowMapChanged = new VcsEvent();
|
|
405
|
+
|
|
386
406
|
this.webGLaa = parseBoolean(options.webGLaa, defaultOptions.webGLaa);
|
|
387
407
|
|
|
388
408
|
this.useOriginalCesiumShader = parseBoolean(
|
|
@@ -459,7 +479,7 @@ class CesiumMap extends VcsMap<CesiumVisualisationType> {
|
|
|
459
479
|
}
|
|
460
480
|
|
|
461
481
|
set cameraLimiter(limiter: CameraLimiter | null) {
|
|
462
|
-
|
|
482
|
+
check(limiter, maybe(CameraLimiter));
|
|
463
483
|
|
|
464
484
|
if (this._cameraLimiter !== limiter) {
|
|
465
485
|
this._cameraLimiter = limiter;
|
|
@@ -732,6 +752,13 @@ class CesiumMap extends VcsMap<CesiumVisualisationType> {
|
|
|
732
752
|
},
|
|
733
753
|
),
|
|
734
754
|
);
|
|
755
|
+
|
|
756
|
+
this._defaultShadowMap = this._cesiumWidget.scene.shadowMap;
|
|
757
|
+
|
|
758
|
+
if (this._initialShadowMap) {
|
|
759
|
+
this.setShadowMap(this._initialShadowMap);
|
|
760
|
+
this._initialShadowMap = null;
|
|
761
|
+
}
|
|
735
762
|
}
|
|
736
763
|
return Promise.resolve();
|
|
737
764
|
}
|
|
@@ -1023,6 +1050,40 @@ class CesiumMap extends VcsMap<CesiumVisualisationType> {
|
|
|
1023
1050
|
}
|
|
1024
1051
|
}
|
|
1025
1052
|
|
|
1053
|
+
/**
|
|
1054
|
+
* Sets a shadow map on the scene of the cesiumMaps cesiumWidget. Raises an event if the shadow map changes. This function should be used to set the shadowMap instead of setting it directly on the scene.
|
|
1055
|
+
* @param shadowMap The shadowMap to assign to the scene of the cesium widget.
|
|
1056
|
+
*/
|
|
1057
|
+
setShadowMap(shadowMap: ShadowMap): void {
|
|
1058
|
+
if (!shadowMap) {
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
if (!this._cesiumWidget) {
|
|
1063
|
+
this._initialShadowMap = shadowMap;
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
const { scene } = this._cesiumWidget;
|
|
1068
|
+
|
|
1069
|
+
if (scene.shadowMap !== shadowMap) {
|
|
1070
|
+
scene.shadowMap = shadowMap;
|
|
1071
|
+
this.shadowMapChanged.raiseEvent(shadowMap);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* Sets the default shadow map.
|
|
1077
|
+
*/
|
|
1078
|
+
setDefaultShadowMap(): void {
|
|
1079
|
+
if (!this._cesiumWidget || !this._defaultShadowMap) {
|
|
1080
|
+
this._initialShadowMap = null;
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
this.setShadowMap(this._defaultShadowMap);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1026
1087
|
/**
|
|
1027
1088
|
* returns the cesium Widget Object
|
|
1028
1089
|
*/
|
|
@@ -1380,6 +1441,10 @@ class CesiumMap extends VcsMap<CesiumVisualisationType> {
|
|
|
1380
1441
|
this._cesiumWidget = null;
|
|
1381
1442
|
}
|
|
1382
1443
|
|
|
1444
|
+
this._initialShadowMap = null;
|
|
1445
|
+
this._defaultShadowMap = null;
|
|
1446
|
+
this.shadowMapChanged.destroy();
|
|
1447
|
+
|
|
1383
1448
|
super.destroy();
|
|
1384
1449
|
}
|
|
1385
1450
|
}
|