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;
211 Q_PROPERTY(
bool isGeographic READ isGeographic )
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 );
499 bool createFromUserInput(
const QString &definition );
514 bool isValid() const;
561 bool readXml( const QDomNode &node );
569 bool writeXml( QDomNode &node, QDomDocument &doc ) const;
598 long postgisSrid() const;
612 QString authid() const;
621 QString description() const;
648 QString userFriendlyIdentifier( IdentifierType type = MediumString )
const;
656 QString projectionAcronym()
const;
664 QString ellipsoidAcronym()
const;
675 WKT2_2019 = WKT2_2018,
676 WKT2_2019_SIMPLIFIED = WKT2_2018_SIMPLIFIED,
678 WKT_PREFERRED = WKT2_2019,
679 WKT_PREFERRED_SIMPLIFIED = WKT2_2019_SIMPLIFIED,
680 WKT_PREFERRED_GDAL = WKT2_2019,
694 QString toWkt( WktVariant variant = WKT1_GDAL,
bool multiline =
false,
int indentationWidth = 4 )
const;
722 QString toProj() const;
728 bool isGeographic() const;
734 bool hasAxisInverted() const;
756 void setValidationHint( const QString &html );
761 QString validationHint();
769 static
int syncDatabase();
782 long saveAsUserCrs( const QString &name, Format nativeFormat = FormatWkt );
785 QString geographicCrsAuthId() const;
788 SIP_PYOBJECT __repr__();
790 QString str = QStringLiteral(
"<QgsCoordinateReferenceSystem: %1>" ).arg( sipCpp->authid() );
791 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
796 #if PROJ_VERSION_MAJOR>=6
807 PJ *projObject()
const;
816 Q_DECL_DEPRECATED
static QStringList recentProjections()
SIP_DEPRECATED;
842 static void invalidateCache(
bool disableCache =
false );
852 static void invalidateCache(
bool disableCache
SIP_PYARGREMOVE =
false );
865 static QString projFromSrsId(
int srsId );
872 void setProjString(
const QString &projString );
877 bool setWktString(
const QString &wkt,
bool allowProjFallback =
true );
885 typedef QMap<QString, QString> RecordMap;
894 RecordMap getRecord(
const QString &sql );
906 long getRecordCount();
908 #if PROJ_VERSION_MAJOR>=6
909 bool loadFromAuthCode(
const QString &auth,
const QString &code );
914 static QList< long > userSrsIds();
923 long matchToUserCrs()
const;
930 bool loadFromDatabase(
const QString &db,
const QString &expression,
const QString &value );
932 #if PROJ_VERSION_MAJOR<6 // not used for proj >= 6.0
933 static bool loadIds( QHash<int, QString> &wkts );
934 static bool loadWkts( QHash<int, QString> &wkts,
const char *filename );
937 static bool syncDatumTransform(
const QString &dbPath );
940 QExplicitlySharedDataPointer<QgsCoordinateReferenceSystemPrivate> d;
942 QString mValidationHint;
944 #if PROJ_VERSION_MAJOR>=6
948 static void removeFromCacheObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context );
956 static bool sDisableSrIdCache;
957 static bool sDisableOgcCache;
958 static bool sDisableProjCache;
959 static bool sDisableWktCache;
960 static bool sDisableSrsIdCache;
961 static bool sDisableStringCache;
964 static const QHash< QString, QgsCoordinateReferenceSystem > &stringCache();
965 static const QHash< QString, QgsCoordinateReferenceSystem > &projCache();
966 static const QHash< QString, QgsCoordinateReferenceSystem > &ogcCache();
967 static const QHash< QString, QgsCoordinateReferenceSystem > &wktCache();
968 static const QHash< long, QgsCoordinateReferenceSystem > &srsIdCache();
969 static const QHash< long, QgsCoordinateReferenceSystem > &srIdCache();
971 friend class TestQgsCoordinateReferenceSystem;
972 friend class QgsPostgresProvider;
974 bool createFromPostgisSrid(
const long id );
983 QString mySummary( QStringLiteral(
"\n\tSpatial Reference System:" ) );
984 mySummary += QLatin1String(
"\n\t\tDescription : " );
991 mySummary += QLatin1String(
"Undefined" );
993 mySummary += QLatin1String(
"\n\t\tProjection : " );
1000 mySummary += QLatin1String(
"Undefined" );
1003 mySummary += QLatin1String(
"\n\t\tEllipsoid : " );
1010 mySummary += QLatin1String(
"Undefined" );
1013 mySummary += QLatin1String(
"\n\t\tProjString : " );
1014 if ( !r.
toProj().isNull() )
1020 mySummary += QLatin1String(
"Undefined" );
1023 return os << mySummary.toLocal8Bit().data() << std::endl;
1027 #endif // QGSCOORDINATEREFERENCESYSTEM_H