我已经成功计算出用户在铯中点击的位置的高度,但我的下一步有点复杂。我想要做的是,当用户在地球上的某个点以任何缩放级别单击时,我想计算点击位置周围的最高点、最低点和平均高度(比如 1000 米的圆形区域)。我该怎么做,有什么想法吗?
问问题
638 次
1 回答
3
我通过使用双线性插值在正方形区域中查找所有 LatLngs 解决了这个问题,然后使用 Cesium 的示例地形查询每个点的高度信息。以下是我遵循的步骤:
- 使用 google maps API 中的球形工具查找点击位置周围正方形区域的角点,如下所示:
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);
- 然后使用双线性插值找到正方形区域内的点。您可以使用球形 utils
interpolate
方法来避免额外的工作。像这样:google.maps.geometry.spherical.interpolate(latlng1, latlng2, fraction);
- 之后,使用 Cesium 的示例地形查找在上一步中计算的所有点的高度信息。
- 现在您可以轻松计算最高、最低和平均高度。
于 2017-04-17T18:50:59.440 回答