QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
Classes | Signals | Public Member Functions | List of all members
QgsCoordinateReferenceSystemRegistry Class Reference

A registry for known coordinate reference system (CRS) definitions, including any user-defined CRSes. More...

#include <qgscoordinatereferencesystemregistry.h>

Inheritance diagram for QgsCoordinateReferenceSystemRegistry:
Inheritance graph
[legend]

Classes

class  UserCrsDetails
 Contains details of a custom (user defined) CRS. More...
 

Signals

void crsDefinitionsChanged ()
 Emitted whenever an operation has caused any of the known CRS definitions (including user-defined CRS) to change.
 
void recentCrsCleared ()
 Emitted when the list of recently used CRS has been cleared.
 
void recentCrsPushed (const QgsCoordinateReferenceSystem &crs)
 Emitted when a recently used CRS has been pushed to the top of the recent CRS list.
 
void recentCrsRemoved (const QgsCoordinateReferenceSystem &crs)
 Emitted when a recently used CRS has been removed from the recent CRS list.
 
void userCrsAdded (const QString &id)
 Emitted whenever a new user CRS definition is added.
 
void userCrsChanged (const QString &id)
 Emitted whenever an existing user CRS definition is changed.
 
void userCrsRemoved (long id)
 Emitted when the user CRS with matching id is removed from the database.
 

Public Member Functions

 QgsCoordinateReferenceSystemRegistry (QObject *parent=nullptr)
 Constructor for QgsCoordinateReferenceSystemRegistry, with the specified parent object.
 
 ~QgsCoordinateReferenceSystemRegistry ()
 
long addUserCrs (const QgsCoordinateReferenceSystem &crs, const QString &name, Qgis::CrsDefinitionFormat nativeFormat=Qgis::CrsDefinitionFormat::Wkt)
 Adds a new crs definition as a custom ("USER") CRS.
 
QSet< QString > authorities () const
 Returns a list of all known authorities.
 
QList< QgsCelestialBodycelestialBodies () const
 Returns a list of all known celestial bodies.
 
void clearRecent ()
 Cleans the list of recently used CRS.
 
QList< QgsCrsDbRecordcrsDbRecords () const
 Returns the list of records from the QGIS srs db.
 
QMap< QString, QgsProjOperationprojOperations () const
 Returns a map of all valid PROJ operations.
 
void pushRecent (const QgsCoordinateReferenceSystem &crs)
 Pushes a recently used CRS to the top of the recent CRS list.
 
QList< QgsCoordinateReferenceSystemrecentCrs ()
 Returns a list of recently used CRS.
 
void removeRecent (const QgsCoordinateReferenceSystem &crs)
 Removes a CRS from the list of recently used CRS.
 
bool removeUserCrs (long id)
 Removes the existing user CRS with matching id.
 
bool updateUserCrs (long id, const QgsCoordinateReferenceSystem &crs, const QString &name, Qgis::CrsDefinitionFormat nativeFormat=Qgis::CrsDefinitionFormat::Wkt)
 Updates the definition of the existing user CRS with matching id.
 
QList< QgsCoordinateReferenceSystemRegistry::UserCrsDetailsuserCrsList () const
 Returns a list containing the details of all registered custom (user-defined) CRSes.
 

Detailed Description

A registry for known coordinate reference system (CRS) definitions, including any user-defined CRSes.

QgsCoordinateReferenceSystemRegistry is not usually directly created, but rather accessed through QgsApplication::coordinateReferenceSystemRegistry().

Since
QGIS 3.18

Definition at line 64 of file qgscoordinatereferencesystemregistry.h.

Constructor & Destructor Documentation

◆ QgsCoordinateReferenceSystemRegistry()

QgsCoordinateReferenceSystemRegistry::QgsCoordinateReferenceSystemRegistry ( QObject *  parent = nullptr)
explicit

Constructor for QgsCoordinateReferenceSystemRegistry, with the specified parent object.

Definition at line 37 of file qgscoordinatereferencesystemregistry.cpp.

◆ ~QgsCoordinateReferenceSystemRegistry()

QgsCoordinateReferenceSystemRegistry::~QgsCoordinateReferenceSystemRegistry ( )
default

Member Function Documentation

◆ addUserCrs()

long QgsCoordinateReferenceSystemRegistry::addUserCrs ( const QgsCoordinateReferenceSystem crs,
const QString &  name,
Qgis::CrsDefinitionFormat  nativeFormat = Qgis::CrsDefinitionFormat::Wkt 
)

Adds a new crs definition as a 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.

Warning
Not all CRS definitions can be represented as a Proj string, so take care when using the FormatProj option.
See also
updateUserCrs()
userCrsAdded()

Definition at line 84 of file qgscoordinatereferencesystemregistry.cpp.

◆ authorities()

QSet< QString > QgsCoordinateReferenceSystemRegistry::authorities ( ) const

Returns a list of all known authorities.

Note
authority names will always be returned in lower case
Since
QGIS 3.34

Definition at line 415 of file qgscoordinatereferencesystemregistry.cpp.

◆ celestialBodies()

QList< QgsCelestialBody > QgsCoordinateReferenceSystemRegistry::celestialBodies ( ) const

Returns a list of all known celestial bodies.

Warning
This method requires PROJ 8.1 or later
Exceptions
QgsNotSupportedExceptionon QGIS builds based on PROJ 8.0 or earlier.
Since
QGIS 3.20

Definition at line 379 of file qgscoordinatereferencesystemregistry.cpp.

◆ clearRecent()

void QgsCoordinateReferenceSystemRegistry::clearRecent ( )

Cleans the list of recently used CRS.

See also
recentCrsCleared()
Since
QGIS 3.36

Definition at line 505 of file qgscoordinatereferencesystemregistry.cpp.

◆ crsDbRecords()

QList< QgsCrsDbRecord > QgsCoordinateReferenceSystemRegistry::crsDbRecords ( ) const

Returns the list of records from the QGIS srs db.

Note
Not available in Python bindings
Since
QGIS 3.34

Definition at line 437 of file qgscoordinatereferencesystemregistry.cpp.

◆ crsDefinitionsChanged

void QgsCoordinateReferenceSystemRegistry::crsDefinitionsChanged ( )
signal

Emitted whenever an operation has caused any of the known CRS definitions (including user-defined CRS) to change.

◆ projOperations()

QMap< QString, QgsProjOperation > QgsCoordinateReferenceSystemRegistry::projOperations ( ) const

Returns a map of all valid PROJ operations.

The map keys correspond to PROJ operation IDs.

Since
QGIS 3.20

Definition at line 351 of file qgscoordinatereferencesystemregistry.cpp.

◆ pushRecent()

void QgsCoordinateReferenceSystemRegistry::pushRecent ( const QgsCoordinateReferenceSystem crs)

Pushes a recently used CRS to the top of the recent CRS list.

See also
recentCrsPushed()
Since
QGIS 3.16

Definition at line 515 of file qgscoordinatereferencesystemregistry.cpp.

◆ recentCrs()

QList< QgsCoordinateReferenceSystem > QgsCoordinateReferenceSystemRegistry::recentCrs ( )

Returns a list of recently used CRS.

Since
QGIS 3.36

Definition at line 474 of file qgscoordinatereferencesystemregistry.cpp.

◆ recentCrsCleared

void QgsCoordinateReferenceSystemRegistry::recentCrsCleared ( )
signal

Emitted when the list of recently used CRS has been cleared.

See also
clearRecent()
Since
QGIS 3.36

◆ recentCrsPushed

void QgsCoordinateReferenceSystemRegistry::recentCrsPushed ( const QgsCoordinateReferenceSystem crs)
signal

Emitted when a recently used CRS has been pushed to the top of the recent CRS list.

See also
pushRecent()
Since
QGIS 3.36

◆ recentCrsRemoved

void QgsCoordinateReferenceSystemRegistry::recentCrsRemoved ( const QgsCoordinateReferenceSystem crs)
signal

Emitted when a recently used CRS has been removed from the recent CRS list.

See also
removeRecent()
Since
QGIS 3.36

◆ removeRecent()

void QgsCoordinateReferenceSystemRegistry::removeRecent ( const QgsCoordinateReferenceSystem crs)

Removes a CRS from the list of recently used CRS.

See also
recentCrsRemoved()
Since
QGIS 3.36

Definition at line 583 of file qgscoordinatereferencesystemregistry.cpp.

◆ removeUserCrs()

bool QgsCoordinateReferenceSystemRegistry::removeUserCrs ( long  id)

Removes the existing user CRS with matching id.

Returns false if the CRS could not be removed.

See also
userCrsRemoved()

Definition at line 246 of file qgscoordinatereferencesystemregistry.cpp.

◆ updateUserCrs()

bool QgsCoordinateReferenceSystemRegistry::updateUserCrs ( long  id,
const QgsCoordinateReferenceSystem crs,
const QString &  name,
Qgis::CrsDefinitionFormat  nativeFormat = Qgis::CrsDefinitionFormat::Wkt 
)

Updates the definition of the existing user CRS with matching id.

The crs argument specifies a CRS with the desired new definition.

Returns false if the new CRS definition 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.

Warning
Not all CRS definitions can be represented as a Proj string, so take care when using the FormatProj option.
See also
addUserCrs()
userCrsChanged()

Definition at line 176 of file qgscoordinatereferencesystemregistry.cpp.

◆ userCrsAdded

void QgsCoordinateReferenceSystemRegistry::userCrsAdded ( const QString &  id)
signal

Emitted whenever a new user CRS definition is added.

The id argument specifies the ID of the user CRS which has been changed.

See also
userCrsChanged()
crsDefinitionsChanged()

◆ userCrsChanged

void QgsCoordinateReferenceSystemRegistry::userCrsChanged ( const QString &  id)
signal

Emitted whenever an existing user CRS definition is changed.

The id argument specifies the ID of the user CRS which has been changed.

Objects which store QgsCoordinateReferenceSystem members should connect to this signal and update any stored CRS definitions to ensure that they always use the current definition of any user defined CRSes.

See also
crsDefinitionsChanged()
userCrsAdded()

◆ userCrsList()

QList< QgsCoordinateReferenceSystemRegistry::UserCrsDetails > QgsCoordinateReferenceSystemRegistry::userCrsList ( ) const

Returns a list containing the details of all registered custom (user-defined) CRSes.

Definition at line 45 of file qgscoordinatereferencesystemregistry.cpp.

◆ userCrsRemoved

void QgsCoordinateReferenceSystemRegistry::userCrsRemoved ( long  id)
signal

Emitted when the user CRS with matching id is removed from the database.

See also
removeUserCrs()

The documentation for this class was generated from the following files: