mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Remove all the remaining obscure micro-optimizations
This commit is contained in:
parent
f77e428eeb
commit
f4d0c7f032
@ -34,11 +34,11 @@ Projection CRS::projection(const QString &crs)
|
|||||||
if (!res)
|
if (!res)
|
||||||
return Projection();
|
return Projection();
|
||||||
|
|
||||||
const PCS &pcs = PCS::pcs(epsg);
|
PCS pcs(PCS::pcs(epsg));
|
||||||
if (!pcs.isNull())
|
if (!pcs.isNull())
|
||||||
return Projection(pcs);
|
return Projection(pcs);
|
||||||
|
|
||||||
const GCS &gcs = GCS::gcs(epsg);
|
GCS gcs(GCS::gcs(epsg));
|
||||||
if (!gcs.isNull())
|
if (!gcs.isNull())
|
||||||
return Projection(gcs);
|
return Projection(gcs);
|
||||||
|
|
||||||
@ -54,11 +54,11 @@ Projection CRS::projection(const QString &crs)
|
|||||||
|
|
||||||
Projection CRS::projection(int id)
|
Projection CRS::projection(int id)
|
||||||
{
|
{
|
||||||
const PCS &pcs = PCS::pcs(id);
|
PCS pcs(PCS::pcs(id));
|
||||||
if (!pcs.isNull())
|
if (!pcs.isNull())
|
||||||
return Projection(pcs);
|
return Projection(pcs);
|
||||||
|
|
||||||
const GCS &gcs = GCS::gcs(id);
|
GCS gcs(GCS::gcs(id));
|
||||||
if (!gcs.isNull())
|
if (!gcs.isNull())
|
||||||
return Projection(gcs);
|
return Projection(gcs);
|
||||||
|
|
||||||
|
@ -58,21 +58,17 @@ QList<GCS::Entry> GCS::defaults()
|
|||||||
return list;
|
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++)
|
for (int i = 0; i < _gcss.size(); i++)
|
||||||
if (_gcss.at(i).id() == id)
|
if (_gcss.at(i).id() == id)
|
||||||
return _gcss.at(i).gcs();
|
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++) {
|
for (int i = 0; i < _gcss.size(); i++) {
|
||||||
const Entry &e = _gcss.at(i);
|
const Entry &e = _gcss.at(i);
|
||||||
if (e.gd() == geodeticDatum && e.gcs().primeMeridian() == primeMeridian
|
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 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++)
|
for (int i = 0; i < _gcss.size(); i++)
|
||||||
if (_gcss.at(i).name() == name)
|
if (_gcss.at(i).name() == name)
|
||||||
return _gcss.at(i).gcs();
|
return _gcss.at(i).gcs();
|
||||||
|
|
||||||
return null;
|
return GCS();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCS::loadList(const QString &path)
|
void GCS::loadList(const QString &path)
|
||||||
|
@ -32,10 +32,9 @@ public:
|
|||||||
Coordinates toWGS84(const Coordinates &c) const;
|
Coordinates toWGS84(const Coordinates &c) const;
|
||||||
Coordinates fromWGS84(const Coordinates &c) const;
|
Coordinates fromWGS84(const Coordinates &c) const;
|
||||||
|
|
||||||
static const GCS &gcs(int id);
|
static GCS gcs(int id);
|
||||||
static const GCS &gcs(int geodeticDatum, int primeMeridian,
|
static GCS gcs(int geodeticDatum, int primeMeridian, int angularUnits);
|
||||||
int angularUnits);
|
static GCS gcs(const QString &name);
|
||||||
static const GCS &gcs(const QString &name);
|
|
||||||
static const GCS &WGS84();
|
static const GCS &WGS84();
|
||||||
|
|
||||||
static void loadList(const QString &path);
|
static void loadList(const QString &path);
|
||||||
|
@ -359,7 +359,7 @@ Projection::Method GeoTIFF::coordinateTransformation(QMap<quint16, Value> &kv)
|
|||||||
bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
|
bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
|
||||||
{
|
{
|
||||||
if (IS_SET(kv, ProjectedCSTypeGeoKey)) {
|
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()) {
|
if (pcs.isNull()) {
|
||||||
_errorString = QString("%1: unknown PCS")
|
_errorString = QString("%1: unknown PCS")
|
||||||
.arg(kv.value(ProjectedCSTypeGeoKey).SHORT);
|
.arg(kv.value(ProjectedCSTypeGeoKey).SHORT);
|
||||||
@ -370,7 +370,7 @@ bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
|
|||||||
GCS gcs(geographicCS(kv));
|
GCS gcs(geographicCS(kv));
|
||||||
if (gcs.isNull())
|
if (gcs.isNull())
|
||||||
return false;
|
return false;
|
||||||
const PCS &pcs = PCS::pcs(gcs, kv.value(ProjectionGeoKey).SHORT);
|
PCS pcs(PCS::pcs(gcs, kv.value(ProjectionGeoKey).SHORT));
|
||||||
if (pcs.isNull()) {
|
if (pcs.isNull()) {
|
||||||
_errorString = QString("%1: unknown projection code")
|
_errorString = QString("%1: unknown projection code")
|
||||||
.arg(kv.value(GeographicTypeGeoKey).SHORT)
|
.arg(kv.value(GeographicTypeGeoKey).SHORT)
|
||||||
@ -454,8 +454,7 @@ bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
|
|||||||
fe = NAN;
|
fe = NAN;
|
||||||
|
|
||||||
Projection::Setup setup(lat0, lon0, scale, fe, fn, sp1, sp2);
|
Projection::Setup setup(lat0, lon0, scale, fe, fn, sp1, sp2);
|
||||||
PCS pcs(gcs, method, setup, lu, CoordinateSystem());
|
_projection = Projection(PCS(gcs, method, setup, lu));
|
||||||
_projection = Projection(pcs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -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++)
|
for (int i = 0; i < _pcss.size(); i++)
|
||||||
if (_pcss.at(i).id() == id)
|
if (_pcss.at(i).id() == id)
|
||||||
return _pcss.at(i).pcs();
|
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++)
|
for (int i = 0; i < _pcss.size(); i++)
|
||||||
if (_pcss.at(i).proj() == proj && _pcss.at(i).pcs().gcs() == gcs)
|
if (_pcss.at(i).proj() == proj && _pcss.at(i).pcs().gcs() == gcs)
|
||||||
return _pcss.at(i).pcs();
|
return _pcss.at(i).pcs();
|
||||||
|
|
||||||
return null;
|
return PCS();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCS::loadList(const QString &path)
|
void PCS::loadList(const QString &path)
|
||||||
@ -210,7 +206,7 @@ void PCS::loadList(const QString &path)
|
|||||||
ln);
|
ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const GCS &gcs = GCS::gcs(gcsid);
|
GCS gcs(GCS::gcs(gcsid));
|
||||||
if (gcs.isNull()) {
|
if (gcs.isNull()) {
|
||||||
qWarning("%s:%d: Unknown GCS code", qPrintable(path), ln);
|
qWarning("%s:%d: Unknown GCS code", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
|
@ -36,8 +36,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void loadList(const QString &path);
|
static void loadList(const QString &path);
|
||||||
static const PCS &pcs(int id);
|
static PCS pcs(int id);
|
||||||
static const PCS &pcs(const GCS &gcs, int proj);
|
static PCS pcs(const GCS &gcs, int proj);
|
||||||
static QList<KV<int, QString> > list();
|
static QList<KV<int, QString> > list();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -540,9 +540,7 @@ void PRJFile::projectedCS(CTX &ctx, PCS *pcs)
|
|||||||
optProjectedCS(ctx, &epsg);
|
optProjectedCS(ctx, &epsg);
|
||||||
compare(ctx, RBRK);
|
compare(ctx, RBRK);
|
||||||
|
|
||||||
*pcs = (epsg > 0)
|
*pcs = (epsg > 0) ? PCS::pcs(epsg) : PCS(gcs, method, setup, lu);
|
||||||
? PCS::pcs(epsg)
|
|
||||||
: PCS(gcs, method, setup, lu, CoordinateSystem());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PRJFile::axisType(CTX &ctx)
|
void PRJFile::axisType(CTX &ctx)
|
||||||
|
@ -125,7 +125,7 @@ bool RMap::parseIMP(const QByteArray &data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const GCS &gcs = GCS::gcs(datum);
|
GCS gcs(GCS::gcs(datum));
|
||||||
if (gcs.isNull()) {
|
if (gcs.isNull()) {
|
||||||
_errorString = datum + ": unknown/invalid datum";
|
_errorString = datum + ": unknown/invalid datum";
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user