mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Fixed layer bounding box & scale denominator range joining
This commit is contained in:
parent
e845e216bd
commit
b8815ca9f5
@ -8,13 +8,13 @@ void RangeF::resize(qreal size)
|
|||||||
_max += adj;
|
_max += adj;
|
||||||
}
|
}
|
||||||
|
|
||||||
RangeF RangeF::operator|(const RangeF &r) const
|
RangeF RangeF::operator&(const RangeF &r) const
|
||||||
{
|
{
|
||||||
if (isNull())
|
if (isNull() || r.isNull())
|
||||||
return r;
|
return RangeF();
|
||||||
if (r.isNull())
|
|
||||||
return *this;
|
RangeF tmp(qMax(this->_min, r._min), qMin(this->_max, r._max));
|
||||||
return RangeF(qMax(this->_min, r._min), qMin(this->_max, r._max));
|
return tmp.isValid() ? tmp : RangeF();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
|
@ -29,8 +29,8 @@ public:
|
|||||||
RangeF() {_min = 0; _max = 0;}
|
RangeF() {_min = 0; _max = 0;}
|
||||||
RangeF(qreal min, qreal max) {_min = min, _max = max;}
|
RangeF(qreal min, qreal max) {_min = min, _max = max;}
|
||||||
|
|
||||||
RangeF operator|(const RangeF &r) const;
|
RangeF operator&(const RangeF &r) const;
|
||||||
RangeF &operator|=(const RangeF &r) {*this = *this | r; return *this;}
|
RangeF &operator&=(const RangeF &r) {*this = *this & r; return *this;}
|
||||||
|
|
||||||
qreal min() const {return _min;}
|
qreal min() const {return _min;}
|
||||||
qreal max() const {return _max;}
|
qreal max() const {return _max;}
|
||||||
|
@ -44,6 +44,54 @@ RectC RectC::operator|(const RectC &r) const
|
|||||||
return tmp;
|
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)
|
void RectC::unite(const Coordinates &c)
|
||||||
{
|
{
|
||||||
if (isNull()) {
|
if (isNull()) {
|
||||||
|
@ -30,6 +30,8 @@ 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;}
|
||||||
|
RectC operator&(const RectC &r) const;
|
||||||
|
RectC &operator&=(const RectC &r) {*this = *this & r; return *this;}
|
||||||
|
|
||||||
void unite(const Coordinates &c);
|
void unite(const Coordinates &c);
|
||||||
|
|
||||||
|
@ -96,11 +96,15 @@ void WMS::layer(QXmlStreamReader &reader, CTX &ctx,
|
|||||||
CRSs.append(reader.readElementText());
|
CRSs.append(reader.readElementText());
|
||||||
else if (reader.name() == "Style")
|
else if (reader.name() == "Style")
|
||||||
styles.append(style(reader));
|
styles.append(style(reader));
|
||||||
else if (reader.name() == "MinScaleDenominator")
|
else if (reader.name() == "MinScaleDenominator") {
|
||||||
scaleDenominator.setMin(reader.readElementText().toDouble());
|
double sd = reader.readElementText().toDouble();
|
||||||
else if (reader.name() == "MaxScaleDenominator")
|
if (!std::isnan(sd))
|
||||||
scaleDenominator.setMax(reader.readElementText().toDouble());
|
scaleDenominator.setMin(sd);
|
||||||
else if (reader.name() == "LatLonBoundingBox") {
|
} else if (reader.name() == "MaxScaleDenominator") {
|
||||||
|
double sd = reader.readElementText().toDouble();
|
||||||
|
if (!std::isnan(sd))
|
||||||
|
scaleDenominator.setMax(sd);
|
||||||
|
} else if (reader.name() == "LatLonBoundingBox") {
|
||||||
QXmlStreamAttributes attr = reader.attributes();
|
QXmlStreamAttributes attr = reader.attributes();
|
||||||
boundingBox = RectC(Coordinates(
|
boundingBox = RectC(Coordinates(
|
||||||
attr.value("minx").toString().toDouble(),
|
attr.value("minx").toString().toDouble(),
|
||||||
@ -208,13 +212,14 @@ bool WMS::parseCapabilities(const QString &path, const Setup &setup)
|
|||||||
+ layer.name;
|
+ layer.name;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!layer.scaleDenominator.isValid()) {
|
if (!layer.scaleDenominator.isValid()
|
||||||
_errorString = "Invalid scale denominator range for layer"
|
|| layer.scaleDenominator.isNull()) {
|
||||||
|
_errorString = "Invalid scale denominator range for layer "
|
||||||
+ layer.name;
|
+ layer.name;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!layer.boundingBox.isValid()) {
|
if (!layer.boundingBox.isValid()) {
|
||||||
_errorString = "Invalid/missing bounding box for layer"
|
_errorString = "Invalid/missing bounding box for layer "
|
||||||
+ layer.name;
|
+ layer.name;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -226,10 +231,21 @@ bool WMS::parseCapabilities(const QString &path, const Setup &setup)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < ctx.layers.size(); i++)
|
_boundingBox = ctx.layers.first().boundingBox;
|
||||||
_boundingBox |= ctx.layers.at(i).boundingBox;
|
for (int i = 1; i < ctx.layers.size(); i++)
|
||||||
for (int i = 0; i < ctx.layers.size(); i++)
|
_boundingBox &= ctx.layers.at(i).boundingBox;
|
||||||
_scaleDenominator |= ctx.layers.first().scaleDenominator;
|
if (_boundingBox.isNull()) {
|
||||||
|
_errorString = "Empty layers bounding box join";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_scaleDenominator = ctx.layers.first().scaleDenominator;
|
||||||
|
for (int i = 1; i < ctx.layers.size(); i++)
|
||||||
|
_scaleDenominator &= ctx.layers.at(i).scaleDenominator;
|
||||||
|
if (_scaleDenominator.isNull()) {
|
||||||
|
_errorString = "Empty layers scale denominator range join";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user