當前位置: 首頁>>代碼示例>>Python>>正文


Python QgsHashedLineSymbolLayer.setAverageAngleLength方法代碼示例

本文整理匯總了Python中qgis.core.QgsHashedLineSymbolLayer.setAverageAngleLength方法的典型用法代碼示例。如果您正苦於以下問題:Python QgsHashedLineSymbolLayer.setAverageAngleLength方法的具體用法?Python QgsHashedLineSymbolLayer.setAverageAngleLength怎麽用?Python QgsHashedLineSymbolLayer.setAverageAngleLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qgis.core.QgsHashedLineSymbolLayer的用法示例。


在下文中一共展示了QgsHashedLineSymbolLayer.setAverageAngleLength方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testLineOffset

# 需要導入模塊: from qgis.core import QgsHashedLineSymbolLayer [as 別名]
# 或者: from qgis.core.QgsHashedLineSymbolLayer import setAverageAngleLength [as 別名]
    def testLineOffset(self):
        s = QgsLineSymbol()
        s.deleteSymbolLayer(0)

        hash_line = QgsHashedLineSymbolLayer(True)
        hash_line.setPlacement(QgsTemplatedLineSymbolLayerBase.Interval)
        hash_line.setInterval(6)
        simple_line = QgsSimpleLineSymbolLayer()
        simple_line.setColor(QColor(0, 255, 0))
        simple_line.setWidth(1)
        line_symbol = QgsLineSymbol()
        line_symbol.changeSymbolLayer(0, simple_line)
        hash_line.setSubSymbol(line_symbol)
        hash_line.setHashLength(10)
        hash_line.setAverageAngleLength(0)

        s.appendSymbolLayer(hash_line.clone())

        s.symbolLayer(0).setOffset(3)
        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        assert self.imageCheck('line_offset_positive', 'line_offset_positive', rendered_image)

        s.symbolLayer(0).setOffset(-3)
        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        assert self.imageCheck('line_offset_negative', 'line_offset_negative', rendered_image)
開發者ID:boundlessgeo,項目名稱:QGIS,代碼行數:29,代碼來源:test_qgshashlinesymbollayer.py

示例2: testHashPlacement

# 需要導入模塊: from qgis.core import QgsHashedLineSymbolLayer [as 別名]
# 或者: from qgis.core.QgsHashedLineSymbolLayer import setAverageAngleLength [as 別名]
    def testHashPlacement(self):
        s = QgsLineSymbol()
        s.deleteSymbolLayer(0)

        hash_line = QgsHashedLineSymbolLayer(True)
        hash_line.setPlacement(QgsTemplatedLineSymbolLayerBase.Vertex)
        hash_line.setInterval(6)
        simple_line = QgsSimpleLineSymbolLayer()
        simple_line.setColor(QColor(0, 255, 0))
        simple_line.setWidth(1)
        line_symbol = QgsLineSymbol()
        line_symbol.changeSymbolLayer(0, simple_line)
        hash_line.setSubSymbol(line_symbol)
        hash_line.setHashLength(7)
        hash_line.setAverageAngleLength(0)

        s.appendSymbolLayer(hash_line.clone())

        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        assert self.imageCheck('line_hash_vertex', 'line_hash_vertex', rendered_image)

        s.symbolLayer(0).setPlacement(QgsTemplatedLineSymbolLayerBase.FirstVertex)

        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        assert self.imageCheck('line_hash_first', 'line_hash_first', rendered_image)

        s.symbolLayer(0).setPlacement(QgsTemplatedLineSymbolLayerBase.LastVertex)

        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        assert self.imageCheck('line_hash_last', 'line_hash_last', rendered_image)
開發者ID:boundlessgeo,項目名稱:QGIS,代碼行數:35,代碼來源:test_qgshashlinesymbollayer.py

示例3: testRingFilter

# 需要導入模塊: from qgis.core import QgsHashedLineSymbolLayer [as 別名]
# 或者: from qgis.core.QgsHashedLineSymbolLayer import setAverageAngleLength [as 別名]
    def testRingFilter(self):
        # test filtering rings during rendering
        s = QgsFillSymbol()
        s.deleteSymbolLayer(0)

        hash_line = QgsHashedLineSymbolLayer(True)
        hash_line.setPlacement(QgsTemplatedLineSymbolLayerBase.Interval)
        hash_line.setInterval(6)
        simple_line = QgsSimpleLineSymbolLayer()
        simple_line.setColor(QColor(0, 255, 0))
        simple_line.setWidth(1)
        line_symbol = QgsLineSymbol()
        line_symbol.changeSymbolLayer(0, simple_line)
        hash_line.setSubSymbol(line_symbol)
        hash_line.setHashLength(10)
        hash_line.setAverageAngleLength(0)

        s.appendSymbolLayer(hash_line.clone())
        self.assertEqual(s.symbolLayer(0).ringFilter(), QgsLineSymbolLayer.AllRings)
        s.symbolLayer(0).setRingFilter(QgsLineSymbolLayer.ExteriorRingOnly)
        self.assertEqual(s.symbolLayer(0).ringFilter(), QgsLineSymbolLayer.ExteriorRingOnly)

        s2 = s.clone()
        self.assertEqual(s2.symbolLayer(0).ringFilter(), QgsLineSymbolLayer.ExteriorRingOnly)

        doc = QDomDocument()
        context = QgsReadWriteContext()
        element = QgsSymbolLayerUtils.saveSymbol('test', s, doc, context)

        s2 = QgsSymbolLayerUtils.loadSymbol(element, context)
        self.assertEqual(s2.symbolLayer(0).ringFilter(), QgsLineSymbolLayer.ExteriorRingOnly)

        # rendering test
        s3 = QgsFillSymbol()
        s3.deleteSymbolLayer(0)
        s3.appendSymbolLayer(
            hash_line.clone())
        s3.symbolLayer(0).setRingFilter(QgsLineSymbolLayer.ExteriorRingOnly)

        g = QgsGeometry.fromWkt('Polygon((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 1 2, 2 2, 2 1, 1 1),(8 8, 9 8, 9 9, 8 9, 8 8))')
        rendered_image = self.renderGeometry(s3, g)
        assert self.imageCheck('hashline_exterioronly', 'hashline_exterioronly', rendered_image)

        s3.symbolLayer(0).setRingFilter(QgsLineSymbolLayer.InteriorRingsOnly)
        g = QgsGeometry.fromWkt('Polygon((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 1 2, 2 2, 2 1, 1 1),(8 8, 9 8, 9 9, 8 9, 8 8))')
        rendered_image = self.renderGeometry(s3, g)
        assert self.imageCheck('hashline_interioronly', 'hashline_interioronly', rendered_image)
開發者ID:boundlessgeo,項目名稱:QGIS,代碼行數:49,代碼來源:test_qgshashlinesymbollayer.py

示例4: testHashAverageAngle

# 需要導入模塊: from qgis.core import QgsHashedLineSymbolLayer [as 別名]
# 或者: from qgis.core.QgsHashedLineSymbolLayer import setAverageAngleLength [as 別名]
    def testHashAverageAngle(self):
        s = QgsLineSymbol()
        s.deleteSymbolLayer(0)

        hash_line = QgsHashedLineSymbolLayer(True)
        hash_line.setPlacement(QgsTemplatedLineSymbolLayerBase.CentralPoint)
        simple_line = QgsSimpleLineSymbolLayer()
        simple_line.setColor(QColor(0, 255, 0))
        simple_line.setWidth(1)
        line_symbol = QgsLineSymbol()
        line_symbol.changeSymbolLayer(0, simple_line)
        hash_line.setSubSymbol(line_symbol)
        hash_line.setHashLength(7)
        hash_line.setHashAngle(45)
        hash_line.setAverageAngleLength(30)

        s.appendSymbolLayer(hash_line.clone())

        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        assert self.imageCheck('line_hash_center_average_angle', 'line_hash_center_average_angle', rendered_image)
開發者ID:boundlessgeo,項目名稱:QGIS,代碼行數:23,代碼來源:test_qgshashlinesymbollayer.py

示例5: testPointNumInterval

# 需要導入模塊: from qgis.core import QgsHashedLineSymbolLayer [as 別名]
# 或者: from qgis.core.QgsHashedLineSymbolLayer import setAverageAngleLength [as 別名]
    def testPointNumInterval(self):
        s = QgsLineSymbol()
        s.deleteSymbolLayer(0)

        hash_line = QgsHashedLineSymbolLayer(True)
        hash_line.setPlacement(QgsTemplatedLineSymbolLayerBase.Interval)
        hash_line.setInterval(6)
        simple_line = QgsSimpleLineSymbolLayer()
        simple_line.setColor(QColor(0, 255, 0))
        simple_line.setWidth(1)
        line_symbol = QgsLineSymbol()
        line_symbol.changeSymbolLayer(0, simple_line)
        hash_line.setSubSymbol(line_symbol)
        hash_line.setHashLength(10)
        hash_line.setAverageAngleLength(0)

        s.appendSymbolLayer(hash_line.clone())

        s.symbolLayer(0).setDataDefinedProperty(QgsSymbolLayer.PropertyLineDistance, QgsProperty.fromExpression(
            "@geometry_point_num * 2"))

        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        assert self.imageCheck('line_dd_size', 'line_dd_size', rendered_image)
開發者ID:boundlessgeo,項目名稱:QGIS,代碼行數:26,代碼來源:test_qgshashlinesymbollayer.py


注:本文中的qgis.core.QgsHashedLineSymbolLayer.setAverageAngleLength方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。