mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Refactoring
This commit is contained in:
parent
816e1d1768
commit
17ab241a6d
@ -140,8 +140,9 @@ void GraphView::loadData(const QVector<QPointF> &data)
|
||||
updateBounds(data.at(0));
|
||||
path.moveTo(data.at(0).x(), -data.at(0).y());
|
||||
for (int i = 1; i < data.size(); i++) {
|
||||
path.lineTo(data.at(i).x(), -data.at(i).y());
|
||||
updateBounds(data.at(i));
|
||||
const QPointF &p = data.at(i);
|
||||
path.lineTo(p.x(), -p.y());
|
||||
updateBounds(p);
|
||||
}
|
||||
|
||||
pi = new QGraphicsPathItem(path);
|
||||
|
18
src/poi.cpp
18
src/poi.cpp
@ -46,14 +46,14 @@ bool POI::loadGPXFile(const QString &fileName)
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
for (int i = 0; i < gpx.waypoints().size(); i++)
|
||||
_data.append(Waypoint(gpx.waypoints().at(i).coordinates(),
|
||||
gpx.waypoints().at(i).description()));
|
||||
_data.append(gpx.waypoints().at(i));
|
||||
index.end = _data.size() - 1;
|
||||
|
||||
for (int i = index.start; i <= index.end; i++) {
|
||||
const QPointF &p = _data.at(i).coordinates();
|
||||
qreal c[2];
|
||||
c[0] = _data.at(i).coordinates().x();
|
||||
c[1] = _data.at(i).coordinates().y();
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
_tree.Insert(c, c, i);
|
||||
}
|
||||
|
||||
@ -114,9 +114,10 @@ bool POI::loadCSVFile(const QString &fileName)
|
||||
index.end = _data.size() - 1;
|
||||
|
||||
for (int i = index.start; i <= index.end; i++) {
|
||||
const QPointF &p = _data.at(i).coordinates();
|
||||
qreal c[2];
|
||||
c[0] = _data.at(i).coordinates().x();
|
||||
c[1] = _data.at(i).coordinates().y();
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
_tree.Insert(c, c, i);
|
||||
}
|
||||
|
||||
@ -173,9 +174,10 @@ void POI::enableFile(const QString &fileName, bool enable)
|
||||
continue;
|
||||
|
||||
for (int j = idx.start; j <= idx.end; j++) {
|
||||
const QPointF &p = _data.at(j).coordinates();
|
||||
qreal c[2];
|
||||
c[0] = _data.at(j).coordinates().x();
|
||||
c[1] = _data.at(j).coordinates().y();
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
_tree.Insert(c, c, j);
|
||||
}
|
||||
}
|
||||
|
@ -54,9 +54,12 @@ void TrackView::addTrack(const QVector<QPointF> &track)
|
||||
|
||||
_tracks.append(track);
|
||||
|
||||
path.moveTo(ll2mercator(QPointF(track.at(0).x(), -track.at(0).y())));
|
||||
for (int i = 1; i < track.size(); i++)
|
||||
path.lineTo(ll2mercator(QPointF(track.at(i).x(), -track.at(i).y())));
|
||||
const QPointF &p = track.at(0);
|
||||
path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
for (int i = 1; i < track.size(); i++) {
|
||||
const QPointF &p = track.at(i);
|
||||
path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
}
|
||||
|
||||
_maxLen = qMax(path.length(), _maxLen);
|
||||
|
||||
@ -80,16 +83,17 @@ void TrackView::addTrack(const QVector<QPointF> &track)
|
||||
void TrackView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
{
|
||||
for (int i = 0; i < waypoints.count(); i++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
WaypointItem *wi = new WaypointItem(
|
||||
Waypoint(ll2mercator(QPointF(waypoints.at(i).coordinates().x(),
|
||||
-waypoints.at(i).coordinates().y())), waypoints.at(i).description()));
|
||||
Waypoint(ll2mercator(QPointF(w.coordinates().x(),
|
||||
-w.coordinates().y())), w.description()));
|
||||
|
||||
wi->setPos(wi->entry().coordinates() * 1.0/_scale);
|
||||
wi->setZValue(1);
|
||||
_scene->addItem(wi);
|
||||
|
||||
_locations.append(wi);
|
||||
_waypoints.append(waypoints.at(i).coordinates());
|
||||
_waypoints.append(w.coordinates());
|
||||
}
|
||||
|
||||
_zoom = qMin(_zoom, scale2zoom(waypointScale()));
|
||||
@ -246,18 +250,20 @@ void TrackView::rescale(qreal scale)
|
||||
void TrackView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
{
|
||||
for (int i = 0; i < waypoints.size(); i++) {
|
||||
if (_pois.contains(waypoints.at(i)))
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
|
||||
if (_pois.contains(w))
|
||||
continue;
|
||||
|
||||
WaypointItem *pi = new WaypointItem(
|
||||
Waypoint(ll2mercator(QPointF(waypoints.at(i).coordinates().x(),
|
||||
-waypoints.at(i).coordinates().y())), waypoints.at(i).description()));
|
||||
Waypoint(ll2mercator(QPointF(w.coordinates().x(),
|
||||
-w.coordinates().y())), w.description()));
|
||||
|
||||
pi->setPos(pi->entry().coordinates() * 1.0/_scale);
|
||||
pi->setZValue(1);
|
||||
_scene->addItem(pi);
|
||||
|
||||
_pois.insert(waypoints.at(i), pi);
|
||||
_pois.insert(w, pi);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user