1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 06:43:22 +02:00

Code cleanup

This commit is contained in:
Martin Tůma 2021-06-27 16:00:27 +02:00
parent f5ea667f34
commit c0c7e9046a
5 changed files with 29 additions and 20 deletions

View File

@ -289,7 +289,7 @@ bool GeoTIFF::readGeoValue(TIFFFile &file, quint32 offset, quint16 index,
return true;
}
GCS GeoTIFF::gcs(QMap<quint16, Value> &kv)
GCS GeoTIFF::geographicCS(QMap<quint16, Value> &kv)
{
GCS gcs;
@ -321,7 +321,7 @@ GCS GeoTIFF::gcs(QMap<quint16, Value> &kv)
return gcs;
}
Projection::Method GeoTIFF::method(QMap<quint16, Value> &kv)
Projection::Method GeoTIFF::coordinateTransformation(QMap<quint16, Value> &kv)
{
if (!IS_SET(kv, ProjCoordTransGeoKey)) {
_errorString = "Missing coordinate transformation method";
@ -367,10 +367,10 @@ bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
}
_projection = Projection(pcs);
} else if (IS_SET(kv, ProjectionGeoKey)) {
const GCS g(gcs(kv));
if (g.isNull())
GCS gcs(geographicCS(kv));
if (gcs.isNull())
return false;
const PCS &pcs = PCS::pcs(g, kv.value(ProjectionGeoKey).SHORT);
const PCS &pcs = PCS::pcs(gcs, kv.value(ProjectionGeoKey).SHORT);
if (pcs.isNull()) {
_errorString = QString("%1: unknown projection code")
.arg(kv.value(GeographicTypeGeoKey).SHORT)
@ -381,11 +381,11 @@ bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
} else {
double lat0, lon0, scale, fe, fn, sp1, sp2;
GCS g(gcs(kv));
if (g.isNull())
GCS gcs(geographicCS(kv));
if (gcs.isNull())
return false;
Projection::Method m(method(kv));
if (m.isNull())
Projection::Method method(coordinateTransformation(kv));
if (method.isNull())
return false;
AngularUnits au(IS_SET(kv, GeogAngularUnitsGeoKey)
@ -454,7 +454,7 @@ bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
fe = NAN;
Projection::Setup setup(lat0, lon0, scale, fe, fn, sp1, sp2);
PCS pcs(g, m, setup, lu, CoordinateSystem());
PCS pcs(gcs, method, setup, lu, CoordinateSystem());
_projection = Projection(pcs);
}
@ -463,11 +463,11 @@ bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
bool GeoTIFF::geographicModel(QMap<quint16, Value> &kv)
{
GCS g(gcs(kv));
if (g.isNull())
GCS gcs(geographicCS(kv));
if (gcs.isNull())
return false;
_projection = Projection(g);
_projection = Projection(gcs);
return true;
}

View File

@ -48,8 +48,8 @@ private:
bool readGeoValue(TIFFFile &file, quint32 offset, quint16 index,
double &val) const;
GCS gcs(QMap<quint16, Value> &kv);
Projection::Method method(QMap<quint16, Value> &kv);
GCS geographicCS(QMap<quint16, Value> &kv);
Projection::Method coordinateTransformation(QMap<quint16, Value> &kv);
bool geographicModel(QMap<quint16, Value> &kv);
bool projectedModel(QMap<quint16, Value> &kv);

View File

@ -30,8 +30,9 @@ public:
&& _setup.isNull() && _cs.isNull());
}
bool isValid() const {
return (_gcs.isValid() && _units.isValid() && _method.isValid()
&& _cs.isValid());
// We do not check the CoordinateSystem here as it is not always defined
// and except of WMTS/WMS it is not needed.
return (_gcs.isValid() && _units.isValid() && _method.isValid());
}
static void loadList(const QString &path);

View File

@ -115,7 +115,7 @@ Projection::Projection(const PCS &pcs)
}
Projection::Projection(const GCS &gcs, const CoordinateSystem &cs)
: _gcs(gcs), _ct(0), _units(LinearUnits(9001)), _cs(cs), _geographic(true)
: _gcs(gcs), _units(LinearUnits(9001)), _cs(cs), _geographic(true)
{
_ct = new LatLon(gcs.angularUnits());
}

View File

@ -80,8 +80,16 @@ public:
Projection &operator=(const Projection &p);
bool operator==(const Projection &p) const;
bool isNull() const {return (_gcs.isNull() && _ct == 0 && _units.isNull());}
bool isValid() const {return _gcs.isValid() && _ct != 0 && _units.isValid();}
bool isNull() const
{
return (_gcs.isNull() && _ct == 0 && _units.isNull() && _cs.isNull());
}
bool isValid() const
{
// We do not check the CoordinateSystem here as it is not always defined
// and except of WMTS/WMS it is not needed.
return (_gcs.isValid() && _ct != 0 && _units.isValid());
}
bool isGeographic() const {return _geographic;}
PointD ll2xy(const Coordinates &c) const;