Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert geopoint longitude +latitude to double?

I am retrieving the center of a map view and i need to pass the longs and lats as doubles to my server for testing against the database .

How would i go about converting mapView.getMapCenter().getLongitudeE6() to a double ?

like image 461
molleman Avatar asked Dec 05 '22 21:12

molleman


1 Answers

Calling mapView.getMapCenter() returns a GeoPoint. GeoPoint.getLongitudeE6() and GeoPoint.getLatitudeE6() both return microdegrees (basically degrees * 1E6).

So, in Java, to convert microdegrees to degrees simply do:

public static double microDegreesToDegrees(int microDegrees) {
    return microDegrees / 1E6;
}
like image 127
Rob Harrop Avatar answered Dec 27 '22 10:12

Rob Harrop