2018-03-30 10:25:05 +02:00
|
|
|
#include <QStringList>
|
|
|
|
#include "pcs.h"
|
|
|
|
#include "crs.h"
|
|
|
|
|
|
|
|
Projection CRS::projection(const QString &crs)
|
|
|
|
{
|
|
|
|
QStringList list(crs.split(':'));
|
|
|
|
QString authority, code;
|
|
|
|
bool res;
|
|
|
|
|
|
|
|
switch (list.size()) {
|
|
|
|
case 2:
|
|
|
|
authority = list.at(0);
|
|
|
|
code = list.at(1);
|
|
|
|
break;
|
2021-03-20 23:06:09 +01:00
|
|
|
case 6:
|
|
|
|
authority = list.at(4);
|
|
|
|
code = list.at(5);
|
|
|
|
break;
|
2018-03-30 10:25:05 +02:00
|
|
|
case 7:
|
|
|
|
authority = list.at(4);
|
|
|
|
code = list.at(6);
|
|
|
|
break;
|
2020-05-02 09:48:30 +02:00
|
|
|
case 8:
|
|
|
|
authority = list.at(4);
|
|
|
|
code = list.at(7);
|
|
|
|
break;
|
2018-03-30 10:25:05 +02:00
|
|
|
default:
|
|
|
|
return Projection();
|
|
|
|
}
|
|
|
|
|
2020-10-11 21:33:19 +02:00
|
|
|
if (!authority.compare("EPSG", Qt::CaseInsensitive)) {
|
2021-06-17 21:58:25 +02:00
|
|
|
int epsg = code.toInt(&res);
|
2018-03-30 10:25:05 +02:00
|
|
|
if (!res)
|
|
|
|
return Projection();
|
|
|
|
|
2021-07-01 08:54:48 +02:00
|
|
|
PCS pcs(PCS::pcs(epsg));
|
2021-06-17 21:58:25 +02:00
|
|
|
if (!pcs.isNull())
|
2018-04-05 20:38:23 +02:00
|
|
|
return Projection(pcs);
|
2021-06-17 21:58:25 +02:00
|
|
|
|
2021-07-01 08:54:48 +02:00
|
|
|
GCS gcs(GCS::gcs(epsg));
|
2021-06-17 21:58:25 +02:00
|
|
|
if (!gcs.isNull())
|
2018-03-30 10:25:05 +02:00
|
|
|
return Projection(gcs);
|
2021-06-17 21:58:25 +02:00
|
|
|
|
|
|
|
return Projection();
|
2020-10-11 21:33:19 +02:00
|
|
|
} else if (!authority.compare("OGC", Qt::CaseInsensitive)) {
|
2018-03-30 10:25:05 +02:00
|
|
|
if (code == "CRS84")
|
2018-04-05 21:13:48 +02:00
|
|
|
return Projection(GCS::gcs(4326), CoordinateSystem::XY);
|
2018-03-30 10:25:05 +02:00
|
|
|
else
|
|
|
|
return Projection();
|
|
|
|
} else
|
|
|
|
return Projection();
|
|
|
|
}
|
2021-06-17 21:58:25 +02:00
|
|
|
|
|
|
|
Projection CRS::projection(int id)
|
|
|
|
{
|
2021-07-01 08:54:48 +02:00
|
|
|
PCS pcs(PCS::pcs(id));
|
2021-06-17 21:58:25 +02:00
|
|
|
if (!pcs.isNull())
|
|
|
|
return Projection(pcs);
|
|
|
|
|
2021-07-01 08:54:48 +02:00
|
|
|
GCS gcs(GCS::gcs(id));
|
2021-06-17 21:58:25 +02:00
|
|
|
if (!gcs.isNull())
|
|
|
|
return Projection(gcs);
|
|
|
|
|
|
|
|
return Projection();
|
|
|
|
}
|