diff --git a/src/atlas.cpp b/src/atlas.cpp index 6611da0d..4a65f198 100644 --- a/src/atlas.cpp +++ b/src/atlas.cpp @@ -203,7 +203,7 @@ qreal Atlas::zoomFit(const QSize &size, const RectC &br) { _zoom = 0; - if (br.isNull()) { + if (!br.isValid()) { _zoom = _zooms.size() - 1; return _zoom; } diff --git a/src/emptymap.cpp b/src/emptymap.cpp index 329f5cab..3dbaf283 100644 --- a/src/emptymap.cpp +++ b/src/emptymap.cpp @@ -24,7 +24,7 @@ QRectF EmptyMap::bounds() const qreal EmptyMap::zoomFit(const QSize &size, const RectC &br) { - if (br.isNull()) + if (!br.isValid()) _scale = SCALE_MAX; else { QRectF tbr(Mercator().ll2xy(br.topLeft()), diff --git a/src/onlinemap.cpp b/src/onlinemap.cpp index 762d8fe1..803c3d03 100644 --- a/src/onlinemap.cpp +++ b/src/onlinemap.cpp @@ -168,7 +168,7 @@ QRectF OnlineMap::bounds() const qreal OnlineMap::zoomFit(const QSize &size, const RectC &br) { - if (br.isNull()) + if (!br.isValid()) _zoom = ZOOM_MAX; else { QRectF tbr(Mercator().ll2xy(br.topLeft()), diff --git a/src/pathview.cpp b/src/pathview.cpp index 226eab8d..5baf2c93 100644 --- a/src/pathview.cpp +++ b/src/pathview.cpp @@ -173,22 +173,15 @@ QList PathView::loadData(const Data &data) void PathView::updateWaypointsBoundingRect(const Coordinates &wp) { - if (_wr.isNull()) { - if (_wp.isNull()) - _wp = wp; - else { - _wr = RectC(_wp, wp).normalized(); - _wp = Coordinates(); - } - } else + if (_wr.isNull()) + _wr = RectC(wp, wp); + else _wr.unite(wp); } qreal PathView::mapScale() const { RectC br = _tr | _rr | _wr; - if (!br.isNull() && !_wp.isNull()) - br.unite(_wp); return _map->zoomFit(viewport()->size() - QSize(MARGIN/2, MARGIN/2), br); } @@ -196,13 +189,8 @@ qreal PathView::mapScale() const QPointF PathView::contentCenter() const { RectC br = _tr | _rr | _wr; - if (!br.isNull() && !_wp.isNull()) - br.unite(_wp); - if (br.isNull()) - return _map->ll2xy(_wp); - else - return _map->ll2xy(br.center()); + return _map->ll2xy(br.center()); } void PathView::updatePOIVisibility() @@ -530,8 +518,9 @@ void PathView::clear() _scene->clear(); _palette.reset(); - _tr = RectC(); _rr = RectC(); _wr = RectC(); - _wp = Coordinates(); + _tr = RectC(); + _rr = RectC(); + _wr = RectC(); resetDigitalZoom(); resetCachedContent(); diff --git a/src/pathview.h b/src/pathview.h index e45bdb59..973f6b15 100644 --- a/src/pathview.h +++ b/src/pathview.h @@ -99,7 +99,6 @@ private: QHash _pois; RectC _tr, _rr, _wr; - Coordinates _wp; qreal _res; Map *_map; diff --git a/src/rectc.cpp b/src/rectc.cpp index a5bce4be..89b11801 100644 --- a/src/rectc.cpp +++ b/src/rectc.cpp @@ -1,28 +1,5 @@ #include "rectc.h" -RectC RectC::normalized() const -{ - RectC r; - - if (_br.lon() < _tl.lon()) { - r._tl.setLon(_br.lon()); - r._br.setLon(_tl.lon()); - } else { - r._tl.setLon(_tl.lon()); - r._br.setLon(_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; -} - RectC RectC::operator|(const RectC &r) const { if (isNull()) diff --git a/src/rectc.h b/src/rectc.h index e174727f..c1d87b1e 100644 --- a/src/rectc.h +++ b/src/rectc.h @@ -13,7 +13,9 @@ public: : _tl(topLeft), _br(bottomRight) {} bool isNull() const - {return _tl.isNull() || _br.isNull() || _tl == _br;} + {return _tl.isNull() && _br.isNull();} + bool isValid() const + {return !(_tl.isNull() || _br.isNull() || _tl == _br);} Coordinates topLeft() const {return _tl;} Coordinates bottomRight() const {return _br;} @@ -26,8 +28,6 @@ public: QSizeF size() const {return QSizeF(width(), height());} - RectC normalized() const; - RectC operator|(const RectC &r) const; RectC &operator|=(const RectC &r) {*this = *this | r; return *this;}