1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-27 03:29:16 +02:00

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

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

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