本文整理汇总了Python中safe.test.utilities.set_jakarta_extent函数的典型用法代码示例。如果您正苦于以下问题:Python set_jakarta_extent函数的具体用法?Python set_jakarta_extent怎么用?Python set_jakarta_extent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_jakarta_extent函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: test_check_aggregation_no_attributes
def test_check_aggregation_no_attributes(self):
"""Aggregation attribute chosen correctly when no attr available."""
layer_path = os.path.join(
TESTDATA, 'kabupaten_jakarta_singlepart_0_good_attr.shp')
file_list = [layer_path]
# add additional layers
load_layers(file_list, clear_flag=False)
attribute_key = get_defaults('AGGR_ATTR_KEY')
# with no good aggregation attribute using
# kabupaten_jakarta_singlepart_0_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 0 good attr')
set_jakarta_extent(dock=DOCK)
assert result, message
# Press RUN
DOCK.accept()
DOCK.runtime_keywords_dialog.accept()
attribute = DOCK.analysis.aggregator.attributes[attribute_key]
message = (
'The aggregation should be None. Found: %s' % attribute)
assert attribute is None, message
开发者ID:severinmenard,项目名称:inasafe,代码行数:25,代码来源:test_aggregator.py
示例3: setUp
def setUp(self):
"""Fixture run before all tests"""
register_impact_functions()
self.maxDiff = None # show full diff for assert errors
os.environ['LANG'] = 'en'
self.DOCK.show_only_visible_layers_flag = True
load_standard_layers(self.DOCK)
self.DOCK.cboHazard.setCurrentIndex(0)
self.DOCK.cboExposure.setCurrentIndex(0)
self.DOCK.cboFunction.setCurrentIndex(0)
self.DOCK.run_in_thread_flag = False
self.DOCK.show_only_visible_layers_flag = False
self.DOCK.set_layer_from_title_flag = False
self.DOCK.zoom_to_impact_flag = False
self.DOCK.hide_exposure_flag = False
self.DOCK.show_intermediate_layers = False
set_jakarta_extent()
self._keywordIO = KeywordIO()
self._defaults = get_defaults()
# Set extent as Jakarta extent
geo_crs = QgsCoordinateReferenceSystem()
geo_crs.createFromSrid(4326)
self.extent = extent_to_geo_array(CANVAS.extent(), geo_crs)
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:25,代码来源:test_aggregator.py
示例4: test_check_aggregation_single_attribute
def test_check_aggregation_single_attribute(self):
"""Aggregation attribute is chosen correctly when there is only
one attr available."""
layer_path = os.path.join(
TESTDATA, 'kabupaten_jakarta_singlepart_1_good_attr.shp')
file_list = [layer_path]
# 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(
self.DOCK,
hazard='Continuous Flood',
exposure='Population',
function_id='FloodEvacuationRasterHazardFunction',
aggregation_layer='kabupaten jakarta singlepart 1 good attr')
set_jakarta_extent(dock=self.DOCK)
assert result, message
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
self.DOCK.accept()
aggregator = self.DOCK.impact_function.aggregator
attribute = aggregator.attributes[attribute_key]
message = (
'The aggregation should be KAB_NAME. Found: %s' % attribute)
self.assertEqual(attribute, 'KAB_NAME', message)
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:28,代码来源:test_aggregator.py
示例5: xtest_print_map
def xtest_print_map(self):
"""Test print map, especially on Windows."""
settings = QtCore.QSettings()
settings.setValue('inasafe/analysis_extents_mode', 'HazardExposure')
result, message = setup_scenario(
self.dock,
hazard='Classified Flood',
exposure='Buildings',
function='Be impacted in each hazard class',
function_id='ClassifiedRasterHazardBuildingFunction')
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent(self.dock)
self.assertTrue(result, message)
# 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:easmetz,项目名称:inasafe,代码行数:31,代码来源:test_dock.py
示例6: test_check_aggregation_single_attribute
def test_check_aggregation_single_attribute(self):
"""Aggregation attribute is chosen correctly when there is only
one attr available."""
layer_path = os.path.join(
TESTDATA, 'kabupaten_jakarta_singlepart_1_good_attr.shp')
file_list = [layer_path]
# 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.analysis.aggregator.attributes
attribute = DOCK.analysis.aggregator.attributes[attribute_key]
message = (
'The aggregation should be KAB_NAME. Found: %s' % attribute)
self.assertEqual(attribute, 'KAB_NAME', message)
开发者ID:severinmenard,项目名称:inasafe,代码行数:30,代码来源:test_aggregator.py
示例7: 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
示例8: test_result_styling
def test_result_styling(self):
"""Test that colours and opacity from a model are correctly styled."""
settings = QtCore.QSettings()
settings.setValue('inasafe/analysis_extents_mode', 'HazardExposure')
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()
safe_layer = self.dock.impact_function.impact
qgis_layer = read_impact_layer(safe_layer)
style = safe_layer.get_style_info()
setRasterStyle(qgis_layer, style)
# simple test for now - we could test explicitly for style state
# later if needed.
message = (
'Raster layer was not assigned a Singleband pseudocolor '
'renderer as expected.')
self.assertEquals(
qgis_layer.renderer().type(), 'singlebandpseudocolor', message)
开发者ID:easmetz,项目名称:inasafe,代码行数:30,代码来源:test_dock.py
示例9: test_check_aggregation_no_attributes
def test_check_aggregation_no_attributes(self):
"""Aggregation attribute chosen correctly when no attr available."""
layer_path = os.path.join(
TESTDATA, 'kabupaten_jakarta_singlepart_0_good_attr.shp')
file_list = [layer_path]
# add additional layers
load_layers(file_list, clear_flag=False)
attribute_key = get_defaults('AGGR_ATTR_KEY')
# with no good aggregation attribute using
# kabupaten_jakarta_singlepart_0_good_attr.shp
result, message = setup_scenario(
self.DOCK,
hazard='Continuous Flood',
exposure='Population',
function_id='FloodEvacuationRasterHazardFunction',
aggregation_layer='kabupaten jakarta singlepart 0 good attr')
set_jakarta_extent(dock=self.DOCK)
self.assertTrue(result, message)
# Press RUN
self.DOCK.accept()
aggregator = self.DOCK.impact_function.aggregator
attribute = aggregator.attributes[attribute_key]
message = (
'The aggregation should be None. Found: %s' % attribute)
self.assertIsNone(attribute, message)
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:25,代码来源:test_aggregator.py
示例10: 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
示例11: test_save_scenario
def test_save_scenario(self):
"""Test saving Current scenario."""
result, message = setup_scenario(
DOCK,
hazard='Classified Flood',
exposure='Population',
function='Be affected by each hazard class',
function_id='ClassifiedRasterHazardPopulationFunction')
self.assertTrue(result, message)
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent(dock=DOCK)
# 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 == '[Classified Flood]',
'Title is not the same')
self.assertTrue(
exposure.startswith('exposure =') and exposure.endswith(
'pop_binary_raster_20_20.asc'),
'Exposure is not the same')
self.assertTrue(
hazard.startswith('hazard =') and hazard.endswith(
'classified_flood_20_20.asc'),
'Hazard is not the same')
self.assertTrue(
function == (
'function = ClassifiedRasterHazardPopulationFunction'),
'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:Samweli,项目名称:inasafe,代码行数:57,代码来源:test_save_scenario.py
示例12: test_full_run_qgszstats
def test_full_run_qgszstats(self):
"""Aggregation results are correct using native QGIS zonal stats.
.. note:: We know this is going to fail (hence the decorator) as
QGIS1.8 zonal stats are broken. We expect this to pass when we
have ported to the QGIS 2.0 api at which time we can remove the
decorator. TS July 2013
"""
# TODO check that the values are similar enough to the python stats
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)
self.assertTrue(result, message)
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent(self.dock)
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
# use QGIS zonal stats only in the test
qgis_zonal_flag = bool(QtCore.QSettings().value(
'inasafe/use_native_zonal_stats', False, type=bool))
QtCore.QSettings().setValue('inasafe/use_native_zonal_stats', True)
self.dock.accept()
QtCore.QSettings().setValue('inasafe/use_native_zonal_stats',
qgis_zonal_flag)
result = self.dock.wvResults.page_to_text()
control_file_path = test_data_path(
'control',
'files',
'test-full-run-results-qgis.txt')
expected_result = codecs.open(
control_file_path,
mode='r',
encoding='utf-8').readlines()
result = result.replace(
'</td> <td>', ' ').replace('</td><td>', ' ')
result = result.replace(
'<th class="text-right">', ' ').replace('</th>', ' ')
result = result.replace(
'</td><td class="text-right">', ' ')
for line in expected_result:
line = line.replace('\n', '')
self.assertIn(line, result)
开发者ID:lucernae,项目名称:inasafe,代码行数:55,代码来源:test_dock.py
示例13: 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(self.dock)
result, message = setup_scenario(
self.dock,
hazard='Continuous Flood',
exposure='Buildings',
function='Be flooded',
function_id='FloodRasterBuildingFunction')
self.dock.get_functions()
self.assertTrue(result, message)
开发者ID:lucernae,项目名称:inasafe,代码行数:13,代码来源:test_dock.py
示例14: 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(DOCK)
result, message = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='OSM Building Polygons',
function='Be flooded',
function_id='Flood Raster Building Impact Function')
DOCK.get_functions()
self.assertTrue(result, message)
开发者ID:severinmenard,项目名称:inasafe,代码行数:13,代码来源:test_dock.py
示例15: test_full_run_qgszstats
def test_full_run_qgszstats(self):
"""Aggregation results are correct using native QGIS zonal stats.
.. note:: We know this is going to fail (hence the decorator) as
QGIS1.8 zonal stats are broken. We expect this to pass when we
have ported to the QGIS 2.0 api at which time we can remove the
decorator. TS July 2013
"""
# TODO check that the values are similar enough to the python stats
path = os.path.join(BOUNDDATA, 'kabupaten_jakarta.shp')
file_list = [path]
load_layers(file_list, clear_flag=False)
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(DOCK)
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
# use QGIS zonal stats only in the test
qgis_zonal_flag = bool(QtCore.QSettings().value(
'inasafe/use_native_zonal_stats', False, type=bool))
QtCore.QSettings().setValue('inasafe/use_native_zonal_stats', True)
DOCK.accept()
QtCore.QSettings().setValue('inasafe/use_native_zonal_stats',
qgis_zonal_flag)
result = DOCK.wvResults.page_to_text()
control_file_path = test_data_path(
'control',
'files',
'test-full-run-results-qgis.txt')
expected_result = open(control_file_path, 'rb').readlines()
result = result.replace(
'</td> <td>', ' ').replace('</td><td>', ' ')
for line in expected_result:
line = line.replace('\n', '')
self.assertIn(line, result)
开发者ID:severinmenard,项目名称:inasafe,代码行数:51,代码来源:test_dock.py
示例16: 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
示例17: setUp
def setUp(self):
"""Fixture run before all tests"""
os.environ['LANG'] = 'en'
DOCK.show_only_visible_layers_flag = True
load_standard_layers(DOCK)
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:severinmenard,项目名称:inasafe,代码行数:15,代码来源:test_postprocessor_manager.py
示例18: 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
示例19: test_vector_projections
def test_vector_projections(self):
"""Test that vector input data is reprojected properly during clip."""
# Input data is OSM in GOOGLE CRS
# We are reprojecting to GEO and expecting the output shp to be in GEO
# see https://github.com/AIFDR/inasafe/issues/119
# and https://github.com/AIFDR/inasafe/issues/95
vector_layer = QgsVectorLayer(
VECTOR_PATH2, 'OSM Buildings', 'ogr')
message = 'Failed to load osm buildings'
assert vector_layer is not None, message
assert vector_layer.isValid()
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
clip_rectangle = [106.52, -6.38, 107.14, -6.07]
# Clip the vector to the bbox
result = clip_layer(vector_layer, clip_rectangle)
assert(os.path.exists(result.source()))
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:17,代码来源:test_clipper.py
示例20: test_preprocessing
def test_preprocessing(self):
"""Preprocessing results are correct.
TODO - this needs to be fixed post dock refactor.
"""
layer_path = os.path.join(
TESTDATA, 'jakarta_crosskabupaten_polygons.shp')
# See qgis project in test data: vector_preprocessing_test.qgs
# add additional layers
file_list = [layer_path]
load_layers(file_list, clear_flag=False)
layer_path = os.path.join(
BOUNDDATA, 'kabupaten_jakarta.shp')
file_list = [layer_path]
load_layers(file_list, clear_flag=False)
result, message = setup_scenario(
DOCK,
hazard='jakarta_crosskabupaten_polygons',
exposure='People',
function_id='Flood Evacuation Function Vector Hazard',
aggregation_layer='kabupaten jakarta',
aggregation_enabled_flag=True)
assert result, message
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent(dock=DOCK)
# Press RUN
DOCK.accept()
DOCK.runtime_keywords_dialog.accept()
expected_feature_count = 20
message = (
'The preprocessing should have generated %s features, '
'found %s' % (
expected_feature_count,
DOCK.analysis.aggregator.preprocessed_feature_count))
self.assertEqual(
expected_feature_count,
DOCK.analysis.aggregator.preprocessed_feature_count,
message)
开发者ID:severinmenard,项目名称:inasafe,代码行数:44,代码来源:test_aggregator.py
注:本文中的safe.test.utilities.set_jakarta_extent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论