Why does Cesium only get 3 zoom layers of terrain?

I am exploring terrain options for my app and trying to get “hello world” for custom terrain to work. While I think the terrain tiles are successfully being served and accessed, it looks like Cesium is only requesting up to the third zoom layer when I pan/zoom on the map. Here is what I have done:

  1. Created terrain tiles using Cesium Terrain Builder. For terrain data, I downloaded GeoTiff files for GTOPO30 dataset from USGS. The result is a folder structure that supports 9 levels of zoom.

  2. I created a basic layer.json file at the tile root folder:

{

“tilejson”: “2.1.0”,

“format”: “heightmap-1.0”,

“version”: “1.0.0”,

“scheme”: “tms”,

“tiles”: ["{z}/{x}/{y}.terrain"]

}

  1. Used Cesium Terrain Server to serve tiles on localhost.

  2. In Cesium app, created new ProviderViewModel with URL to localhost location and added to default list of terrain providers.

Looking at the server output, I see tiles being requested for levels 1, 2, and 3. For example:

[06/Jun/2017:11:09:34 -0400] “GET /tilesets/test/2/0/0.terrain HTTP/1.1”

However, no higher levels are requested when I zoom into an area. The terrain is flat and looks the same to me as using Ellipsoid. There are no errors or output in console.

I verified that I can use sampleTerrain at the higher zoom levels. For example, I tried it at level 9 and it successfully gave a correct answer. So it seems Cesium only thinks there are 3 levels of terrain for the map? Any help on what’s going on or how to make this work? I am on Cesium 1.27 right now.

Thanks,

Jacob

I believe I have solved the problem and will describe the solution here for posterity.

I was led to the solution in reading about the Cesium height-map file format, and that the end of each terrain file encodes information about the availability of data at the next level of detail. I suspected that I was not seeing more level of detail than 3 as an artifact of how I generated the tiles, which was by using ctb-tile from Cesium Terrain Builder on each of the 33 GTOPO30 .tif files independently. In order to solve the problem, I needed to create the terrain tiles from these .tif files as a batch. I do not see how this can be done in Cesium Terrain Builder, so I looked for a way to combine the 33 .tif files into a single one that can be operated on.

The combination was done by using the gdal_merge utility, which I ultimately got working from OSGeo4W (after trying a few different tools) on my Windows machine. So I combined the 33 .tif files into 1, then used ctb-tile on that, served it up with Cesium Terrain Server, and now I see 9 levels of detail. The terrain actually looks nicer than I expected given the 1 km resolution of the elevation data.

Jacob

The other option would be creating a “VRT” file, which is a metadata file that can point to many individual files/datasets but will be treated by GDAL as a single dataset. You can then point CTB at the VRT file as its input, and GDAL will handle the combined datasets correctly.

Thanks for the tip Mark! Maybe next time I’ll try that.

Jacob