Skip to content

Commit

Permalink
Merge pull request #59430 from qgis/backport-59426-to-release-3_34
Browse files Browse the repository at this point in the history
[Backport release-3_34] Fix negative angles for symbols are ignored when exporting to SLD
  • Loading branch information
rouault authored Nov 17, 2024
2 parents d6b8c51 + b80a63e commit d9e6202
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/qgsogcutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,7 @@ QDomElement QgsOgcUtils::expressionToOgcExpression( const QgsExpression &express
case QgsExpressionNode::ntFunction:
case QgsExpressionNode::ntLiteral:
case QgsExpressionNode::ntColumnRef:
case QgsExpressionNode::ntUnaryOperator:
{
QgsOgcUtilsExprToFilter utils( doc, gmlVersion, filterVersion, QString(), QString(), geometryName, srsName, honourAxisOrientation, invertAxisOrientation );
const QDomElement exprRootElem = utils.expressionNodeToOgcFilter( node, &exp, &context );
Expand Down
34 changes: 34 additions & 0 deletions tests/src/python/test_qgssymbollayer_createsld.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ def testSimpleMarkerRotation(self):

self.assertStaticRotation(root, '50')

symbol.setAngle(-50)
dom, root = self.symbolToSld(symbol)
# print( "Simple marker rotation: " + root.ownerDocument().toString())

self.assertStaticRotation(root, '-50')

def testSimpleMarkerUnitDefault(self):
symbol = QgsSimpleMarkerSymbolLayer(
QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0), strokeColor=QColor(0, 255, 0), size=10)
Expand Down Expand Up @@ -146,6 +152,10 @@ def testSvgMarkerUnitDefault(self):
self.assertStaticRotation(root, '90')
self.assertStaticDisplacement(root, 18, 36)

symbol.setAngle(-45)
dom, root = self.symbolToSld(symbol)
self.assertStaticRotation(root, '-45')

def testSvgMarkerUnitPixels(self):
symbol = QgsSvgMarkerSymbolLayer('symbols/star.svg', 10, 0)
symbol.setFillColor(QColor("blue"))
Expand Down Expand Up @@ -179,6 +189,10 @@ def testFontMarkerUnitDefault(self):
self.assertStaticRotation(root, '45')
self.assertStaticDisplacement(root, 18, 36)

symbol.setAngle(-45)
dom, root = self.symbolToSld(symbol)
self.assertStaticRotation(root, '-45')

def testFontMarkerUnitPixel(self):
symbol = QgsFontMarkerSymbolLayer('sans', ',', 10, QColor('black'), 45)
symbol.setOffset(QPointF(5, 10))
Expand All @@ -191,6 +205,10 @@ def testFontMarkerUnitPixel(self):
self.assertStaticRotation(root, '45')
self.assertStaticDisplacement(root, 5, 10)

symbol.setAngle(-45)
dom, root = self.symbolToSld(symbol)
self.assertStaticRotation(root, '-45')

def createEllipseSymbolLayer(self):
# No way to build it programmatically...
mTestName = 'QgsEllipseSymbolLayer'
Expand Down Expand Up @@ -349,6 +367,10 @@ def testSvgFillDefault(self):
lineSymbolizer = root.elementsByTagName('se:LineSymbolizer').item(0).toElement()
self.assertStrokeWidth(lineSymbolizer, 1, 36)

symbol.setAngle(-45)
dom, root = self.symbolToSld(symbol)
self.assertStaticRotation(root, '-45')

def testSvgFillPixel(self):
symbol = QgsSVGFillSymbolLayer('test/star.svg', 10, 45)
symbol.setSubSymbol(QgsLineSymbol())
Expand All @@ -374,6 +396,10 @@ def testSvgFillPixel(self):
lineSymbolizer = root.elementsByTagName('se:LineSymbolizer').item(0).toElement()
self.assertStrokeWidth(lineSymbolizer, 1, 10)

symbol.setAngle(-45)
dom, root = self.symbolToSld(symbol)
self.assertStaticRotation(root, '-45')

def testLineFillDefault(self):
symbol = QgsLinePatternFillSymbolLayer()
symbol.setLineAngle(45)
Expand All @@ -388,6 +414,10 @@ def testLineFillDefault(self):
self.assertStaticSize(root, '18')
self.assertStaticDisplacement(root, 15, 9)

symbol.setLineAngle(-45)
dom, root = self.symbolToSld(symbol)
self.assertStaticRotation(root, '-45')

def testLineFillPixels(self):
symbol = QgsLinePatternFillSymbolLayer()
symbol.setLineAngle(45)
Expand All @@ -403,6 +433,10 @@ def testLineFillPixels(self):
self.assertStaticSize(root, '5')
self.assertStaticDisplacement(root, 4.25, 2.63)

symbol.setLineAngle(-45)
dom, root = self.symbolToSld(symbol)
self.assertStaticRotation(root, '-45')

def testPointFillDefault(self):
symbol = QgsPointPatternFillSymbolLayer()
dom, root = self.symbolToSld(symbol)
Expand Down

0 comments on commit d9e6202

Please sign in to comment.