geo-data / cesium-terrain-builder

A C++ library and associated command line tools designed to create terrain tiles for use in the Cesium JavaScript library
Other
706 stars 338 forks source link

Can not add the terrain data in cesium #96

Open DeZhao-Zhang opened 3 years ago

DeZhao-Zhang commented 3 years ago
  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`,
    });
  4. The world is black and can not see anything image

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

jachym commented 3 years ago

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.

deepatm003 commented 3 years ago

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 commented 3 years ago

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

jachym commented 3 years ago

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.

deepatm003 commented 3 years ago

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?

klucg commented 2 years ago

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')

BWibo commented 2 years ago

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

crocij commented 2 years ago

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 thelayer.json. For testing, I fixed it by hard coding it into the node_modules/cesium/Source/Core/CesiumTerrainProvider.js file in the parseMetadataSuccess method

ruanqizhen commented 2 years ago

I got the same problem

Gitwinters1973 commented 2 years ago

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

zhangiser commented 2 years ago

@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.

BWibo commented 2 years ago

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.

maximilianwicen commented 1 year ago

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 thelayer.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 What changes to CesiumTerrainProvider.js did you do? I am having this problem and getting the correct gzip and the Content-Type as well...

crocij commented 1 year ago

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 thelayer.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 What changes to CesiumTerrainProvider.js did you do? I am having this problem and getting the correct gzip and the Content-Type as well...

At the start of the parseMetadataSuccess I just added the the available array like this: data.available = [ [ { "startX": 0, "startY": 0, "endX": 1, "endY": 0 } ] ,[ { "startX": 2, "startY": 1, "endX": 2, "endY": 1 } ] ,[ { "startX": 4, "startY": 3, "endX": 4, "endY": 3 } ] ,[ { "startX": 8, "startY": 6, "endX": 8, "endY": 6 } ] ,[ { "startX": 16, "startY": 12, "endX": 16, "endY": 12 } ] ,[ { "startX": 33, "startY": 24, "endX": 33, "endY": 24 } ] ,[ { "startX": 66, "startY": 48, "endX": 67, "endY": 49 } ] ,[ { "startX": 132, "startY": 96, "endX": 135, "endY": 98 } ] ,[ { "startX": 264, "startY": 193, "endX": 271, "endY": 196 } ] ,[ { "startX": 528, "startY": 386, "endX": 542, "endY": 392 } ] ,[ { "startX": 1057, "startY": 772, "endX": 1084, "endY": 784 } ] ,[ { "startX": 2115, "startY": 1544, "endX": 2168, "endY": 1568 } ] ,[ { "startX": 4230, "startY": 3089, "endX": 4336, "endY": 3136 } ] ,[ { "startX": 8460, "startY": 6179, "endX": 8672, "endY": 6272 } ] ,[ { "startX": 16921, "startY": 12359, "endX": 17345, "endY": 12544 } ] ,[ { "startX": 33843, "startY": 24719, "endX": 34690, "endY": 25088 } ] ,[ { "startX": 67686, "startY": 49438, "endX": 69380, "endY": 50176 } ] ,[ { "startX": 135373, "startY": 98877, "endX": 138761, "endY": 100353 } ] ]

maximilianwicen commented 1 year ago

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 thelayer.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 What changes to CesiumTerrainProvider.js did you do? I am having this problem and getting the correct gzip and the Content-Type as well...

At the start of the parseMetadataSuccess I just added the the available array like this: data.available = [ [ { "startX": 0, "startY": 0, "endX": 1, "endY": 0 } ] ,[ { "startX": 2, "startY": 1, "endX": 2, "endY": 1 } ] ,[ { "startX": 4, "startY": 3, "endX": 4, "endY": 3 } ] ,[ { "startX": 8, "startY": 6, "endX": 8, "endY": 6 } ] ,[ { "startX": 16, "startY": 12, "endX": 16, "endY": 12 } ] ,[ { "startX": 33, "startY": 24, "endX": 33, "endY": 24 } ] ,[ { "startX": 66, "startY": 48, "endX": 67, "endY": 49 } ] ,[ { "startX": 132, "startY": 96, "endX": 135, "endY": 98 } ] ,[ { "startX": 264, "startY": 193, "endX": 271, "endY": 196 } ] ,[ { "startX": 528, "startY": 386, "endX": 542, "endY": 392 } ] ,[ { "startX": 1057, "startY": 772, "endX": 1084, "endY": 784 } ] ,[ { "startX": 2115, "startY": 1544, "endX": 2168, "endY": 1568 } ] ,[ { "startX": 4230, "startY": 3089, "endX": 4336, "endY": 3136 } ] ,[ { "startX": 8460, "startY": 6179, "endX": 8672, "endY": 6272 } ] ,[ { "startX": 16921, "startY": 12359, "endX": 17345, "endY": 12544 } ] ,[ { "startX": 33843, "startY": 24719, "endX": 34690, "endY": 25088 } ] ,[ { "startX": 67686, "startY": 49438, "endX": 69380, "endY": 50176 } ] ,[ { "startX": 135373, "startY": 98877, "endX": 138761, "endY": 100353 } ] ]

Cool. I ended up fixing it by using the docker container rinstead of compiling the Go code.

techmavengeospatial commented 5 months ago

PAID Commercial Cesium Quantized Mesh Terrain Tile Serving (from MBTILES) https://tileserver.techmaven.net/ https://3dsceneserver.techmaven.net/ https://geodataserver.techmaven.net/ they offers the proper headers and metadata

Perfect for Cesium WebGL, Cesium Game Engines, Other Solutions Terriajs

techmavengeospatial commented 5 months ago

Serve Quantized Mesh in Android App (from MBTILES) https://techmaven.net/portabletileserver/

or iOS, Android and Windows APp https://earthexplorer.techmaven.net