40 QStringList &layerList );
46 QDomDocument doc =
getStyles( serverIface, project, version, request );
47 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
48 response.
write( doc.toByteArray() );
58 QString layersName = parameters.value(
"LAYERS" );
60 if ( layersName.isEmpty() )
66 QStringList layerList = layersName.split(
',', QString::SkipEmptyParts );
67 if ( layerList.isEmpty() )
73 return getStyledLayerDescriptorDocument( serverIface, project, layerList );
80 QDomDocument doc =
getStyle( serverIface, project, version, request );
81 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
82 response.
write( doc.toByteArray() );
94 QString styleName = parameters.value( QStringLiteral(
"STYLE" ) );
95 QString layerName = parameters.value( QStringLiteral(
"LAYER" ) );
97 if ( styleName.isEmpty() )
103 if ( layerName.isEmpty() )
109 QStringList layerList;
110 layerList.append( layerName );
111 return getStyledLayerDescriptorDocument( serverIface, project, layerList );
117 QStringList &layerList )
119 QDomDocument myDocument = QDomDocument();
121 QDomNode header = myDocument.createProcessingInstruction( QStringLiteral(
"xml" ), QStringLiteral(
"version=\"1.0\" encoding=\"UTF-8\"" ) );
122 myDocument.appendChild( header );
125 QDomElement root = myDocument.createElementNS( QStringLiteral(
"http://www.opengis.net/sld" ), QStringLiteral(
"StyledLayerDescriptor" ) );
126 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.1.0" ) );
127 root.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), QStringLiteral(
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" ) );
128 root.setAttribute( QStringLiteral(
"xmlns:ogc" ), QStringLiteral(
"http://www.opengis.net/ogc" ) );
129 root.setAttribute( QStringLiteral(
"xmlns:se" ), QStringLiteral(
"http://www.opengis.net/se" ) );
130 root.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
131 root.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
132 myDocument.appendChild( root );
135 #ifdef HAVE_SERVER_PYTHON_PLUGINS 147 QString name = layer->name();
150 else if ( !layer->shortName().isEmpty() )
151 name = layer->shortName();
153 if ( !layerList.contains( name ) )
159 if ( restrictedLayers.contains( layer->name() ) )
163 #ifdef HAVE_SERVER_PYTHON_PLUGINS 170 QDomElement namedLayerNode = myDocument.createElement( QStringLiteral(
"NamedLayer" ) );
171 root.appendChild( namedLayerNode );
174 QDomElement nameNode = myDocument.createElement( QStringLiteral(
"se:Name" ) );
175 nameNode.appendChild( myDocument.createTextNode( name ) );
176 namedLayerNode.appendChild( nameNode );
187 QDomElement styleElem = vlayer->
renderer()->
writeSld( myDocument, styleName );
188 namedLayerNode.appendChild( styleElem );
QDomDocument getStyle(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Returns an SLD file with the style of the requested layer.
void writeGetStyles(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output GetStyles response.
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.
QStringList styles() const
Returns list of all defined style names.
Exception thrown in case of malformed request.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device...
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
Reads and writes project states.
QgsFeatureRenderer * renderer()
Returns renderer.
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID.
void writeGetStyle(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output GetStyle response.
Median cut implementation.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QString currentStyle() const
Returns name of the current style.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
Exception thrown when data access violates access controls.
QDomDocument getStyles(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Returns an SLD file with the styles of the requested layers.
virtual QDomElement writeSld(QDomDocument &doc, const QString &styleName, const QgsStringMap &props=QgsStringMap()) const
create the SLD UserStyle element following the SLD v1.1 specs with the given name ...
A helper class that centralizes restrictions given by all the access control filter plugins...
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
SERVER_EXPORT QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list.
Represents a vector layer which manages a vector based data sets.
bool setCurrentStyle(const QString &name)
Set a different style as the current style - will apply it to the layer.
QMap< QString, QString > Parameters
SERVER_EXPORT bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS.