Elevation, Units, and Singletons

I have successfully integrated elevation data with Flight Track if only on the dialog where you define a launch site.  I entered the latitude and longitude, and the elevation appeared in the Altitude text box (which will be renamed to Elevation).  It was the easiest method of evaluating this integration.  However, the units of elevation are Metric only and Flight Track supports both Metric and Imperial units.

In the organization of Flight Track, the Launch Site Definition dialog is some distance from anything that could perform a conversion from/to meters to/from feet.  As I looked through the code, I discovered my first attempt to centralize this conversion however it seemed to require too much baggage to pass around to methods and to classes.  It also seemed to require some management to insure everything in the add-in knew which system is in use.

Initially, I thought I could implement a static class available to the add-in.  The measurement units would be available to every class the add-in.  A little more thought and I recalled the Singleton Design Pattern.  The Singleton class is static and exists as a single instance for the entire application.  In my first experiments with my new Units Conversion Singleton, it behaved as expected.  My next tasks are to evaluate the elevation in the Launch Site Definition dialog with the use of a units conversion.  Additionally, I will comb through the add-in to remove the existing method of units conversion in favor of this Singleton.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s