mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-30 22:51:16 +01:00
Some more GPX parser code cleanup
This commit is contained in:
parent
b67428065f
commit
a773921da0
@ -166,33 +166,33 @@ void GPXParser::waypointData(Waypoint &waypoint)
|
||||
waypoint.setElevation(waypoint.elevation() - gh);
|
||||
}
|
||||
|
||||
void GPXParser::trackpoints()
|
||||
void GPXParser::trackpoints(QVector<Trackpoint> &track)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trkpt") {
|
||||
_track->append(Trackpoint(coordinates()));
|
||||
trackpointData(_track->last());
|
||||
track.append(Trackpoint(coordinates()));
|
||||
trackpointData(track.last());
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void GPXParser::routepoints()
|
||||
void GPXParser::routepoints(QVector<Waypoint> &route)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "rtept") {
|
||||
_route->append(Waypoint(coordinates()));
|
||||
waypointData(_route->last());
|
||||
route.append(Waypoint(coordinates()));
|
||||
waypointData(route.last());
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void GPXParser::track()
|
||||
void GPXParser::track(QVector<Trackpoint> &track)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trkseg") {
|
||||
trackpoints();
|
||||
trackpoints(track);
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
@ -203,12 +203,10 @@ void GPXParser::gpx()
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trk") {
|
||||
_tracks.append(QVector<Trackpoint>());
|
||||
_track = &_tracks.back();
|
||||
track();
|
||||
track(_tracks.back());
|
||||
} else if (_reader.name() == "rte") {
|
||||
_routes.append(QVector<Waypoint>());
|
||||
_route = &_routes.back();
|
||||
routepoints();
|
||||
routepoints(_routes.back());
|
||||
} else if (_reader.name() == "wpt") {
|
||||
_waypoints.append(Waypoint(coordinates()));
|
||||
waypointData(_waypoints.last());
|
||||
|
@ -11,7 +11,7 @@ class GPXParser : public Parser
|
||||
public:
|
||||
GPXParser(QList<QVector<Trackpoint> > &tracks,
|
||||
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
||||
: Parser(tracks, routes, waypoints) {_track = 0; _route = 0;}
|
||||
: Parser(tracks, routes, waypoints) {}
|
||||
~GPXParser() {}
|
||||
|
||||
bool loadFile(QIODevice *device);
|
||||
@ -25,9 +25,9 @@ private:
|
||||
|
||||
bool parse();
|
||||
void gpx();
|
||||
void track();
|
||||
void trackpoints();
|
||||
void routepoints();
|
||||
void track(QVector<Trackpoint> &track);
|
||||
void trackpoints(QVector<Trackpoint> &track);
|
||||
void routepoints(QVector<Waypoint> &route);
|
||||
void tpExtension(Trackpoint &trackpoint);
|
||||
void extensions(Trackpoint &trackpoint);
|
||||
void trackpointData(Trackpoint &trackpoint);
|
||||
@ -40,8 +40,6 @@ private:
|
||||
void handleTrackpointData(DataType type, Trackpoint &trackpoint);
|
||||
|
||||
QXmlStreamReader _reader;
|
||||
QVector<Trackpoint> *_track;
|
||||
QVector<Waypoint> *_route;
|
||||
};
|
||||
|
||||
#endif // GPXPARSER_H
|
||||
|
Loading…
Reference in New Issue
Block a user