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


Python utilities_for_testing.set_jakarta_extent函数代码示例

本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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