1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-19 04:02:09 +01:00

Use LineStrings as Tracks rather than routes in KML files

This commit is contained in:
Martin Tůma 2016-10-28 01:33:44 +02:00
parent 7827509a4a
commit 0e5eb7287d
2 changed files with 9 additions and 9 deletions

View File

@ -79,7 +79,7 @@ bool KMLParser::pointCoordinates(Waypoint &waypoint)
return true; return true;
} }
bool KMLParser::lineCoordinates(QVector<Waypoint> &route) bool KMLParser::lineCoordinates(QVector<Trackpoint> &track)
{ {
QString data = _reader.readElementText(); QString data = _reader.readElementText();
const QChar *sp, *ep, *cp, *vp; const QChar *sp, *ep, *cp, *vp;
@ -122,9 +122,9 @@ bool KMLParser::lineCoordinates(QVector<Waypoint> &route)
if (!res) if (!res)
return false; return false;
route.append(Waypoint(Coordinates(val[0], val[1]))); track.append(Trackpoint(Coordinates(val[0], val[1])));
if (c == 2) if (c == 2)
route.last().setElevation(val[2]); track.last().setElevation(val[2]);
while (cp->isSpace()) while (cp->isSpace())
cp++; cp++;
@ -146,11 +146,11 @@ void KMLParser::timeStamp(Waypoint &waypoint)
} }
} }
void KMLParser::lineString(QVector<Waypoint> &route) void KMLParser::lineString(QVector<Trackpoint> &track)
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == "coordinates") { if (_reader.name() == "coordinates") {
if (!lineCoordinates(route)) if (!lineCoordinates(track))
_reader.raiseError("Invalid coordinates."); _reader.raiseError("Invalid coordinates.");
} else } else
_reader.skipCurrentElement(); _reader.skipCurrentElement();
@ -183,8 +183,8 @@ void KMLParser::placemark()
_waypoints.append(waypoint); _waypoints.append(waypoint);
point(_waypoints.last()); point(_waypoints.last());
} else if (_reader.name() == "LineString") { } else if (_reader.name() == "LineString") {
_routes.append(QVector<Waypoint>()); _tracks.append(QVector<Trackpoint>());
lineString(_routes.back()); lineString(_tracks.last());
} else } else
_reader.skipCurrentElement(); _reader.skipCurrentElement();
} }

View File

@ -23,10 +23,10 @@ private:
void document(); void document();
void folder(); void folder();
void placemark(); void placemark();
void lineString(QVector<Waypoint> &route); void lineString(QVector<Trackpoint> &track);
void point(Waypoint &waypoint); void point(Waypoint &waypoint);
bool pointCoordinates(Waypoint &waypoint); bool pointCoordinates(Waypoint &waypoint);
bool lineCoordinates(QVector<Waypoint> &route); bool lineCoordinates(QVector<Trackpoint> &track);
void timeStamp(Waypoint &waypoint); void timeStamp(Waypoint &waypoint);
qreal number(); qreal number();
QDateTime time(); QDateTime time();