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#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
64 QStringList layersList = parameters[ QStringLiteral(
"LAYERS" )].split(
',', QString::SkipEmptyParts );
66 const QStringList layersList = parameters[ QStringLiteral(
"LAYERS" )].split(
',', Qt::SkipEmptyParts );
68 if ( layersList.isEmpty() )
70 throw QgsServiceException( QStringLiteral(
"InvalidParameterValue" ), QStringLiteral(
"Layers is empty" ), 400 );
72 QDomDocument myDocument = QDomDocument();
74 const QDomNode header = myDocument.createProcessingInstruction( QStringLiteral(
"xml" ), QStringLiteral(
"version=\"1.0\" encoding=\"UTF-8\"" ) );
75 myDocument.appendChild( header );
78 QDomElement root = myDocument.createElementNS( QStringLiteral(
"http://www.opengis.net/sld" ), QStringLiteral(
"DescribeLayerResponse" ) );
79 root.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), QStringLiteral(
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/DescribeLayer.xsd" ) );
80 root.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
81 root.setAttribute( QStringLiteral(
"xmlns:se" ), QStringLiteral(
"http://www.opengis.net/se" ) );
82 root.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
83 root.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
84 myDocument.appendChild( root );
87 QDomElement versionNode = myDocument.createElement( QStringLiteral(
"Version" ) );
88 versionNode.appendChild( myDocument.createTextNode( QStringLiteral(
"1.1.0" ) ) );
89 root.appendChild( versionNode );
98 if ( wfsHrefString.isEmpty() )
100 wfsHrefString = wmsHrefString;
106 if ( wcsHrefString.isEmpty() )
108 wcsHrefString = wmsHrefString;
112#ifdef HAVE_SERVER_PYTHON_PLUGINS
128 QString name = layer->name();
131 else if ( !layer->shortName().isEmpty() )
132 name = layer->shortName();
134 if ( !layersList.contains( name ) )
140 if ( restrictedLayers.contains( layer->name() ) )
145#ifdef HAVE_SERVER_PYTHON_PLUGINS
153 QDomElement layerNode = myDocument.createElement( QStringLiteral(
"LayerDescription" ) );
154 root.appendChild( layerNode );
157 QDomElement typeNode = myDocument.createElement( QStringLiteral(
"owsType" ) );
159 QDomElement oResNode = myDocument.createElement( QStringLiteral(
"se:OnlineResource" ) );
160 oResNode.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
162 QDomElement nameNode = myDocument.createElement( QStringLiteral(
"TypeName" ) );
163 switch ( layer->type() )
167 typeNode.appendChild( myDocument.createTextNode( QStringLiteral(
"wfs" ) ) );
169 if ( wfsLayerIds.indexOf( layer->id() ) != -1 )
171 oResNode.setAttribute( QStringLiteral(
"xlink:href" ), wfsHrefString );
175 QDomElement typeNameNode = myDocument.createElement( QStringLiteral(
"se:FeatureTypeName" ) );
176 typeNameNode.appendChild( myDocument.createTextNode( name ) );
177 nameNode.appendChild( typeNameNode );
182 typeNode.appendChild( myDocument.createTextNode( QStringLiteral(
"wcs" ) ) );
184 if ( wcsLayerIds.indexOf( layer->id() ) != -1 )
186 oResNode.setAttribute( QStringLiteral(
"xlink:href" ), wcsHrefString );
190 QDomElement typeNameNode = myDocument.createElement( QStringLiteral(
"se:CoverageTypeName" ) );
191 typeNameNode.appendChild( myDocument.createTextNode( name ) );
192 nameNode.appendChild( typeNameNode );
205 layerNode.appendChild( typeNode );
206 layerNode.appendChild( oResNode );
207 layerNode.appendChild( nameNode );