mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Yet another refactoring
This commit is contained in:
parent
59d8b3cc77
commit
ba4ac9fe51
@ -19,15 +19,15 @@ public:
|
||||
|
||||
int trackCount() const {return _tracks.count();}
|
||||
Track track(int i) const {return Track(_tracks.at(i));}
|
||||
const QList<WayPoint> &waypoints() const {return _waypoints;}
|
||||
const QList<Waypoint> &waypoints() const {return _waypoints;}
|
||||
|
||||
private:
|
||||
Parser _parser;
|
||||
QString _error;
|
||||
int _errorLine;
|
||||
|
||||
QList<QVector<TrackPoint> > _tracks;
|
||||
QList<WayPoint> _waypoints;
|
||||
QList<QVector<Trackpoint> > _tracks;
|
||||
QList<Waypoint> _waypoints;
|
||||
};
|
||||
|
||||
#endif // GPX_H
|
||||
|
@ -64,7 +64,7 @@ void Parser::trackPoints()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trkpt") {
|
||||
_track->append(TrackPoint());
|
||||
_track->append(Trackpoint());
|
||||
handleTrekPointAttributes(_reader.attributes());
|
||||
trackPointData();
|
||||
} else
|
||||
@ -96,11 +96,11 @@ void Parser::gpx()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trk") {
|
||||
_tracks.append(QVector<TrackPoint>());
|
||||
_tracks.append(QVector<Trackpoint>());
|
||||
_track = &_tracks.back();
|
||||
track();
|
||||
} else if (_reader.name() == "wpt") {
|
||||
_waypoints.append(WayPoint());
|
||||
_waypoints.append(Waypoint());
|
||||
handleWayPointAttributes(_reader.attributes());
|
||||
wayPointData();
|
||||
} else
|
||||
|
@ -11,7 +11,7 @@
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
Parser(QList<QVector<TrackPoint> > &tracks, QList<WayPoint> &waypoints)
|
||||
Parser(QList<QVector<Trackpoint> > &tracks, QList<Waypoint> &waypoints)
|
||||
: _tracks(tracks), _waypoints(waypoints) {_track = 0;}
|
||||
bool loadFile(QIODevice *device);
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
@ -33,9 +33,9 @@ private:
|
||||
void handleExtensionData(QStringRef element, const QString &value);
|
||||
|
||||
QXmlStreamReader _reader;
|
||||
QList<QVector<TrackPoint> > &_tracks;
|
||||
QList<WayPoint> &_waypoints;
|
||||
QVector<TrackPoint> *_track;
|
||||
QList<QVector<Trackpoint> > &_tracks;
|
||||
QList<Waypoint> &_waypoints;
|
||||
QVector<Trackpoint> *_track;
|
||||
};
|
||||
|
||||
#endif // PARSER_H
|
||||
|
@ -43,7 +43,7 @@ bool POI::loadGPXFile(const QString &fileName)
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
for (int i = 0; i < gpx.waypoints().size(); i++)
|
||||
_data.append(WayPoint(
|
||||
_data.append(Waypoint(
|
||||
ll2mercator(gpx.waypoints().at(i).coordinates()),
|
||||
gpx.waypoints().at(i).description()));
|
||||
|
||||
@ -97,7 +97,7 @@ bool POI::loadCSVFile(const QString &fileName)
|
||||
}
|
||||
QByteArray ba = list[2].trimmed();
|
||||
|
||||
_data.append(WayPoint(ll2mercator(QPointF(lon, lat)),
|
||||
_data.append(Waypoint(ll2mercator(QPointF(lon, lat)),
|
||||
QString::fromUtf8(ba.data(), ba.size())));
|
||||
ln++;
|
||||
}
|
||||
@ -120,9 +120,9 @@ static bool cb(size_t data, void* context)
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<WayPoint> POI::points(const QVector<QPointF> &path, qreal radius) const
|
||||
QVector<Waypoint> POI::points(const QVector<QPointF> &path, qreal radius) const
|
||||
{
|
||||
QVector<WayPoint> ret;
|
||||
QVector<Waypoint> ret;
|
||||
QSet<int> set;
|
||||
qreal min[2], max[2];
|
||||
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
QString errorString() const {return _error;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
QVector<WayPoint> points(const QVector<QPointF> &path,
|
||||
QVector<Waypoint> points(const QVector<QPointF> &path,
|
||||
qreal radius = 0.01) const;
|
||||
|
||||
void clear();
|
||||
@ -27,7 +27,7 @@ private:
|
||||
bool loadGPXFile(const QString &fileName);
|
||||
|
||||
POITree _tree;
|
||||
QVector<WayPoint> _data;
|
||||
QVector<Waypoint> _data;
|
||||
|
||||
QString _error;
|
||||
int _errorLine;
|
||||
|
@ -8,7 +8,7 @@
|
||||
class Track
|
||||
{
|
||||
public:
|
||||
Track(const QVector<TrackPoint> &data) : _data(data) {}
|
||||
Track(const QVector<Trackpoint> &data) : _data(data) {}
|
||||
|
||||
void elevationGraph(QVector<QPointF> &graph) const;
|
||||
void speedGraph(QVector<QPointF> &graph) const;
|
||||
@ -18,7 +18,7 @@ public:
|
||||
QDateTime date() const;
|
||||
|
||||
private:
|
||||
const QVector<TrackPoint> &_data;
|
||||
const QVector<Trackpoint> &_data;
|
||||
};
|
||||
|
||||
#endif // TRACK_H
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <QPointF>
|
||||
#include <QDateTime>
|
||||
|
||||
struct TrackPoint
|
||||
struct Trackpoint
|
||||
{
|
||||
QPointF coordinates;
|
||||
QDateTime timestamp;
|
||||
@ -12,7 +12,7 @@ struct TrackPoint
|
||||
qreal geoidheight;
|
||||
qreal speed;
|
||||
|
||||
TrackPoint() {elevation = 0; geoidheight = 0; speed = -1;}
|
||||
Trackpoint() {elevation = 0; geoidheight = 0; speed = -1;}
|
||||
};
|
||||
|
||||
#endif // TRACKPOINT_H
|
||||
|
@ -156,7 +156,7 @@ void TrackView::rescale(qreal scale)
|
||||
_trackPaths.at(i)->setPen(pen);
|
||||
}
|
||||
|
||||
QHash<WayPoint, WayPointItem*>::const_iterator it, jt;
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
it.value()->setPos(QPointF(it.value()->entry().coordinates().x()
|
||||
* 1.0/scale, -it.value()->entry().coordinates().y() * 1.0/scale));
|
||||
@ -176,19 +176,19 @@ void TrackView::rescale(qreal scale)
|
||||
|
||||
void TrackView::loadPOI(const POI &poi)
|
||||
{
|
||||
QHash<WayPoint, WayPointItem*>::const_iterator it,jt;
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it,jt;
|
||||
|
||||
if (!_tracks.size())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++) {
|
||||
QVector<WayPoint> p = poi.points(_tracks.at(i));
|
||||
QVector<Waypoint> p = poi.points(_tracks.at(i));
|
||||
|
||||
for (int i = 0; i < p.size(); i++) {
|
||||
if (_pois.contains(p.at(i)))
|
||||
continue;
|
||||
|
||||
WayPointItem *pi = new WayPointItem(p.at(i));
|
||||
WaypointItem *pi = new WaypointItem(p.at(i));
|
||||
pi->setPos(p.at(i).coordinates().x() * 1.0/_scale,
|
||||
-p.at(i).coordinates().y() * 1.0/_scale);
|
||||
pi->setZValue(1);
|
||||
@ -298,7 +298,7 @@ enum QPrinter::Orientation TrackView::orientation() const
|
||||
|
||||
void TrackView::clearPOI()
|
||||
{
|
||||
QHash<WayPoint, WayPointItem*>::const_iterator it;
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
_scene->removeItem(it.value());
|
||||
|
@ -13,7 +13,7 @@
|
||||
class GPX;
|
||||
class POI;
|
||||
class Map;
|
||||
class WayPointItem;
|
||||
class WaypointItem;
|
||||
class MarkerItem;
|
||||
class ScaleItem;
|
||||
|
||||
@ -61,7 +61,7 @@ private:
|
||||
QList<QVector<QPointF> > _tracks;
|
||||
QList<QGraphicsPathItem*> _trackPaths;
|
||||
QList<MarkerItem*> _markers;
|
||||
QHash<WayPoint, WayPointItem*> _pois;
|
||||
QHash<Waypoint, WaypointItem*> _pois;
|
||||
Map *_map;
|
||||
ScaleItem *_mapScale;
|
||||
|
||||
|
@ -5,11 +5,11 @@
|
||||
#include <QString>
|
||||
#include <QHash>
|
||||
|
||||
class WayPoint
|
||||
class Waypoint
|
||||
{
|
||||
public:
|
||||
WayPoint() {}
|
||||
WayPoint(const QPointF &coordinates, const QString &description)
|
||||
Waypoint() {}
|
||||
Waypoint(const QPointF &coordinates, const QString &description)
|
||||
: _coordinates(coordinates), _description(description) {}
|
||||
|
||||
const QPointF &coordinates() const {return _coordinates;}
|
||||
@ -19,7 +19,7 @@ public:
|
||||
void setDescription(const QString &description)
|
||||
{_description = description;}
|
||||
|
||||
bool operator==(const WayPoint &other) const
|
||||
bool operator==(const Waypoint &other) const
|
||||
{return this->_description == other._description
|
||||
&& this->_coordinates == other._coordinates;}
|
||||
|
||||
@ -28,7 +28,7 @@ private:
|
||||
QString _description;
|
||||
};
|
||||
|
||||
inline uint qHash(const WayPoint &key)
|
||||
inline uint qHash(const Waypoint &key)
|
||||
{
|
||||
return ::qHash(key.description());
|
||||
}
|
||||
|
@ -5,14 +5,14 @@
|
||||
|
||||
#define POINT_SIZE 8
|
||||
|
||||
WayPointItem::WayPointItem(const WayPoint &entry, QGraphicsItem *parent)
|
||||
WaypointItem::WaypointItem(const Waypoint &entry, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
{
|
||||
_entry = entry;
|
||||
updateBoundingRect();
|
||||
}
|
||||
|
||||
void WayPointItem::updateBoundingRect()
|
||||
void WaypointItem::updateBoundingRect()
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
@ -24,7 +24,7 @@ void WayPointItem::updateBoundingRect()
|
||||
ts.height() + fm.descent() + POINT_SIZE);
|
||||
}
|
||||
|
||||
void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
void WaypointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
|
@ -4,11 +4,11 @@
|
||||
#include <QGraphicsItem>
|
||||
#include "waypoint.h"
|
||||
|
||||
class WayPointItem : public QGraphicsItem
|
||||
class WaypointItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
WayPointItem(const WayPoint &entry, QGraphicsItem *parent = 0);
|
||||
const WayPoint &entry() const {return _entry;}
|
||||
WaypointItem(const Waypoint &entry, QGraphicsItem *parent = 0);
|
||||
const Waypoint &entry() const {return _entry;}
|
||||
|
||||
QRectF boundingRect() const {return _boundingRect;}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
@ -17,7 +17,7 @@ public:
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
||||
WayPoint _entry;
|
||||
Waypoint _entry;
|
||||
QRectF _boundingRect;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user