• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utilities_for_testing.set_jakarta_extent函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中safe_qgis.utilities.utilities_for_testing.set_jakarta_extent函数的典型用法代码示例。如果您正苦于以下问题:Python set_jakarta_extent函数的具体用法?Python set_jakarta_extent怎么用?Python set_jakarta_extent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_check_aggregation_single_attribute

    def test_check_aggregation_single_attribute(self):
        """Aggregation attribute is chosen correctly when there is only
        one attr available."""
        file_list = ['kabupaten_jakarta_singlepart_1_good_attr.shp']
        # add additional layers
        load_layers(file_list, clear_flag=False)
        attribute_key = get_defaults('AGGR_ATTR_KEY')

        # with 1 good aggregation attribute using
        # kabupaten_jakarta_singlepart_1_good_attr.shp
        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function_id='Flood Evacuation Function',
            aggregation_layer='kabupaten jakarta singlepart 1 good attr')
        set_jakarta_extent(dock=DOCK)
        assert result, message
        # Press RUN
        # noinspection PyCallByClass,PyTypeChecker
        DOCK.accept()
        DOCK.runtime_keywords_dialog.accept()
        print attribute_key
        print DOCK.aggregator.attributes
        attribute = DOCK.aggregator.attributes[attribute_key]
        message = (
            'The aggregation should be KAB_NAME. Found: %s' % attribute)
        self.assertEqual(attribute, 'KAB_NAME', message)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:28,代码来源:test_aggregator.py


示例2: test_runFloodPopulationImpactFunction

    def test_runFloodPopulationImpactFunction(self):
        """Flood function runs in GUI with Jakarta data
           Raster on raster based function runs as expected."""

        # Push OK with the left mouse button
        myButton = DOCK.pbnRunStop

        myMessage = 'Run button was not enabled'
        assert myButton.isEnabled(), myMessage

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='Penduduk Jakarta',
            function='HKVtest',
            function_id='HKVtest')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()

        # Check that the number is as what was calculated by
        # Marco Hartman form HKV
        myMessage = 'Result not as expected: %s' % myResult
        # This is the expected impact number
        assert format_int(2480) in myResult, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:31,代码来源:test_dock.py


示例3: test_full_run_pyzstats

    def test_full_run_pyzstats(self):
        """Aggregation results correct using our own python zonal stats code.
        """
        file_list = ['kabupaten_jakarta.shp']
        load_layers(file_list, clear_flag=False, data_directory=BOUNDDATA)

        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function',
            aggregation_layer='kabupaten jakarta',
            aggregation_enabled_flag=True)
        self.assertTrue(result, message)

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()
        # Press RUN
        # noinspection PyCallByClass,PyTypeChecker
        DOCK.accept()

        result = DOCK.wvResults.page_to_text()

        expected_result = open(
            TEST_FILES_DIR +
            '/test-full-run-results.txt',
            'r').readlines()
        result = result.replace(
            '</td> <td>', ' ').replace('</td><td>', ' ')
        for line in expected_result:
            line = line.replace('\n', '')
            self.assertIn(line, result)
开发者ID:D2KG,项目名称:FLOOgin,代码行数:34,代码来源:test_dock.py


示例4: Xtest_printMap

    def Xtest_printMap(self):
        """Test print map, especially on Windows."""

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='Flood in Jakarta',
            exposure='Essential buildings',
            function='Be affected',
            function_id='Categorised Hazard Building Impact Function')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        # Press RUN
        myButton = DOCK.pbnRunStop
        # noinspection PyCallByClass,PyTypeChecker
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        printButton = DOCK.pbnPrint

        try:
            # noinspection PyCallByClass,PyTypeChecker
            QTest.mouseClick(printButton, QtCore.Qt.LeftButton)
        except OSError:
            LOGGER.debug('OSError')
            # pass
        except Exception, e:
            raise Exception('Exception is not expected, %s' % e)
开发者ID:feyeandal,项目名称:inasafe,代码行数:29,代码来源:test_dock.py


示例5: test_runCategorisedHazardPopulationImpactFunction

    def test_runCategorisedHazardPopulationImpactFunction(self):
        """Flood function runs in GUI with Flood in Jakarta hazard data
            Uses Penduduk Jakarta as exposure data."""

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='Flood in Jakarta',
            exposure='Penduduk Jakarta',
            function='Be impacted',
            function_id='Categorised Hazard Population Impact Function')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()

        myMessage = 'Result not as expected: %s' % myResult
        # This is the expected number of population might be affected
        assert format_int(30938000) in myResult, myMessage
        assert format_int(68280000) in myResult, myMessage
        assert format_int(157551000) in myResult, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:25,代码来源:test_dock.py


示例6: Xtest_runnerExceptions

    def Xtest_runnerExceptions(self):
        """Test runner exceptions"""

        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Exception riser',
            function_id='Exception Raising Impact Function',
            aggregation_enabled_flag=True)
        self.assertTrue(result, message)

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()
        # Press RUN
        # noinspection PyCallByClass,PyTypeChecker
        DOCK.accept()
        #        DOCK.runtime_keywords_dialog.accept()
        expected_result = """Error:
An exception occurred when calculating the results
Problem:
Exception : AHAHAH I got you
Click for Diagnostic Information:
"""
        result = DOCK.wvResults.page_to_text()
        message = (
            'The result message should be:\n%s\nFound:\n%s' %
            (expected_result, result))
        self.assertEqual(expected_result, result, message)
开发者ID:D2KG,项目名称:FLOOgin,代码行数:30,代码来源:test_dock.py


示例7: test_runFloodPopulationImpactFunction_scaling

    def test_runFloodPopulationImpactFunction_scaling(self):
        """Flood function runs in GUI with 5x5km population data
           Raster on raster based function runs as expected with scaling."""

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        # Press RUN
        myButton = DOCK.pbnRunStop
        # noinspection PyCallByClass,PyTypeChecker
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myResult = DOCK.wvResults.page_to_text()

        myMessage = 'Result not as expected: %s' % myResult

        # Check numbers are OK (within expected errors from resampling)
        # These are expected impact number
        assert format_int(10484) in myResult, myMessage
        assert format_int(977) in myResult, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:28,代码来源:test_dock.py


示例8: setUp

    def setUp(self):
        """Fixture run before all tests"""

        self.maxDiff = None  # show full diff for assert errors

        os.environ['LANG'] = 'en'
        DOCK.show_only_visible_layers_flag = True
        load_standard_layers()
        DOCK.cboHazard.setCurrentIndex(0)
        DOCK.cboExposure.setCurrentIndex(0)
        DOCK.cboFunction.setCurrentIndex(0)
        DOCK.run_in_thread_flag = False
        DOCK.show_only_visible_layers_flag = False
        DOCK.set_layer_from_title_flag = False
        DOCK.zoom_to_impact_flag = False
        DOCK.hide_exposure_flag = False
        DOCK.show_intermediate_layers = False
        set_jakarta_extent()

        self._keywordIO = KeywordIO()
        self._defaults = breakdown_defaults()

        # Set extent as Jakarta extent
        geo_crs = QgsCoordinateReferenceSystem()
        geo_crs.createFromSrid(4326)
        self.extent = extent_to_geo_array(CANVAS.extent(), geo_crs)
开发者ID:D2KG,项目名称:FLOOgin,代码行数:26,代码来源:test_aggregator.py


示例9: Xtest_runnerIsNone

    def Xtest_runnerIsNone(self):
        """Test for none runner exceptions"""
        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='None returner',
            function_id='None Returning Impact Function',
            aggregation_enabled_flag=True)
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        # Press RUN
        # noinspection PyCallByClass,PyTypeChecker
        DOCK.accept()
        #        DOCK.runtimeKeywordsDialog.accept()
        myExpectedResult = """Error:
An exception occurred when calculating the results
Problem:
AttributeError : 'NoneType' object has no attribute 'keywords'
Click for Diagnostic Information:
"""
        myResult = DOCK.wvResults.page_to_text()
        myMessage = ('The result message should be:\n%s\nFound:\n%s' %
                     (myExpectedResult, myResult))
        self.assertEqual(myExpectedResult, myResult, myMessage)
开发者ID:feyeandal,项目名称:inasafe,代码行数:29,代码来源:test_dock.py


示例10: test_post_processor_output

    def test_post_processor_output(self):
        """Check that the post processor does not add spurious report rows."""

        # with KAB_NAME aggregation attribute defined in .keyword using
        # kabupaten_jakarta_singlepart.shp
        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function')

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        assert result, message

        # Press RUN
        DOCK.accept()
        message = 'Spurious 0 filled rows added to post processing report.'
        result = DOCK.wvResults.page().currentFrame().toPlainText()
        for line in result.split('\n'):
            if 'Entire area' in line:
                tokens = str(line).split('\t')
                tokens = tokens[1:]
                total = 0
                for token in tokens:
                    total += float(token.replace(',', '.'))

                assert total != 0, message
开发者ID:FlavioFalcao,项目名称:inasafe,代码行数:31,代码来源:test_postprocessor_manager.py


示例11: test_postProcessorOutput

    def test_postProcessorOutput(self):
        """Check that the post processor does not add spurious report rows."""
        myRunButton = DOCK.pbnRunStop

        # with KAB_NAME aggregation attribute defined in .keyword using
        # kabupaten_jakarta_singlepart.shp
        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function')

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        assert myResult, myMessage

        # Press RUN
        # noinspection PyCallByClass,PyTypeChecker
        QTest.mouseClick(myRunButton, QtCore.Qt.LeftButton)
        myMessage = 'Spurious 0 filled rows added to post processing report.'
        myResult = DOCK.wvResults.page().currentFrame().toPlainText()
        for line in myResult.split('\n'):
            if 'Entire area' in line:
                myTokens = str(line).split('\t')
                myTokens = myTokens[1:]
                mySum = 0
                for myToken in myTokens:
                    mySum += float(myToken.replace(',', '.'))

                assert mySum != 0, myMessage
开发者ID:gsuhartono,项目名称:inasafe,代码行数:33,代码来源:test_postprocessor_manager.py


示例12: test_runCategorisedHazardPopulationImpactFunction

    def test_runCategorisedHazardPopulationImpactFunction(self):
        """Flood function runs in GUI with Flood in Jakarta hazard data
            Uses Penduduk Jakarta as exposure data."""

        result, message = setup_scenario(
            DOCK,
            hazard='Flood in Jakarta',
            exposure='Penduduk Jakarta',
            function='Be impacted',
            function_id='Categorised Hazard Population Impact Function')
        self.assertTrue(result, message)

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        # Press RUN
        DOCK.accept()
        result = DOCK.wvResults.page_to_text()

        message = ('Result not as expected: %s' % result)
        # This is the expected number of population might be affected
        self.assertTrue(format_int(30938000) in result, message)  # high
        #self.assertTrue(format_int(68280000) in result, message)
        #self.assertTrue(format_int(157551000) in result, message)
        # The 2 asserts above are not valid anymore after the fix we made to
        # CategorisedHazardPopulationImpactFunction
        # Look at the fix here:
        # (https://github.com/AIFDR/inasafe/commit/aa5b3d72145c031c91f4d101b830
        # 8228915c248d#diff-378093670f4ebd60b4487af9b7c2e164)
        # New Asserts
        self.assertTrue(format_int(0) in result, message)  # medium
        self.assertTrue(format_int(256769000) in result, message)  # low
开发者ID:D2KG,项目名称:FLOOgin,代码行数:33,代码来源:test_dock.py


示例13: test_runFloodPopulationImpactFunction_scaling

    def test_runFloodPopulationImpactFunction_scaling(self):
        """Flood function runs in GUI with 5x5km population data
           Raster on raster based function runs as expected with scaling."""

        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function')
        self.assertTrue(result, message)

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        # Press RUN
        button = DOCK.pbnRunStop
        button.click()
        result = DOCK.wvResults.page_to_text()

        message = 'Result not as expected: %s' % result

        # Check numbers are OK (within expected errors from resampling)
        # These are expected impact number
        self.assertTrue(format_int(10473000) in result, message)
        self.assertTrue(format_int(978000) in result, message)
开发者ID:D2KG,项目名称:FLOOgin,代码行数:27,代码来源:test_dock.py


示例14: test_runCategorizedHazardBuildingImpact

    def test_runCategorizedHazardBuildingImpact(self):
        """Flood function runs in GUI with Flood in Jakarta hazard data
            Uses DKI buildings exposure data."""

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='Flood in Jakarta',
            exposure='Essential buildings',
            function='Be affected',
            function_id='Categorised Hazard Building Impact Function')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()

        myMessage = 'Result not as expected: %s' % myResult
        # This is the expected number of building might be affected
        assert format_int(535) in myResult, myMessage
        assert format_int(453) in myResult, myMessage
        assert format_int(436) in myResult, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:25,代码来源:test_dock.py


示例15: test_fullRunResults

    def test_fullRunResults(self):
        """Aggregation results are correct."""
        myExpectedResult = open(
            TEST_FILES_DIR +
            '/test-full-run-results.txt',
            'r').read()

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function',
            aggregation_layer='kabupaten jakarta singlepart',
            aggregation_enabled_flag=True)
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()
        # Press RUN
        # noinspection PyCallByClass,PyTypeChecker
        DOCK.accept()
        DOCK.runtimeKeywordsDialog.accept()

        myResult = DOCK.wvResults.page_to_text()
        myMessage = ('The aggregation report should be:\n%s\n\nFound:\n\n%s' %
                     (myExpectedResult, myResult))
        self.assertEqual(myResult, myExpectedResult, myMessage)
开发者ID:feyeandal,项目名称:inasafe,代码行数:29,代码来源:test_dock.py


示例16: test_save_scenario

    def test_save_scenario(self):
        """Test saving Current scenario."""
        result, message = setup_scenario(
            DOCK,
            hazard='Flood in Jakarta',
            exposure='Penduduk Jakarta',
            function='Be impacted',
            function_id='Categorised Hazard Population Impact Function')
        self.assertTrue(result, message)

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()

        # create unique file
        scenario_file = unique_filename(
            prefix='scenarioTest', suffix='.txt', dir=temp_dir('test'))

        self.save_scenario_dialog.save_scenario(
            scenario_file_path=scenario_file)
        with open(scenario_file) as f:
            data = f.readlines()
        title = data[0][:-1]
        exposure = data[1][:-1]
        hazard = data[2][:-1]
        function = data[3][:-1]
        extent = data[4][:-1]
        self.assertTrue(
            os.path.exists(scenario_file),
            'File %s does not exist' % scenario_file)
        self.assertTrue(title == '[Flood in Jakarta]', 'Title is not the same')
        self.assertTrue(
            exposure.startswith('exposure =') and exposure.endswith(
                'Population_Jakarta_geographic.asc'),
            'Exposure is not the same')
        self.assertTrue(
            hazard.startswith('hazard =') and hazard.endswith(
                'jakarta_flood_category_123.asc'),
            'Hazard is not the same')
        self.assertTrue(
            function == (
                'function = Categorised Hazard Population Impact Function'),
            'Impact function is not same')

        # TODO: figure out why this changed between releases
        if qgis_version() < 20400:
            # For QGIS 2.0
            expected_extent = (
                'extent = 106.313333, -6.380000, 107.346667, -6.070000')
            self.assertEqual(expected_extent, extent)
        else:
            # for QGIS 2.4
            expected_extent = (
                'extent = 106.287500, -6.380000, 107.372500, -6.070000')
            self.assertEqual(expected_extent, expected_extent)
开发者ID:SamudraYe,项目名称:inasafe,代码行数:55,代码来源:test_save_scenario.py


示例17: test_issue317

    def test_issue317(self):
        """Points near the edge of a raster hazard layer are interpolated OK"""

        set_canvas_crs(GEOCRS, True)
        set_jakarta_extent()
        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='OSM Building Polygons',
            function='Be flooded',
            function_id='Flood Building Impact Function')
        DOCK.get_functions()
        assert myResult, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:13,代码来源:test_dock.py


示例18: test_hasParametersButtonEnabled

 def test_hasParametersButtonEnabled(self):
     """Function configuration button is enabled when layers are compatible.
     """
     set_canvas_crs(GEOCRS, True)
     set_jakarta_extent()
     setup_scenario(
         DOCK,
         hazard='A flood in Jakarta like in 2007',
         exposure='Penduduk Jakarta',
         function='Need evacuation',
         function_id='Flood Evacuation Function')
     myToolButton = DOCK.toolFunctionOptions
     myFlag = myToolButton.isEnabled()
     assert myFlag, 'Expected configuration options button to be enabled'
开发者ID:feyeandal,项目名称:inasafe,代码行数:14,代码来源:test_dock.py


示例19: setUp

 def setUp(self):
     """Fixture run before all tests"""
     os.environ['LANG'] = 'en'
     DOCK.showOnlyVisibleLayersFlag = True
     load_standard_layers()
     DOCK.cboHazard.setCurrentIndex(0)
     DOCK.cboExposure.setCurrentIndex(0)
     DOCK.cboFunction.setCurrentIndex(0)
     DOCK.runInThreadFlag = False
     DOCK.showOnlyVisibleLayersFlag = False
     DOCK.setLayerNameFromTitleFlag = False
     DOCK.zoomToImpactFlag = False
     DOCK.hideExposureFlag = False
     DOCK.showIntermediateLayers = False
     set_jakarta_extent()
开发者ID:gsuhartono,项目名称:inasafe,代码行数:15,代码来源:test_postprocessor_manager.py


示例20: setUp

 def setUp(self):
     """Fixture run before all tests"""
     os.environ['LANG'] = 'en'
     DOCK.show_only_visible_layers_flag = True
     load_standard_layers()
     DOCK.cboHazard.setCurrentIndex(0)
     DOCK.cboExposure.setCurrentIndex(0)
     DOCK.cboFunction.setCurrentIndex(0)
     DOCK.run_in_thread_flag = False
     DOCK.show_only_visible_layers_flag = False
     DOCK.set_layer_from_title_flag = False
     DOCK.zoom_to_impact_flag = False
     DOCK.hide_exposure_flag = False
     DOCK.show_intermediate_layers = False
     set_jakarta_extent()
开发者ID:FlavioFalcao,项目名称:inasafe,代码行数:15,代码来源:test_postprocessor_manager.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap