diff --git a/src/map/encatlas.cpp b/src/map/encatlas.cpp index 0e40a701..20a9e4c9 100644 --- a/src/map/encatlas.cpp +++ b/src/map/encatlas.cpp @@ -9,6 +9,7 @@ using namespace ENC; +#define EPSILON 1e-6 #define TILE_SIZE 512 Range ENCAtlas::zooms(IntendedUsage usage) @@ -204,7 +205,8 @@ int ENCAtlas::zoomFit(const QSize &size, const RectC &rect) Transform t(transform(i)); QRectF r(t.proj2img(pr.topLeft()), t.proj2img(pr.bottomRight())); - if (size.width() < r.width() || size.height() < r.height()) { + if (size.width() + EPSILON < r.width() + || size.height() + EPSILON < r.height()) { updateTransform(); return _zoom; } diff --git a/src/map/encmap.cpp b/src/map/encmap.cpp index 9eaf018d..ae318de7 100644 --- a/src/map/encmap.cpp +++ b/src/map/encmap.cpp @@ -12,6 +12,7 @@ using namespace ENC; +#define EPSILON 1e-6 #define TILE_SIZE 512 static Range zooms(const RectC &bounds) @@ -204,7 +205,8 @@ int ENCMap::zoomFit(const QSize &size, const RectC &rect) for (int i = _zooms.min() + 1; i <= _zooms.max(); i++) { Transform t(transform(i)); QRectF r(t.proj2img(pr.topLeft()), t.proj2img(pr.bottomRight())); - if (size.width() < r.width() || size.height() < r.height()) + if (size.width() + EPSILON < r.width() + || size.height() + EPSILON < r.height()) break; _zoom = i; } diff --git a/src/map/imgmap.cpp b/src/map/imgmap.cpp index 1211debe..54a1d003 100644 --- a/src/map/imgmap.cpp +++ b/src/map/imgmap.cpp @@ -15,6 +15,7 @@ using namespace IMG; +#define EPSILON 1e-6 #define TILE_SIZE 384 static RectC limitBounds(const RectC &bounds, const Projection &proj) @@ -112,7 +113,8 @@ int IMGMap::zoomFit(const QSize &size, const RectC &rect) for (int i = zooms.min() + 1; i <= zooms.max(); i++) { Transform t(transform(i)); QRectF r(t.proj2img(pr.topLeft()), t.proj2img(pr.bottomRight())); - if (size.width() < r.width() || size.height() < r.height()) + if (size.width() + EPSILON < r.width() + || size.height() + EPSILON < r.height()) break; _zoom = i; } diff --git a/src/map/mapsforgemap.cpp b/src/map/mapsforgemap.cpp index 0e6b9793..dc69fd1c 100644 --- a/src/map/mapsforgemap.cpp +++ b/src/map/mapsforgemap.cpp @@ -9,6 +9,8 @@ using namespace Mapsforge; +#define EPSILON 1e-6 + MapsforgeMap::MapsforgeMap(const QString &fileName, QObject *parent) : Map(fileName, parent), _data(fileName), _zoom(0), _projection(PCS::pcs(3857)), _tileRatio(1.0) @@ -51,7 +53,8 @@ int MapsforgeMap::zoomFit(const QSize &size, const RectC &rect) for (int i = _data.zooms().min() + 1; i <= _data.zooms().max(); i++) { Transform t(transform(i)); QRectF r(t.proj2img(pr.topLeft()), t.proj2img(pr.bottomRight())); - if (size.width() < r.width() || size.height() < r.height()) + if (size.width() + EPSILON < r.width() + || size.height() + EPSILON < r.height()) break; _zoom = i; }