@vcmap/core 5.0.0-rc.3 → 5.0.0-rc.30
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/LICENSE.md +1 -1
- package/README.md +12 -5
- package/build/postinstall.js +14 -3
- package/index.d.ts +3477 -2007
- package/index.js +169 -131
- package/package.json +25 -27
- package/src/category/category.js +483 -0
- package/src/category/categoryCollection.js +153 -0
- package/src/cesium/cesium3DTileFeature.js +2 -2
- package/src/cesium/cesium3DTilePointFeature.js +1 -1
- package/src/cesium/cesiumVcsCameraPrimitive.js +16 -8
- package/src/cesium/entity.js +29 -0
- package/src/cesium/wallpaperMaterial.js +5 -3
- package/src/classRegistry.js +169 -0
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/abstractFeatureProvider.js +49 -46
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/tileProviderFeatureProvider.js +13 -5
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/wmsFeatureProvider.js +56 -26
- package/src/{vcs/vcm/interaction → interaction}/abstractInteraction.js +33 -21
- package/src/{vcs/vcm/interaction → interaction}/coordinateAtPixel.js +40 -21
- package/src/{vcs/vcm/interaction → interaction}/eventHandler.js +131 -26
- package/src/{vcs/vcm/interaction → interaction}/featureAtPixelInteraction.js +108 -53
- package/src/interaction/featureProviderInteraction.js +58 -0
- package/src/{vcs/vcm/interaction → interaction}/interactionChain.js +40 -41
- package/src/{vcs/vcm/interaction → interaction}/interactionType.js +24 -31
- package/src/{vcs/vcm/layer/cesium/cesiumTilesetCesium.js → layer/cesium/cesiumTilesetCesiumImpl.js} +67 -55
- package/src/{vcs/vcm/layer → layer}/cesium/clusterContext.js +33 -8
- package/src/{vcs/vcm/layer/cesium/dataSourceCesium.js → layer/cesium/dataSourceCesiumImpl.js} +24 -13
- package/src/layer/cesium/openStreetMapCesiumImpl.js +32 -0
- package/src/{vcs/vcm/layer/cesium/rasterLayerCesium.js → layer/cesium/rasterLayerCesiumImpl.js} +12 -9
- package/src/{vcs/vcm/layer/cesium/singleImageCesium.js → layer/cesium/singleImageCesiumImpl.js} +19 -9
- package/src/{vcs/vcm/layer/cesium/terrainCesium.js → layer/cesium/terrainCesiumImpl.js} +6 -6
- package/src/{vcs/vcm/layer/cesium/tmsCesium.js → layer/cesium/tmsCesiumImpl.js} +21 -10
- package/src/{vcs/vcm/layer/cesium/vectorCesium.js → layer/cesium/vectorCesiumImpl.js} +93 -35
- package/src/layer/cesium/vectorContext.js +363 -0
- package/src/{vcs/vcm/layer/cesium/vectorRasterTileCesium.js → layer/cesium/vectorRasterTileCesiumImpl.js} +21 -13
- package/src/{vcs/vcm/layer → layer}/cesium/vectorTileImageryProvider.js +58 -21
- package/src/{vcs/vcm/layer/cesium/wmsCesium.js → layer/cesium/wmsCesiumImpl.js} +20 -9
- package/src/{vcs/vcm/layer/cesium/wmtsCesium.js → layer/cesium/wmtsCesiumImpl.js} +24 -13
- package/src/{vcs/vcm/layer → layer}/cesium/x3dmHelper.js +6 -3
- package/src/{vcs/vcm/layer/cesiumTileset.js → layer/cesiumTilesetLayer.js} +71 -108
- package/src/{vcs/vcm/layer/czml.js → layer/czmlLayer.js} +23 -20
- package/src/{vcs/vcm/layer/dataSource.js → layer/dataSourceLayer.js} +55 -90
- package/src/{vcs/vcm/layer → layer}/featureLayer.js +89 -74
- package/src/{vcs/vcm/layer/featureStore.js → layer/featureStoreLayer.js} +197 -150
- package/src/{vcs/vcm/layer/featureStoreChanges.js → layer/featureStoreLayerChanges.js} +150 -92
- package/src/{vcs/vcm/layer/featureStoreState.js → layer/featureStoreLayerState.js} +1 -2
- package/src/{vcs/vcm/layer → layer}/featureVisibility.js +114 -82
- package/src/{vcs/vcm/layer → layer}/geojsonHelpers.js +84 -69
- package/src/{vcs/vcm/layer/geojson.js → layer/geojsonLayer.js} +30 -27
- package/src/{vcs/vcm/layer → layer}/globalHider.js +25 -39
- package/src/{vcs/vcm/layer → layer}/layer.js +171 -96
- package/src/{vcs/vcm/layer → layer}/layerImplementation.js +13 -6
- package/src/{vcs/vcm/layer → layer}/layerState.js +0 -1
- package/src/{vcs/vcm/layer → layer}/layerSymbols.js +2 -1
- package/src/{vcs/vcm/layer/oblique/layerOblique.js → layer/oblique/layerObliqueImpl.js} +7 -5
- package/src/{vcs/vcm/layer → layer}/oblique/obliqueHelpers.js +76 -31
- package/src/{vcs/vcm/layer/oblique/vectorOblique.js → layer/oblique/vectorObliqueImpl.js} +198 -80
- package/src/{vcs/vcm/layer/openStreetMap.js → layer/openStreetMapLayer.js} +59 -40
- package/src/layer/openlayers/layerOpenlayersImpl.js +165 -0
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +28 -0
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +44 -0
- package/src/{vcs/vcm/layer/openlayers/singleImageOpenlayers.js → layer/openlayers/singleImageOpenlayersImpl.js} +8 -7
- package/src/{vcs/vcm/layer/openlayers/tileDebugOpenlayers.js → layer/openlayers/tileDebugOpenlayersImpl.js} +7 -6
- package/src/{vcs/vcm/layer/openlayers/tmsOpenlayers.js → layer/openlayers/tmsOpenlayersImpl.js} +12 -10
- package/src/{vcs/vcm/layer/openlayers/vectorOpenlayers.js → layer/openlayers/vectorOpenlayersImpl.js} +21 -12
- package/src/{vcs/vcm/layer/openlayers/vectorTileOpenlayers.js → layer/openlayers/vectorTileOpenlayersImpl.js} +18 -12
- package/src/{vcs/vcm/layer/openlayers/wmsOpenlayers.js → layer/openlayers/wmsOpenlayersImpl.js} +9 -8
- package/src/{vcs/vcm/layer/openlayers/wmtsOpenlayers.js → layer/openlayers/wmtsOpenlayersImpl.js} +19 -12
- package/src/{vcs/vcm/layer/pointCloud.js → layer/pointCloudLayer.js} +42 -39
- package/src/{vcs/vcm/layer → layer}/rasterLayer.js +86 -37
- package/src/{vcs/vcm/layer/singleImage.js → layer/singleImageLayer.js} +25 -22
- package/src/layer/terrainHelpers.js +98 -0
- package/src/{vcs/vcm/layer/terrain.js → layer/terrainLayer.js} +26 -18
- package/src/{vcs/vcm/layer → layer}/tileLoadedHelper.js +13 -8
- package/src/{vcs/vcm/layer → layer}/tileProvider/mvtTileProvider.js +51 -8
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +87 -0
- package/src/{vcs/vcm/layer → layer}/tileProvider/tileProvider.js +200 -89
- package/src/{vcs/vcm/layer → layer}/tileProvider/urlTemplateTileProvider.js +54 -13
- package/src/{vcs/vcm/layer/tms.js → layer/tmsLayer.js} +22 -22
- package/src/layer/vectorHelpers.js +129 -0
- package/src/{vcs/vcm/layer/vector.js → layer/vectorLayer.js} +124 -94
- package/src/{vcs/vcm/layer → layer}/vectorProperties.js +419 -107
- package/src/{vcs/vcm/layer → layer}/vectorSymbols.js +11 -1
- package/src/{vcs/vcm/layer/vectorTile.js → layer/vectorTileLayer.js} +181 -116
- package/src/{vcs/vcm/layer/wfs.js → layer/wfsLayer.js} +33 -23
- package/src/{vcs/vcm/layer → layer}/wmsHelpers.js +14 -7
- package/src/{vcs/vcm/layer/wms.js → layer/wmsLayer.js} +53 -32
- package/src/{vcs/vcm/layer/wmts.js → layer/wmtsLayer.js} +56 -42
- package/src/{vcs/vcm/maps → map}/baseOLMap.js +83 -35
- package/src/{vcs/vcm/maps → map}/cameraLimiter.js +75 -32
- package/src/{vcs/vcm/maps/cesium.js → map/cesiumMap.js} +429 -276
- package/src/{vcs/vcm/maps → map}/mapState.js +0 -1
- package/src/{vcs/vcm/maps/oblique.js → map/obliqueMap.js} +132 -97
- package/src/{vcs/vcm/maps/openlayers.js → map/openlayersMap.js} +69 -45
- package/src/{vcs/vcm/maps/map.js → map/vcsMap.js} +118 -46
- package/src/oblique/defaultObliqueCollection.js +62 -0
- package/src/{vcs/vcm/oblique → oblique}/helpers.js +221 -78
- package/src/{vcs/vcm/oblique/ObliqueCollection.js → oblique/obliqueCollection.js} +145 -54
- package/src/{vcs/vcm/oblique/ObliqueDataSet.js → oblique/obliqueDataSet.js} +62 -32
- package/src/{vcs/vcm/oblique/ObliqueImage.js → oblique/obliqueImage.js} +58 -26
- package/src/{vcs/vcm/oblique/ObliqueImageMeta.js → oblique/obliqueImageMeta.js} +9 -9
- package/src/{vcs/vcm/oblique/ObliqueProvider.js → oblique/obliqueProvider.js} +85 -35
- package/src/{vcs/vcm/oblique/ObliqueView.js → oblique/obliqueView.js} +45 -5
- package/src/{vcs/vcm/oblique/ObliqueViewDirection.js → oblique/obliqueViewDirection.js} +3 -5
- package/src/{vcs/vcm/oblique → oblique}/parseImageJson.js +62 -28
- package/src/ol/feature.js +34 -1
- package/src/ol/geom/circle.js +14 -5
- package/src/ol/geom/geometryCollection.js +14 -8
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -10
- package/src/overrideClassRegistry.js +214 -0
- package/src/style/arcStyle.js +453 -0
- package/src/style/arrowStyle.js +304 -0
- package/src/{vcs/vcm/util/style → style}/declarativeStyleItem.js +147 -82
- package/src/{vcs/vcm/util/style → style}/shapesCategory.js +8 -8
- package/src/style/styleFactory.js +32 -0
- package/src/{vcs/vcm/util/style → style}/styleHelpers.js +24 -26
- package/src/style/styleItem.js +174 -0
- package/src/{vcs/vcm/util/style → style}/vectorStyleItem.js +230 -156
- package/src/{vcs/vcm/util/style → style}/writeStyle.js +7 -12
- package/src/{vcs/vcm/util → util}/clipping/clippingObject.js +84 -52
- package/src/{vcs/vcm/util → util}/clipping/clippingObjectManager.js +56 -23
- package/src/{vcs/vcm/util → util}/clipping/clippingPlaneHelper.js +149 -88
- package/src/{vcs/vcm/util → util}/collection.js +28 -10
- package/src/util/editor/createFeatureSession.js +195 -0
- package/src/util/editor/editFeaturesSession.js +325 -0
- package/src/util/editor/editGeometrySession.js +452 -0
- package/src/util/editor/editorHelpers.js +300 -0
- package/src/util/editor/editorSessionHelpers.js +132 -0
- package/src/util/editor/editorSymbols.js +21 -0
- package/src/util/editor/interactions/createBBoxInteraction.js +154 -0
- package/src/util/editor/interactions/createCircleInteraction.js +119 -0
- package/src/util/editor/interactions/createLineStringInteraction.js +119 -0
- package/src/util/editor/interactions/createPointInteraction.js +73 -0
- package/src/util/editor/interactions/createPolygonInteraction.js +136 -0
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +88 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +119 -0
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +50 -0
- package/src/util/editor/interactions/insertVertexInteraction.js +103 -0
- package/src/util/editor/interactions/mapInteractionController.js +119 -0
- package/src/util/editor/interactions/removeVertexInteraction.js +42 -0
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +152 -0
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +165 -0
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +120 -0
- package/src/util/editor/interactions/translateVertexInteraction.js +60 -0
- package/src/util/editor/selectFeaturesSession.js +303 -0
- package/src/util/editor/transformation/create2DHandlers.js +339 -0
- package/src/util/editor/transformation/create3DHandlers.js +678 -0
- package/src/util/editor/transformation/extrudeInteraction.js +106 -0
- package/src/util/editor/transformation/rotateInteraction.js +201 -0
- package/src/util/editor/transformation/scaleInteraction.js +201 -0
- package/src/util/editor/transformation/transformationHandler.js +178 -0
- package/src/util/editor/transformation/transformationTypes.js +88 -0
- package/src/util/editor/transformation/translateInteraction.js +263 -0
- package/src/util/editor/validateGeoemetry.js +24 -0
- package/src/{vcs/vcm/util → util}/exclusiveManager.js +6 -3
- package/src/{vcs/vcm/util → util}/extent.js +26 -20
- package/src/util/featureconverter/arcToCesium.js +121 -0
- package/src/{vcs/vcm/util → util}/featureconverter/circleToCesium.js +70 -37
- package/src/{vcs/vcm/util → util}/featureconverter/convert.js +94 -16
- package/src/util/featureconverter/extent3D.js +284 -0
- package/src/{vcs/vcm/util → util}/featureconverter/featureconverterHelper.js +253 -94
- package/src/util/featureconverter/lineStringToCesium.js +343 -0
- package/src/util/featureconverter/pointHelpers.js +413 -0
- package/src/{vcs/vcm/util → util}/featureconverter/pointToCesium.js +157 -107
- package/src/{vcs/vcm/util → util}/featureconverter/polygonToCesium.js +57 -24
- package/src/util/fetch.js +34 -0
- package/src/{vcs/vcm/util → util}/geometryHelpers.js +25 -17
- package/src/{vcs/vcm/util → util}/indexedCollection.js +27 -8
- package/src/{vcs/vcm/util → util}/isMobile.js +8 -2
- package/src/{vcs/vcm/util → util}/layerCollection.js +109 -19
- package/src/util/locale.js +12 -0
- package/src/{vcs/vcm/util → util}/mapCollection.js +170 -63
- package/src/util/math.js +193 -0
- package/src/util/overrideCollection.js +261 -0
- package/src/{vcs/vcm/util → util}/projection.js +23 -31
- package/src/{vcs/vcm/util → util}/urlHelpers.js +5 -3
- package/src/{vcs/vcm/util → util}/viewpoint.js +83 -57
- package/src/vcsApp.js +657 -0
- package/src/{vcs/vcm/event/vcsEvent.js → vcsEvent.js} +2 -3
- package/src/vcsModule.js +130 -0
- package/src/vcsModuleHelpers.js +136 -0
- package/src/{vcs/vcm/object.js → vcsObject.js} +3 -10
- package/tests/data/dynamicPointCzml.json +53 -0
- package/tests/data/oblique/imageData/imagev34.json +136 -0
- package/tests/data/oblique/imageData/imagev35.json +307 -0
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +333 -0
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -0
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -0
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -0
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -0
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -0
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -0
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -0
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -0
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -0
- package/tests/data/oblique/tiledImageData/image.json +70 -0
- package/tests/data/terrain/13/8800/6485.terrain +0 -0
- package/tests/data/terrain/13/8800/6486.terrain +0 -0
- package/tests/data/terrain/13/8801/6485.terrain +0 -0
- package/tests/data/terrain/13/8801/6486.terrain +0 -0
- package/tests/data/terrain/layer.json +127 -0
- package/tests/data/testGeoJSON.json +149 -0
- package/tests/data/tile.pbf +0 -0
- package/tests/unit/helpers/cesiumHelpers.js +326 -0
- package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
- package/tests/unit/helpers/helpers.js +32 -0
- package/tests/unit/helpers/imageHelpers.js +24 -0
- package/tests/unit/helpers/importJSON.js +15 -0
- package/tests/unit/helpers/obliqueData.js +102 -0
- package/tests/unit/helpers/obliqueHelpers.js +115 -0
- package/tests/unit/helpers/openlayersHelpers.js +25 -0
- package/tests/unit/helpers/terrain/terrainData.js +47 -0
- package/src/vcs/vcm/classRegistry.js +0 -106
- package/src/vcs/vcm/globalCollections.js +0 -11
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +0 -54
- package/src/vcs/vcm/layer/buildings.js +0 -17
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +0 -29
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +0 -58
- package/src/vcs/vcm/layer/cesium/vectorContext.js +0 -167
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +0 -79
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +0 -27
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +0 -121
- package/src/vcs/vcm/layer/terrainHelpers.js +0 -119
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +0 -67
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +0 -28
- package/src/vcs/vcm/layer/vectorHelpers.js +0 -206
- package/src/vcs/vcm/util/dateTime.js +0 -60
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +0 -51
- package/src/vcs/vcm/util/featureconverter/extent3d.js +0 -154
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +0 -171
- package/src/vcs/vcm/util/locale.js +0 -53
- package/src/vcs/vcm/util/math.js +0 -71
- package/src/vcs/vcm/util/splitScreen.js +0 -233
- package/src/vcs/vcm/util/style/styleFactory.js +0 -48
- package/src/vcs/vcm/util/style/styleItem.js +0 -243
- /package/src/{vcs/vcm/util/featureProvider → featureProvider}/featureProviderSymbols.js +0 -0
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import RBush from 'rbush';
|
|
3
|
-
import {
|
|
3
|
+
import { check } from '@vcsuite/check';
|
|
4
|
+
import {
|
|
5
|
+
Rectangle,
|
|
6
|
+
Math as CesiumMath,
|
|
7
|
+
WebMercatorTilingScheme,
|
|
8
|
+
Cartographic,
|
|
9
|
+
} from '@vcmap-cesium/engine';
|
|
4
10
|
import LRUCache from 'ol/structs/LRUCache.js';
|
|
5
11
|
import { buffer, createOrUpdateFromCoordinate } from 'ol/extent.js';
|
|
6
12
|
import { parseBoolean, parseInteger } from '@vcsuite/parsers';
|
|
@@ -10,8 +16,9 @@ import {
|
|
|
10
16
|
wgs84Projection,
|
|
11
17
|
wgs84ToMercatorTransformer,
|
|
12
18
|
} from '../../util/projection.js';
|
|
13
|
-
import VcsObject from '../../
|
|
14
|
-
import VcsEvent from '../../
|
|
19
|
+
import VcsObject from '../../vcsObject.js';
|
|
20
|
+
import VcsEvent from '../../vcsEvent.js';
|
|
21
|
+
import { tileProviderClassRegistry } from '../../classRegistry.js';
|
|
15
22
|
|
|
16
23
|
/**
|
|
17
24
|
* @typedef {Object} tileProviderRTreeEntry
|
|
@@ -33,7 +40,7 @@ for (let i = 0; i < mercatorResolutionsToLevel.length; i++) {
|
|
|
33
40
|
|
|
34
41
|
/**
|
|
35
42
|
* transforms cesium geographic rectangle to mercator extent
|
|
36
|
-
* @param {import("@vcmap/
|
|
43
|
+
* @param {import("@vcmap-cesium/engine").Rectangle} rectangle in wgs84 radians
|
|
37
44
|
* @returns {import("ol/extent").Extent} extent in mercator
|
|
38
45
|
*/
|
|
39
46
|
export function rectangleToExtent(rectangle) {
|
|
@@ -68,13 +75,11 @@ export function rectangleToExtent(rectangle) {
|
|
|
68
75
|
* @api
|
|
69
76
|
*/
|
|
70
77
|
|
|
71
|
-
|
|
72
78
|
/**
|
|
73
79
|
* TileProvider class
|
|
74
80
|
*
|
|
75
81
|
* @class
|
|
76
82
|
* @extends {VcsObject}
|
|
77
|
-
* @export
|
|
78
83
|
* @api
|
|
79
84
|
*/
|
|
80
85
|
class TileProvider extends VcsObject {
|
|
@@ -82,7 +87,9 @@ class TileProvider extends VcsObject {
|
|
|
82
87
|
* @readonly
|
|
83
88
|
* @returns {string}
|
|
84
89
|
*/
|
|
85
|
-
static get className() {
|
|
90
|
+
static get className() {
|
|
91
|
+
return 'TileProvider';
|
|
92
|
+
}
|
|
86
93
|
|
|
87
94
|
/**
|
|
88
95
|
* @returns {TileProviderOptions}
|
|
@@ -105,7 +112,7 @@ class TileProvider extends VcsObject {
|
|
|
105
112
|
|
|
106
113
|
/**
|
|
107
114
|
* Cesium Webmercator TilingScheme
|
|
108
|
-
* @type {import("@vcmap/
|
|
115
|
+
* @type {import("@vcmap-cesium/engine").WebMercatorTilingScheme}
|
|
109
116
|
* @api
|
|
110
117
|
* @readonly
|
|
111
118
|
*/
|
|
@@ -115,13 +122,17 @@ class TileProvider extends VcsObject {
|
|
|
115
122
|
* @type {number}
|
|
116
123
|
* @private
|
|
117
124
|
*/
|
|
118
|
-
this._tileCacheSize = parseInteger(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
this._tileCacheSize = parseInteger(
|
|
126
|
+
options.tileCacheSize,
|
|
127
|
+
defaultOptions.tileCacheSize,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const baseLevels = Array.isArray(options.baseLevels)
|
|
131
|
+
? options.baseLevels.slice()
|
|
132
|
+
: defaultOptions.baseLevels.slice();
|
|
133
|
+
baseLevels.sort((a, b) => {
|
|
134
|
+
return b - a;
|
|
135
|
+
});
|
|
125
136
|
|
|
126
137
|
/**
|
|
127
138
|
* sorted baseLevels, maximumLevel first example: [18,17,16]
|
|
@@ -154,13 +165,19 @@ class TileProvider extends VcsObject {
|
|
|
154
165
|
* @api
|
|
155
166
|
* @readonly
|
|
156
167
|
*/
|
|
157
|
-
this.trackFeaturesToTiles = parseBoolean(
|
|
168
|
+
this.trackFeaturesToTiles = parseBoolean(
|
|
169
|
+
options.trackFeaturesToTiles,
|
|
170
|
+
defaultOptions.trackFeaturesToTiles,
|
|
171
|
+
);
|
|
158
172
|
|
|
159
173
|
/**
|
|
160
174
|
* @type {boolean}
|
|
161
175
|
* @api
|
|
162
176
|
*/
|
|
163
|
-
this.allowTileAggregation = parseBoolean(
|
|
177
|
+
this.allowTileAggregation = parseBoolean(
|
|
178
|
+
options.allowTileAggregation,
|
|
179
|
+
defaultOptions.allowTileAggregation,
|
|
180
|
+
);
|
|
164
181
|
|
|
165
182
|
/**
|
|
166
183
|
* set of currently loaded featureIds with the corresponding tileIds
|
|
@@ -176,6 +193,12 @@ class TileProvider extends VcsObject {
|
|
|
176
193
|
* @api
|
|
177
194
|
*/
|
|
178
195
|
this.tileLoadedEvent = new VcsEvent();
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @type {string}
|
|
199
|
+
* @private
|
|
200
|
+
*/
|
|
201
|
+
this._locale = 'en';
|
|
179
202
|
}
|
|
180
203
|
|
|
181
204
|
/**
|
|
@@ -188,6 +211,24 @@ class TileProvider extends VcsObject {
|
|
|
188
211
|
return this._tileCacheSize;
|
|
189
212
|
}
|
|
190
213
|
|
|
214
|
+
/**
|
|
215
|
+
* @type {string}
|
|
216
|
+
*/
|
|
217
|
+
get locale() {
|
|
218
|
+
return this._locale;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* sets the locale and reloads the layer the if the URL is a locale aware Object.
|
|
223
|
+
* @param {string} value
|
|
224
|
+
*/
|
|
225
|
+
set locale(value) {
|
|
226
|
+
check(value, String);
|
|
227
|
+
if (this._locale !== value) {
|
|
228
|
+
this._locale = value;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
191
232
|
/**
|
|
192
233
|
* @param {number} value
|
|
193
234
|
* @returns {Promise<*>}
|
|
@@ -255,43 +296,52 @@ class TileProvider extends VcsObject {
|
|
|
255
296
|
* @private
|
|
256
297
|
*/
|
|
257
298
|
_addTilePromiseToCache(featuresPromise, baseLevel, tileId) {
|
|
258
|
-
const rtreePromise = featuresPromise
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
feature.
|
|
262
|
-
|
|
299
|
+
const rtreePromise = featuresPromise
|
|
300
|
+
.then((features) => {
|
|
301
|
+
features.forEach((feature) => {
|
|
302
|
+
if (!feature.getId()) {
|
|
303
|
+
feature.setId(uuidv4());
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
const rtree = new RBush(features.length);
|
|
307
|
+
rtree.load(
|
|
308
|
+
features
|
|
309
|
+
.map((feature) => {
|
|
310
|
+
const geometry = feature.getGeometry();
|
|
311
|
+
if (geometry) {
|
|
312
|
+
const extent = geometry.getExtent();
|
|
313
|
+
const item = {
|
|
314
|
+
minX: extent[0],
|
|
315
|
+
minY: extent[1],
|
|
316
|
+
maxX: extent[2],
|
|
317
|
+
maxY: extent[3],
|
|
318
|
+
value: feature,
|
|
319
|
+
};
|
|
320
|
+
return item;
|
|
321
|
+
}
|
|
322
|
+
return null;
|
|
323
|
+
})
|
|
324
|
+
.filter((item) => item),
|
|
325
|
+
);
|
|
326
|
+
this.tileLoadedEvent.raiseEvent({ tileId, rtree });
|
|
327
|
+
this._trackFeatures(features, tileId);
|
|
328
|
+
this.rtreeCache.set(tileId, rtree);
|
|
329
|
+
return rtree;
|
|
330
|
+
})
|
|
331
|
+
.catch(() => {
|
|
332
|
+
// Discussion, do we want to go on on tileLoadFailure ?
|
|
333
|
+
this.getLogger().warning(`Could not load Tile ${tileId}`);
|
|
334
|
+
const rtree = new RBush();
|
|
335
|
+
this.rtreeCache.set(tileId, rtree);
|
|
336
|
+
return rtree;
|
|
263
337
|
});
|
|
264
|
-
const rtree = new RBush(features.length);
|
|
265
|
-
rtree.load(features.map((feature) => {
|
|
266
|
-
const geometry = feature.getGeometry();
|
|
267
|
-
if (geometry) {
|
|
268
|
-
const extent = geometry.getExtent();
|
|
269
|
-
const item = {
|
|
270
|
-
minX: extent[0],
|
|
271
|
-
minY: extent[1],
|
|
272
|
-
maxX: extent[2],
|
|
273
|
-
maxY: extent[3],
|
|
274
|
-
value: feature,
|
|
275
|
-
};
|
|
276
|
-
return item;
|
|
277
|
-
}
|
|
278
|
-
return null;
|
|
279
|
-
}).filter(item => item));
|
|
280
|
-
this.tileLoadedEvent.raiseEvent({ tileId, rtree });
|
|
281
|
-
this._trackFeatures(features, tileId);
|
|
282
|
-
this.rtreeCache.set(tileId, rtree);
|
|
283
|
-
return rtree;
|
|
284
|
-
}).catch(() => {
|
|
285
|
-
// Discussion, do we want to go on on tileLoadFailure ?
|
|
286
|
-
this.getLogger().warning(`Could not load Tile ${tileId}`);
|
|
287
|
-
const rtree = new RBush();
|
|
288
|
-
this.rtreeCache.set(tileId, rtree);
|
|
289
|
-
return rtree;
|
|
290
|
-
});
|
|
291
338
|
|
|
292
339
|
this.cache.get(baseLevel).set(tileId, rtreePromise);
|
|
293
340
|
if (this.cache.get(baseLevel).canExpireCache()) {
|
|
294
|
-
return Promise.all([
|
|
341
|
+
return Promise.all([
|
|
342
|
+
rtreePromise,
|
|
343
|
+
this._removeLastTileFromCache(baseLevel),
|
|
344
|
+
]);
|
|
295
345
|
}
|
|
296
346
|
return rtreePromise;
|
|
297
347
|
}
|
|
@@ -309,7 +359,10 @@ class TileProvider extends VcsObject {
|
|
|
309
359
|
if (rtree) {
|
|
310
360
|
this.rtreeCache.delete(tileIdToRemove);
|
|
311
361
|
setTimeout(() => {
|
|
312
|
-
this._unTrackFeatures(
|
|
362
|
+
this._unTrackFeatures(
|
|
363
|
+
rtree.all().map((item) => item.value),
|
|
364
|
+
tileIdToRemove,
|
|
365
|
+
);
|
|
313
366
|
rtree.clear();
|
|
314
367
|
}, 0);
|
|
315
368
|
}
|
|
@@ -335,7 +388,9 @@ class TileProvider extends VcsObject {
|
|
|
335
388
|
}
|
|
336
389
|
}
|
|
337
390
|
const baseLevel = this.getBaseLevel(currentLevel);
|
|
338
|
-
return baseLevel === undefined
|
|
391
|
+
return baseLevel === undefined
|
|
392
|
+
? this.baseLevels[this.baseLevels.length - 1]
|
|
393
|
+
: baseLevel;
|
|
339
394
|
}
|
|
340
395
|
|
|
341
396
|
/**
|
|
@@ -365,17 +420,25 @@ class TileProvider extends VcsObject {
|
|
|
365
420
|
|
|
366
421
|
/**
|
|
367
422
|
* @param {number} baseLevel
|
|
368
|
-
* @param {import("@vcmap/
|
|
423
|
+
* @param {import("@vcmap-cesium/engine").Cartographic} tileCenter
|
|
369
424
|
* @returns {Promise<import("rbush").default<tileProviderRTreeEntry>|null>}
|
|
370
425
|
* @private
|
|
371
426
|
*/
|
|
372
427
|
async _getRtreeForBaseTile(baseLevel, tileCenter) {
|
|
373
428
|
const baseTile = this.tilingScheme.positionToTileXY(tileCenter, baseLevel);
|
|
374
|
-
const baseTileCacheKey = this.getCacheKey(
|
|
429
|
+
const baseTileCacheKey = this.getCacheKey(
|
|
430
|
+
baseTile.x,
|
|
431
|
+
baseTile.y,
|
|
432
|
+
baseLevel,
|
|
433
|
+
);
|
|
375
434
|
if (this.cache.has(baseLevel)) {
|
|
376
435
|
if (!this.cache.get(baseLevel).containsKey(baseTileCacheKey)) {
|
|
377
436
|
const featuresPromise = this.loader(baseTile.x, baseTile.y, baseLevel);
|
|
378
|
-
this._addTilePromiseToCache(
|
|
437
|
+
this._addTilePromiseToCache(
|
|
438
|
+
featuresPromise,
|
|
439
|
+
baseLevel,
|
|
440
|
+
baseTileCacheKey,
|
|
441
|
+
);
|
|
379
442
|
}
|
|
380
443
|
return this.cache.get(baseLevel).get(baseTileCacheKey);
|
|
381
444
|
}
|
|
@@ -394,16 +457,24 @@ class TileProvider extends VcsObject {
|
|
|
394
457
|
const extent = createOrUpdateFromCoordinate(coordinate);
|
|
395
458
|
buffer(extent, resolution, extent);
|
|
396
459
|
const wgs84Coordinate = mercatorToWgs84Transformer(coordinate);
|
|
397
|
-
const cartographic = Cartographic.fromDegrees(
|
|
398
|
-
|
|
460
|
+
const cartographic = Cartographic.fromDegrees(
|
|
461
|
+
wgs84Coordinate[0],
|
|
462
|
+
wgs84Coordinate[1],
|
|
463
|
+
);
|
|
464
|
+
const baseLevel = this.getBaseLevelForResolution(
|
|
465
|
+
resolution,
|
|
466
|
+
cartographic.latitude,
|
|
467
|
+
);
|
|
399
468
|
const rtree = await this._getRtreeForBaseTile(baseLevel, cartographic);
|
|
400
469
|
if (rtree) {
|
|
401
|
-
const features = rtree
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
470
|
+
const features = rtree
|
|
471
|
+
.search({
|
|
472
|
+
minX: extent[0],
|
|
473
|
+
minY: extent[1],
|
|
474
|
+
maxX: extent[2],
|
|
475
|
+
maxY: extent[3],
|
|
476
|
+
})
|
|
477
|
+
.map((item) => item.value);
|
|
407
478
|
return features;
|
|
408
479
|
}
|
|
409
480
|
return [];
|
|
@@ -425,28 +496,45 @@ class TileProvider extends VcsObject {
|
|
|
425
496
|
const rtree = await this._getRtreeForBaseTile(baseLevel, tileCenter);
|
|
426
497
|
if (rtree) {
|
|
427
498
|
if (level === baseLevel) {
|
|
428
|
-
return rtree.all().map(item => item.value);
|
|
499
|
+
return rtree.all().map((item) => item.value);
|
|
429
500
|
} else {
|
|
430
501
|
const extent = rectangleToExtent(rectangle);
|
|
431
|
-
const features = rtree
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
502
|
+
const features = rtree
|
|
503
|
+
.search({
|
|
504
|
+
minX: extent[0],
|
|
505
|
+
minY: extent[1],
|
|
506
|
+
maxX: extent[2],
|
|
507
|
+
maxY: extent[3],
|
|
508
|
+
})
|
|
509
|
+
.map((item) => item.value);
|
|
437
510
|
return features;
|
|
438
511
|
}
|
|
439
512
|
}
|
|
440
|
-
} else if (
|
|
513
|
+
} else if (
|
|
514
|
+
this.allowTileAggregation &&
|
|
515
|
+
this.baseLevels[this.baseLevels.length - 1] - level <= 2
|
|
516
|
+
) {
|
|
441
517
|
// tile aggregation, only allowed for 2 levels
|
|
442
518
|
const childLevel = level + 1;
|
|
443
519
|
const childNorth = x * 2;
|
|
444
520
|
const childWest = y * 2;
|
|
445
521
|
return [
|
|
446
|
-
...await this.getFeaturesForTile(childNorth, childWest, childLevel),
|
|
447
|
-
...await this.getFeaturesForTile(
|
|
448
|
-
|
|
449
|
-
|
|
522
|
+
...(await this.getFeaturesForTile(childNorth, childWest, childLevel)),
|
|
523
|
+
...(await this.getFeaturesForTile(
|
|
524
|
+
childNorth + 1,
|
|
525
|
+
childWest,
|
|
526
|
+
childLevel,
|
|
527
|
+
)),
|
|
528
|
+
...(await this.getFeaturesForTile(
|
|
529
|
+
childNorth + 1,
|
|
530
|
+
childWest + 1,
|
|
531
|
+
childLevel,
|
|
532
|
+
)),
|
|
533
|
+
...(await this.getFeaturesForTile(
|
|
534
|
+
childNorth,
|
|
535
|
+
childWest + 1,
|
|
536
|
+
childLevel,
|
|
537
|
+
)),
|
|
450
538
|
];
|
|
451
539
|
}
|
|
452
540
|
return [];
|
|
@@ -462,9 +550,16 @@ class TileProvider extends VcsObject {
|
|
|
462
550
|
async getFeaturesForExtent(extent, level) {
|
|
463
551
|
let usedLevel = level != null ? level : this.baseLevels[0];
|
|
464
552
|
usedLevel = this.getBaseLevel(usedLevel);
|
|
465
|
-
const [minx, miny, maxx, maxy] =
|
|
466
|
-
|
|
467
|
-
const
|
|
553
|
+
const [minx, miny, maxx, maxy] =
|
|
554
|
+
extent.getCoordinatesInProjection(wgs84Projection);
|
|
555
|
+
const topLeft = this.tilingScheme.positionToTileXY(
|
|
556
|
+
Cartographic.fromDegrees(minx, maxy),
|
|
557
|
+
usedLevel,
|
|
558
|
+
);
|
|
559
|
+
const bottomRight = this.tilingScheme.positionToTileXY(
|
|
560
|
+
Cartographic.fromDegrees(maxx, miny),
|
|
561
|
+
usedLevel,
|
|
562
|
+
);
|
|
468
563
|
const tileCoordinates = [];
|
|
469
564
|
for (let { x } = topLeft; x <= bottomRight.x; x++) {
|
|
470
565
|
for (let { y } = topLeft; y <= bottomRight.y; y++) {
|
|
@@ -472,14 +567,15 @@ class TileProvider extends VcsObject {
|
|
|
472
567
|
}
|
|
473
568
|
}
|
|
474
569
|
|
|
475
|
-
const features = await Promise.all(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
.
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
570
|
+
const features = await Promise.all(
|
|
571
|
+
tileCoordinates.map(([x, y]) => this.getFeaturesForTile(x, y, usedLevel)),
|
|
572
|
+
);
|
|
573
|
+
const mercatorExtent =
|
|
574
|
+
extent.getCoordinatesInProjection(mercatorProjection);
|
|
575
|
+
return features.flat().filter((f) => {
|
|
576
|
+
const geometry = f.getGeometry();
|
|
577
|
+
return geometry && geometry.intersectsExtent(mercatorExtent);
|
|
578
|
+
});
|
|
483
579
|
}
|
|
484
580
|
|
|
485
581
|
/**
|
|
@@ -489,12 +585,15 @@ class TileProvider extends VcsObject {
|
|
|
489
585
|
*/
|
|
490
586
|
forEachFeature(callback) {
|
|
491
587
|
this.rtreeCache.forEach((rtree) => {
|
|
492
|
-
rtree
|
|
588
|
+
rtree
|
|
589
|
+
.all()
|
|
590
|
+
.map((item) => item.value)
|
|
591
|
+
.forEach(callback);
|
|
493
592
|
});
|
|
494
593
|
}
|
|
495
594
|
|
|
496
595
|
/**
|
|
497
|
-
* Public API to load features from a source (for example a rest API, or
|
|
596
|
+
* Public API to load features from a source (for example a rest API, or WfsLayer)
|
|
498
597
|
*
|
|
499
598
|
* Can be used to write custom TileProvider to provide an interface to a "feature Source"
|
|
500
599
|
* Can also be used to manipulate the features, for example setting an ID Prefix or filter the features.
|
|
@@ -538,13 +637,24 @@ class TileProvider extends VcsObject {
|
|
|
538
637
|
config.tileCacheSize = this.tileCacheSize;
|
|
539
638
|
}
|
|
540
639
|
|
|
541
|
-
if (
|
|
640
|
+
if (
|
|
641
|
+
!(
|
|
642
|
+
this.baseLevels.length === defaultOptions.baseLevels.length &&
|
|
643
|
+
this.baseLevels.every((level) =>
|
|
644
|
+
defaultOptions.baseLevels.includes(level),
|
|
645
|
+
)
|
|
646
|
+
)
|
|
647
|
+
) {
|
|
542
648
|
config.baseLevels = this.baseLevels.slice();
|
|
543
649
|
}
|
|
544
650
|
|
|
545
651
|
if (defaultOptions.trackFeaturesToTiles !== this.trackFeaturesToTiles) {
|
|
546
652
|
config.trackFeaturesToTiles = this.trackFeaturesToTiles;
|
|
547
653
|
}
|
|
654
|
+
|
|
655
|
+
if (defaultOptions.allowTileAggregation !== this.allowTileAggregation) {
|
|
656
|
+
config.allowTileAggregation = this.allowTileAggregation;
|
|
657
|
+
}
|
|
548
658
|
return config;
|
|
549
659
|
}
|
|
550
660
|
|
|
@@ -582,3 +692,4 @@ class TileProvider extends VcsObject {
|
|
|
582
692
|
}
|
|
583
693
|
|
|
584
694
|
export default TileProvider;
|
|
695
|
+
tileProviderClassRegistry.registerClass(TileProvider.className, TileProvider);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Math as CesiumMath, Rectangle } from '@vcmap/cesium';
|
|
1
|
+
import { Math as CesiumMath, Rectangle } from '@vcmap-cesium/engine';
|
|
3
2
|
import { parseGeoJSON } from '../geojsonHelpers.js';
|
|
4
3
|
import TileProvider from './tileProvider.js';
|
|
5
|
-
import {
|
|
4
|
+
import { requestJson } from '../../util/fetch.js';
|
|
5
|
+
import { tileProviderClassRegistry } from '../../classRegistry.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {TileProviderOptions} URLTemplateTileProviderOptions
|
|
@@ -13,16 +13,17 @@ import { getCurrentLocale } from '../../util/locale.js';
|
|
|
13
13
|
/**
|
|
14
14
|
* replaces {x}, {y}, {z} with the x, y, z tiling coordinates
|
|
15
15
|
* replaces {minx}, {miny}, {maxx}, {maxy} with extent of the tile if tilingExtent is provided
|
|
16
|
-
* replaces {locale} with the
|
|
16
|
+
* replaces {locale} with the given locale
|
|
17
17
|
*
|
|
18
18
|
* @param {string} url
|
|
19
19
|
* @param {number} x
|
|
20
20
|
* @param {number} y
|
|
21
21
|
* @param {number} z
|
|
22
|
-
* @param {import("@vcmap/
|
|
22
|
+
* @param {import("@vcmap-cesium/engine").Rectangle=} tilingExtent
|
|
23
|
+
* @param {string=} locale
|
|
23
24
|
* @returns {string}
|
|
24
25
|
*/
|
|
25
|
-
export function getURL(url, x, y, z, tilingExtent) {
|
|
26
|
+
export function getURL(url, x, y, z, tilingExtent, locale = 'en') {
|
|
26
27
|
let replacedURL = url;
|
|
27
28
|
if (tilingExtent) {
|
|
28
29
|
const southwest = Rectangle.southwest(tilingExtent);
|
|
@@ -42,19 +43,18 @@ export function getURL(url, x, y, z, tilingExtent) {
|
|
|
42
43
|
.replace(/\{x\}/, String(x))
|
|
43
44
|
.replace(/\{y\}/, String(y))
|
|
44
45
|
.replace(/\{z\}/, String(z))
|
|
45
|
-
.replace(/\{locale\}/,
|
|
46
|
+
.replace(/\{locale\}/, locale);
|
|
46
47
|
return replacedURL;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
|
-
* TileProvider loads
|
|
51
|
+
* TileProvider loads GeojsonLayer from the provided URL. The URL has placeholders:
|
|
51
52
|
* the extent in latitude/longitude via: {minx}, {miny}, {maxx}, {maxy}
|
|
52
53
|
* tile Coordinates in x, y, z(level) via: {x}, {y}, {z}
|
|
53
54
|
* {locale} can be used to request locale aware content.
|
|
54
55
|
*
|
|
55
56
|
* @class
|
|
56
57
|
* @extends {TileProvider}
|
|
57
|
-
* @export
|
|
58
58
|
* @api
|
|
59
59
|
*/
|
|
60
60
|
class URLTemplateTileProvider extends TileProvider {
|
|
@@ -62,7 +62,9 @@ class URLTemplateTileProvider extends TileProvider {
|
|
|
62
62
|
* @readonly
|
|
63
63
|
* @returns {string}
|
|
64
64
|
*/
|
|
65
|
-
static get className() {
|
|
65
|
+
static get className() {
|
|
66
|
+
return 'URLTemplateTileProvider';
|
|
67
|
+
}
|
|
66
68
|
|
|
67
69
|
/**
|
|
68
70
|
* @returns {URLTemplateTileProviderOptions}
|
|
@@ -87,6 +89,26 @@ class URLTemplateTileProvider extends TileProvider {
|
|
|
87
89
|
this.url = options.url || defaultOptions.url;
|
|
88
90
|
}
|
|
89
91
|
|
|
92
|
+
/**
|
|
93
|
+
* @type {string}
|
|
94
|
+
*/
|
|
95
|
+
get locale() {
|
|
96
|
+
return super.locale;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* sets the locale and clears the Cache if the URL is a locale aware Object.
|
|
101
|
+
* @param {string} value
|
|
102
|
+
*/
|
|
103
|
+
set locale(value) {
|
|
104
|
+
if (this.locale !== value) {
|
|
105
|
+
super.locale = value;
|
|
106
|
+
if (this.url.includes('{locale}')) {
|
|
107
|
+
this.clearCache();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
90
112
|
/**
|
|
91
113
|
* @inheritDoc
|
|
92
114
|
* @param {number} x
|
|
@@ -96,11 +118,30 @@ class URLTemplateTileProvider extends TileProvider {
|
|
|
96
118
|
*/
|
|
97
119
|
async loader(x, y, z) {
|
|
98
120
|
const rectangle = this.tilingScheme.tileXYToRectangle(x, y, z);
|
|
99
|
-
const url = getURL(this.url, x, y, z, rectangle);
|
|
100
|
-
const
|
|
101
|
-
const { features } = parseGeoJSON(
|
|
121
|
+
const url = getURL(this.url, x, y, z, rectangle, this.locale);
|
|
122
|
+
const data = await requestJson(url);
|
|
123
|
+
const { features } = parseGeoJSON(data, { dynamicStyle: true });
|
|
102
124
|
return features;
|
|
103
125
|
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @returns {URLTemplateTileProviderOptions}
|
|
129
|
+
*/
|
|
130
|
+
toJSON() {
|
|
131
|
+
const config = /** @type {URLTemplateTileProviderOptions} */ (
|
|
132
|
+
super.toJSON()
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
if (this.url) {
|
|
136
|
+
config.url = this.url;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return config;
|
|
140
|
+
}
|
|
104
141
|
}
|
|
105
142
|
|
|
106
143
|
export default URLTemplateTileProvider;
|
|
144
|
+
tileProviderClassRegistry.registerClass(
|
|
145
|
+
URLTemplateTileProvider.className,
|
|
146
|
+
URLTemplateTileProvider,
|
|
147
|
+
);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import RasterLayer from './rasterLayer.js';
|
|
2
|
-
import
|
|
3
|
-
import CesiumMap from '../
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
2
|
+
import OpenlayersMap from '../map/openlayersMap.js';
|
|
3
|
+
import CesiumMap from '../map/cesiumMap.js';
|
|
4
|
+
import TmsOpenlayersImpl from './openlayers/tmsOpenlayersImpl.js';
|
|
5
|
+
import TmsCesiumImpl from './cesium/tmsCesiumImpl.js';
|
|
6
|
+
import { layerClassRegistry } from '../classRegistry.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {RasterLayerOptions} TMSOptions
|
|
@@ -19,14 +19,15 @@ import { VcsClassRegistry } from '../classRegistry.js';
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* TmsLayer Layer
|
|
23
23
|
* @class
|
|
24
|
-
* @export
|
|
25
24
|
* @extends {RasterLayer}
|
|
26
25
|
* @api stable
|
|
27
26
|
*/
|
|
28
|
-
class
|
|
29
|
-
static get className() {
|
|
27
|
+
class TMSLayer extends RasterLayer {
|
|
28
|
+
static get className() {
|
|
29
|
+
return 'TMSLayer';
|
|
30
|
+
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* @returns {TMSOptions}
|
|
@@ -44,20 +45,19 @@ class TMS extends RasterLayer {
|
|
|
44
45
|
* @param {TMSOptions} options
|
|
45
46
|
*/
|
|
46
47
|
constructor(options) {
|
|
47
|
-
const defaultOptions =
|
|
48
|
+
const defaultOptions = TMSLayer.getDefaultOptions();
|
|
48
49
|
options.tilingSchema = options.tilingSchema || defaultOptions.tilingSchema;
|
|
49
50
|
super(options);
|
|
50
51
|
|
|
51
|
-
this._supportedMaps = [
|
|
52
|
-
Openlayers.className,
|
|
53
|
-
CesiumMap.className,
|
|
54
|
-
];
|
|
52
|
+
this._supportedMaps = [OpenlayersMap.className, CesiumMap.className];
|
|
55
53
|
|
|
56
54
|
/** @type {?string} */
|
|
57
55
|
this.format = options.format || defaultOptions.format;
|
|
58
56
|
|
|
59
57
|
/** @type {import("ol/size").Size} */
|
|
60
|
-
this.tileSize = Array.isArray(options.tileSize)
|
|
58
|
+
this.tileSize = Array.isArray(options.tileSize)
|
|
59
|
+
? options.tileSize.slice()
|
|
60
|
+
: defaultOptions.tileSize;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -75,15 +75,15 @@ class TMS extends RasterLayer {
|
|
|
75
75
|
/**
|
|
76
76
|
* @inheritDoc
|
|
77
77
|
* @param {import("@vcmap/core").VcsMap} map
|
|
78
|
-
* @returns {Array<
|
|
78
|
+
* @returns {Array<TmsOpenlayersImpl|TmsCesiumImpl>}
|
|
79
79
|
*/
|
|
80
80
|
createImplementationsForMap(map) {
|
|
81
|
-
if (map instanceof
|
|
82
|
-
return [new
|
|
81
|
+
if (map instanceof OpenlayersMap) {
|
|
82
|
+
return [new TmsOpenlayersImpl(map, this.getImplementationOptions())];
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
if (map instanceof CesiumMap) {
|
|
86
|
-
return [new
|
|
86
|
+
return [new TmsCesiumImpl(map, this.getImplementationOptions())];
|
|
87
87
|
}
|
|
88
88
|
return [];
|
|
89
89
|
}
|
|
@@ -94,7 +94,7 @@ class TMS extends RasterLayer {
|
|
|
94
94
|
*/
|
|
95
95
|
toJSON() {
|
|
96
96
|
const config = /** @type {TMSOptions} */ (super.toJSON());
|
|
97
|
-
const defaultOptions =
|
|
97
|
+
const defaultOptions = TMSLayer.getDefaultOptions();
|
|
98
98
|
|
|
99
99
|
if (this.tilingSchema !== defaultOptions.tilingSchema) {
|
|
100
100
|
config.tilingSchema = this.tilingSchema;
|
|
@@ -117,5 +117,5 @@ class TMS extends RasterLayer {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
export default
|
|
120
|
+
layerClassRegistry.registerClass(TMSLayer.className, TMSLayer);
|
|
121
|
+
export default TMSLayer;
|