podstawie SO odpowiedzi zrobiłem kod, który przelicz DEG na DMS z FORMATEM
przykład 40 ° 42'51 "N 74 ° 00'21" W
przykład połączenia przychodzącego getLocationAsDMS (położenie 8) 8 jest odpowiedni numer tego formatu
public String getLocationAsDMS (Location location, int decimalPlace){
String strLatitude = Location.convert(location.getLatitude(), Location.FORMAT_SECONDS);
strLatitude = replaceDelimiters(strLatitude, decimalPlace);
char latCardinal = location.getLongitude() >= 0 ? 'N' : 'S';
strLatitude = strLatitude + " " + latCardinal;
String strLongitude = Location.convert(location.getLongitude(), Location.FORMAT_SECONDS);
strLongitude = replaceDelimiters(strLongitude, decimalPlace);
char lonCardinal = location.getLongitude() >= 0 ? 'E' : 'W';
strLongitude = strLongitude + " " + lonCardinal;
return strLatitude + " " + strLongitude;
}
@NonNull
private String replaceDelimiters(String str, int decimalPlace) {
str = str.replaceFirst(":", "°");
str = str.replaceFirst(":", "'");
int pointIndex = str.indexOf(".");
int endIndex = pointIndex + 1 + decimalPlace;
if(endIndex < str.length()) {
str = str.substring(0, endIndex);
}
str = str + "\"";
return str;
}
Wystarczy wyjaśnij, co masz (37.33168900, -122.03073100) to stopnie. To, czego chcesz (37 19 '54, 48 11' 52) to stopnie minutowe. – CaseyB