@vcmap/core 5.0.0-rc.0
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 +21 -0
- package/README.md +44 -0
- package/build/postinstall.js +44 -0
- package/index.js +139 -0
- package/package.json +92 -0
- package/src/cesium/cesium3DTileFeature.js +9 -0
- package/src/cesium/cesium3DTilePointFeature.js +9 -0
- package/src/cesium/cesiumVcsCameraPrimitive.js +146 -0
- package/src/cesium/wallpaperMaterial.js +64 -0
- package/src/ol/feature.js +47 -0
- package/src/ol/geom/circle.js +24 -0
- package/src/ol/geom/geometryCollection.js +33 -0
- package/src/ol/render/canvas/canvasTileRenderer.js +179 -0
- package/src/ol/source/ClusterEnhancedVectorSource.js +39 -0
- package/src/ol/source/VcsCluster.js +37 -0
- package/src/vcs/vcm/classRegistry.js +106 -0
- package/src/vcs/vcm/event/vcsEvent.js +89 -0
- package/src/vcs/vcm/globalCollections.js +11 -0
- package/src/vcs/vcm/interaction/abstractInteraction.js +149 -0
- package/src/vcs/vcm/interaction/coordinateAtPixel.js +102 -0
- package/src/vcs/vcm/interaction/eventHandler.js +425 -0
- package/src/vcs/vcm/interaction/featureAtPixelInteraction.js +286 -0
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +54 -0
- package/src/vcs/vcm/interaction/interactionChain.js +124 -0
- package/src/vcs/vcm/interaction/interactionType.js +114 -0
- package/src/vcs/vcm/layer/buildings.js +17 -0
- package/src/vcs/vcm/layer/cesium/cesiumTilesetCesium.js +359 -0
- package/src/vcs/vcm/layer/cesium/clusterContext.js +95 -0
- package/src/vcs/vcm/layer/cesium/dataSourceCesium.js +171 -0
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +29 -0
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +58 -0
- package/src/vcs/vcm/layer/cesium/rasterLayerCesium.js +110 -0
- package/src/vcs/vcm/layer/cesium/singleImageCesium.js +49 -0
- package/src/vcs/vcm/layer/cesium/terrainCesium.js +80 -0
- package/src/vcs/vcm/layer/cesium/tmsCesium.js +54 -0
- package/src/vcs/vcm/layer/cesium/vectorCesium.js +255 -0
- package/src/vcs/vcm/layer/cesium/vectorContext.js +167 -0
- package/src/vcs/vcm/layer/cesium/vectorRasterTileCesium.js +116 -0
- package/src/vcs/vcm/layer/cesium/vectorTileImageryProvider.js +246 -0
- package/src/vcs/vcm/layer/cesium/wmsCesium.js +71 -0
- package/src/vcs/vcm/layer/cesium/wmtsCesium.js +101 -0
- package/src/vcs/vcm/layer/cesium/x3dmHelper.js +22 -0
- package/src/vcs/vcm/layer/cesiumTileset.js +376 -0
- package/src/vcs/vcm/layer/czml.js +141 -0
- package/src/vcs/vcm/layer/dataSource.js +259 -0
- package/src/vcs/vcm/layer/featureLayer.js +261 -0
- package/src/vcs/vcm/layer/featureStore.js +647 -0
- package/src/vcs/vcm/layer/featureStoreChanges.js +360 -0
- package/src/vcs/vcm/layer/featureStoreState.js +19 -0
- package/src/vcs/vcm/layer/featureVisibility.js +435 -0
- package/src/vcs/vcm/layer/geojson.js +185 -0
- package/src/vcs/vcm/layer/geojsonHelpers.js +450 -0
- package/src/vcs/vcm/layer/globalHider.js +157 -0
- package/src/vcs/vcm/layer/layer.js +752 -0
- package/src/vcs/vcm/layer/layerImplementation.js +102 -0
- package/src/vcs/vcm/layer/layerState.js +17 -0
- package/src/vcs/vcm/layer/layerSymbols.js +6 -0
- package/src/vcs/vcm/layer/oblique/layerOblique.js +76 -0
- package/src/vcs/vcm/layer/oblique/obliqueHelpers.js +175 -0
- package/src/vcs/vcm/layer/oblique/vectorOblique.js +469 -0
- package/src/vcs/vcm/layer/openStreetMap.js +194 -0
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +79 -0
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +27 -0
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +121 -0
- package/src/vcs/vcm/layer/openlayers/singleImageOpenlayers.js +49 -0
- package/src/vcs/vcm/layer/openlayers/tileDebugOpenlayers.js +39 -0
- package/src/vcs/vcm/layer/openlayers/tmsOpenlayers.js +62 -0
- package/src/vcs/vcm/layer/openlayers/vectorOpenlayers.js +118 -0
- package/src/vcs/vcm/layer/openlayers/vectorTileOpenlayers.js +177 -0
- package/src/vcs/vcm/layer/openlayers/wmsOpenlayers.js +55 -0
- package/src/vcs/vcm/layer/openlayers/wmtsOpenlayers.js +141 -0
- package/src/vcs/vcm/layer/pointCloud.js +162 -0
- package/src/vcs/vcm/layer/rasterLayer.js +294 -0
- package/src/vcs/vcm/layer/singleImage.js +119 -0
- package/src/vcs/vcm/layer/terrain.js +122 -0
- package/src/vcs/vcm/layer/terrainHelpers.js +123 -0
- package/src/vcs/vcm/layer/tileLoadedHelper.js +72 -0
- package/src/vcs/vcm/layer/tileProvider/mvtTileProvider.js +104 -0
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +67 -0
- package/src/vcs/vcm/layer/tileProvider/tileProvider.js +584 -0
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +28 -0
- package/src/vcs/vcm/layer/tileProvider/urlTemplateTileProvider.js +106 -0
- package/src/vcs/vcm/layer/tms.js +121 -0
- package/src/vcs/vcm/layer/vector.js +632 -0
- package/src/vcs/vcm/layer/vectorHelpers.js +206 -0
- package/src/vcs/vcm/layer/vectorProperties.js +1391 -0
- package/src/vcs/vcm/layer/vectorSymbols.js +40 -0
- package/src/vcs/vcm/layer/vectorTile.js +480 -0
- package/src/vcs/vcm/layer/wfs.js +165 -0
- package/src/vcs/vcm/layer/wms.js +270 -0
- package/src/vcs/vcm/layer/wmsHelpers.js +65 -0
- package/src/vcs/vcm/layer/wmts.js +235 -0
- package/src/vcs/vcm/maps/baseOLMap.js +257 -0
- package/src/vcs/vcm/maps/cameraLimiter.js +219 -0
- package/src/vcs/vcm/maps/cesium.js +1192 -0
- package/src/vcs/vcm/maps/map.js +511 -0
- package/src/vcs/vcm/maps/mapState.js +17 -0
- package/src/vcs/vcm/maps/oblique.js +536 -0
- package/src/vcs/vcm/maps/openlayers.js +205 -0
- package/src/vcs/vcm/object.js +92 -0
- package/src/vcs/vcm/oblique/ObliqueCollection.js +572 -0
- package/src/vcs/vcm/oblique/ObliqueDataSet.js +357 -0
- package/src/vcs/vcm/oblique/ObliqueImage.js +247 -0
- package/src/vcs/vcm/oblique/ObliqueImageMeta.js +126 -0
- package/src/vcs/vcm/oblique/ObliqueProvider.js +433 -0
- package/src/vcs/vcm/oblique/ObliqueView.js +130 -0
- package/src/vcs/vcm/oblique/ObliqueViewDirection.js +40 -0
- package/src/vcs/vcm/oblique/helpers.js +483 -0
- package/src/vcs/vcm/oblique/parseImageJson.js +248 -0
- package/src/vcs/vcm/util/clipping/clippingObject.js +386 -0
- package/src/vcs/vcm/util/clipping/clippingObjectManager.js +312 -0
- package/src/vcs/vcm/util/clipping/clippingPlaneHelper.js +413 -0
- package/src/vcs/vcm/util/collection.js +193 -0
- package/src/vcs/vcm/util/dateTime.js +60 -0
- package/src/vcs/vcm/util/exclusiveManager.js +135 -0
- package/src/vcs/vcm/util/extent.js +124 -0
- package/src/vcs/vcm/util/featureProvider/abstractFeatureProvider.js +196 -0
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +51 -0
- package/src/vcs/vcm/util/featureProvider/featureProviderSymbols.js +11 -0
- package/src/vcs/vcm/util/featureProvider/tileProviderFeatureProvider.js +62 -0
- package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +280 -0
- package/src/vcs/vcm/util/featureconverter/circleToCesium.js +215 -0
- package/src/vcs/vcm/util/featureconverter/convert.js +83 -0
- package/src/vcs/vcm/util/featureconverter/extent3d.js +154 -0
- package/src/vcs/vcm/util/featureconverter/featureconverterHelper.js +591 -0
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +171 -0
- package/src/vcs/vcm/util/featureconverter/pointToCesium.js +359 -0
- package/src/vcs/vcm/util/featureconverter/polygonToCesium.js +229 -0
- package/src/vcs/vcm/util/geometryHelpers.js +172 -0
- package/src/vcs/vcm/util/indexedCollection.js +158 -0
- package/src/vcs/vcm/util/isMobile.js +12 -0
- package/src/vcs/vcm/util/layerCollection.js +216 -0
- package/src/vcs/vcm/util/locale.js +53 -0
- package/src/vcs/vcm/util/mapCollection.js +363 -0
- package/src/vcs/vcm/util/math.js +71 -0
- package/src/vcs/vcm/util/projection.js +348 -0
- package/src/vcs/vcm/util/splitScreen.js +233 -0
- package/src/vcs/vcm/util/style/declarativeStyleItem.js +631 -0
- package/src/vcs/vcm/util/style/shapesCategory.js +67 -0
- package/src/vcs/vcm/util/style/styleFactory.js +48 -0
- package/src/vcs/vcm/util/style/styleHelpers.js +555 -0
- package/src/vcs/vcm/util/style/styleItem.js +226 -0
- package/src/vcs/vcm/util/style/vectorStyleItem.js +927 -0
- package/src/vcs/vcm/util/style/writeStyle.js +48 -0
- package/src/vcs/vcm/util/urlHelpers.js +16 -0
- package/src/vcs/vcm/util/viewpoint.js +333 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { check } from '@vcsuite/check';
|
|
2
|
+
import { parseBoolean } from '@vcsuite/parsers';
|
|
3
|
+
import RasterLayer from './rasterLayer.js';
|
|
4
|
+
import WMSFeatureProvider from '../util/featureProvider/wmsFeatureProvider.js';
|
|
5
|
+
import CesiumMap from '../maps/cesium.js';
|
|
6
|
+
import WMSCesium from './cesium/wmsCesium.js';
|
|
7
|
+
import Openlayers from '../maps/openlayers.js';
|
|
8
|
+
import WMSOpenlayers from './openlayers/wmsOpenlayers.js';
|
|
9
|
+
import Extent from '../util/extent.js';
|
|
10
|
+
import { VcsClassRegistry } from '../classRegistry.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {RasterLayerImplementationOptions} WMSImplementationOptions
|
|
14
|
+
* @property {Object<string, *>} parameters
|
|
15
|
+
* @property {boolean} highResolution
|
|
16
|
+
* @property {import("ol/size").Size} tileSize
|
|
17
|
+
* @property {string} version
|
|
18
|
+
* @api
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {RasterLayerOptions} WMSOptions
|
|
23
|
+
* @property {string|undefined} layers - string with comma separated names of the layers to display
|
|
24
|
+
* @property {string} [version='1.1.1'] - WMS version (either 1.1.1 (default) or 1.3.0)
|
|
25
|
+
* @property {Object<string, *>|string|undefined} parameters - key value pair of additional WMS parameters, url query notation possible
|
|
26
|
+
* @property {WMSFeatureProviderOptions|undefined} featureInfo - whether this layer should send getFeatureInfo requests to the service when objects are clicked.
|
|
27
|
+
* @property {import("ol/size").Size} [tileSize=[256,256]]
|
|
28
|
+
* @property {boolean} [highResolution=false] - use higher resolution images (sofar only in 3D)
|
|
29
|
+
* @api
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* WMS layer for Cesium and Openlayers
|
|
34
|
+
* @class
|
|
35
|
+
* @export
|
|
36
|
+
* @extends {RasterLayer}
|
|
37
|
+
* @api stable
|
|
38
|
+
*/
|
|
39
|
+
class WMS extends RasterLayer {
|
|
40
|
+
static get className() { return 'vcs.vcm.layer.WMS'; }
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @returns {WMSOptions}
|
|
44
|
+
*/
|
|
45
|
+
static getDefaultOptions() {
|
|
46
|
+
return {
|
|
47
|
+
...RasterLayer.getDefaultOptions(),
|
|
48
|
+
version: '1.1.1',
|
|
49
|
+
parameters: undefined,
|
|
50
|
+
featureInfo: undefined,
|
|
51
|
+
tileSize: /** @type {import("ol/size").Size} */ ([256, 256]),
|
|
52
|
+
highResolution: false,
|
|
53
|
+
layers: '',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {WMSOptions} options
|
|
59
|
+
*/
|
|
60
|
+
constructor(options) {
|
|
61
|
+
super(options);
|
|
62
|
+
const defaultOptions = WMS.getDefaultOptions();
|
|
63
|
+
|
|
64
|
+
/** @type {string} */
|
|
65
|
+
this.version = options.version || defaultOptions.version;
|
|
66
|
+
|
|
67
|
+
/** @type {Object<string, *>} */
|
|
68
|
+
this.parameters = {};
|
|
69
|
+
if (options.parameters) {
|
|
70
|
+
let parsedParameters;
|
|
71
|
+
if (typeof options.parameters === 'string') {
|
|
72
|
+
parsedParameters = Object.fromEntries(new URLSearchParams(options.parameters));
|
|
73
|
+
} else if (options.parameters instanceof Object) {
|
|
74
|
+
parsedParameters = options.parameters;
|
|
75
|
+
}
|
|
76
|
+
Object.keys(parsedParameters).forEach((key) => {
|
|
77
|
+
this.parameters[key.toUpperCase()] = parsedParameters[key];
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (this.parameters.TRANSPARENT == null) {
|
|
82
|
+
this.parameters.TRANSPARENT = false;
|
|
83
|
+
}
|
|
84
|
+
if (this.version) {
|
|
85
|
+
this.parameters.VERSION = this.version;
|
|
86
|
+
}
|
|
87
|
+
this.parameters.LAYERS = options.layers || defaultOptions.layers;
|
|
88
|
+
|
|
89
|
+
/** @type {import("ol/size").Size} */
|
|
90
|
+
this.tileSize = options.tileSize || defaultOptions.tileSize;
|
|
91
|
+
/** @type {boolean} */
|
|
92
|
+
this.highResolution = parseBoolean(options.highResolution, defaultOptions.highResolution);
|
|
93
|
+
/**
|
|
94
|
+
* @type {WMSFeatureProviderOptions}
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
this._featureInfoOptions = options.featureInfo || defaultOptions.featureInfo;
|
|
98
|
+
this._supportedMaps = [
|
|
99
|
+
CesiumMap.className,
|
|
100
|
+
Openlayers.className,
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @inheritDoc
|
|
106
|
+
* @returns {Promise<void>}
|
|
107
|
+
*/
|
|
108
|
+
initialize() {
|
|
109
|
+
if (!this.initialized) {
|
|
110
|
+
this._setFeatureProvider();
|
|
111
|
+
}
|
|
112
|
+
return super.initialize();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Sets a FeatureProvider if provided with featureInfo options
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
_setFeatureProvider() {
|
|
120
|
+
if (this._featureInfoOptions) {
|
|
121
|
+
const options = {
|
|
122
|
+
url: this.url,
|
|
123
|
+
tilingSchema: this.tilingSchema,
|
|
124
|
+
maxLevel: this.maxLevel,
|
|
125
|
+
minLevel: this.minLevel,
|
|
126
|
+
tileSize: this.tileSize,
|
|
127
|
+
extent: this.extent,
|
|
128
|
+
parameters: this.parameters,
|
|
129
|
+
version: this.version,
|
|
130
|
+
...this._featureInfoOptions,
|
|
131
|
+
};
|
|
132
|
+
this.featureProvider = new WMSFeatureProvider(this.name, options);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async reload() {
|
|
137
|
+
if (this.featureProvider && this._featureInfoOptions) {
|
|
138
|
+
this.featureProvider.destroy();
|
|
139
|
+
this._setFeatureProvider();
|
|
140
|
+
}
|
|
141
|
+
return super.reload();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @returns {WMSImplementationOptions}
|
|
146
|
+
*/
|
|
147
|
+
getImplementationOptions() {
|
|
148
|
+
return {
|
|
149
|
+
...super.getImplementationOptions(),
|
|
150
|
+
version: this.version,
|
|
151
|
+
parameters: this.parameters,
|
|
152
|
+
highResolution: this.highResolution,
|
|
153
|
+
tileSize: this.tileSize,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {import("@vcmap/core").VcsMap} map
|
|
159
|
+
* @returns {Array<WMSCesium|WMSOpenlayers>}
|
|
160
|
+
*/
|
|
161
|
+
createImplementationsForMap(map) {
|
|
162
|
+
if (map instanceof CesiumMap) {
|
|
163
|
+
return [new WMSCesium(map, this.getImplementationOptions())];
|
|
164
|
+
} else if (map instanceof Openlayers) {
|
|
165
|
+
return [new WMSOpenlayers(map, this.getImplementationOptions())];
|
|
166
|
+
}
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Sets the layers to request from the WMS
|
|
172
|
+
* @param {string|Array<string>} layers - a layer name or an array of layer names
|
|
173
|
+
* @returns {Promise<void>}
|
|
174
|
+
* @api stable
|
|
175
|
+
*/
|
|
176
|
+
async setLayers(layers) {
|
|
177
|
+
check(layers, [String, [String]]);
|
|
178
|
+
const layersArray = Array.isArray(layers) ? layers : [layers];
|
|
179
|
+
this.parameters.LAYERS = layersArray.join(',');
|
|
180
|
+
await this.forceRedraw();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Returns the currently active layers
|
|
185
|
+
* @returns {Array<string>}
|
|
186
|
+
* @api
|
|
187
|
+
*/
|
|
188
|
+
getLayers() {
|
|
189
|
+
return this.parameters.LAYERS ? this.parameters.LAYERS.split(',') : [];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @returns {WMSOptions}
|
|
194
|
+
*/
|
|
195
|
+
getConfigObject() {
|
|
196
|
+
const config = /** @type {WMSOptions} */ (super.getConfigObject());
|
|
197
|
+
const defaultOptions = WMS.getDefaultOptions();
|
|
198
|
+
|
|
199
|
+
if (this.parameters.LAYERS) {
|
|
200
|
+
config.layers = this.parameters.LAYERS;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (this.version !== defaultOptions.version) {
|
|
204
|
+
config.version = this.version;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const parameters = { ...this.parameters };
|
|
208
|
+
delete parameters.VERSION;
|
|
209
|
+
delete parameters.LAYERS;
|
|
210
|
+
|
|
211
|
+
if (parameters.TRANSPARENT === false) {
|
|
212
|
+
delete parameters.TRANSPARENT;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (Object.keys(parameters).length > 0) {
|
|
216
|
+
config.parameters = parameters;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (this.version !== defaultOptions.version) {
|
|
220
|
+
config.version = this.version;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (this.highResolution !== defaultOptions.highResolution) {
|
|
224
|
+
config.highResolution = this.highResolution;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (this.tileSize[0] !== defaultOptions.tileSize[0] || this.tileSize[1] !== defaultOptions.tileSize[1]) {
|
|
228
|
+
config.tileSize = /** @type {import("ol/size").Size} */ (this.tileSize.slice());
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (this.featureProvider && this.featureProvider instanceof WMSFeatureProvider) {
|
|
232
|
+
const featureInfoConfig = this.featureProvider.getConfigObject();
|
|
233
|
+
if (this.tileSize[0] === featureInfoConfig.tileSize[0] || this.tileSize[1] === featureInfoConfig.tileSize[1]) {
|
|
234
|
+
delete featureInfoConfig.tileSize;
|
|
235
|
+
}
|
|
236
|
+
if (Object.entries(this.parameters).every(([key, value]) => featureInfoConfig.parameters[key] === value)) {
|
|
237
|
+
delete featureInfoConfig.parameters;
|
|
238
|
+
}
|
|
239
|
+
if (
|
|
240
|
+
featureInfoConfig.extent &&
|
|
241
|
+
new Extent(/** @type {ExtentOptions} */ (featureInfoConfig.extent)).equals(this.extent)
|
|
242
|
+
) {
|
|
243
|
+
delete featureInfoConfig.extent;
|
|
244
|
+
}
|
|
245
|
+
if (this.url === featureInfoConfig.url) {
|
|
246
|
+
delete featureInfoConfig.url;
|
|
247
|
+
}
|
|
248
|
+
if (this.tilingSchema === featureInfoConfig.tilingSchema) {
|
|
249
|
+
delete featureInfoConfig.tilingSchema;
|
|
250
|
+
}
|
|
251
|
+
if (this.version === featureInfoConfig.version) {
|
|
252
|
+
delete featureInfoConfig.version;
|
|
253
|
+
}
|
|
254
|
+
if (this.minLevel === featureInfoConfig.minLevel) {
|
|
255
|
+
delete featureInfoConfig.minLevel;
|
|
256
|
+
}
|
|
257
|
+
if (this.maxLevel === featureInfoConfig.maxLevel) {
|
|
258
|
+
delete featureInfoConfig.maxLevel;
|
|
259
|
+
}
|
|
260
|
+
config.featureInfo = featureInfoConfig;
|
|
261
|
+
} else if (this._featureInfoOptions) {
|
|
262
|
+
config.featureInfo = this._featureInfoOptions;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return config;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
VcsClassRegistry.registerClass(WMS.className, WMS);
|
|
270
|
+
export default WMS;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import TileWMS from 'ol/source/TileWMS.js';
|
|
2
|
+
import { getTopLeft, getWidth } from 'ol/extent.js';
|
|
3
|
+
import TileGrid from 'ol/tilegrid/TileGrid.js';
|
|
4
|
+
import { mercatorProjection, wgs84Projection } from '../util/projection.js';
|
|
5
|
+
import { isSameOrigin } from '../util/urlHelpers.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} WMSSourceOptions
|
|
9
|
+
* @property {string} url
|
|
10
|
+
* @property {string} tilingSchema - either "geographic" or "mercator"
|
|
11
|
+
* @property {number} maxLevel
|
|
12
|
+
* @property {number} minLevel
|
|
13
|
+
* @property {import("ol/size").Size} tileSize
|
|
14
|
+
* @property {import("@vcmap/core").Extent|undefined} extent
|
|
15
|
+
* @property {Object<string, string>} parameters
|
|
16
|
+
* @property {string} version
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {WMSSourceOptions} options
|
|
21
|
+
* @returns {import("ol/source/TileWMS").default}
|
|
22
|
+
*/
|
|
23
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
24
|
+
export function getWMSSource(options) {
|
|
25
|
+
const projection = options.tilingSchema === 'geographic' ?
|
|
26
|
+
wgs84Projection :
|
|
27
|
+
mercatorProjection;
|
|
28
|
+
|
|
29
|
+
const projectionExtent = projection.proj.getExtent();
|
|
30
|
+
|
|
31
|
+
const width = getWidth(projectionExtent);
|
|
32
|
+
const size = options.tilingSchema === 'geographic' ? width / (options.tileSize[0] * 2) : width / options.tileSize[0];
|
|
33
|
+
const maxZoom = options.maxLevel + 1;
|
|
34
|
+
const resolutions = [];
|
|
35
|
+
for (let z = 0; z < maxZoom; ++z) {
|
|
36
|
+
// generate resolutions and matrixIds arrays for options WMTS
|
|
37
|
+
resolutions.push(size / (2 ** z));
|
|
38
|
+
}
|
|
39
|
+
const tilingOptions = {
|
|
40
|
+
origin: getTopLeft(projectionExtent),
|
|
41
|
+
resolutions,
|
|
42
|
+
tileSize: options.tileSize,
|
|
43
|
+
minZoom: options.minLevel,
|
|
44
|
+
};
|
|
45
|
+
if (options.extent && options.extent.isValid()) {
|
|
46
|
+
tilingOptions.extent = options.extent.getCoordinatesInProjection(projection);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const sourceOptions = {
|
|
50
|
+
url: options.url,
|
|
51
|
+
tileGrid: new TileGrid(tilingOptions),
|
|
52
|
+
params: options.parameters,
|
|
53
|
+
};
|
|
54
|
+
if (!isSameOrigin(options.url)) {
|
|
55
|
+
sourceOptions.crossOrigin = 'anonymous';
|
|
56
|
+
}
|
|
57
|
+
if (options.tilingSchema === 'geographic') {
|
|
58
|
+
if (options.version === '1.3.0') {
|
|
59
|
+
sourceOptions.projection = 'CRS:84';
|
|
60
|
+
} else {
|
|
61
|
+
sourceOptions.projection = 'EPSG:4326';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return new TileWMS(sourceOptions);
|
|
65
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { parseInteger } from '@vcsuite/parsers';
|
|
2
|
+
import { getLogger } from '@vcsuite/logger';
|
|
3
|
+
import RasterLayer from './rasterLayer.js';
|
|
4
|
+
import Openlayers from '../maps/openlayers.js';
|
|
5
|
+
import CesiumMap from '../maps/cesium.js';
|
|
6
|
+
import WMTSOpenlayers from './openlayers/wmtsOpenlayers.js';
|
|
7
|
+
import WMTSCesium from './cesium/wmtsCesium.js';
|
|
8
|
+
import { VcsClassRegistry } from '../classRegistry.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {RasterLayerOptions} WMTSOptions
|
|
12
|
+
* @property {string} layer
|
|
13
|
+
* @property {string|undefined} style
|
|
14
|
+
* @property {string|undefined} format
|
|
15
|
+
* @property {string|undefined} tileMatrixSetID
|
|
16
|
+
* @property {string|undefined} tileMatrixPrefix
|
|
17
|
+
* @property {Array<string>} matrixIds
|
|
18
|
+
* @property {number} [numberOfLevelZeroTilesX=1]
|
|
19
|
+
* @property {number} [numberOfLevelZeroTilesY=1]
|
|
20
|
+
* @property {Object|undefined} openlayersOptions
|
|
21
|
+
* @property {import("ol/size").Size} [tileSize=[256,256]]
|
|
22
|
+
* @api
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {RasterLayerImplementationOptions} WMTSImplementationOptions
|
|
27
|
+
* @property {string} layer
|
|
28
|
+
* @property {string} style
|
|
29
|
+
* @property {string} format
|
|
30
|
+
* @property {string} tileMatrixSetID
|
|
31
|
+
* @property {import("ol/size").Size} tileSize
|
|
32
|
+
* @property {number} numberOfLevelZeroTilesX
|
|
33
|
+
* @property {number} numberOfLevelZeroTilesY
|
|
34
|
+
* @property {Array<string>} matrixIds
|
|
35
|
+
* @property {Object} openlayersOptions
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {Array<string>} matrixIds
|
|
41
|
+
* @param {number} maxLevel
|
|
42
|
+
* @param {string} prefix
|
|
43
|
+
* @returns {Array<string>}
|
|
44
|
+
*/
|
|
45
|
+
function getMatrixIds(matrixIds, maxLevel, prefix) {
|
|
46
|
+
if (matrixIds.length > 0) {
|
|
47
|
+
if (matrixIds.length === (maxLevel + 1)) {
|
|
48
|
+
return matrixIds;
|
|
49
|
+
} else {
|
|
50
|
+
getLogger('vcs.vcm.layer.cesium.WMTSCesium')
|
|
51
|
+
.log('matrixIds must have the same length as maxLevel');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return new Array(maxLevel + 1).fill(undefined).map((value, index) => {
|
|
55
|
+
return `${prefix}${index}`;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* WMTS layer
|
|
62
|
+
* @class
|
|
63
|
+
* @export
|
|
64
|
+
* @extends {RasterLayer}
|
|
65
|
+
* @api stable
|
|
66
|
+
*/
|
|
67
|
+
class WMTS extends RasterLayer {
|
|
68
|
+
static get className() { return 'vcs.vcm.layer.WMTS'; }
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @returns {WMTSOptions}
|
|
72
|
+
*/
|
|
73
|
+
static getDefaultOptions() {
|
|
74
|
+
return {
|
|
75
|
+
...RasterLayer.getDefaultOptions(),
|
|
76
|
+
tilingSchema: 'mercator',
|
|
77
|
+
numberOfLevelZeroTilesX: 1,
|
|
78
|
+
numberOfLevelZeroTilesY: 1,
|
|
79
|
+
layer: '',
|
|
80
|
+
style: '',
|
|
81
|
+
format: '',
|
|
82
|
+
tileMatrixPrefix: '',
|
|
83
|
+
tileMatrixSetID: '',
|
|
84
|
+
openlayersOptions: {},
|
|
85
|
+
matrixIds: [],
|
|
86
|
+
tileSize: /** @type {import("ol/size").Size} */ ([256, 256]),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param {WMTSOptions} options
|
|
92
|
+
*/
|
|
93
|
+
constructor(options) {
|
|
94
|
+
const defaultOptions = WMTS.getDefaultOptions();
|
|
95
|
+
options.tilingSchema = options.tilingSchema || defaultOptions.tilingSchema;
|
|
96
|
+
super(options);
|
|
97
|
+
|
|
98
|
+
this._supportedMaps = [
|
|
99
|
+
Openlayers.className,
|
|
100
|
+
CesiumMap.className,
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
/** @type {number} */
|
|
104
|
+
this.numberOfLevelZeroTilesX = parseInteger(
|
|
105
|
+
options.numberOfLevelZeroTilesX,
|
|
106
|
+
defaultOptions.numberOfLevelZeroTilesX,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
/** @type {number} */
|
|
110
|
+
this.numberOfLevelZeroTilesY = parseInteger(
|
|
111
|
+
options.numberOfLevelZeroTilesY,
|
|
112
|
+
defaultOptions.numberOfLevelZeroTilesY,
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
/** @type {string} */
|
|
116
|
+
this.layer = options.layer || defaultOptions.layer;
|
|
117
|
+
|
|
118
|
+
/** @type {string} */
|
|
119
|
+
this.style = options.style || defaultOptions.style;
|
|
120
|
+
|
|
121
|
+
/** @type {string} */
|
|
122
|
+
this.format = options.format || defaultOptions.format;
|
|
123
|
+
|
|
124
|
+
/** @type {string} */
|
|
125
|
+
this.tileMatrixPrefix = options.tileMatrixPrefix || defaultOptions.tileMatrixPrefix;
|
|
126
|
+
|
|
127
|
+
/** @type {string} */
|
|
128
|
+
this.tileMatrixSetID = options.tileMatrixSetID || defaultOptions.tileMatrixSetID;
|
|
129
|
+
|
|
130
|
+
/** @type {Object} */
|
|
131
|
+
this.openlayersOptions = options.openlayersOptions || defaultOptions.openlayersOptions;
|
|
132
|
+
|
|
133
|
+
/** @type {Array.<string> | null} */
|
|
134
|
+
this.matrixIds = Array.isArray(options.matrixIds) ? options.matrixIds : defaultOptions.matrixIds;
|
|
135
|
+
|
|
136
|
+
/** @type {import("ol/size").Size} */
|
|
137
|
+
this.tileSize = options.tileSize || defaultOptions.tileSize;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @inheritDoc
|
|
142
|
+
* @returns {WMTSImplementationOptions}
|
|
143
|
+
*/
|
|
144
|
+
getImplementationOptions() {
|
|
145
|
+
return {
|
|
146
|
+
...super.getImplementationOptions(),
|
|
147
|
+
layer: this.layer,
|
|
148
|
+
style: this.style,
|
|
149
|
+
format: this.format,
|
|
150
|
+
tileMatrixSetID: this.tileMatrixSetID,
|
|
151
|
+
tileSize: this.tileSize,
|
|
152
|
+
numberOfLevelZeroTilesX: this.numberOfLevelZeroTilesX,
|
|
153
|
+
numberOfLevelZeroTilesY: this.numberOfLevelZeroTilesY,
|
|
154
|
+
matrixIds: getMatrixIds(this.matrixIds, this.maxLevel, this.tileMatrixPrefix),
|
|
155
|
+
openlayersOptions: this.openlayersOptions,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @inheritDoc
|
|
161
|
+
* @param {import("@vcmap/core").VcsMap} map
|
|
162
|
+
* @returns {Array<WMTSOpenlayers|WMTSCesium>}
|
|
163
|
+
*/
|
|
164
|
+
createImplementationsForMap(map) {
|
|
165
|
+
if (map instanceof Openlayers) {
|
|
166
|
+
return [new WMTSOpenlayers(map, this.getImplementationOptions())];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (map instanceof CesiumMap) {
|
|
170
|
+
return [new WMTSCesium(map, this.getImplementationOptions())];
|
|
171
|
+
}
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @inheritDoc
|
|
177
|
+
* @returns {WMTSOptions}
|
|
178
|
+
*/
|
|
179
|
+
getConfigObject() {
|
|
180
|
+
const config = /** @type {WMTSOptions} */ (super.getConfigObject());
|
|
181
|
+
const defaultOptions = WMTS.getDefaultOptions();
|
|
182
|
+
|
|
183
|
+
if (this.tilingSchema !== defaultOptions.tilingSchema) {
|
|
184
|
+
config.tilingSchema = this.tilingSchema;
|
|
185
|
+
} else {
|
|
186
|
+
delete config.tilingSchema;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (this.numberOfLevelZeroTilesX !== defaultOptions.numberOfLevelZeroTilesX) {
|
|
190
|
+
config.numberOfLevelZeroTilesX = this.numberOfLevelZeroTilesX;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (this.numberOfLevelZeroTilesY !== defaultOptions.numberOfLevelZeroTilesY) {
|
|
194
|
+
config.numberOfLevelZeroTilesY = this.numberOfLevelZeroTilesY;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (this.layer !== defaultOptions.layer) {
|
|
198
|
+
config.layer = this.layer;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (this.style !== defaultOptions.style) {
|
|
202
|
+
config.style = this.style;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (this.format !== defaultOptions.format) {
|
|
206
|
+
config.format = this.format;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (this.tileMatrixPrefix !== defaultOptions.tileMatrixPrefix) {
|
|
210
|
+
config.tileMatrixPrefix = this.tileMatrixPrefix;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (this.tileMatrixSetID !== defaultOptions.tileMatrixSetID) {
|
|
214
|
+
config.tileMatrixSetID = this.tileMatrixSetID;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (Object.keys(this.openlayersOptions).length > 0) {
|
|
218
|
+
config.openlayersOptions = { ...this.openlayersOptions };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (this.matrixIds.length > 0) {
|
|
222
|
+
config.matrixIds = this.matrixIds.slice();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (this.tileSize[0] !== defaultOptions.tileSize[0] || this.tileSize[1] !== defaultOptions.tileSize[1]) {
|
|
226
|
+
config.tileSize = /** @type {import("ol/size").Size} */ (this.tileSize.slice());
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return config;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
VcsClassRegistry.registerClass(WMTS.className, WMTS);
|
|
234
|
+
export default WMTS;
|
|
235
|
+
|