mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Made the axis order an attribute of the set rather than a separate element
This commit is contained in:
parent
5e5ff6d96f
commit
fbab4b0097
@ -126,10 +126,10 @@ Map *MapSource::map(QXmlStreamReader &reader)
|
||||
{
|
||||
QString name, url, layer, style, set;
|
||||
QString format("image/png");
|
||||
bool wmts, rest = false, invertAxis = false;
|
||||
bool wmts, rest = false, yx = false;
|
||||
Range z(ZOOM_MIN, ZOOM_MAX);
|
||||
RectC b(Coordinates(BOUNDS_LEFT, BOUNDS_TOP),
|
||||
Coordinates(BOUNDS_RIGHT, BOUNDS_BOTTOM));
|
||||
RectC b(Coordinates(BOUNDS_LEFT, BOUNDS_TOP), Coordinates(BOUNDS_RIGHT,
|
||||
BOUNDS_BOTTOM));
|
||||
|
||||
wmts = (reader.attributes().value("type") == "WMTS") ? true : false;
|
||||
|
||||
@ -151,11 +151,10 @@ Map *MapSource::map(QXmlStreamReader &reader)
|
||||
layer = reader.readElementText();
|
||||
else if (reader.name() == "style")
|
||||
style = reader.readElementText();
|
||||
else if (reader.name() == "set")
|
||||
else if (reader.name() == "set") {
|
||||
yx = (reader.attributes().value("axis") == "yx") ? true : false;
|
||||
set = reader.readElementText();
|
||||
else if (reader.name() == "axis")
|
||||
invertAxis = (reader.readElementText() == "yx") ? true : false;
|
||||
else
|
||||
} else
|
||||
reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
@ -163,7 +162,7 @@ Map *MapSource::map(QXmlStreamReader &reader)
|
||||
return 0;
|
||||
else if (wmts)
|
||||
return new WMTSMap(name, WMTS::Setup(url, layer, set, style, format,
|
||||
rest), invertAxis);
|
||||
rest, yx));
|
||||
else
|
||||
return new OnlineMap(name, url, z, b);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ bool WMTS::createProjection(const QString &crs)
|
||||
return false;
|
||||
}
|
||||
|
||||
WMTS::TileMatrix WMTS::tileMatrix(QXmlStreamReader &reader)
|
||||
WMTS::TileMatrix WMTS::tileMatrix(QXmlStreamReader &reader, bool yx)
|
||||
{
|
||||
TileMatrix matrix;
|
||||
|
||||
@ -69,7 +69,11 @@ WMTS::TileMatrix WMTS::tileMatrix(QXmlStreamReader &reader)
|
||||
matrix.scaleDenominator = reader.readElementText().toDouble();
|
||||
else if (reader.name() == "TopLeftCorner") {
|
||||
QString str = reader.readElementText();
|
||||
QTextStream(&str) >> matrix.topLeft.rx() >> matrix.topLeft.ry();
|
||||
QTextStream ts(&str);
|
||||
if (yx)
|
||||
ts >> matrix.topLeft.ry() >> matrix.topLeft.rx();
|
||||
else
|
||||
ts >> matrix.topLeft.rx() >> matrix.topLeft.ry();
|
||||
} else if (reader.name() == "TileWidth")
|
||||
matrix.tile.setWidth(reader.readElementText().toInt());
|
||||
else if (reader.name() == "TileHeight")
|
||||
@ -88,7 +92,7 @@ WMTS::TileMatrix WMTS::tileMatrix(QXmlStreamReader &reader)
|
||||
return matrix;
|
||||
}
|
||||
|
||||
void WMTS::tileMatrixSet(QXmlStreamReader &reader, const QString &set)
|
||||
void WMTS::tileMatrixSet(QXmlStreamReader &reader, const QString &set, bool yx)
|
||||
{
|
||||
QString id, crs;
|
||||
QSet<TileMatrix> matrixes;
|
||||
@ -99,7 +103,7 @@ void WMTS::tileMatrixSet(QXmlStreamReader &reader, const QString &set)
|
||||
else if (reader.name() == "SupportedCRS")
|
||||
crs = reader.readElementText();
|
||||
else if (reader.name() == "TileMatrix")
|
||||
matrixes.insert(tileMatrix(reader));
|
||||
matrixes.insert(tileMatrix(reader, yx));
|
||||
else
|
||||
reader.skipCurrentElement();
|
||||
}
|
||||
@ -219,11 +223,11 @@ void WMTS::layer(QXmlStreamReader &reader, const QString &layer,
|
||||
}
|
||||
|
||||
void WMTS::contents(QXmlStreamReader &reader, const QString &layer,
|
||||
const QString &set)
|
||||
const QString &set, bool yx)
|
||||
{
|
||||
while (reader.readNextStartElement()) {
|
||||
if (reader.name() == "TileMatrixSet")
|
||||
tileMatrixSet(reader, set);
|
||||
tileMatrixSet(reader, set, yx);
|
||||
else if (reader.name() == "Layer")
|
||||
WMTS::layer(reader, layer, set);
|
||||
else
|
||||
@ -232,18 +236,18 @@ void WMTS::contents(QXmlStreamReader &reader, const QString &layer,
|
||||
}
|
||||
|
||||
void WMTS::capabilities(QXmlStreamReader &reader, const QString &layer,
|
||||
const QString &set)
|
||||
const QString &set, bool yx)
|
||||
{
|
||||
while (reader.readNextStartElement()) {
|
||||
if (reader.name() == "Contents")
|
||||
contents(reader, layer, set);
|
||||
contents(reader, layer, set, yx);
|
||||
else
|
||||
reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
bool WMTS::parseCapabilities(const QString &path, const QString &layer,
|
||||
const QString &set)
|
||||
const QString &set, bool yx)
|
||||
{
|
||||
QFile file(path);
|
||||
QXmlStreamReader reader;
|
||||
@ -257,7 +261,7 @@ bool WMTS::parseCapabilities(const QString &path, const QString &layer,
|
||||
|
||||
if (reader.readNextStartElement()) {
|
||||
if (reader.name() == "Capabilities")
|
||||
capabilities(reader, layer, set);
|
||||
capabilities(reader, layer, set, yx);
|
||||
else
|
||||
reader.raiseError("Not a Capabilities XML file");
|
||||
}
|
||||
@ -296,7 +300,7 @@ bool WMTS::load(const QString &file, const WMTS::Setup &setup)
|
||||
if (!QFileInfo(file).exists())
|
||||
if (!getCapabilities(capaUrl, file))
|
||||
return false;
|
||||
if (!parseCapabilities(file, setup.layer, setup.set))
|
||||
if (!parseCapabilities(file, setup.layer, setup.set, setup.yx))
|
||||
return false;
|
||||
|
||||
if (!setup.rest)
|
||||
|
@ -22,11 +22,12 @@ public:
|
||||
QString style;
|
||||
QString format;
|
||||
bool rest;
|
||||
bool yx;
|
||||
|
||||
Setup(const QString &url, const QString &layer, const QString &set,
|
||||
const QString &style, const QString &format, bool rest) :
|
||||
const QString &style, const QString &format, bool rest, bool yx) :
|
||||
url(url), layer(layer), set(set), style(style), format(format),
|
||||
rest(rest) {}
|
||||
rest(rest), yx(yx) {}
|
||||
};
|
||||
|
||||
struct Zoom {
|
||||
@ -90,18 +91,18 @@ private:
|
||||
|
||||
RectC wgs84BoundingBox(QXmlStreamReader &reader);
|
||||
MatrixLimits tileMatrixLimits(QXmlStreamReader &reader);
|
||||
TileMatrix tileMatrix(QXmlStreamReader &reader);
|
||||
TileMatrix tileMatrix(QXmlStreamReader &reader, bool yx);
|
||||
QSet<MatrixLimits> tileMatrixSetLimits(QXmlStreamReader &reader);
|
||||
void tileMatrixSet(QXmlStreamReader &reader, const QString &set);
|
||||
void tileMatrixSet(QXmlStreamReader &reader, const QString &set, bool yx);
|
||||
void tileMatrixSetLink(QXmlStreamReader &reader, const QString &set);
|
||||
void layer(QXmlStreamReader &reader, const QString &layer,
|
||||
const QString &set);
|
||||
void contents(QXmlStreamReader &reader, const QString &layer,
|
||||
const QString &set);
|
||||
const QString &set, bool yx);
|
||||
void capabilities(QXmlStreamReader &reader, const QString &layer,
|
||||
const QString &set);
|
||||
const QString &set, bool yx);
|
||||
bool parseCapabilities(const QString &path, const QString &layer,
|
||||
const QString &set);
|
||||
const QString &set, bool yx);
|
||||
bool getCapabilities(const QString &url, const QString &file);
|
||||
|
||||
QSet<TileMatrix> _matrixes;
|
||||
|
@ -9,9 +9,8 @@
|
||||
|
||||
#define CAPABILITIES_FILE "capabilities.xml"
|
||||
|
||||
WMTSMap::WMTSMap(const QString &name, const WMTS::Setup &setup, bool invertAxis,
|
||||
QObject *parent) : Map(parent), _name(name), _setup(setup),
|
||||
_invertAxis(invertAxis), _zoom(0), _valid(false)
|
||||
WMTSMap::WMTSMap(const QString &name, const WMTS::Setup &setup, QObject *parent)
|
||||
: Map(parent), _name(name), _setup(setup), _zoom(0), _valid(false)
|
||||
{
|
||||
QString dir(TILES_DIR + "/" + _name);
|
||||
QString file = dir + "/" + CAPABILITIES_FILE;
|
||||
@ -50,13 +49,11 @@ void WMTSMap::updateTransform()
|
||||
if (_projection.isGeographic())
|
||||
pixelSpan /= deg2rad(WGS84_RADIUS);
|
||||
QPointF tileSpan(z.tile.width() * pixelSpan, z.tile.height() * pixelSpan);
|
||||
QPointF topLeft = _invertAxis
|
||||
? QPointF(z.topLeft.y(), z.topLeft.x()) : z.topLeft;
|
||||
QPointF bottomRight(topLeft.x() + tileSpan.x() * z.matrix.width(),
|
||||
topLeft.y() - tileSpan.y() * z.matrix.height());
|
||||
QPointF bottomRight(z.topLeft.x() + tileSpan.x() * z.matrix.width(),
|
||||
z.topLeft.y() - tileSpan.y() * z.matrix.height());
|
||||
|
||||
tl.xy = QPoint(0, 0);
|
||||
tl.pp = topLeft;
|
||||
tl.pp = z.topLeft;
|
||||
br.xy = QPoint(z.tile.width() * z.matrix.width(),
|
||||
z.tile.height() * z.matrix.height());
|
||||
br.pp = bottomRight;
|
||||
|
@ -13,8 +13,7 @@ class WMTSMap : public Map
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WMTSMap(const QString &name, const WMTS::Setup &setup, bool invertAxis,
|
||||
QObject *parent = 0);
|
||||
WMTSMap(const QString &name, const WMTS::Setup &setup, QObject *parent = 0);
|
||||
|
||||
const QString &name() const {return _name;}
|
||||
|
||||
@ -58,7 +57,6 @@ private:
|
||||
TileLoader _tileLoader;
|
||||
RectC _bounds;
|
||||
QList<WMTS::Zoom> _zooms;
|
||||
bool _invertAxis;
|
||||
Projection _projection;
|
||||
QTransform _transform, _inverted;
|
||||
int _zoom;
|
||||
|
Loading…
x
Reference in New Issue
Block a user