繁体   English   中英

如何在 Android 上为 Google 地图获取 E6 格式的经纬度

[英]How to get E6 format of Longitude Latitude for Google Maps on Android

我如何找出某个位置的经度纬度的特定E6 值。 例如,我用谷歌搜索了巴拉圭首都亚松森的纬度。 它返回给我:

The latitude and longitude of Asuncion, Paraguay is 25°16' S, 57°40 W

现在我如何将这种 long-lat 格式转换为 android 理解的 E6 格式的 long-lat? 这个E6到底是什么东西?

[ps 我还用谷歌搜索了亚松森的 E6 long-lat ......没有运气]

所以这是一个两步的过程 - 感谢hooked82的回答


步骤 1. 从 DMS 转换为Wikipedia的十进制度

给定一个 DMS(度、分、秒)坐标,例如87°43′41″ W ,使用以下方法将其转换为十进制度数很简单:

  • 总度数
    = 87
  • 总秒数
    = 43′41″ = (43*60 + 41*1) = 2621 秒。
  • 小数部分是总秒数除以 3600
    = 2621 / 3600 = 0.728056
  • 将分数度数添加到整个度数以产生最终结果
    = 87 + 0.728056 = 87.728056。
  • 由于它是西经坐标,因此否定结果。
    = -87.728056。
  • 经纬度参考:

    Lat.  North = +
    Lat.  South = -
    Long. East  = +
    Long. West  = -
    

    步骤 2. 从十进制度数转换为微度数(E6 格式) 来自 SO 讨论

    MicroDegrees (E6 格式)= DecimalDegrees * 1e6
    ---正如 AndroidDevGuide 中提到的那样

    因此,

    float lat   = -23.4456f;   //in DecimalDegrees
    float lng   = 45.44334f;   //in DecimalDegrees
    GeoPoint gp = new GeoPoint((int)(lat * 1E6), (int)(lng * 1E6));
    

    我不确定将 DMS 坐标转换为微度的编程方法,但是我遇到了一个手动转换过程:

    http://en.wikipedia.org/wiki/Geographic_coordinate_conversion#Conversion_from_DMS_to_Decimal_Degree

    另外,看看这个SO问题:

    Android 具有纬度/经度值的地理点

    If you're manually trying to get GPS coordinates and want values that Android can handle, you can always go to Google Maps and Right-Click on a point on the map and select "What's Here". 它会给你 position 的纬度/经度,尽管有很多方法可以获得这些。

    暂无
    暂无

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM