1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-17 16:20:48 +01:00

Projection error handling cleanup

This commit is contained in:
Martin Tůma 2018-05-16 18:52:48 +02:00
parent 025a403c73
commit 81a5c712c6
5 changed files with 11 additions and 9 deletions

View File

@ -12,6 +12,7 @@ public:
CoordinateSystem(AxisOrder axisOrder) : _axisOrder(axisOrder) {} CoordinateSystem(AxisOrder axisOrder) : _axisOrder(axisOrder) {}
CoordinateSystem(int code); CoordinateSystem(int code);
bool isNull() const {return (_axisOrder == Unknown);}
bool isValid() const {return (_axisOrder != Unknown);} bool isValid() const {return (_axisOrder != Unknown);}
AxisOrder axisOrder() const {return _axisOrder;} AxisOrder axisOrder() const {return _axisOrder;}

View File

@ -25,10 +25,11 @@ public:
const CoordinateSystem &coordinateSystem() const {return _cs;} const CoordinateSystem &coordinateSystem() const {return _cs;}
bool isNull() const bool isNull() const
{return (_gcs->isNull() && _units.isNull() && _method.isNull() {return (!_gcs && _units.isNull() && _method.isNull() && _setup.isNull()
&& _setup.isNull());} && _cs.isNull());}
bool isValid() const bool isValid() const
{return (_gcs->isValid() && _units.isValid() && _method.isValid());} {return (_gcs && _gcs->isValid() && _units.isValid()
&& _method.isValid() && _cs.isValid());}
static void loadList(const QString &path); static void loadList(const QString &path);
static const PCS *pcs(int id); static const PCS *pcs(int id);

View File

@ -110,14 +110,14 @@ Projection &Projection::operator=(const Projection &p)
PointD Projection::ll2xy(const Coordinates &c) const PointD Projection::ll2xy(const Coordinates &c) const
{ {
return isValid() Q_ASSERT(isValid());
? _units.fromMeters(_ct->ll2xy(_gcs->fromWGS84(c))) : PointD(); return _units.fromMeters(_ct->ll2xy(_gcs->fromWGS84(c)));
} }
Coordinates Projection::xy2ll(const PointD &p) const Coordinates Projection::xy2ll(const PointD &p) const
{ {
return isValid() Q_ASSERT(isValid());
? _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p))) : Coordinates(); return _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p)));
} }
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG

View File

@ -227,7 +227,7 @@ bool WMS::parseCapabilities(const QString &path, const Setup &setup)
} }
_projection = CRS::projection(ctx.setup.crs()); _projection = CRS::projection(ctx.setup.crs());
if (_projection.isNull()) { if (!_projection.isValid()) {
_errorString = ctx.setup.crs() + ": unknown CRS"; _errorString = ctx.setup.crs() + ": unknown CRS";
return false; return false;
} }

View File

@ -261,7 +261,7 @@ bool WMTS::parseCapabilities(const QString &path, const Setup &setup)
return false; return false;
} }
_projection = CRS::projection(ctx.crs); _projection = CRS::projection(ctx.crs);
if (_projection.isNull()) { if (!_projection.isValid()) {
_errorString = ctx.crs + ": unknown CRS"; _errorString = ctx.crs + ": unknown CRS";
return false; return false;
} }