C++ functions to convert between decimal degrees and degrees, minutes, and seconds

Filed under: C++ — jac @ April 25, 2008 - 6:39 am

Back when I was developing shiphandling simulator software, I ran into situations where it was necessary to convert decimal degrees to degrees, minutes, and seconds (for example, nautical types like to express latitude/longitude using degrees, minutes, and seconds while computers prefer decimal degrees).

Here's some C++ functions which handle the conversion between these two formats:


std::string DMS::DegreesMinutesSeconds(double ang,
                                       unsigned int num_dec_places = 2)
std::string DMS::DegreesMinutesSecondsLat(double ang,
                                          unsigned int num_dec_places = 2)
std::string DMS::DegreesMinutesSecondsLon(double ang,
                                          unsigned int num_dec_places = 2)

double DMS::DecimalDegrees(const std::string& dms)

These are inline functions defined in the header file, dms.h:

(more...)



  



April 2008
M T W T F S S
« Mar   Jul »
 123456
78910111213
14151617181920
21222324252627
282930  

Statistics

There are currently 32 posts and 22 comments, contained within 12 categories.


Miscellaneous
- Source Files

Add to Technorati Favorites


Storage B
-WordPress 2.7
-OpenDDS Version 1.2 Released
-FreeVMS
-OpenDDS Version 1.1 Released
-WordPress 2.5
-Multics
-C++ Functions to Evaluate Chebyshev Polynomials
-OpenDDS
-X Windows Programming in C++: Part III
-X Windows Programming in C++: Part II

Valid XHTML 1.0!

Valid CSS!