Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Lat-Lng
private LatLng getLatLng(String lat, String lng){
LatLng ll = null;
if(lat.length() == 6 && lng.length() == 7){
double hoursLat = Double.valueOf(lat.substring(0,2));
double minLat = Double.valueOf(lat.substring(2,4));
double secLat = Double.valueOf(lat.substring(4,6));
double hoursLng = Double.valueOf(lng.substring(0,3));
double minLng = Double.valueOf(lng.substring(3,5));
double secLng = Double.valueOf(lng.substring(5,7));
double decimalLat = Math.signum(hoursLat) * (Math.abs(hoursLat) + (minLat / 60.0) + (secLat / 3600.0));
double decimalLng = Math.signum(hoursLng) * (Math.abs(hoursLng) + (minLng / 60.0) + (secLng / 3600.0));
ll = new LatLng(decimalLat, -decimalLng);
}
return ll;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.