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;
203 Q_PROPERTY(
bool isGeographic READ isGeographic )
256 operator QVariant()
const 258 return QVariant::fromValue( *
this );
268 static QList< long > validSrsIds();
327 bool createFromId(
long id,
CrsType type = PostgisCrsId );
341 bool createFromOgcWmsCrs(
const QString &
crs );
350 bool createFromSrid(
long srid );
365 bool createFromWkt(
const QString &wkt );
377 bool createFromSrsId(
long srsId );
402 bool createFromProj4(
const QString &projString );
418 bool createFromString(
const QString &definition );
435 bool createFromUserInput(
const QString &definition );
446 static void setupESRIWktFix();
449 bool isValid()
const;
473 long findMatchingProj();
495 bool readXml(
const QDomNode &node );
503 bool writeXml( QDomNode &node, QDomDocument &doc )
const;
532 long postgisSrid()
const;
546 QString authid()
const;
556 QString description()
const;
564 QString projectionAcronym()
const;
572 QString ellipsoidAcronym()
const;
596 QString toWkt(
WktVariant variant = WKT1_GDAL,
bool multiline =
false,
int indentationWidth = 4 )
const;
608 QString toProj4()
const;
614 bool isGeographic()
const;
620 bool hasAxisInverted()
const;
642 void setValidationHint(
const QString &html );
647 QString validationHint();
655 static int syncDatabase();
663 long saveAsUserCrs(
const QString &name );
666 QString geographicCrsAuthId()
const;
669 SIP_PYOBJECT __repr__();
671 QString str = QStringLiteral(
"<QgsCoordinateReferenceSystem: %1>" ).arg( sipCpp->authid() );
672 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
677 #if PROJ_VERSION_MAJOR>=6 688 PJ *projObject()
const;
697 static QStringList recentProjections();
711 static void invalidateCache(
bool disableCache =
false );
721 static void invalidateCache(
bool disableCache
SIP_PYARGREMOVE =
false );
734 static QString proj4FromSrsId(
int srsId );
740 void setInternalId(
long srsId );
746 void setSrid(
long srid );
752 void setDescription(
const QString &description );
765 void setProj4String(
const QString &proj4String );
771 void setGeographicFlag(
bool geoFlag );
777 void setEpsg(
long epsg );
783 void setAuthId(
const QString &theID );
789 void setProjectionAcronym(
const QString &projectionAcronym );
795 void setEllipsoidAcronym(
const QString &ellipsoidAcronym );
803 typedef QMap<QString, QString> RecordMap;
812 RecordMap getRecord(
const QString &sql );
824 long getRecordCount();
826 #if PROJ_VERSION_MAJOR>=6 827 bool loadFromAuthCode(
const QString &auth,
const QString &code );
834 bool loadFromDatabase(
const QString &db,
const QString &expression,
const QString &value );
836 #if PROJ_VERSION_MAJOR<6 // not used for proj >= 6.0 837 static bool loadIds( QHash<int, QString> &wkts );
838 static bool loadWkts( QHash<int, QString> &wkts,
const char *filename );
841 static bool syncDatumTransform(
const QString &dbPath );
844 QExplicitlySharedDataPointer<QgsCoordinateReferenceSystemPrivate> d;
852 static QReadWriteLock sSrIdCacheLock;
853 static QHash< long, QgsCoordinateReferenceSystem > sSrIdCache;
854 static bool sDisableSrIdCache;
856 static QReadWriteLock sOgcLock;
857 static QHash< QString, QgsCoordinateReferenceSystem > sOgcCache;
858 static bool sDisableOgcCache;
860 static QReadWriteLock sProj4CacheLock;
861 static QHash< QString, QgsCoordinateReferenceSystem > sProj4Cache;
862 static bool sDisableProj4Cache;
864 static QReadWriteLock sCRSWktLock;
865 static QHash< QString, QgsCoordinateReferenceSystem > sWktCache;
866 static bool sDisableWktCache;
868 static QReadWriteLock sCRSSrsIdLock;
869 static QHash< long, QgsCoordinateReferenceSystem > sSrsIdCache;
870 static bool sDisableSrsIdCache;
872 static QReadWriteLock sCrsStringLock;
873 static QHash< QString, QgsCoordinateReferenceSystem > sStringCache;
874 static bool sDisableStringCache;
876 friend class TestQgsCoordinateReferenceSystem;
885 QString mySummary( QStringLiteral(
"\n\tSpatial Reference System:" ) );
886 mySummary += QLatin1String(
"\n\t\tDescription : " );
893 mySummary += QLatin1String(
"Undefined" );
895 mySummary += QLatin1String(
"\n\t\tProjection : " );
902 mySummary += QLatin1String(
"Undefined" );
905 mySummary += QLatin1String(
"\n\t\tEllipsoid : " );
912 mySummary += QLatin1String(
"Undefined" );
915 mySummary += QLatin1String(
"\n\t\tProj4String : " );
922 mySummary += QLatin1String(
"Undefined" );
925 return os << mySummary.toLocal8Bit().data() << std::endl;
929 #endif // QGSCOORDINATEREFERENCESYSTEM_H A rectangle specified with double values.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QString toProj4() const
Returns a Proj4 string representation of this CRS.
Full WKT2 string, conforming to ISO 19162:2015(E) / OGC 12-063r5 with all possible nodes and new keyw...
const QgsCoordinateReferenceSystem & crs
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...
QString ellipsoidAcronym() const
Returns the ellipsoid acronym for the ellipsoid used by the CRS.
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)
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 ...
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).
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.