1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 19:55:53 +01:00

Atlas ll2xy() optimization

This commit is contained in:
Martin Tůma 2017-04-29 23:15:44 +02:00
parent 699e4f32d5
commit b500031713

View File

@ -235,16 +235,29 @@ qreal Atlas::zoomOut()
QPointF Atlas::ll2xy(const Coordinates &c) const QPointF Atlas::ll2xy(const Coordinates &c) const
{ {
int idx = _zooms.at(_zoom).first; static int idx = -1;
static int zoom = -1;
QPointF pp;
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) { if (zoom != _zoom) {
if (_bounds.at(i).first.contains(_maps.at(i)->ll2pp(c))) { idx = -1;
idx = i; zoom = _zoom;
break; }
if (idx >= 0)
pp = _maps.at(idx)->ll2pp(c);
if (idx < 0 || !_bounds.at(idx).first.contains(pp)) {
idx = _zooms.at(zoom).first;
for (int i = _zooms.at(zoom).first; i <= _zooms.at(zoom).second; i++) {
pp = _maps.at(i)->ll2pp(c);
if (_bounds.at(i).first.contains(pp)) {
idx = i;
break;
}
} }
} }
QPointF p = _maps.at(idx)->ll2xy(c); QPointF p = _maps.at(idx)->pp2xy(pp);
return p + _bounds.at(idx).second.topLeft(); return p + _bounds.at(idx).second.topLeft();
} }