34 QDomDocument doc =
describeLayer( serverIface, project, version, request );
35 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
36 response.
write( doc.toByteArray() );
47 if ( !parameters.contains( QStringLiteral(
"SLD_VERSION" ) ) )
50 QStringLiteral(
"SLD_VERSION is mandatory for DescribeLayer operation" ), 400 );
52 if ( parameters[ QStringLiteral(
"SLD_VERSION" )] != QLatin1String(
"1.1.0" ) )
55 QStringLiteral(
"SLD_VERSION = %1 is not supported" ).arg( parameters[ QStringLiteral(
"SLD_VERSION" )] ), 400 );
58 if ( !parameters.contains( QStringLiteral(
"LAYERS" ) ) )
61 QStringLiteral(
"LAYERS is mandatory for DescribeLayer operation" ), 400 );
64 QStringList layersList = parameters[ QStringLiteral(
"LAYERS" )].split(
',', QString::SkipEmptyParts );
65 if ( layersList.isEmpty() )
67 throw QgsServiceException( QStringLiteral(
"InvalidParameterValue" ), QStringLiteral(
"Layers is empty" ), 400 );
69 QDomDocument myDocument = QDomDocument();
71 QDomNode header = myDocument.createProcessingInstruction( QStringLiteral(
"xml" ), QStringLiteral(
"version=\"1.0\" encoding=\"UTF-8\"" ) );
72 myDocument.appendChild( header );
75 QDomElement root = myDocument.createElementNS( QStringLiteral(
"http://www.opengis.net/sld" ), QStringLiteral(
"DescribeLayerResponse" ) );
76 root.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), QStringLiteral(
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/DescribeLayer.xsd" ) );
77 root.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
78 root.setAttribute( QStringLiteral(
"xmlns:se" ), QStringLiteral(
"http://www.opengis.net/se" ) );
79 root.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
80 root.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
81 myDocument.appendChild( root );
84 QDomElement versionNode = myDocument.createElement( QStringLiteral(
"Version" ) );
85 versionNode.appendChild( myDocument.createTextNode( QStringLiteral(
"1.1.0" ) ) );
86 root.appendChild( versionNode );
90 QString wmsHrefString =
serviceUrl( request, project ).toString();
95 if ( wfsHrefString.isEmpty() )
97 wfsHrefString = wmsHrefString;
103 if ( wcsHrefString.isEmpty() )
105 wcsHrefString = wmsHrefString;
109 #ifdef HAVE_SERVER_PYTHON_PLUGINS
125 QString name = layer->name();
128 else if ( !layer->shortName().isEmpty() )
129 name = layer->shortName();
131 if ( !layersList.contains( name ) )
137 if ( restrictedLayers.contains( layer->name() ) )
142 #ifdef HAVE_SERVER_PYTHON_PLUGINS
150 QDomElement layerNode = myDocument.createElement( QStringLiteral(
"LayerDescription" ) );
151 root.appendChild( layerNode );
154 QDomElement typeNode = myDocument.createElement( QStringLiteral(
"owsType" ) );
156 QDomElement oResNode = myDocument.createElement( QStringLiteral(
"se:OnlineResource" ) );
157 oResNode.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
159 QDomElement nameNode = myDocument.createElement( QStringLiteral(
"TypeName" ) );
160 switch ( layer->type() )
164 typeNode.appendChild( myDocument.createTextNode( QStringLiteral(
"wfs" ) ) );
168 oResNode.setAttribute( QStringLiteral(
"xlink:href" ), wfsHrefString );
172 QDomElement typeNameNode = myDocument.createElement( QStringLiteral(
"se:FeatureTypeName" ) );
173 typeNameNode.appendChild( myDocument.createTextNode( name ) );
174 nameNode.appendChild( typeNameNode );
179 typeNode.appendChild( myDocument.createTextNode( QStringLiteral(
"wcs" ) ) );
183 oResNode.setAttribute( QStringLiteral(
"xlink:href" ), wcsHrefString );
187 QDomElement typeNameNode = myDocument.createElement( QStringLiteral(
"se:CoverageTypeName" ) );
188 typeNameNode.appendChild( myDocument.createTextNode( name ) );
189 nameNode.appendChild( typeNameNode );
200 layerNode.appendChild( typeNode );
201 layerNode.appendChild( oResNode );
202 layerNode.appendChild( nameNode );
A helper class that centralizes restrictions given by all the access control filter plugins.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.
Base class for all map layer types.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
QMap< QString, QString > Parameters
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
virtual void setHeader(const QString &key, const QString &value)=0
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
Exception thrown when data access violates access controls.
Exception class for WMS service exceptions.
@ PointCloudLayer
Added in 3.18.
@ VectorTileLayer
Added in 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
SERVER_EXPORT QString wcsServiceUrl(const QgsProject &project)
Returns the WCS service url defined in a QGIS project.
SERVER_EXPORT QString wfsServiceUrl(const QgsProject &project)
Returns the WFS service url defined in a QGIS project.
SERVER_EXPORT bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
SERVER_EXPORT QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list.
SERVER_EXPORT QStringList wcsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WCS.
Median cut implementation.
QDomDocument describeLayer(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
DescribeLayer is defined for WMS1.1.1/SLD1.0 and in WMS 1.3.0 SLD Extension.
void writeDescribeLayer(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output GetMap response in DXF format.
QUrl serviceUrl(const QgsServerRequest &request, const QgsProject *project)
Returns WMS service URL.