2018-02-20 23:37:19 +01:00
|
|
|
#include <QXmlStreamReader>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QEventLoop>
|
|
|
|
#include <QTextStream>
|
2018-02-21 00:13:11 +01:00
|
|
|
#include <QStringList>
|
2018-02-24 10:34:27 +01:00
|
|
|
#include <QtAlgorithms>
|
2018-02-27 21:50:29 +01:00
|
|
|
#include <QXmlStreamReader>
|
2018-02-20 23:37:19 +01:00
|
|
|
#include "downloader.h"
|
|
|
|
#include "pcs.h"
|
2018-03-30 10:25:05 +02:00
|
|
|
#include "crs.h"
|
2018-02-20 23:37:19 +01:00
|
|
|
#include "wmts.h"
|
|
|
|
|
|
|
|
|
2018-04-05 20:38:23 +02:00
|
|
|
WMTS::TileMatrix WMTS::tileMatrix(QXmlStreamReader &reader)
|
2018-02-20 23:37:19 +01:00
|
|
|
{
|
2018-02-24 16:44:30 +01:00
|
|
|
TileMatrix matrix;
|
2018-02-20 23:37:19 +01:00
|
|
|
|
|
|
|
while (reader.readNextStartElement()) {
|
2018-02-24 01:59:03 +01:00
|
|
|
if (reader.name() == "Identifier")
|
2018-02-24 16:44:30 +01:00
|
|
|
matrix.id = reader.readElementText();
|
2018-02-24 01:59:03 +01:00
|
|
|
else if (reader.name() == "ScaleDenominator")
|
2018-02-24 16:44:30 +01:00
|
|
|
matrix.scaleDenominator = reader.readElementText().toDouble();
|
2018-02-20 23:37:19 +01:00
|
|
|
else if (reader.name() == "TopLeftCorner") {
|
|
|
|
QString str = reader.readElementText();
|
2018-02-25 08:58:40 +01:00
|
|
|
QTextStream ts(&str);
|
2018-04-05 20:38:23 +02:00
|
|
|
ts >> matrix.topLeft.rx() >> matrix.topLeft.ry();
|
2018-02-20 23:37:19 +01:00
|
|
|
} else if (reader.name() == "TileWidth")
|
2018-02-24 16:44:30 +01:00
|
|
|
matrix.tile.setWidth(reader.readElementText().toInt());
|
2018-02-20 23:37:19 +01:00
|
|
|
else if (reader.name() == "TileHeight")
|
2018-02-24 16:44:30 +01:00
|
|
|
matrix.tile.setHeight(reader.readElementText().toInt());
|
2018-02-20 23:37:19 +01:00
|
|
|
else if (reader.name() == "MatrixWidth")
|
2018-02-24 16:44:30 +01:00
|
|
|
matrix.matrix.setWidth(reader.readElementText().toInt());
|
2018-02-20 23:37:19 +01:00
|
|
|
else if (reader.name() == "MatrixHeight")
|
2018-02-24 16:44:30 +01:00
|
|
|
matrix.matrix.setHeight(reader.readElementText().toInt());
|
2018-02-20 23:37:19 +01:00
|
|
|
else
|
|
|
|
reader.skipCurrentElement();
|
|
|
|
}
|
|
|
|
|
2018-02-24 16:44:30 +01:00
|
|
|
if (!matrix.isValid())
|
|
|
|
reader.raiseError("Invalid TileMatrix definition");
|
|
|
|
|
|
|
|
return matrix;
|
2018-02-20 23:37:19 +01:00
|
|
|
}
|
|
|
|
|
2018-02-27 21:50:29 +01:00
|
|
|
void WMTS::tileMatrixSet(QXmlStreamReader &reader, CTX &ctx)
|
2018-02-20 23:37:19 +01:00
|
|
|
{
|
2018-02-24 16:44:30 +01:00
|
|
|
QString id, crs;
|
|
|
|
QSet<TileMatrix> matrixes;
|
2018-02-20 23:37:19 +01:00
|
|
|
|
2018-02-27 21:50:29 +01:00
|
|
|
while (reader.readNextStartElement()) {
|
|
|
|
if (reader.name() == "Identifier")
|
|
|
|
id = reader.readElementText();
|
|
|
|
else if (reader.name() == "SupportedCRS")
|
|
|
|
crs = reader.readElementText();
|
|
|
|
else if (reader.name() == "TileMatrix")
|
2018-04-05 20:38:23 +02:00
|
|
|
matrixes.insert(tileMatrix(reader));
|
2018-02-20 23:37:19 +01:00
|
|
|
else
|
2018-02-27 21:50:29 +01:00
|
|
|
reader.skipCurrentElement();
|
2018-02-20 23:37:19 +01:00
|
|
|
}
|
2018-02-24 16:44:30 +01:00
|
|
|
|
2018-03-30 10:25:05 +02:00
|
|
|
if (id == ctx.setup.set()) {
|
2018-02-26 22:35:58 +01:00
|
|
|
ctx.crs = crs;
|
2018-02-26 19:05:53 +01:00
|
|
|
_matrixes = matrixes;
|
2018-02-24 16:44:30 +01:00
|
|
|
}
|
2018-02-20 23:37:19 +01:00
|
|
|
}
|
|
|
|
|
2018-02-24 16:44:30 +01:00
|
|
|
WMTS::MatrixLimits WMTS::tileMatrixLimits(QXmlStreamReader &reader)
|
2018-02-24 01:59:03 +01:00
|
|
|
{
|
2018-02-24 16:44:30 +01:00
|
|
|
MatrixLimits limits;
|
2018-02-24 01:59:03 +01:00
|
|
|
|
|
|
|
while (reader.readNextStartElement()) {
|
|
|
|
if (reader.name() == "TileMatrix")
|
2018-02-24 16:44:30 +01:00
|
|
|
limits.id = reader.readElementText();
|
2018-02-24 01:59:03 +01:00
|
|
|
else if (reader.name() == "MinTileRow")
|
2018-02-24 16:44:30 +01:00
|
|
|
limits.rect.setTop(reader.readElementText().toInt());
|
2018-02-24 01:59:03 +01:00
|
|
|
else if (reader.name() == "MaxTileRow")
|
2018-02-24 16:44:30 +01:00
|
|
|
limits.rect.setBottom(reader.readElementText().toInt());
|
2018-02-24 01:59:03 +01:00
|
|
|
else if (reader.name() == "MinTileCol")
|
2018-02-24 16:44:30 +01:00
|
|
|
limits.rect.setLeft(reader.readElementText().toInt());
|
2018-02-24 01:59:03 +01:00
|
|
|
else if (reader.name() == "MaxTileCol")
|
2018-02-24 16:44:30 +01:00
|
|
|
limits.rect.setRight(reader.readElementText().toInt());
|
2018-02-24 01:59:03 +01:00
|
|
|
else
|
|
|
|
reader.skipCurrentElement();
|
|
|
|
}
|
|
|
|
|
2018-02-24 16:44:30 +01:00
|
|
|
if (!limits.isValid())
|
|
|
|
reader.raiseError("Invalid TileMatrixLimits definition");
|
|
|
|
|
|
|
|
return limits;
|
2018-02-24 01:59:03 +01:00
|
|
|
}
|
|
|
|
|
2018-02-24 16:44:30 +01:00
|
|
|
QSet<WMTS::MatrixLimits> WMTS::tileMatrixSetLimits(QXmlStreamReader &reader)
|
2018-02-24 01:59:03 +01:00
|
|
|
{
|
2018-02-24 16:44:30 +01:00
|
|
|
QSet<MatrixLimits> limits;
|
|
|
|
|
2018-02-24 01:59:03 +01:00
|
|
|
while (reader.readNextStartElement()) {
|
|
|
|
if (reader.name() == "TileMatrixLimits")
|
2018-02-24 16:44:30 +01:00
|
|
|
limits.insert(tileMatrixLimits(reader));
|
2018-02-24 01:59:03 +01:00
|
|
|
else
|
|
|
|
reader.skipCurrentElement();
|
|
|
|
}
|
2018-02-24 16:44:30 +01:00
|
|
|
|
|
|
|
return limits;
|
2018-02-24 01:59:03 +01:00
|
|
|
}
|
|
|
|
|
2018-02-27 21:50:29 +01:00
|
|
|
void WMTS::tileMatrixSetLink(QXmlStreamReader &reader, CTX &ctx)
|
2018-02-24 01:59:03 +01:00
|
|
|
{
|
|
|
|
QString id;
|
2018-02-24 16:44:30 +01:00
|
|
|
QSet<MatrixLimits> limits;
|
2018-02-24 01:59:03 +01:00
|
|
|
|
2018-02-27 21:50:29 +01:00
|
|
|
while (reader.readNextStartElement()) {
|
|
|
|
if (reader.name() == "TileMatrixSet")
|
|
|
|
id = reader.readElementText();
|
|
|
|
else if (reader.name() == "TileMatrixSetLimits")
|
|
|
|
limits = tileMatrixSetLimits(reader);
|
2018-02-24 01:59:03 +01:00
|
|
|
else
|
2018-02-27 21:50:29 +01:00
|
|
|
reader.skipCurrentElement();
|
2018-02-24 01:59:03 +01:00
|
|
|
}
|
2018-02-24 16:44:30 +01:00
|
|
|
|
2018-03-30 10:25:05 +02:00
|
|
|
if (id == ctx.setup.set()) {
|
2018-04-03 22:35:13 +02:00
|
|
|
ctx.hasSet = true;
|
2018-02-26 19:05:53 +01:00
|
|
|
_limits = limits;
|
2018-02-26 22:35:58 +01:00
|
|
|
}
|
2018-02-24 16:44:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
RectC WMTS::wgs84BoundingBox(QXmlStreamReader &reader)
|
|
|
|
{
|
|
|
|
Coordinates topLeft, bottomRight;
|
|
|
|
|
|
|
|
while (reader.readNextStartElement()) {
|
|
|
|
if (reader.name() == "LowerCorner") {
|
|
|
|
QString str = reader.readElementText();
|
|
|
|
QTextStream(&str) >> topLeft.rlon() >> bottomRight.rlat();
|
|
|
|
} else if (reader.name() == "UpperCorner") {
|
|
|
|
QString str = reader.readElementText();
|
|
|
|
QTextStream(&str) >> bottomRight.rlon() >> topLeft.rlat();
|
|
|
|
} else
|
|
|
|
reader.skipCurrentElement();
|
|
|
|
}
|
|
|
|
|
|
|
|
return RectC(topLeft, bottomRight);
|
2018-02-24 01:59:03 +01:00
|
|
|
}
|
|
|
|
|
2018-02-26 22:35:58 +01:00
|
|
|
QString WMTS::style(QXmlStreamReader &reader)
|
2018-02-24 01:59:03 +01:00
|
|
|
{
|
|
|
|
QString id;
|
|
|
|
|
|
|
|
while (reader.readNextStartElement()) {
|
|
|
|
if (reader.name() == "Identifier")
|
|
|
|
id = reader.readElementText();
|
2018-02-26 22:35:58 +01:00
|
|
|
else
|
|
|
|
reader.skipCurrentElement();
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2018-02-27 21:50:29 +01:00
|
|
|
void WMTS::layer(QXmlStreamReader &reader, CTX &ctx)
|
2018-02-26 22:35:58 +01:00
|
|
|
{
|
|
|
|
QString id, tpl;
|
|
|
|
RectC bounds;
|
|
|
|
QStringList formats, styles;
|
|
|
|
|
2018-02-27 21:50:29 +01:00
|
|
|
while (reader.readNextStartElement()) {
|
|
|
|
if (reader.name() == "Identifier")
|
|
|
|
id = reader.readElementText();
|
|
|
|
else if (reader.name() == "TileMatrixSetLink")
|
|
|
|
tileMatrixSetLink(reader, ctx);
|
|
|
|
else if (reader.name() == "WGS84BoundingBox")
|
|
|
|
bounds = wgs84BoundingBox(reader);
|
|
|
|
else if (reader.name() == "ResourceURL") {
|
|
|
|
const QXmlStreamAttributes &attr = reader.attributes();
|
2018-02-25 02:31:01 +01:00
|
|
|
if (attr.value("resourceType") == "tile")
|
|
|
|
tpl = attr.value("template").toString();
|
2018-02-27 21:50:29 +01:00
|
|
|
reader.skipCurrentElement();
|
|
|
|
} else if (reader.name() == "Style")
|
|
|
|
styles.append(style(reader));
|
|
|
|
else if (reader.name() == "Format")
|
|
|
|
formats.append(reader.readElementText());
|
2018-02-26 22:35:58 +01:00
|
|
|
else
|
2018-02-27 21:50:29 +01:00
|
|
|
reader.skipCurrentElement();
|
2018-02-24 01:59:03 +01:00
|
|
|
}
|
2018-02-24 16:44:30 +01:00
|
|
|
|
2018-03-30 10:25:05 +02:00
|
|
|
if (id == ctx.setup.layer()) {
|
2018-04-03 22:35:13 +02:00
|
|
|
ctx.hasLayer = true;
|
2018-02-24 16:44:30 +01:00
|
|
|
_bounds = bounds;
|
2018-03-30 10:25:05 +02:00
|
|
|
if (ctx.setup.rest())
|
2018-02-26 22:35:58 +01:00
|
|
|
_tileUrl = tpl;
|
2018-04-03 22:35:13 +02:00
|
|
|
if (styles.contains(ctx.setup.style()) || ctx.setup.style().isEmpty())
|
|
|
|
ctx.hasStyle = true;
|
2018-03-30 10:25:05 +02:00
|
|
|
if (formats.contains(ctx.setup.format()))
|
2018-04-03 22:35:13 +02:00
|
|
|
ctx.hasFormat = true;
|
2018-02-25 02:31:01 +01:00
|
|
|
}
|
2018-02-24 01:59:03 +01:00
|
|
|
}
|
|
|
|
|
2018-02-27 21:50:29 +01:00
|
|
|
void WMTS::contents(QXmlStreamReader &reader, CTX &ctx)
|
2018-02-20 23:37:19 +01:00
|
|
|
{
|
2018-02-27 21:50:29 +01:00
|
|
|
while (reader.readNextStartElement()) {
|
|
|
|
if (reader.name() == "TileMatrixSet")
|
|
|
|
tileMatrixSet(reader, ctx);
|
|
|
|
else if (reader.name() == "Layer")
|
|
|
|
layer(reader, ctx);
|
2018-02-20 23:37:19 +01:00
|
|
|
else
|
2018-02-27 21:50:29 +01:00
|
|
|
reader.skipCurrentElement();
|
2018-02-20 23:37:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-27 21:50:29 +01:00
|
|
|
void WMTS::capabilities(QXmlStreamReader &reader, CTX &ctx)
|
2018-02-20 23:37:19 +01:00
|
|
|
{
|
2018-02-27 21:50:29 +01:00
|
|
|
while (reader.readNextStartElement()) {
|
|
|
|
if (reader.name() == "Contents")
|
|
|
|
contents(reader, ctx);
|
2018-02-20 23:37:19 +01:00
|
|
|
else
|
2018-02-27 21:50:29 +01:00
|
|
|
reader.skipCurrentElement();
|
2018-02-20 23:37:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-26 22:35:58 +01:00
|
|
|
bool WMTS::parseCapabilities(const QString &path, const Setup &setup)
|
2018-02-20 23:37:19 +01:00
|
|
|
{
|
|
|
|
QFile file(path);
|
2018-02-26 22:35:58 +01:00
|
|
|
CTX ctx(setup);
|
2018-02-27 21:50:29 +01:00
|
|
|
QXmlStreamReader reader;
|
2018-02-20 23:37:19 +01:00
|
|
|
|
|
|
|
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
|
|
|
_errorString = file.errorString();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-27 21:50:29 +01:00
|
|
|
reader.setDevice(&file);
|
|
|
|
if (reader.readNextStartElement()) {
|
|
|
|
if (reader.name() == "Capabilities")
|
|
|
|
capabilities(reader, ctx);
|
2018-02-20 23:37:19 +01:00
|
|
|
else
|
2018-02-27 21:50:29 +01:00
|
|
|
reader.raiseError("Not a Capabilities XML file");
|
2018-02-26 22:35:58 +01:00
|
|
|
}
|
2018-02-27 21:50:29 +01:00
|
|
|
if (reader.error()) {
|
|
|
|
_errorString = QString("%1:%2: %3").arg(path).arg(reader.lineNumber())
|
|
|
|
.arg(reader.errorString());
|
2018-02-26 22:35:58 +01:00
|
|
|
return false;
|
2018-02-20 23:37:19 +01:00
|
|
|
}
|
|
|
|
|
2018-04-03 22:35:13 +02:00
|
|
|
if (!ctx.hasLayer) {
|
2018-03-30 10:25:05 +02:00
|
|
|
_errorString = ctx.setup.layer() + ": layer not provided";
|
2018-02-26 22:35:58 +01:00
|
|
|
return false;
|
|
|
|
}
|
2018-04-03 22:35:13 +02:00
|
|
|
if (!ctx.hasStyle) {
|
2018-03-30 10:25:05 +02:00
|
|
|
_errorString = ctx.setup.style() + ": style not provided";
|
2018-02-26 22:35:58 +01:00
|
|
|
return false;
|
|
|
|
}
|
2018-04-03 22:35:13 +02:00
|
|
|
if (!ctx.setup.rest() && !ctx.hasFormat) {
|
2018-03-30 10:25:05 +02:00
|
|
|
_errorString = ctx.setup.format() + ": format not provided";
|
2018-02-26 22:35:58 +01:00
|
|
|
return false;
|
|
|
|
}
|
2018-04-03 22:35:13 +02:00
|
|
|
if (!ctx.hasSet) {
|
2018-03-30 10:25:05 +02:00
|
|
|
_errorString = ctx.setup.set() + ": set not provided";
|
2018-02-26 22:35:58 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (ctx.crs.isNull()) {
|
|
|
|
_errorString = "Missing CRS definition";
|
|
|
|
return false;
|
|
|
|
}
|
2018-03-30 10:25:05 +02:00
|
|
|
_projection = CRS::projection(ctx.crs);
|
2018-05-16 18:52:48 +02:00
|
|
|
if (!_projection.isValid()) {
|
2018-02-26 22:35:58 +01:00
|
|
|
_errorString = ctx.crs + ": unknown CRS";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (_matrixes.isEmpty()) {
|
|
|
|
_errorString = "No usable tile matrix found";
|
|
|
|
return false;
|
|
|
|
}
|
2018-03-30 10:25:05 +02:00
|
|
|
if (ctx.setup.rest() && _tileUrl.isNull()) {
|
2018-02-26 22:35:58 +01:00
|
|
|
_errorString = "Missing tile URL template";
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-20 23:37:19 +01:00
|
|
|
|
2018-02-26 22:35:58 +01:00
|
|
|
return true;
|
2018-02-20 23:37:19 +01:00
|
|
|
}
|
|
|
|
|
2018-04-01 20:01:25 +02:00
|
|
|
bool WMTS::getCapabilities(const QString &url, const QString &file,
|
|
|
|
const Authorization &authorization)
|
2018-02-20 23:37:19 +01:00
|
|
|
{
|
2018-04-27 19:31:27 +02:00
|
|
|
Downloader d;
|
2018-02-20 23:37:19 +01:00
|
|
|
QList<Download> dl;
|
|
|
|
|
2018-02-25 02:31:01 +01:00
|
|
|
dl.append(Download(url, file));
|
2018-02-20 23:37:19 +01:00
|
|
|
|
|
|
|
QEventLoop wait;
|
2018-04-27 19:31:27 +02:00
|
|
|
QObject::connect(&d, SIGNAL(finished()), &wait, SLOT(quit()));
|
|
|
|
if (d.get(dl, authorization))
|
2018-02-20 23:37:19 +01:00
|
|
|
wait.exec();
|
|
|
|
|
2018-04-07 23:04:26 +02:00
|
|
|
if (QFileInfo(file).exists())
|
2018-02-20 23:37:19 +01:00
|
|
|
return true;
|
|
|
|
else {
|
|
|
|
_errorString = "Error downloading capabilities XML file";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-30 10:25:05 +02:00
|
|
|
WMTS::WMTS(const QString &file, const WMTS::Setup &setup) : _valid(false)
|
2018-02-20 23:37:19 +01:00
|
|
|
{
|
2018-03-30 10:25:05 +02:00
|
|
|
QString capaUrl = setup.rest() ? setup.url() :
|
2018-02-25 02:31:01 +01:00
|
|
|
QString("%1?service=WMTS&Version=1.0.0&request=GetCapabilities")
|
2018-03-30 10:25:05 +02:00
|
|
|
.arg(setup.url());
|
2018-02-24 11:40:54 +01:00
|
|
|
|
2018-04-07 23:04:26 +02:00
|
|
|
if (!QFileInfo(file).exists())
|
2018-04-01 20:01:25 +02:00
|
|
|
if (!getCapabilities(capaUrl, file, setup.authorization()))
|
2018-03-30 10:25:05 +02:00
|
|
|
return;
|
2018-02-26 22:35:58 +01:00
|
|
|
if (!parseCapabilities(file, setup))
|
2018-03-30 10:25:05 +02:00
|
|
|
return;
|
2018-02-20 23:37:19 +01:00
|
|
|
|
2018-04-03 22:35:13 +02:00
|
|
|
QString style = setup.style().isEmpty() ? "default" : setup.style();
|
2018-03-30 10:25:05 +02:00
|
|
|
if (!setup.rest()) {
|
2018-02-25 02:31:01 +01:00
|
|
|
_tileUrl = QString("%1?service=WMTS&Version=1.0.0&request=GetTile"
|
|
|
|
"&Format=%2&Layer=%3&Style=%4&TileMatrixSet=%5&TileMatrix=$z"
|
2018-04-03 22:35:13 +02:00
|
|
|
"&TileRow=$y&TileCol=$x").arg(setup.url(), setup.format(),
|
|
|
|
setup.layer(), style, setup.set());
|
2018-03-30 10:25:05 +02:00
|
|
|
for (int i = 0; i < setup.dimensions().size(); i++) {
|
|
|
|
const QPair<QString, QString> &dim = setup.dimensions().at(i);
|
2018-04-03 22:35:13 +02:00
|
|
|
_tileUrl.append(QString("&%1=%2").arg(dim.first, dim.second));
|
2018-03-11 10:31:41 +01:00
|
|
|
}
|
|
|
|
} else {
|
2018-04-03 22:35:13 +02:00
|
|
|
_tileUrl.replace("{Style}", style, Qt::CaseInsensitive);
|
2018-03-30 10:25:05 +02:00
|
|
|
_tileUrl.replace("{TileMatrixSet}", setup.set(), Qt::CaseInsensitive);
|
2018-03-11 19:23:40 +01:00
|
|
|
_tileUrl.replace("{TileMatrix}", "$z", Qt::CaseInsensitive);
|
|
|
|
_tileUrl.replace("{TileRow}", "$y", Qt::CaseInsensitive);
|
|
|
|
_tileUrl.replace("{TileCol}", "$x", Qt::CaseInsensitive);
|
2018-03-30 10:25:05 +02:00
|
|
|
for (int i = 0; i < setup.dimensions().size(); i++) {
|
|
|
|
const QPair<QString, QString> &dim = setup.dimensions().at(i);
|
2018-03-11 19:23:40 +01:00
|
|
|
_tileUrl.replace(QString("{%1}").arg(dim.first), dim.second,
|
|
|
|
Qt::CaseInsensitive);
|
2018-03-11 10:31:41 +01:00
|
|
|
}
|
2018-02-25 02:31:01 +01:00
|
|
|
}
|
|
|
|
|
2018-03-30 10:25:05 +02:00
|
|
|
_valid = true;
|
2018-02-20 23:37:19 +01:00
|
|
|
}
|
2018-02-24 01:59:03 +01:00
|
|
|
|
2018-02-24 10:34:27 +01:00
|
|
|
QList<WMTS::Zoom> WMTS::zooms() const
|
|
|
|
{
|
2018-02-24 16:44:30 +01:00
|
|
|
QList<Zoom> zooms;
|
|
|
|
QSet<TileMatrix>::const_iterator mi;
|
|
|
|
QSet<MatrixLimits>::const_iterator li;
|
|
|
|
|
|
|
|
for (mi = _matrixes.constBegin(); mi != _matrixes.constEnd(); ++mi) {
|
|
|
|
if ((li = _limits.find(MatrixLimits(mi->id))) == _limits.constEnd())
|
|
|
|
zooms.append(Zoom(mi->id, mi->scaleDenominator, mi->topLeft,
|
|
|
|
mi->tile, mi->matrix, QRect()));
|
|
|
|
else
|
2018-04-03 22:35:13 +02:00
|
|
|
zooms.append(Zoom(mi->id, mi->scaleDenominator, mi->topLeft,
|
|
|
|
mi->tile, mi->matrix, li->rect));
|
2018-02-24 16:44:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
qSort(zooms);
|
|
|
|
|
|
|
|
return zooms;
|
2018-02-24 10:34:27 +01:00
|
|
|
}
|
|
|
|
|
2018-02-24 01:59:03 +01:00
|
|
|
#ifndef QT_NO_DEBUG
|
2018-02-25 02:31:01 +01:00
|
|
|
QDebug operator<<(QDebug dbg, const WMTS::Setup &setup)
|
|
|
|
{
|
2018-03-30 10:25:05 +02:00
|
|
|
dbg.nospace() << "Setup(" << setup.url() << ", " << setup.layer() << ", "
|
|
|
|
<< setup.set() << ", " << setup.style() << ", " << setup.format() << ", "
|
|
|
|
<< setup.rest() << ")";
|
2018-02-25 02:31:01 +01:00
|
|
|
return dbg.space();
|
|
|
|
}
|
|
|
|
|
2018-02-24 01:59:03 +01:00
|
|
|
QDebug operator<<(QDebug dbg, const WMTS::Zoom &zoom)
|
|
|
|
{
|
2018-03-30 10:25:05 +02:00
|
|
|
dbg.nospace() << "Zoom(" << zoom.id() << ", " << zoom.scaleDenominator()
|
|
|
|
<< ", " << zoom.topLeft() << ", " << zoom.tile() << ", " << zoom.matrix()
|
|
|
|
<< ", " << zoom.limits() << ")";
|
2018-02-24 01:59:03 +01:00
|
|
|
return dbg.space();
|
|
|
|
}
|
|
|
|
#endif // QT_NO_DEBUG
|