cesiumjsaltitude

Cesium- How to calculate highest point, lowest point, average altitude in a specified area around the click position?


I have successfully computed the height of a location where user clicks in cesium but my next step is a bit complex. What i want to do is that when user clicks at some point on globe, at any zoom level, i want to calculate highest point, lowest point and, average altitude around click position (say a circular area of 1000 meters). How should I do it, any ideas?


Solution

  • I solved this problem by finding all LatLngs in a square region using bi-linear interpolation and then used Cesium's sample terrain to query height info for each point. Following are the steps I followed:

    1. Find corner points of a square region around click position using spherical utils in google maps API like this: var northwest = google.maps.geometry.spherical.computeOffset(center, radius * Math.sqrt(2.0), 135); var northeast = google.maps.geometry.spherical.computeOffset(center, radius * Math.sqrt(2.0), 45); var southwest = google.maps.geometry.spherical.computeOffset(center, radius * Math.sqrt(2.0), 225); var southeast = google.maps.geometry.spherical.computeOffset(center, radius * Math.sqrt(2.0), 315);
    2. Then use bilinear interpolation to find points inside the square region. You can use spherical utils interpolate method for avoiding extra work.Like this: google.maps.geometry.spherical.interpolate(latlng1, latlng2, fraction);
    3. After that find height info of all the points calculated in previous step using Cesium's sample terrain.
    4. Now you can easily calculate highest, lowest and average height.