Skip to content
Permalink
Browse files

[Bugfix] Read SLD TextSymbolizer for lines

  • Loading branch information
rldhont committed Feb 3, 2020
1 parent dd19eb8 commit 9e5b2691cc69491abba97fa3c185eb483510e576
Showing with 18 additions and 0 deletions.
  1. +13 −0 src/core/qgsvectorlayer.cpp
  2. +5 −0 tests/src/python/test_qgssymbollayer_readsld.py
@@ -4618,6 +4618,10 @@ bool QgsVectorLayer::readSldTextSymbolizer( const QDomNode &node, QgsPalLayerSet
if ( !pointPlacementElem.isNull() )
{
settings.placement = QgsPalLayerSettings::OverPoint;
if ( geometryType() == QgsWkbTypes::LineGeometry )
{
settings.placement = QgsPalLayerSettings::Line;
}

QDomElement displacementElem = pointPlacementElem.firstChildElement( QStringLiteral( "Displacement" ) );
if ( !displacementElem.isNull() )
@@ -4683,6 +4687,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 9e5b269

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