计算 Google Earth KML LookAt 元素的范围和高度以适合所有要素(多边形)
我在谷歌地球插件的表面上绘制了几个多边形。我从它们生成一个 KML。
问题是如何计算 LookAt 的参数,以便在桌面 Google Earth 中打开时视图包含所有多边形? 对于纬度和经度来说,这非常简单 - 只需计算边界框的中心,但是高度和范围参数呢?
例如,我们有两个多边形:
1:
40.724536 -74.001914
40.724102 -74.001091
40.723003 -74.002067
40.723392 -74.002891
2:
40.723186 -74.003112
40.722843 -74.002311
40.721977 -74.003036
40.722320 -74.003738
那么 lon 和 lat 将是
长=(40.724536+40.721977)/2=40.7232565
lat=-(74.001091+74.003738)/2=-74.0024145
现在如何计算范围和高度?
I have several polygons drawn on the surface in google earth plugin. I generate a KML from them.
Question is how can I calculate parameters for the LookAt so that the view includes all the polygons when open in the desktop Google Earth?
For lat and lon it's quite simple - just calculate the center of bounding box, but what about altitude and range parameters?
For example we have two polygons:
1:
40.724536 -74.001914
40.724102 -74.001091
40.723003 -74.002067
40.723392 -74.002891
2:
40.723186 -74.003112
40.722843 -74.002311
40.721977 -74.003036
40.722320 -74.003738
Then lon and lat will be
lon=(40.724536+40.721977)/2=40.7232565
lat=-(74.001091+74.003738)/2=-74.0024145
Now how to calculate the range and altitude?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 Google 地球 API 实用程序库。它增强了 Earth API 的功能,提供了有用的帮助方法,为您封装了常用的任务。
它包含 createBoundsView() 方法 将为您构建一个
LookAt
对象,该对象配置为适合视口内给定的边界框。我认为正是您所需要的。例如Take a look at the Google Earth API Utility Library. It augments the functionality of the Earth API providing useful helper methods which wrap up commonly needed tasks for you.
It includes a createBoundsView() method which will build you a
LookAt
object configured to fit a given bounding box within the viewport. Does exactly what you need I think. e.g.