@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
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { unByKey } from 'ol/Observable.js';
|
|
2
2
|
import Feature from 'ol/Feature.js';
|
|
3
3
|
import { EventsKey } from 'ol/events.js';
|
|
4
|
-
import { GeoJSONFeature } from 'ol/format/GeoJSON.js';
|
|
5
4
|
import type { VectorSourceEvent } from 'ol/source/Vector.js';
|
|
6
|
-
|
|
5
|
+
import type {
|
|
6
|
+
Feature as GeojsonFeature,
|
|
7
|
+
LineString,
|
|
8
|
+
MultiLineString,
|
|
9
|
+
MultiPoint,
|
|
10
|
+
MultiPolygon,
|
|
11
|
+
Point,
|
|
12
|
+
Polygon,
|
|
13
|
+
} from 'geojson';
|
|
7
14
|
import { check } from '@vcsuite/check';
|
|
8
|
-
import {
|
|
9
|
-
FeatureStoreLayerState,
|
|
10
|
-
featureStoreStateSymbol,
|
|
11
|
-
} from './featureStoreLayerState.js';
|
|
15
|
+
import { featureStoreStateSymbol } from './featureStoreLayerState.js';
|
|
12
16
|
import { parseGeoJSON, writeGeoJSONFeature } from './geojsonHelpers.js';
|
|
13
17
|
import VcsObject from '../vcsObject.js';
|
|
14
|
-
import { requestJson } from '../util/fetch.js';
|
|
15
18
|
|
|
16
19
|
import type FeatureStoreLayer from './featureStoreLayer.js';
|
|
20
|
+
import VcsEvent from '../vcsEvent.js';
|
|
17
21
|
|
|
18
22
|
export type FeatureStoreTrackResults = {
|
|
19
23
|
add: Feature[];
|
|
@@ -27,13 +31,25 @@ export type FeatureStoreChangesListeners = {
|
|
|
27
31
|
removefeature: EventsKey | EventsKey[] | null;
|
|
28
32
|
};
|
|
29
33
|
|
|
30
|
-
export type
|
|
31
|
-
|
|
34
|
+
export type FeatureStoreGeojsonGeometry =
|
|
35
|
+
| Point
|
|
36
|
+
| MultiPoint
|
|
37
|
+
| LineString
|
|
38
|
+
| MultiLineString
|
|
39
|
+
| Polygon
|
|
40
|
+
| MultiPolygon;
|
|
41
|
+
|
|
42
|
+
export type FeatureStoreGeojsonFeature<
|
|
43
|
+
G extends FeatureStoreGeojsonGeometry = FeatureStoreGeojsonGeometry,
|
|
44
|
+
P extends Record<string, unknown> = Record<string, unknown>,
|
|
45
|
+
> = Omit<GeojsonFeature<G, P>, 'id'> & {
|
|
46
|
+
_id?: string;
|
|
47
|
+
id?: string;
|
|
32
48
|
};
|
|
33
49
|
|
|
34
50
|
type CommitAction = {
|
|
35
|
-
action:
|
|
36
|
-
feature:
|
|
51
|
+
action: 'add' | 'edit' | 'remove';
|
|
52
|
+
feature: FeatureStoreGeojsonFeature | { _id: string };
|
|
37
53
|
original: Feature;
|
|
38
54
|
success(opt?: string): void;
|
|
39
55
|
};
|
|
@@ -45,28 +61,32 @@ export function createCommitActions(
|
|
|
45
61
|
): CommitAction[] {
|
|
46
62
|
const actions: CommitAction[] = [];
|
|
47
63
|
added.forEach((f) => {
|
|
48
|
-
const feature = writeGeoJSONFeature(f, {
|
|
64
|
+
const feature = writeGeoJSONFeature(f, {
|
|
65
|
+
writeStyle: true,
|
|
66
|
+
}) as FeatureStoreGeojsonFeature;
|
|
49
67
|
actions.push({
|
|
50
68
|
action: 'add',
|
|
51
69
|
feature,
|
|
52
70
|
original: f,
|
|
53
71
|
success(data) {
|
|
54
72
|
f.setId(data);
|
|
55
|
-
f[featureStoreStateSymbol] =
|
|
73
|
+
f[featureStoreStateSymbol] = 'dynamic';
|
|
56
74
|
},
|
|
57
75
|
});
|
|
58
76
|
});
|
|
59
77
|
|
|
60
78
|
edited.forEach((f) => {
|
|
61
|
-
const feature = writeGeoJSONFeature(f, {
|
|
62
|
-
|
|
79
|
+
const feature = writeGeoJSONFeature(f, {
|
|
80
|
+
writeStyle: true,
|
|
81
|
+
}) as FeatureStoreGeojsonFeature;
|
|
82
|
+
feature._id = f.getId() as string;
|
|
63
83
|
actions.push({
|
|
64
84
|
action: 'edit',
|
|
65
85
|
original: f,
|
|
66
86
|
feature,
|
|
67
87
|
success() {
|
|
68
|
-
if (f[featureStoreStateSymbol] ===
|
|
69
|
-
f[featureStoreStateSymbol] =
|
|
88
|
+
if (f[featureStoreStateSymbol] === 'static') {
|
|
89
|
+
f[featureStoreStateSymbol] = 'edited';
|
|
70
90
|
}
|
|
71
91
|
},
|
|
72
92
|
});
|
|
@@ -76,7 +96,7 @@ export function createCommitActions(
|
|
|
76
96
|
actions.push({
|
|
77
97
|
original: f,
|
|
78
98
|
action: 'remove',
|
|
79
|
-
feature: { _id: f.getId() },
|
|
99
|
+
feature: { _id: f.getId() as string },
|
|
80
100
|
success() {},
|
|
81
101
|
});
|
|
82
102
|
});
|
|
@@ -108,9 +128,7 @@ class FeatureStoreLayerChanges extends VcsObject {
|
|
|
108
128
|
|
|
109
129
|
private _convertedFeatures: Set<Feature> = new Set();
|
|
110
130
|
|
|
111
|
-
|
|
112
|
-
changed: false,
|
|
113
|
-
};
|
|
131
|
+
changed = new VcsEvent<void>();
|
|
114
132
|
|
|
115
133
|
constructor(layer: FeatureStoreLayer) {
|
|
116
134
|
super({});
|
|
@@ -166,12 +184,24 @@ class FeatureStoreLayerChanges extends VcsObject {
|
|
|
166
184
|
};
|
|
167
185
|
}
|
|
168
186
|
|
|
187
|
+
hasChanges(): boolean {
|
|
188
|
+
return (
|
|
189
|
+
this._addedFeatures.size !== 0 ||
|
|
190
|
+
this._editedFeatures.size !== 0 ||
|
|
191
|
+
this._removedFeatures.size !== 0
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
169
195
|
/**
|
|
170
196
|
* commits the changes to the provided url. url should contain accessTokens and point to a featureStore layers bulk operation endpoint
|
|
171
197
|
*/
|
|
172
198
|
async commitChanges(
|
|
173
|
-
|
|
174
|
-
|
|
199
|
+
postCallback: (
|
|
200
|
+
body: Pick<CommitAction, 'action' | 'feature'>[],
|
|
201
|
+
) => Promise<{
|
|
202
|
+
failedActions: { index: number; error: string }[];
|
|
203
|
+
insertedIds: { _id: string }[];
|
|
204
|
+
}>,
|
|
175
205
|
): Promise<void> {
|
|
176
206
|
const actions: (CommitAction | null)[] = createCommitActions(
|
|
177
207
|
this._addedFeatures,
|
|
@@ -179,19 +209,9 @@ class FeatureStoreLayerChanges extends VcsObject {
|
|
|
179
209
|
this._removedFeatures,
|
|
180
210
|
);
|
|
181
211
|
if (actions.length > 0) {
|
|
182
|
-
const data = await
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}>(url.toString(), {
|
|
186
|
-
method: 'POST',
|
|
187
|
-
headers: {
|
|
188
|
-
...headers,
|
|
189
|
-
'Content-Type': 'application/json',
|
|
190
|
-
},
|
|
191
|
-
body: JSON.stringify(
|
|
192
|
-
actions.map((a) => ({ action: a!.action, feature: a!.feature })),
|
|
193
|
-
),
|
|
194
|
-
});
|
|
212
|
+
const data = await postCallback(
|
|
213
|
+
actions.map((a) => ({ action: a!.action, feature: a!.feature })),
|
|
214
|
+
);
|
|
195
215
|
|
|
196
216
|
const failures = data.failedActions.map(({ index, error }) => {
|
|
197
217
|
const action = actions[index] as CommitAction;
|
|
@@ -259,7 +279,7 @@ class FeatureStoreLayerChanges extends VcsObject {
|
|
|
259
279
|
return Promise.resolve();
|
|
260
280
|
}
|
|
261
281
|
|
|
262
|
-
if (feature[featureStoreStateSymbol] ===
|
|
282
|
+
if (feature[featureStoreStateSymbol] === 'static') {
|
|
263
283
|
this.layer.resetStaticFeature(featureId);
|
|
264
284
|
return Promise.resolve();
|
|
265
285
|
}
|
|
@@ -284,7 +304,6 @@ class FeatureStoreLayerChanges extends VcsObject {
|
|
|
284
304
|
this._editedFeatures.clear();
|
|
285
305
|
this._removedFeatures.clear();
|
|
286
306
|
this._convertedFeatures.clear();
|
|
287
|
-
this.values.changed = false;
|
|
288
307
|
}
|
|
289
308
|
|
|
290
309
|
/**
|
|
@@ -316,12 +335,10 @@ class FeatureStoreLayerChanges extends VcsObject {
|
|
|
316
335
|
if (feature) {
|
|
317
336
|
if (!feature[featureStoreStateSymbol]) {
|
|
318
337
|
this._addedFeatures.add(feature);
|
|
319
|
-
this.
|
|
320
|
-
} else if (
|
|
321
|
-
feature[featureStoreStateSymbol] === FeatureStoreLayerState.STATIC
|
|
322
|
-
) {
|
|
338
|
+
this.changed.raiseEvent();
|
|
339
|
+
} else if (feature[featureStoreStateSymbol] === 'static') {
|
|
323
340
|
this._convertedFeatures.add(feature);
|
|
324
|
-
this.
|
|
341
|
+
this.changed.raiseEvent();
|
|
325
342
|
}
|
|
326
343
|
}
|
|
327
344
|
}
|
|
@@ -334,7 +351,7 @@ class FeatureStoreLayerChanges extends VcsObject {
|
|
|
334
351
|
if (feature[featureStoreStateSymbol]) {
|
|
335
352
|
this._convertedFeatures.delete(feature);
|
|
336
353
|
this._editedFeatures.add(feature);
|
|
337
|
-
this.
|
|
354
|
+
this.changed.raiseEvent();
|
|
338
355
|
}
|
|
339
356
|
}
|
|
340
357
|
}
|
|
@@ -348,7 +365,7 @@ class FeatureStoreLayerChanges extends VcsObject {
|
|
|
348
365
|
this._removedFeatures.add(feature);
|
|
349
366
|
this._editedFeatures.delete(feature);
|
|
350
367
|
this._convertedFeatures.delete(feature);
|
|
351
|
-
this.
|
|
368
|
+
this.changed.raiseEvent();
|
|
352
369
|
} else {
|
|
353
370
|
this._addedFeatures.delete(feature);
|
|
354
371
|
}
|
|
@@ -385,6 +402,7 @@ class FeatureStoreLayerChanges extends VcsObject {
|
|
|
385
402
|
destroy(): void {
|
|
386
403
|
this.unTrack();
|
|
387
404
|
this._layer = undefined;
|
|
405
|
+
this.changed.destroy();
|
|
388
406
|
super.destroy();
|
|
389
407
|
}
|
|
390
408
|
}
|
|
@@ -3,8 +3,9 @@ export const featureStoreStateSymbol = Symbol('vcsFeatureType');
|
|
|
3
3
|
/**
|
|
4
4
|
* Enumeration of feature store item states
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export type FeatureStoreLayerState =
|
|
7
|
+
| 'dynamic'
|
|
8
|
+
| 'static'
|
|
9
|
+
| 'edited'
|
|
10
|
+
| 'deleted'
|
|
11
|
+
| 'removed';
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { GeoJSONFeature } from 'ol/format/GeoJSON.js';
|
|
2
2
|
import { FeatureCollection } from 'geojson';
|
|
3
|
-
|
|
4
3
|
import VectorLayer, { VectorOptions } from './vectorLayer.js';
|
|
5
4
|
import { parseGeoJSON, writeGeoJSONFeature } from './geojsonHelpers.js';
|
|
6
5
|
import Projection, { wgs84Projection } from '../util/projection.js';
|
|
7
6
|
import { layerClassRegistry } from '../classRegistry.js';
|
|
8
|
-
import { requestJson } from '../util/fetch.js';
|
|
7
|
+
import { getInitForUrl, requestJson } from '../util/fetch.js';
|
|
9
8
|
|
|
10
9
|
export type GeoJSONOptions = VectorOptions & {
|
|
11
10
|
features?: GeoJSONFeature[];
|
|
@@ -86,7 +85,8 @@ class GeoJSONLayer extends VectorLayer {
|
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
if (this.url) {
|
|
89
|
-
|
|
88
|
+
const init = getInitForUrl(this.url, this.headers);
|
|
89
|
+
this._dataFetchedPromise = requestJson(this.url, init)
|
|
90
90
|
.then((data) => this._parseGeojsonData(data as FeatureCollection))
|
|
91
91
|
.catch((err) => {
|
|
92
92
|
this.getLogger().warning(
|
package/src/layer/layer.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import deepEqual from 'fast-deep-equal';
|
|
2
|
+
import { check, maybe, oneOf, optional, recordOf } from '@vcsuite/check';
|
|
2
3
|
import { parseBoolean, parseInteger } from '@vcsuite/parsers';
|
|
3
4
|
import VcsObject, { VcsObjectOptions } from '../vcsObject.js';
|
|
4
5
|
import Extent, { type ExtentOptions } from '../util/extent.js';
|
|
@@ -50,11 +51,17 @@ export type LayerOptions = VcsObjectOptions & {
|
|
|
50
51
|
* to other sources of data.
|
|
51
52
|
*/
|
|
52
53
|
datasourceId?: string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Optional Request Headers which will be sent with each request.
|
|
57
|
+
*/
|
|
58
|
+
headers?: Record<string, string>;
|
|
53
59
|
};
|
|
54
60
|
|
|
55
61
|
export type LayerImplementationOptions = {
|
|
56
62
|
name: string;
|
|
57
63
|
url: string;
|
|
64
|
+
headers?: Record<string, string>;
|
|
58
65
|
};
|
|
59
66
|
|
|
60
67
|
/**
|
|
@@ -82,6 +89,7 @@ class Layer<
|
|
|
82
89
|
hiddenObjectIds: [],
|
|
83
90
|
copyright: undefined,
|
|
84
91
|
datasourceId: undefined,
|
|
92
|
+
headers: undefined,
|
|
85
93
|
};
|
|
86
94
|
}
|
|
87
95
|
|
|
@@ -145,6 +153,8 @@ class Layer<
|
|
|
145
153
|
|
|
146
154
|
private _locale: string;
|
|
147
155
|
|
|
156
|
+
protected _headers?: Record<string, string>;
|
|
157
|
+
|
|
148
158
|
/**
|
|
149
159
|
* Optional Id to synchronize with the vcPublisher Datasources. This can also be used to track a connection
|
|
150
160
|
* to other sources of data.
|
|
@@ -208,6 +218,8 @@ class Layer<
|
|
|
208
218
|
this._locale = 'en';
|
|
209
219
|
|
|
210
220
|
this.datasourceId = options.datasourceId || defaultOptions.datasourceId;
|
|
221
|
+
|
|
222
|
+
this._headers = structuredClone(options.headers);
|
|
211
223
|
}
|
|
212
224
|
|
|
213
225
|
/**
|
|
@@ -254,7 +266,7 @@ class Layer<
|
|
|
254
266
|
}
|
|
255
267
|
|
|
256
268
|
set url(url: string | Record<string, string>) {
|
|
257
|
-
check(url,
|
|
269
|
+
check(url, oneOf(String, recordOf(String)));
|
|
258
270
|
|
|
259
271
|
if (this._url !== url) {
|
|
260
272
|
const currentValue = this._url;
|
|
@@ -285,7 +297,7 @@ class Layer<
|
|
|
285
297
|
}
|
|
286
298
|
|
|
287
299
|
setGlobalHider(globalHider?: GlobalHider): void {
|
|
288
|
-
|
|
300
|
+
check(globalHider, maybe(GlobalHider));
|
|
289
301
|
|
|
290
302
|
if (globalHider && this.active) {
|
|
291
303
|
globalHider.hideObjects(this.hiddenObjectIds);
|
|
@@ -308,7 +320,7 @@ class Layer<
|
|
|
308
320
|
}
|
|
309
321
|
|
|
310
322
|
set exclusiveGroups(groups: (string | symbol)[]) {
|
|
311
|
-
check(groups, [
|
|
323
|
+
check(groups, [oneOf(String, Symbol)]);
|
|
312
324
|
|
|
313
325
|
if (
|
|
314
326
|
groups.length !== this._exclusiveGroups.length ||
|
|
@@ -332,6 +344,26 @@ class Layer<
|
|
|
332
344
|
}
|
|
333
345
|
}
|
|
334
346
|
|
|
347
|
+
/**
|
|
348
|
+
* directly manipulating the headers Object will not trigger a reload. Reload the data via layer.reload() manually.
|
|
349
|
+
*/
|
|
350
|
+
get headers(): Record<string, string> | undefined {
|
|
351
|
+
return this._headers;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
*
|
|
356
|
+
* @param headers
|
|
357
|
+
*/
|
|
358
|
+
set headers(headers: Record<string, string> | undefined) {
|
|
359
|
+
check(headers, optional(recordOf(String)));
|
|
360
|
+
if (!deepEqual(this._headers, headers)) {
|
|
361
|
+
this._headers = structuredClone(headers);
|
|
362
|
+
// eslint-disable-next-line no-void
|
|
363
|
+
void this.reload();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
335
367
|
/**
|
|
336
368
|
* returns the currently set locale. Can be used to provide locale specific URLs.
|
|
337
369
|
*/
|
|
@@ -397,6 +429,7 @@ class Layer<
|
|
|
397
429
|
return {
|
|
398
430
|
name: this.name,
|
|
399
431
|
url: this.url,
|
|
432
|
+
headers: this.headers,
|
|
400
433
|
};
|
|
401
434
|
}
|
|
402
435
|
|
|
@@ -652,6 +685,10 @@ class Layer<
|
|
|
652
685
|
config.datasourceId = this.datasourceId;
|
|
653
686
|
}
|
|
654
687
|
|
|
688
|
+
if (!deepEqual(this._headers, defaultOptions.headers)) {
|
|
689
|
+
config.headers = structuredClone(this._headers);
|
|
690
|
+
}
|
|
691
|
+
|
|
655
692
|
return config;
|
|
656
693
|
}
|
|
657
694
|
|
|
@@ -19,10 +19,13 @@ class LayerImplementation<M extends VcsMap> extends VcsObject {
|
|
|
19
19
|
|
|
20
20
|
private _initialized = false;
|
|
21
21
|
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
|
|
22
24
|
constructor(map: M, options: LayerImplementationOptions) {
|
|
23
25
|
super(options);
|
|
24
26
|
this._map = map;
|
|
25
27
|
this.url = options.url;
|
|
28
|
+
this.headers = options.headers;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
get map(): M {
|
|
@@ -182,7 +182,7 @@ class VectorObliqueImpl
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
private addFeature(originalFeature: Feature): Promise<void> {
|
|
185
|
+
private async addFeature(originalFeature: Feature): Promise<void> {
|
|
186
186
|
if (!this.active) {
|
|
187
187
|
this.fetchedFeaturesForImageName = null;
|
|
188
188
|
}
|
|
@@ -196,7 +196,7 @@ class VectorObliqueImpl
|
|
|
196
196
|
return Promise.resolve();
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
if (this.obliqueSource.getFeatureById(id)) {
|
|
199
|
+
if (this.obliqueSource.getFeatureById(id) || this._updatingOblique[id]) {
|
|
200
200
|
return Promise.resolve();
|
|
201
201
|
}
|
|
202
202
|
const obliqueFeature = new Feature({});
|
|
@@ -207,11 +207,8 @@ class VectorObliqueImpl
|
|
|
207
207
|
|
|
208
208
|
this._setFeatureListeners(originalFeature, obliqueFeature);
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
this.obliqueSource.addFeature(obliqueFeature);
|
|
213
|
-
},
|
|
214
|
-
);
|
|
210
|
+
await this._convertToOblique(originalFeature, obliqueFeature);
|
|
211
|
+
this.obliqueSource.addFeature(obliqueFeature);
|
|
215
212
|
}
|
|
216
213
|
return Promise.resolve();
|
|
217
214
|
}
|
|
@@ -308,8 +305,9 @@ class VectorObliqueImpl
|
|
|
308
305
|
const vectorGeometry = originalFeature.getGeometry() as Geometry;
|
|
309
306
|
const imageGeometry = obliqueFeature.getGeometry() as Geometry;
|
|
310
307
|
this._updatingOblique[id] = true;
|
|
308
|
+
let promise: Promise<unknown>;
|
|
311
309
|
if (!vectorGeometry[alreadyTransformedToImage]) {
|
|
312
|
-
|
|
310
|
+
promise = mercatorGeometryToImageGeometry(
|
|
313
311
|
vectorGeometry,
|
|
314
312
|
imageGeometry,
|
|
315
313
|
this.map.currentImage as ObliqueImage,
|
|
@@ -318,7 +316,10 @@ class VectorObliqueImpl
|
|
|
318
316
|
obliqueFeature
|
|
319
317
|
.getGeometry()!
|
|
320
318
|
.setCoordinates(vectorGeometry.getCoordinates());
|
|
319
|
+
// we MUST wait for a promise, otherwise this is sync and you can add a feature twice
|
|
320
|
+
promise = Promise.resolve();
|
|
321
321
|
}
|
|
322
|
+
await promise;
|
|
322
323
|
this._updatingOblique[id] = null;
|
|
323
324
|
}
|
|
324
325
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LoadFunction } from 'ol/Tile.js';
|
|
2
|
+
import type { ImageTile } from 'ol';
|
|
3
|
+
import TileState from 'ol/TileState.js';
|
|
4
|
+
import { getInitForUrl, requestObjectUrl } from '../../util/fetch.js';
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
7
|
+
export function getTileLoadFunction(
|
|
8
|
+
headers: Record<string, string>,
|
|
9
|
+
): LoadFunction {
|
|
10
|
+
return function tileLoadFunction(imageTile, src): void {
|
|
11
|
+
const image = (imageTile as ImageTile).getImage() as HTMLImageElement;
|
|
12
|
+
const init = getInitForUrl(src, headers);
|
|
13
|
+
requestObjectUrl(src, init)
|
|
14
|
+
.then((blobUrl) => {
|
|
15
|
+
image.src = blobUrl;
|
|
16
|
+
image.onload = (): void => {
|
|
17
|
+
URL.revokeObjectURL(blobUrl);
|
|
18
|
+
};
|
|
19
|
+
})
|
|
20
|
+
.catch(() => {
|
|
21
|
+
imageTile.setState(TileState.ERROR);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ImageLayer from 'ol/layer/Image.js';
|
|
2
|
+
import { TrustedServers } from '@vcmap-cesium/engine';
|
|
2
3
|
import ImageStatic, {
|
|
3
4
|
type Options as ImageStaticOptions,
|
|
4
5
|
} from 'ol/source/ImageStatic.js';
|
|
@@ -7,6 +8,7 @@ import { wgs84Projection } from '../../util/projection.js';
|
|
|
7
8
|
import { isSameOrigin } from '../../util/urlHelpers.js';
|
|
8
9
|
import type { SingleImageImplementationOptions } from '../singleImageLayer.js';
|
|
9
10
|
import type OpenlayersMap from '../../map/openlayersMap.js';
|
|
11
|
+
import { getInitForUrl, requestObjectUrl } from '../../util/fetch.js';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* represents a specific OpenLayers SingleImageLayer Layer class.
|
|
@@ -33,10 +35,32 @@ class SingleImageOpenlayersImpl extends RasterLayerOpenlayersImpl {
|
|
|
33
35
|
projection: 'EPSG:4326',
|
|
34
36
|
imageExtent: this.extent.getCoordinatesInProjection(wgs84Projection),
|
|
35
37
|
};
|
|
36
|
-
if (
|
|
38
|
+
if (TrustedServers.contains(options.url)) {
|
|
39
|
+
options.crossOrigin = 'use-credentials';
|
|
40
|
+
} else if (!isSameOrigin(this.url as string)) {
|
|
37
41
|
options.crossOrigin = 'anonymous';
|
|
38
42
|
}
|
|
39
43
|
|
|
44
|
+
if (this.headers) {
|
|
45
|
+
options.imageLoadFunction = (imageWrapper, src): void => {
|
|
46
|
+
const init = getInitForUrl(src, this.headers);
|
|
47
|
+
requestObjectUrl(src, init)
|
|
48
|
+
.then((blobUrl) => {
|
|
49
|
+
const image = imageWrapper.getImage() as HTMLImageElement;
|
|
50
|
+
image.src = blobUrl;
|
|
51
|
+
image.onload = (): void => {
|
|
52
|
+
URL.revokeObjectURL(blobUrl);
|
|
53
|
+
};
|
|
54
|
+
})
|
|
55
|
+
.catch(() => {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,no-underscore-dangle
|
|
59
|
+
imageWrapper.handleImageError_();
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
40
64
|
return new ImageLayer({
|
|
41
65
|
source: new ImageStatic(options),
|
|
42
66
|
opacity: this.opacity,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TrustedServers } from '@vcmap-cesium/engine';
|
|
1
2
|
import XYZ, { type Options as XYZOptions } from 'ol/source/XYZ.js';
|
|
2
3
|
import Tile from 'ol/layer/Tile.js';
|
|
3
4
|
import { type Options as TileOptions } from 'ol/layer/BaseTile.js';
|
|
@@ -8,6 +9,7 @@ import { TilingScheme } from '../rasterLayer.js';
|
|
|
8
9
|
import { isSameOrigin } from '../../util/urlHelpers.js';
|
|
9
10
|
import type { TMSImplementationOptions } from '../tmsLayer.js';
|
|
10
11
|
import type OpenlayersMap from '../../map/openlayersMap.js';
|
|
12
|
+
import { getTileLoadFunction } from './loadFunctionHelpers.js';
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* TmsLayer implementation for {@link OpenlayersMap}.
|
|
@@ -43,12 +45,17 @@ class TmsOpenlayersImpl extends RasterLayerOpenlayersImpl {
|
|
|
43
45
|
maxZoom: this.maxLevel,
|
|
44
46
|
wrapX: false,
|
|
45
47
|
};
|
|
46
|
-
if (
|
|
48
|
+
if (TrustedServers.contains(this.url as string)) {
|
|
49
|
+
sourceOptions.crossOrigin = 'use-credentials';
|
|
50
|
+
} else if (!isSameOrigin(this.url as string)) {
|
|
47
51
|
sourceOptions.crossOrigin = 'anonymous';
|
|
48
52
|
}
|
|
49
53
|
if (this.tilingSchema === TilingScheme.GEOGRAPHIC) {
|
|
50
54
|
sourceOptions.projection = 'EPSG:4326';
|
|
51
55
|
}
|
|
56
|
+
if (this.headers) {
|
|
57
|
+
sourceOptions.tileLoadFunction = getTileLoadFunction(this.headers);
|
|
58
|
+
}
|
|
52
59
|
|
|
53
60
|
const tileOptions: TileOptions<XYZ> = {
|
|
54
61
|
source: new XYZ(sourceOptions),
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import Tile from 'ol/layer/Tile.js';
|
|
2
2
|
import type { Size } from 'ol/size.js';
|
|
3
3
|
import type TileWMS from 'ol/source/TileWMS.js';
|
|
4
|
+
import ImageWMS from 'ol/source/ImageWMS.js';
|
|
5
|
+
import ImageLayer from 'ol/layer/Image.js';
|
|
4
6
|
import RasterLayerOpenlayersImpl from './rasterLayerOpenlayersImpl.js';
|
|
5
|
-
import { getWMSSource } from '../wmsHelpers.js';
|
|
7
|
+
import { getImageWMSSource, getWMSSource } from '../wmsHelpers.js';
|
|
6
8
|
import type { WMSImplementationOptions } from '../wmsLayer.js';
|
|
7
9
|
import type OpenlayersMap from '../../map/openlayersMap.js';
|
|
10
|
+
import { mercatorProjection } from '../../util/projection.js';
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* represents a specific Cesium WmsOpenlayersImpl Layer class.
|
|
@@ -20,14 +23,31 @@ class WmsOpenlayersImpl extends RasterLayerOpenlayersImpl {
|
|
|
20
23
|
|
|
21
24
|
tileSize: Size;
|
|
22
25
|
|
|
26
|
+
singleImage2d: boolean;
|
|
27
|
+
|
|
23
28
|
constructor(map: OpenlayersMap, options: WMSImplementationOptions) {
|
|
24
29
|
super(map, options);
|
|
25
30
|
this.parameters = options.parameters;
|
|
26
31
|
this.version = options.version;
|
|
27
32
|
this.tileSize = options.tileSize;
|
|
33
|
+
this.singleImage2d = options.singleImage2d;
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
getOLLayer(): Tile<TileWMS> {
|
|
36
|
+
getOLLayer(): Tile<TileWMS> | ImageLayer<ImageWMS> {
|
|
37
|
+
if (this.singleImage2d) {
|
|
38
|
+
return new ImageLayer({
|
|
39
|
+
extent: this.extent.getCoordinatesInProjection(mercatorProjection),
|
|
40
|
+
visible: false,
|
|
41
|
+
source: getImageWMSSource({
|
|
42
|
+
url: this.url as string,
|
|
43
|
+
parameters: this.parameters,
|
|
44
|
+
tilingSchema: this.tilingSchema,
|
|
45
|
+
version: this.version,
|
|
46
|
+
headers: this.headers,
|
|
47
|
+
}),
|
|
48
|
+
opacity: this.opacity,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
31
51
|
return new Tile({
|
|
32
52
|
visible: false,
|
|
33
53
|
source: getWMSSource({
|
|
@@ -39,6 +59,7 @@ class WmsOpenlayersImpl extends RasterLayerOpenlayersImpl {
|
|
|
39
59
|
minLevel: this.minLevel,
|
|
40
60
|
maxLevel: this.maxLevel,
|
|
41
61
|
tilingSchema: this.tilingSchema,
|
|
62
|
+
headers: this.headers,
|
|
42
63
|
}),
|
|
43
64
|
opacity: this.opacity,
|
|
44
65
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TrustedServers } from '@vcmap-cesium/engine';
|
|
1
2
|
import { getTopLeft, getWidth } from 'ol/extent.js';
|
|
2
3
|
import WMTSTileGrid, {
|
|
3
4
|
type Options as WMTSTileGridOptions,
|
|
@@ -11,6 +12,7 @@ import { TilingScheme } from '../rasterLayer.js';
|
|
|
11
12
|
import { isSameOrigin } from '../../util/urlHelpers.js';
|
|
12
13
|
import type { WMTSImplementationOptions } from '../wmtsLayer.js';
|
|
13
14
|
import type OpenlayersMap from '../../map/openlayersMap.js';
|
|
15
|
+
import { getTileLoadFunction } from './loadFunctionHelpers.js';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* WmtsLayer implementation for {@link OpenlayersMap}.
|
|
@@ -106,13 +108,18 @@ class WmtsOpenlayersImpl extends RasterLayerOpenlayersImpl {
|
|
|
106
108
|
url: this.url,
|
|
107
109
|
};
|
|
108
110
|
|
|
109
|
-
if (
|
|
111
|
+
if (TrustedServers.contains(this.url as string)) {
|
|
112
|
+
wmtsOptions.crossOrigin = 'use-credentials';
|
|
113
|
+
} else if (!isSameOrigin(this.url as string)) {
|
|
110
114
|
wmtsOptions.crossOrigin = 'anonymous';
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
if (this.tilingSchema === TilingScheme.GEOGRAPHIC) {
|
|
114
118
|
wmtsOptions.projection = 'EPSG:4326';
|
|
115
119
|
}
|
|
120
|
+
if (this.headers) {
|
|
121
|
+
wmtsOptions.tileLoadFunction = getTileLoadFunction(this.headers);
|
|
122
|
+
}
|
|
116
123
|
|
|
117
124
|
Object.assign(wmtsOptions, this.openlayersOptions);
|
|
118
125
|
return new Tile({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { check, maybe, oneOf } from '@vcsuite/check';
|
|
2
2
|
// eslint-disable-next-line import/no-named-default
|
|
3
3
|
import type { default as OLStyle, StyleFunction } from 'ol/style/Style.js';
|
|
4
4
|
import CesiumTilesetLayer, {
|
|
@@ -80,7 +80,7 @@ class PointCloudLayer extends CesiumTilesetLayer {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
set pointSize(size: string | number | undefined) {
|
|
83
|
-
|
|
83
|
+
check(size, maybe(oneOf(Number, String)));
|
|
84
84
|
this._pointSize = size;
|
|
85
85
|
(this.style as DeclarativeStyleItem).pointSize = size?.toString();
|
|
86
86
|
}
|