From d035a307d88a6609eed7946f9bc65982f4c94f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 23 Jan 2020 23:19:32 +0100 Subject: [PATCH] Variables with underscores followed by a capital letter are prohibited by the C++ standard Fixes #266 --- src/GUI/gui.cpp | 16 +++++------ src/GUI/gui.h | 2 +- src/data/link.h | 8 +++--- src/data/nmeaparser.cpp | 46 ++++++++++++++++---------------- src/data/nmeaparser.h | 22 ++++++++------- src/map/albersequal.cpp | 8 +++--- src/map/albersequal.h | 2 +- src/map/krovak.cpp | 30 ++++++++++----------- src/map/krovak.h | 4 +-- src/map/lambertazimuthal.cpp | 26 +++++++++--------- src/map/lambertazimuthal.h | 5 ++-- src/map/obliquestereographic.cpp | 12 ++++----- src/map/obliquestereographic.h | 2 +- 13 files changed, 93 insertions(+), 90 deletions(-) diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index 548a6e9d..501ddcb3 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -451,11 +451,11 @@ void GUI::createActions() _degreesMinutesAction->setActionGroup(ag); connect(_degreesMinutesAction, SIGNAL(triggered()), this, SLOT(setDegreesMinutes())); - _DMSAction = new QAction(tr("Degrees, minutes, seconds (DMS)"), this); - _DMSAction->setMenuRole(QAction::NoRole); - _DMSAction->setCheckable(true); - _DMSAction->setActionGroup(ag); - connect(_DMSAction, SIGNAL(triggered()), this, SLOT(setDMS())); + _dmsAction = new QAction(tr("Degrees, minutes, seconds (DMS)"), this); + _dmsAction->setMenuRole(QAction::NoRole); + _dmsAction->setCheckable(true); + _dmsAction->setActionGroup(ag); + connect(_dmsAction, SIGNAL(triggered()), this, SLOT(setDMS())); _fullscreenAction = new QAction(QIcon(FULLSCREEN_ICON), tr("Fullscreen mode"), this); _fullscreenAction->setMenuRole(QAction::NoRole); @@ -559,7 +559,7 @@ void GUI::createMenus() QMenu *coordinatesMenu = settingsMenu->addMenu(tr("Coordinates format")); coordinatesMenu->addAction(_decimalDegreesAction); coordinatesMenu->addAction(_degreesMinutesAction); - coordinatesMenu->addAction(_DMSAction); + coordinatesMenu->addAction(_dmsAction); settingsMenu->addSeparator(); settingsMenu->addAction(_showToolbarsAction); settingsMenu->addAction(_fullscreenAction); @@ -1655,7 +1655,7 @@ void GUI::writeSettings() : _nauticalUnitsAction->isChecked() ? Nautical : Metric; if (units != UNITS_DEFAULT) settings.setValue(UNITS_SETTING, units); - CoordinatesFormat format = _DMSAction->isChecked() ? DMS + CoordinatesFormat format = _dmsAction->isChecked() ? DMS : _degreesMinutesAction->isChecked() ? DegreesMinutes : DecimalDegrees; if (format != COORDINATES_DEFAULT) settings.setValue(COORDINATES_SETTING, format); @@ -1879,7 +1879,7 @@ void GUI::readSettings() value = settings.value(COORDINATES_SETTING, COORDINATES_DEFAULT).toInt(); if (value == DMS) - _DMSAction->trigger(); + _dmsAction->trigger(); else if (value == DegreesMinutes) _degreesMinutesAction->trigger(); else diff --git a/src/GUI/gui.h b/src/GUI/gui.h index d985131d..dd10b21f 100644 --- a/src/GUI/gui.h +++ b/src/GUI/gui.h @@ -180,7 +180,7 @@ private: QAction *_nauticalUnitsAction; QAction *_decimalDegreesAction; QAction *_degreesMinutesAction; - QAction *_DMSAction; + QAction *_dmsAction; QAction *_totalTimeAction; QAction *_movingTimeAction; QAction *_nextMapAction; diff --git a/src/data/link.h b/src/data/link.h index 8ad5d8a7..16d8c332 100644 --- a/src/data/link.h +++ b/src/data/link.h @@ -7,15 +7,15 @@ class Link { public: Link() {} Link(const QString &URL, const QString &text = QString()) - : _URL(URL), _text(text) {} + : _url(URL), _text(text) {} - void setURL(const QString &URL) {_URL = URL;} + void setURL(const QString &URL) {_url = URL;} void setText(const QString &text) {_text = text;} - const QString &URL() const {return _URL;} + const QString &URL() const {return _url;} const QString &text() const {return _text;} private: - QString _URL; + QString _url; QString _text; }; diff --git a/src/data/nmeaparser.cpp b/src/data/nmeaparser.cpp index d3e69787..9dc4dacb 100644 --- a/src/data/nmeaparser.cpp +++ b/src/data/nmeaparser.cpp @@ -227,7 +227,8 @@ bool NMEAParser::readEW(const char *data, int len, qreal &lon) return true; } -bool NMEAParser::readRMC(SegmentData &segment, const char *line, int len) +bool NMEAParser::readRMC(CTX &ctx, const char *line, int len, + SegmentData &segment) { int col = 1; const char *vp = line; @@ -280,23 +281,24 @@ bool NMEAParser::readRMC(SegmentData &segment, const char *line, int len) } if (!date.isNull()) { - if (_date.isNull() && !_time.isNull() && !segment.isEmpty()) - segment.last().setTimestamp(QDateTime(date, _time, Qt::UTC)); - _date = date; + if (ctx.date.isNull() && !ctx.time.isNull() && !segment.isEmpty()) + segment.last().setTimestamp(QDateTime(date, ctx.time, Qt::UTC)); + ctx.date = date; } Coordinates c(lon, lat); - if (valid && !_GGA && c.isValid()) { + if (valid && !ctx.GGA && c.isValid()) { Trackpoint t(c); - if (!_date.isNull() && !time.isNull()) - t.setTimestamp(QDateTime(_date, time, Qt::UTC)); + if (!ctx.date.isNull() && !time.isNull()) + t.setTimestamp(QDateTime(ctx.date, time, Qt::UTC)); segment.append(t); } return true; } -bool NMEAParser::readGGA(SegmentData &segment, const char *line, int len) +bool NMEAParser::readGGA(CTX &ctx, const char *line, int len, + SegmentData &segment) { int col = 1; const char *vp = line; @@ -306,7 +308,7 @@ bool NMEAParser::readGGA(SegmentData &segment, const char *line, int len) if (*lp == ',' || *lp == '*') { switch (col) { case 1: - if (!readTime(vp, lp - vp, _time)) + if (!readTime(vp, lp - vp, ctx.time)) return false; break; case 2: @@ -360,19 +362,19 @@ bool NMEAParser::readGGA(SegmentData &segment, const char *line, int len) Coordinates c(lon, lat); if (c.isValid()) { Trackpoint t(c); - if (!(_time.isNull() || _date.isNull())) - t.setTimestamp(QDateTime(_date, _time, Qt::UTC)); + if (!(ctx.time.isNull() || ctx.date.isNull())) + t.setTimestamp(QDateTime(ctx.date, ctx.time, Qt::UTC)); if (!std::isnan(ele)) t.setElevation(ele - gh); segment.append(t); - _GGA = true; + ctx.GGA = true; } return true; } -bool NMEAParser::readWPL(QVector &waypoints, const char *line, int len) +bool NMEAParser::readWPL(const char *line, int len, QVector &waypoints) { int col = 1; const char *vp = line; @@ -423,7 +425,7 @@ bool NMEAParser::readWPL(QVector &waypoints, const char *line, int len return true; } -bool NMEAParser::readZDA(const char *line, int len) +bool NMEAParser::readZDA(CTX &ctx, const char *line, int len) { int col = 1; const char *vp = line; @@ -468,8 +470,8 @@ bool NMEAParser::readZDA(const char *line, int len) return false; } - _date = QDate(y, m, d); - if (!_date.isValid()) { + ctx.date = QDate(y, m, d); + if (!ctx.date.isValid()) { _errorString = "Invalid date"; return false; } @@ -486,13 +488,11 @@ bool NMEAParser::parse(QFile *file, QList &tracks, qint64 len; char line[80 + 2 + 1 + 1]; SegmentData segment; + CTX ctx; _errorLine = 1; _errorString.clear(); - _date = QDate(); - _time = QTime(); - _GGA = false; while (!file->atEnd()) { len = file->readLine(line, sizeof(line)); @@ -507,16 +507,16 @@ bool NMEAParser::parse(QFile *file, QList &tracks, if (validSentence(line, len)) { if (!memcmp(line + 3, "RMC,", 4)) { - if (!readRMC(segment, line + 7, len - 7)) + if (!readRMC(ctx, line + 7, len - 7, segment)) return false; } else if (!memcmp(line + 3, "GGA,", 4)) { - if (!readGGA(segment, line + 7, len - 7)) + if (!readGGA(ctx, line + 7, len - 7, segment)) return false; } else if (!memcmp(line + 3, "WPL,", 4)) { - if (!readWPL(waypoints, line + 7, len - 7)) + if (!readWPL(line + 7, len - 7, waypoints)) return false; } else if (!memcmp(line + 3, "ZDA,", 4)) { - if (!readZDA(line + 7, len - 7)) + if (!readZDA(ctx, line + 7, len - 7)) return false; } } diff --git a/src/data/nmeaparser.h b/src/data/nmeaparser.h index f34cf860..d725be36 100644 --- a/src/data/nmeaparser.h +++ b/src/data/nmeaparser.h @@ -8,7 +8,7 @@ class NMEAParser : public Parser { public: - NMEAParser() : _errorLine(0), _GGA(false) {} + NMEAParser() : _errorLine(0) {} bool parse(QFile *file, QList &tracks, QList &routes, QList &polygons, QVector &waypoints); @@ -16,6 +16,14 @@ public: int errorLine() const {return _errorLine;} private: + struct CTX { + CTX() : GGA(false) {} + + QDate date; + QTime time; + bool GGA; + }; + bool readEW(const char *data, int len, qreal &lon); bool readLon(const char *data, int len, qreal &lon); bool readNS(const char *data, int len, qreal &lat); @@ -25,17 +33,13 @@ private: bool readAltitude(const char *data, int len, qreal &ele); bool readGeoidHeight(const char *data, int len, qreal &gh); - bool readRMC(SegmentData &segment, const char *line, int len); - bool readGGA(SegmentData &segment, const char *line, int len); - bool readWPL(QVector &waypoints, const char *line, int len); - bool readZDA(const char *line, int len); + bool readRMC(CTX &ctx, const char *line, int len, SegmentData &segment); + bool readGGA(CTX &ctx, const char *line, int len, SegmentData &segment); + bool readWPL(const char *line, int len, QVector &waypoints); + bool readZDA(CTX &ctx, const char *line, int len); int _errorLine; QString _errorString; - - QDate _date; - QTime _time; - bool _GGA; }; #endif // NMEAPARSER_H diff --git a/src/map/albersequal.cpp b/src/map/albersequal.cpp index e79b4c15..f93ad20a 100644 --- a/src/map/albersequal.cpp +++ b/src/map/albersequal.cpp @@ -104,10 +104,10 @@ AlbersEqual::AlbersEqual(const Ellipsoid *ellipsoid, double standardParallel1, } else _n = sin_lat1; - _C = sqr_m1 + _n * q1; + _c = sqr_m1 + _n * q1; _a_over_n = ellipsoid->radius() / _n; nq0 = _n * q0; - _rho0 = (_C < nq0) ? 0 : _a_over_n * sqrt(_C - nq0); + _rho0 = (_c < nq0) ? 0 : _a_over_n * sqrt(_c - nq0); } PointD AlbersEqual::ll2xy(const Coordinates &c) const @@ -131,7 +131,7 @@ PointD AlbersEqual::ll2xy(const Coordinates &c) const e_sin = _e * sin_lat; q = ALBERS_Q(sin_lat, ONE_MINUS_SQR(e_sin), e_sin); nq = _n * q; - rho = (_C < nq) ? 0 : _a_over_n * sqrt(_C - nq); + rho = (_c < nq) ? 0 : _a_over_n * sqrt(_c - nq); theta = _n * dlam; return PointD(rho * sin(theta) + _falseEasting, @@ -168,7 +168,7 @@ Coordinates AlbersEqual::xy2ll(const PointD &p) const if (rho != 0.0) theta = atan2(dx, rho0_minus_dy); rho_n = rho * _n; - q = (_C - (rho_n * rho_n) / _a2) / _n; + q = (_c - (rho_n * rho_n) / _a2) / _n; qc = 1 - ((_one_minus_es) / (_two_e)) * log((1.0 - _e) / (1.0 + _e)); if (fabs(fabs(qc) - fabs(q)) > 1.0e-6) { q_over_2 = q / 2.0; diff --git a/src/map/albersequal.h b/src/map/albersequal.h index ef03d2c2..2f3f10c9 100644 --- a/src/map/albersequal.h +++ b/src/map/albersequal.h @@ -25,7 +25,7 @@ private: double _a2; double _rho0; - double _C; + double _c; double _n; double _e; double _es; diff --git a/src/map/krovak.cpp b/src/map/krovak.cpp index b3f27515..84d5b922 100644 --- a/src/map/krovak.cpp +++ b/src/map/krovak.cpp @@ -15,16 +15,16 @@ Krovak::Krovak(const Ellipsoid *ellipsoid, double standardParallel, _phiP = deg2rad(standardParallel); _e = sqrt(ellipsoid->es()); - _A = ellipsoid->radius() * sqrt(1.0 - ellipsoid->es()) + _a = ellipsoid->radius() * sqrt(1.0 - ellipsoid->es()) / (1.0 - ellipsoid->es() * sinPhiC2); - _B = sqrt(1.0 + (ellipsoid->es() * cosPhiC4 / (1.0 - ellipsoid->es()))); - double gamma0 = asin(sinPhiC / _B); + _b = sqrt(1.0 + (ellipsoid->es() * cosPhiC4 / (1.0 - ellipsoid->es()))); + double gamma0 = asin(sinPhiC / _b); _t0 = tan(M_PI_4 + gamma0 / 2.0) * pow((1.0 + _e * sinPhiC) / - (1.0 - _e * sinPhiC), _e*_B / 2.0) / pow(tan(M_PI_4 + phiC/2.0), _B); + (1.0 - _e * sinPhiC), _e*_b / 2.0) / pow(tan(M_PI_4 + phiC/2.0), _b); _n = sin(_phiP); - _r0 = scale * _A / tan(_phiP); - _FE = falseEasting; - _FN = falseNorthing; + _r0 = scale * _a / tan(_phiP); + _fe = falseEasting; + _fn = falseNorthing; _cosAlphaC = cos(alphaC); _sinAlphaC = sin(alphaC); _lambda0 = deg2rad(longitudeOrigin); @@ -35,23 +35,23 @@ PointD Krovak::ll2xy(const Coordinates &c) const double phi = deg2rad(c.lat()); double lambda = deg2rad(c.lon()); double eSinPhi = _e * sin(phi); - double U = 2.0 * (atan(_t0 * pow(tan(phi/2.0 + M_PI_4), _B) - / pow((1.0 + eSinPhi) / (1.0 - eSinPhi), _e * _B/2.0)) - M_PI_4); + double U = 2.0 * (atan(_t0 * pow(tan(phi/2.0 + M_PI_4), _b) + / pow((1.0 + eSinPhi) / (1.0 - eSinPhi), _e * _b/2.0)) - M_PI_4); double cosU = cos(U); - double V = _B * (_lambda0 - lambda); + double V = _b * (_lambda0 - lambda); double T = asin(_cosAlphaC * sin(U) + _sinAlphaC * cosU * cos(V)); double D = asin(cosU * sin(V) / cos(T)); double theta = _n * D; double r = _r0 * pow(tan(M_PI_4 + _phiP/2.0), _n) / pow(tan(T/2.0 + M_PI_4), _n); - return PointD(r * sin(theta) + _FE, r * cos(theta) + _FN); + return PointD(r * sin(theta) + _fe, r * cos(theta) + _fn); } Coordinates Krovak::xy2ll(const PointD &p) const { - double Xp = p.y() - _FN; - double Yp = p.x() - _FE; + double Xp = p.y() - _fn; + double Yp = p.x() - _fe; double Xp2 = Xp * Xp; double Yp2 = Yp * Yp; double r = sqrt(Xp2 + Yp2); @@ -63,8 +63,8 @@ Coordinates Krovak::xy2ll(const PointD &p) const double V = asin(cos(T) * sin(D) / cos(U)); double phi = U; for (int i = 0; i < 3; i++) - phi = 2.0 * (atan(pow(_t0, -1.0/_B) * pow(tan(U/2.0 + M_PI_4), 1.0/_B) + phi = 2.0 * (atan(pow(_t0, -1.0/_b) * pow(tan(U/2.0 + M_PI_4), 1.0/_b) * pow((1.0 + _e * sin(phi))/(1.0 - _e * sin(phi)), _e/2.0)) - M_PI_4); - return Coordinates(rad2deg(_lambda0 - V/_B), rad2deg(phi)); + return Coordinates(rad2deg(_lambda0 - V/_b), rad2deg(phi)); } diff --git a/src/map/krovak.h b/src/map/krovak.h index 3139d78f..17bbb983 100644 --- a/src/map/krovak.h +++ b/src/map/krovak.h @@ -18,8 +18,8 @@ public: virtual Coordinates xy2ll(const PointD &p) const; private: - double _e, _A, _B, _t0, _n, _r0, _phiP; - double _cosAlphaC, _sinAlphaC, _lambda0, _FE, _FN; + double _e, _a, _b, _t0, _n, _r0, _phiP; + double _cosAlphaC, _sinAlphaC, _lambda0, _fe, _fn; }; class KrovakNE : public CT diff --git a/src/map/lambertazimuthal.cpp b/src/map/lambertazimuthal.cpp index 6255c12f..da1ad89e 100644 --- a/src/map/lambertazimuthal.cpp +++ b/src/map/lambertazimuthal.cpp @@ -11,8 +11,8 @@ LambertAzimuthal::LambertAzimuthal(const Ellipsoid *ellipsoid, { double lat0 = deg2rad(latitudeOrigin); - _falseEasting = falseEasting; - _falseNorthing = falseNorthing; + _fe = falseEasting; + _fn = falseNorthing; _lon0 = deg2rad(longitudeOrigin); _a = ellipsoid->radius(); @@ -25,8 +25,8 @@ LambertAzimuthal::LambertAzimuthal(const Ellipsoid *ellipsoid, _qP = (1.0 - _es) * ((1.0 / (1.0 - _es)) - ((1.0/(2.0*_e)) * log((1.0 - _e) / (1.0 + _e)))); _beta0 = asin(q0 / _qP); - _Rq = _a * sqrt(_qP / 2.0); - _D = _a * (cos(lat0) / sqrt(1.0 - _es * sin2(lat0))) / (_Rq * cos(_beta0)); + _rq = _a * sqrt(_qP / 2.0); + _d = _a * (cos(lat0) / sqrt(1.0 - _es * sin2(lat0))) / (_rq * cos(_beta0)); } PointD LambertAzimuthal::ll2xy(const Coordinates &c) const @@ -38,11 +38,11 @@ PointD LambertAzimuthal::ll2xy(const Coordinates &c) const - ((1.0/(2.0*_e)) * log((1.0 - _e * sin(lat)) / (1.0 + _e * sin(lat))))); double beta = asin(q / _qP); - double B = _Rq * sqrt(2.0 / (1.0 + sin(_beta0) * sin(beta) + (cos(_beta0) + double B = _rq * sqrt(2.0 / (1.0 + sin(_beta0) * sin(beta) + (cos(_beta0) * cos(beta) * cos(lon - _lon0)))); - double x = _falseEasting + ((B * _D) * (cos(beta) * sin(lon - _lon0))); - double y = _falseNorthing + (B / _D) * ((cos(_beta0) * sin(beta)) + double x = _fe + ((B * _d) * (cos(beta) * sin(lon - _lon0))); + double y = _fn + (B / _d) * ((cos(_beta0) * sin(beta)) - (sin(_beta0) * cos(beta) * cos(lon - _lon0))); return PointD(x, y); @@ -53,14 +53,14 @@ Coordinates LambertAzimuthal::xy2ll(const PointD &p) const double es4 = _es * _es; double es6 = _es * es4; - double rho = sqrt(sqr((p.x() - _falseEasting) / _D) + sqr(_D * (p.y() - - _falseNorthing))); - double C = 2.0 * asin(rho / (2.0*_Rq)); - double betaS = asin((cos(C) * sin(_beta0)) + ((_D * (p.y() -_falseNorthing) + double rho = sqrt(sqr((p.x() - _fe) / _d) + sqr(_d * (p.y() + - _fn))); + double C = 2.0 * asin(rho / (2.0*_rq)); + double betaS = asin((cos(C) * sin(_beta0)) + ((_d * (p.y() -_fn) * sin(C) * cos(_beta0)) / rho)); - double lon = _lon0 + atan((p.x() - _falseEasting) * sin(C) / (_D * rho - * cos(_beta0) * cos(C) - sqr(_D) * (p.y() - _falseNorthing) * sin(_beta0) + double lon = _lon0 + atan((p.x() - _fe) * sin(C) / (_d * rho + * cos(_beta0) * cos(C) - sqr(_d) * (p.y() - _fn) * sin(_beta0) * sin(C))); double lat = betaS + ((_es/3.0 + 31.0*es4/180.0 + 517.0*es6/5040.0) * sin(2.0*betaS)) + ((23.0*es4/360.0 + 251.0*es6/3780.0) * sin(4.0*betaS)) diff --git a/src/map/lambertazimuthal.h b/src/map/lambertazimuthal.h index eecd329b..f7aab623 100644 --- a/src/map/lambertazimuthal.h +++ b/src/map/lambertazimuthal.h @@ -18,9 +18,8 @@ public: private: double _lon0; - double _falseNorthing; - double _falseEasting; - double _a, _e, _es, _qP, _beta0, _Rq, _D; + double _fn, _fe; + double _a, _e, _es, _qP, _beta0, _rq, _d; }; #endif // LAMBERTAZIMUTHAL_H diff --git a/src/map/obliquestereographic.cpp b/src/map/obliquestereographic.cpp index f7c2c84e..b3add846 100644 --- a/src/map/obliquestereographic.cpp +++ b/src/map/obliquestereographic.cpp @@ -8,7 +8,7 @@ ObliqueStereographic::ObliqueStereographic(const Ellipsoid *ellipsoid, double latitudeOrigin, double longitudeOrigin, double scale, double falseEasting, double falseNorthing) - : _FE(falseEasting), _FN(falseNorthing) + : _fe(falseEasting), _fn(falseNorthing) { double lat0 = deg2rad(latitudeOrigin); double sinPhi0 = sin(lat0); @@ -48,17 +48,17 @@ PointD ObliqueStereographic::ll2xy(const Coordinates &c) const double B = (1.0 + sin(chi) * _sinChi0 + cos(chi) * _cosChi0 * cos(lambda - _lambda0)); - return PointD(_FE + _twoRk0 * cos(chi) * sin(lambda - _lambda0) / B, - _FN + _twoRk0 * (sin(chi) * _cosChi0 - cos(chi) * _sinChi0 + return PointD(_fe + _twoRk0 * cos(chi) * sin(lambda - _lambda0) / B, + _fn + _twoRk0 * (sin(chi) * _cosChi0 - cos(chi) * _sinChi0 * cos(lambda - _lambda0)) / B); } Coordinates ObliqueStereographic::xy2ll(const PointD &p) const { - double i = atan((p.x() - _FE) / (_h + (p.y() - _FN))); - double j = atan((p.x() - _FE) / (_g - (p.y() - _FN))) - i; + double i = atan((p.x() - _fe) / (_h + (p.y() - _fn))); + double j = atan((p.x() - _fe) / (_g - (p.y() - _fn))) - i; - double chi = _chi0 + 2.0 * atan(((p.y() - _FN) - (p.x() - _FE) * tan(j/2.0)) + double chi = _chi0 + 2.0 * atan(((p.y() - _fn) - (p.x() - _fe) * tan(j/2.0)) / _twoRk0); double lambda = j + 2.0 * i + _lambda0; diff --git a/src/map/obliquestereographic.h b/src/map/obliquestereographic.h index c0ae7039..429be7dc 100644 --- a/src/map/obliquestereographic.h +++ b/src/map/obliquestereographic.h @@ -22,7 +22,7 @@ private: double _lambda0; double _n; double _c; - double _FE, _FN; + double _fe, _fn; double _twoRk0, _g, _h; };