25using namespace Qt::StringLiterals;
29 const double scaleFactor = std::pow( 10.0, places );
30 return ( std::ceil( number * scaleFactor ) / scaleFactor );
35 const double scaleFactor = std::pow( 10.0, places );
36 return ( std::floor( number * scaleFactor ) / scaleFactor );
41 return project.
readBoolEntry( u
"WMSServiceCapabilities"_s, u
"/"_s,
false );
46 QString title = project.
readEntry( u
"WMSServiceTitle"_s, u
"/"_s );
47 if ( title.isEmpty() )
49 title = project.
title();
51 if ( title.isEmpty() )
53 title = QObject::tr(
"Untitled" );
60 return project.
readEntry( u
"WMSServiceAbstract"_s, u
"/"_s );
65 QStringList keywordList;
66 const QStringList list = project.
readListEntry( u
"WMSKeywordList"_s, u
"/"_s, QStringList() );
67 if ( !list.isEmpty() )
69 for (
int i = 0; i < list.size(); ++i )
71 const QString keyword = list.at( i );
72 if ( !keyword.isEmpty() )
74 keywordList.append( keyword );
83 QString wmsOnlineResource = project.
readEntry( u
"WMSOnlineResource"_s, u
"/"_s );
89 return wmsOnlineResourceProperty.
valueAsString( context, wmsOnlineResource );
92 return wmsOnlineResource;
97 return project.
readEntry( u
"WMSContactOrganization"_s, u
"/"_s );
102 return project.
readEntry( u
"WMSContactPosition"_s, u
"/"_s );
107 return project.
readEntry( u
"WMSContactPerson"_s, u
"/"_s );
112 return project.
readEntry( u
"WMSContactMail"_s, u
"/"_s );
117 return project.
readEntry( u
"WMSContactPhone"_s, u
"/"_s );
122 return project.
readEntry( u
"WMSFees"_s, u
"/"_s );
127 return project.
readEntry( u
"WMSAccessConstraints"_s, u
"/"_s );
132 return project.
readNumEntry( u
"WMSMaxWidth"_s, u
"/"_s, -1 );
137 return project.
readNumEntry( u
"WMSMaxHeight"_s, u
"/"_s, -1 );
142 return project.
readBoolEntry( u
"WMSUseLayerIDs"_s, u
"/"_s,
false );
147 return project.
readNumEntry( u
"WMSImageQuality"_s, u
"/"_s, -1 );
152 return project.
readNumEntry( u
"WMSTileBuffer"_s, u
"/"_s, 0 );
157 return project.
readNumEntry( u
"WMSMaxAtlasFeatures"_s, u
"/"_s, 1 );
162 return project.
readDoubleEntry( u
"WMSDefaultMapUnitsPerMm"_s, u
"/"_s, 1 );
167 const QString sia2045 = project.
readEntry( u
"WMSInfoFormatSIA2045"_s, u
"/"_s,
"" );
169 return sia2045.compare(
"enabled"_L1, Qt::CaseInsensitive ) == 0
170 || sia2045.compare(
"true"_L1, Qt::CaseInsensitive ) == 0;
175 const QString wktGeom = project.
readEntry( u
"WMSAddWktGeometry"_s, u
"/"_s,
"" );
177 return wktGeom.compare(
"enabled"_L1, Qt::CaseInsensitive ) == 0
178 || wktGeom.compare(
"true"_L1, Qt::CaseInsensitive ) == 0;
183 const QString useFormSettings = project.
readEntry( u
"WMSFeatureInfoUseAttributeFormSettings"_s, u
"/"_s,
"" );
184 return useFormSettings.compare(
"enabled"_L1, Qt::CaseInsensitive ) == 0
185 || useFormSettings.compare(
"true"_L1, Qt::CaseInsensitive ) == 0;
190 const QString useFormSettings = project.
readEntry( u
"WMSHTMLFeatureInfoUseOnlyMaptip"_s, u
"/"_s,
"" );
191 return useFormSettings.compare(
"true"_L1, Qt::CaseInsensitive ) == 0;
196 const QString segmGeom = project.
readEntry( u
"WMSSegmentizeFeatureInfoGeometry"_s, u
"/"_s,
"" );
198 return segmGeom.compare(
"enabled"_L1, Qt::CaseInsensitive ) == 0
199 || segmGeom.compare(
"true"_L1, Qt::CaseInsensitive ) == 0;
204 const QString legendGroups = project.
readEntry( u
"WMSAddLayerGroupsLegendGraphic"_s, u
"/"_s,
"" );
205 return legendGroups.compare(
"enabled"_L1, Qt::CaseInsensitive ) == 0
206 || legendGroups.compare(
"true"_L1, Qt::CaseInsensitive ) == 0;
211 return project.
readBoolEntry( u
"WMSSkipNameForGroup"_s, u
"/"_s,
false );
216 return project.
readNumEntry( u
"WMSPrecision"_s, u
"/"_s, 6 );
221 return project.
readEntry( u
"WMSFeatureInfoDocumentElement"_s, u
"/"_s,
"" );
226 return project.
readEntry( u
"WMSFeatureInfoDocumentElementNS"_s, u
"/"_s,
"" );
231 return project.
readEntry( u
"WMSFeatureInfoSchema"_s, u
"/"_s,
"" );
236 QHash<QString, QString> aliasMap;
239 const QStringList aliasLayerStringList = project.
readListEntry( u
"WMSFeatureInfoAliasLayers"_s, u
"/value"_s, QStringList() );
240 if ( aliasLayerStringList.isEmpty() )
246 const QStringList layerAliasStringList = project.
readListEntry( u
"WMSFeatureInfoLayerAliases"_s, u
"/value"_s, QStringList() );
247 if ( layerAliasStringList.isEmpty() )
252 const int nMapEntries = std::min( aliasLayerStringList.size(), layerAliasStringList.size() );
253 for (
int i = 0; i < nMapEntries; ++i )
255 aliasMap.insert( aliasLayerStringList.at( i ), layerAliasStringList.at( i ) );
263 return project.
readBoolEntry( u
"WMSInspire"_s, u
"/activated"_s );
268 return project.
readEntry( u
"WMSInspire"_s, u
"/language"_s );
273 return project.
readEntry( u
"WMSInspire"_s, u
"/metadataUrl"_s );
278 return project.
readEntry( u
"WMSInspire"_s, u
"/metadataUrlType"_s );
283 return project.
readEntry( u
"WMSInspire"_s, u
"/temporalReference"_s );
288 return project.
readEntry( u
"WMSInspire"_s, u
"/metadataDate"_s );
293 return project.
readListEntry( u
"WMSRestrictedComposers"_s, u
"/"_s, QStringList() );
299 const QStringList wmsCrsList = project.
readListEntry( u
"WMSCrsList"_s, u
"/"_s, QStringList() );
300 if ( !wmsCrsList.isEmpty() )
302 for (
const auto &crs : std::as_const( wmsCrsList ) )
304 if ( !crs.isEmpty() )
306 crsList.append( crs );
310 if ( crsList.isEmpty() )
312 const QStringList valueList = project.
readListEntry( u
"WMSEpsgList"_s, u
"/"_s, QStringList() );
314 for (
const auto &espgStr : valueList )
316 const int epsgNr = espgStr.toInt( &conversionOk );
319 crsList.append( u
"EPSG:%1"_s.arg( epsgNr ) );
323 if ( crsList.isEmpty() )
326 const QString projectCrsId = project.
crs().
authid();
327 crsList.append( projectCrsId );
328 if ( projectCrsId.compare(
"EPSG:4326"_L1, Qt::CaseInsensitive ) != 0 )
330 crsList.append( u
"EPSG:%1"_s.arg( 4326 ) );
332 if ( projectCrsId.compare(
"EPSG:3857"_L1, Qt::CaseInsensitive ) != 0 )
334 crsList.append( u
"EPSG:%1"_s.arg( 3857 ) );
343 QStringList crsListAsOgcUrn;
344 for (
const QString &crsString : crsList )
349 return crsListAsOgcUrn;
354 const QString serviceUpper = service.toUpper();
355 QString url = settings.
serviceUrl( serviceUpper );
356 if ( !url.isEmpty() )
362 if ( serviceUpper ==
"WMS"_L1 )
366 else if ( serviceUpper ==
"WFS"_L1 )
370 else if ( serviceUpper ==
"WCS"_L1 )
374 else if ( serviceUpper ==
"WMTS"_L1 )
378 url = request.
header( header );
379 if ( !url.isEmpty() )
384 if ( !url.isEmpty() )
393 if ( !forwarded.isEmpty() )
395 forwarded = forwarded.split(
','_L1 )[0];
396 const QStringList elements = forwarded.split(
';' );
397 for (
const QString &element : elements )
399 QStringList splited_element = element.trimmed().split(
'='_L1 );
400 if ( splited_element[0] ==
"host" )
402 host = splited_element[1];
404 if ( splited_element[0] ==
"proto" )
406 proto = splited_element[1];
411 if ( host.isEmpty() )
417 if ( host.isEmpty() )
422 QUrl urlQUrl = request.
baseUrl();
423 if ( !proto.isEmpty() )
425 urlQUrl.setScheme( proto );
428 if ( !host.isEmpty() )
430 QStringList hostPort = host.split(
':'_L1 );
431 if ( hostPort.length() == 1 )
433 urlQUrl.setHost( hostPort[0] );
434 urlQUrl.setPort( -1 );
436 if ( hostPort.length() == 2 )
438 urlQUrl.setHost( hostPort[0] );
439 urlQUrl.setPort( hostPort[1].toInt() );
444 const QUrlQuery query { request.
originalUrl().query() };
445 const QList<QPair<QString, QString>> constItems { query.queryItems() };
447 for (
const QPair<QString, QString> &item : std::as_const( constItems ) )
449 if ( 0 == item.first.compare(
"MAP"_L1, Qt::CaseSensitivity::CaseInsensitive ) )
456 if ( !map.isEmpty() )
459 query.setQueryItems( { {
"MAP", map } } );
460 urlQUrl.setQuery( query );
464 urlQUrl.setQuery(
nullptr );
467 return urlQUrl.url();
472 QString url = project.
readEntry( u
"WMSUrl"_s, u
"/"_s,
"" );
475 url =
serviceUrl( u
"WMS"_s, request, settings );
482 return project.
readEntry( u
"WMSRootName"_s, u
"/"_s,
"" );
487 return project.
readListEntry( u
"WMSRestrictedLayers"_s, u
"/"_s, QStringList() );
493 QStringList values = project.
readListEntry( u
"WMSExtent"_s, u
"/"_s, QStringList(), &ok );
494 if ( !ok || values.size() != 4 )
499 const double xmin = values[0].toDouble();
500 const double ymin = values[1].toDouble();
501 const double xmax = values[2].toDouble();
502 const double ymax = values[3].toDouble();
508 QString url = project.
readEntry( u
"WFSUrl"_s, u
"/"_s,
"" );
511 url =
serviceUrl( u
"WFS"_s, request, settings );
523 return project.
readNumEntry( u
"WFSLayersPrecision"_s,
"/" + layerId, 6 );
528 return project.
readListEntry( u
"WFSTLayers"_s, u
"Update"_s );
533 return project.
readListEntry( u
"WFSTLayers"_s, u
"Insert"_s );
538 return project.
readListEntry( u
"WFSTLayers"_s, u
"Delete"_s );
543 QString url = project.
readEntry( u
"WCSUrl"_s, u
"/"_s,
"" );
546 url =
serviceUrl( u
"WCS"_s, request, settings );
558 QString url = project.
readEntry( u
"WMTSUrl"_s, u
"/"_s,
"" );
561 url =
serviceUrl( u
"WMTS"_s, request, settings );
568 return project.
readBoolEntry( u
"RenderMapTile"_s, u
"/"_s,
false );
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
int readNumEntry(const QString &scope, const QString &key, int def=0, bool *ok=nullptr) const
Reads an integer from the specified scope and key.
QgsPropertyCollection dataDefinedServerProperties() const
Returns the data defined properties used for overrides in user defined server parameters.
@ WMSOnlineResource
Alias.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QString readEntry(const QString &scope, const QString &key, const QString &def=QString(), bool *ok=nullptr) const
Reads a string from the specified scope and key.
bool readBoolEntry(const QString &scope, const QString &key, bool def=false, bool *ok=nullptr) const
Reads a boolean from the specified scope and key.
QgsCoordinateReferenceSystem crs
double readDoubleEntry(const QString &scope, const QString &key, double def=0, bool *ok=nullptr) const
Reads a double from the specified scope and key.
QStringList readListEntry(const QString &scope, const QString &key, const QStringList &def=QStringList(), bool *ok=nullptr) const
Reads a string list from the specified scope and key.
QgsProperty property(int key) const final
Returns a matching property from the collection, if one exists.
A store for object properties.
QString expressionString() const
Returns the expression used for the property value.
QString valueAsString(const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a string.
bool isActive() const
Returns whether the property is currently active.
A rectangle specified with double values.
static QString wmsFeatureInfoSchema(const QgsProject &project)
Returns the schema URL for XML GetFeatureInfo request.
static int wmsTileBuffer(const QgsProject &project)
Returns the tile buffer in pixels for WMS images defined in a QGIS project.
static QString wcsServiceUrl(const QgsProject &project, const QgsServerRequest &request=QgsServerRequest(), const QgsServerSettings &settings=QgsServerSettings())
Returns the WCS service url.
static QString wmsRootName(const QgsProject &project)
Returns the WMS root layer name defined in a QGIS project.
static bool wmsInfoFormatSia2045(const QgsProject &project)
Returns if the info format is SIA20145.
static bool wmsSkipNameForGroup(const QgsProject &project)
Returns if name attribute should be skipped for groups in WMS capabilities document.
static QString wmsInspireMetadataUrl(const QgsProject &project)
Returns the Inspire metadata URL.
static bool wmsHTMLFeatureInfoUseOnlyMaptip(const QgsProject &project)
Returns if only the maptip should be used for HTML feature info response so that the HTML response to...
static QString wmtsServiceUrl(const QgsProject &project, const QgsServerRequest &request=QgsServerRequest(), const QgsServerSettings &settings=QgsServerSettings())
Returns the WMTS service url.
static int wmsFeatureInfoPrecision(const QgsProject &project)
Returns the geometry precision for GetFeatureInfo request.
static double ceilWithPrecision(double number, int places)
Returns a double greater than number to the specified number of places.
static QString wmsFeatureInfoDocumentElementNs(const QgsProject &project)
Returns the document element namespace for XML GetFeatureInfo request.
static QStringList wmsRestrictedComposers(const QgsProject &project)
Returns the restricted composer list.
static QgsRectangle wmsExtent(const QgsProject &project)
Returns the WMS Extent restriction.
static bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS.
static bool wmsFeatureInfoSegmentizeWktGeometry(const QgsProject &project)
Returns if the geometry has to be segmentize in GetFeatureInfo request.
static QString owsServiceAccessConstraints(const QgsProject &project)
Returns the owsService access constraints defined in project.
static QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
static bool wmsRenderMapTiles(const QgsProject &project)
Returns true if WMS requests should use the QgsMapSettings::RenderMapTile flag, so that no visible ar...
static QString owsServiceOnlineResource(const QgsProject &project)
Returns the owsService online resource defined in project.
static QString owsServiceFees(const QgsProject &project)
Returns the owsService fees defined in project.
static QStringList owsServiceKeywords(const QgsProject &project)
Returns the owsService keywords defined in project.
static QString owsServiceContactPosition(const QgsProject &project)
Returns the owsService contact position defined in project.
static QStringList wfstUpdateLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with update capabilities.
static bool wmsFeatureInfoUseAttributeFormSettings(const QgsProject &project)
Returns if feature form settings should be considered for the format of the feature info response.
static QStringList wmsOutputCrsListAsOgcUrn(const QgsProject &project)
Returns the WMS output CRS list as OGC URNs.
static QString serviceUrl(const QString &service, const QgsServerRequest &request, const QgsServerSettings &settings)
Returns the service url defined in the environment variable or with HTTP header.
static QStringList wfstInsertLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with insert capabilities.
static QString wmsInspireTemporalReference(const QgsProject &project)
Returns the Inspire temporal reference.
static QStringList wmsOutputCrsList(const QgsProject &project)
Returns the WMS output CRS list.
static QString wmsInspireMetadataDate(const QgsProject &project)
Returns the Inspire metadata date.
static QString owsServiceContactOrganization(const QgsProject &project)
Returns the owsService contact organization defined in project.
static QHash< QString, QString > wmsFeatureInfoLayerAliasMap(const QgsProject &project)
Returns the mapping between layer name and wms layer name for GetFeatureInfo request.
static bool wmsFeatureInfoAddWktGeometry(const QgsProject &project)
Returns if the geometry is displayed as Well Known Text in GetFeatureInfo request.
static QString wmsServiceUrl(const QgsProject &project, const QgsServerRequest &request=QgsServerRequest(), const QgsServerSettings &settings=QgsServerSettings())
Returns the WMS service url.
static QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list.
static int wmsImageQuality(const QgsProject &project)
Returns the quality for WMS images defined in a QGIS project.
static QString wmsInspireLanguage(const QgsProject &project)
Returns the Inspire language.
static QString wmsInspireMetadataUrlType(const QgsProject &project)
Returns the Inspire metadata URL type.
static double wmsDefaultMapUnitsPerMm(const QgsProject &project)
Returns the default number of map units per millimeters in case of the scale is not given.
static bool owsServiceCapabilities(const QgsProject &project)
Returns if owsService capabilities are enabled.
static bool wmsInspireActivate(const QgsProject &project)
Returns if Inspire is activated.
static int wmsMaxWidth(const QgsProject &project)
Returns the maximum width for WMS images defined in a QGIS project.
static QString owsServiceTitle(const QgsProject &project)
Returns the owsService title defined in project.
static QString owsServiceContactMail(const QgsProject &project)
Returns the owsService contact mail defined in project.
static QString owsServiceAbstract(const QgsProject &project)
Returns the owsService abstract defined in project.
static double floorWithPrecision(double number, int places)
Returns a double less than number to the specified number of places.
static QStringList wfstDeleteLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with delete capabilities.
static QString wfsServiceUrl(const QgsProject &project, const QgsServerRequest &request=QgsServerRequest(), const QgsServerSettings &settings=QgsServerSettings())
Returns the WFS service url.
static int wmsMaxHeight(const QgsProject &project)
Returns the maximum height for WMS images defined in a QGIS project.
static QStringList wcsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WCS.
static bool wmsAddLegendGroupsLegendGraphic(const QgsProject &project)
Returns if legend groups should be in the legend graphic response if GetLegendGraphic is called on a ...
static QString wmsFeatureInfoDocumentElement(const QgsProject &project)
Returns the document element name for XML GetFeatureInfo request.
static int wmsMaxAtlasFeatures(const QgsProject &project)
Returns the maximum number of atlas features which can be printed in a request.
static QString owsServiceContactPhone(const QgsProject &project)
Returns the owsService contact phone defined in project.
static int wfsLayerPrecision(const QgsProject &project, const QString &layerId)
Returns the Layer precision defined in a QGIS project for the WFS GetFeature.
static QString owsServiceContactPerson(const QgsProject &project)
Returns the owsService contact person defined in project.
Defines requests passed to QgsService classes.
virtual QString header(const QString &name) const
Returns the header value.
QUrl baseUrl() const
Returns the base URL of QGIS server.
QUrl originalUrl() const
Returns the request url as seen by the web server, by default this is equal to the url seen by QGIS s...
RequestHeader
The internal HTTP Header used for the request as enum.
@ X_QGIS_WMS_SERVICE_URL
The QGIS WMS service URL.
@ X_QGIS_WCS_SERVICE_URL
The QGIS WCS service URL.
@ X_QGIS_WFS_SERVICE_URL
The QGIS WFS service URL.
@ X_FORWARDED_PROTO
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto.
@ X_QGIS_WMTS_SERVICE_URL
The QGIS WMTS service URL.
@ X_QGIS_SERVICE_URL
The QGIS service URL.
@ X_FORWARDED_HOST
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host.
@ FORWARDED
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded, https://tools....
@ HOST
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host.
Provides a way to retrieve settings by prioritizing according to environment variables,...
QString serviceUrl(const QString &service) const
Returns the service URL from the setting.