mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-31 09:05:14 +01:00
parent
81a5c712c6
commit
0cd6a82a0f
@ -51,6 +51,17 @@ Coordinates GPXParser::coordinates()
|
|||||||
return Coordinates(lon, lat);
|
return Coordinates(lon, lat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GPXParser::rpExtension(TrackData *autoRoute)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "rpt") {
|
||||||
|
autoRoute->append(Trackpoint(coordinates()));
|
||||||
|
trackpointData(autoRoute->last());
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GPXParser::tpExtension(Trackpoint &trackpoint)
|
void GPXParser::tpExtension(Trackpoint &trackpoint)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
@ -63,7 +74,17 @@ void GPXParser::tpExtension(Trackpoint &trackpoint)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::extensions(Trackpoint &trackpoint)
|
void GPXParser::rteptExtensions(TrackData *autoRoute)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "RoutePointExtension")
|
||||||
|
rpExtension(autoRoute);
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPXParser::trkptExtensions(Trackpoint &trackpoint)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "speed")
|
if (_reader.name() == "speed")
|
||||||
@ -95,7 +116,7 @@ void GPXParser::trackpointData(Trackpoint &trackpoint)
|
|||||||
else if (_reader.name() == "geoidheight")
|
else if (_reader.name() == "geoidheight")
|
||||||
gh = number();
|
gh = number();
|
||||||
else if (_reader.name() == "extensions")
|
else if (_reader.name() == "extensions")
|
||||||
extensions(trackpoint);
|
trkptExtensions(trackpoint);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
@ -104,7 +125,7 @@ void GPXParser::trackpointData(Trackpoint &trackpoint)
|
|||||||
trackpoint.setElevation(trackpoint.elevation() - gh);
|
trackpoint.setElevation(trackpoint.elevation() - gh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::waypointData(Waypoint &waypoint)
|
void GPXParser::waypointData(Waypoint &waypoint, TrackData *autoRoute)
|
||||||
{
|
{
|
||||||
qreal gh = NAN;
|
qreal gh = NAN;
|
||||||
|
|
||||||
@ -119,6 +140,8 @@ void GPXParser::waypointData(Waypoint &waypoint)
|
|||||||
gh = number();
|
gh = number();
|
||||||
else if (_reader.name() == "time")
|
else if (_reader.name() == "time")
|
||||||
waypoint.setTimestamp(time());
|
waypoint.setTimestamp(time());
|
||||||
|
else if (autoRoute && _reader.name() == "extensions")
|
||||||
|
rteptExtensions(autoRoute);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
@ -138,12 +161,14 @@ void GPXParser::trackpoints(TrackData &track)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::routepoints(RouteData &route)
|
void GPXParser::routepoints(RouteData &route, QList<TrackData> &tracks)
|
||||||
{
|
{
|
||||||
|
TrackData autoRoute;
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "rtept") {
|
if (_reader.name() == "rtept") {
|
||||||
route.append(Waypoint(coordinates()));
|
route.append(Waypoint(coordinates()));
|
||||||
waypointData(route.last());
|
waypointData(route.last(), &autoRoute);
|
||||||
} else if (_reader.name() == "name")
|
} else if (_reader.name() == "name")
|
||||||
route.setName(_reader.readElementText());
|
route.setName(_reader.readElementText());
|
||||||
else if (_reader.name() == "desc")
|
else if (_reader.name() == "desc")
|
||||||
@ -151,6 +176,12 @@ void GPXParser::routepoints(RouteData &route)
|
|||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!autoRoute.isEmpty()) {
|
||||||
|
autoRoute.setName(route.name());
|
||||||
|
autoRoute.setDescription(route.description());
|
||||||
|
tracks.append(autoRoute);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::track(TrackData &track)
|
void GPXParser::track(TrackData &track)
|
||||||
@ -176,7 +207,7 @@ void GPXParser::gpx(QList<TrackData> &tracks, QList<RouteData> &routes,
|
|||||||
track(tracks.back());
|
track(tracks.back());
|
||||||
} else if (_reader.name() == "rte") {
|
} else if (_reader.name() == "rte") {
|
||||||
routes.append(RouteData());
|
routes.append(RouteData());
|
||||||
routepoints(routes.back());
|
routepoints(routes.back(), tracks);
|
||||||
} else if (_reader.name() == "wpt") {
|
} else if (_reader.name() == "wpt") {
|
||||||
waypoints.append(Waypoint(coordinates()));
|
waypoints.append(Waypoint(coordinates()));
|
||||||
waypointData(waypoints.last());
|
waypointData(waypoints.last());
|
||||||
|
@ -18,11 +18,13 @@ private:
|
|||||||
QList<Waypoint> &waypoints);
|
QList<Waypoint> &waypoints);
|
||||||
void track(TrackData &track);
|
void track(TrackData &track);
|
||||||
void trackpoints(TrackData &track);
|
void trackpoints(TrackData &track);
|
||||||
void routepoints(RouteData &route);
|
void routepoints(RouteData &route, QList<TrackData> &tracks);
|
||||||
|
void rpExtension(TrackData *autoRoute);
|
||||||
void tpExtension(Trackpoint &trackpoint);
|
void tpExtension(Trackpoint &trackpoint);
|
||||||
void extensions(Trackpoint &trackpoint);
|
void trkptExtensions(Trackpoint &trackpoint);
|
||||||
|
void rteptExtensions(TrackData *autoRoute);
|
||||||
void trackpointData(Trackpoint &trackpoint);
|
void trackpointData(Trackpoint &trackpoint);
|
||||||
void waypointData(Waypoint &waypoint);
|
void waypointData(Waypoint &waypoint, TrackData *autoRoute = 0);
|
||||||
qreal number();
|
qreal number();
|
||||||
QDateTime time();
|
QDateTime time();
|
||||||
Coordinates coordinates();
|
Coordinates coordinates();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user