← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4391: (GIS) All visible layers merged when zooming to visible extent.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 4391 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-08-20 04:41:51 +0200
message:
  (GIS) All visible layers merged when zooming to visible extent.
modified:
  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.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/javascript/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js	2011-08-20 01:35:18 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js	2011-08-20 02:34:06 +0000
@@ -319,8 +319,8 @@
         }
     },
     
-    setKeepPosition: function(cb) {
-        cb.keepPosition = !cb.keepPosition ? true : cb.keepPosition;
+    setLockPosition: function(cb) {
+        cb.lockPosition = !cb.lockPosition ? true : cb.lockPosition;
     },
     
     mergeSvg: function(str, ext) {
@@ -427,6 +427,30 @@
         return layers;
     },
     
+    zoomToVisibleExtent: function(lockPosition) {
+        if (!lockPosition) {
+            var bounds = [];
+            var layers = this.getLayersByType(G.conf.map_layer_type_thematic);
+            
+            for (var i = 0; i < layers.length; i++) {
+                if (layers[i].getDataExtent() && layers[i].visibility) {
+                    bounds.push(layers[i].getDataExtent());
+                }
+            }
+                     
+            if (bounds.length === 1) {
+                G.vars.map.zoomToExtent(bounds[0]);
+            }
+            else if (bounds.length > 1) {
+                var extended = bounds[0];
+                for (var i = 1; i < bounds.length; i++) {
+                    extended.extend(bounds[i]);
+                }
+                G.vars.map.zoomToExtent(extended);
+            }
+        }
+    },
+    
     setZIndexByLayerType: function(type, index) {
         for (var i = 0; i < G.vars.map.layers.length; i++) {
             if (G.vars.map.layers[i].layerType == type) {

=== 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-20 01:20:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-08-20 02:34:06 +0000
@@ -2488,26 +2488,7 @@
 		tooltip: G.i18n.zoom_to_visible_extent,
         style: 'margin-top:1px',
 		handler: function() {
-            if (G.vars.activePanel.isPolygon()) {
-                if (choropleth.layer.getDataExtent()) {
-                    G.vars.map.zoomToExtent(choropleth.layer.getDataExtent());
-                }
-            }
-            else if (G.vars.activePanel.isPoint()) {
-                if (point.layer.getDataExtent()) {
-                    G.vars.map.zoomToExtent(point.layer.getDataExtent());
-                }
-            }
-            else if (G.vars.activePanel.isSymbol()) {
-                if (symbol.layer.getDataExtent()) {
-                    G.vars.map.zoomToExtent(symbol.layer.getDataExtent());
-                }
-            }
-            else if (G.vars.activePanel.isCentroid()) {
-                if (centroid.layer.getDataExtent()) {
-                    G.vars.map.zoomToExtent(centroid.layer.getDataExtent());
-                }
-            }
+            G.util.zoomToVisibleExtent();
         }
 	});         
     

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js	2011-08-18 11:24:05 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js	2011-08-20 02:24:53 +0000
@@ -98,7 +98,7 @@
         if (!G.vars.activeWidget.formValidation.validateForm.call(G.vars.activeWidget)) {
                 G.vars.mask.hide();
             }
-        G.vars.activeWidget.classify(false);
+        G.vars.activeWidget.classify();
     },
 
     onSuccess2: function(request) {
@@ -121,7 +121,7 @@
 		if (!G.vars.activeWidget.formValidation.validateForm.call(G.vars.activeWidget)) {
 			G.vars.mask.hide();
 		}
-		G.vars.activeWidget.classify(false);
+		G.vars.activeWidget.classify();
     },
 
     onFailure: function(request) {

=== 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-20 01:07:01 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js	2011-08-20 02:34:06 +0000
@@ -328,7 +328,7 @@
             width: G.conf.combo_width,
             store: this.stores.indicatorsByGroup,
             currentValue: null,
-            keepPosition: false,
+            lockPosition: false,
             listeners: {
                 'select': {
                     scope: this,
@@ -359,8 +359,8 @@
                                     }
                                 }
                                 
-                                this.classify(false, cb.keepPosition);
-                                G.util.setKeepPosition(cb);
+                                this.classify(false, cb.lockPosition);
+                                G.util.setLockPosition(cb);
                             }
                         });
                         
@@ -408,7 +408,7 @@
             selectOnFocus: true,
             width: G.conf.combo_width,
             store: this.stores.dataElementsByGroup,
-            keepPosition: false,
+            lockPosition: false,
             listeners: {
                 'select': {
                     scope: this,
@@ -439,8 +439,8 @@
                                     }
                                 }
                                 
-                                this.classify(false, cb.keepPosition);
-                                G.util.setKeepPosition(cb);
+                                this.classify(false, cb.lockPosition);
+                                G.util.setLockPosition(cb);
                             }
                         });
                         
@@ -488,15 +488,15 @@
             selectOnFocus: true,
             width: G.conf.combo_width,
             store: this.stores.periodsByType,
-            keepPosition: false,
+            lockPosition: false,
             listeners: {
                 'select': {
                     scope: this,
                     fn: function(cb) {
                         this.updateValues = true;
                         
-                        this.classify(false, cb.keepPosition);                        
-                        G.util.setKeepPosition(cb);
+                        this.classify(false, cb.lockPosition);                        
+                        G.util.setLockPosition(cb);
                         
                         this.window.cmp.reset.enable();
                     }
@@ -829,7 +829,7 @@
             obj.stores.c2.load({scope: this, callback: function() {
                 obj.components.c2.setValue(this.mapView[obj.mapView.c2]);
                 obj.components.c2.currentValue = this.mapView[obj.mapView.c2];
-                obj.components.c2.keepPosition = true;
+                obj.components.c2.lockPosition = true;
                 
                 this.setMapViewLegend();
             }});
@@ -1068,14 +1068,12 @@
         );
     },
 
-    classify: function(exception, position) {
+    classify: function(exception, lockPosition) {
         if (this.formValidation.validateForm.apply(this, [exception])) {
             G.vars.mask.msg = G.i18n.aggregating_map_values;
             G.vars.mask.show();
             
-            if (!position && this.layer.features.length) {
-                G.vars.map.zoomToExtent(this.layer.getDataExtent());
-            }
+            G.util.zoomToVisibleExtent(lockPosition);
             
             if (this.mapView) {
                 if (this.mapView.longitude && this.mapView.latitude && this.mapView.zoom) {
@@ -1083,7 +1081,7 @@
                     G.vars.map.setCenter(new OpenLayers.LonLat(point.x, point.y), this.mapView.zoom);
                 }
                 else {
-                    G.vars.map.zoomToExtent(this.layer.getDataExtent());
+                    G.util.zoomToVisibleExtent();
                 }
                 this.mapView = 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-20 01:07:01 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-08-20 02:34:06 +0000
@@ -397,7 +397,7 @@
             width: G.conf.combo_width,
             store: this.stores.indicatorsByGroup,
             currentValue: null,
-            keepPosition: false,
+            lockPosition: false,
             listeners: {
                 'select': {
                     scope: this,
@@ -435,8 +435,8 @@
                                 else {
                                     this.legend.value = G.conf.map_legendset_type_automatic;
                                     this.prepareMapViewLegend();
-                                    this.classify(false, cb.keepPosition);
-                                    G.util.setKeepPosition(cb);
+                                    this.classify(false, cb.lockPosition);
+                                    G.util.setLockPosition(cb);
                                 }
                             }
                         });
@@ -485,7 +485,7 @@
             selectOnFocus: true,
             width: G.conf.combo_width,
             store: this.stores.dataElementsByGroup,
-            keepPosition: false,
+            lockPosition: false,
             listeners: {
                 'select': {
                     scope: this,
@@ -523,8 +523,8 @@
                                 else {
                                     this.legend.value = G.conf.map_legendset_type_automatic;
                                     this.prepareMapViewLegend();
-                                    this.classify(false, cb.keepPosition);
-                                    G.util.setKeepPosition(cb);
+                                    this.classify(false, cb.lockPosition);
+                                    G.util.setLockPosition(cb);
                                 }
                             }
                         });
@@ -573,7 +573,7 @@
             selectOnFocus: true,
             width: G.conf.combo_width,
             store: this.stores.periodsByType,
-            keepPosition: false,
+            lockPosition: false,
             listeners: {
                 'select': {
                     scope: this,
@@ -583,8 +583,8 @@
                         }
                         
                         this.updateValues = true;
-                        this.classify(false, cb.keepPosition);                        
-                        G.util.setKeepPosition(cb);
+                        this.classify(false, cb.lockPosition);                        
+                        G.util.setLockPosition(cb);
                         
                         this.window.cmp.reset.enable();
                     }
@@ -1066,7 +1066,7 @@
                                             selectOnFocus: true,
                                             width: G.conf.combo_width,
                                             store: G.stores.infrastructuralPeriodsByType,
-                                            keepPosition: false,
+                                            lockPosition: false,
                                             listeners: {
                                                 'select': function(cb) {
                                                     scope.infrastructuralPeriod = cb.getValue();
@@ -1374,7 +1374,7 @@
             obj.stores.c2.load({scope: this, callback: function() {
                 obj.components.c2.setValue(this.mapView[obj.mapView.c2]);
                 obj.components.c2.currentValue = this.mapView[obj.mapView.c2];
-                obj.components.c2.keepPosition = true;
+                obj.components.c2.lockPosition = true;
                 
                 this.setMapViewLegend();
             }});
@@ -1684,14 +1684,12 @@
         );
     },
 
-    classify: function(exception, position) {
+    classify: function(exception, lockPosition) {
         if (this.formValidation.validateForm.apply(this, [exception])) {
             G.vars.mask.msg = G.i18n.aggregating_map_values;
             G.vars.mask.show();
             
-            if (!position && this.layer.features.length) {
-                G.vars.map.zoomToExtent(this.layer.getDataExtent());
-            }
+            G.util.zoomToVisibleExtent(lockPosition);
             
             if (this.mapView) {
                 if (this.mapView.longitude && this.mapView.latitude && this.mapView.zoom) {
@@ -1699,7 +1697,7 @@
                     G.vars.map.setCenter(new OpenLayers.LonLat(point.x, point.y), this.mapView.zoom);
                 }
                 else {
-                    G.vars.map.zoomToExtent(this.layer.getDataExtent());
+                    G.util.zoomToVisibleExtent();
                 }
                 this.mapView = false;
             }

=== 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-20 01:07:01 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js	2011-08-20 02:34:06 +0000
@@ -397,7 +397,7 @@
             width: G.conf.combo_width,
             store: this.stores.indicatorsByGroup,
             currentValue: null,
-            keepPosition: false,
+            lockPosition: false,
             listeners: {
                 'select': {
                     scope: this,
@@ -435,8 +435,8 @@
                                 else {
                                     this.legend.value = G.conf.map_legendset_type_automatic;
                                     this.prepareMapViewLegend();
-                                    this.classify(false, cb.keepPosition);
-                                    G.util.setKeepPosition(cb);
+                                    this.classify(false, cb.lockPosition);
+                                    G.util.setLockPosition(cb);
                                 }
                             }
                         });
@@ -485,7 +485,7 @@
             selectOnFocus: true,
             width: G.conf.combo_width,
             store: this.stores.dataElementsByGroup,
-            keepPosition: false,
+            lockPosition: false,
             listeners: {
                 'select': {
                     scope: this,
@@ -523,8 +523,8 @@
                                 else {
                                     this.legend.value = G.conf.map_legendset_type_automatic;
                                     this.prepareMapViewLegend();
-                                    this.classify(false, cb.keepPosition);
-                                    G.util.setKeepPosition(cb);
+                                    this.classify(false, cb.lockPosition);
+                                    G.util.setLockPosition(cb);
                                 }
                             }
                         });
@@ -573,7 +573,7 @@
             selectOnFocus: true,
             width: G.conf.combo_width,
             store: this.stores.periodsByType,
-            keepPosition: false,
+            lockPosition: false,
             listeners: {
                 'select': {
                     scope: this,
@@ -583,8 +583,8 @@
                         }
                         
                         this.updateValues = true;
-                        this.classify(false, cb.keepPosition);                        
-                        G.util.setKeepPosition(cb);
+                        this.classify(false, cb.lockPosition);                        
+                        G.util.setLockPosition(cb);
                         
                         this.window.cmp.reset.enable();
                     }
@@ -1066,7 +1066,7 @@
                                             selectOnFocus: true,
                                             width: G.conf.combo_width,
                                             store: G.stores.infrastructuralPeriodsByType,
-                                            keepPosition: false,
+                                            lockPosition: false,
                                             listeners: {
                                                 'select': function(cb) {
                                                     scope.infrastructuralPeriod = cb.getValue();
@@ -1374,7 +1374,7 @@
             obj.stores.c2.load({scope: this, callback: function() {
                 obj.components.c2.setValue(this.mapView[obj.mapView.c2]);
                 obj.components.c2.currentValue = this.mapView[obj.mapView.c2];
-                obj.components.c2.keepPosition = true;
+                obj.components.c2.lockPosition = true;
                 
                 this.setMapViewLegend();
             }});
@@ -1684,14 +1684,12 @@
         );
     },
 
-    classify: function(exception, position) {
+    classify: function(exception, lockPosition) {
         if (this.formValidation.validateForm.apply(this, [exception])) {
             G.vars.mask.msg = G.i18n.aggregating_map_values;
             G.vars.mask.show();
             
-            if (!position && this.layer.features.length) {
-                G.vars.map.zoomToExtent(this.layer.getDataExtent());
-            }
+            G.util.zoomToVisibleExtent(lockPosition);
             
             if (this.mapView) {
                 if (this.mapView.longitude && this.mapView.latitude && this.mapView.zoom) {
@@ -1699,7 +1697,7 @@
                     G.vars.map.setCenter(new OpenLayers.LonLat(point.x, point.y), this.mapView.zoom);
                 }
                 else {
-                    G.vars.map.zoomToExtent(this.layer.getDataExtent());
+                    G.util.zoomToVisibleExtent();
                 }
                 this.mapView = false;
             }

=== 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-20 01:07:01 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2011-08-20 02:34:06 +0000
@@ -500,7 +500,7 @@
                                             selectOnFocus: true,
                                             width: G.conf.combo_width,
                                             store: G.stores.infrastructuralPeriodsByType,
-                                            keepPosition: false,
+                                            lockPosition: false,
                                             listeners: {
                                                 'select': function(cb) {
                                                     scope.infrastructuralPeriod = cb.getValue();
@@ -757,11 +757,9 @@
         );
     },
 
-    classify: function(exception, position) {
-        if (this.formValidation.validateForm.apply(this, [exception])) {            
-            if (!position && this.layer.features.length) {
-                G.vars.map.zoomToExtent(this.layer.getDataExtent());
-            }
+    classify: function(exception, lockPosition) {
+        if (this.formValidation.validateForm.apply(this, [exception])) {
+            G.util.zoomToVisibleExtent(lockPosition);
             
             for (var i = 0; i < this.layer.features.length; i++) {
                 this.layer.features[i].attributes.labelString = this.layer.features[i].attributes.name;