| Author |
how to convert the decimal degree format to degree minutes format of latitude and longitude?
|
ashwini kalmath
Greenhorn
Joined: Oct 24, 2011
Posts: 25
|
|
hello,
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 :-)
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14561
|
|
I don't think you'll find an API, but the math is simple enough.
vFraction = (value * 3600) % 3600
vMinutes = vFraction / 60
vSeconds = vFraction % 60
If I haven't mess up the "vFraction" calculation, that should do it.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
ashwini kalmath
Greenhorn
Joined: Oct 24, 2011
Posts: 25
|
|
hello Tim Holloway,
i did the conversion in another way and i got it. but still me bit curios to know how exactly the calculation done as you said?
can you explain me with some example? let me give you the values wait............
degree decimal format : 13.025493599706797
i need to get the value in degree minutes format that is as :1301.5296N
can you solve it and get that value as result?
Thank you:-)
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14561
|
|
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
|
|
hello tim,
Thanks a lot. so for north and south same calculations.
so is the same calculation for east and west values.
or any other method to convert them:-)
if so can you please explain?
Thank you
|
 |
 |
|
|
subject: how to convert the decimal degree format to degree minutes format of latitude and longitude?
|
|
|