Further to the discussion here:, I have made a few modifications to the calculation provided by jbante. These modifications include:
- Getting the Cardinal directions (N,S,E,W) reporting corrctly for positive (N, E) cardinals and (S, W) for negative cardinals,
- Leading Zeroes on whole degrees for both Latitude and Longitude -to more closely comply with "correct" (perhaps more commonly used and familiar?) notation, and
- Limited the decimal precision of Minutes of arc to 5 places.
So far, so good.
My final stumbling block with this is to get Leading Zeroes in the whole minutes notation of the coordinates. For example, the Decimal Latitude coordinate -4.00699999183416 is correctly rounding to -4.00699999. After calculation, the result is displaying as: S04° .42'... which should be, with "correct" notation: S04° 00.42'. I've tried adding a Right function, without success... I suspect it may be to do with where I am calling that function, but I can't make it work!
The calculation as it currently exists:
Let ( [
~original = LATITUDE ;
~negative = ~original < 0 ; // True (1) if value is negative
~positive = Abs ( ~original ) ;
~degrees = Div ( ~positive ; 1 ) ;
~minutes = Mod ( ~positive ; 1 ) * 60 ;
~decimal = ~degrees + ~minutes / 60 ;
~decimal = If ( ~negative ; 0 - ~decimal ; /* Else */ ~decimal )
If ( ~negative ; "S" ; "N")
& Right ( "00" & ~degrees ; 2 ) & "° "
& Round ( ~minutes ; 5 ) & "'"
Would appreciate any assistance available!