45 if ( !parameters.contains( QStringLiteral(
"SLD_VERSION" ) ) )
47 throw QgsServiceException( QStringLiteral(
"MissingParameterValue" ), QStringLiteral(
"SLD_VERSION is mandatory for DescribeLayer operation" ), 400 );
49 if ( parameters[QStringLiteral(
"SLD_VERSION" )] != QLatin1String(
"1.1.0" ) )
51 throw QgsServiceException( QStringLiteral(
"InvalidParameterValue" ), QStringLiteral(
"SLD_VERSION = %1 is not supported" ).arg( parameters[QStringLiteral(
"SLD_VERSION" )] ), 400 );
54 if ( !parameters.contains( QStringLiteral(
"LAYERS" ) ) && !parameters.contains( QStringLiteral(
"LAYER" ) ) )
56 throw QgsServiceException( QStringLiteral(
"MissingParameterValue" ), QStringLiteral(
"LAYERS or LAYER is mandatory for DescribeLayer operation" ), 400 );
59 QStringList layersList;
61 if ( parameters.contains( QStringLiteral(
"LAYERS" ) ) )
63 layersList = parameters[QStringLiteral(
"LAYERS" )].split(
',', Qt::SkipEmptyParts );
67 layersList = parameters[QStringLiteral(
"LAYER" )].split(
',', Qt::SkipEmptyParts );
69 if ( layersList.isEmpty() )
71 throw QgsServiceException( QStringLiteral(
"InvalidParameterValue" ), QStringLiteral(
"Layers is empty" ), 400 );
73 QDomDocument myDocument = QDomDocument();
75 const QDomNode header = myDocument.createProcessingInstruction( QStringLiteral(
"xml" ), QStringLiteral(
"version=\"1.0\" encoding=\"UTF-8\"" ) );
76 myDocument.appendChild( header );
79 QDomElement root = myDocument.createElementNS( QStringLiteral(
"http://www.opengis.net/sld" ), QStringLiteral(
"DescribeLayerResponse" ) );
80 root.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), QStringLiteral(
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/DescribeLayer.xsd" ) );
81 root.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
82 root.setAttribute( QStringLiteral(
"xmlns:se" ), QStringLiteral(
"http://www.opengis.net/se" ) );
83 root.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
84 root.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
85 myDocument.appendChild( root );
88 QDomElement versionNode = myDocument.createElement( QStringLiteral(
"Version" ) );
89 versionNode.appendChild( myDocument.createTextNode( QStringLiteral(
"1.1.0" ) ) );
90 root.appendChild( versionNode );
99 if ( wfsHrefString.isEmpty() )
101 wfsHrefString = wmsHrefString;
107 if ( wcsHrefString.isEmpty() )
109 wcsHrefString = wmsHrefString;
113#ifdef HAVE_SERVER_PYTHON_PLUGINS
116 ( void ) serverIface;
129 QString name = layer->name();
132 else if ( !layer->serverProperties()->shortName().isEmpty() )
133 name = layer->serverProperties()->shortName();
135 if ( !layersList.contains( name ) )
141 if ( restrictedLayers.contains( layer->name() ) )
146#ifdef HAVE_SERVER_PYTHON_PLUGINS
154 QDomElement layerNode = myDocument.createElement( QStringLiteral(
"LayerDescription" ) );
155 root.appendChild( layerNode );
158 QDomElement typeNode = myDocument.createElement( QStringLiteral(
"owsType" ) );
160 QDomElement oResNode = myDocument.createElement( QStringLiteral(
"se:OnlineResource" ) );
161 oResNode.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
163 QDomElement nameNode = myDocument.createElement( QStringLiteral(
"TypeName" ) );
164 switch ( layer->type() )
168 typeNode.appendChild( myDocument.createTextNode( QStringLiteral(
"wfs" ) ) );
170 if ( wfsLayerIds.indexOf( layer->id() ) != -1 )
172 oResNode.setAttribute( QStringLiteral(
"xlink:href" ), wfsHrefString );
176 QDomElement typeNameNode = myDocument.createElement( QStringLiteral(
"se:FeatureTypeName" ) );
177 typeNameNode.appendChild( myDocument.createTextNode( name ) );
178 nameNode.appendChild( typeNameNode );
183 typeNode.appendChild( myDocument.createTextNode( QStringLiteral(
"wcs" ) ) );
185 if ( wcsLayerIds.indexOf( layer->id() ) != -1 )
187 oResNode.setAttribute( QStringLiteral(
"xlink:href" ), wcsHrefString );
191 QDomElement typeNameNode = myDocument.createElement( QStringLiteral(
"se:CoverageTypeName" ) );
192 typeNameNode.appendChild( myDocument.createTextNode( name ) );
193 nameNode.appendChild( typeNameNode );
206 layerNode.appendChild( typeNode );
207 layerNode.appendChild( oResNode );
208 layerNode.appendChild( nameNode );