diff --git a/src/kmlparser.cpp b/src/kmlparser.cpp index 24c3b9c2..bcb13f1e 100644 --- a/src/kmlparser.cpp +++ b/src/kmlparser.cpp @@ -225,7 +225,7 @@ void KMLParser::point(Waypoint &waypoint) _reader.raiseError("Missing Point coordinates"); } -void KMLParser::Track(TrackData &track) +void KMLParser::track(TrackData &track) { const char mismatchError[] = "gx:coord/when element count mismatch"; int i = track.size(); @@ -251,6 +251,28 @@ void KMLParser::Track(TrackData &track) _reader.raiseError(mismatchError); } +void KMLParser::multiGeometry(const QString &name, const QString &desc, + const QDateTime timestamp) +{ + while (_reader.readNextStartElement()) { + if (_reader.name() == "Point") { + _waypoints.append(Waypoint()); + Waypoint &w = _waypoints.last(); + w.setName(name); + w.setDescription(desc); + w.setTimestamp(timestamp); + point(w); + } else if (_reader.name() == "LineString") { + _tracks.append(TrackData()); + TrackData &t = _tracks.last(); + t.setName(name); + t.setDescription(desc); + lineString(t); + } else + _reader.skipCurrentElement(); + } +} + void KMLParser::placemark() { QString name, desc; @@ -263,25 +285,27 @@ void KMLParser::placemark() desc = _reader.readElementText(); else if (_reader.name() == "TimeStamp") timestamp = timeStamp(); + else if (_reader.name() == "MultiGeometry") + multiGeometry(name, desc, timestamp); else if (_reader.name() == "Point") { _waypoints.append(Waypoint()); - Waypoint &waypoint = _waypoints.last(); - waypoint.setName(name); - waypoint.setDescription(desc); - waypoint.setTimestamp(timestamp); - point(waypoint); + Waypoint &w = _waypoints.last(); + w.setName(name); + w.setDescription(desc); + w.setTimestamp(timestamp); + point(w); } else if (_reader.name() == "LineString") { _tracks.append(TrackData()); - TrackData &track = _tracks.last(); - track.setName(name); - track.setDescription(desc); - lineString(track); + TrackData &t = _tracks.last(); + t.setName(name); + t.setDescription(desc); + lineString(t); } else if (_reader.name() == "Track") { _tracks.append(TrackData()); - TrackData &track = _tracks.last(); - track.setName(name); - track.setDescription(desc); - Track(track); + TrackData &t = _tracks.last(); + t.setName(name); + t.setDescription(desc); + track(t); } else _reader.skipCurrentElement(); } diff --git a/src/kmlparser.h b/src/kmlparser.h index 9596a610..2e872ebf 100644 --- a/src/kmlparser.h +++ b/src/kmlparser.h @@ -22,7 +22,9 @@ private: void document(); void folder(); void placemark(); - void Track(TrackData &track); + void multiGeometry(const QString &name, const QString &desc, + const QDateTime timestamp); + void track(TrackData &track); void lineString(TrackData &track); void point(Waypoint &waypoint); bool pointCoordinates(Waypoint &waypoint);