1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-06 07:32:51 +02:00

Compare commits

...

4 Commits
7.24 ... 7.25

Author SHA1 Message Date
bf0dd1b24a Version++ 2020-03-04 19:49:11 +01:00
9859608115 Added missing support for URLs defined in OnlineResources 2020-03-04 19:47:23 +01:00
9f62b7114e The service parameter is expected in the GetMap request by some servers
(The WMS specification is not 100% clear here)
2020-03-03 09:38:18 +01:00
c85f404d28 Enable specifiing of format parameters 2020-03-03 09:29:16 +01:00
9 changed files with 64 additions and 12 deletions

View File

@ -1,4 +1,4 @@
version: 7.24.{build} version: 7.25.{build}
configuration: configuration:
- Release - Release

View File

@ -3,7 +3,7 @@ unix:!macx {
} else { } else {
TARGET = GPXSee TARGET = GPXSee
} }
VERSION = 7.24 VERSION = 7.25
QT += core \ QT += core \
gui \ gui \

View File

@ -7,7 +7,7 @@
; The name of the installer ; The name of the installer
Name "GPXSee" Name "GPXSee"
; Program version ; Program version
!define VERSION "7.24" !define VERSION "7.25"
; The file to write ; The file to write
OutFile "GPXSee-${VERSION}.exe" OutFile "GPXSee-${VERSION}.exe"

View File

@ -7,7 +7,7 @@
; The name of the installer ; The name of the installer
Name "GPXSee" Name "GPXSee"
; Program version ; Program version
!define VERSION "7.24" !define VERSION "7.25"
; The file to write ; The file to write
OutFile "GPXSee-${VERSION}_x64.exe" OutFile "GPXSee-${VERSION}_x64.exe"

View File

@ -8,6 +8,11 @@
#include "wms.h" #include "wms.h"
static QString bareFormat(const QString &format)
{
return format.left(format.indexOf(';')).trimmed();
}
static inline double hint2denominator(double h) static inline double hint2denominator(double h)
{ {
/* Some WMS 1.1.1 servers use a 72dpi resolution by default. Using the usual /* Some WMS 1.1.1 servers use a 72dpi resolution by default. Using the usual
@ -33,14 +38,48 @@ 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()) {
if (reader.name() == "Format") { if (reader.name() == "Format") {
QString format(reader.readElementText()); QString format(reader.readElementText());
if (format.left(format.indexOf(';')) == 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();
} }
} }
@ -267,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;
} }

View File

@ -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;

View File

@ -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%2version=%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)

View File

@ -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);

View File

@ -12,6 +12,11 @@
#include "wmts.h" #include "wmts.h"
static QString bareFormat(const QString &format)
{
return format.left(format.indexOf(';')).trimmed();
}
static void skipParentElement(QXmlStreamReader &reader) static void skipParentElement(QXmlStreamReader &reader)
{ {
while (reader.readNextStartElement()) while (reader.readNextStartElement())
@ -183,7 +188,7 @@ void WMTS::layer(QXmlStreamReader &reader, CTX &ctx)
ctx.hasStyle = true; ctx.hasStyle = true;
} else if (reader.name() == "Format") { } else if (reader.name() == "Format") {
QString format(reader.readElementText()); QString format(reader.readElementText());
if (format.left(format.indexOf(';')) == ctx.setup.format()) if (bareFormat(format) == bareFormat(ctx.setup.format()))
ctx.hasFormat = true; ctx.hasFormat = true;
} else } else
reader.skipCurrentElement(); reader.skipCurrentElement();