1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Fixed bounds computation

This commit is contained in:
Martin Tůma 2019-01-14 23:47:24 +01:00
parent 9d5725f732
commit b8a2b76d7c
3 changed files with 8 additions and 11 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);