← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4483: (GIS) Basic orgunit filtering functionality impl for thematic layer 1 and 2.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 4483 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-08-30 16:58:25 +0200
message:
  (GIS) Basic orgunit filtering functionality impl for thematic layer 1 and 2.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js
  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/widgets/geostat/Centroid.js
  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/Point.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-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2011-08-25 13:50:11 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2011-08-30 14:45:40 +0000
@@ -452,6 +452,12 @@
 	font:bold 11px arial;
 	color:#111;
 }
+.window-filter-title {
+	padding:0 0 3px 21px;
+	background:url('../../../images/filter.png') no-repeat 0 0 transparent;
+	font:bold 11px arial;
+	color:#111;
+}
 
 /* Ext Panel */
 .panel-title {

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js	2011-08-25 13:50:11 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js	2011-08-30 14:56:26 +0000
@@ -85,6 +85,8 @@
     map_view_access_level_system: 'system',
     aggregation_strategy_real_time: 'real_time',
     aggregation_strategy_batch: 'batch',
+    operator_lowerthan: 'lt',
+    operator_greaterthan: 'gt',
     
 //  MapFish
 
@@ -688,7 +690,7 @@
             style: 'margin-top:1px',
             widget: widget,
             enableItems: function(bool) {
-                var menuItems = [2,3,5,6,8];
+                var menuItems = [2,3,5,6,7,9];
                 for (var i = 0; i < menuItems.length; i++) {
                     if (bool) {
                         this.menu.items.items[menuItems[i]].enable();
@@ -733,14 +735,15 @@
                                 }
                             },
                             '-',
-                            //{
-                                //text: 'Filter..',
-                                //iconCls: 'menu-layeroptions-filter',
-                                //scope: this,
-                                //handler: function() {
-                                    //this.widget.window.show();
-                                //}
-                            //},
+                            {
+                                text: 'Filter..',
+                                iconCls: 'menu-layeroptions-filter',
+                                hidden: (widget.legendDiv == 'symbollegend' || widget.legendDiv == 'centroidlegend'),
+                                scope: this,
+                                handler: function() {
+                                    this.widget.filtering.showFilteringWindow.call(this.widget);
+                                }
+                            },
                             {
                                 text: 'Search..',
                                 iconCls: 'menu-layeroptions-locate',

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-08-25 14:17:33 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-08-30 14:45:40 +0000
@@ -3,7 +3,7 @@
 	Ext.layout.FormLayout.prototype.trackLabels = true;
     Ext.QuickTips.init();
 	document.body.oncontextmenu = function(){return false;};
-	
+    
 	G.vars.map = new OpenLayers.Map({
         controls: [new OpenLayers.Control.MouseToolbar()],
         displayProjection: new OpenLayers.Projection('EPSG:4326'),
@@ -307,6 +307,7 @@
     
 	/* Thematic layers */
     polygonLayer = new OpenLayers.Layer.Vector(G.conf.thematic_layer_1, {
+        strategies: [ new OpenLayers.Strategy.Refresh({force:true}) ],
         'visibility': false,
         'displayInLayerSwitcher': false,
         'styleMap': new OpenLayers.StyleMap({
@@ -727,7 +728,7 @@
                         xtype: 'checkbox',
                         id: 'exportimageincludelegend_chb',
                         fieldLabel: G.i18n.legend,
-                        labelSeparator: '',				
+                        labelSeparator: '',
                         isFormField: true,
                         checked: true
                     }
@@ -2676,7 +2677,7 @@
         handler: function() {
             var control = G.vars.map.getControl('measuredistance');
             
-            if (!control.active) {                
+            if (!control.active) {
                 if (!control.window) {
                     control.window = new Ext.Window({
                         title: '<span id="window-measure-title">' + G.i18n.measure_distance + '</span>',
@@ -2721,7 +2722,7 @@
 		tooltip: 'Administrator settings',
 		disabled: !G.user.isAdmin,
         style: 'margin-top:1px',
-		handler: function() {         
+		handler: function() {
             if (!adminWindow.hidden) {
                 adminWindow.hide();
             }
@@ -2768,7 +2769,7 @@
 			'-',
 			' ',' ',' ',
 			layersLabel,
-			' ',' ',
+			' ',' ', 
             choroplethButton,
             pointButton,
             symbolButton,

=== 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	2011-08-19 21:17:43 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat/Choropleth.js	2011-08-29 15:24:44 +0000
@@ -114,7 +114,7 @@
 		this.extendStyle(null, {'pointRadius': '${calculateRadius}'}, {'calculateRadius': calculateRadius});
     
         var boundsArray = this.classification.getBoundsArray();
-        var rules = new Array(boundsArray.length-1);
+        var rules = new Array(boundsArray.length-1);        
         for (var i = 0; i < boundsArray.length-1; i++) {
             var rule = new OpenLayers.Rule({
                 symbolizer: {fillColor: this.colorInterpolation[i].toHexString()},

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js	2011-08-25 12:58:16 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js	2011-08-29 15:24:44 +0000
@@ -54,15 +54,11 @@
 
     colorInterpolation: false,
 
-    newUrl: false,
-
     legend: false,
 
 	bounds: false,
 
     mapView: false,
-
-    mapData: false,
     
     labels: false,
     

=== 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	2011-08-25 12:58:16 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-08-30 14:56:26 +0000
@@ -54,15 +54,11 @@
 
     colorInterpolation: false,
 
-    newUrl: false,
-
     legend: false,
 
 	bounds: false,
 
     mapView: false,
-
-    mapData: false,
     
     labels: false,
     
@@ -88,6 +84,113 @@
     
     requireUpdate: false,
     
+    filtering: {
+        cache: [],
+        options: {
+            gt: null,
+            lt: null
+        },
+        filter: function() {
+            var gt = this.filtering.options.gt;
+            var lt = this.filtering.options.lt;
+            var add = [];
+            for (var i = 0; i < this.filtering.cache.length; i++) {
+                if (gt && lt && this.filtering.cache[i].attributes.value > gt && this.filtering.cache[i].attributes.value < lt) {
+                    add.push(this.filtering.cache[i]);
+                }
+                else {
+                    if (!(gt && lt) && gt && this.filtering.cache[i].attributes.value > gt) {
+                        add.push(this.filtering.cache[i]);
+                    }
+                    else if (!(gt && lt) && lt && this.filtering.cache[i].attributes.value < lt) {
+                        add.push(this.filtering.cache[i]);
+                    }
+                }
+            }
+            this.layer.removeAllFeatures();
+            this.layer.addFeatures(add);
+        },
+        showFilteringWindow: function() {
+            var window = new Ext.Window({
+                title: '<span class="window-filter-title">Organisation unit filter</span>',
+                layout: 'fit',
+                autoHeight: true,
+                height: 'auto',
+                width: G.conf.window_width,
+                items: [
+                    {
+                        xtype: 'form',
+                        bodyStyle:'padding:8px',
+                        autoHeight: true,
+                        height: 'auto',
+                        labelWidth: G.conf.label_width,
+                        items: [
+                            { html: 'Show organisation units where <b>value</b> is..' },
+                            { html: '<div class="window-p"></div>' },
+                            {
+                                xtype: 'numberfield',
+                                fieldLabel: 'Greater than',
+                                width: G.conf.combo_number_width_small,
+                                listeners: {
+                                    'change': {
+                                        scope: this,
+                                        fn: function(nf) {
+                                            this.filtering.options.gt = nf.getValue();
+                                        }
+                                    }
+                                }
+                            },
+                            {
+                                xtype: 'numberfield',
+                                fieldLabel: 'Lower than',
+                                width: G.conf.combo_number_width_small,
+                                listeners: {
+                                    'change': {
+                                        scope: this,
+                                        fn: function(nf) {
+                                            this.filtering.options.lt = nf.getValue();
+                                        }
+                                    }
+                                }
+                            }
+                        ]
+                    }
+                ],
+                bbar: [
+                    '->',
+                    {
+                        xtype: 'button',
+                        text: G.i18n.update,
+                        iconCls: 'icon-assign',
+                        scope: this,
+                        handler: function() {
+                            this.filtering.filter.call(this);
+                        }
+                    }
+                ],
+                listeners: {
+                    'afterrender': {
+                        scope: this,
+                        fn: function() {
+                            this.filtering.cache = this.layer.features.slice(0);
+                        }
+                    },
+                    'close': {
+                        scope: this,
+                        fn: function() {
+                            this.layer.removeAllFeatures();
+                            this.layer.addFeatures(this.filtering.cache);
+                            this.filtering.options.gt = null;
+                            this.filtering.options.lt = null;
+                        }
+                    }
+                }
+            });
+            window.setPagePosition(G.conf.window_x_left,G.conf.window_y_left);
+            window.show();
+        }
+    },
+    
     initComponent: function() {
     
         this.initProperties();

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js	2011-08-25 12:58:16 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js	2011-08-30 14:56:26 +0000
@@ -54,15 +54,11 @@
 
     colorInterpolation: false,
 
-    newUrl: false,
-
     legend: false,
 
 	bounds: false,
 
     mapView: false,
-
-    mapData: false,
     
     labels: false,
     
@@ -88,6 +84,113 @@
     
     requireUpdate: false,
     
+    filtering: {
+        cache: [],
+        options: {
+            gt: null,
+            lt: null
+        },
+        filter: function() {
+            var gt = this.filtering.options.gt;
+            var lt = this.filtering.options.lt;
+            var add = [];
+            for (var i = 0; i < this.filtering.cache.length; i++) {
+                if (gt && lt && this.filtering.cache[i].attributes.value > gt && this.filtering.cache[i].attributes.value < lt) {
+                    add.push(this.filtering.cache[i]);
+                }
+                else {
+                    if (!(gt && lt) && gt && this.filtering.cache[i].attributes.value > gt) {
+                        add.push(this.filtering.cache[i]);
+                    }
+                    else if (!(gt && lt) && lt && this.filtering.cache[i].attributes.value < lt) {
+                        add.push(this.filtering.cache[i]);
+                    }
+                }
+            }
+            this.layer.removeAllFeatures();
+            this.layer.addFeatures(add);
+        },
+        showFilteringWindow: function() {
+            var window = new Ext.Window({
+                title: '<span class="window-filter-title">Organisation unit filter</span>',
+                layout: 'fit',
+                autoHeight: true,
+                height: 'auto',
+                width: G.conf.window_width,
+                items: [
+                    {
+                        xtype: 'form',
+                        bodyStyle:'padding:8px',
+                        autoHeight: true,
+                        height: 'auto',
+                        labelWidth: G.conf.label_width,
+                        items: [
+                            { html: 'Show organisation units where <b>value</b> is..' },
+                            { html: '<div class="window-p"></div>' },
+                            {
+                                xtype: 'numberfield',
+                                fieldLabel: 'Greater than',
+                                width: G.conf.combo_number_width_small,
+                                listeners: {
+                                    'change': {
+                                        scope: this,
+                                        fn: function(nf) {
+                                            this.filtering.options.gt = nf.getValue();
+                                        }
+                                    }
+                                }
+                            },
+                            {
+                                xtype: 'numberfield',
+                                fieldLabel: 'Lower than',
+                                width: G.conf.combo_number_width_small,
+                                listeners: {
+                                    'change': {
+                                        scope: this,
+                                        fn: function(nf) {
+                                            this.filtering.options.lt = nf.getValue();
+                                        }
+                                    }
+                                }
+                            }
+                        ]
+                    }
+                ],
+                bbar: [
+                    '->',
+                    {
+                        xtype: 'button',
+                        text: G.i18n.update,
+                        iconCls: 'icon-assign',
+                        scope: this,
+                        handler: function() {
+                            this.filtering.filter.call(this);
+                        }
+                    }
+                ],
+                listeners: {
+                    'afterrender': {
+                        scope: this,
+                        fn: function() {
+                            this.filtering.cache = this.layer.features.slice(0);
+                        }
+                    },
+                    'close': {
+                        scope: this,
+                        fn: function() {
+                            this.layer.removeAllFeatures();
+                            this.layer.addFeatures(this.filtering.cache);
+                            this.filtering.options.gt = null;
+                            this.filtering.options.lt = null;
+                        }
+                    }
+                }
+            });
+            window.setPagePosition(G.conf.window_x_left,G.conf.window_y_left);
+            window.show();
+        }
+    },
+    
     initComponent: function() {
     
         this.initProperties();

=== 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	2011-08-25 12:58:16 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2011-08-29 15:24:44 +0000
@@ -54,8 +54,6 @@
 
     colorInterpolation: false,
 
-    newUrl: false,
-
     legend: false,
 
 	imageLegend: false,
@@ -63,8 +61,6 @@
 	bounds: false,
 
     mapView: false,
-
-    mapData: false,
     
     labels: false,