This week's book giveaway is in the Big Data forum. We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line! See this thread for details.

actually i am building gps application. i got the latitude and longitude values in decimal format but i need to convert them into the degrees minutes format like 1301.5130N.

so is there any API to convert it into that format please help :-)

I think this comes in somewhere around the basic Geometry maths class.

In the traditional Babylonian-inspired circular metric system, a circle encompasses exactly 360 degrees. Each degree was divided into 60 minutes, each minute was divided into 60 seconds. That pretty well tapped out their limits of precision, so after that you're on your own - we use decimal fractions on seconds.

So:

13.025493599706797°

Removing the integer part, gives:

0.025493599706797°

Scale it up by 3600.0 (60×60):

91.776958944'

Div/mod, gives:

91.776958944 / 60 = 1.529615'

91.776958944 % 60 * 60 = 31.776958944"

So, in traditional form:

13°01'31.777" (approx). Assuming North latitude from a signed number: 13°01'31.777N

Or, since you only want degrees/minutes:, multiply by 60 and skip the seconds calculations, instead:

13° 1.529615982'N

Which you can verify approximately, since 1'30" is exactly 1.5 minutes, by definition.

ashwini kalmath
Greenhorn

Joined: Oct 24, 2011
Posts: 25

posted

0

hello tim,

Thanks a lot. so for north and south same calculations.

so is the same calculation for east and west values.