mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
RectC now uses the expected axis direction
+ some more refactoring
This commit is contained in:
parent
b26a10a5b3
commit
9e36451001
@ -105,7 +105,7 @@ HEADERS += src/config.h \
|
|||||||
src/map/wms.h \
|
src/map/wms.h \
|
||||||
src/map/crs.h \
|
src/map/crs.h \
|
||||||
src/map/coordinatesystem.h \
|
src/map/coordinatesystem.h \
|
||||||
src/map/point.h \
|
src/map/pointd.h \
|
||||||
src/data/graph.h \
|
src/data/graph.h \
|
||||||
src/data/poi.h \
|
src/data/poi.h \
|
||||||
src/data/waypoint.h \
|
src/data/waypoint.h \
|
||||||
|
@ -150,7 +150,7 @@ void MapView::addWaypoints(const QList<Waypoint> &waypoints)
|
|||||||
|
|
||||||
WaypointItem *wi = new WaypointItem(w, _map);
|
WaypointItem *wi = new WaypointItem(w, _map);
|
||||||
_waypoints.append(wi);
|
_waypoints.append(wi);
|
||||||
_wr.unite(wi->waypoint().coordinates());
|
_wr = _wr.united(wi->waypoint().coordinates());
|
||||||
wi->setZValue(1);
|
wi->setZValue(1);
|
||||||
wi->setSize(_waypointSize);
|
wi->setSize(_waypointSize);
|
||||||
wi->setColor(_waypointColor);
|
wi->setColor(_waypointColor);
|
||||||
|
@ -45,39 +45,34 @@ RectC RectC::operator|(const RectC &r) const
|
|||||||
|
|
||||||
double l1 = _tl.lon();
|
double l1 = _tl.lon();
|
||||||
double r1 = _tl.lon();
|
double r1 = _tl.lon();
|
||||||
if (_br.lon() - _tl.lon() < 0)
|
if (_br.lon() < _tl.lon())
|
||||||
l1 = _br.lon();
|
l1 = _br.lon();
|
||||||
else
|
else
|
||||||
r1 = _br.lon();
|
r1 = _br.lon();
|
||||||
|
|
||||||
double l2 = r._tl.lon();
|
double l2 = r._tl.lon();
|
||||||
double r2 = r._tl.lon();
|
double r2 = r._tl.lon();
|
||||||
if (r._br.lon() - r._tl.lon() < 0)
|
if (r._br.lon() < r._tl.lon())
|
||||||
l2 = r._br.lon();
|
l2 = r._br.lon();
|
||||||
else
|
else
|
||||||
r2 = r._br.lon();
|
r2 = r._br.lon();
|
||||||
|
|
||||||
double t1 = _tl.lat();
|
double t1 = _tl.lat();
|
||||||
double b1 = _tl.lat();
|
double b1 = _tl.lat();
|
||||||
if (_br.lat() - _tl.lat() < 0)
|
if (_br.lat() > _tl.lat())
|
||||||
t1 = _br.lat();
|
t1 = _br.lat();
|
||||||
else
|
else
|
||||||
b1 = _br.lat();
|
b1 = _br.lat();
|
||||||
|
|
||||||
double t2 = r._tl.lat();
|
double t2 = r._tl.lat();
|
||||||
double b2 = r._tl.lat();
|
double b2 = r._tl.lat();
|
||||||
if (r._br.lat() - r._tl.lat() < 0)
|
if (r._br.lat() > r._tl.lat())
|
||||||
t2 = r._br.lat();
|
t2 = r._br.lat();
|
||||||
else
|
else
|
||||||
b2 = r._br.lat();
|
b2 = r._br.lat();
|
||||||
|
|
||||||
RectC tmp;
|
return RectC(Coordinates(qMin(l1, l2), qMax(t1, t2)),
|
||||||
tmp._tl.setLon(qMin(l1, l2));
|
Coordinates(qMax(r1, r2), qMin(b1, b2)));
|
||||||
tmp._br.setLon(qMax(r1, r2));
|
|
||||||
tmp._tl.setLat(qMin(t1, t2));
|
|
||||||
tmp._br.setLat(qMax(b1, b2));
|
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RectC RectC::operator&(const RectC &r) const
|
RectC RectC::operator&(const RectC &r) const
|
||||||
@ -87,14 +82,14 @@ RectC RectC::operator&(const RectC &r) const
|
|||||||
|
|
||||||
double l1 = _tl.lon();
|
double l1 = _tl.lon();
|
||||||
double r1 = _tl.lon();
|
double r1 = _tl.lon();
|
||||||
if (_br.lon() - _tl.lon() < 0)
|
if (_br.lon() < _tl.lon())
|
||||||
l1 = _br.lon();
|
l1 = _br.lon();
|
||||||
else
|
else
|
||||||
r1 = _br.lon();
|
r1 = _br.lon();
|
||||||
|
|
||||||
double l2 = r._tl.lon();
|
double l2 = r._tl.lon();
|
||||||
double r2 = r._tl.lon();
|
double r2 = r._tl.lon();
|
||||||
if (r._br.lon() - r._tl.lon() < 0)
|
if (r._br.lon() < r._tl.lon())
|
||||||
l2 = r._br.lon();
|
l2 = r._br.lon();
|
||||||
else
|
else
|
||||||
r2 = r._br.lon();
|
r2 = r._br.lon();
|
||||||
@ -104,67 +99,56 @@ RectC RectC::operator&(const RectC &r) const
|
|||||||
|
|
||||||
double t1 = _tl.lat();
|
double t1 = _tl.lat();
|
||||||
double b1 = _tl.lat();
|
double b1 = _tl.lat();
|
||||||
if (_br.lat() - _tl.lat() < 0)
|
if (_br.lat() > _tl.lat())
|
||||||
t1 = _br.lat();
|
t1 = _br.lat();
|
||||||
else
|
else
|
||||||
b1 = _br.lat();
|
b1 = _br.lat();
|
||||||
|
|
||||||
double t2 = r._tl.lat();
|
double t2 = r._tl.lat();
|
||||||
double b2 = r._tl.lat();
|
double b2 = r._tl.lat();
|
||||||
if (r._br.lat() - r._tl.lat() < 0)
|
if (r._br.lat() > r._tl.lat())
|
||||||
t2 = r._br.lat();
|
t2 = r._br.lat();
|
||||||
else
|
else
|
||||||
b2 = r._br.lat();
|
b2 = r._br.lat();
|
||||||
|
|
||||||
if (t1 > b2 || t2 > b1)
|
if (b1 > t2 || b2 > t1)
|
||||||
return RectC();
|
return RectC();
|
||||||
|
|
||||||
RectC tmp;
|
return RectC(Coordinates(qMax(l1, l2), qMin(t1, t2)),
|
||||||
tmp._tl.setLon(qMax(l1, l2));
|
Coordinates(qMin(r1, r2), qMax(b1, b2)));
|
||||||
tmp._br.setLon(qMin(r1, r2));
|
|
||||||
tmp._tl.setLat(qMax(t1, t2));
|
|
||||||
tmp._br.setLat(qMin(b1, b2));
|
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RectC RectC::normalized() const
|
RectC RectC::united(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
RectC r;
|
if (c.isNull())
|
||||||
|
return *this;
|
||||||
|
if (isNull())
|
||||||
|
return RectC(c, c);
|
||||||
|
|
||||||
if (_br.lon() < _tl.lon()) {
|
double l = _tl.lon();
|
||||||
r._tl.setLon(_br.lon());
|
double r = _tl.lon();
|
||||||
r._br.setLon(_tl.lon());
|
if (_br.lon() < _tl.lon())
|
||||||
} else {
|
l = _br.lon();
|
||||||
r._tl.setLon(_tl.lon());
|
else
|
||||||
r._br.setLon(_br.lon());
|
r = _br.lon();
|
||||||
}
|
|
||||||
if (_br.lat() < _tl.lat()) {
|
|
||||||
r._tl.setLat(_br.lat());
|
|
||||||
r._br.setLat(_tl.lat());
|
|
||||||
} else {
|
|
||||||
r._tl.setLat(_tl.lat());
|
|
||||||
r._br.setLat(_br.lat());
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
double t = _tl.lat();
|
||||||
}
|
double b = _tl.lat();
|
||||||
|
if (_br.lat() > _tl.lat())
|
||||||
|
t = _br.lat();
|
||||||
|
else
|
||||||
|
b = _br.lat();
|
||||||
|
|
||||||
void RectC::unite(const Coordinates &c)
|
if (c.lon() < l)
|
||||||
{
|
l = c.lon();
|
||||||
if (isNull()) {
|
if (c.lon() > r)
|
||||||
_tl = c;
|
r = c.lon();
|
||||||
_br = c;
|
if (c.lat() < b)
|
||||||
} else {
|
b = c.lat();
|
||||||
if (c.lon() < _tl.lon())
|
if (c.lat() > t)
|
||||||
_tl.setLon(c.lon());
|
t = c.lat();
|
||||||
if (c.lon() > _br.lon())
|
|
||||||
_br.setLon(c.lon());
|
return RectC(Coordinates(l, t), Coordinates(r, b));
|
||||||
if (c.lat() > _br.lat())
|
|
||||||
_br.setLat(c.lat());
|
|
||||||
if (c.lat() < _tl.lat())
|
|
||||||
_tl.setLat(c.lat());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
|
@ -28,8 +28,7 @@ public:
|
|||||||
RectC operator&(const RectC &r) const;
|
RectC operator&(const RectC &r) const;
|
||||||
RectC &operator&=(const RectC &r) {*this = *this & r; return *this;}
|
RectC &operator&=(const RectC &r) {*this = *this & r; return *this;}
|
||||||
|
|
||||||
void unite(const Coordinates &c);
|
RectC united(const Coordinates &c) const;
|
||||||
RectC normalized() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Coordinates _tl, _br;
|
Coordinates _tl, _br;
|
||||||
|
@ -8,7 +8,7 @@ RectC Path::boundingRect() const
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (int i = 0; i < size(); i++)
|
for (int i = 0; i < size(); i++)
|
||||||
ret.unite(at(i).coordinates());
|
ret = ret.united(at(i).coordinates());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define CT_H
|
#define CT_H
|
||||||
|
|
||||||
#include "common/coordinates.h"
|
#include "common/coordinates.h"
|
||||||
#include "point.h"
|
#include "pointd.h"
|
||||||
|
|
||||||
class CT {
|
class CT {
|
||||||
public:
|
public:
|
||||||
|
@ -51,15 +51,15 @@ QRectF EmptyMap::bounds() const
|
|||||||
return QRectF(ll2xy(Coordinates(-180, 85)), ll2xy(Coordinates(180, -85)));
|
return QRectF(ll2xy(Coordinates(-180, 85)), ll2xy(Coordinates(180, -85)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int EmptyMap::zoomFit(const QSize &size, const RectC &br)
|
int EmptyMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
{
|
{
|
||||||
if (!br.isValid())
|
if (!rect.isValid())
|
||||||
_zoom = ZOOM_MAX;
|
_zoom = ZOOM_MAX;
|
||||||
else {
|
else {
|
||||||
QRectF tbr(ll2m(br.topLeft()), ll2m(br.bottomRight()));
|
QRectF tbr(ll2m(rect.topLeft()), ll2m(rect.bottomRight()));
|
||||||
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||||
|
|
||||||
_zoom = limitZoom(scale2zoom(qMax(sc.x(), sc.y())));
|
_zoom = limitZoom(scale2zoom(qMax(sc.x(), -sc.y())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return _zoom;
|
return _zoom;
|
||||||
|
@ -16,7 +16,7 @@ public:
|
|||||||
qreal resolution(const QRectF &rect) const;
|
qreal resolution(const QRectF &rect) const;
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
int zoomFit(const QSize &size, const RectC &br);
|
int zoomFit(const QSize &size, const RectC &rect);
|
||||||
int zoomIn();
|
int zoomIn();
|
||||||
int zoomOut();
|
int zoomOut();
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "point.h"
|
#include "pointd.h"
|
||||||
|
|
||||||
class LinearUnits
|
class LinearUnits
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
virtual qreal resolution(const QRectF &rect) const = 0;
|
virtual qreal resolution(const QRectF &rect) const = 0;
|
||||||
|
|
||||||
virtual int zoom() const = 0;
|
virtual int zoom() const = 0;
|
||||||
virtual int zoomFit(const QSize &size, const RectC &br) = 0;
|
virtual int zoomFit(const QSize &size, const RectC &rect) = 0;
|
||||||
virtual int zoomIn() = 0;
|
virtual int zoomIn() = 0;
|
||||||
virtual int zoomOut() = 0;
|
virtual int zoomOut() = 0;
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ static int scale2zoom(qreal scale)
|
|||||||
|
|
||||||
OnlineMap::OnlineMap(const QString &name, const QString &url,
|
OnlineMap::OnlineMap(const QString &name, const QString &url,
|
||||||
const Range &zooms, const RectC &bounds, QObject *parent) :
|
const Range &zooms, const RectC &bounds, QObject *parent) :
|
||||||
Map(parent), _name(name), _zooms(zooms), _bounds(bounds),
|
Map(parent), _name(name), _zooms(zooms), _bounds(bounds), _block(false),
|
||||||
_block(false), _valid(false)
|
_valid(false)
|
||||||
{
|
{
|
||||||
QString dir(TILES_DIR + "/" + _name);
|
QString dir(TILES_DIR + "/" + _name);
|
||||||
|
|
||||||
@ -90,15 +90,14 @@ int OnlineMap::limitZoom(int zoom) const
|
|||||||
return zoom;
|
return zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OnlineMap::zoomFit(const QSize &size, const RectC &br)
|
int OnlineMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
{
|
{
|
||||||
if (!br.isValid())
|
if (!rect.isValid())
|
||||||
_zoom = _zooms.max();
|
_zoom = _zooms.max();
|
||||||
else {
|
else {
|
||||||
QRectF tbr(ll2m(br.topLeft()), ll2m(br.bottomRight()));
|
QRectF tbr(ll2m(rect.topLeft()), ll2m(rect.bottomRight()));
|
||||||
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||||
|
_zoom = limitZoom(scale2zoom(qMax(sc.x(), -sc.y())));
|
||||||
_zoom = limitZoom(scale2zoom(qMax(sc.x(), sc.y())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return _zoom;
|
return _zoom;
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
qreal resolution(const QRectF &rect) const;
|
qreal resolution(const QRectF &rect) const;
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
int zoomFit(const QSize &size, const RectC &br);
|
int zoomFit(const QSize &size, const RectC &rect);
|
||||||
int zoomIn();
|
int zoomIn();
|
||||||
int zoomOut();
|
int zoomOut();
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
class PointD {
|
class PointD
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
PointD() : _x(NAN), _y(NAN) {}
|
PointD() : _x(NAN), _y(NAN) {}
|
||||||
PointD(double x, double y) : _x(x), _y(y) {}
|
PointD(double x, double y) : _x(x), _y(y) {}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "common/coordinates.h"
|
#include "common/coordinates.h"
|
||||||
#include "point.h"
|
#include "pointd.h"
|
||||||
#include "linearunits.h"
|
#include "linearunits.h"
|
||||||
#include "coordinatesystem.h"
|
#include "coordinatesystem.h"
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "point.h"
|
#include "pointd.h"
|
||||||
|
|
||||||
class ReferencePoint
|
class ReferencePoint
|
||||||
{
|
{
|
||||||
|
@ -60,15 +60,17 @@ void WMSMap::computeZooms(const RangeF &scaleDenominator)
|
|||||||
|
|
||||||
void WMSMap::updateTransform()
|
void WMSMap::updateTransform()
|
||||||
{
|
{
|
||||||
double scaleDenominator = _zooms.at(_zoom);
|
double pixelSpan = sd2res(_zooms.at(_zoom));
|
||||||
double pixelSpan = sd2res(scaleDenominator);
|
|
||||||
if (_projection.isGeographic())
|
if (_projection.isGeographic())
|
||||||
pixelSpan /= deg2rad(WGS84_RADIUS);
|
pixelSpan /= deg2rad(WGS84_RADIUS);
|
||||||
|
double sx = (_br.x() - _tl.x()) / pixelSpan;
|
||||||
|
double sy = (_tl.y() - _br.y()) / pixelSpan;
|
||||||
|
|
||||||
ReferencePoint tl(PointD(0, 0), _boundingBox.topLeft());
|
ReferencePoint tl(PointD(0, 0), _tl);
|
||||||
ReferencePoint br(PointD(_boundingBox.width() / pixelSpan,
|
ReferencePoint br(PointD(sx, sy), _br);
|
||||||
-_boundingBox.height() / pixelSpan), _boundingBox.bottomRight());
|
|
||||||
_transform = Transform(tl, br);
|
_transform = Transform(tl, br);
|
||||||
|
|
||||||
|
_bounds = QRectF(QPointF(0, 0), QSizeF(sx, sy));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WMSMap::loadWMS()
|
bool WMSMap::loadWMS()
|
||||||
@ -82,10 +84,8 @@ bool WMSMap::loadWMS()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_projection = wms.projection();
|
_projection = wms.projection();
|
||||||
RectC bb = wms.boundingBox().normalized();
|
_tl = _projection.ll2xy(wms.boundingBox().topLeft());
|
||||||
_boundingBox = QRectF(_projection.ll2xy(Coordinates(bb.topLeft().lon(),
|
_br = _projection.ll2xy(wms.boundingBox().bottomRight());
|
||||||
bb.bottomRight().lat())).toPointF(), _projection.ll2xy(Coordinates(
|
|
||||||
bb.bottomRight().lon(), bb.topLeft().lat())).toPointF());
|
|
||||||
_tileLoader = TileLoader(tileUrl(wms.version()), tilesDir(),
|
_tileLoader = TileLoader(tileUrl(wms.version()), tilesDir(),
|
||||||
_setup.authorization());
|
_setup.authorization());
|
||||||
|
|
||||||
@ -141,17 +141,6 @@ void WMSMap::emitLoaded()
|
|||||||
emit loaded();
|
emit loaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF WMSMap::bounds() const
|
|
||||||
{
|
|
||||||
double pixelSpan = sd2res(_zooms.at(_zoom));
|
|
||||||
if (_projection.isGeographic())
|
|
||||||
pixelSpan /= deg2rad(WGS84_RADIUS);
|
|
||||||
QSizeF size(_boundingBox.width() / pixelSpan, -_boundingBox.height()
|
|
||||||
/ pixelSpan);
|
|
||||||
|
|
||||||
return QRectF(QPointF(0, 0), size);
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal WMSMap::resolution(const QRectF &rect) const
|
qreal WMSMap::resolution(const QRectF &rect) const
|
||||||
{
|
{
|
||||||
Coordinates tl = xy2ll((rect.topLeft()));
|
Coordinates tl = xy2ll((rect.topLeft()));
|
||||||
@ -163,12 +152,13 @@ qreal WMSMap::resolution(const QRectF &rect) const
|
|||||||
return ds/ps;
|
return ds/ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WMSMap::zoomFit(const QSize &size, const RectC &br)
|
int WMSMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
{
|
{
|
||||||
if (br.isValid()) {
|
if (rect.isValid()) {
|
||||||
QRectF tbr(_projection.ll2xy(br.topLeft()).toPointF(),
|
PointD tl(_projection.ll2xy(rect.topLeft()));
|
||||||
_projection.ll2xy(br.bottomRight()).toPointF());
|
PointD br(_projection.ll2xy(rect.bottomRight()));
|
||||||
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
PointD sc((br.x() - tl.x()) / size.width(), (tl.y() - br.y())
|
||||||
|
/ size.height());
|
||||||
double resolution = qMax(qAbs(sc.x()), qAbs(sc.y()));
|
double resolution = qMax(qAbs(sc.x()), qAbs(sc.y()));
|
||||||
if (_projection.isGeographic())
|
if (_projection.isGeographic())
|
||||||
resolution *= deg2rad(WGS84_RADIUS);
|
resolution *= deg2rad(WGS84_RADIUS);
|
||||||
|
@ -17,11 +17,11 @@ public:
|
|||||||
|
|
||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds() const {return _bounds;}
|
||||||
qreal resolution(const QRectF &rect) const;
|
qreal resolution(const QRectF &rect) const;
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
int zoomFit(const QSize &size, const RectC &br);
|
int zoomFit(const QSize &size, const RectC &rect);
|
||||||
int zoomIn();
|
int zoomIn();
|
||||||
int zoomOut();
|
int zoomOut();
|
||||||
|
|
||||||
@ -63,7 +63,8 @@ private:
|
|||||||
Transform _transform;
|
Transform _transform;
|
||||||
CoordinateSystem _cs;
|
CoordinateSystem _cs;
|
||||||
QVector<double> _zooms;
|
QVector<double> _zooms;
|
||||||
QRectF _boundingBox;
|
PointD _tl, _br;
|
||||||
|
QRectF _bounds;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
bool _block;
|
bool _block;
|
||||||
|
|
||||||
|
@ -122,13 +122,14 @@ QRectF WMTSMap::bounds() const
|
|||||||
return _bounds.isValid() ? tileBounds.intersected(bounds) : tileBounds;
|
return _bounds.isValid() ? tileBounds.intersected(bounds) : tileBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WMTSMap::zoomFit(const QSize &size, const RectC &br)
|
int WMTSMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
{
|
{
|
||||||
if (br.isValid()) {
|
if (rect.isValid()) {
|
||||||
QRectF tbr(_projection.ll2xy(br.topLeft()).toPointF(),
|
PointD tl(_projection.ll2xy(rect.topLeft()));
|
||||||
_projection.ll2xy(br.bottomRight()).toPointF());
|
PointD br(_projection.ll2xy(rect.bottomRight()));
|
||||||
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
PointD sc((br.x() - tl.x()) / size.width(), (tl.y() - br.y())
|
||||||
qreal resolution = qMax(qAbs(sc.x()), qAbs(sc.y()));
|
/ size.height());
|
||||||
|
double resolution = qMax(qAbs(sc.x()), qAbs(sc.y()));
|
||||||
if (_projection.isGeographic())
|
if (_projection.isGeographic())
|
||||||
resolution *= deg2rad(WGS84_RADIUS);
|
resolution *= deg2rad(WGS84_RADIUS);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
qreal resolution(const QRectF &rect) const;
|
qreal resolution(const QRectF &rect) const;
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
int zoomFit(const QSize &size, const RectC &br);
|
int zoomFit(const QSize &size, const RectC &rect);
|
||||||
int zoomIn();
|
int zoomIn();
|
||||||
int zoomOut();
|
int zoomOut();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user