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

Fixed error line reporting in CSV-based files

This commit is contained in:
2024-03-23 09:16:41 +01:00
parent e8b4105365
commit 01dfbb3706
6 changed files with 72 additions and 40 deletions

View File

@ -14,22 +14,27 @@ bool CSVParser::parse(QFile *file, QList<TrackData> &tracks,
bool ok;
while (!csv.atEnd()) {
if (!csv.readEntry(entry) || entry.size() < 3) {
if (!csv.readEntry(entry)) {
_errorString = "Parse error";
_errorLine = csv.line();
return false;
}
if (entry.size() < 3) {
_errorString = "Invalid column count";
_errorLine = csv.line() - 1;
return false;
}
double lon = entry.at(0).toDouble(&ok);
if (!ok || (lon < -180.0 || lon > 180.0)) {
_errorString = "Invalid longitude";
_errorLine = csv.line();
_errorLine = csv.line() - 1;
return false;
}
double lat = entry.at(1).toDouble(&ok);
if (!ok || (lat < -90.0 || lat > 90.0)) {
_errorString = "Invalid latitude";
_errorLine = csv.line();
_errorLine = csv.line() - 1;
return false;
}
Waypoint wp(Coordinates(lon, lat));

View File

@ -159,7 +159,7 @@ bool CUPParser::parse(QFile *file, QList<TrackData> &tracks,
return false;
}
_errorLine = csv.line();
_errorLine = csv.line() - 1;
}
return true;