18#ifndef QGSCOORDINATEREFERENCESYSTEM_H
19#define QGSCOORDINATEREFERENCESYSTEM_H
29#include <QReadWriteLock>
30#include <QExplicitlySharedDataPointer>
42class QgsCoordinateReferenceSystemPrivate;
49typedef struct PJconsts
PJ;
51#if PROJ_VERSION_MAJOR>=8
216 Q_PROPERTY(
bool isGeographic READ isGeographic )
217 Q_PROPERTY( QString authid READ authid )
218 Q_PROPERTY( QString description READ description )
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 );
501 bool createFromUserInput(
const QString &definition );
516 bool isValid() const;
563 bool readXml( const QDomNode &node );
571 bool writeXml( QDomNode &node, QDomDocument &doc ) const;
600 long postgisSrid() const;
614 QString authid() const;
623 QString description() const;
650 QString userFriendlyIdentifier( IdentifierType type = MediumString )
const;
658 QString projectionAcronym()
const;
666 QString ellipsoidAcronym()
const;
677 WKT2_2019 = WKT2_2018,
678 WKT2_2019_SIMPLIFIED = WKT2_2018_SIMPLIFIED,
680 WKT_PREFERRED = WKT2_2019,
681 WKT_PREFERRED_SIMPLIFIED = WKT2_2019_SIMPLIFIED,
682 WKT_PREFERRED_GDAL = WKT2_2019,
696 QString toWkt( WktVariant variant = WKT1_GDAL,
bool multiline =
false,
int indentationWidth = 4 )
const;
724 QString toProj() const;
731 Qgis::CrsType type() const;
737 bool isGeographic() const;
747 bool isDynamic() const;
799 void setCoordinateEpoch(
double epoch );
824 double coordinateEpoch() const;
862 QList< Qgis::CrsAxisDirection > axisOrdering()
const;
864 SIP_PYOBJECT axisOrdering() const
SIP_TYPEHINT( List[
Qgis.CrsAxisDirection] );
868 const QList<
Qgis::CrsAxisDirection > cppRes = sipCpp->axisOrdering();
870 PyObject *l = PyList_New( cppRes.size() );
876 for (
int i = 0; i < cppRes.size(); ++i )
878 PyObject *eobj = sipConvertFromEnum(
static_cast<int>( cppRes.at( i ) ),
879 sipType_Qgis_CrsAxisDirection );
886 PyList_SetItem( l, i, eobj );
924 QString toOgcUri()
const;
944 void updateDefinition();
949 void setValidationHint(
const QString &html );
954 QString validationHint()
const;
962 static int syncDatabase();
1013 QString geographicCrsAuthId()
const;
1016 SIP_PYOBJECT __repr__();
1018 const QString
str = sipCpp->isValid() ? QStringLiteral(
"<QgsCoordinateReferenceSystem: %1%2>" ).arg( !sipCpp->authid().isEmpty() ? sipCpp->authid() : sipCpp->toWkt(
QgsCoordinateReferenceSystem::WKT_PREFERRED ),
1019 std::isfinite( sipCpp->coordinateEpoch() ) ? QStringLiteral(
" @ %1" ).arg( sipCpp->coordinateEpoch() ) : QString() )
1020 : QStringLiteral(
"<QgsCoordinateReferenceSystem: invalid>" );
1021 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
1036 PJ *projObject()
const;
1058 bool createFromProjObject(
PJ *
object );
1066 Q_DECL_DEPRECATED
static QStringList recentProjections()
SIP_DEPRECATED;
1090 static
void clearRecentCoordinateReferenceSystems();
1104 static void invalidateCache(
bool disableCache =
false );
1114 static void invalidateCache(
bool disableCache
SIP_PYARGREMOVE =
false );
1127 static QString projFromSrsId(
int srsId );
1134 void setProjString(
const QString &projString );
1139 bool setWktString(
const QString &wkt );
1147 typedef QMap<QString, QString> RecordMap;
1156 RecordMap getRecord(
const QString &sql );
1168 static long getRecordCount();
1170 bool loadFromAuthCode(
const QString &auth,
const QString &code );
1175 static QList< long > userSrsIds();
1184 long matchToUserCrs()
const;
1190 bool loadFromDatabase(
const QString &db,
const QString &expression,
const QString &value );
1192 bool createFromWktInternal(
const QString &wkt,
const QString &description );
1194 QExplicitlySharedDataPointer<QgsCoordinateReferenceSystemPrivate> d;
1196 QString mValidationHint;
1203 static void removeFromCacheObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context );
1210 static bool sDisableSrIdCache;
1211 static bool sDisableOgcCache;
1212 static bool sDisableProjCache;
1213 static bool sDisableWktCache;
1214 static bool sDisableSrsIdCache;
1215 static bool sDisableStringCache;
1218 static const QHash< QString, QgsCoordinateReferenceSystem > &stringCache();
1219 static const QHash< QString, QgsCoordinateReferenceSystem > &projCache();
1220 static const QHash< QString, QgsCoordinateReferenceSystem > &ogcCache();
1221 static const QHash< QString, QgsCoordinateReferenceSystem > &wktCache();
1222 static const QHash< long, QgsCoordinateReferenceSystem > &srsIdCache();
1223 static const QHash< long, QgsCoordinateReferenceSystem > &srIdCache();
1225 friend class TestQgsCoordinateReferenceSystem;
1232 bool createFromPostgisSrid(
const long id );
1241 QString mySummary( QStringLiteral(
"\n\tSpatial Reference System:" ) );
1242 mySummary += QLatin1String(
"\n\t\tDescription : " );
1249 mySummary += QLatin1String(
"Undefined" );
1251 mySummary += QLatin1String(
"\n\t\tProjection : " );
1258 mySummary += QLatin1String(
"Undefined" );
1261 mySummary += QLatin1String(
"\n\t\tEllipsoid : " );
1268 mySummary += QLatin1String(
"Undefined" );
1271 mySummary += QLatin1String(
"\n\t\tProjString : " );
1272 if ( !r.
toProj().isNull() )
1278 mySummary += QLatin1String(
"Undefined" );
1281 return os << mySummary.toLocal8Bit().data() << std::endl;
The Qgis class provides global constants for use throughout the application.
DistanceUnit
Units of distance.
CrsDefinitionFormat
CRS definition formats.
@ Wkt
WKT format (always recommended over proj string format)
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 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.
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.
@ 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.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
bool operator>(const QVariant &v1, const QVariant &v2)
Compares two QVariant values and returns whether the first is greater than the second.
bool operator<(const QVariant &v1, const QVariant &v2)
Compares two QVariant values and returns whether the first is less than the second.
#define SIP_TYPEHINT(type)
#define SIP_THROW(name,...)
bool operator>=(const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2)
bool operator<=(const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2)
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)
struct projCtx_t PJ_CONTEXT
bool CORE_EXPORT operator>=(const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2)
void(* CUSTOM_CRS_VALIDATION)(QgsCoordinateReferenceSystem &)
std::ostream & operator<<(std::ostream &os, const QgsCoordinateReferenceSystem &r)
Output stream operator.
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
const QgsCoordinateReferenceSystem & crs