From b8a2b76d7c288a0edd2d4eb8157964fd4fe6defc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 14 Jan 2019 23:47:24 +0100 Subject: [PATCH] Fixed bounds computation --- src/map/ozimap.cpp | 7 ++++--- src/map/wmsmap.cpp | 6 ++---- src/map/wmtsmap.cpp | 6 ++---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/map/ozimap.cpp b/src/map/ozimap.cpp index 60240bfc..de1a4ed7 100644 --- a/src/map/ozimap.cpp +++ b/src/map/ozimap.cpp @@ -12,6 +12,7 @@ #include "ozf.h" #include "image.h" #include "mapfile.h" +#include "rectd.h" #include "ozimap.h" @@ -334,9 +335,9 @@ int OziMap::zoomFit(const QSize &size, const RectC &rect) if (!rect.isValid()) rescale(0); else { - QPointF tl(_transform.proj2img(_projection.ll2xy(rect.topLeft()))); - QPointF br(_transform.proj2img(_projection.ll2xy(rect.bottomRight()))); - QRect sbr(QRectF(tl, br).toRect().normalized()); + RectD prect(rect, _projection); + QRectF sbr(_transform.proj2img(prect.topLeft()), + _transform.proj2img(prect.bottomRight())); for (int i = 0; i < _ozf->zooms(); i++) { rescale(i); diff --git a/src/map/wmsmap.cpp b/src/map/wmsmap.cpp index 6d9dea85..e75348b0 100644 --- a/src/map/wmsmap.cpp +++ b/src/map/wmsmap.cpp @@ -127,10 +127,8 @@ QRectF WMSMap::bounds() int WMSMap::zoomFit(const QSize &size, const RectC &rect) { if (rect.isValid()) { - PointD tl(_projection.ll2xy(rect.topLeft())); - PointD br(_projection.ll2xy(rect.bottomRight())); - PointD sc((br.x() - tl.x()) / size.width(), (tl.y() - br.y()) - / size.height()); + RectD prect(rect, _projection); + PointD sc(prect.width() / size.width(), prect.height() / size.height()); double resolution = qMax(qAbs(sc.x()), qAbs(sc.y())); if (_projection.isGeographic()) resolution *= deg2rad(WGS84_RADIUS); diff --git a/src/map/wmtsmap.cpp b/src/map/wmtsmap.cpp index 05ff6392..f9dba6ac 100644 --- a/src/map/wmtsmap.cpp +++ b/src/map/wmtsmap.cpp @@ -103,10 +103,8 @@ QRectF WMTSMap::bounds() int WMTSMap::zoomFit(const QSize &size, const RectC &rect) { if (rect.isValid()) { - PointD tl(_projection.ll2xy(rect.topLeft())); - PointD br(_projection.ll2xy(rect.bottomRight())); - PointD sc((br.x() - tl.x()) / size.width(), (tl.y() - br.y()) - / size.height()); + RectD prect(rect, _projection); + PointD sc(prect.width() / size.width(), prect.height() / size.height()); double resolution = qMax(qAbs(sc.x()), qAbs(sc.y())); if (_projection.isGeographic()) resolution *= deg2rad(WGS84_RADIUS);