← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1761: (GIS) Fixed bug where orgunit assignment did not work if a predefined legendset was loaded in the...

 

------------------------------------------------------------
revno: 1761
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-04-09 16:57:56 +0200
message:
  (GIS) Fixed bug where orgunit assignment did not work if a predefined legendset was loaded in thematic map.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat/Choropleth.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-04-08 16:02:07 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-04-09 14:57:56 +0000
@@ -2118,7 +2118,7 @@
         value: 7,
         store: new Ext.data.SimpleStore({
             fields: ['value','text'],
-            data: [[5, '5 (out)'], [6,'6'], [7,'7'], [8,'8'], [9,'9 (in)']]
+            data: [[3, '3 (out)'], [4, '4'], [5, '5'], [6,'6'], [7,'7'], [8,'8'], [9,'9'], [10,'10 (in)']]
         })
     });
     
@@ -3862,9 +3862,50 @@
 
 function onClickUnselectChoropleth(feature) {}
 
+/* EXPORT */
+function sortByValue(a, b) {
+	return b.value - a.value;
+}
+
+function getExportDataValueJSON( mapvalues ){
+	var json = '{';
+	json += '"datavalues":';
+	json += '[';
+	
+	mapvalues.sort(sortByValue);
+
+	for (var i = 0; i < mapvalues.length; i++) {		
+		json += '{';
+		json += '"organisation": "' + mapvalues[i].orgUnitId + '",';
+		json += '"value": "' + mapvalues[i].value + '" ';
+		json += i < mapvalues.length-1 ? '},' : '}';
+	}
+	json += ']';
+	json += '}';
+	
+	return json;
+}
+
+function getLegendsJSON() {
+	var legends = choropleth.imageLegend;
+	var json = '{';
+	json += '"legends":';
+	json += '[';
+	
+	for (var i = 0; i < choropleth.imageLegend.length; i++) {
+		json += '{';
+		json += '"label": "' + choropleth.imageLegend[i].label + '",';
+		json += '"color": "' + choropleth.imageLegend[i].color + '" ';
+		json += i < choropleth.imageLegend.length-1 ? '},' : '}';
+	}	
+	json += ']';
+	json += '}';
+	
+	return json;
+}
+
 /*MAP DATA*/
 function loadMapData(redirect, position) {
-
     Ext.Ajax.request({
         url: path + 'getMapByMapLayerPath' + type,
         method: 'POST',
@@ -3921,45 +3962,7 @@
     });
 }
 
-function sortByValue(a, b) {
-	return b.value - a.value;
-}
-
-function getExportDataValueJSON( mapvalues ){
-	var json = '{';
-	json += '"datavalues":';
-	json += '[';
-	mapvalues.sort(sortByValue);
-
-	for (var i = 0; i < mapvalues.length; i++) {		
-		json += '{';
-		json += '"organisation": "' + mapvalues[i].orgUnitId + '",';
-		json += '"value": "' + mapvalues[i].value + '" ';
-		json += i < mapvalues.length-1 ? '},' : '}';
-	}
-	json += ']';
-	json += '}';
-	
-	return json;
-}
-
-function getLegendsJSON() {
-	var legends = choropleth.imageLegend;
-	var json = '{';
-	json += '"legends":';
-	json += '[';
-	
-	for (var i = 0; i < choropleth.imageLegend.length; i++) {
-		json += '{';
-		json += '"label": "' + choropleth.imageLegend[i].label + '",';
-		json += '"color": "' + choropleth.imageLegend[i].color + '" ';
-		json += i < choropleth.imageLegend.length-1 ? '},' : '}';
-	}	
-	json += ']';
-	json += '}';
-	
-	return json;
-}
+
 
 /*CHOROPLETH*/
 function getChoroplethData() {
@@ -4015,7 +4018,7 @@
 			choropleth.indicator = 'value';
 			choropleth.indicatorText = 'Indicator';
 			options.indicator = choropleth.indicator;
-			
+
 			options.method = Ext.getCmp('method').getValue();
 			options.numClasses = Ext.getCmp('numClasses').getValue();
 			options.colors = choropleth.getColors();
@@ -4056,7 +4059,7 @@
 			for (var i = 0; i < features.length; i++) {
 				features[i].attributes['value'] = 0;
 			
-				for (var j=0; j < relations.length; j++) {
+				for (var j = 0; j < relations.length; j++) {
 					if (relations[j].featureId == features[i].attributes[nameColumn]) {
 						features[i].attributes['value'] = 1;
 						noAssigned++;
@@ -4126,8 +4129,8 @@
 				organisationUnits[i].compareName = organisationUnits[i].name.split(' ').join('').toLowerCase();
 			}
 			
-			for ( var i=0; i < organisationUnits.length; i++ ) {
-				for ( var j=0; j < features.length; j++ ) {
+			for ( var i = 0; i < organisationUnits.length; i++ ) {
+				for ( var j = 0; j < features.length; j++ ) {
 					if (features[j].attributes.compareName == organisationUnits[i].compareName) {
 						count_match++;
 						relations += organisationUnits[i].id + '::' + features[j].attributes[nameColumn] + ';;';

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js	2010-03-25 15:27:40 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js	2010-04-09 14:57:56 +0000
@@ -384,7 +384,6 @@
     },
 
     classifyWithBounds: function(bounds) {
-
         var bins = [];
         var binCount = [];
         var sortedValues = [];
@@ -410,10 +409,9 @@
         binCount[nbBins - 1] = this.nbVal - mapfish.Util.sum(binCount);
 		
 		choropleth.imageLegend = new Array();
-
+		
         for (var i = 0; i < nbBins; i++) {
-            bins[i] = new mapfish.GeoStat.Bin(binCount[i], bounds[i], bounds[i + 1],
-                i == (nbBins - 1));
+            bins[i] = new mapfish.GeoStat.Bin(binCount[i], bounds[i], bounds[i + 1], i == (nbBins - 1));
             var labelGenerator = this.labelGenerator || this.defaultLabelGenerator;
             bins[i].label = labelGenerator(bins[i], i, nbBins);
 			choropleth.imageLegend[i] = new Object();
@@ -491,8 +489,8 @@
 				if (str.charAt(str.length-1) == ',') {
 					str = str.substring(0, str.length-1);
 				}
-				
-				var bounds = new Array();
+				//
+				bounds = new Array();
 				bounds = str.split(',');
 				
 				for (var i = 0; i < bounds.length; i++) {
@@ -536,13 +534,15 @@
 				bounds.push(this.maxVal);
 				choropleth.colorInterpolation.push(new mapfish.ColorRgb(240,240,240));
 			}
-			method = mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS;
+			
+			method = ACTIVEPANEL == organisationUnitAssignment ? mapfish.GeoStat.Distribution.CLASSIFY_BY_EQUAL_INTERVALS : mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS;
 		}
         
         var classification = null;
         if (!nbBins) {
             nbBins = this.sturgesRule();
         }
+
         switch (method) {
         case mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS :
             classification = this.classifyWithBounds(bounds);

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat/Choropleth.js	2010-04-07 15:40:43 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat/Choropleth.js	2010-04-09 14:57:56 +0000
@@ -109,7 +109,7 @@
     createColorInterpolation: function() {
         var initialColors = this.colors;
         var numColors = this.classification.bins.length;
-		var mapLegendType = Ext.getCmp('maplegendtype_cb').getValue();
+		var mapLegendType = ACTIVEPANEL == organisationUnitAssignment ? map_legend_type_automatic : Ext.getCmp('maplegendtype_cb').getValue();
 		
 		if (mapLegendType == map_legend_type_automatic) {
 			this.colorInterpolation = mapfish.ColorRgb.getColorsArrayByRgbInterpolation(initialColors[0], initialColors[1], numColors);