Skip to content

Commit

Permalink
Merge pull request #4838 from aaime/textsymbolizer_sc
Browse files Browse the repository at this point in the history
SLD label exports. fixes #8925
  • Loading branch information
nyalldawson committed Jul 26, 2017
2 parents 1b9dea9 + 5cfed12 commit cf042dc
Show file tree
Hide file tree
Showing 11 changed files with 2,695 additions and 60 deletions.
6 changes: 6 additions & 0 deletions python/core/qgsvectorlayerlabeling.sip
Expand Up @@ -76,6 +76,11 @@ Try to create instance of an implementation based on the XML data
:rtype: QgsAbstractVectorLayerLabeling
%End

virtual void toSld( QDomNode &parent, const QgsStringMap &props ) const;
%Docstring
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings
%End

private:
QgsAbstractVectorLayerLabeling( const QgsAbstractVectorLayerLabeling &rhs );
};
Expand Down Expand Up @@ -105,6 +110,7 @@ Constructs simple labeling configuration with given initial settings
virtual QgsPalLayerSettings settings( const QString &providerId = QString() ) const;
virtual bool requiresAdvancedEffects() const;

virtual void toSld( QDomNode &parent, const QgsStringMap &props ) const;

static QgsVectorLayerSimpleLabeling *create( const QDomElement &element, const QgsReadWriteContext &context );
%Docstring
Expand Down
8 changes: 8 additions & 0 deletions python/core/symbology-ng/qgssymbollayerutils.sip
Expand Up @@ -481,6 +481,14 @@ Create ogr feature style string for pen
:rtype: bool
%End

static void createAnchorPointElement( QDomDocument &doc, QDomElement &element, QPointF anchor );
%Docstring
Creates a SE 1.1 anchor point element as a child of the specified element
\param doc The document
\param element The parent element
\param anchor An anchor specification, with values between 0 and 1
%End

static void createOnlineResourceElement( QDomDocument &doc, QDomElement &element, const QString &path, const QString &format );
static bool onlineResourceFromSldElement( QDomElement &element, QString &path, QString &format );
%Docstring
Expand Down
27 changes: 21 additions & 6 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -2205,11 +2205,6 @@ bool QgsVectorLayer::writeSld( QDomNode &node, QDomDocument &doc, QString &error
{
Q_UNUSED( errorMessage );

// store the Name element
QDomElement nameNode = doc.createElement( QStringLiteral( "se:Name" ) );
nameNode.appendChild( doc.createTextNode( name() ) );
node.appendChild( nameNode );

QgsStringMap localProps = QgsStringMap( props );
if ( hasScaleBasedVisibility() )
{
Expand All @@ -2218,7 +2213,27 @@ bool QgsVectorLayer::writeSld( QDomNode &node, QDomDocument &doc, QString &error

if ( isSpatial() )
{
node.appendChild( mRenderer->writeSld( doc, name(), localProps ) );
// store the Name element
QDomElement nameNode = doc.createElement( "se:Name" );
nameNode.appendChild( doc.createTextNode( name() ) );
node.appendChild( nameNode );

QDomElement userStyleElem = doc.createElement( "UserStyle" );
node.appendChild( userStyleElem );

QDomElement nameElem = doc.createElement( "se:Name" );
nameElem.appendChild( doc.createTextNode( name() ) );

userStyleElem.appendChild( nameElem );

QDomElement featureTypeStyleElem = doc.createElement( "se:FeatureTypeStyle" );
userStyleElem.appendChild( featureTypeStyleElem );

mRenderer->toSld( doc, featureTypeStyleElem, localProps );
if ( labelsEnabled() )
{
mLabeling->toSld( featureTypeStyleElem, localProps );
}
}
return true;
}
Expand Down

0 comments on commit cf042dc

Please sign in to comment.