mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Fixed empty CSV fields handling
This commit is contained in:
parent
3f71775101
commit
5eaf0455aa
@ -55,7 +55,9 @@ 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);
|
||||
QByteArray field(list.at(3).trimmed());
|
||||
if (!field.isEmpty()) {
|
||||
double elevation = field.toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid elevation";
|
||||
return false;
|
||||
@ -63,8 +65,11 @@ bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
if (elevation != -777)
|
||||
tp.setElevation(elevation * 0.3048);
|
||||
}
|
||||
}
|
||||
if (list.size() >= 5) {
|
||||
double date = list.at(4).trimmed().toDouble(&res);
|
||||
QByteArray field(list.at(4).trimmed());
|
||||
if (!field.isEmpty()) {
|
||||
double date = field.toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid date";
|
||||
return false;
|
||||
@ -72,6 +77,7 @@ bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
tp.setTimestamp(QDateTime::fromMSecsSinceEpoch(
|
||||
Date::delphi2unixMS(date)));
|
||||
}
|
||||
}
|
||||
|
||||
track.append(tp);
|
||||
}
|
||||
|
@ -68,7 +68,9 @@ 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);
|
||||
QByteArray field(list.at(7).trimmed());
|
||||
if (!field.isEmpty()) {
|
||||
double date = field.toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid date";
|
||||
return false;
|
||||
@ -76,8 +78,10 @@ bool RTEParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
wp.setTimestamp(QDateTime::fromMSecsSinceEpoch(
|
||||
Date::delphi2unixMS(date)));
|
||||
}
|
||||
}
|
||||
if (list.size() >= 14) {
|
||||
QString desc(list.at(13).trimmed().replace('\xD1', ','));
|
||||
if (!desc.isEmpty())
|
||||
wp.setDescription(desc);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,9 @@ 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);
|
||||
QByteArray field(list.at(4).trimmed());
|
||||
if (!field.isEmpty()) {
|
||||
double date = field.toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid date";
|
||||
return false;
|
||||
@ -59,11 +61,15 @@ bool WPTParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
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) {
|
||||
}
|
||||
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";
|
||||
@ -72,6 +78,7 @@ bool WPTParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
if (elevation != -777)
|
||||
wp.setElevation(elevation * 0.3048);
|
||||
}
|
||||
}
|
||||
|
||||
waypoints.append(wp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user