Skip to content

Commit ed65a6a

Browse files
committedApr 22, 2021
Add utility functions to retrieve proj EPSG/ESRI/IGNF database versions
1 parent 9ffdf57 commit ed65a6a

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed
 

‎python/core/auto_generated/qgsprojutils.sip.in

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,60 @@ Utility functions for working with the proj library.
2727
static int projVersionMajor();
2828
%Docstring
2929
Returns the proj library major version number.
30+
%End
31+
32+
static QString epsgRegistryVersion();
33+
%Docstring
34+
Returns the EPSG registry database version used by the proj library (e.g. "v9.8.6").
35+
36+
.. seealso:: :py:func:`epsgRegistryDate`
37+
38+
.. versionadded:: 3.20
39+
%End
40+
41+
static QDate epsgRegistryDate();
42+
%Docstring
43+
Returns the EPSG registry database release date used by the proj library.
44+
45+
.. seealso:: :py:func:`epsgRegistryVersion`
46+
47+
.. versionadded:: 3.20
48+
%End
49+
50+
static QString esriDatabaseVersion();
51+
%Docstring
52+
Returns the ESRI projection engine database version used by the proj library (e.g. "ArcMap 10.8.0").
53+
54+
.. seealso:: :py:func:`esriDatabaseDate`
55+
56+
.. versionadded:: 3.20
57+
%End
58+
59+
static QDate esriDatabaseDate();
60+
%Docstring
61+
Returns the ESRI projection engine database release date used by the proj library.
62+
63+
.. seealso:: :py:func:`esriDatabaseVersion`
64+
65+
.. versionadded:: 3.20
66+
%End
67+
68+
static QString ignfDatabaseVersion();
69+
%Docstring
70+
Returns the IGNF database version used by the proj library (e.g. "3.1.0").
71+
72+
.. seealso:: :py:func:`ignfDatabaseDate`
73+
74+
.. versionadded:: 3.20
75+
%End
76+
77+
static QDate ignfDatabaseDate();
78+
%Docstring
79+
Returns the IGNF database release date used by the proj library.
80+
81+
.. seealso:: :py:func:`ignfDatabaseVersion`
82+
83+
.. versionadded:: 3.20
3084
%End
3185

3286
static QStringList searchPaths();

‎src/core/qgsprojutils.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <QString>
2222
#include <QSet>
2323
#include <QRegularExpression>
24+
#include <QDate>
2425

2526
#include <proj.h>
2627

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

303+
QString QgsProjUtils::epsgRegistryVersion()
304+
{
305+
PJ_CONTEXT *context = QgsProjContext::get();
306+
const char *version = proj_context_get_database_metadata( context, "EPSG.VERSION" );
307+
return QString( version );
308+
}
309+
310+
QDate QgsProjUtils::epsgRegistryDate()
311+
{
312+
PJ_CONTEXT *context = QgsProjContext::get();
313+
const char *date = proj_context_get_database_metadata( context, "EPSG.DATE" );
314+
return QDate::fromString( date, Qt::DateFormat::ISODate );
315+
}
316+
317+
QString QgsProjUtils::esriDatabaseVersion()
318+
{
319+
PJ_CONTEXT *context = QgsProjContext::get();
320+
const char *version = proj_context_get_database_metadata( context, "ESRI.VERSION" );
321+
return QString( version );
322+
}
323+
324+
QDate QgsProjUtils::esriDatabaseDate()
325+
{
326+
PJ_CONTEXT *context = QgsProjContext::get();
327+
const char *date = proj_context_get_database_metadata( context, "ESRI.DATE" );
328+
return QDate::fromString( date, Qt::DateFormat::ISODate );
329+
}
330+
331+
QString QgsProjUtils::ignfDatabaseVersion()
332+
{
333+
PJ_CONTEXT *context = QgsProjContext::get();
334+
const char *version = proj_context_get_database_metadata( context, "IGNF.VERSION" );
335+
return QString( version );
336+
}
337+
338+
QDate QgsProjUtils::ignfDatabaseDate()
339+
{
340+
PJ_CONTEXT *context = QgsProjContext::get();
341+
const char *date = proj_context_get_database_metadata( context, "IGNF.DATE" );
342+
return QDate::fromString( date, Qt::DateFormat::ISODate );
343+
}
344+
302345
QStringList QgsProjUtils::searchPaths()
303346
{
304347
const QString path( proj_info().searchpath );

‎src/core/qgsprojutils.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,54 @@ class CORE_EXPORT QgsProjUtils
4949
*/
5050
static int projVersionMajor();
5151

52+
/**
53+
* Returns the EPSG registry database version used by the proj library (e.g. "v9.8.6").
54+
*
55+
* \see epsgRegistryDate()
56+
* \since QGIS 3.20
57+
*/
58+
static QString epsgRegistryVersion();
59+
60+
/**
61+
* Returns the EPSG registry database release date used by the proj library.
62+
*
63+
* \see epsgRegistryVersion()
64+
* \since QGIS 3.20
65+
*/
66+
static QDate epsgRegistryDate();
67+
68+
/**
69+
* Returns the ESRI projection engine database version used by the proj library (e.g. "ArcMap 10.8.0").
70+
*
71+
* \see esriDatabaseDate()
72+
* \since QGIS 3.20
73+
*/
74+
static QString esriDatabaseVersion();
75+
76+
/**
77+
* Returns the ESRI projection engine database release date used by the proj library.
78+
*
79+
* \see esriDatabaseVersion()
80+
* \since QGIS 3.20
81+
*/
82+
static QDate esriDatabaseDate();
83+
84+
/**
85+
* Returns the IGNF database version used by the proj library (e.g. "3.1.0").
86+
*
87+
* \see ignfDatabaseDate()
88+
* \since QGIS 3.20
89+
*/
90+
static QString ignfDatabaseVersion();
91+
92+
/**
93+
* Returns the IGNF database release date used by the proj library.
94+
*
95+
* \see ignfDatabaseVersion()
96+
* \since QGIS 3.20
97+
*/
98+
static QDate ignfDatabaseDate();
99+
52100
/**
53101
* Returns the current list of Proj file search paths.
54102
*

0 commit comments

Comments
 (0)
Please sign in to comment.