Skip to content
Permalink
Browse files

Merge pull request #34342 from rldhont/backport-34223-to-release-3_10

[Backport Release-3_10][Bugfix] Read SLD TextSymbolizer for lines
  • Loading branch information
rldhont committed Feb 14, 2020
2 parents cb29c2d + 6291d18 commit 34023ed95edd5c8eac7e42ec98a4601ab7ca98f6
Showing with 18 additions and 0 deletions.
  1. +13 −0 src/core/qgsvectorlayer.cpp
  2. +5 −0 tests/src/python/test_qgssymbollayer_readsld.py
@@ -4450,6 +4450,10 @@ bool QgsVectorLayer::readSldTextSymbolizer( const QDomNode &node, QgsPalLayerSet
if ( !pointPlacementElem.isNull() )
{
settings.placement = QgsPalLayerSettings::OverPoint;
if ( geometryType() == QgsWkbTypes::LineGeometry )
{
settings.placement = QgsPalLayerSettings::Horizontal;
}

QDomElement displacementElem = pointPlacementElem.firstChildElement( QStringLiteral( "Displacement" ) );
if ( !displacementElem.isNull() )
@@ -4515,6 +4519,15 @@ bool QgsVectorLayer::readSldTextSymbolizer( const QDomNode &node, QgsPalLayerSet
}
}
}
else
{
// PointPlacement
QDomElement linePlacementElem = labelPlacementElem.firstChildElement( QStringLiteral( "LinePlacement" ) );
if ( !linePlacementElem.isNull() )
{
settings.placement = QgsPalLayerSettings::Line;
}
}
}

// read vendor options
@@ -444,7 +444,12 @@ def testLineOpacity():
self.assertEqual(format.size(), 18)
self.assertEqual(format.sizeUnit(), QgsUnitTypes.RenderPixels)

# the layer contains lines
# from qgis.core import QgsWkbTypes
# self.assertEqual(layer.geometryType(), QgsWkbTypes.LineGeometry)
# the placement should be QgsPalLayerSettings.Line
self.assertEqual(settings.placement, QgsPalLayerSettings.AroundPoint)

self.assertEqual(settings.xOffset, 1)
self.assertEqual(settings.yOffset, 0)
self.assertEqual(settings.offsetUnits, QgsUnitTypes.RenderPixels)

0 comments on commit 34023ed

Please sign in to comment.
You can’t perform that action at this time.