mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +01:00
Prevent zoom change due to float computations errors
This commit is contained in:
parent
f1fd4f8bc9
commit
108e68c7c9
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user