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

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:



OpenDDS: OpenDDS is an open source C++ implementation of the Object Management Group (OMG) Data Distribution Service (DDS). OpenDDS leverages the Adaptive Communication Environment (ACE) to provide a cross platform environment. OpenDDS is supported by Object Computing, Inc. Download OpenDDS here.

X Windows Programming in C++: Part I

Years ago, I did quite a bit X Windows programming. When I started developing X Windows software, I was also learning C++ (this was a long time ago). Unfortunately , the X Windows system I was developing software for did not have a C++ compiler. This led to some frustration since using C++ would have made some of my tasks easier.

A fews years later, I worked on another project using X and Motif. It was mandated that this software be written in C leading to same frustration I experience when I first started learning X (by this time I was a seasoned C++ developer, so writing anything in C seemed like a step backward).

I’ve decided to revisit X Windows programming on my own for a few reasons:

  • I’m a little rusty when it comes to X Windows programming.

  • I want to use X in a project I’ve been contemplating for the past few years.

  • I’m currently working on Microsoft Windows C++/C# project at work and I want to do some non-Microsoft programming on my own.

My first step in getting back into X Windows programming was to revist the book, Xlib Programming Manual, Rel. 5. The examples in this book are written in C (Kerninghan and Ritchie C, no less). One of these examples, basicwin.c, demonstrates the fundementals of programming with the X library. I figure coming up with a C++ version of basicwin.c would be a useful learning experience for myself and possibly others.

I’ll start out by taking pieces of basicwin.c and converting them to C++. I’ll start with following code fragments showing the use of the structures: XSizeHints, XWMHints, and XClassHint.


Matrix Template Library

While rewriting some data analysis software I developed many years ago (the original was written in K & R C, the new version will be written in C++), I stumbled upon The Matrix Template Library (MTL). MTL is a library that provides comprehensive linear algebra functionality for a wide variety of matrix formats. I was … Continue reading “Matrix Template Library”