mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Added missing support for URLs defined in OnlineResources
This commit is contained in:
parent
9f62b7114e
commit
9859608115
@ -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)
|
void WMS::getMap(QXmlStreamReader &reader, CTX &ctx)
|
||||||
{
|
{
|
||||||
while (reader.readNextStartElement()) {
|
while (reader.readNextStartElement()) {
|
||||||
@ -45,7 +77,9 @@ void WMS::getMap(QXmlStreamReader &reader, CTX &ctx)
|
|||||||
QString format(reader.readElementText());
|
QString format(reader.readElementText());
|
||||||
if (bareFormat(format) == bareFormat(ctx.setup.format()))
|
if (bareFormat(format) == bareFormat(ctx.setup.format()))
|
||||||
ctx.formatSupported = true;
|
ctx.formatSupported = true;
|
||||||
} else
|
} else if (reader.name() == "DCPType")
|
||||||
|
dcpType(reader, ctx);
|
||||||
|
else
|
||||||
reader.skipCurrentElement();
|
reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,6 +306,8 @@ bool WMS::parseCapabilities(const QString &path, const Setup &setup)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_tileUrl = ctx.url.isEmpty() ? setup.url() : ctx.url;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
const RangeF &scaleDenominator() const {return _scaleDenominator;}
|
const RangeF &scaleDenominator() const {return _scaleDenominator;}
|
||||||
const RectC &boundingBox() const {return _boundingBox;}
|
const RectC &boundingBox() const {return _boundingBox;}
|
||||||
const QString &version() const {return _version;}
|
const QString &version() const {return _version;}
|
||||||
|
const QString &tileUrl() const {return _tileUrl;}
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
const QString &errorString() const {return _errorString;}
|
const QString &errorString() const {return _errorString;}
|
||||||
@ -79,12 +80,16 @@ private:
|
|||||||
const Setup &setup;
|
const Setup &setup;
|
||||||
QList<Layer> layers;
|
QList<Layer> layers;
|
||||||
bool formatSupported;
|
bool formatSupported;
|
||||||
|
QString url;
|
||||||
|
|
||||||
CTX(const Setup &setup);
|
CTX(const Setup &setup);
|
||||||
};
|
};
|
||||||
|
|
||||||
RectC geographicBoundingBox(QXmlStreamReader &reader);
|
RectC geographicBoundingBox(QXmlStreamReader &reader);
|
||||||
QString style(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 getMap(QXmlStreamReader &reader, CTX &ctx);
|
||||||
void request(QXmlStreamReader &reader, CTX &ctx);
|
void request(QXmlStreamReader &reader, CTX &ctx);
|
||||||
void layer(QXmlStreamReader &reader, CTX &ctx, const QList<QString> &pCRSs,
|
void layer(QXmlStreamReader &reader, CTX &ctx, const QList<QString> &pCRSs,
|
||||||
@ -100,6 +105,7 @@ private:
|
|||||||
RangeF _scaleDenominator;
|
RangeF _scaleDenominator;
|
||||||
RectC _boundingBox;
|
RectC _boundingBox;
|
||||||
QString _version;
|
QString _version;
|
||||||
|
QString _tileUrl;
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
@ -17,13 +17,13 @@ double WMSMap::sd2res(double scaleDenominator) const
|
|||||||
return scaleDenominator * 0.28e-3 * _projection.units().fromMeters(1.0);
|
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;
|
QString url;
|
||||||
|
|
||||||
url = QString("%1%2service=WMS&version=%3&request=GetMap&bbox=$bbox"
|
url = QString("%1%2service=WMS&version=%3&request=GetMap&bbox=$bbox"
|
||||||
"&width=%4&height=%5&layers=%6&styles=%7&format=%8&transparent=true")
|
"&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(),
|
QString::number(_tileSize), QString::number(_tileSize), _setup.layer(),
|
||||||
_setup.style(), _setup.format());
|
_setup.style(), _setup.format());
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ bool WMSMap::loadWMS()
|
|||||||
_projection = wms.projection();
|
_projection = wms.projection();
|
||||||
_bbox = wms.boundingBox();
|
_bbox = wms.boundingBox();
|
||||||
_bounds = RectD(_bbox, _projection);
|
_bounds = RectD(_bbox, _projection);
|
||||||
_tileLoader->setUrl(tileUrl(wms.version()));
|
_tileLoader->setUrl(tileUrl(wms.tileUrl(), wms.version()));
|
||||||
|
|
||||||
if (wms.version() >= "1.3.0") {
|
if (wms.version() >= "1.3.0") {
|
||||||
if (_setup.coordinateSystem().axisOrder() == CoordinateSystem::Unknown)
|
if (_setup.coordinateSystem().axisOrder() == CoordinateSystem::Unknown)
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString tileUrl(const QString &version) const;
|
QString tileUrl(const QString &baseUrl, const QString &version) const;
|
||||||
double sd2res(double scaleDenominator) const;
|
double sd2res(double scaleDenominator) const;
|
||||||
QString tilesDir() const;
|
QString tilesDir() const;
|
||||||
void computeZooms(const RangeF &scaleDenominator);
|
void computeZooms(const RangeF &scaleDenominator);
|
||||||
|
Loading…
Reference in New Issue
Block a user