← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1987: (GIS) Fixed bug where invalid JSON was returned from server.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 1987 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-08-27 23:29:45 +0530
message:
  (GIS) Fixed bug where invalid JSON was returned from server.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
  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


--
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-05 12:26:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2010-08-27 17:51:04 +0000
@@ -224,6 +224,11 @@
         
         return FEATURETYPE_NONE;
     }
+    
+    public String getValidCoordinates()
+    {
+        return coordinates != null && !coordinates.isEmpty() ? coordinates : "[]";
+    }
         
     // -------------------------------------------------------------------------
     // hashCode, equals and toString

=== 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-08-26 16:20:21 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-08-27 17:43:05 +0000
@@ -2952,7 +2952,8 @@
 	}
 	
 	addOverlaysToMap();
-    
+        
+    /* Section: layer options */
     function showWMSLayerOptions(layer) {
         if (Ext.getCmp('baselayeroptions_w')) {
             Ext.getCmp('baselayeroptions_w').destroy();
@@ -3061,6 +3062,68 @@
             Ext.getCmp('vectorlayeroptions_w').destroy();
         }
         
+        var data = [];
+        var layer = MAP.getLayersByName('Polygon layer')[0];
+        
+        for (var i = 0; i < layer.features.length; i++) {
+            data.push([i, layer.features[i].data.name]);
+        }
+        
+        var featureStore = new Ext.data.ArrayStore({
+            mode: 'local',
+            autoDestroy: true,
+            idProperty: 'i',
+            fields: ['i', 'name'],
+            data: [data]
+        });
+        
+        var locateFeatureWindow = new Ext.Window({
+            id: 'locatefeature_w',
+            title: 'Locate features',
+            layout: 'fit',
+            closeAction: 'hide',
+            defaults: {layout: 'fit', bodyStyle:'padding:8px; border:0px'},
+            width: 200,
+            items: [
+                {
+                    xtype: 'panel',
+                    items: [
+                        {
+                            xtype: 'panel',
+                            items: [
+                                { html: '<div class="window-field-label-first">Feature name</div>' },
+                                {
+                                    xtype: 'textfield',
+                                    id: 'locatefeature_tf'
+                                },
+                                { html: '<div class="window-field-label"></div>' },
+                                {
+                                    xtype: 'grid',
+                                    id: 'featuregrid_gp',
+                                    autoHeight: true,
+                                    store: featureStore,
+                                    cm: new Ext.grid.ColumnModel({
+                                        columns: [
+                                            {   
+                                                id: 'name',
+                                                header: 'Features',
+                                                dataIndex: 'name',
+                                                width: 200
+                                            }
+                                        ]
+                                    }),
+                                    sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
+                                    viewConfig: {forceFit: true},
+                                    sortable: true,
+                                    // autoExpandColumn: 'name'
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        });                    
+        
         var vectorLayerOptionsWindow = new Ext.Window({
             id: 'vectorlayeroptions_w',
             title: 'Options: <span style="font-weight:normal;">' + layer.name + '</span>',
@@ -3136,7 +3199,19 @@
                                     }
                                 }
                             }
-                        }
+                        },
+                        {
+                            html: 'Locate feature',
+                            listeners: {
+                                'click': {
+                                    fn: function() {
+                                        locateFeatureWindow.setPagePosition(Ext.getCmp('east').x - 173, Ext.getCmp('center').y + 50);
+                                        locateFeatureWindow.show();
+                                        vectorLayerOptionsWindow.hide();
+                                    }
+                                }
+                            }
+                        }                                        
                     ]
                 }
             ]
@@ -3954,6 +4029,11 @@
 }
 
 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');

=== 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-07-02 23:29:14 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/pointShapefile.vm	2010-08-27 17:51:04 +0000
@@ -10,7 +10,7 @@
       "geometry":
         {
           "type":"Point",
-          "coordinates":$!encoder.jsEncode( $!{unit.coordinates} ),
+          "coordinates":$!encoder.jsEncode( $!{unit.validCoordinates} )
         },
       "properties":
         {

=== 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-07-02 23:29:14 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/polygonShapefile.vm	2010-08-27 17:51:04 +0000
@@ -10,8 +10,7 @@
       "geometry":
         {
           "type":"MultiPolygon",
-          "coordinates":
-            $!encoder.jsEncode( $!{unit.coordinates} )
+           "coordinates":$!encoder.jsEncode( $!{unit.validCoordinates} )
         },
       "properties":
         {

=== 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-08-26 16:20:21 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2010-08-27 17:43:05 +0000
@@ -1371,6 +1371,7 @@
                     }
 
                     for (var i = 0; i < mapvalues.length; i++) {
+alert(i);                    
                         for (var j = 0; j < FEATURE[thematicMap].length; j++) {
                             if (mapvalues[i].orgUnitName == FEATURE[thematicMap][j].attributes.name) {
                                 FEATURE[thematicMap][j].attributes.value = parseFloat(mapvalues[i].value);