QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsserversettings.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsserversettings.h
3  -------------------
4  begin : December 19, 2016
5  copyright : (C) 2016 by Paul Blottiere
6  email : paul dot blottiere at oslandia dot com
7 
8 ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 
20 #ifndef QGSSERVERSETTINGS_H
21 #define QGSSERVERSETTINGS_H
22 
23 #include <QObject>
24 #include <QMetaEnum>
25 
26 #include "qgsmessagelog.h"
27 #include "qgis_server.h"
28 #include "qgis_sip.h"
29 
36 #ifndef SIP_RUN
37 class SERVER_EXPORT QgsServerSettingsEnv : public QObject
38 {
39  Q_OBJECT
40 
41  public:
43  enum Source
44  {
47  INI_FILE
48  };
49  Q_ENUM( Source )
50 
51 
52  enum EnvVar
53  {
70  QGIS_SERVER_API_WFS3_MAX_LIMIT
71  };
72  Q_ENUM( EnvVar )
73 };
74 #endif
75 
82 class SERVER_EXPORT QgsServerSettings
83 {
84  public:
86  {
89  QString descr;
90  QString iniKey;
91  QVariant::Type type;
92  QVariant defaultVal;
93  QVariant val;
94  };
95 
100 
104  void load();
105 
110  bool load( const QString &envVarName );
111 
115  void logSummary() const;
116 
121  QString iniFile() const;
122 
127  bool parallelRendering() const;
128 
133  int maxThreads() const;
134 
139  int maxCacheLayers() const;
140 
145  Qgis::MessageLevel logLevel() const;
146 
151  QString projectFile() const;
152 
157  QString logFile() const;
158 
164  bool logStderr() const;
165 
170  qint64 cacheSize() const;
171 
176  QString cacheDirectory() const;
177 
183  QString overrideSystemLocale() const;
184 
190  bool showGroupSeparator() const;
191 
197  int wmsMaxHeight() const;
198 
204  int wmsMaxWidth() const;
205 
214  QString apiResourcesDirectory() const;
215 
224  qlonglong apiWfs3MaxLimit() const;
225 
235  bool ignoreBadLayers() const;
236 
237  private:
238  void initSettings();
239  QVariant value( QgsServerSettingsEnv::EnvVar envVar ) const;
240  QMap<QgsServerSettingsEnv::EnvVar, QString> getEnv() const;
241  void loadQSettings( const QString &envOptPath ) const;
242  void prioritize( const QMap<QgsServerSettingsEnv::EnvVar, QString> &env );
243 
244  QMap< QgsServerSettingsEnv::EnvVar, Setting > mSettings;
245 };
246 
247 #endif
QgsServerSettingsEnv::MAX_CACHE_LAYERS
@ MAX_CACHE_LAYERS
Definition: qgsserversettings.h:61
QgsServerSettings::Setting::val
QVariant val
Definition: qgsserversettings.h:93
QgsServerSettingsEnv::QGIS_SERVER_CACHE_DIRECTORY
@ QGIS_SERVER_CACHE_DIRECTORY
Definition: qgsserversettings.h:63
QgsServerSettingsEnv::Source
Source
Source of the parameter used in the configuration.
Definition: qgsserversettings.h:43
QgsServerSettingsEnv::ENVIRONMENT_VARIABLE
@ ENVIRONMENT_VARIABLE
Definition: qgsserversettings.h:46
QgsServerSettingsEnv::DEFAULT_VALUE
@ DEFAULT_VALUE
Definition: qgsserversettings.h:45
QgsServerSettingsEnv::QGIS_SERVER_CACHE_SIZE
@ QGIS_SERVER_CACHE_SIZE
Definition: qgsserversettings.h:64
QgsServerSettingsEnv
Provides some enum describing the environment currently supported for configuration.
Definition: qgsserversettings.h:37
QgsServerSettings::Setting::descr
QString descr
Definition: qgsserversettings.h:89
QgsServerSettingsEnv::QGIS_SERVER_LOG_LEVEL
@ QGIS_SERVER_LOG_LEVEL
Definition: qgsserversettings.h:57
QgsServerSettings
Provides a way to retrieve settings by prioritizing according to environment variables,...
Definition: qgsserversettings.h:82
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsServerProjectUtils::wmsMaxHeight
SERVER_EXPORT int wmsMaxHeight(const QgsProject &project)
Returns the maximum height for WMS images defined in a QGIS project.
Definition: qgsserverprojectutils.cpp:120
QgsServerSettingsEnv::QGIS_SERVER_PARALLEL_RENDERING
@ QGIS_SERVER_PARALLEL_RENDERING
Definition: qgsserversettings.h:55
QgsServerSettings::Setting::iniKey
QString iniKey
Definition: qgsserversettings.h:90
QgsServerSettings::Setting::type
QVariant::Type type
Definition: qgsserversettings.h:91
QgsServerSettings::Setting::defaultVal
QVariant defaultVal
Definition: qgsserversettings.h:92
QgsServerSettingsEnv::QGIS_SERVER_WMS_MAX_HEIGHT
@ QGIS_SERVER_WMS_MAX_HEIGHT
Maximum height for a WMS request. The most conservative between this and the project one is used (sin...
Definition: qgsserversettings.h:67
QgsServerSettingsEnv::QGIS_SERVER_API_RESOURCES_DIRECTORY
@ QGIS_SERVER_API_RESOURCES_DIRECTORY
Base directory where HTML templates and static assets (e.g. images, js and css files) are searched fo...
Definition: qgsserversettings.h:69
qgis_sip.h
QgsServerSettingsEnv::QGIS_SERVER_LOG_STDERR
@ QGIS_SERVER_LOG_STDERR
Definition: qgsserversettings.h:59
QgsServerProjectUtils::wmsMaxWidth
SERVER_EXPORT int wmsMaxWidth(const QgsProject &project)
Returns the maximum width for WMS images defined in a QGIS project.
Definition: qgsserverprojectutils.cpp:115
QgsServerSettingsEnv::QGIS_SERVER_OVERRIDE_SYSTEM_LOCALE
@ QGIS_SERVER_OVERRIDE_SYSTEM_LOCALE
Override system locale (since QGIS 3.8)
Definition: qgsserversettings.h:66
QgsServerSettingsEnv::QGIS_SERVER_MAX_THREADS
@ QGIS_SERVER_MAX_THREADS
Definition: qgsserversettings.h:56
Qgis::MessageLevel
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:101
QgsServerSettingsEnv::QGIS_OPTIONS_PATH
@ QGIS_OPTIONS_PATH
Definition: qgsserversettings.h:54
QgsServerSettings::Setting
Definition: qgsserversettings.h:85
QgsServerSettingsEnv::QGIS_SERVER_LOG_FILE
@ QGIS_SERVER_LOG_FILE
Definition: qgsserversettings.h:58
QgsServerSettingsEnv::QGIS_SERVER_WMS_MAX_WIDTH
@ QGIS_SERVER_WMS_MAX_WIDTH
Maximum width for a WMS request. The most conservative between this and the project one is used (sinc...
Definition: qgsserversettings.h:68
QgsServerSettingsEnv::QGIS_PROJECT_FILE
@ QGIS_PROJECT_FILE
Definition: qgsserversettings.h:60
QgsServerSettingsEnv::EnvVar
EnvVar
Environment variables to configure the server.
Definition: qgsserversettings.h:52
QgsServerSettingsEnv::QGIS_SERVER_IGNORE_BAD_LAYERS
@ QGIS_SERVER_IGNORE_BAD_LAYERS
Do not consider the whole project unavailable if it contains bad layers.
Definition: qgsserversettings.h:62
QgsServerSettings::Setting::envVar
QgsServerSettingsEnv::EnvVar envVar
Definition: qgsserversettings.h:87
QgsServerSettingsEnv::QGIS_SERVER_SHOW_GROUP_SEPARATOR
@ QGIS_SERVER_SHOW_GROUP_SEPARATOR
Show group (thousands) separator when formatting numeric values, defaults to false (since QGIS 3....
Definition: qgsserversettings.h:65
QgsServerSettings::Setting::src
QgsServerSettingsEnv::Source src
Definition: qgsserversettings.h:88
qgsmessagelog.h