1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Added missing support for URLs defined in OnlineResources

This commit is contained in:
Martin Tůma 2020-03-04 19:47:23 +01:00
parent 9f62b7114e
commit 9859608115
4 changed files with 47 additions and 5 deletions

View File

@ -38,6 +38,38 @@ WMS::CTX::CTX(const Setup &setup) : setup(setup), formatSupported(false)
}
}
void WMS::get(QXmlStreamReader &reader, CTX &ctx)
{
while (reader.readNextStartElement()) {
if (reader.name() == "OnlineResource") {
QXmlStreamAttributes attr = reader.attributes();
ctx.url = attr.value("xlink:href").toString();
reader.skipCurrentElement();
} else
reader.skipCurrentElement();
}
}
void WMS::http(QXmlStreamReader &reader, CTX &ctx)
{
while (reader.readNextStartElement()) {
if (reader.name() == "Get")
get(reader, ctx);
else
reader.skipCurrentElement();
}
}
void WMS::dcpType(QXmlStreamReader &reader, CTX &ctx)
{
while (reader.readNextStartElement()) {
if (reader.name() == "HTTP")
http(reader, ctx);
else
reader.skipCurrentElement();
}
}
void WMS::getMap(QXmlStreamReader &reader, CTX &ctx)
{
while (reader.readNextStartElement()) {
@ -45,7 +77,9 @@ void WMS::getMap(QXmlStreamReader &reader, CTX &ctx)
QString format(reader.readElementText());
if (bareFormat(format) == bareFormat(ctx.setup.format()))
ctx.formatSupported = true;
} else
} else if (reader.name() == "DCPType")
dcpType(reader, ctx);
else
reader.skipCurrentElement();
}
}
@ -272,6 +306,8 @@ bool WMS::parseCapabilities(const QString &path, const Setup &setup)
return false;
}
_tileUrl = ctx.url.isEmpty() ? setup.url() : ctx.url;
return true;
}

View File

@ -54,6 +54,7 @@ public:
const RangeF &scaleDenominator() const {return _scaleDenominator;}
const RectC &boundingBox() const {return _boundingBox;}
const QString &version() const {return _version;}
const QString &tileUrl() const {return _tileUrl;}
bool isValid() const {return _valid;}
const QString &errorString() const {return _errorString;}
@ -79,12 +80,16 @@ private:
const Setup &setup;
QList<Layer> layers;
bool formatSupported;
QString url;
CTX(const Setup &setup);
};
RectC geographicBoundingBox(QXmlStreamReader &reader);
QString style(QXmlStreamReader &reader);
void get(QXmlStreamReader &reader, CTX &ctx);
void http(QXmlStreamReader &reader, CTX &ctx);
void dcpType(QXmlStreamReader &reader, CTX &ctx);
void getMap(QXmlStreamReader &reader, CTX &ctx);
void request(QXmlStreamReader &reader, CTX &ctx);
void layer(QXmlStreamReader &reader, CTX &ctx, const QList<QString> &pCRSs,
@ -100,6 +105,7 @@ private:
RangeF _scaleDenominator;
RectC _boundingBox;
QString _version;
QString _tileUrl;
bool _valid;
QString _errorString;

View File

@ -17,13 +17,13 @@ double WMSMap::sd2res(double scaleDenominator) const
return scaleDenominator * 0.28e-3 * _projection.units().fromMeters(1.0);
}
QString WMSMap::tileUrl(const QString &version) const
QString WMSMap::tileUrl(const QString &baseUrl, const QString &version) const
{
QString url;
url = QString("%1%2service=WMS&version=%3&request=GetMap&bbox=$bbox"
"&width=%4&height=%5&layers=%6&styles=%7&format=%8&transparent=true")
.arg(_setup.url(), _setup.url().contains('?') ? "&" : "?", version,
.arg(baseUrl, baseUrl.contains('?') ? "&" : "?", version,
QString::number(_tileSize), QString::number(_tileSize), _setup.layer(),
_setup.style(), _setup.format());
@ -83,7 +83,7 @@ bool WMSMap::loadWMS()
_projection = wms.projection();
_bbox = wms.boundingBox();
_bounds = RectD(_bbox, _projection);
_tileLoader->setUrl(tileUrl(wms.version()));
_tileLoader->setUrl(tileUrl(wms.tileUrl(), wms.version()));
if (wms.version() >= "1.3.0") {
if (_setup.coordinateSystem().axisOrder() == CoordinateSystem::Unknown)

View File

@ -40,7 +40,7 @@ public:
QString errorString() const {return _errorString;}
private:
QString tileUrl(const QString &version) const;
QString tileUrl(const QString &baseUrl, const QString &version) const;
double sd2res(double scaleDenominator) const;
QString tilesDir() const;
void computeZooms(const RangeF &scaleDenominator);