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;
48 #if PROJ_VERSION_MAJOR>=8
214 Q_PROPERTY(
bool isGeographic READ isGeographic )
279 operator QVariant()
const
281 return QVariant::fromValue( *
this );
291 static QList< long > validSrsIds();
357 Q_DECL_DEPRECATED
bool createFromId(
long id, CrsType type = PostgisCrsId )
SIP_DEPRECATED;
371 bool createFromOgcWmsCrs(
const QString &
crs );
382 Q_DECL_DEPRECATED
bool createFromSrid(
long srid )
SIP_DEPRECATED;
396 bool createFromWkt(
const QString &wkt );
410 bool createFromSrsId(
long srsId );
435 Q_DECL_DEPRECATED
bool createFromProj4(
const QString &projString )
SIP_DEPRECATED;
465 bool createFromProj(
const QString &projString,
bool identify =
true );
467 bool createFromProj(
const QString &projString );
485 bool createFromString(
const QString &definition );
504 bool createFromUserInput(
const QString &definition );
519 bool isValid() const;
566 bool readXml( const QDomNode &node );
574 bool writeXml( QDomNode &node, QDomDocument &doc ) const;
603 long postgisSrid() const;
617 QString authid() const;
626 QString description() const;
653 QString userFriendlyIdentifier( IdentifierType type = MediumString )
const;
661 QString projectionAcronym()
const;
669 QString ellipsoidAcronym()
const;
680 WKT2_2019 = WKT2_2018,
681 WKT2_2019_SIMPLIFIED = WKT2_2018_SIMPLIFIED,
683 WKT_PREFERRED = WKT2_2019,
684 WKT_PREFERRED_SIMPLIFIED = WKT2_2019_SIMPLIFIED,
685 WKT_PREFERRED_GDAL = WKT2_2019,
699 QString toWkt( WktVariant variant = WKT1_GDAL,
bool multiline =
false,
int indentationWidth = 4 )
const;
727 QString toProj() const;
733 bool isGeographic() const;
739 bool hasAxisInverted() const;
774 void updateDefinition();
779 void setValidationHint( const QString &html );
784 QString validationHint();
792 static
int syncDatabase();
807 long saveAsUserCrs( const QString &name, Format nativeFormat = FormatWkt );
810 QString geographicCrsAuthId() const;
813 SIP_PYOBJECT __repr__();
815 const QString str = sipCpp->isValid() ? QStringLiteral(
"<QgsCoordinateReferenceSystem: %1>" ).arg( !sipCpp->authid().isEmpty() ? sipCpp->authid() : sipCpp->toWkt(
QgsCoordinateReferenceSystem::WKT_PREFERRED ) )
816 : QStringLiteral(
"<QgsCoordinateReferenceSystem: invalid>" );
817 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
822 #if PROJ_VERSION_MAJOR>=6
833 PJ *projObject()
const;
842 Q_DECL_DEPRECATED
static QStringList recentProjections()
SIP_DEPRECATED;
868 static void invalidateCache(
bool disableCache =
false );
878 static void invalidateCache(
bool disableCache
SIP_PYARGREMOVE =
false );
891 static QString projFromSrsId(
int srsId );
898 void setProjString(
const QString &projString );
903 bool setWktString(
const QString &wkt,
bool allowProjFallback =
true );
911 typedef QMap<QString, QString> RecordMap;
920 RecordMap getRecord(
const QString &sql );
932 static long getRecordCount();
934 #if PROJ_VERSION_MAJOR>=6
935 bool loadFromAuthCode(
const QString &auth,
const QString &code );
940 static QList< long > userSrsIds();
949 long matchToUserCrs()
const;
956 bool loadFromDatabase(
const QString &db,
const QString &expression,
const QString &value );
958 bool createFromWktInternal(
const QString &wkt,
const QString &description );
960 #if PROJ_VERSION_MAJOR<6
961 static bool loadIds( QHash<int, QString> &wkts );
962 static bool loadWkts( QHash<int, QString> &wkts,
const char *filename );
965 static bool syncDatumTransform(
const QString &dbPath );
968 QExplicitlySharedDataPointer<QgsCoordinateReferenceSystemPrivate> d;
970 QString mValidationHint;
972 #if PROJ_VERSION_MAJOR>=6
976 static void removeFromCacheObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context );
984 static bool sDisableSrIdCache;
985 static bool sDisableOgcCache;
986 static bool sDisableProjCache;
987 static bool sDisableWktCache;
988 static bool sDisableSrsIdCache;
989 static bool sDisableStringCache;
992 static const QHash< QString, QgsCoordinateReferenceSystem > &stringCache();
993 static const QHash< QString, QgsCoordinateReferenceSystem > &projCache();
994 static const QHash< QString, QgsCoordinateReferenceSystem > &ogcCache();
995 static const QHash< QString, QgsCoordinateReferenceSystem > &wktCache();
996 static const QHash< long, QgsCoordinateReferenceSystem > &srsIdCache();
997 static const QHash< long, QgsCoordinateReferenceSystem > &srIdCache();
999 friend class TestQgsCoordinateReferenceSystem;
1000 friend class QgsPostgresProvider;
1003 bool createFromPostgisSrid(
const long id );
1012 QString mySummary( QStringLiteral(
"\n\tSpatial Reference System:" ) );
1013 mySummary += QLatin1String(
"\n\t\tDescription : " );
1020 mySummary += QLatin1String(
"Undefined" );
1022 mySummary += QLatin1String(
"\n\t\tProjection : " );
1029 mySummary += QLatin1String(
"Undefined" );
1032 mySummary += QLatin1String(
"\n\t\tEllipsoid : " );
1039 mySummary += QLatin1String(
"Undefined" );
1042 mySummary += QLatin1String(
"\n\t\tProjString : " );
1043 if ( !r.
toProj().isNull() )
1049 mySummary += QLatin1String(
"Undefined" );
1052 return os << mySummary.toLocal8Bit().data() << std::endl;
A registry for known coordinate reference system (CRS) definitions, including any user-defined CRSes.
This class represents a coordinate reference system (CRS).
QString toProj() const
Returns a Proj string representation of this CRS.
QString ellipsoidAcronym() const
Returns the ellipsoid acronym for the ellipsoid used by the CRS.
QString description() const
Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94".
QString projectionAcronym() const
Returns the projection acronym for the projection used by the CRS.
CrsType
Enumeration of types of IDs accepted in createFromId() method.
@ InternalCrsId
Internal ID used by QGIS in the local SQLite database.
@ PostgisCrsId
SRID used in PostGIS. DEPRECATED – DO NOT USE.
IdentifierType
Type of identifier string to create.
@ MediumString
A medium-length string, recommended for general purpose use.
@ FullString
Full definition – possibly a very lengthy string, e.g. with no truncation of custom WKT definitions.
@ ShortString
A heavily abbreviated string, for use when a compact representation is required.
Format
Projection definition formats.
@ FormatProj
Proj string format.
WktVariant
WKT formatting variants, only used for builds based on Proj >= 6.
@ WKT1_GDAL
WKT1 as traditionally output by GDAL, deriving from OGC 01-009. A notable departure from WKT1_GDAL wi...
@ WKT2_2018_SIMPLIFIED
Alias for WKT2_2019_SIMPLIFIED.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
@ WKT2_2015
Full WKT2 string, conforming to ISO 19162:2015(E) / OGC 12-063r5 with all possible nodes and new keyw...
@ WKT2_2018
Alias for WKT2_2019.
@ WKT1_ESRI
WKT1 as traditionally output by ESRI software, deriving from OGC 99-049.
@ WKT2_2015_SIMPLIFIED
Same as WKT2_2015 with the following exceptions: UNIT keyword used. ID node only on top element....
Used to create and store a proj context object, correctly freeing the context upon destruction.
A rectangle specified with double values.
Helper functions for various unit types.
DistanceUnit
Units of distance.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
void * OGRSpatialReferenceH
std::ostream & operator<<(std::ostream &os, const QgsCoordinateReferenceSystem &r)
Output stream operator.
void(* CUSTOM_CRS_VALIDATION)(QgsCoordinateReferenceSystem &)
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
const QgsCoordinateReferenceSystem & crs