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" ) ) && !parameters.contains( QStringLiteral(
"LAYER" ) ) )
60 QStringLiteral(
"LAYERS or LAYER is mandatory for DescribeLayer operation" ), 400 );
63 QStringList layersList;
65 if ( parameters.contains( QStringLiteral(
"LAYERS" ) ) )
67 layersList = parameters[ QStringLiteral(
"LAYERS" )].split(
',', Qt::SkipEmptyParts );
71 layersList = parameters[ QStringLiteral(
"LAYER" )].split(
',', Qt::SkipEmptyParts );
73 if ( layersList.isEmpty() )
75 throw QgsServiceException( QStringLiteral(
"InvalidParameterValue" ), QStringLiteral(
"Layers is empty" ), 400 );
77 QDomDocument myDocument = QDomDocument();
79 const QDomNode header = myDocument.createProcessingInstruction( QStringLiteral(
"xml" ), QStringLiteral(
"version=\"1.0\" encoding=\"UTF-8\"" ) );
80 myDocument.appendChild( header );
83 QDomElement root = myDocument.createElementNS( QStringLiteral(
"http://www.opengis.net/sld" ), QStringLiteral(
"DescribeLayerResponse" ) );
84 root.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), QStringLiteral(
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/DescribeLayer.xsd" ) );
85 root.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
86 root.setAttribute( QStringLiteral(
"xmlns:se" ), QStringLiteral(
"http://www.opengis.net/se" ) );
87 root.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
88 root.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
89 myDocument.appendChild( root );
92 QDomElement versionNode = myDocument.createElement( QStringLiteral(
"Version" ) );
93 versionNode.appendChild( myDocument.createTextNode( QStringLiteral(
"1.1.0" ) ) );
94 root.appendChild( versionNode );
103 if ( wfsHrefString.isEmpty() )
105 wfsHrefString = wmsHrefString;
111 if ( wcsHrefString.isEmpty() )
113 wcsHrefString = wmsHrefString;
117#ifdef HAVE_SERVER_PYTHON_PLUGINS
133 QString name = layer->name();
136 else if ( !layer->serverProperties()->shortName().isEmpty() )
137 name = layer->serverProperties()->shortName();
139 if ( !layersList.contains( name ) )
145 if ( restrictedLayers.contains( layer->name() ) )
150#ifdef HAVE_SERVER_PYTHON_PLUGINS
158 QDomElement layerNode = myDocument.createElement( QStringLiteral(
"LayerDescription" ) );
159 root.appendChild( layerNode );
162 QDomElement typeNode = myDocument.createElement( QStringLiteral(
"owsType" ) );
164 QDomElement oResNode = myDocument.createElement( QStringLiteral(
"se:OnlineResource" ) );
165 oResNode.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
167 QDomElement nameNode = myDocument.createElement( QStringLiteral(
"TypeName" ) );
168 switch ( layer->type() )
172 typeNode.appendChild( myDocument.createTextNode( QStringLiteral(
"wfs" ) ) );
174 if ( wfsLayerIds.indexOf( layer->id() ) != -1 )
176 oResNode.setAttribute( QStringLiteral(
"xlink:href" ), wfsHrefString );
180 QDomElement typeNameNode = myDocument.createElement( QStringLiteral(
"se:FeatureTypeName" ) );
181 typeNameNode.appendChild( myDocument.createTextNode( name ) );
182 nameNode.appendChild( typeNameNode );
187 typeNode.appendChild( myDocument.createTextNode( QStringLiteral(
"wcs" ) ) );
189 if ( wcsLayerIds.indexOf( layer->id() ) != -1 )
191 oResNode.setAttribute( QStringLiteral(
"xlink:href" ), wcsHrefString );
195 QDomElement typeNameNode = myDocument.createElement( QStringLiteral(
"se:CoverageTypeName" ) );
196 typeNameNode.appendChild( myDocument.createTextNode( name ) );
197 nameNode.appendChild( typeNameNode );
210 layerNode.appendChild( typeNode );
211 layerNode.appendChild( oResNode );
212 layerNode.appendChild( nameNode );