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

Fix negative angles for symbols are ignored when exporting to SLD #59426

Merged
merged 1 commit into from
Nov 13, 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 @@ -1955,6 +1955,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, fieldNameToXPathMap, namespacePrefixToUriMap );
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 @@ -83,6 +83,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.Shape.Star, color=QColor(255, 0, 0), strokeColor=QColor(0, 255, 0), size=10)
Expand Down Expand Up @@ -145,6 +151,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 @@ -178,6 +188,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 @@ -190,6 +204,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 @@ -348,6 +366,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 @@ -373,6 +395,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 @@ -387,6 +413,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 @@ -402,6 +432,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