Android中通过经度和纬度获取海拔高度
Android平台上有没有一种快速高效的通过经纬度获取海拔高度(elevation)的方法?
Is there a quick and efficient way to get altitude (elevation) by longitude and latitude on the Android platform?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我的方法是使用 USGS Elevation Query Web Service:
以及使用示例(就在HelloMapView 类):
My approach is to use USGS Elevation Query Web Service:
And example of use (right in HelloMapView class):
您还可以使用 Google Elevation API。它的在线文档位于:
https://developers.google.com/maps/documentation/elevation/
请注意以下来自上述 API 页面:
更改上面的 Google API 的 Max Gontar 代码可得到以下结果,返回的海拔高度以英尺为单位:
You can also use the Google Elevation API. The online documentation for it is located at:
https://developers.google.com/maps/documentation/elevation/
Please note the following from the above API page:
Altering Max Gontar's code above for the Google API gives the following, with the returned elevation given in feet:
首先区分海拔高度很重要。
高度是从一点到当地表面的距离;无论是土地还是水。该测量主要用于航空。
可以使用 Location.getAltitude() 函数。
高程是当地表面到海平面的距离;更常用,并且经常被错误地称为海拔。
尽管如此,对于美国来说,USGS 提供了更新的 HTTP POST 和 GET 查询,可以返回以英尺或米为单位的海拔的 XML 或 JSON 值。对于全球海拔高度,您可以使用 Google Elevation API。
It's important to first differentiate altitude from elevation.
Altitude is the distance from a point down to the local surface; whether that be land or water. This measurement is mainly used for aviation.
Altitude can be obtained by using the Location.getAltitude() function.
Elevation is the distance from the local surface to the sea level; much more often used, and often mistakenly referred to as altitude.
With that said, for the US, USGS has provided a newer HTTP POST and GET queries that can return XML or JSON values for elevation in either feet or meters. For worldwide elevation, you could use the Google Elevation API.
如果您使用具有 GPS 接收器的 Android 设备,那么有一个方法 getAltitude() 通过使用您可以通过海拔高度获取海拔高度。
If u are using android device which has GPS Recever then there is a method getAltitude() by using that u can get the altitude by elevation.
试试我构建的这个:https://algorithmia.com/algorithms/Gaploid/Elevation
这是 Java 的示例:
Try this one that I`v built: https://algorithmia.com/algorithms/Gaploid/Elevation
here is example for Java:
谷歌地图有海拔高度,你需要的是这个代码
Google maps have the altitude, what you need is this code
使用 Google Elevation API 的想法很好,但使用字符串函数解析 XML 则不然。此外,HttpClient 现在已被弃用,因为它使用不安全的连接。
请参阅此处以获得更好的解决方案:
https://github .com/M66B/BackPackTrackII/blob/master/app/src/main/java/eu/faircode/backpacktrack2/GoogleElevationApi.java
The idea to use the Google Elevation API is good, but parsing XML using string functions is not. Also, HttpClient is deprecated now, as using insecure connections.
See here for a better solution:
https://github.com/M66B/BackPackTrackII/blob/master/app/src/main/java/eu/faircode/backpacktrack2/GoogleElevationApi.java