├── CoordinatePosition.h └── CoordinatePosition.cpp /CoordinatePosition.h: -------------------------------------------------------------------------------- 1 | #ifndef COORDINATEPOSITION_H 2 | #define COORDINATEPOSITION_H 3 | 4 | //System includes 5 | #include 6 | #include 7 | 8 | //Library includes 9 | 10 | //Local includes 11 | 12 | namespace AVN 13 | { 14 | 15 | struct cCoordinatePosition 16 | { 17 | double m_dLatitude_deg; 18 | double m_dLongitude_deg; 19 | float m_fAltitude_mASL; 20 | std::string m_strLabel; 21 | 22 | //Default constructor everything to zero. 23 | cCoordinatePosition(); 24 | 25 | //Compared function on labels for sorting vectors of cCoordinatePostion by label 26 | static bool compareLabel(const cCoordinatePosition &oPos1, const cCoordinatePosition &oPos2); 27 | 28 | //Convert from decimal degrees to DMS 29 | static void decimalDegreesToDMS(double dDecimalDegrees, int32_t &i32Degrees, int32_t &i32Minutes, double &dSeconds); 30 | }; 31 | 32 | } 33 | 34 | #endif // COORDINATEPOSITION_H 35 | -------------------------------------------------------------------------------- /CoordinatePosition.cpp: -------------------------------------------------------------------------------- 1 | //System includes 2 | 3 | //Library includes 4 | 5 | //Local includes 6 | #include "CoordinatePosition.h" 7 | 8 | 9 | AVN::cCoordinatePosition::cCoordinatePosition() : 10 | m_dLatitude_deg(0.0), 11 | m_dLongitude_deg(0.0), 12 | m_fAltitude_mASL(0.0f), 13 | m_strLabel("") 14 | { 15 | } 16 | 17 | bool AVN::cCoordinatePosition::compareLabel(const cCoordinatePosition &oPos1, const cCoordinatePosition &oPos2) 18 | { 19 | //Invert the output of compare function for alphabetically ascending: 20 | return !oPos1.m_strLabel.compare(oPos2.m_strLabel); 21 | } 22 | 23 | void AVN::cCoordinatePosition::decimalDegreesToDMS(double dDecimalDegrees, int32_t &i32Degrees, int32_t &i32Minutes, double &dSeconds) 24 | { 25 | i32Degrees = (int32_t)( dDecimalDegrees ); 26 | i32Minutes = (int32_t)( (dDecimalDegrees - (double)i32Degrees) * 60.0); 27 | dSeconds = (int32_t)( (dDecimalDegrees - (double)i32Degrees - (double)i32Minutes / 60.0) * 60.0 * 60.0); 28 | } 29 | --------------------------------------------------------------------------------