QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
42 QDomDocument getStyledLayerDescriptorDocument(
QgsServerInterface *serverIface,
const QgsProject *project,
const QgsWmsRequest &request );
48 const QDomDocument doc =
getStyles( serverIface, project, request );
49 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
50 response.
write( doc.toByteArray() );
54 const QgsWmsRequest &request )
56 return getStyledLayerDescriptorDocument( serverIface, project, request );
61 QDomDocument getStyledLayerDescriptorDocument(
QgsServerInterface *serverIface,
const QgsProject *project,
const QgsWmsRequest &request )
71 QDomDocument myDocument = QDomDocument();
73 const QDomNode header = myDocument.createProcessingInstruction( QStringLiteral(
"xml" ), QStringLiteral(
"version=\"1.0\" encoding=\"UTF-8\"" ) );
74 myDocument.appendChild( header );
77 QDomElement root = myDocument.createElementNS( QStringLiteral(
"http://www.opengis.net/sld" ), QStringLiteral(
"StyledLayerDescriptor" ) );
78 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.1.0" ) );
79 root.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), QStringLiteral(
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" ) );
80 root.setAttribute( QStringLiteral(
"xmlns:ogc" ), QStringLiteral(
"http://www.opengis.net/ogc" ) );
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 );
89 QDomElement namedLayerNode = myDocument.createElement( QStringLiteral(
"NamedLayer" ) );
90 root.appendChild( namedLayerNode );
93 QDomElement nameNode = myDocument.createElement( QStringLiteral(
"se:Name" ) );
94 nameNode.appendChild( myDocument.createTextNode( context.
layerNickname( *layer ) ) );
95 namedLayerNode.appendChild( nameNode );
109 props[ QStringLiteral(
"scaleMinDenom" ) ] = QString::number( vlayer->
maximumScale() );
110 props[ QStringLiteral(
"scaleMaxDenom" ) ] = QString::number( vlayer->
minimumScale() );
117 QDomElement userStyleElem = myDocument.createElement( QStringLiteral(
"UserStyle" ) );
119 QDomElement styleNameElem = myDocument.createElement( QStringLiteral(
"se:Name" ) );
120 styleNameElem.appendChild( myDocument.createTextNode( styleName ) );
122 userStyleElem.appendChild( styleNameElem );
124 QDomElement featureTypeStyleElem = myDocument.createElement( QStringLiteral(
"se:FeatureTypeStyle" ) );
125 userStyleElem.appendChild( featureTypeStyleElem );
127 vlayer->
renderer()->
toSld( myDocument, featureTypeStyleElem, props );
133 namedLayerNode.appendChild( userStyleElem );
QStringList styles() const
Returns list of all defined style names.
Provides an interface to retrieve and manipulate WMS parameters received from the client.
@ VectorLayer
Vector layer.
void setFlag(Flag flag, bool on=true)
Sets or unsets a rendering flag according to the on value.
void setParameters(const QgsWmsParameters ¶meters)
Sets WMS parameters.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
Rendering context for the WMS renderer.
virtual void toSld(QDomNode &parent, const QVariantMap &props) const
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
QString layerNickname(const QgsMapLayer &layer) const
Returns the nickname (short name, id or name) of the layer according to the current configuration.
double minimumScale() const
Returns the minimum map scale (i.e.
QString currentStyle() const
Returns name of the current style.
double maximumScale() const
Returns the maximum map scale (i.e.
Median cut implementation.
void writeGetStyles(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request, QgsServerResponse &response)
Output GetStyles response.
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.
QList< QgsMapLayer * > layersToRender() const
Returns a list of all layers to actually render according to the current configuration.
QDomDocument getStyles(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request)
Returns an SLD file with the styles of the requested layers.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
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...
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.