mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Fixed empty CSV fields handling
This commit is contained in:
parent
3f71775101
commit
5eaf0455aa
@ -55,22 +55,28 @@ bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
Trackpoint tp(gcs->toWGS84(Coordinates(lon, lat)));
|
||||
|
||||
if (list.size() >= 4) {
|
||||
double elevation = list.at(3).trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid elevation";
|
||||
return false;
|
||||
QByteArray field(list.at(3).trimmed());
|
||||
if (!field.isEmpty()) {
|
||||
double elevation = field.toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid elevation";
|
||||
return false;
|
||||
}
|
||||
if (elevation != -777)
|
||||
tp.setElevation(elevation * 0.3048);
|
||||
}
|
||||
if (elevation != -777)
|
||||
tp.setElevation(elevation * 0.3048);
|
||||
}
|
||||
if (list.size() >= 5) {
|
||||
double date = list.at(4).trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid date";
|
||||
return false;
|
||||
QByteArray field(list.at(4).trimmed());
|
||||
if (!field.isEmpty()) {
|
||||
double date = field.toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid date";
|
||||
return false;
|
||||
}
|
||||
tp.setTimestamp(QDateTime::fromMSecsSinceEpoch(
|
||||
Date::delphi2unixMS(date)));
|
||||
}
|
||||
tp.setTimestamp(QDateTime::fromMSecsSinceEpoch(
|
||||
Date::delphi2unixMS(date)));
|
||||
}
|
||||
|
||||
track.append(tp);
|
||||
|
@ -68,17 +68,21 @@ bool RTEParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
if (!name.isEmpty())
|
||||
wp.setName(name);
|
||||
if (list.size() >= 8) {
|
||||
double date = list.at(7).trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid date";
|
||||
return false;
|
||||
QByteArray field(list.at(7).trimmed());
|
||||
if (!field.isEmpty()) {
|
||||
double date = field.toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid date";
|
||||
return false;
|
||||
}
|
||||
wp.setTimestamp(QDateTime::fromMSecsSinceEpoch(
|
||||
Date::delphi2unixMS(date)));
|
||||
}
|
||||
wp.setTimestamp(QDateTime::fromMSecsSinceEpoch(
|
||||
Date::delphi2unixMS(date)));
|
||||
}
|
||||
if (list.size() >= 14) {
|
||||
QString desc(list.at(13).trimmed().replace('\xD1', ','));
|
||||
wp.setDescription(desc);
|
||||
if (!desc.isEmpty())
|
||||
wp.setDescription(desc);
|
||||
}
|
||||
|
||||
routes.last().append(wp);
|
||||
|
@ -51,26 +51,33 @@ bool WPTParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
if (!name.isEmpty())
|
||||
wp.setName(name);
|
||||
if (list.size() >= 5) {
|
||||
double date = list.at(4).trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid date";
|
||||
return false;
|
||||
QByteArray field(list.at(4).trimmed());
|
||||
if (!field.isEmpty()) {
|
||||
double date = field.toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid date";
|
||||
return false;
|
||||
}
|
||||
wp.setTimestamp(QDateTime::fromMSecsSinceEpoch(
|
||||
Date::delphi2unixMS(date)));
|
||||
}
|
||||
wp.setTimestamp(QDateTime::fromMSecsSinceEpoch(
|
||||
Date::delphi2unixMS(date)));
|
||||
}
|
||||
if (list.size() >= 11) {
|
||||
QString desc(list.at(10).trimmed().replace('\xD1', ','));
|
||||
if (!desc.isEmpty())
|
||||
wp.setDescription(desc);
|
||||
} if (list.size() >= 15) {
|
||||
double elevation = list.at(14).trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid elevation";
|
||||
return false;
|
||||
}
|
||||
if (list.size() >= 15) {
|
||||
QByteArray field(list.at(14).trimmed());
|
||||
if (!field.isEmpty()) {
|
||||
double elevation = list.at(14).trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid elevation";
|
||||
return false;
|
||||
}
|
||||
if (elevation != -777)
|
||||
wp.setElevation(elevation * 0.3048);
|
||||
}
|
||||
if (elevation != -777)
|
||||
wp.setElevation(elevation * 0.3048);
|
||||
}
|
||||
|
||||
waypoints.append(wp);
|
||||
|
Loading…
Reference in New Issue
Block a user