当前位置: 首页>>代码示例>>Python>>正文


Python Map.setImpactLayer方法代码示例

本文整理汇总了Python中safe_qgis.report.map.Map.setImpactLayer方法的典型用法代码示例。如果您正苦于以下问题:Python Map.setImpactLayer方法的具体用法?Python Map.setImpactLayer怎么用?Python Map.setImpactLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在safe_qgis.report.map.Map的用法示例。


在下文中一共展示了Map.setImpactLayer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createPDFReport

# 需要导入模块: from safe_qgis.report.map import Map [as 别名]
# 或者: from safe_qgis.report.map.Map import setImpactLayer [as 别名]
    def createPDFReport(self, theTitle, theOutputDirectory, theImpactLayer,
                        theCount=0, theIndex=''):
        """Create PDF report from impact layer.
        Create map & table report PDF based from theImpactLayer data.

        :param theTitle: the report title.
        :param theOutputDirectory: output directory
        :param theImpactLayer: impact layer instance.
        :param theCount: the number of as scenario has been run
        :param theIndex: the index for the beginning of the file name

        See also:
            Dock.printMap()
        """

        myMap = Map(self.iface)

        # FIXME: check if theImpactLayer is the real impact layer...
        myMap.setImpactLayer(theImpactLayer)

        LOGGER.debug('Create Report: %s' % theTitle)
        myMapPath, myTablePath = self.reportPath(
            theOutputDirectory, theTitle, theCount, theIndex)

        # create map pdf
        myMap.printToPdf(myMapPath)

        # create table report pdf
        myHtmlRenderer = HtmlRenderer(myMap.pageDpi)
        myKeywords = myMap.keywordIO.read_keywords(theImpactLayer)
        myHtmlRenderer.printImpactTable(myKeywords, myTablePath)
        LOGGER.debug("Report done %s %s" % (myMapPath, myTablePath))
开发者ID:gsuhartono,项目名称:inasafe,代码行数:34,代码来源:batch_dialog.py

示例2: test_getMapTitle

# 需要导入模块: from safe_qgis.report.map import Map [as 别名]
# 或者: from safe_qgis.report.map.Map import setImpactLayer [as 别名]
 def test_getMapTitle(self):
     """Getting the map title from the keywords"""
     myLayer, _ = load_layer('test_floodimpact.tif')
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myTitle = myMap.getMapTitle()
     myExpectedTitle = 'Penduduk yang Mungkin dievakuasi'
     myMessage = 'Expected: %s\nGot:\n %s' % (myExpectedTitle, myTitle)
     assert myTitle == myExpectedTitle, myMessage
开发者ID:gsuhartono,项目名称:inasafe,代码行数:11,代码来源:test_map.py

示例3: test_handleMissingMapTitle

# 需要导入模块: from safe_qgis.report.map import Map [as 别名]
# 或者: from safe_qgis.report.map.Map import setImpactLayer [as 别名]
 def test_handleMissingMapTitle(self):
     """Missing map title from the keywords fails gracefully"""
     # TODO running OSM Buildngs with Pendudk Jakarta
     # wasthrowing an error when requesting map title
     # that this test wasnt replicating well
     myLayer, _ = load_layer('population_padang_1.asc')
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myTitle = myMap.getMapTitle()
     myExpectedTitle = None
     myMessage = 'Expected: %s\nGot:\n %s' % (myExpectedTitle, myTitle)
     assert myTitle == myExpectedTitle, myMessage
开发者ID:gsuhartono,项目名称:inasafe,代码行数:14,代码来源:test_map.py

示例4: Xtest_renderTemplate

# 需要导入模块: from safe_qgis.report.map import Map [as 别名]
# 或者: from safe_qgis.report.map.Map import setImpactLayer [as 别名]
    def Xtest_renderTemplate(self):
        """Test that load template works"""
        #Use the template from our resources bundle
        myInPath = ':/plugins/inasafe/basic.qpt'
        myLayer, _ = load_layer('test_shakeimpact.shp')

        myCanvasLayer = QgsMapCanvasLayer(myLayer)
        CANVAS.setLayerSet([myCanvasLayer])
        myMap = Map(IFACE)
        set_jakarta_extent()
        myMap.setImpactLayer(myLayer)
        myPath = unique_filename(
            prefix='outTemplate',
            suffix='.pdf',
            dir=temp_dir('test'))
        LOGGER.debug(myPath)
        myMap.renderTemplate(myInPath, myPath)
        assert os.path.exists(myPath)
开发者ID:gsuhartono,项目名称:inasafe,代码行数:20,代码来源:test_map.py

示例5: test_renderComposition

# 需要导入模块: from safe_qgis.report.map import Map [as 别名]
# 或者: from safe_qgis.report.map.Map import setImpactLayer [as 别名]
    def test_renderComposition(self):
        """Test making an image of the map only."""
        LOGGER.info('Testing renderComposition')
        myLayer, _ = load_layer('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

        # 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
        myFlag, myMessage = check_images(
            'renderComposition',
            myImagePath,
            myTolerance)
        assert myFlag, myMessage
开发者ID:gsuhartono,项目名称:inasafe,代码行数:41,代码来源:test_map.py

示例6: test_printToPdf

# 需要导入模块: from safe_qgis.report.map import Map [as 别名]
# 或者: from safe_qgis.report.map.Map import setImpactLayer [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, _ = load_layer('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
     myExpectedSizes = [
         441541,  # as rendered on ub 13.04 post 17 May 2013
         441428,  # as rendered on ub 13.04 5 Jul 2013
         447217,  # Nadia Linux Mint 14
         447051,  # as rendered on Jenkins post 24 April 2013
         447138,  # Windows 7 SP1 AMD64
         233989,  # OSX 10.8
     ]
     myMessage = '%s\nExpected rendered map pdf to be in %s, got %s' % (
         myPath, myExpectedSizes, mySize)
     self.assertIn(mySize, myExpectedSizes, myMessage)
开发者ID:gsuhartono,项目名称:inasafe,代码行数:38,代码来源:test_map.py


注:本文中的safe_qgis.report.map.Map.setImpactLayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。