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;
207 Q_PROPERTY(
bool isGeographic READ isGeographic )
269 operator QVariant()
const 271 return QVariant::fromValue( *
this );
281 static QList< long > validSrsIds();
361 bool createFromOgcWmsCrs(
const QString &
crs );
372 Q_DECL_DEPRECATED
bool createFromSrid(
long srid )
SIP_DEPRECATED;
386 bool createFromWkt(
const QString &wkt );
400 bool createFromSrsId(
long srsId );
427 Q_DECL_DEPRECATED
bool createFromProj4(
const QString &projString )
SIP_DEPRECATED;
454 bool createFromProj(
const QString &projString );
470 bool createFromString(
const QString &definition );
487 bool createFromUserInput(
const QString &definition );
502 bool isValid()
const;
549 bool readXml(
const QDomNode &node );
557 bool writeXml( QDomNode &node, QDomDocument &doc )
const;
586 long postgisSrid()
const;
600 QString authid()
const;
609 QString description()
const;
636 QString userFriendlyIdentifier(
IdentifierType type = MediumString )
const;
644 QString projectionAcronym()
const;
652 QString ellipsoidAcronym()
const;
676 QString toWkt(
WktVariant variant = WKT1_GDAL,
bool multiline =
false,
int indentationWidth = 4 )
const;
690 Q_DECL_DEPRECATED QString toProj4() const SIP_DEPRECATED;
704 QString toProj() const;
710 bool isGeographic() const;
716 bool hasAxisInverted() const;
738 void setValidationHint( const QString &html );
743 QString validationHint();
751 static
int syncDatabase();
764 long saveAsUserCrs( const QString &name,
Format nativeFormat = FormatWkt );
767 QString geographicCrsAuthId() const;
770 SIP_PYOBJECT __repr__();
772 QString str = QStringLiteral(
"<QgsCoordinateReferenceSystem: %1>" ).arg( sipCpp->authid() );
773 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
778 #if PROJ_VERSION_MAJOR>=6 789 PJ *projObject()
const;
798 Q_DECL_DEPRECATED
static QStringList recentProjections() SIP_DEPRECATED;
824 static void invalidateCache(
bool disableCache =
false );
834 static void invalidateCache(
bool disableCache
SIP_PYARGREMOVE =
false );
847 static QString projFromSrsId(
int srsId );
854 void setProjString(
const QString &projString );
859 bool setWktString(
const QString &wkt,
bool allowProjFallback =
true );
867 typedef QMap<QString, QString> RecordMap;
876 RecordMap getRecord(
const QString &sql );
888 long getRecordCount();
890 #if PROJ_VERSION_MAJOR>=6 891 bool loadFromAuthCode(
const QString &auth,
const QString &code );
896 static QList< long > userSrsIds();
905 long matchToUserCrs()
const;
912 bool loadFromDatabase(
const QString &db,
const QString &expression,
const QString &value );
914 #if PROJ_VERSION_MAJOR<6 // not used for proj >= 6.0 915 static bool loadIds( QHash<int, QString> &wkts );
916 static bool loadWkts( QHash<int, QString> &wkts,
const char *filename );
919 static bool syncDatumTransform(
const QString &dbPath );
922 QExplicitlySharedDataPointer<QgsCoordinateReferenceSystemPrivate> d;
924 QString mValidationHint;
926 #if PROJ_VERSION_MAJOR>=6 930 static void removeFromCacheObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context );
938 static bool sDisableSrIdCache;
939 static bool sDisableOgcCache;
940 static bool sDisableProjCache;
941 static bool sDisableWktCache;
942 static bool sDisableSrsIdCache;
943 static bool sDisableStringCache;
946 static const QHash< QString, QgsCoordinateReferenceSystem > &stringCache();
947 static const QHash< QString, QgsCoordinateReferenceSystem > &projCache();
948 static const QHash< QString, QgsCoordinateReferenceSystem > &ogcCache();
949 static const QHash< QString, QgsCoordinateReferenceSystem > &wktCache();
950 static const QHash< long, QgsCoordinateReferenceSystem > &srsIdCache();
951 static const QHash< long, QgsCoordinateReferenceSystem > &srIdCache();
953 friend class TestQgsCoordinateReferenceSystem;
954 friend class QgsPostgresProvider;
956 bool createFromPostgisSrid(
const long id );
965 QString mySummary( QStringLiteral(
"\n\tSpatial Reference System:" ) );
966 mySummary += QLatin1String(
"\n\t\tDescription : " );
973 mySummary += QLatin1String(
"Undefined" );
975 mySummary += QLatin1String(
"\n\t\tProjection : " );
982 mySummary += QLatin1String(
"Undefined" );
985 mySummary += QLatin1String(
"\n\t\tEllipsoid : " );
992 mySummary += QLatin1String(
"Undefined" );
995 mySummary += QLatin1String(
"\n\t\tProjString : " );
996 if ( !r.
toProj().isNull() )
1002 mySummary += QLatin1String(
"Undefined" );
1005 return os << mySummary.toLocal8Bit().data() << std::endl;
1009 #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...
WKT2_2018 with the simplification rule of WKT2_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.
Full WKT2 string, conforming to ISO 19162:2018 / OGC 18-010, with all possible nodes and new keyword ...
A medium-length string, recommended for general purpose use.
QString projectionAcronym() const
Returns the projection acronym for the projection used by the CRS.
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.