@vcmap/core 5.0.2 → 5.1.0-rc.1
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/cesium.d.ts +257 -0
- package/dist/geojson.d.ts +27 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/ol.d.ts +138 -0
- 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 +9 -6
- 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 +4 -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 +9 -8
- 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
|
@@ -4,12 +4,13 @@ import {
|
|
|
4
4
|
ConditionsExpression,
|
|
5
5
|
Expression,
|
|
6
6
|
Cesium3DTileStyle,
|
|
7
|
+
TrustedServers,
|
|
7
8
|
} from '@vcmap-cesium/engine';
|
|
8
9
|
import { is } from '@vcsuite/check';
|
|
9
10
|
|
|
10
11
|
import Style, { type StyleFunction } from 'ol/style/Style.js';
|
|
11
12
|
import Stroke from 'ol/style/Stroke.js';
|
|
12
|
-
import Icon from 'ol/style/Icon.js';
|
|
13
|
+
import Icon, { type Options as IconOptions } from 'ol/style/Icon.js';
|
|
13
14
|
import Circle, { type Options as CircleOptions } from 'ol/style/Circle.js';
|
|
14
15
|
import OLText from 'ol/style/Text.js';
|
|
15
16
|
import Fill from 'ol/style/Fill.js';
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
} from './styleHelpers.js';
|
|
24
25
|
import { originalFeatureSymbol } from '../layer/vectorSymbols.js';
|
|
25
26
|
import { styleClassRegistry } from '../classRegistry.js';
|
|
27
|
+
import { isSameOrigin } from '../util/urlHelpers.js';
|
|
26
28
|
|
|
27
29
|
type DeclarativeStyleItemConditions = {
|
|
28
30
|
conditions: Array<string[] | string>;
|
|
@@ -300,7 +302,13 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
300
302
|
if (this.cesiumStyle.image) {
|
|
301
303
|
const src = this.cesiumStyle.image.evaluate(feature);
|
|
302
304
|
if (src) {
|
|
303
|
-
|
|
305
|
+
const iconOptions: IconOptions = { src };
|
|
306
|
+
if (TrustedServers.contains(src)) {
|
|
307
|
+
iconOptions.crossOrigin = 'use-credentials';
|
|
308
|
+
} else if (!isSameOrigin(src)) {
|
|
309
|
+
iconOptions.crossOrigin = 'anonymous';
|
|
310
|
+
}
|
|
311
|
+
style.setImage(new Icon(iconOptions));
|
|
304
312
|
}
|
|
305
313
|
} else {
|
|
306
314
|
const color =
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { is } from '@vcsuite/check';
|
|
1
|
+
import { is, oneOf } from '@vcsuite/check';
|
|
2
2
|
import StyleItem, { StyleItemOptions } from './styleItem.js';
|
|
3
3
|
import {
|
|
4
4
|
DeclarativeStyleItemOptions,
|
|
@@ -15,7 +15,7 @@ export function getStyleOrDefaultStyle(
|
|
|
15
15
|
| StyleItem,
|
|
16
16
|
defaultStyle?: StyleItem,
|
|
17
17
|
): StyleItem {
|
|
18
|
-
if (is(styleOptions,
|
|
18
|
+
if (is(styleOptions, oneOf(StyleItem, { type: String }))) {
|
|
19
19
|
if (styleOptions instanceof StyleItem) {
|
|
20
20
|
return styleOptions;
|
|
21
21
|
} else {
|
|
@@ -3,12 +3,12 @@ import Fill, { type Options as FillOptions } from 'ol/style/Fill.js';
|
|
|
3
3
|
import Stroke, { type Options as StrokeOptions } from 'ol/style/Stroke.js';
|
|
4
4
|
import OLText, { type Options as TextOptions } from 'ol/style/Text.js';
|
|
5
5
|
import Style from 'ol/style/Style.js';
|
|
6
|
-
import { Color } from '@vcmap-cesium/engine';
|
|
6
|
+
import { Color, TrustedServers } from '@vcmap-cesium/engine';
|
|
7
7
|
import type { Color as OLColor } from 'ol/color.js';
|
|
8
8
|
import type { Size } from 'ol/size.js';
|
|
9
9
|
import ImageStyle from 'ol/style/Image.js';
|
|
10
10
|
import Circle from 'ol/style/Circle.js';
|
|
11
|
-
import Icon from 'ol/style/Icon.js';
|
|
11
|
+
import Icon, { type Options as IconOptions } from 'ol/style/Icon.js';
|
|
12
12
|
import RegularShape from 'ol/style/RegularShape.js';
|
|
13
13
|
import { getLogger as getLoggerByName, type Logger } from '@vcsuite/logger';
|
|
14
14
|
import type {
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
VectorStyleItemOptions,
|
|
18
18
|
VectorStyleItemText,
|
|
19
19
|
} from './vectorStyleItem.js';
|
|
20
|
+
import { isSameOrigin } from '../util/urlHelpers.js';
|
|
20
21
|
|
|
21
22
|
function getLogger(): Logger {
|
|
22
23
|
return getLoggerByName('StyleHelpers');
|
|
@@ -535,13 +536,21 @@ export function getImageStyleFromOptions(
|
|
|
535
536
|
});
|
|
536
537
|
}
|
|
537
538
|
} else {
|
|
538
|
-
|
|
539
|
+
const iconOptions: IconOptions = {
|
|
539
540
|
src: options.src,
|
|
540
541
|
scale: options.scale,
|
|
541
542
|
opacity: options.opacity,
|
|
542
543
|
color: options.color,
|
|
543
544
|
anchor: options.anchor,
|
|
544
|
-
}
|
|
545
|
+
};
|
|
546
|
+
if (options.src) {
|
|
547
|
+
if (TrustedServers.contains(options.src)) {
|
|
548
|
+
iconOptions.crossOrigin = 'use-credentials';
|
|
549
|
+
} else if (!isSameOrigin(options.src)) {
|
|
550
|
+
iconOptions.crossOrigin = 'anonymous';
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return new Icon(iconOptions);
|
|
545
554
|
}
|
|
546
555
|
}
|
|
547
556
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-template-curly-in-string,@typescript-eslint/ban-ts-comment */
|
|
2
2
|
import Stroke, { Options as StrokeOptions } from 'ol/style/Stroke.js';
|
|
3
|
-
import { Color, VerticalOrigin } from '@vcmap-cesium/engine';
|
|
3
|
+
import { Color, TrustedServers, VerticalOrigin } from '@vcmap-cesium/engine';
|
|
4
4
|
import Icon, { type Options as IconOptions } from 'ol/style/Icon.js';
|
|
5
5
|
import Style, { type StyleFunction } from 'ol/style/Style.js';
|
|
6
6
|
import OLText from 'ol/style/Text.js';
|
|
@@ -13,7 +13,7 @@ import { Color as OLColor } from 'ol/color.js';
|
|
|
13
13
|
import { ColorLike as OLColorLike } from 'ol/colorlike.js';
|
|
14
14
|
import type { Feature } from 'ol/index.js';
|
|
15
15
|
|
|
16
|
-
import { check,
|
|
16
|
+
import { check, maybe, oneOf, strict } from '@vcsuite/check';
|
|
17
17
|
import StyleItem, { StyleItemOptions } from './styleItem.js';
|
|
18
18
|
import {
|
|
19
19
|
parseColor,
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
} from './styleHelpers.js';
|
|
33
33
|
import { getShapeFromOptions } from './shapesCategory.js';
|
|
34
34
|
import { styleClassRegistry } from '../classRegistry.js';
|
|
35
|
+
import { isSameOrigin } from '../util/urlHelpers.js';
|
|
35
36
|
|
|
36
37
|
export type ColorType = OLColor | OLColorLike;
|
|
37
38
|
export type VectorStyleItemPattern = {
|
|
@@ -148,9 +149,19 @@ class VectorStyleItem extends StyleItem {
|
|
|
148
149
|
this._cesiumColor = new Color();
|
|
149
150
|
this._image = undefined;
|
|
150
151
|
if (options.image) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
if (options.image.radius) {
|
|
153
|
+
this._image = getShapeFromOptions({ ...options.image });
|
|
154
|
+
} else {
|
|
155
|
+
const iconOptions: IconOptions = { ...(options.image as IconOptions) };
|
|
156
|
+
if (iconOptions.src) {
|
|
157
|
+
if (TrustedServers.contains(iconOptions.src)) {
|
|
158
|
+
iconOptions.crossOrigin = 'use-credentials';
|
|
159
|
+
} else if (!isSameOrigin(iconOptions.src)) {
|
|
160
|
+
iconOptions.crossOrigin = 'anonymous';
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
this._image = new Icon(iconOptions);
|
|
164
|
+
}
|
|
154
165
|
}
|
|
155
166
|
|
|
156
167
|
this._style = new Style({
|
|
@@ -172,7 +183,7 @@ class VectorStyleItem extends StyleItem {
|
|
|
172
183
|
try {
|
|
173
184
|
option.color = parseColor(option.color as ColorType);
|
|
174
185
|
check(option.color, [Number]);
|
|
175
|
-
check(option.color.length,
|
|
186
|
+
check(option.color.length, oneOf(3, 4));
|
|
176
187
|
} catch (e) {
|
|
177
188
|
this.getLogger().error((e as Error).message);
|
|
178
189
|
option.color = [255, 255, 255, 0.4];
|
|
@@ -306,15 +317,16 @@ class VectorStyleItem extends StyleItem {
|
|
|
306
317
|
return;
|
|
307
318
|
}
|
|
308
319
|
if (patternOptions) {
|
|
309
|
-
|
|
320
|
+
check(
|
|
310
321
|
patternOptions,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
322
|
+
maybe(
|
|
323
|
+
strict({
|
|
324
|
+
color: oneOf(String, [Number]),
|
|
325
|
+
width: Number,
|
|
326
|
+
type: Number,
|
|
327
|
+
size: maybe(Number),
|
|
328
|
+
}),
|
|
329
|
+
),
|
|
318
330
|
);
|
|
319
331
|
this._fillOptions.pattern = patternOptions;
|
|
320
332
|
} else {
|
|
@@ -330,7 +342,7 @@ class VectorStyleItem extends StyleItem {
|
|
|
330
342
|
set stroke(stroke: Stroke | undefined) {
|
|
331
343
|
this.exclude.stroke = false;
|
|
332
344
|
if (this._style instanceof Style) {
|
|
333
|
-
|
|
345
|
+
check(stroke, maybe(Stroke));
|
|
334
346
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
335
347
|
// @ts-ignore // bug in ol
|
|
336
348
|
this._style.setStroke(stroke);
|
|
@@ -346,7 +358,7 @@ class VectorStyleItem extends StyleItem {
|
|
|
346
358
|
}
|
|
347
359
|
|
|
348
360
|
set label(label: string | undefined) {
|
|
349
|
-
|
|
361
|
+
check(label, maybe(String));
|
|
350
362
|
if (!label) {
|
|
351
363
|
this._label = undefined;
|
|
352
364
|
} else {
|
|
@@ -363,7 +375,7 @@ class VectorStyleItem extends StyleItem {
|
|
|
363
375
|
|
|
364
376
|
set text(text: OLText | undefined) {
|
|
365
377
|
if (this._style instanceof Style) {
|
|
366
|
-
|
|
378
|
+
check(text, maybe(OLText));
|
|
367
379
|
this._text = text;
|
|
368
380
|
this._text?.setText?.(this._label);
|
|
369
381
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -381,7 +393,7 @@ class VectorStyleItem extends StyleItem {
|
|
|
381
393
|
set image(image: OLImage | undefined) {
|
|
382
394
|
this.exclude.image = false;
|
|
383
395
|
if (this._style instanceof Style) {
|
|
384
|
-
|
|
396
|
+
check(image, maybe(OLImage));
|
|
385
397
|
this._image = image;
|
|
386
398
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
387
399
|
// @ts-ignore // bug in ol
|
|
@@ -397,7 +409,7 @@ class VectorStyleItem extends StyleItem {
|
|
|
397
409
|
}
|
|
398
410
|
|
|
399
411
|
set style(style: Style | StyleFunction) {
|
|
400
|
-
|
|
412
|
+
check(style, maybe(oneOf(Style, Function)));
|
|
401
413
|
if (style instanceof Style) {
|
|
402
414
|
this._stroke = style.getStroke();
|
|
403
415
|
this._fill = style.getFill();
|
|
@@ -816,7 +828,7 @@ class VectorStyleItem extends StyleItem {
|
|
|
816
828
|
* @param section - one of fill, stroke, image
|
|
817
829
|
*/
|
|
818
830
|
unset(section: keyof VectorStyleItemExclusion): void {
|
|
819
|
-
check(section, Object.keys(this.exclude));
|
|
831
|
+
check(section, oneOf(...Object.keys(this.exclude)));
|
|
820
832
|
if (section === 'fill') {
|
|
821
833
|
this.fillColor = undefined;
|
|
822
834
|
} else {
|
|
@@ -18,7 +18,7 @@ import Feature from 'ol/Feature.js';
|
|
|
18
18
|
import LineString from 'ol/geom/LineString.js';
|
|
19
19
|
import { offset } from 'ol/sphere.js';
|
|
20
20
|
import Polygon from 'ol/geom/Polygon.js';
|
|
21
|
-
import { check,
|
|
21
|
+
import { check, maybe, optional } from '@vcsuite/check';
|
|
22
22
|
import Projection, {
|
|
23
23
|
mercatorProjection,
|
|
24
24
|
wgs84Projection,
|
|
@@ -159,7 +159,7 @@ export function createClippingPlaneCollection(
|
|
|
159
159
|
): ClippingPlaneCollection | null {
|
|
160
160
|
check(feature, Feature);
|
|
161
161
|
check(options, Object);
|
|
162
|
-
|
|
162
|
+
check(transformMatrix, optional(Matrix4));
|
|
163
163
|
|
|
164
164
|
const clippingPlanes = [];
|
|
165
165
|
const geometry = feature.getGeometry() as Geometry;
|
|
@@ -457,7 +457,7 @@ export function getClippingOptions(
|
|
|
457
457
|
feature?: Feature,
|
|
458
458
|
infinite = false,
|
|
459
459
|
): ClippingPlaneCreationOptions {
|
|
460
|
-
|
|
460
|
+
check(feature, maybe(Feature));
|
|
461
461
|
check(infinite, Boolean);
|
|
462
462
|
|
|
463
463
|
const vertical = feature
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { check } from '@vcsuite/check';
|
|
1
|
+
import { check, ofEnum } from '@vcsuite/check';
|
|
2
2
|
import { Feature } from 'ol';
|
|
3
3
|
import type { Geometry } from 'ol/geom.js';
|
|
4
4
|
import VcsEvent from '../../vcsEvent.js';
|
|
@@ -21,12 +21,13 @@ import geometryIsValid from './validateGeoemetry.js';
|
|
|
21
21
|
import ObliqueMap from '../../map/obliqueMap.js';
|
|
22
22
|
import { cursorMap } from './interactions/editGeometryMouseOverInteraction.js';
|
|
23
23
|
|
|
24
|
-
export type CreateFeatureSession<T extends GeometryType> =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
export type CreateFeatureSession<T extends GeometryType> =
|
|
25
|
+
EditorSession<SessionType.CREATE> & {
|
|
26
|
+
geometryType: T;
|
|
27
|
+
featureCreated: VcsEvent<Feature<GeometryToType<T>>>;
|
|
28
|
+
creationFinished: VcsEvent<Feature<GeometryToType<T>> | null>;
|
|
29
|
+
finish(): void;
|
|
30
|
+
};
|
|
30
31
|
|
|
31
32
|
type InteractionOfGeometryType<T extends GeometryType> =
|
|
32
33
|
T extends GeometryType.Point
|
|
@@ -94,7 +95,7 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
94
95
|
): CreateFeatureSession<T> {
|
|
95
96
|
check(app, VcsApp);
|
|
96
97
|
check(layer, VectorLayer);
|
|
97
|
-
check(geometryType,
|
|
98
|
+
check(geometryType, ofEnum(GeometryType));
|
|
98
99
|
|
|
99
100
|
const {
|
|
100
101
|
interactionChain,
|
|
@@ -77,7 +77,7 @@ function clearAllowPicking(
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
export type EditFeaturesSession = EditorSession & {
|
|
80
|
+
export type EditFeaturesSession = EditorSession<SessionType.EDIT_FEATURES> & {
|
|
81
81
|
readonly mode: TransformationMode;
|
|
82
82
|
/**
|
|
83
83
|
* Function for rotating features. Takes angle in radians as parameter.
|
|
@@ -31,7 +31,7 @@ import MapInteractionController from './interactions/mapInteractionController.js
|
|
|
31
31
|
import type VectorLayer from '../../layer/vectorLayer.js';
|
|
32
32
|
import type VcsApp from '../../vcsApp.js';
|
|
33
33
|
|
|
34
|
-
export type EditGeometrySession = EditorSession & {
|
|
34
|
+
export type EditGeometrySession = EditorSession<SessionType.EDIT_GEOMETRY> & {
|
|
35
35
|
setFeature(feature: Feature): void;
|
|
36
36
|
feature: Feature | null;
|
|
37
37
|
};
|
|
@@ -22,8 +22,8 @@ export enum SessionType {
|
|
|
22
22
|
* event handler.
|
|
23
23
|
* A stopped session will be destroyed and can no longer be used.
|
|
24
24
|
*/
|
|
25
|
-
export type EditorSession = {
|
|
26
|
-
type:
|
|
25
|
+
export type EditorSession<T extends SessionType = SessionType> = {
|
|
26
|
+
type: T;
|
|
27
27
|
stop(): void;
|
|
28
28
|
stopped: VcsEvent<void>;
|
|
29
29
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { check } from '@vcsuite/check';
|
|
1
|
+
import { check, ofEnum } from '@vcsuite/check';
|
|
2
2
|
import { Circle, Fill, Style, Stroke } from 'ol/style.js';
|
|
3
3
|
import type { Feature } from 'ol/index.js';
|
|
4
4
|
import { createSync } from '../../layer/vectorSymbols.js';
|
|
@@ -117,7 +117,7 @@ export function getDefaultHighlightStyle(): Style {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
type SelectFeaturesSession = EditorSession & {
|
|
120
|
+
export type SelectFeaturesSession = EditorSession<SessionType.SELECT> & {
|
|
121
121
|
currentFeatures: Feature[];
|
|
122
122
|
firstFeature: Feature | null;
|
|
123
123
|
featuresChanged: VcsEvent<Feature[]>;
|
|
@@ -298,7 +298,7 @@ function startSelectFeaturesSession(
|
|
|
298
298
|
return currentSelectionMode;
|
|
299
299
|
},
|
|
300
300
|
setMode(newMode: SelectionMode): void {
|
|
301
|
-
check(newMode,
|
|
301
|
+
check(newMode, ofEnum(SelectionMode));
|
|
302
302
|
|
|
303
303
|
createSelectInteraction(newMode);
|
|
304
304
|
modeChanged.raiseEvent(currentSelectionMode);
|
|
@@ -33,10 +33,14 @@ export function getGeometryOptions(
|
|
|
33
33
|
coords: Coordinate[],
|
|
34
34
|
_geometry: LineString,
|
|
35
35
|
positionHeightAdjustment: number,
|
|
36
|
+
perPositionHeight: boolean,
|
|
37
|
+
groundLevelOrMinHeight: number,
|
|
36
38
|
): { positions: Cartesian3[]; arcType: ArcType } {
|
|
37
39
|
const positions = coords.map((coord) => {
|
|
38
40
|
const wgs84Coords = Projection.mercatorToWgs84(coord);
|
|
39
|
-
if (
|
|
41
|
+
if (!perPositionHeight && groundLevelOrMinHeight) {
|
|
42
|
+
wgs84Coords[2] = groundLevelOrMinHeight;
|
|
43
|
+
} else if (wgs84Coords[2] != null) {
|
|
40
44
|
wgs84Coords[2] += positionHeightAdjustment;
|
|
41
45
|
}
|
|
42
46
|
return Cartesian3.fromDegrees(
|
|
@@ -105,19 +105,25 @@ export function createLineGeometries(
|
|
|
105
105
|
* extracts the center and radius from the CircleGeometry and converts it to Cartesian3/radius in m
|
|
106
106
|
* @param geometry
|
|
107
107
|
* @param positionHeightAdjustment
|
|
108
|
-
* @
|
|
108
|
+
* @param perPositionHeight
|
|
109
|
+
* @param groundLevelOrMinHeight
|
|
110
|
+
* @returns
|
|
109
111
|
* @private
|
|
110
112
|
*/
|
|
111
113
|
export function getGeometryOptions(
|
|
112
114
|
geometry: Circle,
|
|
113
115
|
positionHeightAdjustment: number,
|
|
116
|
+
perPositionHeight: boolean,
|
|
117
|
+
groundLevelOrMinHeight: number,
|
|
114
118
|
): ConstructorParameters<typeof CircleGeometry>[0] {
|
|
115
119
|
// olCoordinates of center and radius in WGS84
|
|
116
120
|
const olCenter = geometry.getCenter();
|
|
117
121
|
const olPoint = olCenter.slice();
|
|
118
122
|
olPoint[0] += geometry.getRadius();
|
|
119
123
|
const wgs84Center = Projection.mercatorToWgs84(olCenter, true);
|
|
120
|
-
if (
|
|
124
|
+
if (!perPositionHeight && groundLevelOrMinHeight) {
|
|
125
|
+
wgs84Center[2] = groundLevelOrMinHeight;
|
|
126
|
+
} else if (wgs84Center[2] != null) {
|
|
121
127
|
wgs84Center[2] += positionHeightAdjustment;
|
|
122
128
|
}
|
|
123
129
|
|
|
@@ -13,7 +13,7 @@ class Extent3D {
|
|
|
13
13
|
static fromArray(
|
|
14
14
|
array: [number, number, number, number, number, number],
|
|
15
15
|
): Extent3D {
|
|
16
|
-
check(array, [Number]);
|
|
16
|
+
check(array as [number, number, number, number, number, number], [Number]);
|
|
17
17
|
check(array.length, 6);
|
|
18
18
|
return new Extent3D(
|
|
19
19
|
array[0],
|
|
@@ -520,6 +520,8 @@ export function addPrimitivesToContext(
|
|
|
520
520
|
const geometryOptions = geometryFactory.getGeometryOptions(
|
|
521
521
|
geometry,
|
|
522
522
|
heightInfo.heightAboveGroundAdjustment,
|
|
523
|
+
heightInfo.perPositionHeight,
|
|
524
|
+
heightInfo.groundLevel,
|
|
523
525
|
);
|
|
524
526
|
const storeyOptions = getStoreyOptions(
|
|
525
527
|
heightInfo.storeyHeightsAboveGround,
|
|
@@ -609,11 +611,7 @@ export function addPrimitivesToContext(
|
|
|
609
611
|
);
|
|
610
612
|
} else {
|
|
611
613
|
lineGeometries.push(
|
|
612
|
-
...geometryFactory.createLineGeometries(
|
|
613
|
-
geometryOptions,
|
|
614
|
-
style,
|
|
615
|
-
heightInfo.groundLevel,
|
|
616
|
-
),
|
|
614
|
+
...geometryFactory.createLineGeometries(geometryOptions, style),
|
|
617
615
|
);
|
|
618
616
|
}
|
|
619
617
|
}
|
|
@@ -185,6 +185,7 @@ export function createLineGeometries(
|
|
|
185
185
|
style: Style,
|
|
186
186
|
): PolylineGeometry[] {
|
|
187
187
|
const width = parseNumber(style.getStroke().getWidth(), 1.0);
|
|
188
|
+
|
|
188
189
|
return [
|
|
189
190
|
new PolylineGeometry({
|
|
190
191
|
...options,
|
|
@@ -197,16 +198,22 @@ export function createLineGeometries(
|
|
|
197
198
|
* Creates the positions array for PolylineGeometry
|
|
198
199
|
* @param geometry
|
|
199
200
|
* @param positionHeightAdjustment
|
|
201
|
+
* @param perPositionHeight
|
|
202
|
+
* @param groundLevelOrMinHeight
|
|
200
203
|
* @private
|
|
201
204
|
*/
|
|
202
205
|
export function getGeometryOptions(
|
|
203
206
|
geometry: LineString,
|
|
204
207
|
positionHeightAdjustment: number,
|
|
208
|
+
perPositionHeight: boolean,
|
|
209
|
+
groundLevelOrMinHeight: number,
|
|
205
210
|
): LineGeometryOptions {
|
|
206
211
|
const coords = geometry.getCoordinates();
|
|
207
212
|
const positions = coords.map((coord) => {
|
|
208
213
|
const wgs84Coords = Projection.mercatorToWgs84(coord);
|
|
209
|
-
if (
|
|
214
|
+
if (!perPositionHeight && groundLevelOrMinHeight) {
|
|
215
|
+
wgs84Coords[2] = groundLevelOrMinHeight;
|
|
216
|
+
} else if (wgs84Coords[2] != null) {
|
|
210
217
|
wgs84Coords[2] += positionHeightAdjustment;
|
|
211
218
|
}
|
|
212
219
|
return Cartesian3.fromDegrees(
|
|
@@ -228,7 +228,7 @@ export function getCartesian3AndWGS84FromCoordinates(
|
|
|
228
228
|
wgs84Positions[index] = Projection.mercatorToWgs84(coord, true);
|
|
229
229
|
let height = null;
|
|
230
230
|
if (heightInfo.heightReference === HeightReference.RELATIVE_TO_GROUND) {
|
|
231
|
-
height = heightInfo.heightAboveGroundAdjustment;
|
|
231
|
+
height = heightValue + heightInfo.heightAboveGroundAdjustment;
|
|
232
232
|
} else {
|
|
233
233
|
height = heightValue;
|
|
234
234
|
}
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
PolygonHierarchy,
|
|
8
8
|
PolylineGeometry,
|
|
9
9
|
type Scene,
|
|
10
|
-
Cartographic,
|
|
11
10
|
} from '@vcmap-cesium/engine';
|
|
12
11
|
import type { Style } from 'ol/style.js';
|
|
13
12
|
import type { Polygon } from 'ol/geom.js';
|
|
@@ -74,7 +73,6 @@ export function createFillGeometries(
|
|
|
74
73
|
export function getLineGeometryOptions(
|
|
75
74
|
options: PolygonGeometryOptions,
|
|
76
75
|
style: Style,
|
|
77
|
-
groundLevel?: number,
|
|
78
76
|
): PolylineGeometryOptions[] {
|
|
79
77
|
const width = parseNumber(style.getStroke().getWidth(), 1.0);
|
|
80
78
|
const geometryOptions: PolylineGeometryOptions[] = [];
|
|
@@ -90,16 +88,6 @@ export function getLineGeometryOptions(
|
|
|
90
88
|
width,
|
|
91
89
|
});
|
|
92
90
|
});
|
|
93
|
-
|
|
94
|
-
if (groundLevel) {
|
|
95
|
-
geometryOptions.forEach((polylineOptions) => {
|
|
96
|
-
polylineOptions.positions = polylineOptions.positions.map((c) => {
|
|
97
|
-
const geographic = Cartographic.fromCartesian(c);
|
|
98
|
-
geographic.height = groundLevel;
|
|
99
|
-
return Cartographic.toCartesian(geographic);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
91
|
return geometryOptions;
|
|
104
92
|
}
|
|
105
93
|
|
|
@@ -114,9 +102,8 @@ export function createGroundLineGeometries(
|
|
|
114
102
|
export function createLineGeometries(
|
|
115
103
|
options: PolygonGeometryOptions,
|
|
116
104
|
style: Style,
|
|
117
|
-
groundLevel?: number,
|
|
118
105
|
): PolylineGeometry[] {
|
|
119
|
-
return getLineGeometryOptions(options, style
|
|
106
|
+
return getLineGeometryOptions(options, style).map((option) => {
|
|
120
107
|
return new PolylineGeometry(option);
|
|
121
108
|
});
|
|
122
109
|
}
|
|
@@ -124,6 +111,8 @@ export function createLineGeometries(
|
|
|
124
111
|
export function getGeometryOptions(
|
|
125
112
|
geometry: Polygon,
|
|
126
113
|
positionHeightAdjustment: number,
|
|
114
|
+
perPositionHeight: boolean,
|
|
115
|
+
groundLevelOrMinHeight: number,
|
|
127
116
|
): PolygonGeometryOptions {
|
|
128
117
|
let hieraryPositions;
|
|
129
118
|
const holes = [];
|
|
@@ -132,7 +121,9 @@ export function getGeometryOptions(
|
|
|
132
121
|
const coords = rings[i].getCoordinates();
|
|
133
122
|
const positions = coords.map((coord) => {
|
|
134
123
|
const wgs84Coords = Projection.mercatorToWgs84(coord);
|
|
135
|
-
if (
|
|
124
|
+
if (!perPositionHeight && groundLevelOrMinHeight) {
|
|
125
|
+
wgs84Coords[2] = groundLevelOrMinHeight;
|
|
126
|
+
} else if (wgs84Coords[2] != null) {
|
|
136
127
|
wgs84Coords[2] += positionHeightAdjustment;
|
|
137
128
|
}
|
|
138
129
|
return Cartesian3.fromDegrees(
|
package/src/util/fetch.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TrustedServers } from '@vcmap-cesium/engine';
|
|
2
|
+
|
|
1
3
|
export async function requestUrl(
|
|
2
4
|
url: string,
|
|
3
5
|
init?: RequestInit,
|
|
@@ -26,3 +28,26 @@ export async function requestArrayBuffer(
|
|
|
26
28
|
const response = await requestUrl(url, init);
|
|
27
29
|
return response.arrayBuffer();
|
|
28
30
|
}
|
|
31
|
+
|
|
32
|
+
export async function requestObjectUrl(
|
|
33
|
+
url: string,
|
|
34
|
+
init?: RequestInit,
|
|
35
|
+
): Promise<string> {
|
|
36
|
+
const response = await requestUrl(url, init);
|
|
37
|
+
const blob = await response.blob();
|
|
38
|
+
return URL.createObjectURL(blob);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getInitForUrl(
|
|
42
|
+
url: string,
|
|
43
|
+
headers?: Record<string, string>,
|
|
44
|
+
): RequestInit {
|
|
45
|
+
const init: RequestInit = {};
|
|
46
|
+
if (headers) {
|
|
47
|
+
init.headers = headers;
|
|
48
|
+
}
|
|
49
|
+
if (TrustedServers.contains(url)) {
|
|
50
|
+
init.credentials = 'include';
|
|
51
|
+
}
|
|
52
|
+
return init;
|
|
53
|
+
}
|