转换后的 latitude/longitude 值中的小数位数(使用 Location.convert 方法)

Number of decimal digits in converted latitude/longitude values (with Location.convert method)

我正在尝试为 latitude/longitude 坐标创建一个转换器实用程序。

请看这段代码:

    ...
    //at this point the location variable has valid location information

    String latDegrees = Location.convert(location.getLatitude(), Location.FORMAT_DEGREES);
    String longDegrees = Location.convert(location.getLongitude(), Location.FORMAT_DEGREES);

    String latMinutes = Location.convert(location.getLatitude(), Location.FORMAT_MINUTES);
    String longMinutes = Location.convert(location.getLongitude(), Location.FORMAT_MINUTES);

    String latSeconds = Location.convert(location.getLatitude(), Location.FORMAT_SECONDS);
    String longSeconds = Location.convert(location.getLongitude(), Location.FORMAT_SECONDS);


    Log.d("results ","lat "+location.getLatitude());
    Log.d("results ","long "+location.getLongitude());
    Log.d("results ","lat degrees "+latDegrees);
    Log.d("results ","long degrees "+longDegrees);
    Log.d("results ","lat min "+latMinutes);
    Log.d("results ","long min "+longMinutes);
    Log.d("results ","lat sec "+latSeconds);
    Log.d("results ","long sec "+longSeconds);
    ...

我得到了这种字符串

results: lat aa.4919783
results: long bb.3432917
results: lat degrees aa.49198
results: long degrees bb.34329
results: lat min aa:29.5187
results: long min bb:20.5975
results: lat sec aa:29:31.12188
results: long sec bb:20:35.85012

(我用字母隐藏了前两位数字)

如您所见,

-原值有7位小数

-度数有5

-分钟有4

-秒有5

是否正确? 这些字符串可以用在需要纬度和经度作为参数的地方吗? 这是标准形式,还是可能需要其他小数?

根据documentation,所有转换结果最多有 5 位小数。如果小数末尾有一个或几个0位,它们将被忽略,所以转换后的结果可以少于5位小数。

原值是Double,所以没有固定的小数位数