本文整理汇总了Python中safe.report.impact_report.ImpactReport.process_components方法的典型用法代码示例。如果您正苦于以下问题:Python ImpactReport.process_components方法的具体用法?Python ImpactReport.process_components怎么用?Python ImpactReport.process_components使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe.report.impact_report.ImpactReport
的用法示例。
在下文中一共展示了ImpactReport.process_components方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_impact_report
# 需要导入模块: from safe.report.impact_report import ImpactReport [as 别名]
# 或者: from safe.report.impact_report.ImpactReport import process_components [as 别名]
def generate_impact_report(impact_function, iface):
"""Generate the impact report from an impact function.
:param impact_function: The impact function used.
:type impact_function: ImpactFunction
:param iface: QGIS QGisAppInterface instance.
:type iface: QGisAppInterface
"""
# create impact report instance
report_metadata = ReportMetadata(
metadata_dict=standard_impact_report_metadata_pdf)
impact_report = ImpactReport(
iface,
report_metadata,
impact_function=impact_function)
# generate report folder
# no other option for now
# TODO: retrieve the information from data store
if isinstance(impact_function.datastore.uri, QDir):
layer_dir = impact_function.datastore.uri.absolutePath()
else:
# No other way for now
return
# We will generate it on the fly without storing it after datastore
# supports
impact_report.output_folder = os.path.join(layer_dir, 'output')
return impact_report.process_components()
示例2: generate_pdf_report
# 需要导入模块: from safe.report.impact_report import ImpactReport [as 别名]
# 或者: from safe.report.impact_report.ImpactReport import process_components [as 别名]
def generate_pdf_report(self, impact_function, iface, scenario_name):
"""Generate and store map and impact report from impact function.
Directory where the report stored is specified by user input from the
dialog. This function is adapted from analysis_utilities.py
:param impact_function: Impact Function.
:type impact_function: ImpactFunction()
:param iface: iface.
:type iface: iface
:param scenario_name: name of the scenario
:type scenario_name: str
"""
# output folder
output_dir = self.output_directory.text()
file_path = os.path.join(output_dir, scenario_name)
# create impact table report instance
table_report_metadata = ReportMetadata(
metadata_dict=standard_impact_report_metadata_pdf)
impact_table_report = ImpactReport(
iface,
table_report_metadata,
impact_function=impact_function)
impact_table_report.output_folder = file_path
impact_table_report.process_components()
# create impact map report instance
map_report_metadata = ReportMetadata(
metadata_dict=update_template_component(map_report))
impact_map_report = ImpactReport(
iface,
map_report_metadata,
impact_function=impact_function)
# TODO: Get from settings file
# get the extent of impact layer
impact_map_report.qgis_composition_context.extent = \
impact_function.impact.extent()
impact_map_report.output_folder = file_path
impact_map_report.process_components()
示例3: test_hello_world_report
# 需要导入模块: from safe.report.impact_report import ImpactReport [as 别名]
# 或者: from safe.report.impact_report.ImpactReport import process_components [as 别名]
def test_hello_world_report(self):
"""Test for creating hello world report.
.. versionadded:: 4.1
"""
QGIS_APP, CANVAS, IFACE, PARENT = get_qgis_app(qsetting=INASAFE_TEST)
output_folder = self.fixtures_dir('../output/hello_world_report')
# sneaky monkey patch
ImpactFunction.outputs = ['Not implemented']
impact_function = ImpactFunction()
template_metadata = ReportMetadata(
metadata_dict=hello_world_metadata_html)
impact_report = ImpactReport(
iface=IFACE,
template_metadata=template_metadata,
impact_function=impact_function)
impact_report.output_folder = output_folder
impact_report.process_components()
示例4: generate_impact_map_report
# 需要导入模块: from safe.report.impact_report import ImpactReport [as 别名]
# 或者: from safe.report.impact_report.ImpactReport import process_components [as 别名]
def generate_impact_map_report(impact_function, iface):
"""Generate impact map pdf from impact function.
:param impact_function: The impact function used.
:type impact_function: ImpactFunction
:param iface: QGIS QGisAppInterface instance.
:type iface: QGisAppInterface
"""
# create impact report instance
report_metadata = ReportMetadata(
metadata_dict=map_report_component(report_a4_blue))
impact_report = ImpactReport(
iface,
report_metadata,
impact_function=impact_function)
# Get other setting
logo_path = setting('organisation_logo_path', None, str)
impact_report.inasafe_context.organisation_logo = logo_path
disclaimer_text = setting('reportDisclaimer', None, str)
impact_report.inasafe_context.disclaimer = disclaimer_text
north_arrow_path = setting('north_arrow_path', None, str)
impact_report.inasafe_context.north_arrow = north_arrow_path
# get the extent of impact layer
impact_report.qgis_composition_context.extent = \
impact_function.impact.extent()
# generate report folder
# no other option for now
# TODO: retrieve the information from data store
if isinstance(impact_function.datastore.uri, QDir):
layer_dir = impact_function.datastore.uri.absolutePath()
else:
# No other way for now
return
# We will generate it on the fly without storing it after datastore
# supports
impact_report.output_folder = os.path.join(layer_dir, 'output')
return impact_report.process_components()
示例5: generate_infographic_report
# 需要导入模块: from safe.report.impact_report import ImpactReport [as 别名]
# 或者: from safe.report.impact_report.ImpactReport import process_components [as 别名]
def generate_infographic_report(impact_function, iface):
"""Generate impact map pdf from impact function.
:param impact_function: The impact function used.
:type impact_function: ImpactFunction
:param iface: QGIS QGisAppInterface instance.
:type iface: QGisAppInterface
"""
# get the extra layers that we need
extra_layers = []
print_atlas = setting('print_atlas_report', False, bool)
if print_atlas:
extra_layers.append(impact_function.aggregation_summary)
# create impact report instance
report_metadata = ReportMetadata(
metadata_dict=update_template_component(infographic_report))
impact_report = ImpactReport(
iface,
report_metadata,
impact_function=impact_function,
extra_layers=extra_layers)
# get the extent of impact layer
impact_report.qgis_composition_context.extent = \
impact_function.impact.extent()
# generate report folder
# no other option for now
# TODO: retrieve the information from data store
if isinstance(impact_function.datastore.uri, QDir):
layer_dir = impact_function.datastore.uri.absolutePath()
else:
# No other way for now
return
# We will generate it on the fly without storing it after datastore
# supports
impact_report.output_folder = os.path.join(layer_dir, 'output')
return impact_report.process_components()
示例6: generate_impact_map_report
# 需要导入模块: from safe.report.impact_report import ImpactReport [as 别名]
# 或者: from safe.report.impact_report.ImpactReport import process_components [as 别名]
def generate_impact_map_report(impact_function, iface):
"""Generate impact map pdf from impact function.
:param impact_function: The impact function used.
:type impact_function: ImpactFunction
:param iface: QGIS QGisAppInterface instance.
:type iface: QGisAppInterface
"""
# get the extra layers that we need
extra_layers = []
print_atlas = setting('print_atlas_report', False, bool)
if print_atlas:
extra_layers.append(impact_function.aggregation_summary)
# get the hazard and exposure type
hazard_layer = impact_function.hazard
exposure_layer = impact_function.exposure
hazard_type = layer_definition_type(hazard_layer)
exposure_type = layer_definition_type(exposure_layer)
# create impact report instance
report_metadata = ReportMetadata(
metadata_dict=update_template_component(
component=map_report,
hazard=hazard_type,
exposure=exposure_type))
impact_report = ImpactReport(
iface,
report_metadata,
impact_function=impact_function,
extra_layers=extra_layers)
# Get other setting
logo_path = setting('organisation_logo_path', None, str)
impact_report.inasafe_context.organisation_logo = logo_path
disclaimer_text = setting('reportDisclaimer', None, str)
impact_report.inasafe_context.disclaimer = disclaimer_text
north_arrow_path = setting('north_arrow_path', None, str)
impact_report.inasafe_context.north_arrow = north_arrow_path
# get the extent of impact layer
impact_report.qgis_composition_context.extent = \
impact_function.impact.extent()
# generate report folder
# no other option for now
# TODO: retrieve the information from data store
if isinstance(impact_function.datastore.uri, QDir):
layer_dir = impact_function.datastore.uri.absolutePath()
else:
# No other way for now
return
# We will generate it on the fly without storing it after datastore
# supports
impact_report.output_folder = os.path.join(layer_dir, 'output')
return impact_report.process_components()
示例7: test_earthquake_population_without_aggregation
# 需要导入模块: from safe.report.impact_report import ImpactReport [as 别名]
# 或者: from safe.report.impact_report.ImpactReport import process_components [as 别名]
def test_earthquake_population_without_aggregation(self):
"""Testing Earthquake in Population without aggregation.
.. versionadded:: 4.0
"""
output_folder = self.fixtures_dir('../output/earthquake_population')
# Classified vector with building-points
shutil.rmtree(output_folder, ignore_errors=True)
hazard_layer = load_test_raster_layer(
'hazard', 'earthquake.tif')
exposure_layer = load_test_raster_layer(
'exposure', 'pop_binary_raster_20_20.asc')
impact_function = ImpactFunction()
impact_function.exposure = exposure_layer
impact_function.hazard = hazard_layer
impact_function.prepare()
return_code, message = impact_function.run()
self.assertEqual(return_code, ANALYSIS_SUCCESS, message)
report_metadata = ReportMetadata(
metadata_dict=standard_impact_report_metadata_html)
impact_report = ImpactReport(
IFACE,
report_metadata,
impact_function=impact_function)
impact_report.output_folder = output_folder
return_code, message = impact_report.process_components()
self.assertEqual(
return_code, ImpactReport.REPORT_GENERATION_SUCCESS, message)
"""Checking generated context"""
empty_component_output_message = 'Empty component output'
# Check Analysis Summary
analysis_summary = impact_report.metadata.component_by_key(
general_report_component['key'])
""":type: safe.report.report_metadata.Jinja2ComponentsMetadata"""
expected_context = {
'table_header': (
u'Estimated Number of people affected per MMI intensity'),
'header': u'General Report',
'summary': [
{
'header_label': u'Hazard Zone',
'rows': [
{'value': 0, 'name': u'X', 'key': 'X'},
{'value': 0, 'name': u'IX', 'key': 'IX'},
{'value': '200', 'name': u'VIII', 'key': 'VIII'},
{'value': 0, 'name': u'VII', 'key': 'VII'},
{'value': 0, 'name': u'VI', 'key': 'VI'},
{'value': 0, 'name': u'V', 'key': 'V'},
{'value': 0, 'name': u'IV', 'key': 'IV'},
{'value': 0, 'name': u'III', 'key': 'III'},
{'value': 0, 'name': u'II', 'key': 'II'},
{'value': 0, 'name': u'I', 'key': 'I'},
{
'as_header': True,
'key': 'total_field',
'name': u'Total',
'value': '200'
}
],
'value_label': u'Count'
},
{
'header_label': u'Population',
'rows': [
{
'value': '200',
'name': u'Affected',
'key': 'total_affected_field',
}, {
'key': 'total_not_affected_field',
'name': u'Not Affected',
'value': '0'
}, {
'key': 'total_not_exposed_field',
'name': u'Not Exposed',
'value': '0'},
{
'value': '200',
'name': u'Displaced',
'key': 'displaced_field'
}, {
'value': '0 - 100',
'name': u'Fatalities',
'key': 'fatalities_field'
}],
'value_label': u'Count'
}
],
'notes': [
'Exposed People: People who are present in hazard zones and '
#.........这里部分代码省略.........