Hello,
I have a WMTS server
having only data from zoom levels 6 to 16 and want to display its tiles in
Cesium. According to the API reference of the WebMapTileServiceImageryProvider
(https://cesiumjs.org/Cesium/Build/Documentation/WebMapTileServiceImageryProvider.html#WebMapTileServiceImageryProvider),
I should be able to use the ‘minimumLevel’ and ‘maximumLevel’ properties to
indicate the available tile range.
I used the following
code (the URL is not the one I used, as my server is not accessible from
Internet):
var viewer = new
Cesium.Viewer(‘cesiumContainer’);
var wmts = new
Cesium.WebMapTileServiceImageryProvider({
url : "https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryTopo/MapServer/WMTS/tile/1.0.0/USGSImageryTopo/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}",
layer : 'USGSImageryTopo',
style : 'default',
format : 'image/png',
tileMatrixSetID : 'default028mm',
minimumLevel: 6,
maximumLevel: 16
});
viewer.imageryLayers.addImageryProvider(wmts);
I get the following
error: “Uncaught DeveloperError: The imagery provider’s rectangle and
minimumLevel indicate that there are 4096 tiles at the minimum level. Imagery
providers with more than four tiles at the minimum level are not
supported.”
I guess the reason
why Cesium tries to download data from zoom level 6 when the view is currently
at zoom level 0 is to “compute” the missing tiles from higher level
ones.
I
tried creating an ImageryLayer and specifying the minimumTerrainLevel, but
that’s not valid workaround, because the check is done in the
WebMapTileServiceImageryProvider constructor (https://github.com/AnalyticalGraphicsInc/cesium/blob/3ef9dad02f4be88894e58501a602118008c5b5c6/Source/Scene/WebMapTileServiceImageryProvider.js#L214).
The only workaround I could find was that, if you work on a
relatively small area, you can specify your extent
of interest with the ‘rectangle’ property of the options.
I see there was an
issue created to raise the allowed number of tiles at minimum level (https://github.com/AnalyticalGraphicsInc/cesium/issues/4372).
But would not it be
better to totally disable this “extrapolation” mechanism" when
it is not wanted?
It could be done
like that:
- Remove the check of the
number of tiles at minimum level (https://github.com/AnalyticalGraphicsInc/cesium/blob/3ef9dad02f4be88894e58501a602118008c5b5c6/Source/Scene/WebMapTileServiceImageryProvider.js#L214) - Add a new optional property
to the ImageryLayer options named for instance
‘extrapolateLowerLevelTiles’. True would mean the current behavior (use
higher level tiles to compute missing lower level ones), and false would
mean that the layer should not try to display anything. Defaut value could
be true to keep current behavior. - Change the following block (https://github.com/AnalyticalGraphicsInc/cesium/blob/3ef9dad02f4be88894e58501a602118008c5b5c6/Source/Scene/ImageryLayer.js#L545)
if
(defined(imageryProvider.minimumLevel)) {
var minimumLevel =
imageryProvider.minimumLevel;
if (imageryLevel < minimumLevel) {
imageryLevel = minimumLevel;
}
}
by
something like:
if
(defined(imageryProvider.minimumLevel)) {
var minimumLevel =
imageryProvider.minimumLevel;
if (imageryLevel < minimumLevel) {
if (this.extrapolateLowerLevelTiles) {
imageryLevel = minimumLevel;
} else {
// Do not create missing tiles from
higher level ones.
return false;
}
}
}
Would it be of any
interest for the product?
Best regards