1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Fixed error handling

This commit is contained in:
Martin Tůma 2018-03-11 09:24:04 +01:00
parent 7aef81d823
commit 49792064d7
2 changed files with 7 additions and 7 deletions

View File

@ -68,8 +68,6 @@ Projection::Projection(const GCS *gcs, const Method &method, const Setup &setup,
default: default:
_ct = 0; _ct = 0;
} }
Q_ASSERT(_ct != 0);
} }
Projection::Projection(const GCS *gcs) : _gcs(gcs), _geographic(true) Projection::Projection(const GCS *gcs) : _gcs(gcs), _geographic(true)
@ -82,7 +80,7 @@ Projection::Projection(const Projection &p)
{ {
_gcs = p._gcs; _gcs = p._gcs;
_units = p._units; _units = p._units;
_ct = p._ct->clone(); _ct = p._ct ? p._ct->clone() : 0;
_geographic = p._geographic; _geographic = p._geographic;
} }
@ -95,7 +93,7 @@ Projection &Projection::operator=(const Projection &p)
{ {
_gcs = p._gcs; _gcs = p._gcs;
_units = p._units; _units = p._units;
_ct = p._ct->clone(); _ct = p._ct ? p._ct->clone() : 0;
_geographic = p._geographic; _geographic = p._geographic;
return *this; return *this;
@ -103,12 +101,14 @@ Projection &Projection::operator=(const Projection &p)
QPointF Projection::ll2xy(const Coordinates &c) const QPointF Projection::ll2xy(const Coordinates &c) const
{ {
return _units.fromMeters(_ct->ll2xy(_gcs->fromWGS84(c))); return isValid()
? _units.fromMeters(_ct->ll2xy(_gcs->fromWGS84(c))) : QPointF();
} }
Coordinates Projection::xy2ll(const QPointF &p) const Coordinates Projection::xy2ll(const QPointF &p) const
{ {
return _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p))); return isValid()
? _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p))) : Coordinates();
} }
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG

View File

@ -78,7 +78,7 @@ public:
Projection &operator=(const Projection &p); Projection &operator=(const Projection &p);
bool isNull() const {return (_gcs == 0 && _ct == 0 && _units.isNull());} bool isNull() const {return (_gcs == 0 && _ct == 0 && _units.isNull());}
bool isValid() const {return (_gcs == 0 || _ct == 0 || _units.isNull());} bool isValid() const {return !(_gcs == 0 || _ct == 0 || _units.isNull());}
bool isGeographic() const {return _geographic;} bool isGeographic() const {return _geographic;}
QPointF ll2xy(const Coordinates &c) const; QPointF ll2xy(const Coordinates &c) const;