diff --git a/src/gpxparser.cpp b/src/gpxparser.cpp index 9582eb7c..8f1032aa 100644 --- a/src/gpxparser.cpp +++ b/src/gpxparser.cpp @@ -166,33 +166,33 @@ void GPXParser::waypointData(Waypoint &waypoint) waypoint.setElevation(waypoint.elevation() - gh); } -void GPXParser::trackpoints() +void GPXParser::trackpoints(QVector &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 &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 &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()); - _track = &_tracks.back(); - track(); + track(_tracks.back()); } else if (_reader.name() == "rte") { _routes.append(QVector()); - _route = &_routes.back(); - routepoints(); + routepoints(_routes.back()); } else if (_reader.name() == "wpt") { _waypoints.append(Waypoint(coordinates())); waypointData(_waypoints.last()); diff --git a/src/gpxparser.h b/src/gpxparser.h index 56e346d1..a159bc85 100644 --- a/src/gpxparser.h +++ b/src/gpxparser.h @@ -11,7 +11,7 @@ class GPXParser : public Parser public: GPXParser(QList > &tracks, QList > &routes, QList &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 &track); + void trackpoints(QVector &track); + void routepoints(QVector &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 *_track; - QVector *_route; }; #endif // GPXPARSER_H