mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Fixed error line reporting in CSV-based files
This commit is contained in:
parent
e8b4105365
commit
01dfbb3706
@ -14,22 +14,27 @@ bool CSVParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
while (!csv.atEnd()) {
|
while (!csv.atEnd()) {
|
||||||
if (!csv.readEntry(entry) || entry.size() < 3) {
|
if (!csv.readEntry(entry)) {
|
||||||
_errorString = "Parse error";
|
_errorString = "Parse error";
|
||||||
_errorLine = csv.line();
|
_errorLine = csv.line();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (entry.size() < 3) {
|
||||||
|
_errorString = "Invalid column count";
|
||||||
|
_errorLine = csv.line() - 1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
double lon = entry.at(0).toDouble(&ok);
|
double lon = entry.at(0).toDouble(&ok);
|
||||||
if (!ok || (lon < -180.0 || lon > 180.0)) {
|
if (!ok || (lon < -180.0 || lon > 180.0)) {
|
||||||
_errorString = "Invalid longitude";
|
_errorString = "Invalid longitude";
|
||||||
_errorLine = csv.line();
|
_errorLine = csv.line() - 1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
double lat = entry.at(1).toDouble(&ok);
|
double lat = entry.at(1).toDouble(&ok);
|
||||||
if (!ok || (lat < -90.0 || lat > 90.0)) {
|
if (!ok || (lat < -90.0 || lat > 90.0)) {
|
||||||
_errorString = "Invalid latitude";
|
_errorString = "Invalid latitude";
|
||||||
_errorLine = csv.line();
|
_errorLine = csv.line() - 1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Waypoint wp(Coordinates(lon, lat));
|
Waypoint wp(Coordinates(lon, lat));
|
||||||
|
@ -159,7 +159,7 @@ bool CUPParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_errorLine = csv.line();
|
_errorLine = csv.line() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -147,50 +147,55 @@ bool Conversion::loadList(const QString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (!csv.atEnd()) {
|
while (!csv.atEnd()) {
|
||||||
if (!csv.readEntry(entry) || entry.size() < 26) {
|
if (!csv.readEntry(entry)) {
|
||||||
qWarning("%s:%d: Parse error", qPrintable(path), csv.line());
|
qWarning("%s:%d: Parse error", qPrintable(path), csv.line());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (entry.size() < 26) {
|
||||||
|
qWarning("%s:%d: Invalid column count", qPrintable(path),
|
||||||
|
csv.line() - 1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString name(entry.at(0));
|
QString name(entry.at(0));
|
||||||
int proj = entry.at(1).toInt(&res);
|
int proj = entry.at(1).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid projection code", qPrintable(path),
|
qWarning("%s:%d: Invalid projection code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int units = entry.at(2).toInt(&res);
|
int units = entry.at(2).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid linear units code", qPrintable(path),
|
qWarning("%s:%d: Invalid linear units code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int transform = entry.at(3).toInt(&res);
|
int transform = entry.at(3).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid coordinate transformation code",
|
qWarning("%s:%d: Invalid coordinate transformation code",
|
||||||
qPrintable(path), csv.line());
|
qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int cs = entry.at(4).toInt(&res);
|
int cs = entry.at(4).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid coordinate system code",
|
qWarning("%s:%d: Invalid coordinate system code",
|
||||||
qPrintable(path), csv.line());
|
qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LinearUnits(units).isValid()) {
|
if (!LinearUnits(units).isValid()) {
|
||||||
qWarning("%s:%d: Unknown linear units code", qPrintable(path),
|
qWarning("%s:%d: Unknown linear units code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!Method(transform).isValid()) {
|
if (!Method(transform).isValid()) {
|
||||||
qWarning("%s:%d: Unknown coordinate transformation code",
|
qWarning("%s:%d: Unknown coordinate transformation code",
|
||||||
qPrintable(path), csv.line());
|
qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!CoordinateSystem(cs).isValid()) {
|
if (!CoordinateSystem(cs).isValid()) {
|
||||||
qWarning("%s:%d: Unknown coordinate system code", qPrintable(path),
|
qWarning("%s:%d: Unknown coordinate system code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,25 +44,32 @@ bool Ellipsoid::loadList(const QString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (!csv.atEnd()) {
|
while (!csv.atEnd()) {
|
||||||
if (!csv.readEntry(entry) || entry.size() < 4) {
|
if (!csv.readEntry(entry)) {
|
||||||
qWarning("%s:%d: Parse error", qPrintable(path), csv.line());
|
qWarning("%s:%d: Parse error", qPrintable(path), csv.line());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (entry.size() < 4) {
|
||||||
|
qWarning("%s:%d: Invalid column count", qPrintable(path),
|
||||||
|
csv.line() - 1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int id = entry.at(1).toInt(&res);
|
int id = entry.at(1).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s: %d: Invalid ellipsoid code", qPrintable(path),
|
qWarning("%s: %d: Invalid ellipsoid code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double radius = entry.at(2).toDouble(&res);
|
double radius = entry.at(2).toDouble(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s: %d: Invalid radius", qPrintable(path), csv.line());
|
qWarning("%s: %d: Invalid radius", qPrintable(path),
|
||||||
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double flattening = entry.at(3).toDouble(&res);
|
double flattening = entry.at(3).toDouble(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s: %d: Invalid flattening", qPrintable(path), csv.line());
|
qWarning("%s: %d: Invalid flattening", qPrintable(path),
|
||||||
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,86 +101,92 @@ bool GCS::loadList(const QString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (!csv.atEnd()) {
|
while (!csv.atEnd()) {
|
||||||
if (!csv.readEntry(entry) || entry.size() < 14) {
|
if (!csv.readEntry(entry)) {
|
||||||
qWarning("%s:%d: Parse error", qPrintable(path), csv.line());
|
qWarning("%s:%d: Parse error", qPrintable(path), csv.line());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (entry.size() < 14) {
|
||||||
|
qWarning("%s:%d: Invalid column count", qPrintable(path),
|
||||||
|
csv.line() - 1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int id = parameter(entry.at(1), &res);
|
int id = parameter(entry.at(1), &res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid GCS code", qPrintable(path), csv.line());
|
qWarning("%s:%d: Invalid GCS code", qPrintable(path),
|
||||||
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int gd = parameter(entry.at(2), &res);
|
int gd = parameter(entry.at(2), &res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid geodetic datum code", qPrintable(path),
|
qWarning("%s:%d: Invalid geodetic datum code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int au = entry.at(3).toInt(&res);
|
int au = entry.at(3).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid angular units code", qPrintable(path),
|
qWarning("%s:%d: Invalid angular units code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int el = entry.at(4).toInt(&res);
|
int el = entry.at(4).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid ellipsoid code", qPrintable(path),
|
qWarning("%s:%d: Invalid ellipsoid code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int pm = entry.at(5).toInt(&res);
|
int pm = entry.at(5).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid prime meridian code", qPrintable(path),
|
qWarning("%s:%d: Invalid prime meridian code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int ct = entry.at(6).toInt(&res);
|
int ct = entry.at(6).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid coordinates transformation code",
|
qWarning("%s:%d: Invalid coordinates transformation code",
|
||||||
qPrintable(path), csv.line());
|
qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double dx = entry.at(7).toDouble(&res);
|
double dx = entry.at(7).toDouble(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid dx", qPrintable(path), csv.line());
|
qWarning("%s:%d: Invalid dx", qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double dy = entry.at(8).toDouble(&res);
|
double dy = entry.at(8).toDouble(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid dy", qPrintable(path), csv.line());
|
qWarning("%s:%d: Invalid dy", qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double dz = entry.at(9).toDouble(&res);
|
double dz = entry.at(9).toDouble(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid dz", qPrintable(path), csv.line());
|
qWarning("%s:%d: Invalid dz", qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double rx = parameterd(entry.at(10), &res);
|
double rx = parameterd(entry.at(10), &res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid rx", qPrintable(path), csv.line());
|
qWarning("%s:%d: Invalid rx", qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double ry = parameterd(entry.at(11), &res);
|
double ry = parameterd(entry.at(11), &res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid ry", qPrintable(path), csv.line());
|
qWarning("%s:%d: Invalid ry", qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double rz = parameterd(entry.at(12), &res);
|
double rz = parameterd(entry.at(12), &res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid rz", qPrintable(path), csv.line());
|
qWarning("%s:%d: Invalid rz", qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double ds = parameterd(entry.at(13), &res);
|
double ds = parameterd(entry.at(13), &res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid ds", qPrintable(path), csv.line());
|
qWarning("%s:%d: Invalid ds", qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Ellipsoid &e = Ellipsoid::ellipsoid(el);
|
const Ellipsoid &e = Ellipsoid::ellipsoid(el);
|
||||||
if (e.isNull()) {
|
if (e.isNull()) {
|
||||||
qWarning("%s:%d: Unknown ellipsoid code", qPrintable(path),
|
qWarning("%s:%d: Unknown ellipsoid code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,12 +203,12 @@ bool GCS::loadList(const QString &path)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning("%s:%d: Unknown coordinates transformation method",
|
qWarning("%s:%d: Unknown coordinates transformation method",
|
||||||
qPrintable(path), csv.line());
|
qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!datum.isValid()) {
|
if (!datum.isValid()) {
|
||||||
qWarning("%s:%d: Invalid coordinates transformation parameters",
|
qWarning("%s:%d: Invalid coordinates transformation parameters",
|
||||||
qPrintable(path), csv.line());
|
qPrintable(path), csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +217,7 @@ bool GCS::loadList(const QString &path)
|
|||||||
_gcss.append(Entry(id, gd, entry.at(0), gcs));
|
_gcss.append(Entry(id, gd, entry.at(0), gcs));
|
||||||
else
|
else
|
||||||
qWarning("%s:%d: Unknown prime meridian/angular units code",
|
qWarning("%s:%d: Unknown prime meridian/angular units code",
|
||||||
qPrintable(path), csv.line());
|
qPrintable(path), csv.line() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -37,35 +37,44 @@ bool PCS::loadList(const QString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (!csv.atEnd()) {
|
while (!csv.atEnd()) {
|
||||||
if (!csv.readEntry(entry) || entry.size() < 4) {
|
if (!csv.readEntry(entry)) {
|
||||||
qWarning("%s:%d: Parse error", qPrintable(path), csv.line());
|
qWarning("%s:%d: Parse error", qPrintable(path), csv.line());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (entry.size() < 4) {
|
||||||
|
qWarning("%s:%d: Invalid column count", qPrintable(path),
|
||||||
|
csv.line() - 1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString name(entry.at(0));
|
QString name(entry.at(0));
|
||||||
int id = entry.at(1).toInt(&res);
|
int id = entry.at(1).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid PCS code", qPrintable(path), csv.line());
|
qWarning("%s:%d: Invalid PCS code", qPrintable(path),
|
||||||
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int gcs = entry.at(2).toInt(&res);
|
int gcs = entry.at(2).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid GCS code", qPrintable(path), csv.line());
|
qWarning("%s:%d: Invalid GCS code", qPrintable(path),
|
||||||
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int proj = entry.at(3).toInt(&res);
|
int proj = entry.at(3).toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid projection code", qPrintable(path),
|
qWarning("%s:%d: Invalid projection code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GCS::gcs(gcs).isNull()) {
|
if (GCS::gcs(gcs).isNull()) {
|
||||||
qWarning("%s:%d: Unknown GCS code", qPrintable(path), csv.line());
|
qWarning("%s:%d: Unknown GCS code", qPrintable(path),
|
||||||
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Conversion::conversion(proj).isNull()) {
|
if (Conversion::conversion(proj).isNull()) {
|
||||||
qWarning("%s:%d: Unknown projection code", qPrintable(path),
|
qWarning("%s:%d: Unknown projection code", qPrintable(path),
|
||||||
csv.line());
|
csv.line() - 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user