1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Avoid error summing when computing map positions

This commit is contained in:
Martin Tůma 2017-08-08 18:41:19 +02:00
parent 4b0b6513d1
commit 359a9f0a5a

View File

@ -85,23 +85,21 @@ void Atlas::computeBounds()
offsets.append(QPointF());
for (int z = 0; z < _zooms.count(); z++) {
qreal w = 0, h = 0;
QList<OfflineMap*> m;
for (int i = _zooms.at(z).first; i <= _zooms.at(z).second; i++)
m.append(_maps.at(i));
qSort(m.begin(), m.end(), xCmp);
offsets[_maps.indexOf(m.first())].setX(w);
offsets[_maps.indexOf(m.first())].setX(0);
for (int i = 1; i < m.size(); i++) {
w += round(m.at(i-1)->pp2xy(TL(m.at(i))).x());
qreal w = round(m.first()->pp2xy(TL(m.at(i))).x());
offsets[_maps.indexOf(m.at(i))].setX(w);
}
qSort(m.begin(), m.end(), yCmp);
offsets[_maps.indexOf(m.first())].setY(h);
offsets[_maps.indexOf(m.first())].setY(0);
for (int i = 1; i < m.size(); i++) {
h += round(m.at(i-1)->pp2xy(TL(m.at(i))).y());
qreal h = round(m.first()->pp2xy(TL(m.at(i))).y());
offsets[_maps.indexOf(m.at(i))].setY(h);
}
}