← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 302: Parent organisation unit / level always set to lowest when registering shapefiles + work in progr...

 

------------------------------------------------------------
revno: 302
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Tue 2009-05-19 15:24:46 +0200
message:
  Parent organisation unit / level always set to lowest when registering shapefiles + work in progress on point layer.
modified:
  gis/dhis-web-mapping/src/main/webapp/demos/geostat/geostat.js
  gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/core/GeoStat.js
  gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/ProportionalSymbol.js

=== modified file 'gis/dhis-web-mapping/src/main/webapp/demos/geostat/geostat.js'
--- gis/dhis-web-mapping/src/main/webapp/demos/geostat/geostat.js	2009-05-16 00:18:28 +0000
+++ gis/dhis-web-mapping/src/main/webapp/demos/geostat/geostat.js	2009-05-19 13:24:46 +0000
@@ -54,7 +54,7 @@
         })
     });
 
-    map.addLayers([jpl_wms, vmap0, choroplethLayer]);
+    map.addLayers([jpl_wms, vmap0, choroplethLayer, propSymbolLayer]);
 
     var selectFeatureChoropleth = new OpenLayers.Control.newSelectFeature(
         choroplethLayer,
@@ -86,6 +86,7 @@
 
     var organisationUnitStore = new Ext.data.JsonStore({
         url: path + 'getOrganisationUnitsAtLevel' + type,
+        baseParams: { level: 1, format: 'json' },
         root: 'organisationUnits',
         fields: ['id', 'name'],
         sortInfo: { field: 'name', direction: 'ASC' },
@@ -282,52 +283,70 @@
         text: 'Register new map',
         handler: function()
         {
-            var nm = Ext.getCmp('newmap_cb').getValue();
-            var oui = Ext.getCmp('organisationunit_cb').getValue();
-            var ouli = Ext.getCmp('organisationunitlevel_cb').getValue();
-            var nn = Ext.getCmp('newname_tf').getValue();
-            var mlp = Ext.getCmp('maplayerpath_tf').getValue();
-            var t = Ext.getCmp('type_cb').getValue();
-            var uc = Ext.getCmp('newuniquecolumn_tf').getValue();
-            var nc = Ext.getCmp('newnamecolumn_tf').getValue();
-            var lon = Ext.getCmp('newlongitude_tf').getValue();
-            var lat = Ext.getCmp('newlatitude_tf').getValue();
-            var zoom = Ext.getCmp('newzoom_cb').getValue();
-             
-            if (!nm || !nn || !mlp || !oui || !ouli || !uc || !nc || !lon || !lat)
-            {
-                Ext.MessageBox.alert('Error', 'Form is not complete');
-                return;
-            }
-            
+//            var nm = Ext.getCmp('newmap_cb').getValue();
+//            var oui = Ext.getCmp('organisationunit_cb').getValue();
+
             Ext.Ajax.request(
             {
-                url: path + 'addOrUpdateMap' + type,
+                url: path + 'getOrganisationUnitsAtLevel' + type,
                 method: 'GET',
-                params: { name: nn, mapLayerPath: mlp, type: t, organisationUnitId: oui, organisationUnitLevelId: ouli, uniqueColumn: uc, nameColumn: nc,
-                          longitude: lon, latitude: lat, zoom: zoom},
+                params: { level: 1, format: 'json' },
 
                 success: function( responseObject )
                 {
-                    Ext.Msg.show({
-                        title:'Register shapefiles',
-                        msg: '<p style="padding-top:8px">The map <b>' + nn + '</b> was successfully registered!</b></p>',
-                        buttons: Ext.Msg.OK,
-                        animEl: 'elId',
-                        minWidth: 400,
-                        icon: Ext.MessageBox.INFO
+                    var oui = Ext.util.JSON.decode( responseObject.responseText ).organisationUnits[0].id;
+                    var ouli = Ext.getCmp('organisationunitlevel_cb').getValue();
+                    var nn = Ext.getCmp('newname_tf').getValue();
+                    var mlp = Ext.getCmp('maplayerpath_tf').getValue();
+                    var t = Ext.getCmp('type_cb').getValue();
+                    var uc = Ext.getCmp('newuniquecolumn_tf').getValue();
+                    var nc = Ext.getCmp('newnamecolumn_tf').getValue();
+                    var lon = Ext.getCmp('newlongitude_tf').getValue();
+                    var lat = Ext.getCmp('newlatitude_tf').getValue();
+                    var zoom = Ext.getCmp('newzoom_cb').getValue();
+                     
+                    if (!nn || !mlp || !oui || !ouli || !uc || !nc || !lon || !lat)
+                    {
+                        Ext.MessageBox.alert('Error', 'Form is not complete');
+                        return;
+                    }
+                    
+                    Ext.Ajax.request(
+                    {
+                        url: path + 'addOrUpdateMap' + type,
+                        method: 'GET',
+                        params: { name: nn, mapLayerPath: mlp, type: t, organisationUnitId: oui, organisationUnitLevelId: ouli, uniqueColumn: uc, nameColumn: nc,
+                                  longitude: lon, latitude: lat, zoom: zoom},
+
+                        success: function( responseObject )
+                        {
+                            Ext.Msg.show({
+                                title:'Register shapefiles',
+                                msg: '<p style="padding-top:8px">The map <b>' + nn + '</b> was successfully registered!</b></p>',
+                                buttons: Ext.Msg.OK,
+                                animEl: 'elId',
+                                minWidth: 400,
+                                icon: Ext.MessageBox.INFO
+                            });
+                            
+                            Ext.getCmp('map_cb').getStore().reload();
+                            Ext.getCmp('maps_cb').getStore().reload();
+                            Ext.getCmp('editmap_cb').getStore().reload();
+                            Ext.getCmp('deletemap_cb').getStore().reload();
+                        },
+                        failure: function()
+                        {
+                            alert( 'Status', 'Error while saving data' );
+                        }
                     });
-                    
-                    Ext.getCmp('map_cb').getStore().reload();
-                    Ext.getCmp('maps_cb').getStore().reload();
-                    Ext.getCmp('editmap_cb').getStore().reload();
-                    Ext.getCmp('deletemap_cb').getStore().reload();
                 },
                 failure: function()
                 {
                     alert( 'Status', 'Error while saving data' );
                 }
             });
+            
+            
         }
     });
     
@@ -530,9 +549,9 @@
         items:
         [   
             { html: '<p style="padding-bottom:4px">Map type:</p>' }, typeComboBox, { html: '<br>' },
-            { html: '<p style="padding-bottom:4px">Organisation unit level:</p>' }, newMapComboBox, { html: '<br>' },
-            { html: '<p style="padding-bottom:4px">Organisation unit:</p>' }, organisationUnitComboBox, { html: '<br>' },
-            { html: '<p style="padding-bottom:4px">Divided into level:</p>' }, organisationUnitLevelComboBox, { html: '<br>' },
+//            { html: '<p style="padding-bottom:4px">Organisation unit level:</p>' }, newMapComboBox, { html: '<br>' },
+//            { html: '<p style="padding-bottom:4px">Organisation unit:</p>' }, organisationUnitComboBox, { html: '<br>' },
+            { html: '<p style="padding-bottom:4px">Organisation unit level:</p>' }, organisationUnitLevelComboBox, { html: '<br>' },
             { html: '<p style="padding-bottom:4px">Map name:</p>' }, newNameTextField, { html: '<br>' },
             { html: '<p style="padding-bottom:4px">Geoserver map layer path:</p>' }, mapLayerPathTextField, { html: '<br>' },
             { html: '<p style="padding-bottom:4px">Unique column:</p>' }, newUniqueColumnTextField, { html: '<br>' },
@@ -976,14 +995,14 @@
         }
     });
 
-    var propSymbol = new mapfish.widgets.geostat.ProportionalSymbol({
+    propSymbol = new mapfish.widgets.geostat.ProportionalSymbol({
         id: 'propsymbol',
         map: map,
         layer: propSymbolLayer,
         title: 'Proportional symbol',
         nameAttribute: "ouname",
-        indicators: [['PERIMETER', 'Perimeter']],
-        url: 'pageload.geojson',
+        indicators: [['value', 'Value']],
+        url: '../../../geoserver/wfs?request=GetFeature&typename=who:clinics&outputformat=json&version=1.0.0',
         featureSelection: false,
         loadMask : {msg: 'Loading Data...', msgCls: 'x-mask-loading'},
         defaults: {width: 130},
@@ -1088,6 +1107,7 @@
                 items:
                 [
                     choropleth,
+                    //propSymbol,
                     mapping,
                     shapefilePanel,
                     legendsetPanel
@@ -1113,7 +1133,7 @@
     }));
 
     map.addControl(new OpenLayers.Control.OverviewMap({div: $('overviewmap')}));
-
+    
     Ext.get('loading').fadeOut({remove: true});
 });
 
@@ -1222,11 +1242,12 @@
 function onClickUnselectPoint(feature) {}
 
 
-
+// MAP DATA
 mapData = null;
 
 function loadMapData(redirect)
 {
+                                                 if (url == null) {url = 'who:clinics';}
     Ext.Ajax.request( 
     {
         url: path + 'getMapByMapLayerPath' + type,
@@ -1255,6 +1276,7 @@
     });
 }
 
+// CHOROPLETH
 function getChoroplethData()
 {
     var indicatorId = Ext.getCmp('indicator_cb').getValue();
@@ -1278,74 +1300,6 @@
     });
 }
 
-function getPointData()
-{
-    var indicatorId = Ext.getCmp('indicator_cb').getValue();
-    var periodId = Ext.getCmp('period_cb').getValue();
-    var level = mapData.organisationUnitLevel;
-
-    var url = 'getMapValues' + type;
-    format = 'json';
-
-    Ext.Ajax.request( 
-    {
-        url: url,
-        method: 'GET',
-        params: { indicatorId: indicatorId, periodId: periodId, level: level, format: format },
-
-        success: function( responseObject )
-        {
-            dataReceivedPoint( responseObject.responseText );
-        },
-        failure: function()
-        {
-            alert( 'Status', 'Error while retrieving data' );
-        } 
-    });
-}
-
-function getAssignOrganisationUnitData()
-{
-    var mlp = mapData.mapLayerPath;
-    
-    Ext.Ajax.request( 
-    {
-        url: path + 'getAvailableMapOrganisationUnitRelations' + type,
-        method: 'GET',
-        params: { mapLayerPath: mlp, format: 'json' },
-
-        success: function( responseObject )
-        {
-            dataReceivedAssignOrganisationUnit( responseObject.responseText );
-        },
-        failure: function()
-        {
-            alert( 'Error while retrieving data: getAssignOrganisationUnitData' );
-        } 
-    });
-}
-
-function getAutoAssignOrganisationUnitData()
-{
-    var level = mapData.organisationUnitLevel;
-
-    Ext.Ajax.request( 
-    {
-        url: path + 'getOrganisationUnitsAtLevel' + type,
-        method: 'GET',
-        params: { level: level, format: 'json' },
-
-        success: function( responseObject )
-        {
-            dataReceivedAutoAssignOrganisationUnit( responseObject.responseText );
-        },
-        failure: function()
-        {
-            alert( 'Status', 'Error while retrieving data' );
-        } 
-    });
-}
-
 function dataReceivedChoropleth( responseText )
 {
     var layers = this.myMap.getLayersByName(choroplethLayerName);
@@ -1415,27 +1369,105 @@
     });
 }
 
+// PROPORTIONAL SYMBOL
+function getPointData()
+{
+    var indicatorId = Ext.getCmp('indicator_cb').getValue();
+    var periodId = Ext.getCmp('period_cb').getValue();
+    var level = mapData.organisationUnitLevel;
+
+    Ext.Ajax.request( 
+    {
+        url: path + 'getMapValues' + type,
+        method: 'GET',
+        params: { indicatorId: indicatorId, periodId: periodId, level: level, format: 'json' },
+
+        success: function( responseObject )
+        {
+            dataReceivedPoint( responseObject.responseText );
+        },
+        failure: function()
+        {
+            alert( 'Status', 'Error while retrieving data' );
+        } 
+    });
+}
+
 function dataReceivedPoint( responseText )
 {
-    var layers = this.myMap.getLayersByName(propSymbolLayerName);
-    var features = layers[0]["features"];
-    var featuresLength = features.length;
-    var data = Ext.util.JSON.decode(responseText);
-    var dataLength = data.mapvalues.length;
+    var layers = this.myMap.getLayersByName(choroplethLayerName);
+    var features = layers[0]['features'];
 
-    for ( var j=0; j < featuresLength; j++ ) 
+    var mapvalues = Ext.util.JSON.decode(responseText).mapvalues;
+    
+    var mlp = mapData.mapLayerPath;
+    var uniqueColumn = mapData.uniqueColumn;
+    
+    Ext.Ajax.request(
     {
-        features[j].attributes["value"] = 0;
-        
-        for ( var i=0; i < dataLength; i++ )
+        url: path + 'getAvailableMapOrganisationUnitRelations' + type,
+        method: 'GET',
+        params: { mapLayerPath: mlp, format: 'json' },
+
+        success: function( responseObject )
         {
-            if (features[j].attributes[shpcols[pointLayer][0].geocode] == data.mapvalues[i].geoCode)
+            var relations = Ext.util.JSON.decode(responseObject.responseText).mapOrganisationUnitRelations;
+
+            for (var i=0; i < relations.length; i++)
             {
-                features[j].attributes["name"] = data.mapvalues[i].orgUnit;
-                features[j].attributes["value"] = data.mapvalues[i].value;
+                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;
+                            }
+                            
+                            if (featureid == features[k].attributes[uniqueColumn])
+                            {
+                                features[k].attributes['value'] = mapvalues[j].value;
+                            }
+                        }
+                    }
+                }
             }
-        }
-    }
+            
+//            proportionalsymbol.coreComp.applyClassification();
+//            proportionalsymbol.classificationApplied = true;
+        },
+        failure: function()
+        {
+            alert( 'Error while retrieving data: dataReceivedChoropleth' );
+        } 
+    });
+}
+
+// MAPPING
+function getAssignOrganisationUnitData()
+{
+    var mlp = mapData.mapLayerPath;
+    
+    Ext.Ajax.request( 
+    {
+        url: path + 'getAvailableMapOrganisationUnitRelations' + type,
+        method: 'GET',
+        params: { mapLayerPath: mlp, format: 'json' },
+
+        success: function( responseObject )
+        {
+            dataReceivedAssignOrganisationUnit( responseObject.responseText );
+        },
+        failure: function()
+        {
+            alert( 'Error while retrieving data: getAssignOrganisationUnitData' );
+        } 
+    });
 }
 
 function dataReceivedAssignOrganisationUnit( responseText )
@@ -1484,6 +1516,29 @@
     mapping.classificationApplied = true;
 }
 
+// AUTO MAPPING
+
+function getAutoAssignOrganisationUnitData()
+{
+    var level = mapData.organisationUnitLevel;
+
+    Ext.Ajax.request( 
+    {
+        url: path + 'getOrganisationUnitsAtLevel' + type,
+        method: 'GET',
+        params: { level: level, format: 'json' },
+
+        success: function( responseObject )
+        {
+            dataReceivedAutoAssignOrganisationUnit( responseObject.responseText );
+        },
+        failure: function()
+        {
+            alert( 'Status', 'Error while retrieving data' );
+        } 
+    });
+}
+
 function dataReceivedAutoAssignOrganisationUnit( responseText )
 {
     var layers = this.myMap.getLayersByName(choroplethLayerName);
@@ -1530,4 +1585,4 @@
     
     Ext.getCmp('grid_gp').getStore().reload();
     loadMapData('assignment');
-}
\ No newline at end of file
+}

=== modified file 'gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/core/GeoStat.js'
--- gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/core/GeoStat.js	2009-04-17 23:00:32 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/core/GeoStat.js	2009-05-19 13:24:46 +0000
@@ -363,7 +363,7 @@
      *   nBins - {Integer} Total number of bins
      */
     defaultLabelGenerator: function(bin, binIndex, nbBins) {
-        return bin.lowerBound.toFixed(3) + ' - ' + bin.upperBound.toFixed(3) + ' (' + bin.nbVal + ')'
+        return bin.lowerBound.toFixed(1) + ' - ' + bin.upperBound.toFixed(1) + ' (' + bin.nbVal + ')'
     },
 
     classifyWithBounds: function(bounds) {
@@ -452,6 +452,9 @@
      * {<mapfish.GeoStat.Classification>} Classification
      */
     classify: function(method, nbBins, bounds) {
+    
+//        bounds = [this.minVal,100,this.maxVal];
+
         var classification = null;
         if (!nbBins) {
             nbBins = this.sturgesRule();

=== modified file 'gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/ProportionalSymbol.js'
--- gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/ProportionalSymbol.js	2009-04-28 14:23:39 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/ProportionalSymbol.js	2009-05-19 13:24:46 +0000
@@ -223,12 +223,15 @@
             }
             return;
         }
+
         this.indicator = this.form.findField('indicator').getValue();
         this.indicatorText = this.form.findField('indicator').getRawValue();
+
         if (!this.indicator) {
             Ext.MessageBox.alert('Error', 'You must choose an indicator');
             return;
         }
+
         var minSize = this.form.findField('minSize').getValue();
         var maxSize = this.form.findField('maxSize').getValue();
         this.coreComp.updateOptions({
@@ -237,8 +240,8 @@
             'maxSize': maxSize
         });
         
-        getPointData();
-        
+        loadMapData('point');
+
         this.coreComp.applyClassification();
         this.classificationApplied = true;
     },



--
Trunk
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.