QGIS API Documentation 3.99.0-Master (d270888f95f)
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 <QString>
31#include <QSysInfo>
32
33using namespace Qt::StringLiterals;
34
35#ifdef WITH_SFCGAL
36#include <SFCGAL/capi/sfcgal_c.h>
37#include <SFCGAL/version.h>
38#endif
39
40#ifdef WITH_GEOGRAPHICLIB
41#include <GeographicLib/Constants.hpp>
42#endif
43
45{
46
47 // QGIS main version
48 QString versionString = u"QGIS %1 '%2' (%3)\n"_s.arg( VERSION, RELEASE_NAME, QGSVERSION );
49
50 // QGIS code revision
51 if ( QString( Qgis::devVersion() ) == "exported"_L1 )
52 {
53 versionString += "QGIS code branch"_L1;
54 if ( Qgis::version().endsWith( "Master"_L1 ) )
55 {
56 versionString += "master\n"_L1;
57 }
58 else
59 {
60 versionString += u"Release %1.%2\n"_s.arg( Qgis::versionInt() / 10000 ).arg( Qgis::versionInt() / 100 % 100 );
61 }
62 }
63 else
64 {
65 versionString += u"QGIS code revision %1\n"_s.arg( Qgis::devVersion() );
66 }
67
68 // Qt version
69 const QString qtVersionCompiled{ QT_VERSION_STR };
70 const QString qtVersionRunning{ qVersion() };
71 if ( qtVersionCompiled != qtVersionRunning )
72 {
73 versionString += u"Compiled against Qt %1\n"_s.arg( qtVersionCompiled );
74 versionString += u"Running against Qt %1\n"_s.arg( qtVersionRunning );
75 }
76 else
77 {
78 versionString += u"Qt version %1\n"_s.arg( qtVersionCompiled );
79 }
80
81 // Python version
82 versionString += u"Python version %1\n"_s.arg( PYTHON_VERSION );
83
84 // GDAL version
85 const QString gdalVersionCompiled { GDAL_RELEASE_NAME };
86 const QString gdalVersionRunning { GDALVersionInfo( "RELEASE_NAME" ) };
87 if ( gdalVersionCompiled != gdalVersionRunning )
88 {
89 versionString += u"Compiled against GDAL/OGR %1\n"_s.arg( gdalVersionCompiled );
90 versionString += u"Running against GDAL/OGR %1\n"_s.arg( gdalVersionRunning );
91 }
92 else
93 {
94 versionString += u"GDAL/OGR version %1\n"_s.arg( gdalVersionCompiled );
95 }
96
97 // proj
98 const PJ_INFO info = proj_info();
99 const QString projVersionCompiled { u"%1.%2.%3"_s.arg( PROJ_VERSION_MAJOR ).arg( PROJ_VERSION_MINOR ).arg( PROJ_VERSION_PATCH ) };
100 const QString projVersionRunning { info.version };
101 if ( projVersionCompiled != projVersionRunning )
102 {
103 versionString += u"Compiled against PROJ %1\n"_s.arg( projVersionCompiled );
104 versionString += u"Running against PROJ %2\n"_s.arg( projVersionRunning );
105 }
106 else
107 {
108 versionString += u"PROJ version %1\n"_s.arg( projVersionCompiled );
109 }
110
111 // CRS database versions
112 versionString += u"EPSG Registry database version %1 (%2)\n"_s.arg( QgsProjUtils::epsgRegistryVersion(), QgsProjUtils::epsgRegistryDate().toString( Qt::ISODate ) );
113
114 // GEOS version
115 const QString geosVersionCompiled { GEOS_CAPI_VERSION };
116 const QString geosVersionRunning { GEOSversion() };
117 if ( geosVersionCompiled != geosVersionRunning )
118 {
119 versionString += u"Compiled against GEOS %1\n"_s.arg( geosVersionCompiled );
120 versionString += u"Running against GEOS %1\n"_s.arg( geosVersionRunning );
121 }
122 else
123 {
124 versionString += u"GEOS version %1\n"_s.arg( geosVersionCompiled );
125 }
126
127 // SFCGAL version
128#ifdef WITH_SFCGAL
129 const QString sfcgalVersionCompiled { SFCGAL_VERSION };
130 const QString sfcgalVersionRunning { sfcgal_version() };
131 if ( sfcgalVersionCompiled != sfcgalVersionRunning )
132 {
133 versionString += u"Compiled against SFCGAL %1\n"_s.arg( sfcgalVersionCompiled );
134 versionString += u"Running against SFCGAL %1\n"_s.arg( sfcgalVersionRunning );
135 }
136 else
137 {
138 versionString += u"SFCGAL version %1\n"_s.arg( sfcgalVersionCompiled );
139 }
140#else
141 versionString += "No support for SFCGAL\n"_L1;
142#endif
143
144 // GeographicLib version
145#ifdef WITH_GEOGRAPHICLIB
146 const QString geographicLibVersionRunning = u"%1.%2.%3"_s.arg( GEOGRAPHICLIB_VERSION_MAJOR ).arg( GEOGRAPHICLIB_VERSION_MINOR ).arg( GEOGRAPHICLIB_VERSION_PATCH );
147 versionString += u"GeographicLib version %1\n"_s.arg( geographicLibVersionRunning );
148#else
149 versionString += "No support for GeographicLib\n"_L1;
150#endif
151
152 // SQLite version
153 const QString sqliteVersionCompiled { SQLITE_VERSION };
154 const QString sqliteVersionRunning { sqlite3_libversion() };
155 if ( sqliteVersionCompiled != sqliteVersionRunning )
156 {
157 versionString += u"Compiled against SQLite %1\n"_s.arg( sqliteVersionCompiled );
158 versionString += u"Running against SQLite %1\n"_s.arg( sqliteVersionRunning );
159 }
160 else
161 {
162 versionString += u"SQLite version %1\n"_s.arg( sqliteVersionCompiled );
163 }
164
165 // Operating system
166 versionString += u"OS %1\n"_s.arg( QSysInfo::prettyProductName() );
167
168#ifdef QGISDEBUG
169 versionString += "This copy of QGIS writes debugging output.\n"_L1;
170#endif
171
172 return versionString;
173}
static QString version()
Version string.
Definition qgis.cpp:682
static QString devVersion()
The development version.
Definition qgis.cpp:699
static int versionInt()
Version number used for comparing versions using the "Check QGIS Version" function.
Definition qgis.cpp:687
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.