Skip to content
Permalink
Browse files
Add utility functions to retrieve proj EPSG/ESRI/IGNF database versions
  • Loading branch information
nyalldawson committed Apr 22, 2021
1 parent 9ffdf57 commit ed65a6a3a78e33986629a28bbcf9146fd1dcccb3
Showing with 145 additions and 0 deletions.
  1. +54 −0 python/core/auto_generated/qgsprojutils.sip.in
  2. +43 −0 src/core/qgsprojutils.cpp
  3. +48 −0 src/core/qgsprojutils.h
@@ -27,6 +27,60 @@ Utility functions for working with the proj library.
static int projVersionMajor();
%Docstring
Returns the proj library major version number.
%End

static QString epsgRegistryVersion();
%Docstring
Returns the EPSG registry database version used by the proj library (e.g. "v9.8.6").

.. seealso:: :py:func:`epsgRegistryDate`

.. versionadded:: 3.20
%End

static QDate epsgRegistryDate();
%Docstring
Returns the EPSG registry database release date used by the proj library.

.. seealso:: :py:func:`epsgRegistryVersion`

.. versionadded:: 3.20
%End

static QString esriDatabaseVersion();
%Docstring
Returns the ESRI projection engine database version used by the proj library (e.g. "ArcMap 10.8.0").

.. seealso:: :py:func:`esriDatabaseDate`

.. versionadded:: 3.20
%End

static QDate esriDatabaseDate();
%Docstring
Returns the ESRI projection engine database release date used by the proj library.

.. seealso:: :py:func:`esriDatabaseVersion`

.. versionadded:: 3.20
%End

static QString ignfDatabaseVersion();
%Docstring
Returns the IGNF database version used by the proj library (e.g. "3.1.0").

.. seealso:: :py:func:`ignfDatabaseDate`

.. versionadded:: 3.20
%End

static QDate ignfDatabaseDate();
%Docstring
Returns the IGNF database release date used by the proj library.

.. seealso:: :py:func:`ignfDatabaseVersion`

.. versionadded:: 3.20
%End

static QStringList searchPaths();
@@ -21,6 +21,7 @@
#include <QString>
#include <QSet>
#include <QRegularExpression>
#include <QDate>

#include <proj.h>

@@ -299,6 +300,48 @@ int QgsProjUtils::projVersionMajor()
return PROJ_VERSION_MAJOR;
}

QString QgsProjUtils::epsgRegistryVersion()
{
PJ_CONTEXT *context = QgsProjContext::get();
const char *version = proj_context_get_database_metadata( context, "EPSG.VERSION" );
return QString( version );
}

QDate QgsProjUtils::epsgRegistryDate()
{
PJ_CONTEXT *context = QgsProjContext::get();
const char *date = proj_context_get_database_metadata( context, "EPSG.DATE" );
return QDate::fromString( date, Qt::DateFormat::ISODate );
}

QString QgsProjUtils::esriDatabaseVersion()
{
PJ_CONTEXT *context = QgsProjContext::get();
const char *version = proj_context_get_database_metadata( context, "ESRI.VERSION" );
return QString( version );
}

QDate QgsProjUtils::esriDatabaseDate()
{
PJ_CONTEXT *context = QgsProjContext::get();
const char *date = proj_context_get_database_metadata( context, "ESRI.DATE" );
return QDate::fromString( date, Qt::DateFormat::ISODate );
}

QString QgsProjUtils::ignfDatabaseVersion()
{
PJ_CONTEXT *context = QgsProjContext::get();
const char *version = proj_context_get_database_metadata( context, "IGNF.VERSION" );
return QString( version );
}

QDate QgsProjUtils::ignfDatabaseDate()
{
PJ_CONTEXT *context = QgsProjContext::get();
const char *date = proj_context_get_database_metadata( context, "IGNF.DATE" );
return QDate::fromString( date, Qt::DateFormat::ISODate );
}

QStringList QgsProjUtils::searchPaths()
{
const QString path( proj_info().searchpath );
@@ -49,6 +49,54 @@ class CORE_EXPORT QgsProjUtils
*/
static int projVersionMajor();

/**
* Returns the EPSG registry database version used by the proj library (e.g. "v9.8.6").
*
* \see epsgRegistryDate()
* \since QGIS 3.20
*/
static QString epsgRegistryVersion();

/**
* Returns the EPSG registry database release date used by the proj library.
*
* \see epsgRegistryVersion()
* \since QGIS 3.20
*/
static QDate epsgRegistryDate();

/**
* Returns the ESRI projection engine database version used by the proj library (e.g. "ArcMap 10.8.0").
*
* \see esriDatabaseDate()
* \since QGIS 3.20
*/
static QString esriDatabaseVersion();

/**
* Returns the ESRI projection engine database release date used by the proj library.
*
* \see esriDatabaseVersion()
* \since QGIS 3.20
*/
static QDate esriDatabaseDate();

/**
* Returns the IGNF database version used by the proj library (e.g. "3.1.0").
*
* \see ignfDatabaseDate()
* \since QGIS 3.20
*/
static QString ignfDatabaseVersion();

/**
* Returns the IGNF database release date used by the proj library.
*
* \see ignfDatabaseVersion()
* \since QGIS 3.20
*/
static QDate ignfDatabaseDate();

/**
* Returns the current list of Proj file search paths.
*

0 comments on commit ed65a6a

Please sign in to comment.