diff --git a/src/core/symbology-ng/qgssymbollayerutils.cpp b/src/core/symbology-ng/qgssymbollayerutils.cpp index 77a046d5ddb..cabc25dcab5 100644 --- a/src/core/symbology-ng/qgssymbollayerutils.cpp +++ b/src/core/symbology-ng/qgssymbollayerutils.cpp @@ -2499,6 +2499,7 @@ bool QgsSymbolLayerUtils::createFunctionElement( QDomDocument &doc, QDomElement bool QgsSymbolLayerUtils::functionFromSldElement( QDomElement &element, QString &function ) { + // check if ogc:Filter or containe ogc:Filters QDomElement elem = element; if ( element.tagName() != QLatin1String( "Filter" ) ) { @@ -2514,7 +2515,15 @@ bool QgsSymbolLayerUtils::functionFromSldElement( QDomElement &element, QString return false; } + // check if it is a single string value + if ( elem.hasChildNodes() && + elem.firstChild().nodeType() == QDomNode::TextNode ) + { + function = elem.firstChild().nodeValue(); + return true; + } + // parse ogc:Filter QgsExpression *expr = QgsOgcUtils::expressionFromOgcFilter( elem ); if ( !expr ) return false; diff --git a/tests/src/python/test_qgssymbollayer_readsld.py b/tests/src/python/test_qgssymbollayer_readsld.py index 28c08526e47..5ce1cf2d65d 100644 --- a/tests/src/python/test_qgssymbollayer_readsld.py +++ b/tests/src/python/test_qgssymbollayer_readsld.py @@ -2,7 +2,11 @@ """ *************************************************************************** +<<<<<<< b3e8d8219090068ba14a67004f9412633a6ec7b3 test_qgssymbollayer_readsld.py +======= + test_qgssymbollayerv2_readsld.py +>>>>>>> Tests and fix to read sld:Rotation when does not have ogc sub tags --------------------- Date : January 2017 Copyright : (C) 2017, Jorge Gustavo Rocha @@ -87,5 +91,31 @@ class TestQgsSymbolLayerReadSld(unittest.TestCase): testLineWidth() testLineOpacity() + def testSimpleMarkerRotation(self): + """ + Test if pointMarker property sld:Rotation value can be read if rormat is: + 50.0 + or + 50 + """ + # technically it's not necessary to use a real shape, but a empty memory + # layer. In case these tests will upgrate to a rendering where to + # compare also rendering no only properties + #myShpFile = os.path.join(unitTestDataPath(), 'points.shp') + #layer = QgsVectorLayer(myShpFile, 'points', 'ogr') + layer = QgsVectorLayer("Point", "addfeat", "memory") + assert(layer.isValid()) + # test if able to read 50.0 + mFilePath = os.path.join(unitTestDataPath(), 'symbol_layer/external_sld/testSimpleMarkerRotation-directValue.sld') + layer.loadSldStyle(mFilePath) + props = layer.renderer().symbol().symbolLayers()[0].properties() + self.assertEqual(props['angle'], '50') + # test if able to read 50 + mFilePath = os.path.join(unitTestDataPath(), 'symbol_layer/external_sld/testSimpleMarkerRotation-ogcLiteral.sld') + layer.loadSldStyle(mFilePath) + props = layer.renderer().symbol().symbolLayers()[0].properties() + self.assertEqual(props['angle'], '50') + + if __name__ == '__main__': unittest.main() diff --git a/tests/testdata/symbol_layer/external_sld/testSimpleMarkerRotation-directValue.sld b/tests/testdata/symbol_layer/external_sld/testSimpleMarkerRotation-directValue.sld new file mode 100644 index 00000000000..ee82a9c47f9 --- /dev/null +++ b/tests/testdata/symbol_layer/external_sld/testSimpleMarkerRotation-directValue.sld @@ -0,0 +1,30 @@ + + + + testSimpleMarkerRotation + + testSimpleMarkerRotation + + name + + Single symbol + + + + star + + #ff0000 + + + #00ff00 + + + 36 + 50.0 + + + + + + + diff --git a/tests/testdata/symbol_layer/external_sld/testSimpleMarkerRotation-ogcLiteral.sld b/tests/testdata/symbol_layer/external_sld/testSimpleMarkerRotation-ogcLiteral.sld new file mode 100644 index 00000000000..d3139fbc177 --- /dev/null +++ b/tests/testdata/symbol_layer/external_sld/testSimpleMarkerRotation-ogcLiteral.sld @@ -0,0 +1,31 @@ + + + + points + + points + + + Single symbol + + + + regular_star + + #ff0000 + + + #00ff00 + + + 10 + + 50 + + + + + + + +