From b80a63e4ad7cb896ff7ec067f9901422ddd486ce Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 13 Nov 2024 11:06:35 +1000 Subject: [PATCH] Fix negative angles for symbols are ignored when exporting to SLD --- src/core/qgsogcutils.cpp | 1 + .../python/test_qgssymbollayer_createsld.py | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/core/qgsogcutils.cpp b/src/core/qgsogcutils.cpp index 735a5cddebd8..e41cad0cfdc5 100644 --- a/src/core/qgsogcutils.cpp +++ b/src/core/qgsogcutils.cpp @@ -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 ); diff --git a/tests/src/python/test_qgssymbollayer_createsld.py b/tests/src/python/test_qgssymbollayer_createsld.py index a6c9914da643..084c84299ac4 100644 --- a/tests/src/python/test_qgssymbollayer_createsld.py +++ b/tests/src/python/test_qgssymbollayer_createsld.py @@ -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) @@ -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")) @@ -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)) @@ -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' @@ -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()) @@ -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) @@ -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) @@ -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)