Hi,
I'm working on fetching altitude at a given position on a map which has terrain loaded into it. I found little confusing that both the below methods are returning 2 different values for near same location.
PickRay on Mousemove:
var ray = viewer.camera.getPickRay(movement.endPosition);
var position1 = viewer.scene.globe.pick(ray, viewer.scene);
if (Cesium.defined(position1)) {
var positionCartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position1);
var height1 = positionCartographic.height.toFixed(2);
}
sample terrain:
Cesium.sampleTerrain(viewer.terrainProvider, 11, [cartographic])
.then(function () {
var span = document.getElementById('altData');
span.textContent = cartographic.height.toFixed(2);
});
Interestingly, I could even found that height returned from sample terrain is not right when I compare between 2 different location of a slope area.
Did I miss anything here or is this the regular behavior? How do I get altitude at given lat and long with user interaction in the screen. Anyhelp is highly appreciated.
Thanks,
Shiva Kumar