mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-30 22:51:16 +01:00
Code cleanup
This commit is contained in:
parent
f2b72ec1b5
commit
4530ec1354
@ -75,8 +75,9 @@ void Atlas::computeBounds()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _maps.count(); i++)
|
for (int i = 0; i < _maps.count(); i++)
|
||||||
_bounds.append(QPair<QRectF, QRectF>(QRectF(TL(_maps.at(i)),
|
_bounds.append(QPair<QRectF, QRectF>(QRectF(TL(_maps.at(i)).toPointF(),
|
||||||
BR(_maps.at(i))), QRectF(offsets.at(i), _maps.at(i)->bounds().size())));
|
BR(_maps.at(i)).toPointF()), QRectF(offsets.at(i),
|
||||||
|
_maps.at(i)->bounds().size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
Atlas::Atlas(const QString &fileName, QObject *parent)
|
Atlas::Atlas(const QString &fileName, QObject *parent)
|
||||||
@ -166,7 +167,8 @@ qreal Atlas::resolution(const QRectF &rect) const
|
|||||||
int idx = _zooms.at(_zoom).first;
|
int idx = _zooms.at(_zoom).first;
|
||||||
|
|
||||||
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
if (_bounds.at(i).second.contains(_maps.at(i)->xy2pp(rect.center()))) {
|
if (_bounds.at(i).second.contains(_maps.at(i)->xy2pp(rect.center())
|
||||||
|
.toPointF())) {
|
||||||
idx = i;
|
idx = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -187,7 +189,8 @@ int Atlas::zoomFit(const QSize &size, const RectC &br)
|
|||||||
|
|
||||||
for (int z = 0; z < _zooms.count(); z++) {
|
for (int z = 0; z < _zooms.count(); z++) {
|
||||||
for (int i = _zooms.at(z).first; i <= _zooms.at(z).second; i++) {
|
for (int i = _zooms.at(z).first; i <= _zooms.at(z).second; i++) {
|
||||||
if (!_bounds.at(i).first.contains(_maps.at(i)->ll2pp(br.center())))
|
if (!_bounds.at(i).first.contains(_maps.at(i)->ll2pp(br.center())
|
||||||
|
.toPointF()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QRect sbr = QRectF(_maps.at(i)->ll2xy(br.topLeft()),
|
QRect sbr = QRectF(_maps.at(i)->ll2xy(br.topLeft()),
|
||||||
@ -226,11 +229,11 @@ QPointF Atlas::ll2xy(const Coordinates &c)
|
|||||||
QPointF pp;
|
QPointF pp;
|
||||||
|
|
||||||
if (_mapIndex >= 0)
|
if (_mapIndex >= 0)
|
||||||
pp = _maps.at(_mapIndex)->ll2pp(c);
|
pp = _maps.at(_mapIndex)->ll2pp(c).toPointF();
|
||||||
if (_mapIndex < 0 || !_bounds.at(_mapIndex).first.contains(pp)) {
|
if (_mapIndex < 0 || !_bounds.at(_mapIndex).first.contains(pp)) {
|
||||||
_mapIndex = _zooms.at(_zoom).first;
|
_mapIndex = _zooms.at(_zoom).first;
|
||||||
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
pp = _maps.at(i)->ll2pp(c);
|
pp = _maps.at(i)->ll2pp(c).toPointF();
|
||||||
if (_bounds.at(i).first.contains(pp)) {
|
if (_bounds.at(i).first.contains(pp)) {
|
||||||
_mapIndex = i;
|
_mapIndex = i;
|
||||||
break;
|
break;
|
||||||
@ -247,7 +250,7 @@ Coordinates Atlas::xy2ll(const QPointF &p)
|
|||||||
int idx = _zooms.at(_zoom).first;
|
int idx = _zooms.at(_zoom).first;
|
||||||
|
|
||||||
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
if (_bounds.at(i).second.contains(_maps.at(i)->xy2pp(p))) {
|
if (_bounds.at(i).second.contains(_maps.at(i)->xy2pp(p).toPointF())) {
|
||||||
idx = i;
|
idx = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ void OfflineMap::draw(QPainter *painter, const QRectF &rect)
|
|||||||
|
|
||||||
QPointF OfflineMap::ll2xy(const Coordinates &c) const
|
QPointF OfflineMap::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
QPointF p(_transform.proj2img(_projection.ll2xy(c).toPointF()));
|
QPointF p(_transform.proj2img(_projection.ll2xy(c)));
|
||||||
return _ozf ? QPointF(p.x() * _scale.x(), p.y() * _scale.y()) : p;
|
return _ozf ? QPointF(p.x() * _scale.x(), p.y() * _scale.y()) : p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,10 +363,8 @@ int OfflineMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
if (!rect.isValid())
|
if (!rect.isValid())
|
||||||
rescale(0);
|
rescale(0);
|
||||||
else {
|
else {
|
||||||
QPointF tl(_transform.proj2img(_projection.ll2xy(rect.topLeft())
|
QPointF tl(_transform.proj2img(_projection.ll2xy(rect.topLeft())));
|
||||||
.toPointF()));
|
QPointF br(_transform.proj2img(_projection.ll2xy(rect.bottomRight())));
|
||||||
QPointF br(_transform.proj2img(_projection.ll2xy(rect.bottomRight())
|
|
||||||
.toPointF()));
|
|
||||||
QRect sbr(QRectF(tl, br).toRect().normalized());
|
QRect sbr(QRectF(tl, br).toRect().normalized());
|
||||||
|
|
||||||
for (int i = 0; i < _ozf->zooms(); i++) {
|
for (int i = 0; i < _ozf->zooms(); i++) {
|
||||||
|
@ -41,11 +41,11 @@ public:
|
|||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
|
|
||||||
QPointF ll2pp(const Coordinates &c) const
|
PointD ll2pp(const Coordinates &c) const
|
||||||
{return _projection.ll2xy(c).toPointF();}
|
{return _projection.ll2xy(c);}
|
||||||
QPointF xy2pp(const QPointF &p) const
|
PointD xy2pp(const QPointF &p) const
|
||||||
{return _transform.img2proj(p);}
|
{return _transform.img2proj(p);}
|
||||||
QPointF pp2xy(const QPointF &p) const
|
QPointF pp2xy(const PointD &p) const
|
||||||
{return _transform.proj2img(p);}
|
{return _transform.proj2img(p);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -30,8 +30,10 @@ public:
|
|||||||
Transform(const ReferencePoint &p, const PointD &scale);
|
Transform(const ReferencePoint &p, const PointD &scale);
|
||||||
Transform(double matrix[16]);
|
Transform(double matrix[16]);
|
||||||
|
|
||||||
QPointF proj2img(const QPointF &p) const {return _proj2img.map(p);}
|
QPointF proj2img(const PointD &p) const
|
||||||
QPointF img2proj(const QPointF &p) const {return _img2proj.map(p);}
|
{return _proj2img.map(p.toPointF());}
|
||||||
|
PointD img2proj(const QPointF &p) const
|
||||||
|
{return _img2proj.map(p);}
|
||||||
|
|
||||||
bool isValid() const
|
bool isValid() const
|
||||||
{return _proj2img.isInvertible() && _img2proj.isInvertible();}
|
{return _proj2img.isInvertible() && _img2proj.isInvertible();}
|
||||||
|
@ -202,7 +202,7 @@ int WMSMap::zoomOut()
|
|||||||
|
|
||||||
QPointF WMSMap::ll2xy(const Coordinates &c) const
|
QPointF WMSMap::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
return _transform.proj2img(_projection.ll2xy(c).toPointF());
|
return _transform.proj2img(_projection.ll2xy(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates WMSMap::xy2ll(const QPointF &p) const
|
Coordinates WMSMap::xy2ll(const QPointF &p) const
|
||||||
@ -220,13 +220,13 @@ void WMSMap::draw(QPainter *painter, const QRectF &rect)
|
|||||||
QList<Tile> tiles;
|
QList<Tile> tiles;
|
||||||
for (int i = tl.x(); i < br.x(); i++) {
|
for (int i = tl.x(); i < br.x(); i++) {
|
||||||
for (int j = tl.y(); j < br.y(); j++) {
|
for (int j = tl.y(); j < br.y(); j++) {
|
||||||
QPointF ttl(_transform.img2proj(QPointF(i * TILE_SIZE,
|
PointD ttl(_transform.img2proj(QPointF(i * TILE_SIZE,
|
||||||
j * TILE_SIZE)));
|
j * TILE_SIZE)));
|
||||||
QPointF tbr(_transform.img2proj(QPointF(i * TILE_SIZE + TILE_SIZE
|
PointD tbr(_transform.img2proj(QPointF(i * TILE_SIZE + TILE_SIZE
|
||||||
- 1, j * TILE_SIZE + TILE_SIZE - 1)));
|
- 1, j * TILE_SIZE + TILE_SIZE - 1)));
|
||||||
QRectF bbox = (_cs.axisOrder() == CoordinateSystem::YX)
|
QRectF bbox = (_cs.axisOrder() == CoordinateSystem::YX)
|
||||||
? QRectF(QPointF(tbr.y(), tbr.x()), QPointF(ttl.y(), ttl.x()))
|
? QRectF(QPointF(tbr.y(), tbr.x()), QPointF(ttl.y(), ttl.x()))
|
||||||
: QRectF(ttl, tbr);
|
: QRectF(ttl.toPointF(), tbr.toPointF());
|
||||||
|
|
||||||
tiles.append(Tile(QPoint(i, j), _zoom, bbox));
|
tiles.append(Tile(QPoint(i, j), _zoom, bbox));
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ void WMTSMap::draw(QPainter *painter, const QRectF &rect)
|
|||||||
|
|
||||||
QPointF WMTSMap::ll2xy(const Coordinates &c) const
|
QPointF WMTSMap::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
return _transform.proj2img(_projection.ll2xy(c).toPointF());
|
return _transform.proj2img(_projection.ll2xy(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates WMTSMap::xy2ll(const QPointF &p) const
|
Coordinates WMTSMap::xy2ll(const QPointF &p) const
|
||||||
|
Loading…
Reference in New Issue
Block a user