33 QDomDocument doc =
describeLayer( serverIface, project, version, request );
34 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
35 response.
write( doc.toByteArray() );
46 if ( !parameters.contains( QStringLiteral(
"SLD_VERSION" ) ) )
49 QStringLiteral(
"SLD_VERSION is mandatory for DescribeLayer operation" ), 400 );
51 if ( parameters[ QStringLiteral(
"SLD_VERSION" )] != QLatin1String(
"1.1.0" ) )
54 QStringLiteral(
"SLD_VERSION = %1 is not supported" ).arg( parameters[ QStringLiteral(
"SLD_VERSION" )] ), 400 );
57 if ( !parameters.contains( QStringLiteral(
"LAYERS" ) ) )
60 QStringLiteral(
"LAYERS is mandatory for DescribeLayer operation" ), 400 );
63 QStringList layersList = parameters[ QStringLiteral(
"LAYERS" )].split(
',', QString::SkipEmptyParts );
64 if ( layersList.isEmpty() )
66 throw QgsServiceException( QStringLiteral(
"InvalidParameterValue" ), QStringLiteral(
"Layers is empty" ), 400 );
68 QDomDocument myDocument = QDomDocument();
70 QDomNode header = myDocument.createProcessingInstruction( QStringLiteral(
"xml" ), QStringLiteral(
"version=\"1.0\" encoding=\"UTF-8\"" ) );
71 myDocument.appendChild( header );
74 QDomElement root = myDocument.createElementNS( QStringLiteral(
"http://www.opengis.net/sld" ), QStringLiteral(
"DescribeLayerResponse" ) );
75 root.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), QStringLiteral(
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/DescribeLayer.xsd" ) );
76 root.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
77 root.setAttribute( QStringLiteral(
"xmlns:se" ), QStringLiteral(
"http://www.opengis.net/se" ) );
78 root.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
79 root.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
80 myDocument.appendChild( root );
83 QDomElement versionNode = myDocument.createElement( QStringLiteral(
"Version" ) );
84 versionNode.appendChild( myDocument.createTextNode( QStringLiteral(
"1.1.0" ) ) );
85 root.appendChild( versionNode );
89 QString wmsHrefString =
serviceUrl( request, project ).toString();
94 if ( wfsHrefString.isEmpty() )
96 wfsHrefString = wmsHrefString;
102 if ( wcsHrefString.isEmpty() )
104 wcsHrefString = wmsHrefString;
108 #ifdef HAVE_SERVER_PYTHON_PLUGINS 124 QString name = layer->name();
127 else if ( !layer->shortName().isEmpty() )
128 name = layer->shortName();
130 if ( !layersList.contains( name ) )
136 if ( restrictedLayers.contains( layer->name() ) )
141 #ifdef HAVE_SERVER_PYTHON_PLUGINS 149 QDomElement layerNode = myDocument.createElement( QStringLiteral(
"LayerDescription" ) );
150 root.appendChild( layerNode );
153 QDomElement typeNode = myDocument.createElement( QStringLiteral(
"owsType" ) );
155 QDomElement oResNode = myDocument.createElement( QStringLiteral(
"se:OnlineResource" ) );
156 oResNode.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
158 QDomElement nameNode = myDocument.createElement( QStringLiteral(
"TypeName" ) );
161 typeNode.appendChild( myDocument.createTextNode( QStringLiteral(
"wfs" ) ) );
163 if ( wfsLayerIds.indexOf( layer->id() ) != -1 )
165 oResNode.setAttribute( QStringLiteral(
"xlink:href" ), wfsHrefString );
169 QDomElement typeNameNode = myDocument.createElement( QStringLiteral(
"se:FeatureTypeName" ) );
170 typeNameNode.appendChild( myDocument.createTextNode( name ) );
171 nameNode.appendChild( typeNameNode );
175 typeNode.appendChild( myDocument.createTextNode( QStringLiteral(
"wcs" ) ) );
177 if ( wcsLayerIds.indexOf( layer->id() ) != -1 )
179 oResNode.setAttribute( QStringLiteral(
"xlink:href" ), wcsHrefString );
183 QDomElement typeNameNode = myDocument.createElement( QStringLiteral(
"se:CoverageTypeName" ) );
184 typeNameNode.appendChild( myDocument.createTextNode( name ) );
185 nameNode.appendChild( typeNameNode );
187 layerNode.appendChild( typeNode );
188 layerNode.appendChild( oResNode );
189 layerNode.appendChild( nameNode );
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...
Base class for all map layer types.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device...
Exception class for WMS service exceptions.
SERVER_EXPORT QStringList wcsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WCS.
Reads and writes project states.
Median cut implementation.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
SERVER_EXPORT QString wcsServiceUrl(const QgsProject &project)
Returns the WCS service url defined in a QGIS project.
Exception thrown when data access violates access controls.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
QUrl serviceUrl(const QgsServerRequest &request, const QgsProject *project)
Returns WMS service URL.
A helper class that centralizes restrictions given by all the access control filter plugins...
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.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
void writeDescribeLayer(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output GetMap response in DXF format.
SERVER_EXPORT QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list.
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
SERVER_EXPORT QString wfsServiceUrl(const QgsProject &project)
Returns the WFS service url defined in a QGIS project.
QMap< QString, QgsMapLayer * > mapLayers() const
Returns a map of all registered layers by layer ID.
QMap< QString, QString > Parameters
SERVER_EXPORT bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.