Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-3_34] Fix negative angles for symbols are ignored when exporting to SLD #59430

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading