Permalink
Browse files

added area to stats

  • Loading branch information...
1 parent 72eae56 commit bab5043ee48dbccc0c6a9e644f1f3a771d9de6b4 @javisantana javisantana committed Oct 10, 2011
View
@@ -19,3 +19,4 @@ src/packages/wtforms/
.sass-cache
static/bb/
static/tiles/
+gae
@@ -176,7 +176,7 @@ def update_report_stats(report_id):
'stats': {}
}
for desc, table, name in tables:
- stats['stats'].update(stats_for(r.assetid, table))
+ stats['stats'].update(stats_for(r.assetid or "PRODES_IMAZON_2011a", table))
data = json.dumps(stats)
s = StatsStore.get_for_report(report_id)
@@ -6,8 +6,8 @@
from earthengine.connector import EarthEngine
-PIXEL_SIZE = 0.25
-PIXEL_AREA = PIXEL_SIZE**2
+METER2_TO_KM2 = 1.0/(1000*1000)
+
class Stats(object):
@@ -78,8 +78,9 @@ def get_stats(self, frozen_image, table_id):
stats[str(table_id) + '_' + k] = {
"id": k,
"table": table_id,
- "def": int(v[u'2'])*PIXEL_AREA,
- "deg": int(v[u'3'])*PIXEL_AREA
+ "total_area": int(v[u'1'])*METER2_TO_KM2,
+ "def": int(v[u'2'])*METER2_TO_KM2,
+ "deg": int(v[u'3'])*METER2_TO_KM2
}
return stats
@@ -428,7 +428,7 @@ def _get_ft_client():
def fusion_tables_type(self):
""" custom type id for FT """
if self.type == self.DEGRADATION:
- return 1
+ return 3
return 2
def delete_fusion_tables(self):
@@ -1,6 +1,6 @@
# encoding: utf-8
-
+import logging
import simplejson as json
import random
from resource import Resource
@@ -30,7 +30,7 @@ def __init__( self, token, api_url=DEFAULT_API):
def _http( self, method, url, params=None ):
logging.info("ee -> %s" % url)
- #logging.info(params)
+ logging.info(params)
try:
response = urlfetch.fetch(
method = method,
View
@@ -147,7 +147,7 @@ var Vizzualization = Backbone.View.extend({
'States',
'Federal Conservation',
'State Conservation',
- 'Ingienous Land'
+ 'Indigenous Land'
],
el: $('body'),
@@ -167,6 +167,8 @@ var Vizzualization = Backbone.View.extend({
this.map = new MapView({el: this.$("#main_map")});
this.map.map.setCenter(new google.maps.LatLng(-6.348056476859352, -57.88696289062));
this.map.map.setOptions({disableDoubleClickZoom: false});
+
+
this.map.bind('ready', this.start);
// widgets
@@ -219,6 +221,12 @@ var Vizzualization = Backbone.View.extend({
start: function() {
var self = this;
+
+ if(this.reports.length === 0) {
+ show_error("No reports finished");
+ return;
+ }
+
// load layers in map
this.map.layers.reset(this.available_layers.models.reverse());
@@ -306,7 +314,7 @@ var Vizzualization = Backbone.View.extend({
} else {
//hack to avoid fails on tables without description
var desc = data.row.description || {'value': 'desc'};
- self.popup.showAt(data.latLng, data.table, data.row.name.value, desc.value, '23.291', stats.def, stats.deg);
+ self.popup.showAt(data.latLng, data.table, data.row.name.value, desc.value, stats.total_area, stats.def, stats.deg);
}
loading_small.finished('fething stats');
});
@@ -41,14 +41,16 @@ var ReportStatCollection = Backbone.Collection.extend({
self.fetch_periods(periods, function() {
var def = 0;
var deg = 0;
- //var total_area = 0;
+ var total_area = 0;
_(periods).each(function(p) {
var st = self.get(p).get('stats')[key];
def += parseFloat(st.def);
deg += parseFloat(st.deg);
- //total_area += st.total_area;
+ total_area += st.total_area;
});
- callback({'def': def.toFixed(2), 'deg': deg.toFixed(2)});
+ callback({'def': def.toFixed(2),
+ 'deg': deg.toFixed(2),
+ 'total_area': total_area.toFixed(1)});
});
return this;
}
@@ -80,11 +82,13 @@ var PolygonStatCollection = Backbone.Collection.extend({
var callback_after = _.after(self.reports.length, function(){
// agregate
var def = 0, deg = 0;
+ var total_area = 0;
self.each(function(p) {
def += p.get('def');
deg += p.get('deg');
+ total_area += p.get('total_area');
});
- callback({def: def, deg: def});
+ callback({def: def, deg: def, total_area: total_area});
});
_(this.reports).each(function(r) {
var poly = new PolygonStat({

0 comments on commit bab5043

Please sign in to comment.