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

后端 未结 2 1338
悲&欢浪女
悲&欢浪女 2020-12-28 19:20

how do i find out the SPECIFIC E6 values of longitude latitude of a location. For example, i googled for long-lat of Asuncion, the capital city of Paraguay.

2条回答
  •  难免孤独
    2020-12-28 19:35

    So it's a two step process - thanks to hooked82's answer


    step 1. Conversion from DMS to Decimal Degrees From Wikipedia

    Given a DMS (Degrees, Minutes, Seconds) coordinate such as 87°43′41″ W, it's trivial to convert it to a number of decimal degrees using the following methods:

  • Total number of degrees
    = 87
  • Total number of seconds
    = 43′41″ = (43*60 + 41*1) = 2621 seconds.
  • The fractional part is total number of seconds divided by 3600
    = 2621 / 3600 = 0.728056
  • Add fractional degrees to the whole degrees to produce the final result
    = 87 + 0.728056 = 87.728056.
  • Since it is a West longitude coordinate, negate the result.
    = -87.728056.
  • Long-Lat reference:

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

    step 2. Conversion from Decimal Degrees to MicroDegrees (the E6 format) From SO discussion

    MicroDegrees (the E6 format) = DecimalDegrees * 1e6
    --- as mentioned in AndroidDevGuide as well

    thus,

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

提交回复
热议问题