forked from GeoNode/geonode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request GeoNode#102 from kartoza/geosafe
Geosafe - Impact Summary
- Loading branch information
Showing
30 changed files
with
1,304 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# coding=utf-8 | ||
|
||
__author__ = 'Rizky Maulana Nugraha <[email protected]>' | ||
|
||
__date__ = '5/17/16' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# coding=utf-8 | ||
|
||
__author__ = 'Rizky Maulana Nugraha <[email protected]>' | ||
|
||
__date__ = '5/17/16' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# coding=utf-8 | ||
from collections import OrderedDict | ||
|
||
from geosafe.helpers.impact_summary.summary_base import ImpactSummary | ||
|
||
__author__ = 'Rizky Maulana Nugraha <[email protected]>' | ||
__date__ = '5/18/16' | ||
|
||
|
||
class StructureSummary(ImpactSummary): | ||
|
||
def total(self): | ||
return self.total_buildings() | ||
|
||
def total_buildings(self): | ||
return 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) | ||
|
||
def breakdown_dict(self): | ||
ret_val = OrderedDict() | ||
for key, value in self.summary_dict().iteritems(): | ||
contain_total = 'total' in key.lower() | ||
contain_affected = 'affected' in key.lower() | ||
contain_not = 'not' in key.lower() | ||
if contain_total or (contain_affected and not contain_not): | ||
continue | ||
|
||
ret_val[key] = int(value) | ||
return ret_val | ||
|
||
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(): | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# coding=utf-8 | ||
from collections import OrderedDict | ||
|
||
from geosafe.helpers.impact_summary.summary_base import ImpactSummary | ||
|
||
__author__ = 'Rizky Maulana Nugraha <[email protected]>' | ||
__date__ = '5/18/16' | ||
|
||
|
||
class PolygonPeopleSummary(ImpactSummary): | ||
|
||
def total(self): | ||
return self.total_people() | ||
|
||
def total_people(self): | ||
return int(self.summary_dict().get('Total people')) | ||
|
||
def total_affected(self): | ||
if 'Total affected people' in self.summary_dict().keys(): | ||
return int(self.summary_dict().get('Total affected people')) | ||
return 0 | ||
|
||
def breakdown_dict(self): | ||
ret_val = OrderedDict() | ||
for key, value in self.summary_dict().iteritems(): | ||
contain_total = 'total' in key.lower() | ||
contain_affected = 'affected' in key.lower() | ||
contain_not = 'not' in key.lower() | ||
contain_unaffected = 'unaffected' in key.lower() | ||
if (contain_total or | ||
(contain_affected and | ||
not contain_not and | ||
not contain_unaffected)): | ||
continue | ||
|
||
ret_val[key] = int(value) | ||
return ret_val | ||
|
||
def category_css_class(self, category): | ||
css_class = ImpactSummary.category_css_class(category) | ||
if not css_class: | ||
if 'people' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'fatalities' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'displaced' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'affected' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'floodprone' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'radius' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
return css_class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# coding=utf-8 | ||
from collections import OrderedDict | ||
|
||
from geosafe.helpers.impact_summary.summary_base import ImpactSummary | ||
|
||
__author__ = 'Rizky Maulana Nugraha <[email protected]>' | ||
__date__ = '5/18/16' | ||
|
||
|
||
class PopulationSummary(ImpactSummary): | ||
|
||
def total(self): | ||
return self.total_populations() | ||
|
||
def total_populations(self): | ||
return self.summary_dict().get('Total population') | ||
|
||
def total_affected(self): | ||
if 'Total affected population' in self.summary_dict().keys(): | ||
return int(self.summary_dict().get('Total affected population')) | ||
return 0 | ||
|
||
def breakdown_dict(self): | ||
ret_val = OrderedDict() | ||
for key, value in self.summary_dict().iteritems(): | ||
contain_total = 'total' in key.lower() | ||
contain_affected = 'affected' in key.lower() | ||
contain_not = 'not' in key.lower() | ||
contain_unaffected = 'unaffected' in key.lower() | ||
if (contain_total or | ||
(contain_affected and | ||
not contain_not and | ||
not contain_unaffected)): | ||
continue | ||
|
||
ret_val[key] = int(value) | ||
return ret_val | ||
|
||
def category_css_class(self, category): | ||
css_class = ImpactSummary.category_css_class(category) | ||
if not css_class: | ||
if 'people' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'fatalities' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'displaced' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'affected' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'floodprone' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'radius' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
return css_class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# coding=utf-8 | ||
from collections import OrderedDict | ||
|
||
from geosafe.helpers.impact_summary.summary_base import ImpactSummary | ||
|
||
__author__ = 'Rizky Maulana Nugraha <[email protected]>' | ||
__date__ = '6/13/16' | ||
|
||
|
||
class RoadSummary(ImpactSummary): | ||
|
||
def total(self): | ||
return self.total_roads() | ||
|
||
def total_roads(self): | ||
for idx, val in enumerate(self.summary_attributes()): | ||
if 'total' in val.lower(): | ||
if self.is_summary_exists(): | ||
return int(self.impact_data.get('impact summary').get( | ||
'fields')[0][idx]) | ||
return 0 | ||
|
||
def total_affected(self): | ||
lowercase_keys = [k.lower() for k in self.summary_attributes()] | ||
for idx, val in enumerate(lowercase_keys): | ||
if 'flooded' in val or 'closed' in val: | ||
return int(self.impact_data.get('impact summary').get( | ||
'fields')[0][idx]) | ||
return 0 | ||
|
||
def breakdown_dict(self): | ||
ret_val = OrderedDict() | ||
for idx, key in enumerate(self.summary_attributes()): | ||
contain_total = 'total' in key.lower() | ||
contain_affected = 'affected' in key.lower() | ||
contain_not = 'not' in key.lower() | ||
contain_unaffected = 'unaffected' in key.lower() | ||
if (contain_total or | ||
(contain_affected and | ||
not contain_not and | ||
not contain_unaffected)): | ||
continue | ||
|
||
ret_val[key] = int(self.impact_data.get('impact summary').get( | ||
'fields')[0][idx]) | ||
return ret_val | ||
|
||
def category_css_class(self, category): | ||
css_class = ImpactSummary.category_css_class(category) | ||
if not css_class: | ||
if 'closed' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
elif 'flooded' in category.lower(): | ||
css_class = 'hazard-category-high' | ||
return css_class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# coding=utf-8 | ||
from collections import OrderedDict | ||
|
||
from geosafe.helpers.impact_summary.summary_base import ImpactSummary | ||
|
||
__author__ = 'Rizky Maulana Nugraha <[email protected]>' | ||
__date__ = '5/18/16' | ||
|
||
|
||
class StructureSummary(ImpactSummary): | ||
|
||
def total(self): | ||
return self.total_buildings() | ||
|
||
def total_buildings(self): | ||
return 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) | ||
|
||
def breakdown_dict(self): | ||
ret_val = OrderedDict() | ||
for key, value in self.summary_dict().iteritems(): | ||
contain_total = 'total' in key.lower() | ||
contain_affected = 'affected' in key.lower() | ||
contain_not = 'not' in key.lower() | ||
if contain_total or (contain_affected and not contain_not): | ||
continue | ||
|
||
ret_val[key] = int(value) | ||
return ret_val | ||
|
||
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(): | ||
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 |
Oops, something went wrong.