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


Python Map.composeMap方法代碼示例

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


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

示例1: test_printToPdf

# 需要導入模塊: from safe_qgis.map import Map [as 別名]
# 或者: from safe_qgis.map.Map import composeMap [as 別名]
 def test_printToPdf(self):
     """Test making a pdf of the map - this is the most typical use of map.
     """
     LOGGER.info('Testing printToPdf')
     myLayer, _ = loadLayer('test_shakeimpact.shp')
     myCanvasLayer = QgsMapCanvasLayer(myLayer)
     CANVAS.setLayerSet([myCanvasLayer])
     myRect = QgsRectangle(106.7894, -6.2308, 106.8004, -6.2264)
     CANVAS.setExtent(myRect)
     CANVAS.refresh()
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myMap.composeMap()
     myPath = unique_filename(prefix='mapPdfTest',
                              suffix='.pdf',
                              dir=temp_dir('test'))
     myMap.printToPdf(myPath)
     LOGGER.debug(myPath)
     myMessage = 'Rendered output does not exist: %s' % myPath
     assert os.path.exists(myPath), myMessage
     # pdf rendering is non deterministic so we can't do a hash check
     # test_renderComposition renders just the image instead of pdf
     # so we hash check there and here we just do a basic minimum file
     # size check.
     mySize = os.stat(myPath).st_size
     myExpectedSize = 352798  # as rendered on linux ub 12.04 64
     myMessage = 'Expected rendered map pdf to be at least %s, got %s' % (
         myExpectedSize, mySize)
     assert mySize >= myExpectedSize, myMessage
開發者ID:zzpwelkin,項目名稱:inasafe,代碼行數:31,代碼來源:test_map.py

示例2: test_renderComposition

# 需要導入模塊: from safe_qgis.map import Map [as 別名]
# 或者: from safe_qgis.map.Map import composeMap [as 別名]
    def test_renderComposition(self):
        """Test making an image of the map only."""
        LOGGER.info('Testing renderComposition')
        myLayer, _ = loadLayer('test_shakeimpact.shp')
        myCanvasLayer = QgsMapCanvasLayer(myLayer)
        CANVAS.setLayerSet([myCanvasLayer])

        myRect = QgsRectangle(106.7894, -6.2308, 106.8004, -6.2264)
        CANVAS.setExtent(myRect)
        CANVAS.refresh()
        myMap = Map(IFACE)
        myMap.setImpactLayer(myLayer)
        myMap.composeMap()
        myImagePath, myControlImage, myTargetArea = myMap.renderComposition()
        LOGGER.debug(myImagePath)

        assert myControlImage is not None

        myDimensions = [myTargetArea.left(),
                        myTargetArea.top(),
                        myTargetArea.bottom(),
                        myTargetArea.right()]
        myExpectedDimensions = [0.0, 0.0, 3507.0, 2480.0]
        myMessage = 'Expected target area to be %s, got %s' % (
            str(myExpectedDimensions), str(myDimensions))
        assert myExpectedDimensions == myDimensions, myMessage

        myMessage = 'Rendered output does not exist'
        assert os.path.exists(myImagePath), myMessage

        myAcceptableImages = [
            'renderComposition.png',
            'renderComposition-variantUB12.04.png',
            'renderComposition-variantUB12.10.png',
            'renderComposition-variantOSXml.png',
            'renderComposition-variantWindowsVistaSP2-32.png',
            'renderComposition-variantJenkins.png',
            'renderComposition-variantUB11.10-64.png',
            'renderComposition-variantLinuxMint-14-x86_64.png',
            'renderComposition-variantWindows7-SP1-AMD64.png',
            'renderComposition-variantUB11.04-64.png']
        # Beta version and version changes  can introduce a few extra chars
        # into the metadata section so we set a reasonable tolerance to cope
        # with this.
        myTolerance = 8000
        print myImagePath
        print myAcceptableImages
        myFlag, myMessage = checkImages(myAcceptableImages,
                                        myImagePath,
                                        myTolerance)
        assert myFlag, myMessage
開發者ID:rlbartolome,項目名稱:inasafe,代碼行數:53,代碼來源:test_map.py


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