Altitude at position (3 different ways each with there own limitations)

While trying to find the best way to obtain altitude at a given position, I found several ways to accomplish this. Unfortunately, each has it's own drawbacks.

The first example was found on the "Cesium Examples from Google Earth".

http://analyticalgraphicsinc.github.io/cesium-google-earth-examples/examples/groundAlt.html

The problem with this method is that it only works if the scene is in 3D. If the scene is 2D or Columbus View the altitude is not correct.

pick uses a ray to intersect terrain. I think terrain is disabled in 2D (even if you clicked it on) causing it to fail. I’m not sure yet how to turn on terrain in 2D mode. Granted it would go unnoticed being orthographic with a pitch of -90, but you can modify the pitch so it would be noticed. If terrain isn’t on pick should call pickEllipsoid.

getHeight is height of terrain from reference ellipsoid at the supplied lon/lat, but is limited to immediately accessible renderable tiles. sampleTerrain does the same as getHeight, however, it has access to any tile at any LOD You will have to wait for it to be retrieved from the terrain provider, however.

Both getHeight and sampleTerrain yield heights of terrain from reference ellipsoid. Negative numbers mean the terrain is below the reference ellipsoid. This can happen on coastal areas when sea level is also below the reference ellipsoid. Currently there is no built in method to get sea level height at a certain location. On the other hand pick yields distance from ray.origin to the ray’s intersection with the terrain and the ray could be at a tilt. You can even ray test terrain from underground if you disable cullBackFaces.

I’m not sure what you mean by different altitudes for the same position, it appears that each location is slightly offset from the others in the example, and the terrain isn’t flat.