From 23c18d4acdd2fe8366969b8379e0d26cec05c43b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 7 Mar 2020 19:24:39 +0100 Subject: [PATCH] Optimization --- src/map/imgmap.cpp | 11 ++++------- src/map/imgmap.h | 3 ++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/map/imgmap.cpp b/src/map/imgmap.cpp index 9293f714..33077095 100644 --- a/src/map/imgmap.cpp +++ b/src/map/imgmap.cpp @@ -260,13 +260,6 @@ void IMGMap::unload() _data->clear(); } -QRectF IMGMap::bounds() -{ - RectD prect(_data->bounds(), _projection); - return QRectF(_transform.proj2img(prect.topLeft()), - _transform.proj2img(prect.bottomRight())); -} - int IMGMap::zoomFit(const QSize &size, const RectC &rect) { if (rect.isValid()) { @@ -320,6 +313,10 @@ Transform IMGMap::transform(int zoom) const void IMGMap::updateTransform() { _transform = transform(_zoom); + + RectD prect(_data->bounds(), _projection); + _bounds = QRectF(_transform.proj2img(prect.topLeft()), + _transform.proj2img(prect.bottomRight())); } QPointF IMGMap::ll2xy(const Coordinates &c) diff --git a/src/map/imgmap.h b/src/map/imgmap.h index 03dec65b..1618fe36 100644 --- a/src/map/imgmap.h +++ b/src/map/imgmap.h @@ -18,7 +18,7 @@ public: QString name() const {return _data->name();} - QRectF bounds(); + QRectF bounds() {return _bounds;} virtual int zoom() const {return _zoom;} virtual void setZoom(int zoom); @@ -62,6 +62,7 @@ private: int _zoom; Projection _projection; Transform _transform; + QRectF _bounds; bool _valid; QString _errorString;