1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Variables with underscores followed by a capital letter are prohibited by the C++ standard

Fixes #266
This commit is contained in:
Martin Tůma 2020-01-23 23:19:32 +01:00
parent 2ff2195116
commit d035a307d8
13 changed files with 93 additions and 90 deletions

View File

@ -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

View File

@ -180,7 +180,7 @@ private:
QAction *_nauticalUnitsAction;
QAction *_decimalDegreesAction;
QAction *_degreesMinutesAction;
QAction *_DMSAction;
QAction *_dmsAction;
QAction *_totalTimeAction;
QAction *_movingTimeAction;
QAction *_nextMapAction;

View File

@ -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;
};

View File

@ -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<Waypoint> &waypoints, const char *line, int len)
bool NMEAParser::readWPL(const char *line, int len, QVector<Waypoint> &waypoints)
{
int col = 1;
const char *vp = line;
@ -423,7 +425,7 @@ bool NMEAParser::readWPL(QVector<Waypoint> &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<TrackData> &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<TrackData> &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;
}
}

View File

@ -8,7 +8,7 @@
class NMEAParser : public Parser
{
public:
NMEAParser() : _errorLine(0), _GGA(false) {}
NMEAParser() : _errorLine(0) {}
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Area> &polygons, QVector<Waypoint> &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<Waypoint> &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<Waypoint> &waypoints);
bool readZDA(CTX &ctx, const char *line, int len);
int _errorLine;
QString _errorString;
QDate _date;
QTime _time;
bool _GGA;
};
#endif // NMEAPARSER_H

View File

@ -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;

View File

@ -25,7 +25,7 @@ private:
double _a2;
double _rho0;
double _C;
double _c;
double _n;
double _e;
double _es;

View File

@ -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));
}

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -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;

View File

@ -22,7 +22,7 @@ private:
double _lambda0;
double _n;
double _c;
double _FE, _FN;
double _fe, _fn;
double _twoRk0, _g, _h;
};