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

Added support for MultiGeometry objects in KML

This commit is contained in:
Martin Tůma 2016-11-08 20:50:42 +01:00
parent d201101587
commit 9f06b042ca
2 changed files with 41 additions and 15 deletions

View File

@ -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();
}

View File

@ -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);