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


Python utilities.setup_scenario函数代码示例

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


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

示例1: test_cbo_aggregation_toggle

    def test_cbo_aggregation_toggle(self):
        """Aggregation Combobox toggles on and off as expected."""

        # With aggregation layer
        result, message = setup_scenario(
            DOCK,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction',
            aggregation_layer=u'D\xedstr\xedct\'s of Jakarta',
            aggregation_enabled_flag=True)
        message += ' when an aggregation layer is defined.'
        self.assertTrue(result, message)

        # With no aggregation layer
        layer = DOCK.get_aggregation_layer()
        layer_id = layer.id()
        QgsMapLayerRegistry.instance().removeMapLayer(layer_id)
        result, message = setup_scenario(
            DOCK,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction',
            aggregation_enabled_flag=False)
        message += ' when no aggregation layer is defined.'
        self.assertTrue(result, message)
开发者ID:Charlotte-Morgan,项目名称:inasafe,代码行数:28,代码来源:test_dock.py

示例2: test_user_defined_extent

    def test_user_defined_extent(self):
        """Test that analysis honours user defined extents.

        Note that when testing on a desktop system this will overwrite your
        user defined analysis extent.

        """

        settings = QtCore.QSettings()
        extents = '106.772279, -6.237576, 106.885165, -6.165415'
        settings.setValue('inasafe/analysis_extent', extents)
        settings.setValue('inasafe/analysis_extent_crs', 'EPSG:4326')
        DOCK.read_settings()

        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)

        DOCK.extent.show_rubber_bands = True
        expected_vertex_count = 5

        # 4326 with disabled on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        # User extent should override this
        set_small_jakarta_extent(DOCK)
        DOCK.extent.show_user_analysis_extent()
        user_band = DOCK.extent.user_analysis_rubberband
        self.assertEqual(expected_vertex_count, user_band.numberOfVertices())
开发者ID:severinmenard,项目名称:inasafe,代码行数:33,代码来源:test_dock.py

示例3: test_cbo_aggregation_toggle

    def test_cbo_aggregation_toggle(self):
        """Aggregation Combobox toggles on and off as expected."""
        settings = QtCore.QSettings()
        settings.setValue(
            'inasafe/analysis_extents_mode', 'HazardExposure')
        # With aggregation layer
        result, message = setup_scenario(
            self.dock,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction',
            aggregation_layer=u'D\xedstr\xedct\'s of Jakarta',
            aggregation_enabled_flag=True)
        message += ' when an aggregation layer is defined.'
        self.assertTrue(result, message)

        # With no aggregation layer
        layer = self.dock.get_aggregation_layer()
        layer_id = layer.id()
        QgsMapLayerRegistry.instance().removeMapLayer(layer_id)
        result, message = setup_scenario(
            self.dock,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction',
            aggregation_enabled_flag=False)
        message += ' when no aggregation layer is defined.'
        self.assertTrue(result, message)
开发者ID:lucernae,项目名称:inasafe,代码行数:30,代码来源:test_dock.py

示例4: test_cbo_aggregation_toggle

    def test_cbo_aggregation_toggle(self):
        """Aggregation Combobox toggles on and off as expected."""

        # With aggregation layer
        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 singlepart',
            aggregation_enabled_flag=True)
        message += ' when an aggregation layer is defined.'
        self.assertTrue(result, message)

        # With no aggregation layer
        layer = DOCK.get_aggregation_layer()
        layer_id = layer.id()
        QgsMapLayerRegistry.instance().removeMapLayer(layer_id)
        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function',
            aggregation_enabled_flag=False)
        message += ' when no aggregation layer is defined.'
        self.assertTrue(result, message)
开发者ID:severinmenard,项目名称:inasafe,代码行数:28,代码来源:test_dock.py

示例5: test_user_defined_extent

    def test_user_defined_extent(self):
        """Test that analysis honours user defined extents.

        Note that when testing on a desktop system this will overwrite your
        user defined analysis extent.

        """

        settings = QtCore.QSettings()
        extents = '106.772279, -6.237576, 106.885165, -6.165415'
        settings.setValue('inasafe/analysis_extent', extents)
        settings.setValue('inasafe/analysis_extent_crs', 'EPSG:4326')
        self.dock.read_settings()

        setup_scenario(
            self.dock,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction',
            aggregation_layer=u'D\xedstr\xedct\'s of Jakarta',
            aggregation_enabled_flag=True)

        self.dock.extent.show_rubber_bands = True
        expected_vertex_count = 2

        # 4326 with disabled on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        # User extent should override this
        set_small_jakarta_extent(self.dock)
        self.dock.extent.show_user_analysis_extent()
        user_band = self.dock.extent.user_analysis_rubberband
        self.assertEqual(expected_vertex_count, user_band.numberOfVertices())
开发者ID:lucernae,项目名称:inasafe,代码行数:33,代码来源:test_dock.py

示例6: test_has_parameters_button_disabled

 def test_has_parameters_button_disabled(self):
     """Function configuration button is disabled when layers not
     compatible."""
     set_canvas_crs(GEOCRS, True)
     setup_scenario(
         self.dock,
         hazard='Earthquake',
         exposure='Roads',
         function='',
         function_id='')
     tool_button = self.dock.toolFunctionOptions
     flag = tool_button.isEnabled()
     self.assertTrue(
         not flag,
         'Expected configuration options button to be disabled')
开发者ID:lucernae,项目名称:inasafe,代码行数:15,代码来源:test_dock.py

示例7: test_has_parameters_button_disabled

 def test_has_parameters_button_disabled(self):
     """Function configuration button is disabled when layers not
     compatible."""
     set_canvas_crs(GEOCRS, True)
     setup_scenario(
         DOCK,
         hazard='An earthquake in Yogyakarta like in 2006',
         exposure='roads Maumere',
         function='',
         function_id='')
     tool_button = DOCK.toolFunctionOptions
     flag = tool_button.isEnabled()
     self.assertTrue(
         not flag,
         'Expected configuration options button to be disabled')
开发者ID:severinmenard,项目名称:inasafe,代码行数:15,代码来源:test_dock.py

示例8: xtest_extents_changed

 def xtest_extents_changed(self):
     """Memory requirements are calculated correctly when extents change.
     """
     set_canvas_crs(GEOCRS, True)
     set_jakarta_extent(self.dock)
     setup_scenario(
         self.dock,
         hazard='A flood in Jakarta like in 2007',
         exposure='Penduduk Jakarta',
         function='Need evacuation',
         function_id='FloodEvacuationRasterHazardFunction')
     result = self.dock.checkMemoryUsage()
     message = 'Expected "3mb" to apear in : %s' % result
     self.assertTrue(result is not None, 'Check memory reported None')
     self.assertTrue('3mb' in result, message)
开发者ID:lucernae,项目名称:inasafe,代码行数:15,代码来源:test_dock.py

示例9: test_issue581

    def test_issue581(self):
        """Test issue #581 in github - Humanize can produce IndexError : list
        index out of range
        """
        # See https://github.com/AIFDR/inasafe/issues/581

        result, message = setup_scenario(
            self.dock,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction')
        self.assertTrue(result, message)

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_small_jakarta_extent(self.dock)
        # Press RUN
        self.dock.accept()
        result = self.dock.wvResults.page().currentFrame().toPlainText()

        message = 'Result not as expected: %s' % result
        self.assertTrue('IndexError' not in result, message)
        self.assertTrue(
            'It appears that no Population are affected by Continuous Flood.'
            in result, message)
开发者ID:lucernae,项目名称:inasafe,代码行数:26,代码来源:test_dock.py

示例10: test_layer_legend_index

    def test_layer_legend_index(self):
        """Test we can get the legend index for a layer.

        .. versionadded:: 3.2

        """

        setup_scenario(
            self.dock,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction')
        layer = self.dock.get_exposure_layer()
        index = self.dock.layer_legend_index(layer)
        self.assertTrue(index == 8)
开发者ID:lucernae,项目名称:inasafe,代码行数:16,代码来源:test_dock.py

示例11: test_issue47

    def test_issue47(self):
        """Issue47: Hazard & exposure data are in different proj to viewport.

        See https://github.com/AIFDR/inasafe/issues/47"""

        result, message = setup_scenario(
            self.dock,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction')
        self.assertTrue(result, message)

        # Enable on-the-fly reprojection
        set_canvas_crs(GOOGLECRS, True)
        set_jakarta_google_extent(self.dock)

        # Press RUN
        self.dock.accept()

        result = self.dock.wvResults.page_to_text()

        message = 'Result not as expected: %s' % result
        # searching for values 6700 clean water [l] in result
        self.assertTrue(format_int(6700) in result, message)
开发者ID:lucernae,项目名称:inasafe,代码行数:25,代码来源:test_dock.py

示例12: test_result_styling

    def test_result_styling(self):
        """Test that colours and opacity from a model are correctly styled."""

        # Push OK with the left mouse button

        print '--------------------'
        print combos_to_string(self.dock)

        result, message = setup_scenario(
            self.dock,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction')
        self.assertTrue(result, message)

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

        self.dock.accept()
        # self.dock.analysis.get_impact_layer()
        safe_layer = self.dock.analysis.impact_layer
        qgis_layer = read_impact_layer(safe_layer)
        style = safe_layer.get_style_info()
        setRasterStyle(qgis_layer, style)
        # simple test for now - we could test explicity for style state
        # later if needed.
        message = (
            'Raster layer was not assigned a Singleband pseudocolor'
            ' renderer as expected.')
        self.assertTrue(
            qgis_layer.renderer().type() == 'singlebandpseudocolor', message)
开发者ID:lucernae,项目名称:inasafe,代码行数:33,代码来源:test_dock.py

示例13: xtest_print_map

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

        result, message = setup_scenario(
            self.dock,
            hazard='Flood in Jakarta',
            exposure='Essential buildings',
            function='Be affected',
            function_id='Categorised Hazard Building Impact Function')
        self.assertTrue(result, message)

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

        # Press RUN
        button = self.dock.pbnRunStop
        # noinspection PyCallByClass,PyTypeChecker
        button.click()
        print_button = self.dock.pbnPrint

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

示例14: test_insufficient_overlap

    def test_insufficient_overlap(self):
        """Test Insufficient overlap errors are caught.

        ..note:: See https://github.com/AIFDR/inasafe/issues/372
        """
        # Push OK with the left mouse button
        button = self.dock.pbnRunStop

        message = 'Run button was not enabled'
        self.assertTrue(button.isEnabled(), message)
        set_jakarta_extent(self.dock)
        result, message = setup_scenario(
            self.dock,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction')
        self.assertTrue(result, message)

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        # Zoom to an area where there is no overlap with layers
        rectangle = QgsRectangle(106.849, -6.153, 106.866, -6.134)
        CANVAS.setExtent(rectangle)
        crs = QgsCoordinateReferenceSystem('EPSG:4326')
        self.dock.define_user_analysis_extent(rectangle, crs)
        self.dock.show_next_analysis_extent()
        # Check that run button is disabled because extents do not overlap
        message = 'Run button was not disabled'
        self.assertFalse(button.isEnabled(), message)
开发者ID:lucernae,项目名称:inasafe,代码行数:30,代码来源:test_dock.py

示例15: test_has_parameters_button_enabled

 def test_has_parameters_button_enabled(self):
     """Function configuration button is enabled when layers are compatible.
     """
     set_canvas_crs(GEOCRS, True)
     set_jakarta_extent(self.dock)
     setup_scenario(
         self.dock,
         hazard='A flood in Jakarta like in 2007',
         exposure='Penduduk Jakarta',
         function='Need evacuation',
         function_id='FloodEvacuationRasterHazardFunction')
     tool_button = self.dock.toolFunctionOptions
     flag = tool_button.isEnabled()
     self.assertTrue(
         flag,
         'Expected configuration options button to be enabled')
开发者ID:lucernae,项目名称:inasafe,代码行数:16,代码来源:test_dock.py


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