@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
|
@@ -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,11 @@ class VectorObliqueImpl
|
|
|
207
207
|
|
|
208
208
|
this._setFeatureListeners(originalFeature, obliqueFeature);
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
await this._convertToOblique(originalFeature, obliqueFeature);
|
|
211
|
+
if (this.source.hasFeature(originalFeature)) {
|
|
212
|
+
// if not in source, feature has been removed in between.
|
|
213
|
+
this.obliqueSource.addFeature(obliqueFeature);
|
|
214
|
+
}
|
|
215
215
|
}
|
|
216
216
|
return Promise.resolve();
|
|
217
217
|
}
|
|
@@ -308,8 +308,9 @@ class VectorObliqueImpl
|
|
|
308
308
|
const vectorGeometry = originalFeature.getGeometry() as Geometry;
|
|
309
309
|
const imageGeometry = obliqueFeature.getGeometry() as Geometry;
|
|
310
310
|
this._updatingOblique[id] = true;
|
|
311
|
+
let promise: Promise<unknown>;
|
|
311
312
|
if (!vectorGeometry[alreadyTransformedToImage]) {
|
|
312
|
-
|
|
313
|
+
promise = mercatorGeometryToImageGeometry(
|
|
313
314
|
vectorGeometry,
|
|
314
315
|
imageGeometry,
|
|
315
316
|
this.map.currentImage as ObliqueImage,
|
|
@@ -318,7 +319,10 @@ class VectorObliqueImpl
|
|
|
318
319
|
obliqueFeature
|
|
319
320
|
.getGeometry()!
|
|
320
321
|
.setCoordinates(vectorGeometry.getCoordinates());
|
|
322
|
+
// we MUST wait for a promise, otherwise this is sync and you can add a feature twice
|
|
323
|
+
promise = Promise.resolve();
|
|
321
324
|
}
|
|
325
|
+
await promise;
|
|
322
326
|
this._updatingOblique[id] = null;
|
|
323
327
|
}
|
|
324
328
|
|
|
@@ -429,11 +433,13 @@ class VectorObliqueImpl
|
|
|
429
433
|
}
|
|
430
434
|
|
|
431
435
|
private removeFeature(feature: Feature): void {
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
)
|
|
436
|
+
const id = feature.getId() as number | string;
|
|
437
|
+
const feat = this.obliqueSource.getFeatureById(id);
|
|
438
|
+
if (this._updatingOblique[id] != null) {
|
|
439
|
+
clearTimeout(this._updatingOblique[id] as number);
|
|
440
|
+
this._updatingOblique[id] = null;
|
|
441
|
+
}
|
|
435
442
|
if (feat) {
|
|
436
|
-
const id = feat.getId() as string;
|
|
437
443
|
const listeners = this._featureListeners[id];
|
|
438
444
|
if (listeners) {
|
|
439
445
|
unByKey(Object.values(listeners));
|
|
@@ -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
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import type { Coordinate } from 'ol/coordinate.js';
|
|
8
8
|
import { getTransform } from 'ol/proj.js';
|
|
9
9
|
import Projection, { wgs84Projection } from '../util/projection.js';
|
|
10
|
+
import { getResourceOrUrl } from './cesium/resourceHelper.js';
|
|
10
11
|
|
|
11
12
|
export type TerrainProviderOptions = {
|
|
12
13
|
requestVertexNormals?: boolean;
|
|
@@ -15,16 +16,16 @@ export type TerrainProviderOptions = {
|
|
|
15
16
|
|
|
16
17
|
const terrainProviders: Record<string, CesiumTerrainProvider> = {};
|
|
17
18
|
|
|
18
|
-
/**
|
|
19
|
-
* @param url
|
|
20
|
-
* @param options
|
|
21
|
-
*/
|
|
22
19
|
export async function getTerrainProviderForUrl(
|
|
23
20
|
url: string,
|
|
24
21
|
options: TerrainProviderOptions,
|
|
22
|
+
headers?: Record<string, string>,
|
|
25
23
|
): Promise<CesiumTerrainProvider> {
|
|
26
24
|
if (!terrainProviders[url]) {
|
|
27
|
-
terrainProviders[url] = await CesiumTerrainProvider.fromUrl(
|
|
25
|
+
terrainProviders[url] = await CesiumTerrainProvider.fromUrl(
|
|
26
|
+
getResourceOrUrl(url, headers),
|
|
27
|
+
options,
|
|
28
|
+
);
|
|
28
29
|
return terrainProviders[url];
|
|
29
30
|
}
|
|
30
31
|
let terrainProvider = terrainProviders[url];
|
|
@@ -34,12 +35,24 @@ export async function getTerrainProviderForUrl(
|
|
|
34
35
|
(options.requestWaterMask !== undefined &&
|
|
35
36
|
terrainProvider.requestWaterMask !== options.requestWaterMask)
|
|
36
37
|
) {
|
|
37
|
-
terrainProviders[url] = await CesiumTerrainProvider.fromUrl(
|
|
38
|
+
terrainProviders[url] = await CesiumTerrainProvider.fromUrl(
|
|
39
|
+
getResourceOrUrl(url, headers),
|
|
40
|
+
options,
|
|
41
|
+
);
|
|
38
42
|
terrainProvider = terrainProviders[url];
|
|
39
43
|
}
|
|
40
44
|
return terrainProvider;
|
|
41
45
|
}
|
|
42
46
|
|
|
47
|
+
/**
|
|
48
|
+
* cleans the terrainProvider Cache, used for testing
|
|
49
|
+
*/
|
|
50
|
+
export function cleanCachedTerrainProviders(): void {
|
|
51
|
+
Object.keys(terrainProviders).forEach((key) => {
|
|
52
|
+
delete terrainProviders[key];
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
/**
|
|
44
57
|
* changes input coordinate Array in place, new height can also be accessed by coordinates[x][2]
|
|
45
58
|
* @param terrainProvider
|
|
@@ -78,10 +78,14 @@ class TerrainLayer extends Layer<TerrainCesiumImpl> {
|
|
|
78
78
|
async getHeightForWGS84Coordinates(
|
|
79
79
|
coords: Coordinate[],
|
|
80
80
|
): Promise<Coordinate[]> {
|
|
81
|
-
const terrainProvider = await getTerrainProviderForUrl(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
const terrainProvider = await getTerrainProviderForUrl(
|
|
82
|
+
this.url,
|
|
83
|
+
{
|
|
84
|
+
requestVertexNormals: this.requestVertexNormals,
|
|
85
|
+
requestWaterMask: this.requestWaterMask,
|
|
86
|
+
},
|
|
87
|
+
this.headers,
|
|
88
|
+
);
|
|
85
89
|
return getHeightFromTerrainProvider(
|
|
86
90
|
terrainProvider,
|
|
87
91
|
coords,
|
|
@@ -7,7 +7,7 @@ import TileProvider, {
|
|
|
7
7
|
TileProviderOptions,
|
|
8
8
|
} from './tileProvider.js';
|
|
9
9
|
import { getURL } from './urlTemplateTileProvider.js';
|
|
10
|
-
import { requestArrayBuffer } from '../../util/fetch.js';
|
|
10
|
+
import { getInitForUrl, requestArrayBuffer } from '../../util/fetch.js';
|
|
11
11
|
import { tileProviderClassRegistry } from '../../classRegistry.js';
|
|
12
12
|
|
|
13
13
|
export type MVTTileProviderOptions = TileProviderOptions & {
|
|
@@ -68,12 +68,18 @@ class MVTTileProvider extends TileProvider {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
async loader(
|
|
71
|
+
async loader(
|
|
72
|
+
x: number,
|
|
73
|
+
y: number,
|
|
74
|
+
z: number,
|
|
75
|
+
headers?: Record<string, string>,
|
|
76
|
+
): Promise<Feature[]> {
|
|
72
77
|
const rectangle = this.tilingScheme.tileXYToRectangle(x, y, z);
|
|
73
78
|
const url = getURL(this.url, x, y, z, rectangle, this.locale);
|
|
74
79
|
const extent = rectangleToExtent(rectangle);
|
|
75
80
|
const center = getCenter(extent);
|
|
76
|
-
const
|
|
81
|
+
const init = getInitForUrl(this.url, headers);
|
|
82
|
+
const data = await requestArrayBuffer(url, init);
|
|
77
83
|
const features = this._MVTFormat.readFeatures(data) as Feature[];
|
|
78
84
|
const sx = (extent[2] - extent[0]) / 4096;
|
|
79
85
|
const sy = -((extent[3] - extent[1]) / 4096);
|
|
@@ -2,7 +2,7 @@ import type { GeoJSONObject } from 'ol/format/GeoJSON.js';
|
|
|
2
2
|
import type { Feature } from 'ol/index.js';
|
|
3
3
|
import { parseGeoJSON } from '../geojsonHelpers.js';
|
|
4
4
|
import TileProvider, { TileProviderOptions } from './tileProvider.js';
|
|
5
|
-
import { requestJson } from '../../util/fetch.js';
|
|
5
|
+
import { getInitForUrl, requestJson } from '../../util/fetch.js';
|
|
6
6
|
import { tileProviderClassRegistry } from '../../classRegistry.js';
|
|
7
7
|
|
|
8
8
|
export type StaticGeoJSONTileProviderOptions = TileProviderOptions & {
|
|
@@ -36,8 +36,14 @@ class StaticGeoJSONTileProvider extends TileProvider {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// eslint-disable-next-line no-unused-vars
|
|
39
|
-
async loader(
|
|
40
|
-
|
|
39
|
+
async loader(
|
|
40
|
+
_x: number,
|
|
41
|
+
_y: number,
|
|
42
|
+
_z: number,
|
|
43
|
+
headers?: Record<string, string>,
|
|
44
|
+
): Promise<Feature[]> {
|
|
45
|
+
const init = getInitForUrl(this.url, headers);
|
|
46
|
+
const data = await requestJson<GeoJSONObject>(this.url, init);
|
|
41
47
|
const { features } = parseGeoJSON(data, { dynamicStyle: true });
|
|
42
48
|
return features;
|
|
43
49
|
}
|
|
@@ -363,6 +363,7 @@ class TileProvider extends VcsObject {
|
|
|
363
363
|
private async _getRtreeForBaseTile(
|
|
364
364
|
baseLevel: number,
|
|
365
365
|
tileCenter: Cartographic,
|
|
366
|
+
headers?: Record<string, string>,
|
|
366
367
|
): Promise<TileProviderRtree | null> {
|
|
367
368
|
const baseTile = this.tilingScheme.positionToTileXY(tileCenter, baseLevel);
|
|
368
369
|
const baseTileCacheKey = this.getCacheKey(
|
|
@@ -372,7 +373,12 @@ class TileProvider extends VcsObject {
|
|
|
372
373
|
);
|
|
373
374
|
if (this.cache.has(baseLevel)) {
|
|
374
375
|
if (!this.cache.get(baseLevel)!.containsKey(baseTileCacheKey)) {
|
|
375
|
-
const featuresPromise = this.loader(
|
|
376
|
+
const featuresPromise = this.loader(
|
|
377
|
+
baseTile.x,
|
|
378
|
+
baseTile.y,
|
|
379
|
+
baseLevel,
|
|
380
|
+
headers,
|
|
381
|
+
);
|
|
376
382
|
// eslint-disable-next-line no-void
|
|
377
383
|
void this._addTilePromiseToCache(
|
|
378
384
|
featuresPromise,
|
|
@@ -388,12 +394,14 @@ class TileProvider extends VcsObject {
|
|
|
388
394
|
/**
|
|
389
395
|
* returns the features intersecting this coordinate. Depending on the resolution a buffer around the coordinate is requested.
|
|
390
396
|
* The Buffer has the size of the resolution.
|
|
391
|
-
* @param
|
|
392
|
-
* @param
|
|
397
|
+
* @param coordinate in mercator
|
|
398
|
+
* @param resolution in m per pixel
|
|
399
|
+
* @param headers optional request headers to be sent with the server request
|
|
393
400
|
*/
|
|
394
401
|
async getFeaturesByCoordinate(
|
|
395
402
|
coordinate: Coordinate,
|
|
396
403
|
resolution: number,
|
|
404
|
+
headers?: Record<string, string>,
|
|
397
405
|
): Promise<Feature[]> {
|
|
398
406
|
const extent = createOrUpdateFromCoordinate(coordinate);
|
|
399
407
|
buffer(extent, resolution, extent);
|
|
@@ -406,7 +414,11 @@ class TileProvider extends VcsObject {
|
|
|
406
414
|
resolution,
|
|
407
415
|
cartographic.latitude,
|
|
408
416
|
);
|
|
409
|
-
const rtree = await this._getRtreeForBaseTile(
|
|
417
|
+
const rtree = await this._getRtreeForBaseTile(
|
|
418
|
+
baseLevel,
|
|
419
|
+
cartographic,
|
|
420
|
+
headers,
|
|
421
|
+
);
|
|
410
422
|
if (rtree) {
|
|
411
423
|
const features = rtree
|
|
412
424
|
.search({
|
|
@@ -423,20 +435,26 @@ class TileProvider extends VcsObject {
|
|
|
423
435
|
|
|
424
436
|
/**
|
|
425
437
|
* returns features for the requested Tile.
|
|
426
|
-
* @param
|
|
427
|
-
* @param
|
|
428
|
-
* @param
|
|
438
|
+
* @param x
|
|
439
|
+
* @param y
|
|
440
|
+
* @param level - if the level is not a base level, will use the closest match
|
|
441
|
+
* @param headers optional request headers to be sent with the server request
|
|
429
442
|
*/
|
|
430
443
|
async getFeaturesForTile(
|
|
431
444
|
x: number,
|
|
432
445
|
y: number,
|
|
433
446
|
level: number,
|
|
447
|
+
headers?: Record<string, string>,
|
|
434
448
|
): Promise<Feature[]> {
|
|
435
449
|
const rectangle = this.tilingScheme.tileXYToRectangle(x, y, level);
|
|
436
450
|
const tileCenter = Rectangle.center(rectangle);
|
|
437
451
|
const baseLevel = this.getBaseLevel(level);
|
|
438
452
|
if (baseLevel != null) {
|
|
439
|
-
const rtree = await this._getRtreeForBaseTile(
|
|
453
|
+
const rtree = await this._getRtreeForBaseTile(
|
|
454
|
+
baseLevel,
|
|
455
|
+
tileCenter,
|
|
456
|
+
headers,
|
|
457
|
+
);
|
|
440
458
|
if (rtree) {
|
|
441
459
|
if (level === baseLevel) {
|
|
442
460
|
return rtree.all().map((item) => item.value);
|
|
@@ -462,21 +480,29 @@ class TileProvider extends VcsObject {
|
|
|
462
480
|
const childNorth = x * 2;
|
|
463
481
|
const childWest = y * 2;
|
|
464
482
|
return [
|
|
465
|
-
...(await this.getFeaturesForTile(
|
|
483
|
+
...(await this.getFeaturesForTile(
|
|
484
|
+
childNorth,
|
|
485
|
+
childWest,
|
|
486
|
+
childLevel,
|
|
487
|
+
headers,
|
|
488
|
+
)),
|
|
466
489
|
...(await this.getFeaturesForTile(
|
|
467
490
|
childNorth + 1,
|
|
468
491
|
childWest,
|
|
469
492
|
childLevel,
|
|
493
|
+
headers,
|
|
470
494
|
)),
|
|
471
495
|
...(await this.getFeaturesForTile(
|
|
472
496
|
childNorth + 1,
|
|
473
497
|
childWest + 1,
|
|
474
498
|
childLevel,
|
|
499
|
+
headers,
|
|
475
500
|
)),
|
|
476
501
|
...(await this.getFeaturesForTile(
|
|
477
502
|
childNorth,
|
|
478
503
|
childWest + 1,
|
|
479
504
|
childLevel,
|
|
505
|
+
headers,
|
|
480
506
|
)),
|
|
481
507
|
];
|
|
482
508
|
}
|
|
@@ -485,12 +511,14 @@ class TileProvider extends VcsObject {
|
|
|
485
511
|
|
|
486
512
|
/**
|
|
487
513
|
* Retrieves all features which intersect the given extent. Will load all intersecting tiles.
|
|
488
|
-
* @param
|
|
489
|
-
* @param
|
|
514
|
+
* @param extent
|
|
515
|
+
* @param level - Optional level to request. Will use highest level if omitted. If the provided level is not a base level, will use the closest match.
|
|
516
|
+
* @param headers Optional request headers to be sent with the server request
|
|
490
517
|
*/
|
|
491
518
|
async getFeaturesForExtent(
|
|
492
519
|
extent: Extent,
|
|
493
520
|
level?: number,
|
|
521
|
+
headers?: Record<string, string>,
|
|
494
522
|
): Promise<Feature[]> {
|
|
495
523
|
let usedLevel = level != null ? level : this.baseLevels[0];
|
|
496
524
|
usedLevel = this.getBaseLevel(usedLevel) as number;
|
|
@@ -512,7 +540,9 @@ class TileProvider extends VcsObject {
|
|
|
512
540
|
}
|
|
513
541
|
|
|
514
542
|
const features = await Promise.all(
|
|
515
|
-
tileCoordinates.map(([x, y]) =>
|
|
543
|
+
tileCoordinates.map(([x, y]) =>
|
|
544
|
+
this.getFeaturesForTile(x, y, usedLevel, headers),
|
|
545
|
+
),
|
|
516
546
|
);
|
|
517
547
|
const mercatorExtent =
|
|
518
548
|
extent.getCoordinatesInProjection(mercatorProjection);
|
|
@@ -559,7 +589,12 @@ class TileProvider extends VcsObject {
|
|
|
559
589
|
* });
|
|
560
590
|
*/
|
|
561
591
|
// eslint-disable-next-line class-methods-use-this,no-unused-vars
|
|
562
|
-
loader(
|
|
592
|
+
loader(
|
|
593
|
+
_x: number,
|
|
594
|
+
_y: number,
|
|
595
|
+
_z: number,
|
|
596
|
+
_headers?: Record<string, string>,
|
|
597
|
+
): Promise<Feature[]> {
|
|
563
598
|
return Promise.resolve([]);
|
|
564
599
|
}
|
|
565
600
|
|
|
@@ -589,6 +624,7 @@ class TileProvider extends VcsObject {
|
|
|
589
624
|
if (defaultOptions.allowTileAggregation !== this.allowTileAggregation) {
|
|
590
625
|
config.allowTileAggregation = this.allowTileAggregation;
|
|
591
626
|
}
|
|
627
|
+
|
|
592
628
|
return config;
|
|
593
629
|
}
|
|
594
630
|
|
|
@@ -3,7 +3,7 @@ import { Math as CesiumMath, Rectangle } from '@vcmap-cesium/engine';
|
|
|
3
3
|
import type { Feature } from 'ol/index.js';
|
|
4
4
|
import { parseGeoJSON } from '../geojsonHelpers.js';
|
|
5
5
|
import TileProvider, { TileProviderOptions } from './tileProvider.js';
|
|
6
|
-
import { requestJson } from '../../util/fetch.js';
|
|
6
|
+
import { getInitForUrl, requestJson } from '../../util/fetch.js';
|
|
7
7
|
import { tileProviderClassRegistry } from '../../classRegistry.js';
|
|
8
8
|
|
|
9
9
|
export type URLTemplateTileProviderOptions = TileProviderOptions & {
|
|
@@ -94,10 +94,17 @@ class URLTemplateTileProvider extends TileProvider {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
async loader(
|
|
97
|
+
async loader(
|
|
98
|
+
x: number,
|
|
99
|
+
y: number,
|
|
100
|
+
z: number,
|
|
101
|
+
headers?: Record<string, string>,
|
|
102
|
+
): Promise<Feature[]> {
|
|
98
103
|
const rectangle = this.tilingScheme.tileXYToRectangle(x, y, z);
|
|
99
104
|
const url = getURL(this.url, x, y, z, rectangle, this.locale);
|
|
100
|
-
|
|
105
|
+
|
|
106
|
+
const init = getInitForUrl(this.url, headers);
|
|
107
|
+
const data = await requestJson<GeoJSONObject>(url, init);
|
|
101
108
|
const { features } = parseGeoJSON(data, { dynamicStyle: true });
|
|
102
109
|
return features;
|
|
103
110
|
}
|