|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +""" |
| 4 | +*************************************************************************** |
| 5 | + test_qgssymbollayer_createsld.py |
| 6 | + --------------------- |
| 7 | + Date : July 2016 |
| 8 | + Copyright : (C) 2016 by Andrea Aime |
| 9 | + Email : andrea dot aime at geosolutions dot it |
| 10 | +*************************************************************************** |
| 11 | +* * |
| 12 | +* This program is free software; you can redistribute it and/or modify *less |
| 13 | +* it under the terms of the GNU General Public License as published by * |
| 14 | +* the Free Software Foundation; either version 2 of the License, or * |
| 15 | +* (at your option) any later version. * |
| 16 | +* * |
| 17 | +*************************************************************************** |
| 18 | +""" |
| 19 | + |
| 20 | +__author__ = 'Andrea Aime' |
| 21 | +__date__ = 'July 2016' |
| 22 | +__copyright__ = '(C) 2012, Andrea Aime' |
| 23 | +# This will get replaced with a git SHA1 when you do a git archive |
| 24 | +__revision__ = '$Format:%H$' |
| 25 | + |
| 26 | +import qgis # NOQA |
| 27 | + |
| 28 | +import os |
| 29 | + |
| 30 | +from qgis.PyQt.QtCore import pyqtWrapperType, Qt, QDir, QFile, QIODevice, QPointF |
| 31 | +from qgis.PyQt.QtXml import (QDomDocument, QDomElement) |
| 32 | +from qgis.PyQt.QtGui import QColor |
| 33 | + |
| 34 | +from qgis.core import QgsSimpleMarkerSymbolLayer |
| 35 | +from qgis.testing import start_app, unittest |
| 36 | +from utilities import unitTestDataPath |
| 37 | + |
| 38 | +# Convenience instances in case you may need them |
| 39 | +# not used in this test |
| 40 | +start_app() |
| 41 | + |
| 42 | + |
| 43 | +class TestQgsSymbolLayerCreateSld(unittest.TestCase): |
| 44 | + |
| 45 | + """ |
| 46 | + This class tests the creation of SLD from QGis layers |
| 47 | + """ |
| 48 | + |
| 49 | + def testSimpleMarkerSymbolLayer(self): |
| 50 | + symbol = QgsSimpleMarkerSymbolLayer( |
| 51 | + 'star', QColor(255, 0, 0), QColor(0, 255, 0), 10) |
| 52 | + symbol.setAngle(50) |
| 53 | + dom = QDomDocument() |
| 54 | + root = dom.createElement("FakeRoot") |
| 55 | + dom.appendChild(root) |
| 56 | + symbol.toSld(dom, root, {}) |
| 57 | + # print "This is the dom: " + dom.toString() |
| 58 | + |
| 59 | + # Check the rotation element is a literal, not a |
| 60 | + rotation = root.elementsByTagName('se:Rotation').item(0) |
| 61 | + literal = rotation.firstChild() |
| 62 | + self.assertEquals("ogc:Literal", literal.nodeName()) |
| 63 | + self.assertEquals('50', literal.firstChild().nodeValue()) |
| 64 | + |
| 65 | + |
| 66 | +if __name__ == '__main__': |
| 67 | + unittest.main() |
0 commit comments