1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 19:55:53 +01:00

Improved error reporting

This commit is contained in:
Martin Tůma 2018-02-26 19:05:53 +01:00
parent 962310df7d
commit d1b0e2ef73
2 changed files with 15 additions and 15 deletions

View File

@ -12,9 +12,9 @@
Downloader *WMTS::_downloader = 0; Downloader *WMTS::_downloader = 0;
bool WMTS::createProjection(const QString &crs) bool WMTS::createProjection()
{ {
QStringList list(crs.split(':')); QStringList list(_crs.split(':'));
QString authority, code; QString authority, code;
bool res; bool res;
int epsg; int epsg;
@ -109,12 +109,8 @@ void WMTS::tileMatrixSet(QXmlStreamReader &reader, const QString &set, bool yx)
} }
if (id == set) { if (id == set) {
if (!createProjection(crs)) { _crs = crs;
reader.raiseError("Invalid/unknown CRS"); _matrixes = matrixes;
return;
}
_matrixes.unite(matrixes);
} }
} }
@ -172,7 +168,7 @@ void WMTS::tileMatrixSetLink(QXmlStreamReader &reader, const QString &set)
} }
if (id == set) if (id == set)
_limits.unite(limits); _limits = limits;
} }
RectC WMTS::wgs84BoundingBox(QXmlStreamReader &reader) RectC WMTS::wgs84BoundingBox(QXmlStreamReader &reader)
@ -316,12 +312,16 @@ bool WMTS::load(const QString &file, const WMTS::Setup &setup)
_tileUrl.replace("{TileCol}", "$x"); _tileUrl.replace("{TileCol}", "$x");
} }
if (_matrixes.isEmpty()) { if (_crs.isNull()) {
_errorString = "No usable tile matrix found"; _errorString = "Missing CRS definition";
return false; return false;
} }
if (_projection.isNull()) { if (!createProjection()) {
_errorString = "Missing CRS definition"; _errorString = _crs + ": unknown CRS";
return false;
}
if (_matrixes.isEmpty()) {
_errorString = "No usable tile matrix found";
return false; return false;
} }
if (_tileUrl.isNull()) { if (_tileUrl.isNull()) {

View File

@ -87,8 +87,7 @@ private:
{return !id.isEmpty() && rect.isValid();} {return !id.isEmpty() && rect.isValid();}
}; };
bool createProjection(const QString &crs); bool createProjection();
RectC wgs84BoundingBox(QXmlStreamReader &reader); RectC wgs84BoundingBox(QXmlStreamReader &reader);
MatrixLimits tileMatrixLimits(QXmlStreamReader &reader); MatrixLimits tileMatrixLimits(QXmlStreamReader &reader);
TileMatrix tileMatrix(QXmlStreamReader &reader, bool yx); TileMatrix tileMatrix(QXmlStreamReader &reader, bool yx);
@ -108,6 +107,7 @@ private:
QSet<TileMatrix> _matrixes; QSet<TileMatrix> _matrixes;
QSet<MatrixLimits> _limits; QSet<MatrixLimits> _limits;
RectC _bounds; RectC _bounds;
QString _crs;
Projection _projection; Projection _projection;
QString _tileUrl; QString _tileUrl;