← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 677: (GIS) Thematic map value algorithm rewritten, leading to a considerable performance improvement w...

 

------------------------------------------------------------
revno: 677
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Fri 2009-09-11 20:36:26 +0700
message:
  (GIS) Thematic map value algorithm rewritten, leading to a considerable performance improvement when drawing maps.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonAggregatedMapValues.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMap.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.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/jsonAggregatedMapValues.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonAggregatedMapValues.vm	2009-09-11 11:04:21 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonAggregatedMapValues.vm	2009-09-11 13:36:26 +0000
@@ -1,10 +1,11 @@
+#set( $size = $object.size() )
 { "mapvalues": [
 #foreach( $value in $object )
   {
-    "organisationUnitId": "$!{value.organisationUnitId}",
-    "orgUnit": "$!{value.organisationUnitName}",
+    "orgUnitId": "$!{value.organisationUnitId}",
+    "orgUnitName": "$!{value.organisationUnitName}",
     "featureId": "$!{value.featureId}",
     "value": "$!{value.value}"
-  },
+  }#if( $velocityCount < $size ),#end
 #end
 ] }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMap.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMap.vm	2009-07-06 01:22:57 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMap.vm	2009-09-11 13:36:26 +0000
@@ -5,7 +5,6 @@
     "mapLayerPath": "$!encoder.jsEncode( ${object.mapLayerPath} )",
     "organisationUnit": "$!encoder.jsEncode( ${object.organisationUnit.name} )",
     "organisationUnitLevel": "$!{object.organisationUnitLevel.level}",
-    "uniqueColumn": "$!encoder.jsEncode( ${object.uniqueColumn} )",
     "nameColumn": "$!encoder.jsEncode( ${object.nameColumn} )",
     "longitude": "$!encoder.jsEncode( ${object.longitude} )",
     "latitude": "$!encoder.jsEncode( ${object.latitude} )",

=== 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	2009-09-11 07:09:25 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2009-09-11 13:36:26 +0000
@@ -2357,12 +2357,12 @@
 	
     var indicatorId = Ext.getCmp('indicator_cb').getValue();
     var periodId = Ext.getCmp('period_cb').getValue();
-    var level = MAPDATA.organisationUnitLevel;
+    var mapLayerPath = MAPDATA.mapLayerPath;
 
     Ext.Ajax.request({
         url: path + 'getMapValues' + type,
         method: 'POST',
-        params: { indicatorId: indicatorId, periodId: periodId, level: level, format: 'json' },
+        params: { indicatorId: indicatorId, periodId: periodId, mapLayerPath: mapLayerPath, format: 'json' },
 
         success: function( responseObject ) {
             dataReceivedChoropleth( responseObject.responseText );
@@ -2376,98 +2376,109 @@
 function dataReceivedChoropleth( responseText ) {
     var layers = this.myMap.getLayersByName(CHOROPLETH_LAYERNAME);
     var features = layers[0].features;
-    
     var mapvalues = Ext.util.JSON.decode(responseText).mapvalues;
-	
+
 	if (mapvalues.length == 0) {
 		Ext.messageRed.msg('Thematic map', 'The selected indicator, period and level returned no data.');
 		MASK.hide();
 		return;
 	}
-    
+	
+	for (var i = 0; i < features.length; i++) {
+		features[i].attributes.value = 0;
+	}
+
     if (MAPSOURCE == 'database') {
-        for (var i=0; i < features.length; i++) {
-            for (var j=0; j < mapvalues.length; j++) {
-				if (features[i].attributes.value == null) {
-                    features[i].attributes.value = 0;
-                }
-
-                if (features[i].attributes.name == mapvalues[j].orgUnit) {
-                    features[i].attributes.value = parseFloat(mapvalues[j].value);
-                }
-            }
-        }
+		for (var i = 0; i < mapvalues.length; i++) {
+			for (var j = 0; j < features.length; j++) {
+				if (mapvalues[i].orgUnitName == features[j].attributes.name) {
+					features[j].attributes.value = parseFloat(mapvalues[i].value);
+				}
+			}
+		}
         
         var options = {};
         
-        /*hidden*/
-        choropleth.indicator = 'value';
-        choropleth.indicatorText = 'Indicator';
-        options.indicator = choropleth.indicator;
+        // /*hidden*/
+        // 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();
+        // options.method = Ext.getCmp('method').getValue();
+        // options.numClasses = Ext.getCmp('numClasses').getValue();
+        // options.colors = choropleth.getColors();
 
-        choropleth.coreComp.updateOptions(options);
-        choropleth.coreComp.applyClassification();
-        choropleth.classificationApplied = true;
+        // choropleth.coreComp.updateOptions(options);
+        // choropleth.coreComp.applyClassification();
+        // choropleth.classificationApplied = true;
         
-        MASK.hide();
+        // MASK.hide();
     }
     else {
-        var mlp = MAPDATA.mapLayerPath;
         var nameColumn = MAPDATA.nameColumn;
         
-        Ext.Ajax.request({
-            url: path + 'getAvailableMapOrganisationUnitRelations' + type,
-            method: 'POST',
-            params: { mapLayerPath: mlp, format: 'json' },
-
-            success: function( responseObject ) {
-                var relations = Ext.util.JSON.decode(responseObject.responseText).mapOrganisationUnitRelations;
-                
-                for (var i=0; i < relations.length; i++) {
-                    var orgunitid = relations[i].organisationUnitId;
-                    var featureid = relations[i].featureId;
+                // var relations = Ext.util.JSON.decode(responseObject.responseText).mapOrganisationUnitRelations;
+		
+		for (var i = 0; i < mapvalues.length; i++) {
+			for (var j = 0; j < features.length; j++) {
+				if (mapvalues[i].featureId == features[j].attributes[nameColumn]) {
+					features[j].attributes.value = mapvalues[i].value;
+				}
+			}
+		}
+                // for (var i=0; i < relations.length; i++) {
+                    // var orgunitid = relations[i].organisationUnitId;
+                    // var featureid = relations[i].featureId;
                     
-                    for (var j=0; j < mapvalues.length; j++) {
-                        if (orgunitid == mapvalues[j].organisationUnitId) {
-                            for (var k=0; k < features.length; k++) {
-                                if (features[k].attributes['value'] == null) {
-                                    features[k].attributes['value'] = 0;
-                                }
+                    // for (var j=0; j < mapvalues.length; j++) {
+                        // if (orgunitid == mapvalues[j].organisationUnitId) {
+                            // for (var k=0; k < features.length; k++) {
+                                // if (features[k].attributes['value'] == null) {
+                                    // features[k].attributes['value'] = 0;
+                                // }
                                 
-                                if (featureid == features[k].attributes[nameColumn]) {
-                                    features[k].attributes['value'] = mapvalues[j].value;
-                                }
-                            }
-                        }
-                    }
-                }
-                
-                var options = {};
-                
-                /*hidden*/
-                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();
-                
-                choropleth.coreComp.updateOptions(options);
-                choropleth.coreComp.applyClassification();
-                choropleth.classificationApplied = true;
-                
-                MASK.hide();
-            },
-            failure: function() {
-                alert( 'Error while retrieving data: dataReceivedChoropleth' );
-            } 
-        });
+                                // if (featureid == features[k].attributes[nameColumn]) {
+                                    // features[k].attributes['value'] = mapvalues[j].value;
+                                // }
+                            // }
+                        // }
+                    // }
+                // }
+                
+		var options = {};
+		
+		// /*hidden*/
+		// 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();
+		
+		// choropleth.coreComp.updateOptions(options);
+		// choropleth.coreComp.applyClassification();
+		// choropleth.classificationApplied = true;
+		
+		// MASK.hide();
     }
+	
+		var options = {};
+		
+		/*hidden*/
+		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();
+		
+		choropleth.coreComp.updateOptions(options);
+		choropleth.coreComp.applyClassification();
+		choropleth.classificationApplied = true;
+		
+		MASK.hide();
 }
 
 /*PROPORTIONAL SYMBOL*/


Follow ups