mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-19 04:02:09 +01:00
Fixed path/distances size difference issue
This commit is contained in:
parent
eb5692a0ab
commit
e9e7660beb
@ -77,6 +77,8 @@ QPointF PathItem::position(qreal x) const
|
|||||||
int high = _distance.count() - 1;
|
int high = _distance.count() - 1;
|
||||||
int mid = 0;
|
int mid = 0;
|
||||||
|
|
||||||
|
|
||||||
|
Q_ASSERT(_distance.count() == _path.elementCount());
|
||||||
Q_ASSERT(high > low);
|
Q_ASSERT(high > low);
|
||||||
Q_ASSERT(x >= _distance.at(low) && x <= _distance.at(high));
|
Q_ASSERT(x >= _distance.at(low) && x <= _distance.at(high));
|
||||||
|
|
||||||
|
@ -25,25 +25,32 @@ RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
|||||||
: PathItem(parent)
|
: PathItem(parent)
|
||||||
{
|
{
|
||||||
const RouteData &r = route.routeData();
|
const RouteData &r = route.routeData();
|
||||||
Q_ASSERT(r.count() >= 2);
|
const QVector<qreal> &d = route.distanceData();
|
||||||
QPointF p;
|
QPointF p;
|
||||||
|
|
||||||
|
|
||||||
|
Q_ASSERT(r.count() >= 2);
|
||||||
|
Q_ASSERT(r.size() == d.size());
|
||||||
|
|
||||||
_name = r.name();
|
_name = r.name();
|
||||||
_desc = r.description();
|
_desc = r.description();
|
||||||
_distance = route.distanceData();
|
|
||||||
|
|
||||||
new WaypointItem(r.at(0), this);
|
new WaypointItem(r.first(), this);
|
||||||
p = r.at(0).coordinates().toMercator();
|
p = r.first().coordinates().toMercator();
|
||||||
_path.moveTo(QPointF(p.x(), -p.y()));
|
_path.moveTo(QPointF(p.x(), -p.y()));
|
||||||
|
_distance.append(d.first());
|
||||||
for (int i = 1; i < r.size(); i++) {
|
for (int i = 1; i < r.size(); i++) {
|
||||||
|
if (r.at(i).coordinates() == r.at(i-1).coordinates())
|
||||||
|
continue;
|
||||||
p = r.at(i).coordinates().toMercator();
|
p = r.at(i).coordinates().toMercator();
|
||||||
_path.lineTo(QPointF(p.x(), -p.y()));
|
_path.lineTo(QPointF(p.x(), -p.y()));
|
||||||
|
_distance.append(d.at(i));
|
||||||
new WaypointItem(r.at(i), this);
|
new WaypointItem(r.at(i), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateShape();
|
updateShape();
|
||||||
|
|
||||||
_marker->setPos(_path.pointAtPercent(0));
|
_marker->setPos(_path.elementAt(0));
|
||||||
|
|
||||||
_pen.setStyle(Qt::DotLine);
|
_pen.setStyle(Qt::DotLine);
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
|||||||
_path.moveTo(QPointF(p.x(), -p.y()));
|
_path.moveTo(QPointF(p.x(), -p.y()));
|
||||||
_distance.append(path.first().distance());
|
_distance.append(path.first().distance());
|
||||||
for (int i = 1; i < path.size(); i++) {
|
for (int i = 1; i < path.size(); i++) {
|
||||||
|
if (path.at(i).coordinates() == path.at(i-1).coordinates())
|
||||||
|
continue;
|
||||||
p = path.at(i).coordinates().toMercator();
|
p = path.at(i).coordinates().toMercator();
|
||||||
_path.lineTo(QPointF(p.x(), -p.y()));
|
_path.lineTo(QPointF(p.x(), -p.y()));
|
||||||
_distance.append(path.at(i).distance());
|
_distance.append(path.at(i).distance());
|
||||||
@ -49,7 +51,7 @@ TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
|||||||
_date = track.date();
|
_date = track.date();
|
||||||
_time = track.time();
|
_time = track.time();
|
||||||
|
|
||||||
_marker->setPos(_path.pointAtPercent(0));
|
_marker->setPos(_path.elementAt(0));
|
||||||
|
|
||||||
setToolTip(toolTip());
|
setToolTip(toolTip());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user