mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Added support for WMTS dimensions
This commit is contained in:
parent
49792064d7
commit
8132ff722d
@ -153,6 +153,13 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
|
||||
config.wmts.yx = (reader.attributes().value("axis") == "yx")
|
||||
? true : false;
|
||||
config.wmts.set = reader.readElementText();
|
||||
} else if (reader.name() == "dimension") {
|
||||
QXmlStreamAttributes attr = reader.attributes();
|
||||
if (!attr.hasAttribute("id"))
|
||||
reader.raiseError("Missing dimension id");
|
||||
else
|
||||
config.wmts.dimensions.append(QPair<QString, QString>(
|
||||
attr.value("id").toString(), reader.readElementText()));
|
||||
} else
|
||||
reader.skipCurrentElement();
|
||||
}
|
||||
@ -213,7 +220,7 @@ Map *MapSource::loadFile(const QString &path)
|
||||
if (config.type == WMTS)
|
||||
m = new WMTSMap(config.name, WMTS::Setup(config.url, config.wmts.layer,
|
||||
config.wmts.set, config.wmts.style, config.wmts.format,
|
||||
config.wmts.rest, config.wmts.yx));
|
||||
config.wmts.rest, config.wmts.yx, config.wmts.dimensions));
|
||||
else
|
||||
m = new OnlineMap(config.name, config.url, config.tms.zooms,
|
||||
config.tms.bounds);
|
||||
|
@ -34,6 +34,7 @@ private:
|
||||
QString format;
|
||||
bool rest;
|
||||
bool yx;
|
||||
QList<QPair<QString, QString> > dimensions;
|
||||
|
||||
WMTSConfig() : format("image/png"), rest(false), yx(false) {}
|
||||
};
|
||||
|
@ -357,17 +357,25 @@ bool WMTS::load(const QString &file, const WMTS::Setup &setup)
|
||||
if (!parseCapabilities(file, setup))
|
||||
return false;
|
||||
|
||||
if (!setup.rest)
|
||||
if (!setup.rest) {
|
||||
_tileUrl = QString("%1?service=WMTS&Version=1.0.0&request=GetTile"
|
||||
"&Format=%2&Layer=%3&Style=%4&TileMatrixSet=%5&TileMatrix=$z"
|
||||
"&TileRow=$y&TileCol=$x").arg(setup.url).arg(setup.format)
|
||||
.arg(setup.layer).arg(setup.style).arg(setup.set);
|
||||
else {
|
||||
for (int i = 0; i < setup.dimensions.size(); i++) {
|
||||
const QPair<QString, QString> &dim = setup.dimensions.at(i);
|
||||
_tileUrl.append(QString("&%1=%2").arg(dim.first).arg(dim.second));
|
||||
}
|
||||
} else {
|
||||
_tileUrl.replace("{Style}", setup.style);
|
||||
_tileUrl.replace("{TileMatrixSet}", setup.set);
|
||||
_tileUrl.replace("{TileMatrix}", "$z");
|
||||
_tileUrl.replace("{TileRow}", "$y");
|
||||
_tileUrl.replace("{TileCol}", "$x");
|
||||
for (int i = 0; i < setup.dimensions.size(); i++) {
|
||||
const QPair<QString, QString> &dim = setup.dimensions.at(i);
|
||||
_tileUrl.replace(QString("{%1}").arg(dim.first), dim.second);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -23,11 +23,13 @@ public:
|
||||
QString format;
|
||||
bool rest;
|
||||
bool yx;
|
||||
QList<QPair<QString, QString> > dimensions;
|
||||
|
||||
Setup(const QString &url, const QString &layer, const QString &set,
|
||||
const QString &style, const QString &format, bool rest, bool yx) :
|
||||
const QString &style, const QString &format, bool rest, bool yx,
|
||||
const QList<QPair<QString, QString> > &dimensions) :
|
||||
url(url), layer(layer), set(set), style(style), format(format),
|
||||
rest(rest), yx(yx) {}
|
||||
rest(rest), yx(yx), dimensions(dimensions) {}
|
||||
};
|
||||
|
||||
struct Zoom {
|
||||
|
Loading…
x
Reference in New Issue
Block a user