From 0e5eb7287da8a6176a26011167c036653bb20861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 28 Oct 2016 01:33:44 +0200 Subject: [PATCH] Use LineStrings as Tracks rather than routes in KML files --- src/kmlparser.cpp | 14 +++++++------- src/kmlparser.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/kmlparser.cpp b/src/kmlparser.cpp index 7838ac5d..32619568 100644 --- a/src/kmlparser.cpp +++ b/src/kmlparser.cpp @@ -79,7 +79,7 @@ bool KMLParser::pointCoordinates(Waypoint &waypoint) return true; } -bool KMLParser::lineCoordinates(QVector &route) +bool KMLParser::lineCoordinates(QVector &track) { QString data = _reader.readElementText(); const QChar *sp, *ep, *cp, *vp; @@ -122,9 +122,9 @@ bool KMLParser::lineCoordinates(QVector &route) if (!res) return false; - route.append(Waypoint(Coordinates(val[0], val[1]))); + track.append(Trackpoint(Coordinates(val[0], val[1]))); if (c == 2) - route.last().setElevation(val[2]); + track.last().setElevation(val[2]); while (cp->isSpace()) cp++; @@ -146,11 +146,11 @@ void KMLParser::timeStamp(Waypoint &waypoint) } } -void KMLParser::lineString(QVector &route) +void KMLParser::lineString(QVector &track) { while (_reader.readNextStartElement()) { if (_reader.name() == "coordinates") { - if (!lineCoordinates(route)) + if (!lineCoordinates(track)) _reader.raiseError("Invalid coordinates."); } else _reader.skipCurrentElement(); @@ -183,8 +183,8 @@ void KMLParser::placemark() _waypoints.append(waypoint); point(_waypoints.last()); } else if (_reader.name() == "LineString") { - _routes.append(QVector()); - lineString(_routes.back()); + _tracks.append(QVector()); + lineString(_tracks.last()); } else _reader.skipCurrentElement(); } diff --git a/src/kmlparser.h b/src/kmlparser.h index aced6990..e1d71e3b 100644 --- a/src/kmlparser.h +++ b/src/kmlparser.h @@ -23,10 +23,10 @@ private: void document(); void folder(); void placemark(); - void lineString(QVector &route); + void lineString(QVector &track); void point(Waypoint &waypoint); bool pointCoordinates(Waypoint &waypoint); - bool lineCoordinates(QVector &route); + bool lineCoordinates(QVector &track); void timeStamp(Waypoint &waypoint); qreal number(); QDateTime time();