78 double __fdMin = modf( fabs( _fdValue ), &__fdDeg ) * 60;
79 double __fdSec = modf( __fdMin, &__fdMin ) * 60;
80 QString __qsSec = QString::number( __fdSec,
'f', _iPrecision ).prepend(
"0" ).right( 2+( _iPrecision>0 ? _iPrecision+1 : 0 ) );
81 if( __qsSec[0] ==
'6' ) { __fdMin += 1; __qsSec[0] =
'0'; }
82 QString __qsMin = QString::number( __fdMin,
'f', 0 ).prepend(
"0" ).right( 2 );
83 if( __qsMin[0] ==
'6' ) { __fdDeg += 1; __qsMin[0] =
'0'; }
84 __qString = QString::number( __fdDeg,
'f', 0 )+QString::fromUtf8(
"°")+__qsMin+
"'"+__qsSec+
"\"";
91 double __fdMin = modf( fabs( _fdValue ), &__fdDeg ) * 60;
92 QString __qsMin = QString::number( __fdMin,
'f', _iPrecision ).prepend(
"0" ).right( 2+( _iPrecision>0 ? _iPrecision+1 : 0 ) );
93 if( __qsMin[0] ==
'6' ) { __fdDeg += 1; __qsMin[0] =
'0'; }
94 __qString = QString::number( __fdDeg,
'f', 0 )+QString::fromUtf8(
"°")+__qsMin+
"'";
99 __qString = QString::number( fabs( _fdValue ),
'f', _iPrecision )+QString::fromUtf8(
"°");
103 __qString = QString::number( fabs( _fdValue ) *
QVCT::PI / 180.0,
'f', _iPrecision )+QString::fromUtf8(
"°r");
107 __qString = QString::number( fabs( _fdValue ) / 0.9,
'f', _iPrecision )+QString::fromUtf8(
"°g");
114 __qString += _fdValue >= 0 ? ( _eType ==
LONGITUDE ?
"E" :
"N" ) : ( _eType ==
LONGITUDE ?
"W" :
"S" );
126 static const QRegExp __qRegExpDMS( QString::fromUtf8(
"^\\s*(-?\\d+)\\s*°([0-5]?[0-9])\\s*'([0-5]?[0-9](\\.\\d+)?)\\s*\"?\\s*([NnEeSsWw])?\\s*$" ) );
127 static const QRegExp __qRegExpDM( QString::fromUtf8(
"^\\s*(-?\\d+)\\s*°([0-5]?[0-9](\\.\\d+)?)\\s*'?\\s*([NnEeSsWw])?\\s*$" ) );
128 static const QRegExp __qRegExpDEG( QString::fromUtf8(
"^\\s*(-?\\d+(\\.\\d+)?)\\s*°?\\s*([NnEeSsWw])?\\s*$" ) );
129 static const QRegExp __qRegExpRAD( QString::fromUtf8(
"^\\s*(-?\\d+(\\.\\d+)?)\\s*°?r(ad)?\\s*([NnEeSsWw])?\\s*$" ) );
130 static const QRegExp __qRegExpGRAD( QString::fromUtf8(
"^\\s*(-?\\d+(\\.\\d+)?)\\s*°?g(rad)?\\s*([NnEeSsWw])?\\s*$" ) );
132 if( _pbOK ) *_pbOK =
false;
135 QString __qsDirection;
136 if( __qRegExpDMS.exactMatch( _rqString ) )
138 __fdValue = __qRegExpDMS.cap(1).toDouble( &__bOK );
139 if( !__bOK )
return 0.0;
140 __fdValue += __qRegExpDMS.cap(2).toDouble( &__bOK ) / 60.0;
141 if( !__bOK )
return 0.0;
142 __fdValue += __qRegExpDMS.cap(3).toDouble( &__bOK ) / 3600.0;
143 if( !__bOK )
return 0.0;
144 __qsDirection = __qRegExpDMS.cap(5).toUpper();
146 else if( __qRegExpDM.exactMatch( _rqString ) )
148 __fdValue = __qRegExpDM.cap(1).toDouble( &__bOK );
149 if( !__bOK )
return 0.0;
150 __fdValue += __qRegExpDM.cap(2).toDouble( &__bOK ) / 60.0;
151 if( !__bOK )
return 0.0;
152 __qsDirection = __qRegExpDM.cap(4).toUpper();
154 else if( __qRegExpDEG.exactMatch( _rqString ) )
156 __fdValue = __qRegExpDEG.cap(1).toDouble( &__bOK );
157 if( !__bOK )
return 0.0;
158 __qsDirection = __qRegExpDEG.cap(3).toUpper();
160 else if( __qRegExpRAD.exactMatch( _rqString ) )
162 __fdValue = __qRegExpDEG.cap(1).toDouble( &__bOK );
163 if( !__bOK )
return 0.0;
164 __fdValue = __fdValue * 0.9;
165 __qsDirection = __qRegExpDEG.cap(4).toUpper();
167 else if( __qRegExpGRAD.exactMatch( _rqString ) )
169 __fdValue = __qRegExpDEG.cap(1).toDouble( &__bOK );
170 if( !__bOK )
return 0.0;
171 __fdValue = __fdValue * 180.0 /
QVCT::PI;
172 __qsDirection = __qRegExpDEG.cap(4).toUpper();
175 if( !__qsDirection.isEmpty() && __fdValue < 0 )
return 0.0;
176 if( __qsDirection ==
"W" || __qsDirection ==
"S" ) __fdValue = -__fdValue;
177 if( _pbOK ) *_pbOK =
true;
[UI] Container for the application's settings
CUnitPosition::EUnit getUnitPosition()
[Unit] Returns the position format/unit
int getPrecisionPosition()
[Precision] Returns the position decimal precision
Container class for supported machine-friendly format/unit codes.
QMap< CUnitPosition::EUnit, QString > qMapCodes
Container class for supported human-readable format/unit symbols.
QMap< CUnitPosition::EUnit, QString > qMapSymbols
EType
Position coordinate type ID.
static QString toString(double _fdValue, EType _eType, EUnit _eUnit, int _iPrecision=0)
Returns the formatted represention of the given value, using the specified format/unit and decimal pr...
static const CUnitPositionCodes oUnitPositionCodes
Container for supported machine-friendly format/unit codes.
static const QMap< EUnit, QString > & codes()
Returns the list of supported machine-friendly format/unit codes.
@ UNDEFINED
undefined format/unit
@ DMS
degrees, minutes, seconds
static const QMap< EUnit, QString > & symbols()
Returns the list of supported human-readable format/unit symbols.
static QString toCode(EUnit _eUnit)
Returns the machine-friendly code corresponding to the given format/unit ID.
static QString toSymbol(EUnit _eUnit)
Returns the human-readable symbol corresponding to the given format/unit ID.
static double fromString(const QString &_rqString, bool *_pbOK=0)
Returns the numeric value corresponding (parsed) from the string.
static EUnit fromSymbol(const QString &_rqsSymbol)
Returns the format/unit ID corresponding to the given human-readable symbol.
static const CUnitPositionSymbols oUnitPositionSymbols
Container for supported human-readable format/unit symbols.
static EUnit fromCode(const QString &_rqsCode)
Returns the format/unit ID corresponding to the given machine-friendly code.
static CSettings * useSettings()
static constexpr double PI