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();
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;
713 Q_DECL_DEPRECATED QString toProj4() const SIP_DEPRECATED;
727 QString toProj() const;
733 bool isGeographic() const;
739 bool hasAxisInverted() const;
761 void setValidationHint( const QString &html );
766 QString validationHint();
774 static
int syncDatabase();
787 long saveAsUserCrs( const QString &name,
Format nativeFormat = FormatWkt );
790 QString geographicCrsAuthId() const;
793 SIP_PYOBJECT __repr__();
795 const QString str = sipCpp->isValid() ? QStringLiteral(
"<QgsCoordinateReferenceSystem: %1>" ).arg( !sipCpp->authid().isEmpty() ? sipCpp->authid() : sipCpp->toWkt(
QgsCoordinateReferenceSystem::WKT_PREFERRED ) )
796 : QStringLiteral(
"<QgsCoordinateReferenceSystem: invalid>" );
797 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
802 #if PROJ_VERSION_MAJOR>=6 813 PJ *projObject()
const;
822 Q_DECL_DEPRECATED
static QStringList recentProjections() SIP_DEPRECATED;
848 static void invalidateCache(
bool disableCache =
false );
858 static void invalidateCache(
bool disableCache
SIP_PYARGREMOVE =
false );
871 static QString projFromSrsId(
int srsId );
878 void setProjString(
const QString &projString );
883 bool setWktString(
const QString &wkt,
bool allowProjFallback =
true );
891 typedef QMap<QString, QString> RecordMap;
900 RecordMap getRecord(
const QString &sql );
912 long getRecordCount();
914 #if PROJ_VERSION_MAJOR>=6 915 bool loadFromAuthCode(
const QString &auth,
const QString &code );
920 static QList< long > userSrsIds();
929 long matchToUserCrs()
const;
936 bool loadFromDatabase(
const QString &db,
const QString &expression,
const QString &value );
938 bool createFromWktInternal(
const QString &wkt,
const QString &description );
940 #if PROJ_VERSION_MAJOR<6 // not used for proj >= 6.0 941 static bool loadIds( QHash<int, QString> &wkts );
942 static bool loadWkts( QHash<int, QString> &wkts,
const char *filename );
945 static bool syncDatumTransform(
const QString &dbPath );
948 QExplicitlySharedDataPointer<QgsCoordinateReferenceSystemPrivate> d;
950 QString mValidationHint;
952 #if PROJ_VERSION_MAJOR>=6 956 static void removeFromCacheObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context );
964 static bool sDisableSrIdCache;
965 static bool sDisableOgcCache;
966 static bool sDisableProjCache;
967 static bool sDisableWktCache;
968 static bool sDisableSrsIdCache;
969 static bool sDisableStringCache;
972 static const QHash< QString, QgsCoordinateReferenceSystem > &stringCache();
973 static const QHash< QString, QgsCoordinateReferenceSystem > &projCache();
974 static const QHash< QString, QgsCoordinateReferenceSystem > &ogcCache();
975 static const QHash< QString, QgsCoordinateReferenceSystem > &wktCache();
976 static const QHash< long, QgsCoordinateReferenceSystem > &srsIdCache();
977 static const QHash< long, QgsCoordinateReferenceSystem > &srIdCache();
979 friend class TestQgsCoordinateReferenceSystem;
980 friend class QgsPostgresProvider;
982 bool createFromPostgisSrid(
const long id );
991 QString mySummary( QStringLiteral(
"\n\tSpatial Reference System:" ) );
992 mySummary += QLatin1String(
"\n\t\tDescription : " );
999 mySummary += QLatin1String(
"Undefined" );
1001 mySummary += QLatin1String(
"\n\t\tProjection : " );
1008 mySummary += QLatin1String(
"Undefined" );
1011 mySummary += QLatin1String(
"\n\t\tEllipsoid : " );
1018 mySummary += QLatin1String(
"Undefined" );
1021 mySummary += QLatin1String(
"\n\t\tProjString : " );
1022 if ( !r.
toProj().isNull() )
1028 mySummary += QLatin1String(
"Undefined" );
1031 return os << mySummary.toLocal8Bit().data() << std::endl;
1035 #endif // QGSCOORDINATEREFERENCESYSTEM_H A rectangle specified with double values.
QString toProj() const
Returns a Proj string representation of this CRS.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Helper functions for various unit types.
Full WKT2 string, conforming to ISO 19162:2015(E) / OGC 12-063r5 with all possible nodes and new keyw...
SRID used in PostGIS. DEPRECATED – DO NOT USE.
const QgsCoordinateReferenceSystem & crs
Full definition – possibly a very lengthy string, e.g. with no truncation of custom WKT definitions...
Alias for WKT2_2019_SIMPLIFIED.
Internal ID used by QGIS in the local SQLite database.
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...
QString ellipsoidAcronym() const
Returns the ellipsoid acronym for the ellipsoid used by the CRS.
Format
Projection definition formats.
WKT1 as traditionally output by GDAL, deriving from OGC 01-009. A notable departure from WKT1_GDAL wi...
QString description() const
Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94".
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
IdentifierType
Type of identifier string to create.
std::ostream & operator<<(std::ostream &os, const QgsCoordinateReferenceSystem &r)
Output stream operator.
CrsType
Enumeration of types of IDs accepted in createFromId() method.
A medium-length string, recommended for general purpose use.
QString projectionAcronym() const
Returns the projection acronym for the projection used by the CRS.
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019...
DistanceUnit
Units of distance.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
This class represents a coordinate reference system (CRS).
A heavily abbreviated string, for use when a compact representation is required.
WktVariant
WKT formatting variants, only used for builds based on Proj >= 6.
void(* CUSTOM_CRS_VALIDATION)(QgsCoordinateReferenceSystem &)
void * OGRSpatialReferenceH
WKT1 as traditionally output by ESRI software, deriving from OGC 99-049.