6 #include <QRegularExpression>
14 using namespace swift::misc::physical_quantities;
16 namespace swift::misc::geo
18 template <
class LATorLON>
25 template <
class LATorLON>
32 template <
class LATorLON>
39 template <
class LATorLON>
47 template <
class LATorLON>
55 template <
class LATorLON>
63 template <
class LATorLON>
66 const QString wgs = wgsCoordinate.simplified().trimmed();
67 if (wgs.isEmpty()) {
return LATorLON(); }
73 latOrLon.parseFromString(wgs);
79 const double valueDegrees = wgs.toDouble(&isDouble);
87 thread_local
const QRegularExpression rx(
"[+-]?\\d+(?:\\.\\d+)?");
92 QRegularExpressionMatchIterator i = rx.globalMatch(wgs);
93 while (i.hasNext() && c < 3)
95 const QRegularExpressionMatch match = i.next();
99 const QString cap = match.captured(0);
102 case 0: deg = cap.toInt(&ok);
break;
103 case 1: min = cap.toInt(&ok);
break;
104 case 2: sec = cap.toDouble(&ok);
break;
111 if (wgs.contains(
'S', Qt::CaseInsensitive) || wgs.contains(
'W', Qt::CaseInsensitive))
118 physical_quantities::CAngle a(deg, min, sec);
122 template <
class LATorLON>
124 : physical_quantities::
CAngle(0.0, swift::misc::physical_quantities::
CAngleUnit::deg())
127 template <
class LATorLON>
129 : physical_quantities::
CAngle(value, unit)
132 template <
class LATorLON>
134 : physical_quantities::
CAngle(angle)
137 template <
class LATorLON>
143 template <
class LATorLON>
146 return static_cast<LATorLON
const *
>(
this);
149 template <
class LATorLON>
150 LATorLON *CEarthAngle<LATorLON>::derived()
152 return static_cast<LATorLON *
>(
this);
155 template <
class LATorLON>
158 return CIcons::GeoPosition;
161 template <
class LATorLON>
165 const QChar pn = v.
sign < 0 ? neg : pos;
167 static const QString vs(
"%1° %2' %3\" %4");
168 if (fractionalDigits < 1) {
return vs.arg(v.
deg).arg(v.
min).arg(v.
sec).arg(pn); }
170 static const QString vsf(
"%1° %2' %3.%4\" %5");
IconIndex
Index for each icon, allows to send them via DBus, efficiently store them, etc.
Base class for latitude / longitude.
CIcons::IconIndex toIcon() const
As icon, not implemented by all classes.
QString toWgs84(const QChar pos, const QChar neg, int fractionalDigits=3) const
To WGS84 string.
CEarthAngle()
Default constructor.
QString convertToQString(bool i18n=false) const
Cast as QString.
Physical unit angle (radians, degrees)
Specialized class for angles (degrees, radian).
static CAngleUnit rad()
Radians.
static CAngleUnit deg()
Degrees.
CPhysicalQuantity & operator+=(const CPhysicalQuantity &other)
Plus operator +=.
CPhysicalQuantity & operator-=(const CPhysicalQuantity &other)
Minus operator-=.
CPhysicalQuantity & operator*=(double multiply)
Multiply operator *=.
Value as individual values.
QString fractionalSecAsString(int width=-1) const
Fractional seconds as string.