Conversion of GPS values from deg to dms format
Does anyone know how or have an Android function to convert a GPS value from d开发者_如何学JAVAecimal to DMS (degree-minute-second) format?
Have a look at the class android.location.Location
.
The static method convert(double, Location.FORMAT_SECONDS)
is what you're looking for.
You could do the math manually.
Example code:
decimal = ...; // Your given value
boolean neg = decimal < 0;
decimal = abs(decimal);
deg = floor(decimal); // Round down
minutes = floor((decimal * 60) % 60); // This is an integer in the range [0, 60)
seconds = (decimal * 3600) % 60; // This is a decimal in the range [0, 60)
if (neg) prepend minus sign;
精彩评论