1 #include "CoordSymbol.h"
2 #include "EngaugeAssert.h"
3 #include "FormatDegreesMinutesSecondsPolarTheta.h"
9 const int DECIMAL_TO_MINUTES = 60.0;
10 const int DECIMAL_TO_SECONDS = 60.0;
18 bool isNsHemisphere)
const
20 LOG4CPP_INFO_S ((*mainCat)) <<
"FormatDegreesMinutesSecondsPolarTheta::formatOutput";
23 ENGAUGE_ASSERT (coordUnits != COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW);
26 case COORD_UNITS_POLAR_THETA_DEGREES:
27 return formatOutputDegrees (value);
29 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES:
30 return formatOutputDegreesMinutes (value);
32 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS:
35 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW:
43 LOG4CPP_ERROR_S ((*mainCat)) <<
"FormatDegreesMinutesSecondsPolarTheta::formatOutput";
44 ENGAUGE_ASSERT (
false);
49 QString FormatDegreesMinutesSecondsPolarTheta::formatOutputDegrees (
double value)
const
51 LOG4CPP_INFO_S ((*mainCat)) <<
"FormatDegreesMinutesSecondsPolarTheta::formatOutputDegrees";
54 return QString (
"%1%2")
56 .arg (QChar (COORD_SYMBOL_DEGREES));
59 QString FormatDegreesMinutesSecondsPolarTheta::formatOutputDegreesMinutes (
double value)
const
61 LOG4CPP_INFO_S ((*mainCat)) <<
"FormatDegreesMinutesSecondsPolarTheta::formatOutputDegreesMinutes";
64 bool negative = (value < 0);
66 int degrees = qFloor (value);
68 double minutes = value * DECIMAL_TO_MINUTES;
69 degrees *= (negative ? -1.0 : 1.0);
71 return QString (
"%1%2 %3%4")
73 .arg (QChar (COORD_SYMBOL_DEGREES))
75 .arg (QChar (COORD_SYMBOL_MINUTES_PRIME));