← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2152: (GIS) Drilldown improved.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2152 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-09-17 13:00:45 +0200
message:
  (GIS) Drilldown improved.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonOrganisationUnitChildren.vm
  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/pointShapefile.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/polygonShapefile.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.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-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2010-08-27 17:51:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2010-09-17 10:58:14 +0000
@@ -153,6 +153,19 @@
     	return !this.children.isEmpty();
     }
 
+    public boolean hasChildrenWithCoordinates()
+    {
+        for ( OrganisationUnit child : children )
+        {
+            if ( child.hasCoordinates() )
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
     public boolean hasCoordinates()
     {
         return coordinates != null && coordinates.trim().length() > 0;

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm	2010-02-04 11:04:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm	2010-09-17 10:58:14 +0000
@@ -5,7 +5,8 @@
     "id": $!{unit.id},
     "name": "$!encoder.jsEncode( ${unit.name} )",
     "shortName": "$!encoder.jsEncode( ${unit.shortName} )",
-    "code": "$!encoder.jsEncode( ${unit.code} )"
+    "code": "$!encoder.jsEncode( ${unit.code} )",
+    "hasChildrenWithCoordinates": $!{unit.hasChildrenWithCoordinates()}
   }#if( $velocityCount < $size ),#end
 #end
 ] }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties	2010-09-13 14:13:44 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties	2010-09-17 10:58:14 +0000
@@ -66,7 +66,7 @@
 current_selection_no_data 			= The current selection returned no data.
 creating_choropleth					= Creating choropleth..
 assign_organisation_unit			= Assign organisation unit
-no_feature_selected					= No feature selected.
+no_feature_selected					= No feature selected
 cursor_position						= Cursor position
 overview_map						= Overview map
 feature_data						= Feature data
@@ -206,3 +206,4 @@
 highlight_color						= Highlight color
 feature_filter						= Feature filter
 locate_features						= Locate features
+no_coordinates_found				= No coordinates found.

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm	2010-09-15 16:17:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm	2010-09-17 10:58:14 +0000
@@ -205,3 +205,4 @@
 var i18n_highlight_color = '$encoder.jsEscape($i18n.getString( 'highlight_color' ) , "'")';
 var i18n_feature_filter = '$encoder.jsEscape($i18n.getString( 'feature_filter' ) , "'")';
 var i18n_locate_features = '$encoder.jsEscape($i18n.getString( 'locate_features' ) , "'")';
+var i18n_no_coordinates_found = '$encoder.jsEscape($i18n.getString( 'no_coordinates_found' ) , "'")';
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonOrganisationUnitChildren.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonOrganisationUnitChildren.vm	2010-07-05 14:49:02 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonOrganisationUnitChildren.vm	2010-09-17 10:58:14 +0000
@@ -4,13 +4,15 @@
 { 
   "id": ${unit.id}, 
   "text": "$encoder.jsEncode( ${unit.name} )",
+  "hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()},
   #if( $unit.hasChild() )
   "children": [
   #set( $innerSize = $unit.children.size() )
   #foreach( $child in $unit.children )
   {
     "id": ${child.id},
-    "text": "$encoder.jsEncode( ${child.name} )"
+    "text": "$encoder.jsEncode( ${child.name} )",
+    "hasChildrenWithCoordinates":$!{child.hasChildrenWithCoordinates()}
   }#if( $velocityCount < $innerSize ),#end
   #end
   ]

=== 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-09-15 16:20:12 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-17 10:58:14 +0000
@@ -49,6 +49,8 @@
 VALUETYPE.point = map_value_type_indicator;
 /* Top level organisation unit */
 var TOPLEVELUNIT = new Object();
+/* Locate feature window */
+var lfw;
 
 /* Detect mapview parameter in URL */
 function getUrlParam(strParamName){var output='';var strHref=window.location.href;if(strHref.indexOf('?')>-1){var strQueryString=strHref.substr(strHref.indexOf('?')).toLowerCase();var aQueryString=strQueryString.split('&');for(var iParam=0;iParam<aQueryString.length;iParam++){if(aQueryString[iParam].indexOf(strParamName.toLowerCase()+'=')>-1){var aParam=aQueryString[iParam].split('=');output=aParam[1];break;}}}return unescape(output);}
@@ -3089,6 +3091,7 @@
         baseLayerOptionsWindow.show();
     }
     
+    
     function showVectorLayerOptions(layer) {
         if (Ext.getCmp('vectorlayeroptions_w')) {
             Ext.getCmp('vectorlayeroptions_w').destroy();
@@ -3190,15 +3193,19 @@
             listeners: {
                 'close': {
                     fn: function() {
+                        lfw = false;
                         layer.redraw();
                     }
                 }
             }
-        });                    
+        });
+        
+        lfw = locateFeatureWindow;
         
         var vectorLayerOptionsWindow = new Ext.Window({
             id: 'vectorlayeroptions_w',
             title: 'Options: <span style="font-weight:normal;">' + layer.name + '</span>',
+            closeAction: 'hide',
             width: 180,
             items: [
                 {
@@ -3314,7 +3321,7 @@
                 }
             ]
         });
-        vectorLayerOptionsWindow.setPagePosition(Ext.getCmp('east').x - 206, Ext.getCmp('center').y + 50);
+        vectorLayerOptionsWindow.setPagePosition(Ext.getCmp('east').x - 202, Ext.getCmp('center').y + 50);
         vectorLayerOptionsWindow.show();
     }
 	
@@ -4116,7 +4123,7 @@
     // items: CHART
 // });
 
-/* Section: select features */
+/* Section: select features polygon */
 function onHoverSelectPolygon(feature) {
     FEATURE[thematicMap] = feature;
 
@@ -4133,43 +4140,27 @@
 }
 
 function onClickSelectPolygon(feature) {
-// function getKeys(obj){var temp=[];for(var k in obj){if(obj.hasOwnProperty(k)){temp.push(k);}}return temp;}
-// var l = MAP.getLayersByName('Polygon layer')[0];
-// l.drawFeature(feature,{'fillColor':'blue'});
-
     FEATURE[thematicMap] = feature;
-
 	var east_panel = Ext.getCmp('east');
 	var x = east_panel.x - 210;
 	var y = east_panel.y + 41;
     
-    if (ACTIVEPANEL == thematicMap && MAPSOURCE == map_source_type_database) {
-        Ext.getCmp('locatefeature_w').destroy();
-        
-        Ext.getCmp('map_tf').setValue(feature.data.name);
-        
-        for (var i = 0; i < feature.layer.features.length; i++) {
-            if (feature.data.name == feature.layer.features[i].attributes.name) {
-                Ext.getCmp('map_tf').value = feature.layer.features[i].attributes.id;
-                break;
-            }
-        }
-        
-        choropleth.loadFromDatabase(Ext.getCmp('map_tf').value);
-    }
-    else if (ACTIVEPANEL == thematicMap2 && MAPSOURCE == map_source_type_database) {
-        Ext.getCmp('map_tf2').setValue(feature.data.name);
-        
-        for (var i = 0; i < feature.layer.features.length; i++) {
-            if (feature.data.name == feature.layer.features[i].attributes.name) {
-                Ext.getCmp('map_tf2').value = feature.layer.features[i].attributes.id;
-                break;
-            }
-        }
-        
-        proportionalSymbol.loadFromDatabase(Ext.getCmp('map_tf2').value);
-    }
-    else if (ACTIVEPANEL == organisationUnitAssignment) {
+    if (MAPSOURCE == map_source_type_database) {
+        if (feature.attributes.hasChildrenWithCoordinates) {
+            if (lfw) {
+                lfw.destroy();
+            }
+            
+            Ext.getCmp('map_tf').setValue(feature.data.name);
+            Ext.getCmp('map_tf').value = feature.attributes.id;
+            choropleth.loadFromDatabase(feature.attributes.id, true);
+        }
+        else {
+            Ext.message.msg(false, i18n_no_coordinates_found);
+        }
+    }
+    
+    if (ACTIVEPANEL == organisationUnitAssignment) {
 		if (popup) {
 			popup.destroy();
 		}
@@ -4196,22 +4187,47 @@
 		feature_popup.show();
 		mapping.relation = FEATURE[thematicMap].attributes[MAPDATA[organisationUnitAssignment].nameColumn];
     }
-	else {
+	//else {
         // featureWindow.setPagePosition(Ext.getCmp('east').x - 202, Ext.getCmp('center').y + 41);
         // featureWindow.setTitle(FEATURE.attributes[MAPDATA.nameColumn]);
         // featureWindow.show();
         // periodWindow.hide();
-	}
+	//}
 }
 
 function onClickUnselectPolygon(feature) {}
 
-function onClickSelectPoint(feature) {}
-function onClickUnselectPoint(feature) {}
+/* Section: select features point */
 function onHoverSelectPoint(feature) {
     FEATURE[thematicMap2] = feature;
     Ext.getCmp('featureinfo_l').setText('<div style="color:black">' + FEATURE[thematicMap2].attributes[MAPDATA[thematicMap2].nameColumn] + '</div><div style="color:#555">' + FEATURE[thematicMap2].attributes.value + '</div>', false);
 }
+
 function onHoverUnselectPoint(feature) {
     Ext.getCmp('featureinfo_l').setText('<span style="color:#666">'+ i18n_no_feature_selected +'.</span>', false);
 }
+
+function onClickSelectPoint(feature) {
+    FEATURE[thematicMap2] = feature;
+
+	var east_panel = Ext.getCmp('east');
+	var x = east_panel.x - 210;
+	var y = east_panel.y + 41;
+	
+    if (MAPSOURCE == map_source_type_database) {
+        if (feature.attributes.hasChildrenWithCoordinates) {
+            if (lfw) {
+                lfw.destroy();
+            }
+            
+            Ext.getCmp('map_tf2').setValue(feature.data.name);
+            Ext.getCmp('map_tf2').value = feature.attributes.id;
+            proportionalSymbol.loadFromDatabase(Ext.getCmp('map_tf2').value);
+        }
+        else {
+            Ext.message.msg(false, i18n_no_coordinates_found);
+        }
+    }
+}
+
+function onClickUnselectPoint(feature) {}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/pointShapefile.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/pointShapefile.vm	2010-09-02 11:58:04 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/pointShapefile.vm	2010-09-17 10:58:14 +0000
@@ -16,6 +16,7 @@
         {
           "id":"$!{unit.id}",
           "name":"$!encoder.jsEncode( ${unit.name} )",
+          "hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()},
           "type":"Facility"
         }
     }#if( $velocityCount < $size ),#end

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/polygonShapefile.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/polygonShapefile.vm	2010-09-02 11:58:04 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/polygonShapefile.vm	2010-09-17 10:58:14 +0000
@@ -10,12 +10,13 @@
       "geometry":
         {
           "type":"MultiPolygon",
-           "coordinates":$!encoder.jsEncode( $!{unit.validCoordinates} )
+          "coordinates":$!encoder.jsEncode( $!{unit.validCoordinates} )
         },
       "properties":
         {
           "id":"$!{unit.id}",
-          "name":"$!encoder.jsEncode( ${unit.name} )"
+          "name":"$!encoder.jsEncode( ${unit.name} )",
+          "hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()}
         }
     }#if( $velocityCount < $size ),#end
   #end

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2010-09-13 15:19:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2010-09-17 10:58:14 +0000
@@ -1059,6 +1059,7 @@
                                         root: {
                                             id: TOPLEVELUNIT.id,
                                             text: TOPLEVELUNIT.name,
+                                            hasChildrenWithCoordinates: TOPLEVELUNIT.hasChildrenWithCoordinates,
                                             nodeType: 'async',
                                             draggable: false,
                                             expanded: true
@@ -1131,6 +1132,7 @@
                                     var rootNode = Ext.util.JSON.decode(r.responseText).organisationUnits[0];
                                     TOPLEVELUNIT.id = rootNode.id;
                                     TOPLEVELUNIT.name = rootNode.name;
+                                    TOPLEVELUNIT.hasChildrenWithCoordinates = rootNode.hasChildrenWithCoordinates;
                                     
                                     showTree();          
                                 },
@@ -1389,8 +1391,24 @@
         return [colorA, colorB];
     },
     
-    loadFromDatabase: function(id) {
-        if (id != choropleth.parentId || MAPVIEW) {
+    loadFromDatabase: function(id, isDrillDown) {
+        if (isDrillDown) {
+            load();
+        }
+        else if (id != choropleth.parentId || MAPVIEW) {
+            if (!MAPVIEW) {
+                if (!Ext.getCmp('map_tf').node.attributes.hasChildrenWithCoordinates) {
+                    Ext.message.msg(false, i18n_no_coordinates_found);
+                    Ext.getCmp('map_tf').setValue(Ext.getCmp('orgunit_tp').getNodeById(choropleth.parentId).attributes.text);                    
+                    Ext.getCmp('map_tf').value = choropleth.parentId;
+                    Ext.getCmp('map_tf').node = Ext.getCmp('orgunit_tp').getNodeById(choropleth.parentId);
+                    return;
+                }
+            }
+            load();
+        }
+            
+        function load() {
             MASK.msg = i18n_loading_geojson;
             MASK.show();
             

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-09-13 15:19:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-09-17 10:58:14 +0000
@@ -773,19 +773,22 @@
                         Ext.Ajax.request({
                             url: path_mapping + 'getMapLegendSetByIndicator' + type,
                             method: 'POST',
-                            params: { indicatorId: iId, format: 'json' },
-
-                            success: function( responseObject ) {
-                                var data = Ext.util.JSON.decode(responseObject.responseText);
-                                
-                                if (data.mapLegendSet[0].id != '') {
-//                                    Ext.getCmp('method_cb2').setValue(data.mapLegendSet[0].method);
-                                    Ext.getCmp('numClasses_cb2').setValue(data.mapLegendSet[0].classes);
-
-                                    Ext.getCmp('colorA_cf2').setValue(data.mapLegendSet[0].colorLow);
-                                    Ext.getCmp('colorB_cf2').setValue(data.mapLegendSet[0].colorHigh);
+                            params: {indicatorId: iId},
+                            success: function(r) {
+                                var mapLegendSet = Ext.util.JSON.decode(r.responseText).mapLegendSet[0];
+                                if (mapLegendSet.id) {
+                                    LEGEND[thematicMap2].type = map_legend_type_predefined;
+                                    Ext.getCmp('maplegendtype_cb2').setValue(map_legend_type_predefined);
+                                    Ext.getCmp('maplegendset_cb2').showField();
+                                    Ext.getCmp('maplegendset_cb2').setValue(mapLegendSet.id);
+                                    Ext.getCmp('method_cb2').hideField();
+                                    Ext.getCmp('numClasses_cb2').hideField();
+                                    Ext.getCmp('colorA_cf2').hideField();
+                                    Ext.getCmp('colorB_cf2').hideField();
+
+                                    proportionalSymbol.applyPredefinedLegend();
                                 }
-                                
+
                                 proportionalSymbol.classify(false, true);
                             },
                             failure: function()
@@ -1056,6 +1059,7 @@
                                         root: {
                                             id: TOPLEVELUNIT.id,
                                             text: TOPLEVELUNIT.name,
+                                            hasChildrenWithCoordinates: TOPLEVELUNIT.hasChildrenWithCoordinates,
                                             nodeType: 'async',
                                             draggable: false,
                                             expanded: true
@@ -1128,6 +1132,7 @@
                                     var rootNode = Ext.util.JSON.decode(r.responseText).organisationUnits[0];
                                     TOPLEVELUNIT.id = rootNode.id;
                                     TOPLEVELUNIT.name = rootNode.name;
+                                    TOPLEVELUNIT.hasChildrenWithCoordinates = rootNode.hasChildrenWithCoordinates;
                                     
                                     showTree();          
                                 },
@@ -1386,11 +1391,27 @@
         return [colorA, colorB];
     },
     
-    loadFromDatabase: function(id) {
-        if (id != proportionalSymbol.parentId || MAPVIEW) {
+    loadFromDatabase: function(id, isDrillDown) {
+        if (isDrillDown) {
+            load();
+        }
+        else if (id != proportionalSymbol.parentId || MAPVIEW) {
+            if (!MAPVIEW) {
+                if (!Ext.getCmp('map_tf2').node.attributes.hasChildrenWithCoordinates) {
+                    Ext.message.msg(false, i18n_no_coordinates_found);
+                    Ext.getCmp('map_tf2').setValue(Ext.getCmp('orgunit_tp2').getNodeById(proportionalSymbol.parentId).attributes.text);                    
+                    Ext.getCmp('map_tf2').value = proportionalSymbol.parentId;
+                    Ext.getCmp('map_tf2').node = Ext.getCmp('orgunit_tp2').getNodeById(proportionalSymbol.parentId);
+                    return;
+                }
+            }
+            load();
+        }
+            
+        function load() {
             MASK.msg = i18n_loading_geojson;
             MASK.show();
-
+            
             proportionalSymbol.parentId = id;
             proportionalSymbol.setUrl(path_mapping + 'getGeoJson.action?parentId=' + proportionalSymbol.parentId);
         }