18 #ifndef QGSCOORDINATEREFERENCESYSTEM_H
19 #define QGSCOORDINATEREFERENCESYSTEM_H
22 #include "qgis_core.h"
29 #include <QReadWriteLock>
30 #include <QExplicitlySharedDataPointer>
35 #include "qgsconfig.h"
42 class QgsCoordinateReferenceSystemPrivate;
49 typedef struct PJconsts
PJ;
51 #if PROJ_VERSION_MAJOR>=8
216 Q_PROPERTY(
bool isGeographic READ isGeographic )
217 Q_PROPERTY( QString authid READ authid )
218 Q_PROPERTY( QString description READ description )
276 operator QVariant()
const
278 return QVariant::fromValue( *
this );
288 static QList< long > validSrsIds();
354 Q_DECL_DEPRECATED
bool createFromId(
long id, CrsType type = PostgisCrsId )
SIP_DEPRECATED;
368 bool createFromOgcWmsCrs(
const QString &
crs );
379 Q_DECL_DEPRECATED
bool createFromSrid(
long srid )
SIP_DEPRECATED;
393 bool createFromWkt(
const QString &wkt );
407 bool createFromSrsId(
long srsId );
432 Q_DECL_DEPRECATED
bool createFromProj4(
const QString &projString )
SIP_DEPRECATED;
462 bool createFromProj(
const QString &projString,
bool identify =
true );
464 bool createFromProj(
const QString &projString );
482 bool createFromString(
const QString &definition );
501 bool createFromUserInput(
const QString &definition );
516 bool isValid() const;
563 bool readXml( const QDomNode &node );
571 bool writeXml( QDomNode &node, QDomDocument &doc ) const;
600 long postgisSrid() const;
614 QString authid() const;
623 QString description() const;
650 QString userFriendlyIdentifier( IdentifierType type = MediumString )
const;
658 QString projectionAcronym()
const;
666 QString ellipsoidAcronym()
const;
677 WKT2_2019 = WKT2_2018,
678 WKT2_2019_SIMPLIFIED = WKT2_2018_SIMPLIFIED,
680 WKT_PREFERRED = WKT2_2019,
681 WKT_PREFERRED_SIMPLIFIED = WKT2_2019_SIMPLIFIED,
682 WKT_PREFERRED_GDAL = WKT2_2019,
696 QString toWkt( WktVariant variant = WKT1_GDAL,
bool multiline =
false,
int indentationWidth = 4 )
const;
724 QString toProj() const;
730 bool isGeographic() const;
740 bool isDynamic() const;
790 void setCoordinateEpoch(
double epoch );
815 double coordinateEpoch() const;
850 QList< Qgis::CrsAxisDirection > axisOrdering()
const;
852 SIP_PYOBJECT axisOrdering() const
SIP_TYPEHINT( List[
Qgis.CrsAxisDirection] );
856 const QList<
Qgis::CrsAxisDirection > cppRes = sipCpp->axisOrdering();
858 PyObject *l = PyList_New( cppRes.size() );
864 for (
int i = 0; i < cppRes.size(); ++i )
866 PyObject *eobj = sipConvertFromEnum(
static_cast<int>( cppRes.at( i ) ),
867 sipType_Qgis_CrsAxisDirection );
874 PyList_SetItem( l, i, eobj );
922 void updateDefinition();
927 void setValidationHint(
const QString &html );
932 QString validationHint()
const;
940 static int syncDatabase();
991 QString geographicCrsAuthId()
const;
994 SIP_PYOBJECT __repr__();
997 std::isfinite( sipCpp->coordinateEpoch() ) ? QStringLiteral(
" @ %1" ).arg( sipCpp->coordinateEpoch() ) : QString() )
998 : QStringLiteral(
"<QgsCoordinateReferenceSystem: invalid>" );
999 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
1014 PJ *projObject()
const;
1036 bool createFromProjObject(
PJ *
object );
1044 Q_DECL_DEPRECATED
static QStringList recentProjections()
SIP_DEPRECATED;
1070 static void invalidateCache(
bool disableCache =
false );
1080 static void invalidateCache(
bool disableCache
SIP_PYARGREMOVE =
false );
1093 static QString projFromSrsId(
int srsId );
1100 void setProjString(
const QString &projString );
1105 bool setWktString(
const QString &wkt );
1113 typedef QMap<QString, QString> RecordMap;
1122 RecordMap getRecord(
const QString &sql );
1134 static long getRecordCount();
1136 bool loadFromAuthCode(
const QString &auth,
const QString &code );
1141 static QList< long > userSrsIds();
1150 long matchToUserCrs()
const;
1156 bool loadFromDatabase(
const QString &db,
const QString &expression,
const QString &value );
1158 bool createFromWktInternal(
const QString &wkt,
const QString &description );
1160 QExplicitlySharedDataPointer<QgsCoordinateReferenceSystemPrivate> d;
1162 QString mValidationHint;
1169 static void removeFromCacheObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context );
1176 static bool sDisableSrIdCache;
1177 static bool sDisableOgcCache;
1178 static bool sDisableProjCache;
1179 static bool sDisableWktCache;
1180 static bool sDisableSrsIdCache;
1181 static bool sDisableStringCache;
1184 static const QHash< QString, QgsCoordinateReferenceSystem > &stringCache();
1185 static const QHash< QString, QgsCoordinateReferenceSystem > &projCache();
1186 static const QHash< QString, QgsCoordinateReferenceSystem > &ogcCache();
1187 static const QHash< QString, QgsCoordinateReferenceSystem > &wktCache();
1188 static const QHash< long, QgsCoordinateReferenceSystem > &srsIdCache();
1189 static const QHash< long, QgsCoordinateReferenceSystem > &srIdCache();
1191 friend class TestQgsCoordinateReferenceSystem;
1198 bool createFromPostgisSrid(
const long id );
1207 QString mySummary( QStringLiteral(
"\n\tSpatial Reference System:" ) );
1208 mySummary += QLatin1String(
"\n\t\tDescription : " );
1215 mySummary += QLatin1String(
"Undefined" );
1217 mySummary += QLatin1String(
"\n\t\tProjection : " );
1224 mySummary += QLatin1String(
"Undefined" );
1227 mySummary += QLatin1String(
"\n\t\tEllipsoid : " );
1234 mySummary += QLatin1String(
"Undefined" );
1237 mySummary += QLatin1String(
"\n\t\tProjString : " );
1238 if ( !r.
toProj().isNull() )
1244 mySummary += QLatin1String(
"Undefined" );
1247 return os << mySummary.toLocal8Bit().data() << std::endl;
1256 #endif // QGSCOORDINATEREFERENCESYSTEM_H