18 #ifndef QGSCOORDINATEREFERENCESYSTEM_H
19 #define QGSCOORDINATEREFERENCESYSTEM_H
22 #include "qgis_core.h"
29 #include <QReadWriteLock>
30 #include <QExplicitlySharedDataPointer>
41 class QgsCoordinateReferenceSystemPrivate;
45 typedef struct PJconsts
PJ;
47 #if PROJ_VERSION_MAJOR>=8
212 Q_PROPERTY(
bool isGeographic READ isGeographic )
277 operator QVariant()
const
279 return QVariant::fromValue( *
this );
289 static QList< long > validSrsIds();
355 Q_DECL_DEPRECATED
bool createFromId(
long id, CrsType type = PostgisCrsId )
SIP_DEPRECATED;
369 bool createFromOgcWmsCrs(
const QString &
crs );
380 Q_DECL_DEPRECATED
bool createFromSrid(
long srid )
SIP_DEPRECATED;
394 bool createFromWkt(
const QString &wkt );
408 bool createFromSrsId(
long srsId );
433 Q_DECL_DEPRECATED
bool createFromProj4(
const QString &projString )
SIP_DEPRECATED;
463 bool createFromProj(
const QString &projString,
bool identify =
true );
465 bool createFromProj(
const QString &projString );
483 bool createFromString(
const QString &definition );
502 bool createFromUserInput(
const QString &definition );
517 bool isValid() const;
564 bool readXml( const QDomNode &node );
572 bool writeXml( QDomNode &node, QDomDocument &doc ) const;
601 long postgisSrid() const;
615 QString authid() const;
624 QString description() const;
651 QString userFriendlyIdentifier( IdentifierType type = MediumString )
const;
659 QString projectionAcronym()
const;
667 QString ellipsoidAcronym()
const;
678 WKT2_2019 = WKT2_2018,
679 WKT2_2019_SIMPLIFIED = WKT2_2018_SIMPLIFIED,
681 WKT_PREFERRED = WKT2_2019,
682 WKT_PREFERRED_SIMPLIFIED = WKT2_2019_SIMPLIFIED,
683 WKT_PREFERRED_GDAL = WKT2_2019,
697 QString toWkt( WktVariant variant = WKT1_GDAL,
bool multiline =
false,
int indentationWidth = 4 )
const;
725 QString toProj() const;
731 bool isGeographic() const;
737 bool hasAxisInverted() const;
772 void updateDefinition();
777 void setValidationHint( const QString &html );
782 QString validationHint();
790 static
int syncDatabase();
805 long saveAsUserCrs( const QString &name, Format nativeFormat = FormatWkt );
808 QString geographicCrsAuthId() const;
811 SIP_PYOBJECT __repr__();
814 : QStringLiteral(
"<QgsCoordinateReferenceSystem: invalid>" );
815 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
830 PJ *projObject()
const;
838 Q_DECL_DEPRECATED
static QStringList recentProjections()
SIP_DEPRECATED;
864 static void invalidateCache(
bool disableCache =
false );
874 static void invalidateCache(
bool disableCache
SIP_PYARGREMOVE =
false );
887 static QString projFromSrsId(
int srsId );
894 void setProjString(
const QString &projString );
899 bool setWktString(
const QString &wkt );
907 typedef QMap<QString, QString> RecordMap;
916 RecordMap getRecord(
const QString &sql );
928 static long getRecordCount();
930 bool loadFromAuthCode(
const QString &auth,
const QString &code );
935 static QList< long > userSrsIds();
944 long matchToUserCrs()
const;
950 bool loadFromDatabase(
const QString &db,
const QString &expression,
const QString &value );
952 bool createFromWktInternal(
const QString &wkt,
const QString &description );
954 QExplicitlySharedDataPointer<QgsCoordinateReferenceSystemPrivate> d;
956 QString mValidationHint;
961 static void removeFromCacheObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context );
968 static bool sDisableSrIdCache;
969 static bool sDisableOgcCache;
970 static bool sDisableProjCache;
971 static bool sDisableWktCache;
972 static bool sDisableSrsIdCache;
973 static bool sDisableStringCache;
976 static const QHash< QString, QgsCoordinateReferenceSystem > &stringCache();
977 static const QHash< QString, QgsCoordinateReferenceSystem > &projCache();
978 static const QHash< QString, QgsCoordinateReferenceSystem > &ogcCache();
979 static const QHash< QString, QgsCoordinateReferenceSystem > &wktCache();
980 static const QHash< long, QgsCoordinateReferenceSystem > &srsIdCache();
981 static const QHash< long, QgsCoordinateReferenceSystem > &srIdCache();
983 friend class TestQgsCoordinateReferenceSystem;
984 friend class QgsPostgresProvider;
991 bool createFromPostgisSrid(
const long id );
1000 QString mySummary( QStringLiteral(
"\n\tSpatial Reference System:" ) );
1001 mySummary += QLatin1String(
"\n\t\tDescription : " );
1008 mySummary += QLatin1String(
"Undefined" );
1010 mySummary += QLatin1String(
"\n\t\tProjection : " );
1017 mySummary += QLatin1String(
"Undefined" );
1020 mySummary += QLatin1String(
"\n\t\tEllipsoid : " );
1027 mySummary += QLatin1String(
"Undefined" );
1030 mySummary += QLatin1String(
"\n\t\tProjString : " );
1031 if ( !r.
toProj().isNull() )
1037 mySummary += QLatin1String(
"Undefined" );
1040 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
bool CORE_EXPORT operator<(const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2)
bool CORE_EXPORT operator>(const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2)
bool CORE_EXPORT operator<=(const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2)
std::ostream & operator<<(std::ostream &os, const QgsCoordinateReferenceSystem &r)
Output stream operator.
struct projCtx_t PJ_CONTEXT
bool CORE_EXPORT operator>=(const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2)
void(* CUSTOM_CRS_VALIDATION)(QgsCoordinateReferenceSystem &)
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
const QgsCoordinateReferenceSystem & crs