1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +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(int code);
bool isNull() const {return (_axisOrder == Unknown);}
bool isValid() const {return (_axisOrder != Unknown);}
AxisOrder axisOrder() const {return _axisOrder;}

View File

@ -25,10 +25,11 @@ public:
const CoordinateSystem &coordinateSystem() const {return _cs;}
bool isNull() const
{return (_gcs->isNull() && _units.isNull() && _method.isNull()
&& _setup.isNull());}
{return (!_gcs && _units.isNull() && _method.isNull() && _setup.isNull()
&& _cs.isNull());}
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 const PCS *pcs(int id);

View File

@ -110,14 +110,14 @@ Projection &Projection::operator=(const Projection &p)
PointD Projection::ll2xy(const Coordinates &c) const
{
return isValid()
? _units.fromMeters(_ct->ll2xy(_gcs->fromWGS84(c))) : PointD();
Q_ASSERT(isValid());
return _units.fromMeters(_ct->ll2xy(_gcs->fromWGS84(c)));
}
Coordinates Projection::xy2ll(const PointD &p) const
{
return isValid()
? _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p))) : Coordinates();
Q_ASSERT(isValid());
return _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p)));
}
#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());
if (_projection.isNull()) {
if (!_projection.isValid()) {
_errorString = ctx.setup.crs() + ": unknown CRS";
return false;
}

View File

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