mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Added support for WMS 1.1.x versions
This commit is contained in:
parent
aecda0e517
commit
16f2d7ad34
@ -67,13 +67,6 @@ void WMS::layer(QXmlStreamReader &reader, CTX &ctx,
|
||||
else if (reader.name() == "BoundingBox") {
|
||||
QXmlStreamAttributes attr = reader.attributes();
|
||||
if (attr.value("CRS") == ctx.setup.crs()) {
|
||||
if (ctx.setup.yx())
|
||||
boundingBox = QRectF(QPointF(
|
||||
attr.value("miny").toString().toDouble(),
|
||||
attr.value("maxx").toString().toDouble()),
|
||||
QPointF(attr.value("maxy").toString().toDouble(),
|
||||
attr.value("minx").toString().toDouble()));
|
||||
else
|
||||
boundingBox = QRectF(QPointF(
|
||||
attr.value("minx").toString().toDouble(),
|
||||
attr.value("maxy").toString().toDouble()),
|
||||
@ -113,6 +106,8 @@ void WMS::capability(QXmlStreamReader &reader, CTX &ctx)
|
||||
|
||||
void WMS::capabilities(QXmlStreamReader &reader, CTX &ctx)
|
||||
{
|
||||
_version = reader.attributes().value("version").toString();
|
||||
|
||||
while (reader.readNextStartElement()) {
|
||||
if (reader.name() == "Capability")
|
||||
capability(reader, ctx);
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
const Projection &projection() const {return _projection;}
|
||||
const RangeF &scaleDenominator() const {return _scaleDenominator;}
|
||||
const QRectF &boundingBox() const {return _boundingBox;}
|
||||
const QString &version() const {return _version;}
|
||||
|
||||
bool isValid() const {return _valid;}
|
||||
const QString &errorString() const {return _errorString;}
|
||||
@ -76,6 +77,7 @@ private:
|
||||
Projection _projection;
|
||||
RangeF _scaleDenominator;
|
||||
QRectF _boundingBox;
|
||||
QString _version;
|
||||
|
||||
bool _valid;
|
||||
QString _errorString;
|
||||
|
@ -15,11 +15,15 @@ qreal WMSMap::sd2res(qreal scaleDenominator) const
|
||||
return scaleDenominator * 0.28e-3 * _projection.units().fromMeters(1.0);
|
||||
}
|
||||
|
||||
QString WMSMap::tileUrl() const
|
||||
QString WMSMap::tileUrl(const QString &version) const
|
||||
{
|
||||
return QString("%1?version=1.3.0&request=GetMap&CRS=%2&bbox=$bbox"
|
||||
"&width=%3&height=%4&layers=%5&styles=%6&format=%7&transparent=true")
|
||||
.arg(_setup.url(), _setup.crs(), QString::number(TILE_SIZE),
|
||||
QString crs = version >= "1.3.0"
|
||||
? QString("CRS=%1").arg(_setup.crs())
|
||||
: QString("SRS=%1").arg(_setup.crs());
|
||||
|
||||
return QString("%1?version=%2&request=GetMap&%3&bbox=$bbox"
|
||||
"&width=%4&height=%5&layers=%6&styles=%7&format=%8&transparent=true")
|
||||
.arg(_setup.url(), version, crs, QString::number(TILE_SIZE),
|
||||
QString::number(TILE_SIZE), _setup.layer(), _setup.style(),
|
||||
_setup.format());
|
||||
}
|
||||
@ -74,9 +78,12 @@ bool WMSMap::loadWMS()
|
||||
return false;
|
||||
}
|
||||
|
||||
_yx = (_setup.yx() && wms.version() >= "1.3.0") ? true : false;
|
||||
_projection = wms.projection();
|
||||
_boundingBox = wms.boundingBox();
|
||||
_tileLoader = TileLoader(tileUrl(), tilesDir());
|
||||
_boundingBox = _yx ? QRectF(QPointF(wms.boundingBox().bottom(),
|
||||
wms.boundingBox().right()), QPointF(wms.boundingBox().top(),
|
||||
wms.boundingBox().left())) : wms.boundingBox();
|
||||
_tileLoader = TileLoader(tileUrl(wms.version()), tilesDir());
|
||||
|
||||
computeZooms(wms.scaleDenominator());
|
||||
updateTransform();
|
||||
@ -205,7 +212,7 @@ void WMSMap::draw(QPainter *painter, const QRectF &rect)
|
||||
j * TILE_SIZE)));
|
||||
QPointF tbr(_transform.img2proj(QPointF(i * TILE_SIZE + TILE_SIZE
|
||||
- 1, j * TILE_SIZE + TILE_SIZE - 1)));
|
||||
QRectF bbox = _setup.yx()
|
||||
QRectF bbox = _yx
|
||||
? QRectF(QPointF(tbr.y(), tbr.x()), QPointF(ttl.y(), ttl.x()))
|
||||
: QRectF(ttl, tbr);
|
||||
|
||||
|
@ -45,7 +45,7 @@ private slots:
|
||||
void emitLoaded();
|
||||
|
||||
private:
|
||||
QString tileUrl() const;
|
||||
QString tileUrl(const QString &version) const;
|
||||
qreal sd2res(qreal scaleDenominator) const;
|
||||
QString tilesDir() const;
|
||||
void computeZooms(const RangeF &scaleDenominator);
|
||||
@ -64,6 +64,7 @@ private:
|
||||
QVector<qreal> _zooms;
|
||||
int _zoom;
|
||||
QRectF _boundingBox;
|
||||
bool _yx;
|
||||
bool _block;
|
||||
|
||||
bool _valid;
|
||||
|
Loading…
Reference in New Issue
Block a user