QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgscommandlineutils.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgscommandlineutils.cpp
3 ---------------------------
4 begin : June 2021
5 copyright : (C) 2021 by Etienne Trimaille
6 email : etienne dot trimaille at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "qgscommandlineutils.h"
19
20#include <gdal_version.h>
21#include <ogr_api.h>
22#include <proj.h>
23#include <sqlite3.h>
24
25#include "qgsapplication.h"
26#include "qgsgeos.h"
27#include "qgsprojutils.h"
28#include "qgsversion.h"
29
30#include <QSysInfo>
31
32#ifdef WITH_SFCGAL
33#include <SFCGAL/capi/sfcgal_c.h>
34#include <SFCGAL/version.h>
35#endif
36
38{
39
40 // QGIS main version
41 QString versionString = QStringLiteral( "QGIS %1 '%2' (%3)\n" ).arg( VERSION, RELEASE_NAME, QGSVERSION );
42
43 // QGIS code revision
44 if ( QString( Qgis::devVersion() ) == QLatin1String( "exported" ) )
45 {
46 versionString += QLatin1String( "QGIS code branch" );
47 if ( Qgis::version().endsWith( QLatin1String( "Master" ) ) )
48 {
49 versionString += QLatin1String( "master\n" );
50 }
51 else
52 {
53 versionString += QStringLiteral( "Release %1.%2\n" ).arg( Qgis::versionInt() / 10000 ).arg( Qgis::versionInt() / 100 % 100 );
54 }
55 }
56 else
57 {
58 versionString += QStringLiteral( "QGIS code revision %1\n" ).arg( Qgis::devVersion() );
59 }
60
61 // Qt version
62 const QString qtVersionCompiled{ QT_VERSION_STR };
63 const QString qtVersionRunning{ qVersion() };
64 if ( qtVersionCompiled != qtVersionRunning )
65 {
66 versionString += QStringLiteral( "Compiled against Qt %1\n" ).arg( qtVersionCompiled );
67 versionString += QStringLiteral( "Running against Qt %1\n" ).arg( qtVersionRunning );
68 }
69 else
70 {
71 versionString += QStringLiteral( "Qt version %1\n" ).arg( qtVersionCompiled );
72 }
73
74 // Python version
75 versionString += QStringLiteral( "Python version %1\n" ).arg( PYTHON_VERSION );
76
77 // GDAL version
78 const QString gdalVersionCompiled { GDAL_RELEASE_NAME };
79 const QString gdalVersionRunning { GDALVersionInfo( "RELEASE_NAME" ) };
80 if ( gdalVersionCompiled != gdalVersionRunning )
81 {
82 versionString += QStringLiteral( "Compiled against GDAL/OGR %1\n" ).arg( gdalVersionCompiled );
83 versionString += QStringLiteral( "Running against GDAL/OGR %1\n" ).arg( gdalVersionRunning );
84 }
85 else
86 {
87 versionString += QStringLiteral( "GDAL/OGR version %1\n" ).arg( gdalVersionCompiled );
88 }
89
90 // proj
91 const PJ_INFO info = proj_info();
92 const QString projVersionCompiled { QStringLiteral( "%1.%2.%3" ).arg( PROJ_VERSION_MAJOR ).arg( PROJ_VERSION_MINOR ).arg( PROJ_VERSION_PATCH ) };
93 const QString projVersionRunning { info.version };
94 if ( projVersionCompiled != projVersionRunning )
95 {
96 versionString += QStringLiteral( "Compiled against PROJ %1\n" ).arg( projVersionCompiled );
97 versionString += QStringLiteral( "Running against PROJ %2\n" ).arg( projVersionRunning );
98 }
99 else
100 {
101 versionString += QStringLiteral( "PROJ version %1\n" ).arg( projVersionCompiled );
102 }
103
104 // CRS database versions
105 versionString += QStringLiteral( "EPSG Registry database version %1 (%2)\n" ).arg( QgsProjUtils::epsgRegistryVersion(), QgsProjUtils::epsgRegistryDate().toString( Qt::ISODate ) );
106
107 // GEOS version
108 const QString geosVersionCompiled { GEOS_CAPI_VERSION };
109 const QString geosVersionRunning { GEOSversion() };
110 if ( geosVersionCompiled != geosVersionRunning )
111 {
112 versionString += QStringLiteral( "Compiled against GEOS %1\n" ).arg( geosVersionCompiled );
113 versionString += QStringLiteral( "Running against GEOS %1\n" ).arg( geosVersionRunning );
114 }
115 else
116 {
117 versionString += QStringLiteral( "GEOS version %1\n" ).arg( geosVersionCompiled );
118 }
119
120 // SFCGAL version
121#ifdef WITH_SFCGAL
122 const QString sfcgalVersionCompiled { SFCGAL_VERSION };
123 const QString sfcgalVersionRunning { sfcgal_version() };
124 if ( sfcgalVersionCompiled != sfcgalVersionRunning )
125 {
126 versionString += QStringLiteral( "Compiled against SFCGAL %1\n" ).arg( sfcgalVersionCompiled );
127 versionString += QStringLiteral( "Running against SFCGAL %1\n" ).arg( sfcgalVersionRunning );
128 }
129 else
130 {
131 versionString += QStringLiteral( "SFCGAL version %1\n" ).arg( sfcgalVersionCompiled );
132 }
133#else
134 versionString += QLatin1String( "No support for SFCGAL\n" );
135#endif
136
137 // SQLite version
138 const QString sqliteVersionCompiled { SQLITE_VERSION };
139 const QString sqliteVersionRunning { sqlite3_libversion() };
140 if ( sqliteVersionCompiled != sqliteVersionRunning )
141 {
142 versionString += QStringLiteral( "Compiled against SQLite %1\n" ).arg( sqliteVersionCompiled );
143 versionString += QStringLiteral( "Running against SQLite %1\n" ).arg( sqliteVersionRunning );
144 }
145 else
146 {
147 versionString += QStringLiteral( "SQLite version %1\n" ).arg( sqliteVersionCompiled );
148 }
149
150 // Operating system
151 versionString += QStringLiteral( "OS %1\n" ).arg( QSysInfo::prettyProductName() );
152
153#ifdef QGISDEBUG
154 versionString += QLatin1String( "This copy of QGIS writes debugging output.\n" );
155#endif
156
157 return versionString;
158}
static QString version()
Version string.
Definition qgis.cpp:677
static QString devVersion()
The development version.
Definition qgis.cpp:694
static int versionInt()
Version number used for comparing versions using the "Check QGIS Version" function.
Definition qgis.cpp:682
static QString allVersions()
Display all versions in the standard output stream.
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.