Skip to content

Commit

Permalink
[BACKPORT] add vocano considered on volcano-building impact functions.
Browse files Browse the repository at this point in the history
…#536 and resolve conflict.
  • Loading branch information
ismailsunni committed Mar 20, 2013
1 parent 0dd0581 commit 3564db9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions safe/impact_functions/volcanic/volcano_building_impact.py
Expand Up @@ -102,6 +102,7 @@ def run(self, layers):

#category_names = ['%s m' % x for x in radii]
category_names = rad_m
name_attribute = 'NAME' # As in e.g. the Smithsonian dataset
else:
# Use hazard map
category_title = 'KRB'
Expand All @@ -110,6 +111,21 @@ def run(self, layers):
category_names = ['Kawasan Rawan Bencana III',
'Kawasan Rawan Bencana II',
'Kawasan Rawan Bencana I']
name_attribute = 'GUNUNG' # As in e.g. BNPB hazard map

# Get names of volcanos considered
if name_attribute in my_hazard.get_attribute_names():
D = {}
for att in my_hazard.get_data():
# Run through all polygons and get unique names
D[att[name_attribute]] = None

volcano_names = ''
for name in D:
volcano_names += '%s, ' % name
volcano_names = volcano_names[:-2] # Strip trailing ', '
else:
volcano_names = tr('Not specified in data')

if not category_title in my_hazard.get_attribute_names():
msg = ('Hazard data %s did not contain expected '
Expand Down Expand Up @@ -149,7 +165,11 @@ def run(self, layers):
total = len(my_exposure)

# Generate simple impact report
blank_cell = ''
table_body = [question,
TableRow([tr('Volcanos considered'),
'%s' % volcano_names, blank_cell],
header=True),
TableRow([tr('Distance [km]'), tr('Total'),
tr('Cumulative')],
header=True)]
Expand Down

0 comments on commit 3564db9

Please sign in to comment.