tum-gis/cesium-terrain-builder-docker

Cannot visualize with CesiumJS

kilsedar opened this issue · 7 comments

Hello,

I am trying to use the mesh output with CesiumJS.

I am getting the error:
Cesium.js:452 An error occurred in "w": Failed to obtain terrain tile X: 1 Y: 0 Level: 0.
Cesium.js:452 An error occurred in "w": Failed to obtain terrain tile X: 0 Y: 0 Level: 0.

I asked this question also in the cesium-dev Google group. You can find my question at https://groups.google.com/forum/#!topic/cesium-dev/bmH_Rp4FkDY.

Are you familiar with this error? Can you guess what I am doing wrong?

I am using CesiumJS version 1.50.

Thanks.

hi @kilsedar,
I am stuck on the same issue.
Will you please describe how you solved the issue.

Hello @SurajitChowbey, using a file system to fetch the terrain tiles caused the problem. Instead, as I wrote above, using the server built for serving the terrain tiles, namely https://github.com/geo-data/cesium-terrain-server, solves the problem.

Thank you

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

Do I need to install the nginx server separately?

BWibo commented

If you want to host the tiles using a common webserver like Nginx, yes of course.
However, this is not required. You can host the tiles directly through CesiumTerrainServer too.
Here are more examples: https://stackoverflow.com/a/65196056/9496590
Here is an example using Docker and the 3DCityDB WebMapClient for tile visualization: https://github.com/tum-gis/3dcitydb-docker-compose/tree/cesium-terrain-server