QGIS API Documentation 3.41.0-Master (d5b93354e9c)
Loading...
Searching...
No Matches
Classes | Public Types | Static Public Member Functions | List of all members
QgsProjUtils Class Reference

Utility functions for working with the proj library. More...

#include <qgsprojutils.h>

Classes

struct  ProjPJDeleter
 Destroys Proj PJ objects. More...
 

Public Types

enum  IdentifyFlag { FlagMatchBoundCrsToUnderlyingSourceCrs = 1 << 0 }
 Flags controlling CRS identification behavior. More...
 
typedef QFlags< IdentifyFlagIdentifyFlags
 
using proj_pj_unique_ptr = std::unique_ptr< PJ, ProjPJDeleter >
 Scoped Proj PJ object.
 

Static Public Member Functions

static bool axisOrderIsSwapped (const PJ *crs)
 Returns true if the given proj coordinate system uses requires y/x coordinate order instead of x/y.
 
static bool coordinateOperationIsAvailable (const QString &projDef)
 Returns true if a coordinate operation (specified via proj string) is available.
 
static proj_pj_unique_ptr createCompoundCrs (const PJ *horizontalCrs, const PJ *verticalCrs, QStringList *errors=nullptr)
 Given a PROJ horizontal and vertical CRS, attempt to create a compound CRS from them.
 
static proj_pj_unique_ptr crsToDatumEnsemble (const PJ *crs)
 Given a PROJ crs, attempt to retrieve the datum ensemble from it.
 
static proj_pj_unique_ptr crsToHorizontalCrs (const PJ *crs)
 Given a PROJ crs (which may be a compound or bound crs, or some other type), extract the horizontal crs from it.
 
static proj_pj_unique_ptr crsToVerticalCrs (const PJ *crs)
 Given a PROJ crs (which may be a compound crs, or some other type), extract the vertical crs from it.
 
static QDate epsgRegistryDate ()
 Returns the EPSG registry database release date used by the proj library.
 
static QString epsgRegistryVersion ()
 Returns the EPSG registry database version used by the proj library (e.g.
 
static QDate esriDatabaseDate ()
 Returns the ESRI projection engine database release date used by the proj library.
 
static QString esriDatabaseVersion ()
 Returns the ESRI projection engine database version used by the proj library (e.g.
 
static QList< QgsDatumTransform::GridDetailsgridsUsed (const QString &proj)
 Returns a list of grids used by the given proj string.
 
static bool hasVerticalAxis (const PJ *crs)
 Returns true if a PROJ crs has a vertical axis.
 
static bool identifyCrs (const PJ *crs, QString &authName, QString &authCode, IdentifyFlags flags=IdentifyFlags())
 Attempts to identify a crs, matching it to a known authority and code within an acceptable level of tolerance.
 
static QDate ignfDatabaseDate ()
 Returns the IGNF database release date used by the proj library.
 
static QString ignfDatabaseVersion ()
 Returns the IGNF database version used by the proj library (e.g.
 
static bool isDynamic (const PJ *crs)
 Returns true if the given proj coordinate system is a dynamic CRS.
 
static void proj_collecting_logger (void *user_data, int level, const char *message)
 QGIS proj log function which collects errors to a QStringList.
 
static void proj_logger (void *user_data, int level, const char *message)
 Default QGIS proj log function.
 
static int projVersionMajor ()
 Returns the proj library major version number.
 
static int projVersionMinor ()
 Returns the proj library minor version number.
 
static QStringList searchPaths ()
 Returns the current list of Proj file search paths.
 
static proj_pj_unique_ptr unboundCrs (const PJ *crs)
 Given a PROJ crs (which may be a compound or bound crs, or some other type), ensure that it is not a bound CRS object.
 
static bool usesAngularUnit (const QString &projDef)
 Returns true if the given proj coordinate system uses angular units.
 

Detailed Description

Utility functions for working with the proj library.

Since
QGIS 3.8

Definition at line 44 of file qgsprojutils.h.

Member Typedef Documentation

◆ IdentifyFlags

Definition at line 123 of file qgsprojutils.h.

◆ proj_pj_unique_ptr

using QgsProjUtils::proj_pj_unique_ptr = std::unique_ptr< PJ, ProjPJDeleter >

Scoped Proj PJ object.

Definition at line 141 of file qgsprojutils.h.

Member Enumeration Documentation

◆ IdentifyFlag

Flags controlling CRS identification behavior.

Enumerator
FlagMatchBoundCrsToUnderlyingSourceCrs 

Allow matching a BoundCRS object to its underlying SourceCRS.

Definition at line 119 of file qgsprojutils.h.

Member Function Documentation

◆ axisOrderIsSwapped()

bool QgsProjUtils::axisOrderIsSwapped ( const PJ crs)
static

Returns true if the given proj coordinate system uses requires y/x coordinate order instead of x/y.

Definition at line 113 of file qgsprojutils.cpp.

◆ coordinateOperationIsAvailable()

bool QgsProjUtils::coordinateOperationIsAvailable ( const QString &  projDef)
static

Returns true if a coordinate operation (specified via proj string) is available.

Definition at line 468 of file qgsprojutils.cpp.

◆ createCompoundCrs()

QgsProjUtils::proj_pj_unique_ptr QgsProjUtils::createCompoundCrs ( const PJ horizontalCrs,
const PJ verticalCrs,
QStringList *  errors = nullptr 
)
static

Given a PROJ horizontal and vertical CRS, attempt to create a compound CRS from them.

Optionally, the errors argument can be set to a string list to collect errors reported by PROJ when attempting to create the compound CRS.

Since
QGIS 3.38

Definition at line 392 of file qgsprojutils.cpp.

◆ crsToDatumEnsemble()

QgsProjUtils::proj_pj_unique_ptr QgsProjUtils::crsToDatumEnsemble ( const PJ crs)
static

Given a PROJ crs, attempt to retrieve the datum ensemble from it.

Note
In the case of a compound crs, this method will always return the datum ensemble for the horizontal component.
Warning
This method requires PROJ 8.0 or later
Exceptions
QgsNotSupportedExceptionon QGIS builds based on PROJ 7 or earlier.
Since
QGIS 3.20

Definition at line 338 of file qgsprojutils.cpp.

◆ crsToHorizontalCrs()

QgsProjUtils::proj_pj_unique_ptr QgsProjUtils::crsToHorizontalCrs ( const PJ crs)
static

Given a PROJ crs (which may be a compound or bound crs, or some other type), extract the horizontal crs from it.

If crs does not contain a horizontal CRS (i.e. it is a vertical CRS) nullptr will be returned.

See also
crsToVerticalCrs()

Definition at line 193 of file qgsprojutils.cpp.

◆ crsToVerticalCrs()

QgsProjUtils::proj_pj_unique_ptr QgsProjUtils::crsToVerticalCrs ( const PJ crs)
static

Given a PROJ crs (which may be a compound crs, or some other type), extract the vertical crs from it.

If crs does not contain a vertical CRS (i.e. it is a horizontal CRS) nullptr will be returned.

See also
crsToHorizontalCrs()
Since
QGIS 3.38

Definition at line 227 of file qgsprojutils.cpp.

◆ epsgRegistryDate()

QDate QgsProjUtils::epsgRegistryDate ( )
static

Returns the EPSG registry database release date used by the proj library.

See also
epsgRegistryVersion()
Since
QGIS 3.20

Definition at line 552 of file qgsprojutils.cpp.

◆ epsgRegistryVersion()

QString QgsProjUtils::epsgRegistryVersion ( )
static

Returns the EPSG registry database version used by the proj library (e.g.

"v9.8.6").

See also
epsgRegistryDate()
Since
QGIS 3.20

Definition at line 545 of file qgsprojutils.cpp.

◆ esriDatabaseDate()

QDate QgsProjUtils::esriDatabaseDate ( )
static

Returns the ESRI projection engine database release date used by the proj library.

See also
esriDatabaseVersion()
Since
QGIS 3.20

Definition at line 566 of file qgsprojutils.cpp.

◆ esriDatabaseVersion()

QString QgsProjUtils::esriDatabaseVersion ( )
static

Returns the ESRI projection engine database version used by the proj library (e.g.

"ArcMap 10.8.0").

See also
esriDatabaseDate()
Since
QGIS 3.20

Definition at line 559 of file qgsprojutils.cpp.

◆ gridsUsed()

QList< QgsDatumTransform::GridDetails > QgsProjUtils::gridsUsed ( const QString &  proj)
static

Returns a list of grids used by the given proj string.

Definition at line 481 of file qgsprojutils.cpp.

◆ hasVerticalAxis()

bool QgsProjUtils::hasVerticalAxis ( const PJ crs)
static

Returns true if a PROJ crs has a vertical axis.

Since
QGIS 3.38

Definition at line 259 of file qgsprojutils.cpp.

◆ identifyCrs()

bool QgsProjUtils::identifyCrs ( const PJ crs,
QString &  authName,
QString &  authCode,
IdentifyFlags  flags = IdentifyFlags() 
)
static

Attempts to identify a crs, matching it to a known authority and code within an acceptable level of tolerance.

Returns true if a matching authority and code was found.

Definition at line 414 of file qgsprojutils.cpp.

◆ ignfDatabaseDate()

QDate QgsProjUtils::ignfDatabaseDate ( )
static

Returns the IGNF database release date used by the proj library.

See also
ignfDatabaseVersion()
Since
QGIS 3.20

Definition at line 580 of file qgsprojutils.cpp.

◆ ignfDatabaseVersion()

QString QgsProjUtils::ignfDatabaseVersion ( )
static

Returns the IGNF database version used by the proj library (e.g.

"3.1.0").

See also
ignfDatabaseDate()
Since
QGIS 3.20

Definition at line 573 of file qgsprojutils.cpp.

◆ isDynamic()

bool QgsProjUtils::isDynamic ( const PJ crs)
static

Returns true if the given proj coordinate system is a dynamic CRS.

A dynamic CRS relies on a dynamic datum, that is a datum that is not plate-fixed.

Since
QGIS 3.20

Definition at line 149 of file qgsprojutils.cpp.

◆ proj_collecting_logger()

void QgsProjUtils::proj_collecting_logger ( void *  user_data,
int  level,
const char *  message 
)
static

QGIS proj log function which collects errors to a QStringList.

Warning
The user_data argument passed to proj_log_func MUST be a QStringList object, and must exist for the duration where proj_collecting_logger is used. You MUST reset the proj_log_func to proj_logger before the user data QStringList is destroyed.

Definition at line 358 of file qgsprojutils.cpp.

◆ proj_logger()

void QgsProjUtils::proj_logger ( void *  user_data,
int  level,
const char *  message 
)
static

Default QGIS proj log function.

Uses QgsDebugError or QgsDebugMsgLevel to report errors in debug builds only.

Definition at line 366 of file qgsprojutils.cpp.

◆ projVersionMajor()

int QgsProjUtils::projVersionMajor ( )
static

Returns the proj library major version number.

Definition at line 535 of file qgsprojutils.cpp.

◆ projVersionMinor()

int QgsProjUtils::projVersionMinor ( )
static

Returns the proj library minor version number.

Since
QGIS 3.20

Definition at line 540 of file qgsprojutils.cpp.

◆ searchPaths()

QStringList QgsProjUtils::searchPaths ( )
static

Returns the current list of Proj file search paths.

Note
Only available on builds based on Proj >= 6.0. Builds based on earlier Proj versions will always return an empty list.

Definition at line 587 of file qgsprojutils.cpp.

◆ unboundCrs()

QgsProjUtils::proj_pj_unique_ptr QgsProjUtils::unboundCrs ( const PJ crs)
static

Given a PROJ crs (which may be a compound or bound crs, or some other type), ensure that it is not a bound CRS object.

Bound CRS objects will be returned as their source CRS, other types will be returned as a direct clone.

Definition at line 316 of file qgsprojutils.cpp.

◆ usesAngularUnit()

bool QgsProjUtils::usesAngularUnit ( const QString &  projDef)
static

Returns true if the given proj coordinate system uses angular units.

projDef must be a proj string defining a CRS object.

Definition at line 74 of file qgsprojutils.cpp.


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