cesium-terrain-builder icon indicating copy to clipboard operation
cesium-terrain-builder copied to clipboard

Can not add the terrain data in cesium

Open DeZhao-Zhang opened this issue 3 years ago • 17 comments

  1. At first i get the terrain tile use ctb-tile --output-dir ./terrain-tiles dem.tif image

  2. The I add the data in tomcat webapp root dir, which as apache-tomcat-10.0.2\webapps\ROOT\output-dir

  3. I add the terrain use

viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
        url : `http://localhost:8081/output-dir`,
    });
  1. The world is black and can not see anything image

  2. The http request have only one for 0/1/0.terrain image

DeZhao-Zhang avatar Mar 26 '21 11:03 DeZhao-Zhang

I'm facing the same issue. Javascript debugging console reports:

An error occurred in "CesiumTerrainProvider": Failed to obtain terrain tile X: 1 Y: 0 Level: 0.

layers.json and the first tile (zoom level) are loaded fine , http://localhost:8083/data/tin/0/0/0.terrain?v=1.1.0 returns data and corect Content-type

Generated using intput GeoTIFF and -N -C options

Running ctb-info

ctb-info tin7/9/559/395.terrain reports ```Error: File has wrong file size to be a valid terrain

NOTE: It seems I've used different docker image. Will test with homme/cesium-terrain-builder and report. Sorry for disturbance.

jachym avatar Apr 28 '21 14:04 jachym

I am also getting the same problem with Cesium Terrain Builder with quantized mesh. Please help me on this. I am stuck on this problem for over a month

deepatm003 avatar Apr 29 '21 15:04 deepatm003

I'm facing the same issue. Javascript debugging console reports:

An error occurred in "CesiumTerrainProvider": Failed to obtain terrain tile X: 1 Y: 0 Level: 0.

layers.json and the first tile (zoom level) are loaded fine , http://localhost:8083/data/tin/0/0/0.terrain?v=1.1.0 returns data and corect Content-type

Generated using intput GeoTIFF and -N -C options

Running ctb-info

ctb-info tin7/9/559/395.terrain reports ```Error: File has wrong file size to be a valid terrain

NOTE: It seems I've used different docker image. Will test with homme/cesium-terrain-builder and report. Sorry for disturbance.

Any progress on this. I am also getting same error. Cant understand where I did wrong

deepatm003 avatar Apr 30 '21 06:04 deepatm003

I've checked the empty tile issue, as well as tried various ctb-tile tools. All with the same result. Tiles generated with this tool about 3 years back are working in the new version of Cesium.

jachym avatar Apr 30 '21 16:04 jachym

I've checked the empty tile issue, as well as tried various ctb-tile tools. All with the same result. Tiles generated with this tool about 3 years back are working in the new version of Cesium

Can you mention which version of Cesium and ctb-tile tools you used? Have you done any settings in tomcat server?

deepatm003 avatar Apr 30 '21 20:04 deepatm003

The main reason that you can't load terrain file into cesium is because .terrain is ziped file, you need to unzip it or tell your browser to do it (by setting response header 'Content-Encoding: gzip')

klucg avatar Dec 12 '21 02:12 klucg

I can confirm this. Check this for a possible solution: https://stackoverflow.com/questions/54879535/cesium-terrain-builder-docker-error-when-i-load-cesium-js-in-browser/65196056#65196056

BWibo avatar Dec 12 '21 12:12 BWibo

I can confirm this. Check this for a possible solution: https://stackoverflow.com/questions/54879535/cesium-terrain-builder-docker-error-when-i-load-cesium-js-in-browser/65196056#65196056

Sadly the problem still persists for me although the Content-Encoding is correctly set to gzip and the Content-Type to application/octet-stream. The error message in the console using chrome is: RangeError: Invalid typed array length: 4225

I tried it both with a dataset in float32 and UInt16. The layer.json can also be loaded.

I am using geo-data/cesium-terrain-server as server.

EDIT: I found the problem, the terrain sever removes for some reason the available array from the layer.json. For testing, I fixed it by hard coding it into the node_modules/cesium/Source/Core/CesiumTerrainProvider.js file in the parseMetadataSuccess method

crocij avatar Mar 08 '22 19:03 crocij

I got the same problem

ruanqizhen avatar Mar 31 '22 17:03 ruanqizhen

I use docker container cesium-terrain-builder to generate terrain tiles (ctb-tile -f Mesh -C -N -v -o ./terrain/ ./XXX.vrt) , then use cesium-terrain-server to server terrain tiles, a cesium client error occurs :

An error occurred in "CesiumTerrainProvider": Failed to obtain terrain tile X: 0 Y: 0 Level: 0. Error message: "RangeError: Invalid typed array length: 4225"

finally,i found .terrain file is compressed (gzip), then use nginx to server it :

location /{     alias d:/terrain/;         add_header Access-Control-Allow-Origin ;     add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";     add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";     location ~ .terrain$ {         add_header Content-Disposition 'attachment;filename=$arg_filename';         add_header Access-Control-Allow-Origin *;         add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";         add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";         add_header Content-Encoding "gzip";         add_header Content-Type "application/octet-stream";     }  }

then solved it ! I am sure this is the key point :

location ~* .terrain$ { add_header Content-Encoding gzip; }

reference: Cesium-terrain-builder-docker error when i load cesium.js in browser

Gitwinters1973 avatar Jun 08 '22 03:06 Gitwinters1973

@Gitwinters1973 May i know if the quantized-mesh produced by the docker CTB has metadata extension in 0/0/0.terrain and 0/1/0.terrain? I used CTB by this fork https://github.com/ahuarte47/cesium-terrain-builder/tree/master-quantized-mesh,the quantized-mesh has no metadata extension,only can i get is layer.json,i guess there has some bug.

zhangiser avatar Aug 05 '22 08:08 zhangiser

Hey there, cesium-terrain-builder-docker is built from the latest commit on https://github.com/geo-data/cesium-terrain-builder/pull/64. Check the PR for all features included.

BWibo avatar Aug 07 '22 09:08 BWibo