Degrees minutes seconds function
Posted: Wed Nov 06, 2013 9:44 pm
def dms$(d,h)
if d<0 then
if h then h$="S" else h$="W"
else if h then h$="N" else h$="E"
endif
d=abs(d)
m=60*(d-floor(d))
s=60*(m-floor(m))
dms$=floor(d)&chr$(176)&floor(m)&"'"&str$(int(s*10)/10,"##.#")&""""&h$
enddef
The new GPS function reports latitude and longitude in decimal degrees. This is the best format for doing math, recording values, etc. But for human viewing most people are used to thinking of locations in terms degrees, minutes, and seconds. This function can be called from the collected data to provide a string in the format of degrees, minutes, seconds and tenths of seconds. It can be changed of course to whatever resolution you want but this is likely as accurate as you can expect. To use the function you need to supply a lat or lon value and tell the routine which one you want. dms$(lat,h) where h=1 for latitude and 0 for longitude.
By the way, altitude is collected in meters. If you want feet just multiply by 3.28.
Enjoy
Dale
if d<0 then
if h then h$="S" else h$="W"
else if h then h$="N" else h$="E"
endif
d=abs(d)
m=60*(d-floor(d))
s=60*(m-floor(m))
dms$=floor(d)&chr$(176)&floor(m)&"'"&str$(int(s*10)/10,"##.#")&""""&h$
enddef
The new GPS function reports latitude and longitude in decimal degrees. This is the best format for doing math, recording values, etc. But for human viewing most people are used to thinking of locations in terms degrees, minutes, and seconds. This function can be called from the collected data to provide a string in the format of degrees, minutes, seconds and tenths of seconds. It can be changed of course to whatever resolution you want but this is likely as accurate as you can expect. To use the function you need to supply a lat or lon value and tell the routine which one you want. dms$(lat,h) where h=1 for latitude and 0 for longitude.
By the way, altitude is collected in meters. If you want feet just multiply by 3.28.
Enjoy
Dale