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