本文整理匯總了Python中qgis.core.QgsSymbolLayerV2Utils.lineWidthScaleFactor方法的典型用法代碼示例。如果您正苦於以下問題:Python QgsSymbolLayerV2Utils.lineWidthScaleFactor方法的具體用法?Python QgsSymbolLayerV2Utils.lineWidthScaleFactor怎麽用?Python QgsSymbolLayerV2Utils.lineWidthScaleFactor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qgis.core.QgsSymbolLayerV2Utils
的用法示例。
在下文中一共展示了QgsSymbolLayerV2Utils.lineWidthScaleFactor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _getSymbolWidth
# 需要導入模塊: from qgis.core import QgsSymbolLayerV2Utils [as 別名]
# 或者: from qgis.core.QgsSymbolLayerV2Utils import lineWidthScaleFactor [as 別名]
def _getSymbolWidth(self, context, width, unit):
scale = 1.0
if unit == QgsSymbolV2.MapUnit:
scale = QgsSymbolLayerV2Utils.lineWidthScaleFactor(
context, QgsSymbolV2.MM) / QgsSymbolLayerV2Utils.lineWidthScaleFactor(context, QgsSymbolV2.MapUnit)
width = max(width + 2 * self._buffer * scale, self._minWidth * scale)
return width
示例2: testLineWidthScaleFactor
# 需要導入模塊: from qgis.core import QgsSymbolLayerV2Utils [as 別名]
# 或者: from qgis.core.QgsSymbolLayerV2Utils import lineWidthScaleFactor [as 別名]
def testLineWidthScaleFactor(self):
# test QgsSymbolLayerV2Utils::lineWidthScaleFactor() using QgsMapUnitScale
ms = QgsMapSettings()
ms.setExtent(QgsRectangle(0, 0, 100, 100))
ms.setOutputSize(QSize(100, 50))
ms.setOutputDpi(300)
r = QgsRenderContext.fromMapSettings(ms)
# renderer scale should be about 1:291937841
# start with no min/max scale
c = QgsMapUnitScale()
sf = QgsSymbolLayerV2Utils.lineWidthScaleFactor(r, QgsSymbolV2.MapUnit, c)
self.assertAlmostEqual(sf, 0.5, places=5)
sf = QgsSymbolLayerV2Utils.lineWidthScaleFactor(r, QgsSymbolV2.MM, c)
self.assertAlmostEqual(sf, 11.8110236, places=5)
sf = QgsSymbolLayerV2Utils.lineWidthScaleFactor(r, QgsSymbolV2.Pixel, c)
self.assertAlmostEqual(sf, 1.0, places=5)
# minimum scale greater than the renderer scale, so should be limited to minScale
c.minScale = 1 / 150000000.0
sf = QgsSymbolLayerV2Utils.lineWidthScaleFactor(r, QgsSymbolV2.MapUnit, c)
self.assertAlmostEqual(sf, 3.89250455, places=5)
# only conversion from mapunits should be affected
sf = QgsSymbolLayerV2Utils.lineWidthScaleFactor(r, QgsSymbolV2.MM, c)
self.assertAlmostEqual(sf, 11.8110236, places=5)
sf = QgsSymbolLayerV2Utils.lineWidthScaleFactor(r, QgsSymbolV2.Pixel, c)
self.assertAlmostEqual(sf, 1.0, places=5)
c.minScale = 0
# maximum scale less than the renderer scale, so should be limited to maxScale
c.maxScale = 1 / 350000000.0
sf = QgsSymbolLayerV2Utils.lineWidthScaleFactor(r, QgsSymbolV2.MapUnit, c)
self.assertAlmostEqual(sf, 0.5, places=5)
# only conversion from mapunits should be affected
sf = QgsSymbolLayerV2Utils.lineWidthScaleFactor(r, QgsSymbolV2.MM, c)
self.assertAlmostEqual(sf, 11.8110236, places=5)
sf = QgsSymbolLayerV2Utils.lineWidthScaleFactor(r, QgsSymbolV2.Pixel, c)
self.assertAlmostEqual(sf, 1.0, places=5)