18 #ifndef QGSCOORDINATEREFERENCESYSTEM_H
19 #define QGSCOORDINATEREFERENCESYSTEM_H
22 #include "qgis_core.h"
29 #include <QReadWriteLock>
30 #include <QExplicitlySharedDataPointer>
41 class QgsCoordinateReferenceSystemPrivate;
48 typedef struct PJconsts
PJ;
50 #if PROJ_VERSION_MAJOR>=8
215 Q_PROPERTY(
bool isGeographic READ isGeographic )
280 operator QVariant()
const
282 return QVariant::fromValue( *
this );
292 static QList< long > validSrsIds();
358 Q_DECL_DEPRECATED
bool createFromId(
long id, CrsType type = PostgisCrsId )
SIP_DEPRECATED;
372 bool createFromOgcWmsCrs(
const QString &
crs );
383 Q_DECL_DEPRECATED
bool createFromSrid(
long srid )
SIP_DEPRECATED;
397 bool createFromWkt(
const QString &wkt );
411 bool createFromSrsId(
long srsId );
436 Q_DECL_DEPRECATED
bool createFromProj4(
const QString &projString )
SIP_DEPRECATED;
466 bool createFromProj(
const QString &projString,
bool identify =
true );
468 bool createFromProj(
const QString &projString );
486 bool createFromString(
const QString &definition );
505 bool createFromUserInput(
const QString &definition );
520 bool isValid() const;
567 bool readXml( const QDomNode &node );
575 bool writeXml( QDomNode &node, QDomDocument &doc ) const;
604 long postgisSrid() const;
618 QString authid() const;
627 QString description() const;
654 QString userFriendlyIdentifier( IdentifierType type = MediumString )
const;
662 QString projectionAcronym()
const;
670 QString ellipsoidAcronym()
const;
681 WKT2_2019 = WKT2_2018,
682 WKT2_2019_SIMPLIFIED = WKT2_2018_SIMPLIFIED,
684 WKT_PREFERRED = WKT2_2019,
685 WKT_PREFERRED_SIMPLIFIED = WKT2_2019_SIMPLIFIED,
686 WKT_PREFERRED_GDAL = WKT2_2019,
700 QString toWkt( WktVariant variant = WKT1_GDAL,
bool multiline =
false,
int indentationWidth = 4 )
const;
728 QString toProj() const;
734 bool isGeographic() const;
744 bool isDynamic() const;
794 void setCoordinateEpoch(
double epoch );
819 double coordinateEpoch() const;
846 bool hasAxisInverted() const;
881 void updateDefinition();
886 void setValidationHint( const QString &html );
891 QString validationHint();
899 static
int syncDatabase();
914 long saveAsUserCrs( const QString &name, Format nativeFormat = FormatWkt );
917 QString geographicCrsAuthId() const;
920 SIP_PYOBJECT __repr__();
923 std::isfinite( sipCpp->coordinateEpoch() ) ? QStringLiteral(
" @ %1" ).arg( sipCpp->coordinateEpoch() ) : QString() )
924 : QStringLiteral(
"<QgsCoordinateReferenceSystem: invalid>" );
925 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
940 PJ *projObject()
const;
948 Q_DECL_DEPRECATED
static QStringList recentProjections()
SIP_DEPRECATED;
974 static void invalidateCache(
bool disableCache =
false );
984 static void invalidateCache(
bool disableCache
SIP_PYARGREMOVE =
false );
997 static QString projFromSrsId(
int srsId );
1004 void setProjString(
const QString &projString );
1009 bool setWktString(
const QString &wkt );
1017 typedef QMap<QString, QString> RecordMap;
1026 RecordMap getRecord(
const QString &sql );
1038 static long getRecordCount();
1040 bool loadFromAuthCode(
const QString &auth,
const QString &code );
1045 static QList< long > userSrsIds();
1054 long matchToUserCrs()
const;
1060 bool loadFromDatabase(
const QString &db,
const QString &expression,
const QString &value );
1062 bool createFromWktInternal(
const QString &wkt,
const QString &description );
1064 QExplicitlySharedDataPointer<QgsCoordinateReferenceSystemPrivate> d;
1066 QString mValidationHint;
1071 static void removeFromCacheObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context );
1078 static bool sDisableSrIdCache;
1079 static bool sDisableOgcCache;
1080 static bool sDisableProjCache;
1081 static bool sDisableWktCache;
1082 static bool sDisableSrsIdCache;
1083 static bool sDisableStringCache;
1086 static const QHash< QString, QgsCoordinateReferenceSystem > &stringCache();
1087 static const QHash< QString, QgsCoordinateReferenceSystem > &projCache();
1088 static const QHash< QString, QgsCoordinateReferenceSystem > &ogcCache();
1089 static const QHash< QString, QgsCoordinateReferenceSystem > &wktCache();
1090 static const QHash< long, QgsCoordinateReferenceSystem > &srsIdCache();
1091 static const QHash< long, QgsCoordinateReferenceSystem > &srIdCache();
1093 friend class TestQgsCoordinateReferenceSystem;
1100 bool createFromPostgisSrid(
const long id );
1109 QString mySummary( QStringLiteral(
"\n\tSpatial Reference System:" ) );
1110 mySummary += QLatin1String(
"\n\t\tDescription : " );
1117 mySummary += QLatin1String(
"Undefined" );
1119 mySummary += QLatin1String(
"\n\t\tProjection : " );
1126 mySummary += QLatin1String(
"Undefined" );
1129 mySummary += QLatin1String(
"\n\t\tEllipsoid : " );
1136 mySummary += QLatin1String(
"Undefined" );
1139 mySummary += QLatin1String(
"\n\t\tProjString : " );
1140 if ( !r.
toProj().isNull() )
1146 mySummary += QLatin1String(
"Undefined" );
1149 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....
Contains information about a datum ensemble.
Custom exception class which is raised when an operation is not supported.
Point geometry type, with support for z-dimension and m-values.
Used to create and store a proj context object, correctly freeing the context upon destruction.
Contains information about a PROJ operation.
contains various cartographic properties, such as scale factors, angular distortion and meridian conv...
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