7 #include "CoordSymbol.h" 8 #include "EngaugeAssert.h" 9 #include "FormatDegreesMinutesSecondsPolarTheta.h" 13 #include <QStringList> 15 const int DECIMAL_TO_MINUTES = 60.0;
23 bool isNsHemisphere)
const 25 LOG4CPP_INFO_S ((*mainCat)) <<
"FormatDegreesMinutesSecondsPolarTheta::formatOutput";
28 ENGAUGE_ASSERT (coordUnits != COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW);
31 case COORD_UNITS_POLAR_THETA_DEGREES:
32 return formatOutputDegrees (value);
34 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES:
35 return formatOutputDegreesMinutes (value);
37 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS:
40 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW:
48 LOG4CPP_ERROR_S ((*mainCat)) <<
"FormatDegreesMinutesSecondsPolarTheta::formatOutput";
49 ENGAUGE_ASSERT (
false);
54 QString FormatDegreesMinutesSecondsPolarTheta::formatOutputDegrees (
double value)
const 56 LOG4CPP_INFO_S ((*mainCat)) <<
"FormatDegreesMinutesSecondsPolarTheta::formatOutputDegrees";
65 QString FormatDegreesMinutesSecondsPolarTheta::formatOutputDegreesMinutes (
double value)
const 67 LOG4CPP_INFO_S ((*mainCat)) <<
"FormatDegreesMinutesSecondsPolarTheta::formatOutputDegreesMinutes";
70 bool negative = (value < 0);
72 int degrees = qFloor (value);
74 double minutes = value * DECIMAL_TO_MINUTES;
75 degrees *= (negative ? -1.0 : 1.0);
77 return QString (
"%1%2 %3%4")
79 .arg (QChar (COORD_SYMBOL_DEGREES))
81 .arg (QChar (COORD_SYMBOL_MINUTES_PRIME));