18 #ifndef QGSCOORDINATEREFERENCESYSTEM_H
19 #define QGSCOORDINATEREFERENCESYSTEM_H
22 #include "qgis_core.h"
29 #include <QReadWriteLock>
30 #include <QExplicitlySharedDataPointer>
41 class QgsCoordinateReferenceSystemPrivate;
43 #if PROJ_VERSION_MAJOR>=6
46 typedef struct PJconsts PJ;
210 Q_PROPERTY(
bool isGeographic READ isGeographic )
275 operator QVariant()
const
277 return QVariant::fromValue( *
this );
287 static QList< long > validSrsIds();
353 Q_DECL_DEPRECATED
bool createFromId(
long id, CrsType type = PostgisCrsId )
SIP_DEPRECATED;
367 bool createFromOgcWmsCrs(
const QString &
crs );
378 Q_DECL_DEPRECATED
bool createFromSrid(
long srid )
SIP_DEPRECATED;
392 bool createFromWkt(
const QString &wkt );
406 bool createFromSrsId(
long srsId );
431 Q_DECL_DEPRECATED
bool createFromProj4(
const QString &projString )
SIP_DEPRECATED;
461 bool createFromProj(
const QString &projString,
bool identify =
true );
463 bool createFromProj(
const QString &projString );
481 bool createFromString(
const QString &definition );
500 bool createFromUserInput(
const QString &definition );
515 bool isValid() const;
562 bool readXml( const QDomNode &node );
570 bool writeXml( QDomNode &node, QDomDocument &doc ) const;
599 long postgisSrid() const;
613 QString authid() const;
622 QString description() const;
649 QString userFriendlyIdentifier( IdentifierType type = MediumString )
const;
657 QString projectionAcronym()
const;
665 QString ellipsoidAcronym()
const;
676 WKT2_2019 = WKT2_2018,
677 WKT2_2019_SIMPLIFIED = WKT2_2018_SIMPLIFIED,
679 WKT_PREFERRED = WKT2_2019,
680 WKT_PREFERRED_SIMPLIFIED = WKT2_2019_SIMPLIFIED,
681 WKT_PREFERRED_GDAL = WKT2_2019,
695 QString toWkt( WktVariant variant = WKT1_GDAL,
bool multiline =
false,
int indentationWidth = 4 )
const;
723 QString toProj() const;
729 bool isGeographic() const;
735 bool hasAxisInverted() const;
757 void setValidationHint( const QString &html );
762 QString validationHint();
770 static
int syncDatabase();
783 long saveAsUserCrs( const QString &name, Format nativeFormat = FormatWkt );
786 QString geographicCrsAuthId() const;
789 SIP_PYOBJECT __repr__();
791 QString str = QStringLiteral(
"<QgsCoordinateReferenceSystem: %1>" ).arg( sipCpp->authid() );
792 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
797 #if PROJ_VERSION_MAJOR>=6
808 PJ *projObject()
const;
817 Q_DECL_DEPRECATED
static QStringList recentProjections()
SIP_DEPRECATED;
843 static void invalidateCache(
bool disableCache =
false );
853 static void invalidateCache(
bool disableCache
SIP_PYARGREMOVE =
false );
866 static QString projFromSrsId(
int srsId );
873 void setProjString(
const QString &projString );
878 bool setWktString(
const QString &wkt,
bool allowProjFallback =
true );
886 typedef QMap<QString, QString> RecordMap;
895 RecordMap getRecord(
const QString &sql );
907 long getRecordCount();
909 #if PROJ_VERSION_MAJOR>=6
910 bool loadFromAuthCode(
const QString &auth,
const QString &code );
915 static QList< long > userSrsIds();
924 long matchToUserCrs()
const;
931 bool loadFromDatabase(
const QString &db,
const QString &expression,
const QString &value );
933 bool createFromWktInternal(
const QString &wkt,
const QString &description );
935 #if PROJ_VERSION_MAJOR<6 // not used for proj >= 6.0
936 static bool loadIds( QHash<int, QString> &wkts );
937 static bool loadWkts( QHash<int, QString> &wkts,
const char *filename );
940 static bool syncDatumTransform(
const QString &dbPath );
943 QExplicitlySharedDataPointer<QgsCoordinateReferenceSystemPrivate> d;
945 QString mValidationHint;
947 #if PROJ_VERSION_MAJOR>=6
951 static void removeFromCacheObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context );
959 static bool sDisableSrIdCache;
960 static bool sDisableOgcCache;
961 static bool sDisableProjCache;
962 static bool sDisableWktCache;
963 static bool sDisableSrsIdCache;
964 static bool sDisableStringCache;
967 static const QHash< QString, QgsCoordinateReferenceSystem > &stringCache();
968 static const QHash< QString, QgsCoordinateReferenceSystem > &projCache();
969 static const QHash< QString, QgsCoordinateReferenceSystem > &ogcCache();
970 static const QHash< QString, QgsCoordinateReferenceSystem > &wktCache();
971 static const QHash< long, QgsCoordinateReferenceSystem > &srsIdCache();
972 static const QHash< long, QgsCoordinateReferenceSystem > &srIdCache();
974 friend class TestQgsCoordinateReferenceSystem;
975 friend class QgsPostgresProvider;
977 bool createFromPostgisSrid(
const long id );
986 QString mySummary( QStringLiteral(
"\n\tSpatial Reference System:" ) );
987 mySummary += QLatin1String(
"\n\t\tDescription : " );
994 mySummary += QLatin1String(
"Undefined" );
996 mySummary += QLatin1String(
"\n\t\tProjection : " );
1003 mySummary += QLatin1String(
"Undefined" );
1006 mySummary += QLatin1String(
"\n\t\tEllipsoid : " );
1013 mySummary += QLatin1String(
"Undefined" );
1016 mySummary += QLatin1String(
"\n\t\tProjString : " );
1017 if ( !r.
toProj().isNull() )
1023 mySummary += QLatin1String(
"Undefined" );
1026 return os << mySummary.toLocal8Bit().data() << std::endl;
1030 #endif // QGSCOORDINATEREFERENCESYSTEM_H