How to sample single point terrain value with sampleTerrainMostDetailed

Hello,

I am fixing up an abandoned open source cesium-based drone ground station called MAVCesium. It is supposed to draw geofences above the terrain but this line does not appear to be executed ever.

When it is supposed to draw the fences, it needs to know the altitude of the ground, it makes use of Cesium.sampleTerrainMostDetailed. I cannot get this function to ever populate the sample heights.

I’ve reproduced the problem in a sandcastle example here

This is my attempt at a minimized version of the terrain sandcastle example here to perform a single location altitude lookup.

I observe the viewer.terrainProvider attribute not being defined. Any tips on how to initialize the viewer such that I can call sampleTerrainMostDetailed successfully?

Thanks (and sorry for my lack of Javascript/Cesium knowledge).

Hi there,

Viewer.terrainProvider is not immediately defined. The Terrain instance you are using is a helper class which manages the terrain provider’s asynchronous creation behind the scenes.

I would suggest using the TerrainProvider directly to streamline your use case. Adjusting your example to do so looks like this.

Thanks,
Gabby

Wonderful, I appreciate the prompt response. Thank you!

1 Like