1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-18 11:52:08 +01:00

Remove all the remaining obscure micro-optimizations

This commit is contained in:
Martin Tůma 2021-07-01 08:54:48 +02:00
parent f77e428eeb
commit f4d0c7f032
8 changed files with 25 additions and 39 deletions

View File

@ -34,11 +34,11 @@ Projection CRS::projection(const QString &crs)
if (!res)
return Projection();
const PCS &pcs = PCS::pcs(epsg);
PCS pcs(PCS::pcs(epsg));
if (!pcs.isNull())
return Projection(pcs);
const GCS &gcs = GCS::gcs(epsg);
GCS gcs(GCS::gcs(epsg));
if (!gcs.isNull())
return Projection(gcs);
@ -54,11 +54,11 @@ Projection CRS::projection(const QString &crs)
Projection CRS::projection(int id)
{
const PCS &pcs = PCS::pcs(id);
PCS pcs(PCS::pcs(id));
if (!pcs.isNull())
return Projection(pcs);
const GCS &gcs = GCS::gcs(id);
GCS gcs(GCS::gcs(id));
if (!gcs.isNull())
return Projection(gcs);

View File

@ -58,21 +58,17 @@ QList<GCS::Entry> GCS::defaults()
return list;
}
const GCS &GCS::gcs(int id)
GCS GCS::gcs(int id)
{
static const GCS null;
for (int i = 0; i < _gcss.size(); i++)
if (_gcss.at(i).id() == id)
return _gcss.at(i).gcs();
return null;
return GCS();
}
const GCS &GCS::gcs(int geodeticDatum, int primeMeridian, int angularUnits)
GCS GCS::gcs(int geodeticDatum, int primeMeridian, int angularUnits)
{
static const GCS null;
for (int i = 0; i < _gcss.size(); i++) {
const Entry &e = _gcss.at(i);
if (e.gd() == geodeticDatum && e.gcs().primeMeridian() == primeMeridian
@ -80,18 +76,16 @@ const GCS &GCS::gcs(int geodeticDatum, int primeMeridian, int angularUnits)
return e.gcs();
}
return null;
return GCS();
}
const GCS &GCS::gcs(const QString &name)
GCS GCS::gcs(const QString &name)
{
static const GCS null;
for (int i = 0; i < _gcss.size(); i++)
if (_gcss.at(i).name() == name)
return _gcss.at(i).gcs();
return null;
return GCS();
}
void GCS::loadList(const QString &path)

View File

@ -32,10 +32,9 @@ public:
Coordinates toWGS84(const Coordinates &c) const;
Coordinates fromWGS84(const Coordinates &c) const;
static const GCS &gcs(int id);
static const GCS &gcs(int geodeticDatum, int primeMeridian,
int angularUnits);
static const GCS &gcs(const QString &name);
static GCS gcs(int id);
static GCS gcs(int geodeticDatum, int primeMeridian, int angularUnits);
static GCS gcs(const QString &name);
static const GCS &WGS84();
static void loadList(const QString &path);

View File

@ -359,7 +359,7 @@ Projection::Method GeoTIFF::coordinateTransformation(QMap<quint16, Value> &kv)
bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
{
if (IS_SET(kv, ProjectedCSTypeGeoKey)) {
const PCS &pcs = PCS::pcs(kv.value(ProjectedCSTypeGeoKey).SHORT);
PCS pcs(PCS::pcs(kv.value(ProjectedCSTypeGeoKey).SHORT));
if (pcs.isNull()) {
_errorString = QString("%1: unknown PCS")
.arg(kv.value(ProjectedCSTypeGeoKey).SHORT);
@ -370,7 +370,7 @@ bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
GCS gcs(geographicCS(kv));
if (gcs.isNull())
return false;
const PCS &pcs = PCS::pcs(gcs, kv.value(ProjectionGeoKey).SHORT);
PCS pcs(PCS::pcs(gcs, kv.value(ProjectionGeoKey).SHORT));
if (pcs.isNull()) {
_errorString = QString("%1: unknown projection code")
.arg(kv.value(GeographicTypeGeoKey).SHORT)
@ -454,8 +454,7 @@ bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
fe = NAN;
Projection::Setup setup(lat0, lon0, scale, fe, fn, sp1, sp2);
PCS pcs(gcs, method, setup, lu, CoordinateSystem());
_projection = Projection(pcs);
_projection = Projection(PCS(gcs, method, setup, lu));
}
return true;

View File

@ -117,26 +117,22 @@ static int projectionSetup(const QList<QByteArray> &list,
}
const PCS &PCS::pcs(int id)
PCS PCS::pcs(int id)
{
static const PCS null;
for (int i = 0; i < _pcss.size(); i++)
if (_pcss.at(i).id() == id)
return _pcss.at(i).pcs();
return null;
return PCS();
}
const PCS &PCS::pcs(const GCS &gcs, int proj)
PCS PCS::pcs(const GCS &gcs, int proj)
{
static const PCS null;
for (int i = 0; i < _pcss.size(); i++)
if (_pcss.at(i).proj() == proj && _pcss.at(i).pcs().gcs() == gcs)
return _pcss.at(i).pcs();
return null;
return PCS();
}
void PCS::loadList(const QString &path)
@ -210,7 +206,7 @@ void PCS::loadList(const QString &path)
ln);
continue;
}
const GCS &gcs = GCS::gcs(gcsid);
GCS gcs(GCS::gcs(gcsid));
if (gcs.isNull()) {
qWarning("%s:%d: Unknown GCS code", qPrintable(path), ln);
continue;

View File

@ -36,8 +36,8 @@ public:
}
static void loadList(const QString &path);
static const PCS &pcs(int id);
static const PCS &pcs(const GCS &gcs, int proj);
static PCS pcs(int id);
static PCS pcs(const GCS &gcs, int proj);
static QList<KV<int, QString> > list();
private:

View File

@ -540,9 +540,7 @@ void PRJFile::projectedCS(CTX &ctx, PCS *pcs)
optProjectedCS(ctx, &epsg);
compare(ctx, RBRK);
*pcs = (epsg > 0)
? PCS::pcs(epsg)
: PCS(gcs, method, setup, lu, CoordinateSystem());
*pcs = (epsg > 0) ? PCS::pcs(epsg) : PCS(gcs, method, setup, lu);
}
void PRJFile::axisType(CTX &ctx)

View File

@ -125,7 +125,7 @@ bool RMap::parseIMP(const QByteArray &data)
}
}
const GCS &gcs = GCS::gcs(datum);
GCS gcs(GCS::gcs(datum));
if (gcs.isNull()) {
_errorString = datum + ": unknown/invalid datum";
return false;