We have ground and fly tracks in our app. The task is to push ground tracks to ground and ensure that fly tracks are above the ground. For now I do the following:
var cartesianCoords = […]; // Here are track’s coords that we have to process and push to ground
var checkLevelOfDetails = 11;
var promise = Cesium.sampleTerrain(self.map.scene.globe.terrainProvider,checkLevelOfDetails,self.map.scene.globe.ellipsoid.cartesianArrayToCartographicArray(cartesianCoords));
Cesium.when(promise,function(updatedPositions) {
cartesianCoords = self.map.scene.globe.ellipsoid.cartographicArrayToCartesianArray(updatedPositions);
self.update();
});
The question is how to define checkLevelOfDetails? We use //cesiumjs.org/stk-terrain/tilesets/world/tiles for terrain. It has different precision for different map areas. That’s why we can’t set it to some constant. If it’s set to the lower value than the actual terrain is drawn, there’s mismatch (track does not actually lie on the ground). If it’s greater than actual terrain, files for SampleTerrain are not found at all.