QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
qgsserversettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsserversettings.cpp
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#include "qgsserversettings.h"
20#include "qgsapplication.h"
21#include "qgsvariantutils.h"
22
23#include <QSettings>
24#include <QDir>
25
30
31void QgsServerSettings::initSettings()
32{
33 mSettings.clear();
34
35 // options path
36 const Setting sOptPath = { QgsServerSettingsEnv::QGIS_OPTIONS_PATH,
38 QStringLiteral( "Override the default path for user configuration" ),
39 QString(),
40 QVariant::String,
41 QVariant( "" ),
42 QVariant()
43 };
44 mSettings[ sOptPath.envVar ] = sOptPath;
45
46 // parallel rendering
49 QStringLiteral( "Activate/Deactivate parallel rendering for WMS getMap request" ),
50 QStringLiteral( "/qgis/parallel_rendering" ),
51 QVariant::Bool,
52 QVariant( false ),
53 QVariant()
54 };
55 mSettings[ sParRend.envVar ] = sParRend;
56
57 // max threads
58 const Setting sMaxThreads = { QgsServerSettingsEnv::QGIS_SERVER_MAX_THREADS,
60 QStringLiteral( "Number of threads to use when parallel rendering is activated" ),
61 QStringLiteral( "/qgis/max_threads" ),
62 QVariant::Int,
63 QVariant( -1 ),
64 QVariant()
65 };
66 mSettings[ sMaxThreads.envVar ] = sMaxThreads;
67
68 // log level
69 const Setting sLogLevel = { QgsServerSettingsEnv::QGIS_SERVER_LOG_LEVEL,
71 QStringLiteral( "Log level" ),
72 QString(),
73 QVariant::Int,
74 QVariant::fromValue( Qgis::MessageLevel::NoLevel ),
75 QVariant()
76 };
77 mSettings[ sLogLevel.envVar ] = sLogLevel;
78
79 // log file
80 const Setting sLogFile = { QgsServerSettingsEnv::QGIS_SERVER_LOG_FILE,
82 QStringLiteral( "Log file" ),
83 QString(),
84 QVariant::String,
85 QVariant( "" ),
86 QVariant()
87 };
88 mSettings[ sLogFile.envVar ] = sLogFile;
89
90 // log to stderr
91 const Setting sLogStderr = { QgsServerSettingsEnv::QGIS_SERVER_LOG_STDERR,
93 QStringLiteral( "Activate/Deactivate logging to stderr" ),
94 QString(),
95 QVariant::Bool,
96 QVariant( false ),
97 QVariant()
98 };
99 mSettings[ sLogStderr.envVar ] = sLogStderr;
100
101 // project file
102 const Setting sProject = { QgsServerSettingsEnv::QGIS_PROJECT_FILE,
104 QStringLiteral( "QGIS project file" ),
105 QString(),
106 QVariant::String,
107 QVariant( "" ),
108 QVariant()
109 };
110 mSettings[ sProject.envVar ] = sProject;
111
112 // cache directory
113 const Setting sCacheDir = { QgsServerSettingsEnv::QGIS_SERVER_CACHE_DIRECTORY,
115 QStringLiteral( "Specify the cache directory" ),
116 QStringLiteral( "/cache/directory" ),
117 QVariant::String,
118 QVariant( QgsApplication::qgisSettingsDirPath() + "cache" ),
119 QVariant()
120 };
121 mSettings[ sCacheDir.envVar ] = sCacheDir;
122
123 // cache size
124 const Setting sCacheSize = { QgsServerSettingsEnv::QGIS_SERVER_CACHE_SIZE,
126 QStringLiteral( "Specify the cache size" ),
127 QStringLiteral( "/cache/size" ),
128 QVariant::LongLong,
129 QVariant( 256 * 1024 * 1024 ),
130 QVariant()
131 };
132 mSettings[ sCacheSize.envVar ] = sCacheSize;
133
134 // system locale override
135 const Setting sOverrideSystemLocale = { QgsServerSettingsEnv::QGIS_SERVER_OVERRIDE_SYSTEM_LOCALE,
137 QStringLiteral( "Override system locale" ),
138 QStringLiteral( "/locale/userLocale" ),
139 QVariant::String,
140 QVariant( "" ),
141 QVariant()
142 };
143 mSettings[ sOverrideSystemLocale.envVar ] = sOverrideSystemLocale;
144
145 // bad layers handling
146 const Setting sIgnoreBadLayers = { QgsServerSettingsEnv::QGIS_SERVER_IGNORE_BAD_LAYERS,
148 QStringLiteral( "Ignore bad layers" ),
149 QString(),
150 QVariant::Bool,
151 QVariant( false ),
152 QVariant()
153 };
154 mSettings[ sIgnoreBadLayers.envVar ] = sIgnoreBadLayers;
155
156 // trust layer metadata
157 const Setting sTrustLayerMetadata = { QgsServerSettingsEnv::QGIS_SERVER_TRUST_LAYER_METADATA,
159 QStringLiteral( "Trust layer metadata" ),
160 QString(),
161 QVariant::Bool,
162 QVariant( false ),
163 QVariant()
164 };
165 mSettings[ sTrustLayerMetadata.envVar ] = sTrustLayerMetadata;
166
167
168 // force to open layers in read-only mode
169 const Setting sForceReadOnlyLayers = { QgsServerSettingsEnv::QGIS_SERVER_FORCE_READONLY_LAYERS,
171 QStringLiteral( "Force to open layers in read-only mode" ),
172 QString(),
173 QVariant::Bool,
174 QVariant( false ),
175 QVariant()
176 };
177 mSettings[ sForceReadOnlyLayers.envVar ] = sForceReadOnlyLayers;
178
179 // don't load layouts
180 const Setting sDontLoadLayouts = { QgsServerSettingsEnv::QGIS_SERVER_DISABLE_GETPRINT,
182 QStringLiteral( "Don't load layouts" ),
183 QString(),
184 QVariant::Bool,
185 QVariant( false ),
186 QVariant()
187 };
188 mSettings[ sDontLoadLayouts.envVar ] = sDontLoadLayouts;
189
190 // show group separator
191 const Setting sShowGroupSeparator = { QgsServerSettingsEnv::QGIS_SERVER_SHOW_GROUP_SEPARATOR,
193 QStringLiteral( "Show group (thousands) separator" ),
194 QStringLiteral( "/locale/showGroupSeparator" ),
195 QVariant::String,
196 QVariant( false ),
197 QVariant()
198 };
199 mSettings[ sShowGroupSeparator.envVar ] = sShowGroupSeparator;
200
201 // max height
202 const Setting sMaxHeight = { QgsServerSettingsEnv::QGIS_SERVER_WMS_MAX_HEIGHT,
204 QStringLiteral( "Maximum height for a WMS request. The lower one of this and the project configuration is used." ),
205 QStringLiteral( "/qgis/max_wms_height" ),
206 QVariant::LongLong,
207 QVariant( -1 ),
208 QVariant()
209 };
210 mSettings[ sMaxHeight.envVar ] = sMaxHeight;
211
212 // max width
213 const Setting sMaxWidth = { QgsServerSettingsEnv::QGIS_SERVER_WMS_MAX_WIDTH,
215 QStringLiteral( "Maximum width for a WMS request. The most conservative between this and the project one is used" ),
216 QStringLiteral( "/qgis/max_wms_width" ),
217 QVariant::LongLong,
218 QVariant( -1 ),
219 QVariant()
220 };
221 mSettings[ sMaxWidth.envVar ] = sMaxWidth;
222
223 // API templates and static override directory
224 const Setting sApiResourcesDirectory = { QgsServerSettingsEnv::QGIS_SERVER_API_RESOURCES_DIRECTORY,
226 QStringLiteral( "Base directory where HTML templates and static assets (e.g. images, js and css files) are searched for" ),
227 QStringLiteral( "/qgis/server_api_resources_directory" ),
228 QVariant::String,
229 QDir( QgsApplication::pkgDataPath() ).absoluteFilePath( QStringLiteral( "resources/server/api" ) ),
230 QString()
231 };
232
233 mSettings[ sApiResourcesDirectory.envVar ] = sApiResourcesDirectory;
234
235 // API WFS3 max limit
236 const Setting sApiWfs3MaxLimit = { QgsServerSettingsEnv::QGIS_SERVER_API_WFS3_MAX_LIMIT,
238 QStringLiteral( "Maximum value for \"limit\" in a features request, defaults to 10000" ),
239 QStringLiteral( "/qgis/server_api_wfs3_max_limit" ),
240 QVariant::LongLong,
241 QVariant( 10000 ),
242 QVariant()
243 };
244
245 mSettings[ sApiWfs3MaxLimit.envVar ] = sApiWfs3MaxLimit;
246
247 // projects directory for landing page service
248 const Setting sProjectsDirectories = { QgsServerSettingsEnv::QGIS_SERVER_LANDING_PAGE_PROJECTS_DIRECTORIES,
250 QStringLiteral( "Directories used by the landing page service to find .qgs and .qgz projects" ),
251 QStringLiteral( "/qgis/server_projects_directories" ),
252 QVariant::String,
253 QVariant( "" ),
254 QVariant()
255 };
256
257 mSettings[ sProjectsDirectories.envVar ] = sProjectsDirectories;
258
259 // postgresql connection string for landing page service
260 const Setting sProjectsPgConnections = { QgsServerSettingsEnv::QGIS_SERVER_LANDING_PAGE_PROJECTS_PG_CONNECTIONS,
262 QStringLiteral( "PostgreSQL connection strings used by the landing page service to find projects" ),
263 QStringLiteral( "/qgis/server_projects_pg_connections" ),
264 QVariant::String,
265 QVariant( "" ),
266 QVariant()
267 };
268
269 mSettings[ sProjectsPgConnections.envVar ] = sProjectsPgConnections;
270
271 // landing page base URL prefix
272 const Setting sLandingPageBaseUrlPrefix = { QgsServerSettingsEnv::QGIS_SERVER_LANDING_PAGE_PREFIX,
274 QStringLiteral( "Landing page base URL path prefix" ),
275 QStringLiteral( "/qgis/server_landing_page_base_url_prefix" ),
276 QVariant::String,
277 QVariant( "" ),
278 QVariant()
279 };
280
281 mSettings[ sLandingPageBaseUrlPrefix.envVar ] = sLandingPageBaseUrlPrefix;
282
283 // log profile
284 const Setting sLogProfile = { QgsServerSettingsEnv::QGIS_SERVER_LOG_PROFILE,
286 QStringLiteral( "Add detailed profile information to the logs, only effective when QGIS_SERVER_LOG_LEVEL=0" ),
287 QStringLiteral( "/qgis/server_log_profile" ),
288 QVariant::Bool,
289 QVariant( false ),
290 QVariant()
291 };
292
293 mSettings[ sLogProfile.envVar ] = sLogProfile;
294
295 // the default service URL.
296 const Setting sServiceUrl = { QgsServerSettingsEnv::QGIS_SERVER_SERVICE_URL,
298 QStringLiteral( "The default service URL" ),
299 QStringLiteral( "/qgis/server_service_url" ),
300 QVariant::String,
301 QVariant( "" ),
302 QVariant()
303 };
304 mSettings[ sServiceUrl.envVar ] = sServiceUrl;
305
306 // the default WMS service URL.
307 const Setting sWmsServiceUrl = { QgsServerSettingsEnv::QGIS_SERVER_WMS_SERVICE_URL,
309 QStringLiteral( "The default WMS service URL" ),
310 QStringLiteral( "/qgis/server_wms_service_url" ),
311 QVariant::String,
312 QVariant( "" ),
313 QVariant()
314 };
315 mSettings[ sServiceUrl.envVar ] = sWmsServiceUrl;
316
317 // the default WFS service URL.
318 const Setting sWfsServiceUrl = { QgsServerSettingsEnv::QGIS_SERVER_WFS_SERVICE_URL,
320 QStringLiteral( "The default WFS service URL" ),
321 QStringLiteral( "/qgis/server_wfs_service_url" ),
322 QVariant::String,
323 QVariant( "" ),
324 QVariant()
325 };
326 mSettings[ sServiceUrl.envVar ] = sWfsServiceUrl;
327
328 // the default WCS service URL.
329 const Setting sWcsServiceUrl = { QgsServerSettingsEnv::QGIS_SERVER_WCS_SERVICE_URL,
331 QStringLiteral( "The default WcS service URL" ),
332 QStringLiteral( "/qgis/server_wcs_service_url" ),
333 QVariant::String,
334 QVariant( "" ),
335 QVariant()
336 };
337 mSettings[ sServiceUrl.envVar ] = sWfsServiceUrl;
338
339 // the default WMTS service URL.
340 const Setting sWmtsServiceUrl = { QgsServerSettingsEnv::QGIS_SERVER_WMTS_SERVICE_URL,
342 QStringLiteral( "The default WMTS service URL" ),
343 QStringLiteral( "/qgis/server_wmts_service_url" ),
344 QVariant::String,
345 QVariant( "" ),
346 QVariant()
347 };
348 mSettings[ sServiceUrl.envVar ] = sWmtsServiceUrl;
349
350 // the default config cache check interval
351 const Setting sConfigCacheCheckInterval = { QgsServerSettingsEnv::QGIS_SERVER_PROJECT_CACHE_CHECK_INTERVAL,
353 QStringLiteral( "The default project cache check interval (in ms)" ),
354 QStringLiteral( "/qgis/server_project_cache_check_interval" ),
355 QVariant::Int,
356 QVariant( 0 ),
357 QVariant()
358 };
359 mSettings[ sConfigCacheCheckInterval.envVar ] = sConfigCacheCheckInterval;
360
361 // the default config cache strategy
362 const Setting sProjectCacheStrategy = { QgsServerSettingsEnv::QGIS_SERVER_PROJECT_CACHE_STRATEGY,
364 QStringLiteral( "Project's cache strategy. Possible values are 'off','filesystem' or 'periodic'" ),
365 QStringLiteral( "/qgis/server_project_cache_strategy" ),
366 QVariant::String,
367 QVariant( "" ),
368 QVariant()
369 };
370 mSettings[ sProjectCacheStrategy.envVar ] = sProjectCacheStrategy;
371
372 const Setting sAllowedExtraSqlTokens = { QgsServerSettingsEnv::QGIS_SERVER_ALLOWED_EXTRA_SQL_TOKENS,
374 QStringLiteral( "List of comma separated SQL tokens to be added to the list of allowed tokens that the services accepts when filtering features" ),
375 QStringLiteral( "/qgis/server_allowed_extra_sql_tokens" ),
376 QVariant::String,
377 QVariant( "" ),
378 QVariant()
379 };
380 mSettings[ sAllowedExtraSqlTokens.envVar ] = sAllowedExtraSqlTokens;
381
382 const Setting sApplicationName = { QgsServerSettingsEnv::QGIS_SERVER_APPLICATION_NAME,
384 QStringLiteral( "The QGIS Server application name" ),
385 QStringLiteral( "/qgis/application_full_name" ),
386 QVariant::String,
388 QVariant()
389 };
390 mSettings[ sApplicationName.envVar ] = sApplicationName;
391
392 const Setting sCapabilitiesCacheSize = { QgsServerSettingsEnv::QGIS_SERVER_CAPABILITIES_CACHE_SIZE,
394 QStringLiteral( "The QGIS Server capabilities cache size" ),
395 QStringLiteral( "/qgis/capabilities_cache_size" ),
396 QVariant::Int,
397 QVariant( 40 ),
398 QVariant()
399 };
400 mSettings[ sCapabilitiesCacheSize.envVar ] = sCapabilitiesCacheSize;
401}
402
404{
405 // init settings each time to take into account QgsApplication and
406 // QCoreApplication configuration for some default values
407 initSettings();
408
409 // store environment variables
410 QMap<QgsServerSettingsEnv::EnvVar, QString> env = getEnv();
411
412 // load QSettings if QGIS_OPTIONS_PATH is defined
413 loadQSettings( env[ QgsServerSettingsEnv::QGIS_OPTIONS_PATH ] );
414
415 // prioritize values: 'env var' -> 'ini file' -> 'default value'
416 prioritize( env );
417}
418
419bool QgsServerSettings::load( const QString &envVarName )
420{
421 bool rc( false );
422 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
423 const int value = metaEnum.keyToValue( envVarName.toStdString().c_str() );
424
425 if ( value >= 0 )
426 {
427 const QString envValue( getenv( envVarName.toStdString().c_str() ) );
428 prioritize( QMap<QgsServerSettingsEnv::EnvVar, QString> { {( QgsServerSettingsEnv::EnvVar ) value, envValue } } );
429 rc = true;
430 }
431
432 return rc;
433}
434
435QMap<QgsServerSettingsEnv::EnvVar, QString> QgsServerSettings::getEnv() const
436{
437 QMap<QgsServerSettingsEnv::EnvVar, QString> env;
438
439 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
440 for ( int i = 0; i < metaEnum.keyCount(); i++ )
441 {
442 env[( QgsServerSettingsEnv::EnvVar ) metaEnum.value( i )] = getenv( metaEnum.key( i ) );
443 }
444
445 return env;
446}
447
448QVariant QgsServerSettings::value( QgsServerSettingsEnv::EnvVar envVar, bool actual ) const
449{
450 if ( actual )
451 {
452 const QString envValue( getenv( name( envVar ).toStdString().c_str() ) );
453
454 if ( ! envValue.isEmpty() )
455 return envValue;
456 }
457
458 if ( mSettings[ envVar ].src == QgsServerSettingsEnv::DEFAULT_VALUE )
459 {
460 return mSettings[ envVar ].defaultVal;
461 }
462 else
463 {
464 return mSettings[ envVar ].val;
465 }
466}
467
468void QgsServerSettings::loadQSettings( const QString &envOptPath ) const
469{
470 if ( ! envOptPath.isEmpty() )
471 {
472 QSettings::setDefaultFormat( QSettings::IniFormat );
473 QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, envOptPath );
474 }
475}
476
477void QgsServerSettings::prioritize( const QMap<QgsServerSettingsEnv::EnvVar, QString> &env )
478{
479 const auto constKeys( env.keys() );
480 for ( const QgsServerSettingsEnv::EnvVar &e : constKeys )
481 {
482 Setting s = mSettings[ e ];
483
484 QVariant varValue;
485 if ( ! env.value( e ).isEmpty() )
486 {
487 varValue.setValue( env.value( e ) );
488 }
489
490 if ( !QgsVariantUtils::isNull( varValue ) && varValue.canConvert( s.type ) )
491 {
492 s.val = varValue;
494 }
495 else if ( ! s.iniKey.isEmpty() && QSettings().contains( s.iniKey ) && QSettings().value( s.iniKey ).canConvert( s.type ) )
496 {
497 s.val = QSettings().value( s.iniKey );
499 }
500 else
501 {
502 s.val = QVariant();
504 }
505
506 // an empty string can be returned from QSettings. In this case, we want
507 // to use the default value
508 if ( s.type == QVariant::String && s.val.toString().isEmpty() )
509 {
510 s.val = QVariant();
512 }
513
514 mSettings[ e ] = s;
515 }
516}
517
519{
520 const QMetaEnum metaEnumEnv( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
521 return metaEnumEnv.valueToKey( env );
522}
523
525{
526 const QMetaEnum metaEnumSrc( QMetaEnum::fromType<QgsServerSettingsEnv::Source>() );
527
528 QgsMessageLog::logMessage( "QGIS Server Settings: ", "Server", Qgis::MessageLevel::Info );
529 for ( const Setting &s : std::as_const( mSettings ) )
530 {
531 const QString src = metaEnumSrc.valueToKey( s.src );
532 const QString var = name( s.envVar );
533
534 const QString msg = " - " + var + " / '" + s.iniKey + "' (" + s.descr + "): '" + value( s.envVar ).toString() + "' (read from " + src + ")";
536 }
537
538 if ( ! iniFile().isEmpty() )
539 {
540 const QString msg = "Ini file used to initialize settings: " + iniFile();
542 }
543}
544
545// getter
547{
548 return QSettings().fileName();
549}
550
555
557{
558 return value( QgsServerSettingsEnv::QGIS_SERVER_MAX_THREADS ).toInt();
559}
560
562{
563 return value( QgsServerSettingsEnv::QGIS_SERVER_LOG_FILE ).toString();
564}
565
567{
568 return value( QgsServerSettingsEnv::QGIS_SERVER_LOG_STDERR ).toBool();
569}
570
575
577{
578 return value( QgsServerSettingsEnv::QGIS_PROJECT_FILE ).toString();
579}
580
582{
583 return value( QgsServerSettingsEnv::QGIS_SERVER_CACHE_SIZE ).toLongLong();
584}
585
587{
588 return value( QgsServerSettingsEnv::QGIS_SERVER_CACHE_DIRECTORY ).toString();
589}
590
595
600
605
610
615
620
625
630
632{
633 return value( QgsServerSettingsEnv::QGIS_SERVER_API_WFS3_MAX_LIMIT ).toLongLong();
634}
635
640
645
650
655
657{
658 return value( QgsServerSettingsEnv::QGIS_SERVER_LOG_PROFILE, false ).toBool();
659}
660
661QString QgsServerSettings::serviceUrl( const QString &service ) const
662{
663 QString result;
664 if ( service.compare( QLatin1String( "WMS" ) ) )
665 {
666 result = value( QgsServerSettingsEnv::QGIS_SERVER_WMS_SERVICE_URL ).toString();
667 }
668 else if ( service.compare( QLatin1String( "WFS" ) ) )
669 {
670 result = value( QgsServerSettingsEnv::QGIS_SERVER_WFS_SERVICE_URL ).toString();
671 }
672 else if ( service.compare( QLatin1String( "WCS" ) ) )
673 {
674 result = value( QgsServerSettingsEnv::QGIS_SERVER_WCS_SERVICE_URL ).toString();
675 }
676 else if ( service.compare( QLatin1String( "WMTS" ) ) )
677 {
678 result = value( QgsServerSettingsEnv::QGIS_SERVER_WMTS_SERVICE_URL ).toString();
679 }
680
681 if ( result.isEmpty() )
682 {
683 result = value( QgsServerSettingsEnv::QGIS_SERVER_SERVICE_URL ).toString();
684 }
685
686 return result;
687}
688
693
695{
696 QString result = value( QgsServerSettingsEnv::QGIS_SERVER_PROJECT_CACHE_STRATEGY ).toString();
697 if ( result.compare( QLatin1String( "filesystem" ) ) &&
698 result.compare( QLatin1String( "periodic" ) ) &&
699 result.compare( QLatin1String( "off" ) ) )
700 {
701 QgsMessageLog::logMessage( QStringLiteral( "Invalid cache strategy, expecting 'filesystem', 'periodic' or 'off'. Using 'filesystem' as default." ), "Server", Qgis::MessageLevel::Warning );
702 result = QStringLiteral( "filesystem" );
703 }
704 return result;
705}
706
708{
709 const QString strVal { value( QgsServerSettingsEnv::QGIS_SERVER_ALLOWED_EXTRA_SQL_TOKENS ).toString().trimmed() };
710 if ( strVal.isEmpty() )
711 {
712 return QStringList();
713 }
714 return strVal.split( ',' );
715}
716
718{
719 return value( QgsServerSettingsEnv::QGIS_SERVER_APPLICATION_NAME ).toString().trimmed();
720}
721
723{
724 bool ok;
725 int size = value( QgsServerSettingsEnv::QGIS_SERVER_CAPABILITIES_CACHE_SIZE ).toInt( &ok );
726 if ( ok && size >= 1 )
727 return size;
728
729 QgsMessageLog::logMessage( QStringLiteral( "Invalid capabilities cache size, expecting integer - defaulting to 40" ), "Server", Qgis::MessageLevel::Warning );
730 return 40;
731}
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition qgis.h:99
@ NoLevel
No level.
Definition qgis.h:104
@ Warning
Warning message.
Definition qgis.h:101
@ Info
Information message.
Definition qgis.h:100
static QString pkgDataPath()
Returns the common root path of all application data directories.
static QString applicationFullName()
Returns the QGIS application full name.
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
EnvVar
Environment variables to configure the server.
@ QGIS_SERVER_WCS_SERVICE_URL
To set the WCS service URL if it's not present in the project. (since QGIS 3.20).
@ QGIS_SERVER_WMTS_SERVICE_URL
To set the WMTS service URL if it's not present in the project. (since QGIS 3.20).
@ QGIS_SERVER_IGNORE_BAD_LAYERS
Do not consider the whole project unavailable if it contains bad layers.
@ QGIS_SERVER_ALLOWED_EXTRA_SQL_TOKENS
Set the project cache strategy. Possible values are 'filesystem', 'periodic' or 'off' (since QGIS 3....
@ QGIS_SERVER_CAPABILITIES_CACHE_SIZE
Define the QGIS Server application name (since QGIS 3.30).
@ QGIS_SERVER_TRUST_LAYER_METADATA
Trust layer metadata. Improves project read time. (since QGIS 3.16).
@ QGIS_SERVER_WFS_SERVICE_URL
To set the WFS service URL if it's not present in the project. (since QGIS 3.20).
@ QGIS_SERVER_OVERRIDE_SYSTEM_LOCALE
Override system locale (since QGIS 3.8)
@ QGIS_SERVER_LANDING_PAGE_PROJECTS_PG_CONNECTIONS
PostgreSQL connection strings used by the landing page service to find projects (since QGIS 3....
@ QGIS_SERVER_API_WFS3_MAX_LIMIT
Maximum value for "limit" in a features request, defaults to 10000 (since QGIS 3.10).
@ QGIS_SERVER_API_RESOURCES_DIRECTORY
Base directory where HTML templates and static assets (e.g. images, js and css files) are searched fo...
@ QGIS_SERVER_WMS_MAX_WIDTH
Maximum width for a WMS request. The most conservative between this and the project one is used (sinc...
@ QGIS_SERVER_FORCE_READONLY_LAYERS
Force to open layers in read-only mode. (since QGIS 3.28).
@ QGIS_SERVER_PROJECT_CACHE_STRATEGY
Set the interval in milliseconds for cache invalidation strategy 'interval', default to 0 which selec...
@ QGIS_SERVER_APPLICATION_NAME
Adds these tokens to the list of allowed tokens that the services accept when filtering features (sin...
@ QGIS_SERVER_WMS_MAX_HEIGHT
Maximum height for a WMS request. The most conservative between this and the project one is used (sin...
@ QGIS_SERVER_WMS_SERVICE_URL
To set the WMS service URL if it's not present in the project. (since QGIS 3.20).
@ QGIS_SERVER_DISABLE_GETPRINT
Disabled WMS GetPrint request and don't load layouts. Improves project read time. (since QGIS 3....
@ QGIS_SERVER_PROJECT_CACHE_CHECK_INTERVAL
Prefix of the path component of the landing page base URL, default is empty (since QGIS 3....
@ QGIS_SERVER_SHOW_GROUP_SEPARATOR
Show group (thousands) separator when formatting numeric values, defaults to false (since QGIS 3....
@ QGIS_SERVER_LANDING_PAGE_PROJECTS_DIRECTORIES
Directories used by the landing page service to find .qgs and .qgz projects (since QGIS 3....
@ QGIS_SERVER_LOG_PROFILE
When QGIS_SERVER_LOG_LEVEL is 0 this flag adds to the logs detailed information about the time taken ...
@ QGIS_SERVER_SERVICE_URL
To set the service URL if it's not present in the project. (since QGIS 3.20).
QString serviceUrl(const QString &service) const
Returns the service URL from the setting.
QString cacheDirectory() const
Returns the cache directory.
bool getPrintDisabled() const
Returns true if WMS GetPrint request is disabled and the project's reading flag QgsProject::ReadFlag:...
QString landingPageProjectsPgConnections() const
Returns the PostgreSQL connection strings used by the landing page service to find projects.
int maxThreads() const
Returns the maximum number of threads to use.
bool logStderr() const
Returns whether logging to stderr is activated.
QgsServerSettings()
Constructor.
QString projectFile() const
Returns the QGS project file to use.
QString apiResourcesDirectory() const
Returns the server-wide base directory where HTML templates and static assets (e.g.
int projectCacheCheckInterval() const
Returns the config cache check interval (in ms) for the 'periodic' strategy.
Qgis::MessageLevel logLevel() const
Returns the log level.
bool logProfile() const
Returns true if profile information has to be added to the logs, default value is false.
QStringList allowedExtraSqlTokens() const
Returns the list of strings that represent the allowed extra SQL tokens accepted as components of a f...
bool forceReadOnlyLayers() const
Returns true if the reading flag force layer read only is activated.
int wmsMaxWidth() const
Returns the server-wide max width of a WMS GetMap request.
int capabilitiesCacheSize() const
Returns the maximum number of project capabilities to cache.
static QString name(QgsServerSettingsEnv::EnvVar env)
Returns the string representation of a setting.
QString landingPageBaseUrlPrefix() const
Returns the landing page base URL regular expression, defaults to /.
void logSummary() const
Log a summary of settings currently loaded.
QString logFile() const
Returns the log file.
qlonglong apiWfs3MaxLimit() const
Returns the server-wide maximum allowed value for "limit" in a features request.
int wmsMaxHeight() const
Returns the server-wide max height of a WMS GetMap request.
QString landingPageProjectsDirectories() const
Returns the directories used by the landing page service to find .qgs and .qgz projects.
bool parallelRendering() const
Returns parallel rendering setting.
QString applicationName() const
Returns the QGIS Server application name.
bool showGroupSeparator() const
Show group (thousand) separator.
bool ignoreBadLayers() const
Returns true if the bad layers are ignored and false when the presence of a bad layers invalidates th...
QString iniFile() const
Returns the ini file loaded by QSetting.
QString projectCacheStrategy() const
Returns the project's cache strategy The default value is 'filesystem', the value can be changed by s...
QString overrideSystemLocale() const
Overrides system locale.
bool trustLayerMetadata() const
Returns true if the reading flag trust layer metadata is activated.
void load()
Load settings according to current environment variables.
qint64 cacheSize() const
Returns the cache size.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.