mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Added support for track/route names and descriptions
This commit is contained in:
parent
9a0d304e8d
commit
10b903c129
@ -60,7 +60,9 @@ HEADERS += src/config.h \
|
|||||||
src/tile.h \
|
src/tile.h \
|
||||||
src/rd.h \
|
src/rd.h \
|
||||||
src/wgs84.h \
|
src/wgs84.h \
|
||||||
src/kmlparser.h
|
src/kmlparser.h \
|
||||||
|
src/trackdata.h \
|
||||||
|
src/routedata.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/gui.cpp \
|
src/gui.cpp \
|
||||||
src/poi.cpp \
|
src/poi.cpp \
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
class CSVParser : public Parser
|
class CSVParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CSVParser(QList<QVector<Trackpoint> > &tracks,
|
CSVParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints)
|
||||||
: Parser(tracks, routes, waypoints) {_errorLine = 0;}
|
{_errorLine = 0;}
|
||||||
~CSVParser() {}
|
~CSVParser() {}
|
||||||
|
|
||||||
bool loadFile(QIODevice *device);
|
bool loadFile(QIODevice *device);
|
||||||
|
24
src/data.cpp
24
src/data.cpp
@ -10,14 +10,14 @@
|
|||||||
|
|
||||||
Data::Data() : _errorLine(0)
|
Data::Data() : _errorLine(0)
|
||||||
{
|
{
|
||||||
_parsers.insert("gpx", new GPXParser(_track_data, _route_data,
|
_parsers.insert("gpx", new GPXParser(_trackData, _routeData,
|
||||||
_waypoint_data));
|
_waypointData));
|
||||||
_parsers.insert("tcx", new TCXParser(_track_data, _route_data,
|
_parsers.insert("tcx", new TCXParser(_trackData, _routeData,
|
||||||
_waypoint_data));
|
_waypointData));
|
||||||
_parsers.insert("kml", new KMLParser(_track_data, _route_data,
|
_parsers.insert("kml", new KMLParser(_trackData, _routeData,
|
||||||
_waypoint_data));
|
_waypointData));
|
||||||
_parsers.insert("csv", new CSVParser(_track_data, _route_data,
|
_parsers.insert("csv", new CSVParser(_trackData, _routeData,
|
||||||
_waypoint_data));
|
_waypointData));
|
||||||
}
|
}
|
||||||
|
|
||||||
Data::~Data()
|
Data::~Data()
|
||||||
@ -35,10 +35,10 @@ Data::~Data()
|
|||||||
|
|
||||||
void Data::createData()
|
void Data::createData()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _track_data.count(); i++)
|
for (int i = 0; i < _trackData.count(); i++)
|
||||||
_tracks.append(new Track(_track_data.at(i)));
|
_tracks.append(new Track(_trackData.at(i)));
|
||||||
for (int i = 0; i < _route_data.count(); i++)
|
for (int i = 0; i < _routeData.count(); i++)
|
||||||
_routes.append(new Route(_route_data.at(i)));
|
_routes.append(new Route(_routeData.at(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Data::loadFile(const QString &fileName)
|
bool Data::loadFile(const QString &fileName)
|
||||||
|
10
src/data.h
10
src/data.h
@ -9,8 +9,8 @@
|
|||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "track.h"
|
#include "track.h"
|
||||||
#include "route.h"
|
#include "route.h"
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
class Parser;
|
|
||||||
|
|
||||||
class Data
|
class Data
|
||||||
{
|
{
|
||||||
@ -24,7 +24,7 @@ public:
|
|||||||
|
|
||||||
const QList<Track*> &tracks() const {return _tracks;}
|
const QList<Track*> &tracks() const {return _tracks;}
|
||||||
const QList<Route*> &routes() const {return _routes;}
|
const QList<Route*> &routes() const {return _routes;}
|
||||||
const QList<Waypoint> &waypoints() const {return _waypoint_data;}
|
const QList<Waypoint> &waypoints() const {return _waypointData;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createData();
|
void createData();
|
||||||
@ -36,9 +36,9 @@ private:
|
|||||||
QList<Track*> _tracks;
|
QList<Track*> _tracks;
|
||||||
QList<Route*> _routes;
|
QList<Route*> _routes;
|
||||||
|
|
||||||
QList<QVector<Trackpoint> > _track_data;
|
QList<TrackData> _trackData;
|
||||||
QList<QVector<Waypoint> > _route_data;
|
QList<RouteData> _routeData;
|
||||||
QList<Waypoint> _waypoint_data;
|
QList<Waypoint> _waypointData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATA_H
|
#endif // DATA_H
|
||||||
|
@ -166,7 +166,7 @@ void GPXParser::waypointData(Waypoint &waypoint)
|
|||||||
waypoint.setElevation(waypoint.elevation() - gh);
|
waypoint.setElevation(waypoint.elevation() - gh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::trackpoints(QVector<Trackpoint> &track)
|
void GPXParser::trackpoints(TrackData &track)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "trkpt") {
|
if (_reader.name() == "trkpt") {
|
||||||
@ -177,23 +177,31 @@ void GPXParser::trackpoints(QVector<Trackpoint> &track)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::routepoints(QVector<Waypoint> &route)
|
void GPXParser::routepoints(RouteData &route)
|
||||||
{
|
{
|
||||||
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());
|
||||||
} else
|
} else if (_reader.name() == "name")
|
||||||
|
route.setName(_reader.readElementText());
|
||||||
|
else if (_reader.name() == "desc")
|
||||||
|
route.setDescription(_reader.readElementText());
|
||||||
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::track(QVector<Trackpoint> &track)
|
void GPXParser::track(TrackData &track)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "trkseg") {
|
if (_reader.name() == "trkseg")
|
||||||
trackpoints(track);
|
trackpoints(track);
|
||||||
} else
|
else if (_reader.name() == "name")
|
||||||
|
track.setName(_reader.readElementText());
|
||||||
|
else if (_reader.name() == "desc")
|
||||||
|
track.setDescription(_reader.readElementText());
|
||||||
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,10 +210,10 @@ void GPXParser::gpx()
|
|||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "trk") {
|
if (_reader.name() == "trk") {
|
||||||
_tracks.append(QVector<Trackpoint>());
|
_tracks.append(TrackData());
|
||||||
track(_tracks.back());
|
track(_tracks.back());
|
||||||
} else if (_reader.name() == "rte") {
|
} else if (_reader.name() == "rte") {
|
||||||
_routes.append(QVector<Waypoint>());
|
_routes.append(RouteData());
|
||||||
routepoints(_routes.back());
|
routepoints(_routes.back());
|
||||||
} else if (_reader.name() == "wpt") {
|
} else if (_reader.name() == "wpt") {
|
||||||
_waypoints.append(Waypoint(coordinates()));
|
_waypoints.append(Waypoint(coordinates()));
|
||||||
|
@ -8,9 +8,8 @@
|
|||||||
class GPXParser : public Parser
|
class GPXParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GPXParser(QList<QVector<Trackpoint> > &tracks,
|
GPXParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints) {}
|
||||||
: Parser(tracks, routes, waypoints) {}
|
|
||||||
~GPXParser() {}
|
~GPXParser() {}
|
||||||
|
|
||||||
bool loadFile(QIODevice *device);
|
bool loadFile(QIODevice *device);
|
||||||
@ -24,9 +23,9 @@ private:
|
|||||||
|
|
||||||
bool parse();
|
bool parse();
|
||||||
void gpx();
|
void gpx();
|
||||||
void track(QVector<Trackpoint> &track);
|
void track(TrackData &track);
|
||||||
void trackpoints(QVector<Trackpoint> &track);
|
void trackpoints(TrackData &track);
|
||||||
void routepoints(QVector<Waypoint> &route);
|
void routepoints(RouteData &route);
|
||||||
void tpExtension(Trackpoint &trackpoint);
|
void tpExtension(Trackpoint &trackpoint);
|
||||||
void extensions(Trackpoint &trackpoint);
|
void extensions(Trackpoint &trackpoint);
|
||||||
void trackpointData(Trackpoint &trackpoint);
|
void trackpointData(Trackpoint &trackpoint);
|
||||||
|
@ -79,7 +79,7 @@ bool KMLParser::pointCoordinates(Waypoint &waypoint)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KMLParser::lineCoordinates(QVector<Trackpoint> &track)
|
bool KMLParser::lineCoordinates(TrackData &track)
|
||||||
{
|
{
|
||||||
QString data = _reader.readElementText();
|
QString data = _reader.readElementText();
|
||||||
const QChar *sp, *ep, *cp, *vp;
|
const QChar *sp, *ep, *cp, *vp;
|
||||||
@ -136,17 +136,21 @@ bool KMLParser::lineCoordinates(QVector<Trackpoint> &track)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::timeStamp(Waypoint &waypoint)
|
QDateTime KMLParser::timeStamp()
|
||||||
{
|
{
|
||||||
|
QDateTime ts;
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "when")
|
if (_reader.name() == "when")
|
||||||
waypoint.setTimestamp(time());
|
ts = time();
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::lineString(QVector<Trackpoint> &track)
|
void KMLParser::lineString(TrackData &track)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "coordinates") {
|
if (_reader.name() == "coordinates") {
|
||||||
@ -170,21 +174,29 @@ void KMLParser::point(Waypoint &waypoint)
|
|||||||
|
|
||||||
void KMLParser::placemark()
|
void KMLParser::placemark()
|
||||||
{
|
{
|
||||||
Waypoint waypoint;
|
QString name, desc;
|
||||||
|
QDateTime timestamp;
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "name")
|
if (_reader.name() == "name")
|
||||||
waypoint.setName(_reader.readElementText());
|
name = _reader.readElementText();
|
||||||
else if (_reader.name() == "description")
|
else if (_reader.name() == "description")
|
||||||
waypoint.setDescription(_reader.readElementText());
|
desc = _reader.readElementText();
|
||||||
else if (_reader.name() == "TimeStamp")
|
else if (_reader.name() == "TimeStamp")
|
||||||
timeStamp(waypoint);
|
timestamp = timeStamp();
|
||||||
else if (_reader.name() == "Point") {
|
else if (_reader.name() == "Point") {
|
||||||
_waypoints.append(waypoint);
|
_waypoints.append(Waypoint());
|
||||||
point(_waypoints.last());
|
Waypoint &waypoint = _waypoints.last();
|
||||||
|
waypoint.setName(name);
|
||||||
|
waypoint.setDescription(desc);
|
||||||
|
waypoint.setTimestamp(timestamp);
|
||||||
|
point(waypoint);
|
||||||
} else if (_reader.name() == "LineString") {
|
} else if (_reader.name() == "LineString") {
|
||||||
_tracks.append(QVector<Trackpoint>());
|
_tracks.append(TrackData());
|
||||||
lineString(_tracks.last());
|
TrackData &track = _tracks.last();
|
||||||
|
track.setName(name);
|
||||||
|
track.setDescription(desc);
|
||||||
|
lineString(track);
|
||||||
} else
|
} else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,8 @@
|
|||||||
class KMLParser : public Parser
|
class KMLParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KMLParser(QList<QVector<Trackpoint> > &tracks,
|
KMLParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints) {}
|
||||||
: Parser(tracks, routes, waypoints) {}
|
|
||||||
~KMLParser() {}
|
~KMLParser() {}
|
||||||
|
|
||||||
bool loadFile(QIODevice *device);
|
bool loadFile(QIODevice *device);
|
||||||
@ -23,11 +22,11 @@ private:
|
|||||||
void document();
|
void document();
|
||||||
void folder();
|
void folder();
|
||||||
void placemark();
|
void placemark();
|
||||||
void lineString(QVector<Trackpoint> &track);
|
void lineString(TrackData &track);
|
||||||
void point(Waypoint &waypoint);
|
void point(Waypoint &waypoint);
|
||||||
bool pointCoordinates(Waypoint &waypoint);
|
bool pointCoordinates(Waypoint &waypoint);
|
||||||
bool lineCoordinates(QVector<Trackpoint> &track);
|
bool lineCoordinates(TrackData &track);
|
||||||
void timeStamp(Waypoint &waypoint);
|
QDateTime timeStamp();
|
||||||
qreal number();
|
qreal number();
|
||||||
QDateTime time();
|
QDateTime time();
|
||||||
|
|
||||||
|
13
src/parser.h
13
src/parser.h
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "trackpoint.h"
|
#include "trackdata.h"
|
||||||
|
#include "routedata.h"
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
|
|
||||||
class QIODevice;
|
class QIODevice;
|
||||||
@ -11,9 +12,9 @@ class QIODevice;
|
|||||||
class Parser
|
class Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Parser(QList<QVector<Trackpoint> > &tracks,
|
Parser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
QList<Waypoint> &waypoints) : _tracks(tracks), _routes(routes),
|
||||||
: _tracks(tracks), _routes(routes), _waypoints(waypoints) {}
|
_waypoints(waypoints) {}
|
||||||
virtual ~Parser() {}
|
virtual ~Parser() {}
|
||||||
|
|
||||||
virtual bool loadFile(QIODevice *device) = 0;
|
virtual bool loadFile(QIODevice *device) = 0;
|
||||||
@ -21,8 +22,8 @@ public:
|
|||||||
virtual int errorLine() const = 0;
|
virtual int errorLine() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<QVector<Trackpoint> > &_tracks;
|
QList<TrackData> &_tracks;
|
||||||
QList<QVector<Waypoint> > &_routes;
|
QList<RouteData> &_routes;
|
||||||
QList<Waypoint> &_waypoints;
|
QList<Waypoint> &_waypoints;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "route.h"
|
#include "route.h"
|
||||||
|
|
||||||
Route::Route(const QVector<Waypoint> &data) : _data(data)
|
Route::Route(const RouteData &data) : _data(data)
|
||||||
{
|
{
|
||||||
qreal dist = 0;
|
qreal dist = 0;
|
||||||
|
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
#define ROUTE_H
|
#define ROUTE_H
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include "waypoint.h"
|
#include "routedata.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
|
|
||||||
class Route
|
class Route
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Route(const QVector<Waypoint> &data);
|
Route(const RouteData &data);
|
||||||
|
|
||||||
const QVector<Waypoint> &route() const {return _data;}
|
const RouteData &route() const {return _data;}
|
||||||
Graph elevation() const;
|
Graph elevation() const;
|
||||||
|
|
||||||
qreal distance() const;
|
qreal distance() const;
|
||||||
@ -18,7 +18,7 @@ public:
|
|||||||
bool isNull() const {return (_data.count() < 2);}
|
bool isNull() const {return (_data.count() < 2);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QVector<Waypoint> &_data;
|
const RouteData &_data;
|
||||||
QVector<qreal> _distance;
|
QVector<qreal> _distance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
21
src/routedata.h
Normal file
21
src/routedata.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef ROUTEDATA_H
|
||||||
|
#define ROUTEDATA_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include <QString>
|
||||||
|
#include "waypoint.h"
|
||||||
|
|
||||||
|
class RouteData : public QVector<Waypoint>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const QString& name() const {return _name;}
|
||||||
|
const QString& description() const {return _desc;}
|
||||||
|
void setName(const QString &name) {_name = name;}
|
||||||
|
void setDescription(const QString &desc) {_desc = desc;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _name;
|
||||||
|
QString _desc;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ROUTEDATA_H
|
@ -11,6 +11,10 @@ QString RouteItem::toolTip()
|
|||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
|
|
||||||
|
if (!_name.isEmpty())
|
||||||
|
tt.insert(qApp->translate("RouteItem", "Name"), _name);
|
||||||
|
if (!_desc.isEmpty())
|
||||||
|
tt.insert(qApp->translate("RouteItem", "Description"), _desc);
|
||||||
tt.insert(qApp->translate("RouteItem", "Distance"),
|
tt.insert(qApp->translate("RouteItem", "Distance"),
|
||||||
::distance(_distance, _units));
|
::distance(_distance, _units));
|
||||||
|
|
||||||
@ -20,10 +24,13 @@ QString RouteItem::toolTip()
|
|||||||
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
||||||
: PathItem(parent)
|
: PathItem(parent)
|
||||||
{
|
{
|
||||||
QVector<Waypoint> r = route.route();
|
const RouteData &r = route.route();
|
||||||
Q_ASSERT(r.count() >= 2);
|
Q_ASSERT(r.count() >= 2);
|
||||||
QPointF p;
|
QPointF p;
|
||||||
|
|
||||||
|
_name = r.name();
|
||||||
|
_desc = r.description();
|
||||||
|
|
||||||
new WaypointItem(r.at(0), this);
|
new WaypointItem(r.at(0), this);
|
||||||
p = r.at(0).coordinates().toMercator();
|
p = r.at(0).coordinates().toMercator();
|
||||||
_path.moveTo(QPointF(p.x(), -p.y()));
|
_path.moveTo(QPointF(p.x(), -p.y()));
|
||||||
|
@ -20,6 +20,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString toolTip();
|
QString toolTip();
|
||||||
|
|
||||||
|
QString _name;
|
||||||
|
QString _desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ROUTEITEM_H
|
#endif // ROUTEITEM_H
|
||||||
|
@ -83,7 +83,7 @@ void TCXParser::waypointData(Waypoint &waypoint)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCXParser::trackpoints(QVector<Trackpoint> &track)
|
void TCXParser::trackpoints(TrackData &track)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "Trackpoint") {
|
if (_reader.name() == "Trackpoint") {
|
||||||
@ -94,24 +94,26 @@ void TCXParser::trackpoints(QVector<Trackpoint> &track)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCXParser::lap()
|
void TCXParser::lap(TrackData &track)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "Track") {
|
if (_reader.name() == "Track")
|
||||||
_tracks.append(QVector<Trackpoint>());
|
trackpoints(track);
|
||||||
trackpoints(_tracks.back());
|
else
|
||||||
} else
|
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCXParser::course()
|
void TCXParser::course(TrackData &track)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "Track") {
|
if (_reader.name() == "Track")
|
||||||
_tracks.append(QVector<Trackpoint>());
|
trackpoints(track);
|
||||||
trackpoints(_tracks.back());
|
else if (_reader.name() == "Name")
|
||||||
} else if (_reader.name() == "CoursePoint") {
|
track.setName(_reader.readElementText());
|
||||||
|
else if (_reader.name() == "Notes")
|
||||||
|
track.setDescription(_reader.readElementText());
|
||||||
|
else if (_reader.name() == "CoursePoint") {
|
||||||
_waypoints.append(Waypoint());
|
_waypoints.append(Waypoint());
|
||||||
waypointData(_waypoints.back());
|
waypointData(_waypoints.back());
|
||||||
} else
|
} else
|
||||||
@ -119,11 +121,11 @@ void TCXParser::course()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCXParser::activity()
|
void TCXParser::activity(TrackData &track)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "Lap")
|
if (_reader.name() == "Lap")
|
||||||
lap();
|
lap(track);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
@ -132,9 +134,10 @@ void TCXParser::activity()
|
|||||||
void TCXParser::courses()
|
void TCXParser::courses()
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "Course")
|
if (_reader.name() == "Course") {
|
||||||
course();
|
_tracks.append(TrackData());
|
||||||
else
|
course(_tracks.back());
|
||||||
|
} else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,9 +145,10 @@ void TCXParser::courses()
|
|||||||
void TCXParser::activities()
|
void TCXParser::activities()
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "Activity")
|
if (_reader.name() == "Activity") {
|
||||||
activity();
|
_tracks.append(TrackData());
|
||||||
else
|
activity(_tracks.back());
|
||||||
|
} else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,8 @@
|
|||||||
class TCXParser : public Parser
|
class TCXParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TCXParser(QList<QVector<Trackpoint> > &tracks,
|
TCXParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints) {}
|
||||||
: Parser(tracks, routes, waypoints) {}
|
|
||||||
~TCXParser() {}
|
~TCXParser() {}
|
||||||
|
|
||||||
bool loadFile(QIODevice *device);
|
bool loadFile(QIODevice *device);
|
||||||
@ -22,10 +21,10 @@ private:
|
|||||||
void tcx();
|
void tcx();
|
||||||
void courses();
|
void courses();
|
||||||
void activities();
|
void activities();
|
||||||
void course();
|
void course(TrackData &track);
|
||||||
void activity();
|
void activity(TrackData &track);
|
||||||
void lap();
|
void lap(TrackData &track);
|
||||||
void trackpoints(QVector<Trackpoint> &track);
|
void trackpoints(TrackData &track);
|
||||||
void trackpointData(Trackpoint &trackpoint);
|
void trackpointData(Trackpoint &trackpoint);
|
||||||
void waypointData(Waypoint &waypoint);
|
void waypointData(Waypoint &waypoint);
|
||||||
Coordinates position();
|
Coordinates position();
|
||||||
|
@ -79,7 +79,7 @@ static QVector<GraphPoint> filter(const QVector<GraphPoint> &v, int window)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Track::Track(const QVector<Trackpoint> &data) : _data(data)
|
Track::Track(const TrackData &data) : _data(data)
|
||||||
{
|
{
|
||||||
qreal dist = 0;
|
qreal dist = 0;
|
||||||
|
|
||||||
|
@ -3,15 +3,16 @@
|
|||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include "trackpoint.h"
|
#include "trackdata.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
|
|
||||||
|
|
||||||
class Track
|
class Track
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Track(const QVector<Trackpoint> &data);
|
Track(const TrackData &data);
|
||||||
|
|
||||||
const QVector<Trackpoint> &track() const {return _data;}
|
const TrackData &track() const {return _data;}
|
||||||
Graph elevation() const;
|
Graph elevation() const;
|
||||||
Graph speed() const;
|
Graph speed() const;
|
||||||
Graph heartRate() const;
|
Graph heartRate() const;
|
||||||
@ -24,7 +25,7 @@ public:
|
|||||||
bool isNull() const {return (_data.size() < 2);}
|
bool isNull() const {return (_data.size() < 2);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QVector<Trackpoint> &_data;
|
const TrackData &_data;
|
||||||
QVector<qreal> _distance;
|
QVector<qreal> _distance;
|
||||||
QVector<qreal> _time;
|
QVector<qreal> _time;
|
||||||
};
|
};
|
||||||
|
21
src/trackdata.h
Normal file
21
src/trackdata.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef TRACKDATA_H
|
||||||
|
#define TRACKDATA_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include <QString>
|
||||||
|
#include "trackpoint.h"
|
||||||
|
|
||||||
|
class TrackData : public QVector<Trackpoint>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const QString& name() const {return _name;}
|
||||||
|
const QString& description() const {return _desc;}
|
||||||
|
void setName(const QString &name) {_name = name;}
|
||||||
|
void setDescription(const QString &desc) {_desc = desc;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _name;
|
||||||
|
QString _desc;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRACKDATA_H
|
@ -10,6 +10,10 @@ QString TrackItem::toolTip()
|
|||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
|
|
||||||
|
if (!_name.isEmpty())
|
||||||
|
tt.insert(qApp->translate("TrackItem", "Name"), _name);
|
||||||
|
if (!_desc.isEmpty())
|
||||||
|
tt.insert(qApp->translate("TrackItem", "Description"), _desc);
|
||||||
tt.insert(qApp->translate("TrackItem", "Distance"),
|
tt.insert(qApp->translate("TrackItem", "Distance"),
|
||||||
::distance(_distance, _units));
|
::distance(_distance, _units));
|
||||||
if (_time > 0)
|
if (_time > 0)
|
||||||
@ -25,7 +29,7 @@ TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
|||||||
: PathItem(parent)
|
: PathItem(parent)
|
||||||
{
|
{
|
||||||
QPointF p;
|
QPointF p;
|
||||||
const QVector<Trackpoint> &t = track.track();
|
const TrackData &t = track.track();
|
||||||
Q_ASSERT(t.count() >= 2);
|
Q_ASSERT(t.count() >= 2);
|
||||||
|
|
||||||
p = t.first().coordinates().toMercator();
|
p = t.first().coordinates().toMercator();
|
||||||
@ -37,6 +41,8 @@ TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
|||||||
|
|
||||||
updateShape();
|
updateShape();
|
||||||
|
|
||||||
|
_name = t.name();
|
||||||
|
_desc = t.description();
|
||||||
_date = track.date();
|
_date = track.date();
|
||||||
_distance = track.distance();
|
_distance = track.distance();
|
||||||
_time = track.time();
|
_time = track.time();
|
||||||
|
@ -19,6 +19,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
QString toolTip();
|
QString toolTip();
|
||||||
|
|
||||||
|
QString _name;
|
||||||
|
QString _desc;
|
||||||
QDateTime _date;
|
QDateTime _date;
|
||||||
qreal _time;
|
qreal _time;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user