mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 11:39:16 +02:00
Fixed layer bounding box & scale denominator range joining
This commit is contained in:
@ -8,13 +8,13 @@ void RangeF::resize(qreal size)
|
||||
_max += adj;
|
||||
}
|
||||
|
||||
RangeF RangeF::operator|(const RangeF &r) const
|
||||
RangeF RangeF::operator&(const RangeF &r) const
|
||||
{
|
||||
if (isNull())
|
||||
return r;
|
||||
if (r.isNull())
|
||||
return *this;
|
||||
return RangeF(qMax(this->_min, r._min), qMin(this->_max, r._max));
|
||||
if (isNull() || r.isNull())
|
||||
return RangeF();
|
||||
|
||||
RangeF tmp(qMax(this->_min, r._min), qMin(this->_max, r._max));
|
||||
return tmp.isValid() ? tmp : RangeF();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
|
@ -29,8 +29,8 @@ public:
|
||||
RangeF() {_min = 0; _max = 0;}
|
||||
RangeF(qreal min, qreal max) {_min = min, _max = max;}
|
||||
|
||||
RangeF operator|(const RangeF &r) const;
|
||||
RangeF &operator|=(const RangeF &r) {*this = *this | r; return *this;}
|
||||
RangeF operator&(const RangeF &r) const;
|
||||
RangeF &operator&=(const RangeF &r) {*this = *this & r; return *this;}
|
||||
|
||||
qreal min() const {return _min;}
|
||||
qreal max() const {return _max;}
|
||||
|
@ -44,6 +44,54 @@ RectC RectC::operator|(const RectC &r) const
|
||||
return tmp;
|
||||
}
|
||||
|
||||
RectC RectC::operator&(const RectC &r) const
|
||||
{
|
||||
if (isNull() || r.isNull())
|
||||
return RectC();
|
||||
|
||||
qreal l1 = _tl.lon();
|
||||
qreal r1 = _tl.lon();
|
||||
if (_br.lon() - _tl.lon() < 0)
|
||||
l1 = _br.lon();
|
||||
else
|
||||
r1 = _br.lon();
|
||||
|
||||
qreal l2 = r._tl.lon();
|
||||
qreal r2 = r._tl.lon();
|
||||
if (r._br.lon() - r._tl.lon() < 0)
|
||||
l2 = r._br.lon();
|
||||
else
|
||||
r2 = r._br.lon();
|
||||
|
||||
if (l1 > r2 || l2 > r1)
|
||||
return RectC();
|
||||
|
||||
qreal t1 = _tl.lat();
|
||||
qreal b1 = _tl.lat();
|
||||
if (_br.lat() - _tl.lat() < 0)
|
||||
t1 = _br.lat();
|
||||
else
|
||||
b1 = _br.lat();
|
||||
|
||||
qreal t2 = r._tl.lat();
|
||||
qreal b2 = r._tl.lat();
|
||||
if (r._br.lat() - r._tl.lat() < 0)
|
||||
t2 = r._br.lat();
|
||||
else
|
||||
b2 = r._br.lat();
|
||||
|
||||
if (t1 > b2 || t2 > b1)
|
||||
return RectC();
|
||||
|
||||
RectC tmp;
|
||||
tmp._tl.setLon(qMax(l1, l2));
|
||||
tmp._br.setLon(qMin(r1, r2));
|
||||
tmp._tl.setLat(qMax(t1, t2));
|
||||
tmp._br.setLat(qMin(b1, b2));
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void RectC::unite(const Coordinates &c)
|
||||
{
|
||||
if (isNull()) {
|
||||
|
@ -30,6 +30,8 @@ public:
|
||||
|
||||
RectC operator|(const RectC &r) const;
|
||||
RectC &operator|=(const RectC &r) {*this = *this | r; return *this;}
|
||||
RectC operator&(const RectC &r) const;
|
||||
RectC &operator&=(const RectC &r) {*this = *this & r; return *this;}
|
||||
|
||||
void unite(const Coordinates &c);
|
||||
|
||||
|
Reference in New Issue
Block a user