mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Fixed error handling
This commit is contained in:
parent
7aef81d823
commit
49792064d7
@ -68,8 +68,6 @@ Projection::Projection(const GCS *gcs, const Method &method, const Setup &setup,
|
||||
default:
|
||||
_ct = 0;
|
||||
}
|
||||
|
||||
Q_ASSERT(_ct != 0);
|
||||
}
|
||||
|
||||
Projection::Projection(const GCS *gcs) : _gcs(gcs), _geographic(true)
|
||||
@ -82,7 +80,7 @@ Projection::Projection(const Projection &p)
|
||||
{
|
||||
_gcs = p._gcs;
|
||||
_units = p._units;
|
||||
_ct = p._ct->clone();
|
||||
_ct = p._ct ? p._ct->clone() : 0;
|
||||
_geographic = p._geographic;
|
||||
}
|
||||
|
||||
@ -95,7 +93,7 @@ Projection &Projection::operator=(const Projection &p)
|
||||
{
|
||||
_gcs = p._gcs;
|
||||
_units = p._units;
|
||||
_ct = p._ct->clone();
|
||||
_ct = p._ct ? p._ct->clone() : 0;
|
||||
_geographic = p._geographic;
|
||||
|
||||
return *this;
|
||||
@ -103,12 +101,14 @@ Projection &Projection::operator=(const Projection &p)
|
||||
|
||||
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
|
||||
{
|
||||
return _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p)));
|
||||
return isValid()
|
||||
? _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p))) : Coordinates();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
Projection &operator=(const Projection &p);
|
||||
|
||||
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;}
|
||||
|
||||
QPointF ll2xy(const Coordinates &c) const;
|
||||
|
Loading…
Reference in New Issue
Block a user