From 4bba16d825546617f1b638a2049435a479d25132 Mon Sep 17 00:00:00 2001 From: Rizky Maulana Nugraha Date: Wed, 29 Jun 2016 17:56:20 +0700 Subject: [PATCH] Add landcover support --- README.md | 5 ++ geonode.kartoza.nginx.conf | 48 ------------------- helpers/impact_summary/landcover_summary.py | 24 ++++------ .../impact_summary/polygon_people_summary.py | 2 +- helpers/impact_summary/population_summary.py | 4 +- helpers/impact_summary/road_summary.py | 2 +- helpers/impact_summary/structure_summary.py | 6 +-- .../analysis/summary/landcover_report.html | 48 +++++++++++++++++++ 8 files changed, 70 insertions(+), 69 deletions(-) delete mode 100644 geonode.kartoza.nginx.conf create mode 100644 templates/geosafe/analysis/summary/landcover_report.html diff --git a/README.md b/README.md index 5b523ff..62920f4 100644 --- a/README.md +++ b/README.md @@ -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. + diff --git a/geonode.kartoza.nginx.conf b/geonode.kartoza.nginx.conf deleted file mode 100644 index 6eed2e0..0000000 --- a/geonode.kartoza.nginx.conf +++ /dev/null @@ -1,48 +0,0 @@ -upstream geonode { - server 127.0.0.1:8000; -} - -upstream geoserver { - server 127.0.0.1:8080; -} - -server { - - # OTF gzip compression - gzip on; - gzip_min_length 860; - gzip_comp_level 5; - gzip_proxied expired no-cache no-store private auth; - gzip_types text/plain application/xml application/x-javascript text/xml text/css application/json; - gzip_disable “MSIE [1-6].(?!.*SV1)”; - - - # Note: - # I don't specify any logs here. The proxied uwsgi and nginx - # containers maintain their own logs which are placed in the - # deployment/logs directory for the app - - # the port your site will be served on - listen 80; - # the domain name it will serve for - server_name geonode.kartoza.com; - charset utf-8; - - # max upload size, adjust to taste - client_max_body_size 500M; - - location / { - proxy_pass http://geonode; - } -} - -server { - - listen 80; - server_name geoserver.kartoza.com - charset utf-8; - - location / { - proxy_pass http://geoserver; - } -} diff --git a/helpers/impact_summary/landcover_summary.py b/helpers/impact_summary/landcover_summary.py index 7635909..6964423 100644 --- a/helpers/impact_summary/landcover_summary.py +++ b/helpers/impact_summary/landcover_summary.py @@ -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() @@ -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 diff --git a/helpers/impact_summary/polygon_people_summary.py b/helpers/impact_summary/polygon_people_summary.py index 6bdb216..1868dcc 100644 --- a/helpers/impact_summary/polygon_people_summary.py +++ b/helpers/impact_summary/polygon_people_summary.py @@ -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')) diff --git a/helpers/impact_summary/population_summary.py b/helpers/impact_summary/population_summary.py index 1b7f02a..17bb9f7 100644 --- a/helpers/impact_summary/population_summary.py +++ b/helpers/impact_summary/population_summary.py @@ -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(): diff --git a/helpers/impact_summary/road_summary.py b/helpers/impact_summary/road_summary.py index 3134196..ebc34f6 100644 --- a/helpers/impact_summary/road_summary.py +++ b/helpers/impact_summary/road_summary.py @@ -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()): diff --git a/helpers/impact_summary/structure_summary.py b/helpers/impact_summary/structure_summary.py index 7635909..b0fc531 100644 --- a/helpers/impact_summary/structure_summary.py +++ b/helpers/impact_summary/structure_summary.py @@ -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) diff --git a/templates/geosafe/analysis/summary/landcover_report.html b/templates/geosafe/analysis/summary/landcover_report.html new file mode 100644 index 0000000..a61becb --- /dev/null +++ b/templates/geosafe/analysis/summary/landcover_report.html @@ -0,0 +1,48 @@ +{% load geosafe_impact_summary %} +{% load staticfiles %} +
+
+
+
+
{{ summary.total }}
+
Total Area (ha)
+
+
+ {% with analysis.exposure_layer.metadata.category as c %} + {{ c }} + {% endwith %} +
+
+
+
+
{{ summary.total_affected }}
+
Landcover Affected (ha)
+
+
+ {% with analysis.hazard_layer.metadata.category as c %} + {{ c }} + {% endwith %} +
+
+
+
+
Hazard areas (ha)
+
+ {% for category, value in summary.breakdown_dict.iteritems %} +
+
{{ category|lower }}
+
+
{{ value }}
+
+
+ {% with 84.5 as total_width %} + + + + {% endwith %} +
+
+ {% endfor %} +
+
+