Skip to content

Commit

Permalink
Add landcover support
Browse files Browse the repository at this point in the history
  • Loading branch information
lucernae committed Jun 29, 2016
1 parent 68af678 commit 4bba16d
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 69 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ this app. A sample settings can be seen in *local_settings.sample.py*. This
settings file should be included in geonode settings file or called last, to
make sure it was overriding celery settings in the default geonode settings.

# Note

Geonode project is a requirement for this app to works, since it contains
dependency to geonode packages.

48 changes: 0 additions & 48 deletions geonode.kartoza.nginx.conf

This file was deleted.

24 changes: 10 additions & 14 deletions helpers/impact_summary/landcover_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
__date__ = '5/18/16'


class StructureSummary(ImpactSummary):
class LandcoverSummary(ImpactSummary):

def total(self):
return self.total_buildings()
return self.total_landcover()

def total_buildings(self):
return self.summary_dict().get('Total')
def total_landcover(self):
return int(self.summary_dict().get('Total'))

def total_affected(self):
if 'Affected buildings' in self.summary_dict().keys():
return self.summary_dict().get('Affected buildings')
elif 'Not affected buildings' in self.summary_dict().keys():
not_affected = self.summary_dict().get('Not affected buildings')
return int(self.total_buildings()) - int(not_affected)
if 'Affected landcover' in self.summary_dict().keys():
return int(self.summary_dict().get('Affected landcover'))
elif 'Not affected landcover' in self.summary_dict().keys():
not_affected = self.summary_dict().get('Not affected landcover')
return int(self.total_landcover()) - int(not_affected)

def breakdown_dict(self):
ret_val = OrderedDict()
Expand All @@ -37,12 +37,8 @@ def breakdown_dict(self):
def category_css_class(self, category):
css_class = ImpactSummary.category_css_class(category)
if not css_class:
if 'flood' in category.lower():
css_class = 'hazard-category-high'
elif 'dry' in category.lower():
if 'dry' in category.lower():
css_class = 'hazard-category-low'
elif 'wet' in category.lower():
css_class = 'hazard-category-medium'
elif 'radius' in category.lower():
css_class = 'hazard-category-high'
return css_class
2 changes: 1 addition & 1 deletion helpers/impact_summary/polygon_people_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class PolygonPeopleSummary(ImpactSummary):

def total(self):
return self.total_people()
return int(self.total_people())

def total_people(self):
return int(self.summary_dict().get('Total people'))
Expand Down
4 changes: 2 additions & 2 deletions helpers/impact_summary/population_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
class PopulationSummary(ImpactSummary):

def total(self):
return self.total_populations()
return int(self.total_populations())

def total_populations(self):
return self.summary_dict().get('Total population')
return int(self.summary_dict().get('Total population'))

def total_affected(self):
if 'Total affected population' in self.summary_dict().keys():
Expand Down
2 changes: 1 addition & 1 deletion helpers/impact_summary/road_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class RoadSummary(ImpactSummary):

def total(self):
return self.total_roads()
return int(self.total_roads())

def total_roads(self):
for idx, val in enumerate(self.summary_attributes()):
Expand Down
6 changes: 3 additions & 3 deletions helpers/impact_summary/structure_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
class StructureSummary(ImpactSummary):

def total(self):
return self.total_buildings()
return int(self.total_buildings())

def total_buildings(self):
return self.summary_dict().get('Total')
return int(self.summary_dict().get('Total'))

def total_affected(self):
if 'Affected buildings' in self.summary_dict().keys():
return self.summary_dict().get('Affected buildings')
return int(self.summary_dict().get('Affected buildings'))
elif 'Not affected buildings' in self.summary_dict().keys():
not_affected = self.summary_dict().get('Not affected buildings')
return int(self.total_buildings()) - int(not_affected)
Expand Down
48 changes: 48 additions & 0 deletions templates/geosafe/analysis/summary/landcover_report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% load geosafe_impact_summary %}
{% load staticfiles %}
<div class="impact-summary row">
<div class="summary col-xs-6">
<div class="row highlight">
<div class="col-xs-8">
<div class="number">{{ summary.total }}</div>
<div class="category">Total Area (ha)</div>
</div>
<div class="col-xs-4">
{% with analysis.exposure_layer.metadata.category as c %}
<img src="{% static "geosafe/img/"|add:c|add:".svg" %}" alt="{{ c }}" class="svg"/>
{% endwith %}
</div>
</div>
<div class="row highlight">
<div class="col-xs-8">
<div class="number">{{ summary.total_affected }}</div>
<div class="category">Landcover Affected (ha)</div>
</div>
<div class="col-xs-4">
{% with analysis.hazard_layer.metadata.category as c %}
<img src="{% static "geosafe/img/"|add:c|add:".svg" %}" alt="{{ c }}" class="svg"/>
{% endwith %}
</div>
</div>
</div>
<div class="category-breakdown col-xs-6">
<div class="title text-center">Hazard areas (ha)</div>
<div class="content">
{% for category, value in summary.breakdown_dict.iteritems %}
<div class="breakdown row {{ summary|category_css_class:category }}">
<div class="category col-xs-4 text-right">{{ category|lower }}</div>
<div class="value col-xs-4 text-right">
<div style="width: 100%">{{ value }}</div>
</div>
<div class="value col-xs-4 text-left">
{% with 84.5 as total_width %}
<svg width="{{ total_width }}" height="20">
<rect x="0" rx="10" ry="10" height="20" width="{% widthratio value summary.total total_width %}"></rect>
</svg>
{% endwith %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>

0 comments on commit 4bba16d

Please sign in to comment.