QGIS API Documentation
3.18.1-Zürich (202f1bf7e5)
|
This class represents a coordinate reference system (CRS). More...
#include <qgscoordinatereferencesystem.h>
Public Types | |
enum | CrsType { InternalCrsId , PostgisCrsId , EpsgCrsId } |
Enumeration of types of IDs accepted in createFromId() method. More... | |
enum | Format { FormatWkt = 0 , FormatProj } |
Projection definition formats. More... | |
enum | IdentifierType { ShortString , MediumString , FullString } |
Type of identifier string to create. More... | |
enum | WktVariant { WKT1_GDAL , WKT1_ESRI , WKT2_2015 , WKT2_2015_SIMPLIFIED , WKT2_2018 , WKT2_2018_SIMPLIFIED , WKT2_2019 = WKT2_2018 , WKT2_2019_SIMPLIFIED = WKT2_2018_SIMPLIFIED , WKT_PREFERRED = WKT2_2019 , WKT_PREFERRED_SIMPLIFIED = WKT2_2019_SIMPLIFIED , WKT_PREFERRED_GDAL = WKT2_2019 } |
WKT formatting variants, only used for builds based on Proj >= 6. More... | |
Public Member Functions | |
QgsCoordinateReferenceSystem () | |
Constructs an invalid CRS object. More... | |
QgsCoordinateReferenceSystem (const QgsCoordinateReferenceSystem &srs) | |
Copy constructor. More... | |
QgsCoordinateReferenceSystem (const QString &definition) | |
Constructs a CRS object from a string definition using createFromString() More... | |
Q_DECL_DEPRECATED | QgsCoordinateReferenceSystem (long id, CrsType type=PostgisCrsId) |
Constructor. More... | |
~QgsCoordinateReferenceSystem () | |
QString | authid () const |
Returns the authority identifier for the CRS. More... | |
QgsRectangle | bounds () const |
Returns the approximate bounds for the region the CRS is usable within. More... | |
Q_DECL_DEPRECATED bool | createFromId (long id, CrsType type=PostgisCrsId) |
Sets this CRS by lookup of the given ID in the CRS database. More... | |
bool | createFromOgcWmsCrs (const QString &crs) |
Sets this CRS to the given OGC WMS-format Coordinate Reference Systems. More... | |
bool | createFromProj (const QString &projString, bool identify=true) |
Sets this CRS by passing it a PROJ style formatted string. More... | |
Q_DECL_DEPRECATED bool | createFromProj4 (const QString &projString) |
Sets this CRS by passing it a PROJ style formatted string. More... | |
Q_DECL_DEPRECATED bool | createFromSrid (long srid) |
Sets this CRS by lookup of the given PostGIS SRID in the CRS database. More... | |
bool | createFromSrsId (long srsId) |
Sets this CRS by lookup of internal QGIS CRS ID in the CRS database. More... | |
bool | createFromString (const QString &definition) |
Set up this CRS from a string definition. More... | |
bool | createFromUserInput (const QString &definition) |
Set up this CRS from various text formats. More... | |
bool | createFromWkt (const QString &wkt) |
Sets this CRS using a WKT definition. More... | |
QString | description () const |
Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94". More... | |
QString | ellipsoidAcronym () const |
Returns the ellipsoid acronym for the ellipsoid used by the CRS. More... | |
Q_DECL_DEPRECATED long | findMatchingProj () |
Walks the CRS databases (both system and user database) trying to match stored PROJ string to a database entry in order to fill in further pieces of information about CRS. More... | |
QString | geographicCrsAuthId () const |
Returns auth id of related geographic CRS. More... | |
bool | hasAxisInverted () const |
Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS. More... | |
bool | isGeographic () const |
Returns whether the CRS is a geographic CRS (using lat/lon coordinates) More... | |
bool | isValid () const |
Returns whether this CRS is correctly initialized and usable. More... | |
QgsUnitTypes::DistanceUnit | mapUnits () const |
Returns the units for the projection used by the CRS. More... | |
operator QVariant () const | |
Allows direct construction of QVariants from QgsCoordinateReferenceSystem. More... | |
bool | operator!= (const QgsCoordinateReferenceSystem &srs) const |
Overloaded != operator used to compare to CRS's. More... | |
QgsCoordinateReferenceSystem & | operator= (const QgsCoordinateReferenceSystem &srs) |
Assignment operator. More... | |
bool | operator== (const QgsCoordinateReferenceSystem &srs) const |
Overloaded == operator used to compare to CRS's. More... | |
long | postgisSrid () const |
Returns PostGIS SRID for the CRS. More... | |
QString | projectionAcronym () const |
Returns the projection acronym for the projection used by the CRS. More... | |
bool | readXml (const QDomNode &node) |
Restores state from the given DOM node. More... | |
long | saveAsUserCrs (const QString &name, Format nativeFormat=FormatWkt) |
Saves the CRS as a new custom ("USER") CRS. More... | |
void | setValidationHint (const QString &html) |
Set user hint for validation. More... | |
long | srsid () const |
Returns the internal CRS ID, if available. More... | |
QString | toProj () const |
Returns a Proj string representation of this CRS. More... | |
Q_DECL_DEPRECATED QString | toProj4 () const |
Returns a Proj string representation of this CRS. More... | |
QString | toWkt (WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const |
Returns a WKT representation of this CRS. More... | |
void | updateDefinition () |
Updates the definition and parameters of the coordinate reference system to their latest values. More... | |
QString | userFriendlyIdentifier (IdentifierType type=MediumString) const |
Returns a user friendly identifier for the CRS. More... | |
void | validate () |
Perform some validation on this CRS. More... | |
QString | validationHint () |
Gets user hint for validation. More... | |
bool | writeXml (QDomNode &node, QDomDocument &doc) const |
Stores state to the given Dom node in the given document. More... | |
Static Public Member Functions | |
static CUSTOM_CRS_VALIDATION | customCrsValidation () |
Gets custom function. More... | |
static Q_INVOKABLE QgsCoordinateReferenceSystem | fromEpsgId (long epsg) |
Creates a CRS from a given EPSG ID. More... | |
static QgsCoordinateReferenceSystem | fromOgcWmsCrs (const QString &ogcCrs) |
Creates a CRS from a given OGC WMS-format Coordinate Reference System string. More... | |
static QgsCoordinateReferenceSystem | fromProj (const QString &proj) |
Creates a CRS from a proj style formatted string. More... | |
static Q_DECL_DEPRECATED QgsCoordinateReferenceSystem | fromProj4 (const QString &proj4) |
Creates a CRS from a proj style formatted string. More... | |
static QgsCoordinateReferenceSystem | fromSrsId (long srsId) |
Creates a CRS from a specified QGIS SRS ID. More... | |
static QgsCoordinateReferenceSystem | fromWkt (const QString &wkt) |
Creates a CRS from a WKT spatial ref sys definition string. More... | |
static void | invalidateCache (bool disableCache=false) |
Clears the internal cache used to initialize QgsCoordinateReferenceSystem objects. More... | |
static void | pushRecentCoordinateReferenceSystem (const QgsCoordinateReferenceSystem &crs) |
Pushes a recently used CRS to the top of the recent CRS list. More... | |
static QList< QgsCoordinateReferenceSystem > | recentCoordinateReferenceSystems () |
Returns a list of recently used CRS. More... | |
static Q_DECL_DEPRECATED QStringList | recentProjections () |
Returns a list of recently used projections. More... | |
static void | setCustomCrsValidation (CUSTOM_CRS_VALIDATION f) |
Sets custom function to force valid CRS. More... | |
static Q_DECL_DEPRECATED void | setupESRIWktFix () |
Make sure that ESRI WKT import is done properly. More... | |
static int | syncDatabase () |
Update proj.4 parameters in our database from proj.4. More... | |
static QList< long > | validSrsIds () |
Returns a list of all valid SRS IDs present in the CRS database. More... | |
Properties | |
bool | isGeographic |
Q_GADGET QgsUnitTypes::DistanceUnit | mapUnits |
Friends | |
class | QgsCoordinateReferenceSystemRegistry |
class | QgsPostgresProvider |
class | TestQgsCoordinateReferenceSystem |
This class represents a coordinate reference system (CRS).
Coordinate reference system object defines a specific map projection, as well as transformations between different coordinate reference systems. There are various ways how a CRS can be defined: using well-known text (WKT), PROJ string or combination of authority and code (e.g. EPSG:4326). QGIS comes with its internal database of coordinate reference systems (stored in SQLite) that allows lookups of CRS and seamless conversions between the various definitions.
Most commonly one comes across two types of coordinate systems:
Internally QGIS uses proj library for all the math behind coordinate transformations, so in case of any troubles with projections it is best to examine the PROJ representation within the object, as that is the representation that will be ultimately used.
Methods that allow inspection of CRS instances include isValid(), authid(), description(), toWkt(), toProj(), mapUnits() and others. Creation of CRS instances is further described in Object Construction and Copying section below. Transformations between coordinate reference systems are done using QgsCoordinateTransform class.
For example, the following code will create and inspect "British national grid" CRS:
This will produce the following output:
This section gives an overview of various supported CRS definition formats:
Authority and Code: Also referred to as OGC WMS format within QGIS as they have been widely used in OGC standards. These are encoded as <auth>:<code>
, for example EPSG:4326
refers to WGS84 system. EPSG is the most commonly used authority that covers a wide range of coordinate systems around the world.
An extended variant of this format is OGC URN. Syntax of URN for CRS definition is urn:ogc:def:crs:<auth>:[<version>]:<code>
. This class can also parse URNs (versions are currently ignored). For example, WGS84 may be encoded as urn:ogc:def:crs:OGC:1.3:CRS84
.
QGIS adds support for "USER" authority that refers to IDs used internally in QGIS. This variant is best avoided or used with caution as the IDs are not permanent and they refer to different CRS on different machines or user profiles.
+param1=value1 +param2=value2 [...]
. This is the format natively used by the underlying proj library. For example, the definition of WGS84 looks like this:The database of CRS shipped with QGIS is stored in a SQLite database (see QgsApplication::srsDatabaseFilePath()) and it is based on the data files maintained by GDAL project (a variety of .csv and .wkt files).
Sometimes it happens that users need to use a CRS definition that is not well known or that has been only created with a specific purpose (and thus its definition is not available in our database of CRS). Whenever a new CRS definition is seen, it will be added to the local database (in user's home directory, see QgsApplication::qgisUserDatabaseFilePath()). QGIS also features a GUI for management of local custom CRS definitions.
There are therefore two databases: one for shipped CRS definitions and one for custom CRS definitions. Custom CRS have internal IDs (accessible with srsid()) greater or equal to USER_CRS_START_ID. The local CRS databases should never be accessed directly with SQLite functions, instead you should use QgsCoordinateReferenceSystem API for CRS lookups and for managements of custom CRS.
In some cases (most prominently when loading a map layer), QGIS will try to ensure that the given map layer CRS is valid using validate() call. If not, a custom validation function will be called - such function may for example show a GUI for manual CRS selection. The validation function is configured using setCustomCrsValidation(). If validation fails or no validation function is set, the default CRS is assigned (WGS84). QGIS application registers its validation function that will act according to user's settings (either show CRS selector dialog or use project/custom CRS).
The easiest way of creating CRS instances is to use QgsCoordinateReferenceSystem(const QString&) constructor that automatically recognizes definition format from the given string.
Creation of CRS object involves some queries in a local SQLite database, which may be potentially expensive. Consequently, CRS creation methods use an internal cache to avoid unnecessary database lookups. If the CRS database is modified, then it is necessary to call invalidateCache() to ensure that outdated records are not being returned from the cache.
Since QGIS 2.16 QgsCoordinateReferenceSystem objects are implicitly shared.
There are two different flavors of WKT: one is defined by OGC, the other is the standard used by ESRI. They look very similar, but they are not the same. QGIS is able to consume both flavors.
Definition at line 209 of file qgscoordinatereferencesystem.h.
Enumeration of types of IDs accepted in createFromId() method.
Enumerator | |
---|---|
InternalCrsId | Internal ID used by QGIS in the local SQLite database. |
PostgisCrsId | SRID used in PostGIS. DEPRECATED – DO NOT USE. |
EpsgCrsId | EPSG code. |
Definition at line 219 of file qgscoordinatereferencesystem.h.
Projection definition formats.
Enumerator | |
---|---|
FormatWkt | WKT format (always recommended over proj string format) |
FormatProj | Proj string format. |
Definition at line 227 of file qgscoordinatereferencesystem.h.
Type of identifier string to create.
Definition at line 633 of file qgscoordinatereferencesystem.h.
WKT formatting variants, only used for builds based on Proj >= 6.
Definition at line 672 of file qgscoordinatereferencesystem.h.
QgsCoordinateReferenceSystem::QgsCoordinateReferenceSystem | ( | ) |
Constructs an invalid CRS object.
Definition at line 113 of file qgscoordinatereferencesystem.cpp.
QgsCoordinateReferenceSystem::~QgsCoordinateReferenceSystem | ( | ) |
Definition at line 250 of file qgscoordinatereferencesystem.cpp.
|
explicit |
Constructs a CRS object from a string definition using createFromString()
It supports the following formats:
If no prefix is specified, WKT definition is assumed.
definition | A String containing a coordinate reference system definition. |
Definition at line 120 of file qgscoordinatereferencesystem.cpp.
|
explicit |
Constructor.
A CRS object using a PostGIS SRID, an EPSG code or an internal QGIS CRS ID.
id | The ID valid for the chosen CRS ID type |
type | One of the types described in CrsType |
Definition at line 126 of file qgscoordinatereferencesystem.cpp.
QgsCoordinateReferenceSystem::QgsCoordinateReferenceSystem | ( | const QgsCoordinateReferenceSystem & | srs | ) |
Copy constructor.
Definition at line 134 of file qgscoordinatereferencesystem.cpp.
QString QgsCoordinateReferenceSystem::authid | ( | ) | const |
Returns the authority identifier for the CRS.
The identifier includes both the authority (e.g., EPSG) and the CRS number (e.g., 4326). This is the best method to use when showing a very short CRS identifier to a user, e.g., "EPSG:4326".
If CRS object is a custom CRS (not found in database), the method will return internal QGIS CRS ID with "QGIS" authority, for example "QGIS:100005"
Definition at line 1324 of file qgscoordinatereferencesystem.cpp.
QgsRectangle QgsCoordinateReferenceSystem::bounds | ( | ) | const |
Returns the approximate bounds for the region the CRS is usable within.
The returned bounds represent the latitude and longitude extent for the projection in the WGS 84 CRS.
Definition at line 1459 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::createFromId | ( | long | id, |
CrsType | type = PostgisCrsId |
||
) |
Sets this CRS by lookup of the given ID in the CRS database.
true
on success else false
Definition at line 254 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs | ( | const QString & | crs | ) |
Sets this CRS to the given OGC WMS-format Coordinate Reference Systems.
Accepts both "<auth>:<code>" format and OGC URN "urn:ogc:def:crs:<auth>:[<version>]:<code>". It also recognizes "QGIS", "USER", "CUSTOM" authorities, which all have the same meaning and refer to QGIS internal CRS IDs.
true
on success else false
Definition at line 391 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::createFromProj | ( | const QString & | projString, |
bool | identify = true |
||
) |
Sets this CRS by passing it a PROJ style formatted string.
The string will be parsed and the projection and ellipsoid members set and the remainder of the Proj string will be stored in the parameters member. The reason for this is so that we can easily present the user with 'natural language' representation of the projection and ellipsoid by looking them up in the srs.db sqlite database.
We try to match the Proj string to internal QGIS CRS ID using the following logic:
projString | A Proj format string |
identify | if false , no attempts will be made to match the proj string against known CRS authorities. This is much faster, but should only ever be used when it is known in advance that the definition does not correspond to a known or user CRS. This argument is not available in Python. |
true
on success else false
Definition at line 937 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::createFromProj4 | ( | const QString & | projString | ) |
Sets this CRS by passing it a PROJ style formatted string.
The string will be parsed and the projection and ellipsoid members set and the remainder of the Proj string will be stored in the parameters member. The reason for this is so that we can easily present the user with 'natural language' representation of the projection and ellipsoid by looking them up in the srs.db sqlite database.
We try to match the Proj string to internal QGIS CRS ID using the following logic:
projString | A Proj format string |
true
on success else false
Definition at line 932 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::createFromSrid | ( | long | srid | ) |
Sets this CRS by lookup of the given PostGIS SRID in the CRS database.
srid | The PostGIS SRID for the desired spatial reference system. |
true
on success else false
Definition at line 514 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::createFromSrsId | ( | long | srsId | ) |
Sets this CRS by lookup of internal QGIS CRS ID in the CRS database.
If the srsid is < USER_CRS_START_ID, system CRS database is used, otherwise user's local CRS database from home directory is used.
srsId | The internal QGIS CRS ID for the desired spatial reference system. |
true
on success else false
Definition at line 564 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::createFromString | ( | const QString & | definition | ) |
Set up this CRS from a string definition.
It supports the following formats:
If no prefix is specified, WKT definition is assumed.
definition | A String containing a coordinate reference system definition. |
true
on success else false
Definition at line 275 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::createFromUserInput | ( | const QString & | definition | ) |
Set up this CRS from various text formats.
Valid formats: WKT string, "EPSG:n", "EPSGA:n", "AUTO:proj_id,unit_id,lon0,lat0", "urn:ogc:def:crs:EPSG::n", PROJ string, filename (with WKT, XML or PROJ string), well known name (such as NAD27, NAD83, WGS84 or WGS72), ESRI::[WKT string] (directly or in a file), "IGNF:xxx"
For more details on supported formats see OGRSpatialReference::SetFromUserInput() ( https://gdal.org/doxygen/classOGRSpatialReference.html#aec3c6a49533fe457ddc763d699ff8796 )
definition | A String containing a coordinate reference system definition. |
true
on success else false
Definition at line 343 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::createFromWkt | ( | const QString & | wkt | ) |
Sets this CRS using a WKT definition.
If EPSG code of the WKT definition can be determined, it is extracted and createFromOgcWmsCrs() is used to initialize the object.
wkt | The WKT for the desired spatial reference system. |
true
on success else false
Definition at line 847 of file qgscoordinatereferencesystem.cpp.
|
static |
Gets custom function.
Definition at line 2283 of file qgscoordinatereferencesystem.cpp.
QString QgsCoordinateReferenceSystem::description | ( | ) | const |
Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94".
Definition at line 1329 of file qgscoordinatereferencesystem.cpp.
QString QgsCoordinateReferenceSystem::ellipsoidAcronym | ( | ) | const |
Returns the ellipsoid acronym for the ellipsoid used by the CRS.
Definition at line 1376 of file qgscoordinatereferencesystem.cpp.
long QgsCoordinateReferenceSystem::findMatchingProj | ( | ) |
Walks the CRS databases (both system and user database) trying to match stored PROJ string to a database entry in order to fill in further pieces of information about CRS.
Definition at line 1874 of file qgscoordinatereferencesystem.cpp.
|
static |
Creates a CRS from a given EPSG ID.
epsg | epsg CRS ID |
Definition at line 210 of file qgscoordinatereferencesystem.cpp.
|
static |
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
ogcCrs | OGR compliant CRS definition, e.g., "EPSG:4326" |
Definition at line 203 of file qgscoordinatereferencesystem.cpp.
|
static |
Creates a CRS from a proj style formatted string.
proj | proj format string |
Definition at line 229 of file qgscoordinatereferencesystem.cpp.
|
static |
Creates a CRS from a proj style formatted string.
Definition at line 224 of file qgscoordinatereferencesystem.cpp.
|
static |
Creates a CRS from a specified QGIS SRS ID.
srsId | internal QGIS SRS ID |
Definition at line 243 of file qgscoordinatereferencesystem.cpp.
|
static |
Creates a CRS from a WKT spatial ref sys definition string.
wkt | WKT for the desired spatial reference system. |
Definition at line 236 of file qgscoordinatereferencesystem.cpp.
QString QgsCoordinateReferenceSystem::geographicCrsAuthId | ( | ) | const |
Returns auth id of related geographic CRS.
Definition at line 3503 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::hasAxisInverted | ( | ) | const |
Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS.
true
if CRS axis is inverted Definition at line 816 of file qgscoordinatereferencesystem.cpp.
|
static |
Clears the internal cache used to initialize QgsCoordinateReferenceSystem objects.
This should be called whenever the srs database has been modified in order to ensure that outdated CRS objects are not created.
If disableCache is true
then the inbuilt cache will be completely disabled. This argument is for internal use only.
Definition at line 3608 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::isGeographic | ( | ) | const |
Returns whether the CRS is a geographic CRS (using lat/lon coordinates)
true
if CRS is geographic, or false
if it is a projected CRS Definition at line 1446 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::isValid | ( | ) | const |
Returns whether this CRS is correctly initialized and usable.
Definition at line 927 of file qgscoordinatereferencesystem.cpp.
QgsUnitTypes::DistanceUnit QgsCoordinateReferenceSystem::mapUnits | ( | ) | const |
Returns the units for the projection used by the CRS.
Definition at line 1451 of file qgscoordinatereferencesystem.cpp.
|
inline |
Allows direct construction of QVariants from QgsCoordinateReferenceSystem.
Definition at line 279 of file qgscoordinatereferencesystem.h.
bool QgsCoordinateReferenceSystem::operator!= | ( | const QgsCoordinateReferenceSystem & | srs | ) | const |
Overloaded != operator used to compare to CRS's.
Returns opposite bool value to operator ==
Definition at line 1974 of file qgscoordinatereferencesystem.cpp.
QgsCoordinateReferenceSystem & QgsCoordinateReferenceSystem::operator= | ( | const QgsCoordinateReferenceSystem & | srs | ) |
Assignment operator.
Definition at line 140 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::operator== | ( | const QgsCoordinateReferenceSystem & | srs | ) | const |
Overloaded == operator used to compare to CRS's.
Internally it will use authid() for comparison.
Definition at line 1950 of file qgscoordinatereferencesystem.cpp.
long QgsCoordinateReferenceSystem::postgisSrid | ( | ) | const |
Returns PostGIS SRID for the CRS.
Definition at line 1319 of file qgscoordinatereferencesystem.cpp.
QString QgsCoordinateReferenceSystem::projectionAcronym | ( | ) | const |
Returns the projection acronym for the projection used by the CRS.
Definition at line 1364 of file qgscoordinatereferencesystem.cpp.
|
static |
Pushes a recently used CRS to the top of the recent CRS list.
Definition at line 3577 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::readXml | ( | const QDomNode & | node | ) |
Restores state from the given DOM node.
If it fails or if the node is empty, a default empty CRS will be returned.
node | The node from which state will be restored |
true
on success, false
on failure Definition at line 2043 of file qgscoordinatereferencesystem.cpp.
|
static |
Returns a list of recently used CRS.
Definition at line 3546 of file qgscoordinatereferencesystem.cpp.
|
static |
Returns a list of recently used projections.
Definition at line 3534 of file qgscoordinatereferencesystem.cpp.
long QgsCoordinateReferenceSystem::saveAsUserCrs | ( | const QString & | name, |
Format | nativeFormat = FormatWkt |
||
) |
Saves the CRS as a new custom ("USER") CRS.
Returns the new CRS srsid(), or -1 if the CRS could not be saved.
The nativeFormat argument specifies the format to use when saving the CRS definition. FormatWkt is recommended as it is a lossless format.
Definition at line 2320 of file qgscoordinatereferencesystem.cpp.
|
static |
Sets custom function to force valid CRS.
Definition at line 2278 of file qgscoordinatereferencesystem.cpp.
|
static |
Make sure that ESRI WKT import is done properly.
This is required for proper shapefile CRS import when using gdal>= 1.9.
Definition at line 370 of file qgscoordinatereferencesystem.cpp.
void QgsCoordinateReferenceSystem::setValidationHint | ( | const QString & | html | ) |
Set user hint for validation.
Definition at line 2310 of file qgscoordinatereferencesystem.cpp.
long QgsCoordinateReferenceSystem::srsid | ( | ) | const |
Returns the internal CRS ID, if available.
Definition at line 1314 of file qgscoordinatereferencesystem.cpp.
|
static |
Update proj.4 parameters in our database from proj.4.
Definition at line 2696 of file qgscoordinatereferencesystem.cpp.
QString QgsCoordinateReferenceSystem::toProj | ( | ) | const |
Returns a Proj string representation of this CRS.
If proj and ellps keys are found in the parameters, they will be stripped out and the projection and ellipsoid acronyms will be overridden with these.
Definition at line 1423 of file qgscoordinatereferencesystem.cpp.
QString QgsCoordinateReferenceSystem::toProj4 | ( | ) | const |
Returns a Proj string representation of this CRS.
If proj and ellps keys are found in the parameters, they will be stripped out and the projection and ellipsoid acronyms will be overridden with these.
Definition at line 1418 of file qgscoordinatereferencesystem.cpp.
QString QgsCoordinateReferenceSystem::toWkt | ( | WktVariant | variant = WKT1_GDAL , |
bool | multiline = false , |
||
int | indentationWidth = 4 |
||
) | const |
Returns a WKT representation of this CRS.
The variant argument specifies the formatting variant to use when creating the WKT string. This is only used on builds based on Proj >= 6, with earlier versions always using WKT1_GDAL.
If multiline is true
then a formatted multiline string will be returned, using the specified indentationWidth. This is only used on builds based on Proj >= 6.
Definition at line 1979 of file qgscoordinatereferencesystem.cpp.
void QgsCoordinateReferenceSystem::updateDefinition | ( | ) |
Updates the definition and parameters of the coordinate reference system to their latest values.
This only has an effect if the CRS is a user defined custom CRS, and the definition of that custom CRS has changed. In this case the parameters of the object (such as the proj and WKT string definitions, and other related properties) will be updated to reflect the current definition of the custom CRS.
Any objects which store CRS objects should connect to the QgsApplication::coordinateReferenceSystemRegistry()'s QgsCoordinateReferenceSystemRegistry::userCrsChanged() signal and call this method on their stored CRS objects whenever the signal is emitted in order to update these CRSes to their new definitions.
Definition at line 1525 of file qgscoordinatereferencesystem.cpp.
QString QgsCoordinateReferenceSystem::userFriendlyIdentifier | ( | IdentifierType | type = MediumString | ) | const |
Returns a user friendly identifier for the CRS.
Depending on the format of the CRS, this may reflect the CRSes registered name, or for CRSes not saved in the database it may reflect the underlying WKT or Proj string definition of the CRS.
In most cases this is the best method to use when showing a friendly identifier for the CRS to a user.
Definition at line 1341 of file qgscoordinatereferencesystem.cpp.
void QgsCoordinateReferenceSystem::validate | ( | ) |
Perform some validation on this CRS.
If the CRS doesn't validate the default behavior settings for layers with unknown CRS will be consulted and acted on accordingly. By hell or high water this method will do its best to make sure that this CRS is valid - even if that involves resorting to a hard coded default of geocs:wgs84.
Definition at line 504 of file qgscoordinatereferencesystem.cpp.
QString QgsCoordinateReferenceSystem::validationHint | ( | ) |
Gets user hint for validation.
Definition at line 2315 of file qgscoordinatereferencesystem.cpp.
|
static |
Returns a list of all valid SRS IDs present in the CRS database.
Any of the returned values can be safely passed to fromSrsId() to create a new, valid QgsCoordinateReferenceSystem object.
Definition at line 147 of file qgscoordinatereferencesystem.cpp.
bool QgsCoordinateReferenceSystem::writeXml | ( | QDomNode & | node, |
QDomDocument & | doc | ||
) | const |
Stores state to the given Dom node in the given document.
node | The node in which state will be restored |
doc | The document in which state will be stored |
true
on success, false
on failure Definition at line 2148 of file qgscoordinatereferencesystem.cpp.
|
friend |
Definition at line 1001 of file qgscoordinatereferencesystem.h.
|
friend |
Definition at line 1000 of file qgscoordinatereferencesystem.h.
|
friend |
Definition at line 999 of file qgscoordinatereferencesystem.h.
|
read |
Definition at line 211 of file qgscoordinatereferencesystem.h.
|
read |
Definition at line 211 of file qgscoordinatereferencesystem.h.