← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18091: Dashboard, support for cirlular areas in facility layer.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 18091 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-21 19:54:16 +0100
message:
  Dashboard, support for cirlular areas in facility layer.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventreport.js
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/map.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-apps/src/main/webapp/dhis-web-mapping/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2015-01-21 14:54:09 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2015-01-21 18:52:56 +0000
@@ -110,28 +110,6 @@
 				return a;
 			};
 
-			util.map.getPointsByFeatures = function(features) {
-				var a = [];
-				for (var i = 0; i < features.length; i++) {
-					if (features[i].geometry.CLASS_NAME === gis.conf.finals.openLayers.point_classname) {
-						a.push(features[i]);
-					}
-				}
-				return a;
-			};
-
-			util.map.getLonLatsByPoints = function(points) {
-				var lonLat,
-					point,
-					a = [];
-				for (var i = 0; i < points.length; i++) {
-					point = points[i];
-					lonLat = new OpenLayers.LonLat(point.geometry.x, point.geometry.y);
-					a.push(lonLat);
-				}
-				return a;
-			};
-
 			util.map.hasVisibleFeatures = function() {
 				var layers = util.map.getVisibleVectorLayers(),
 					layer;
@@ -4049,49 +4027,6 @@
 		return;
     };
 
-	GIS.app.CircleLayer = function(features, radius) {
-		var points = gis.util.map.getPointsByFeatures(features),
-			lonLats = gis.util.map.getLonLatsByPoints(points),
-			controls = [],
-			control,
-			layer = new OpenLayers.Layer.Vector(),
-			deactivateControls,
-			createCircles,
-			params = {};
-
-		radius = radius && Ext.isNumber(parseInt(radius)) ? parseInt(radius) : 5;
-
-		deactivateControls = function() {
-			for (var i = 0; i < controls.length; i++) {
-				controls[i].deactivate();
-			}
-		};
-
-		createCircles = function() {
-			if (lonLats.length) {
-				for (var i = 0; i < lonLats.length; i++) {
-					control = new OpenLayers.Control.Circle({
-						layer: layer
-					});
-					control.lonLat = lonLats[i];
-					controls.push(control);
-				}
-
-				gis.olmap.addControls(controls);
-
-				for (var i = 0; i < controls.length; i++) {
-					control = controls[i];
-					control.activate();
-					control.updateCircle(control.lonLat, radius);
-				}
-			}
-		}();
-
-		layer.deactivateControls = deactivateControls;
-
-		return layer;
-	};
-
 	GIS.app.LayerWidgetEvent = function(layer) {
 
 		// stores

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js	2014-12-02 16:46:26 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js	2015-01-21 18:52:56 +0000
@@ -1683,7 +1683,7 @@
 				layer.circleLayer = null;
 			}
 			if (Ext.isDefined(radius) && radius) {
-				layer.circleLayer = GIS.app.CircleLayer(layer.features, radius);
+				layer.circleLayer = GIS.core.CircleLayer(gis, layer.features, radius);
 				nissa = layer.circleLayer;
 			}
 		};
@@ -2543,6 +2543,49 @@
 		return loader;
 	};
 
+	GIS.core.CircleLayer = function(gis, features, radius) {
+		var points = gis.util.map.getPointsByFeatures(features),
+			lonLats = gis.util.map.getLonLatsByPoints(points),
+			controls = [],
+			control,
+			layer = new OpenLayers.Layer.Vector(),
+			deactivateControls,
+			createCircles,
+			params = {};
+
+		radius = radius && Ext.isNumber(parseInt(radius)) ? parseInt(radius) : 5;
+
+		deactivateControls = function() {
+			for (var i = 0; i < controls.length; i++) {
+				controls[i].deactivate();
+			}
+		};
+
+		createCircles = function() {
+			if (lonLats.length) {
+				for (var i = 0; i < lonLats.length; i++) {
+					control = new OpenLayers.Control.Circle({
+						layer: layer
+					});
+					control.lonLat = lonLats[i];
+					controls.push(control);
+				}
+
+				gis.olmap.addControls(controls);
+
+				for (var i = 0; i < controls.length; i++) {
+					control = controls[i];
+					control.activate();
+					control.updateCircle(control.lonLat, radius);
+				}
+			}
+		}();
+
+		layer.deactivateControls = deactivateControls;
+
+		return layer;
+	};
+
 	GIS.core.getInstance = function(init) {
 		var conf = {},
 			util = {},
@@ -2836,6 +2879,28 @@
 				return features;
 			};
 
+			util.map.getPointsByFeatures = function(features) {
+				var a = [];
+				for (var i = 0; i < features.length; i++) {
+					if (features[i].geometry.CLASS_NAME === gis.conf.finals.openLayers.point_classname) {
+						a.push(features[i]);
+					}
+				}
+				return a;
+			};
+
+			util.map.getLonLatsByPoints = function(points) {
+				var lonLat,
+					point,
+					a = [];
+				for (var i = 0; i < points.length; i++) {
+					point = points[i];
+					lonLat = new OpenLayers.LonLat(point.geometry.x, point.geometry.y);
+					a.push(lonLat);
+				}
+				return a;
+			};
+
 			util.geojson = {};
 
 			util.geojson.decode = function(organisationUnits, levelOrder) {

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventreport.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventreport.js	2015-01-21 18:27:18 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventreport.js	2015-01-21 18:35:30 +0000
@@ -3462,9 +3462,6 @@
                             el.dom.setAttribute('onmouseover', 'this.onColumnHeaderMouseOver(this)');
                             el.dom.setAttribute('onmouseout', 'this.onColumnHeaderMouseOut(this)');
                         }
-                        else {
-                            console.log('No column header element, setColumnHeaderMouseHandlers, ' + init.el);
-                        }
 					}
 				}
 			};

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/map.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/map.js	2015-01-21 18:27:18 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/map.js	2015-01-21 18:52:56 +0000
@@ -2619,7 +2619,7 @@
         return loader;
     };
 
-    GIS.core.LayerLoaderEvent = function (gis, layer) {
+    GIS.core.LayerLoaderEvent = function(gis, layer) {
         var olmap = layer.map,
             compareView,
             loadOrganisationUnits,
@@ -2853,7 +2853,7 @@
         return loader;
     };
 
-    GIS.core.LayerLoaderFacility = function (gis, layer) {
+    GIS.core.LayerLoaderFacility = function(gis, layer) {
         var olmap = layer.map,
             compareView,
             loadOrganisationUnits,
@@ -2863,7 +2863,7 @@
             afterLoad,
             loader;
 
-        compareView = function (view, doExecute) {
+        compareView = function(view, doExecute) {
             var src = layer.core.view,
                 viewIds,
                 viewDim,
@@ -2933,7 +2933,7 @@
             //gis.olmap.mask.hide();
         };
 
-        loadOrganisationUnits = function (view) {
+        loadOrganisationUnits = function(view) {
             var items = view.rows[0].items,
                 isJsonp = gis.plugin && gis.crossDomain,
                 url = function () {
@@ -3003,7 +3003,7 @@
             }
         };
 
-        loadData = function (view, features) {
+        loadData = function(view, features) {
             view = view || layer.core.view;
             features = features || layer.core.featureStore.features;
 
@@ -3017,7 +3017,7 @@
             loadLegend(view);
         };
 
-        loadLegend = function (view) {
+        loadLegend = function(view) {
             var isJsonp = gis.plugin && gis.crossDomain,
                 type = isJsonp ? 'jsonp' : 'json',
                 url = gis.init.contextPath + '/api/organisationUnitGroupSets/' + view.organisationUnitGroupSet.id + '.' + type + '?fields=organisationUnitGroups[id,name,symbol]',
@@ -3071,7 +3071,7 @@
             }
         };
 
-        addCircles = function (view) {
+        addCircles = function(view) {
             var radius = view.areaRadius;
 
             if (layer.circleLayer) {
@@ -3079,12 +3079,12 @@
                 layer.circleLayer = null;
             }
             if (Ext.isDefined(radius) && radius) {
-                layer.circleLayer = GIS.app.CircleLayer(layer.features, radius);
+                layer.circleLayer = GIS.core.CircleLayer(gis, layer.features, radius);
                 nissa = layer.circleLayer;
             }
         };
 
-        afterLoad = function (view) {
+        afterLoad = function(view) {
 
             // Legend
             gis.viewport.eastRegion.doLayout();
@@ -3153,7 +3153,7 @@
         return loader;
     };
 
-    GIS.core.LayerLoaderBoundary = function (gis, layer) {
+    GIS.core.LayerLoaderBoundary = function(gis, layer) {
         var olmap = layer.map,
             compareView,
             loadOrganisationUnits,
@@ -3426,7 +3426,7 @@
         return loader;
     };
 
-    GIS.core.LayerLoaderThematic = function (gis, layer) {
+    GIS.core.LayerLoaderThematic = function(gis, layer) {
         var olmap = layer.map,
             compareView,
             loadOrganisationUnits,
@@ -3966,6 +3966,49 @@
         return loader;
     };
 
+	GIS.core.CircleLayer = function(gis, features, radius) {
+		var points = gis.util.map.getPointsByFeatures(features),
+			lonLats = gis.util.map.getLonLatsByPoints(points),
+			controls = [],
+			control,
+			layer = new OpenLayers.Layer.Vector(),
+			deactivateControls,
+			createCircles,
+			params = {};
+
+		radius = radius && Ext.isNumber(parseInt(radius)) ? parseInt(radius) : 5;
+
+		deactivateControls = function() {
+			for (var i = 0; i < controls.length; i++) {
+				controls[i].deactivate();
+			}
+		};
+
+		createCircles = function() {
+			if (lonLats.length) {
+				for (var i = 0; i < lonLats.length; i++) {
+					control = new OpenLayers.Control.Circle({
+						layer: layer
+					});
+					control.lonLat = lonLats[i];
+					controls.push(control);
+				}
+
+				gis.olmap.addControls(controls);
+
+				for (var i = 0; i < controls.length; i++) {
+					control = controls[i];
+					control.activate();
+					control.updateCircle(control.lonLat, radius);
+				}
+			}
+		}();
+
+		layer.deactivateControls = deactivateControls;
+
+		return layer;
+	};
+
     GIS.core.getInstance = function(init) {
         var conf = {},
             util = {},
@@ -4350,6 +4393,28 @@
                 return features;
             };
 
+			util.map.getPointsByFeatures = function(features) {
+				var a = [];
+				for (var i = 0; i < features.length; i++) {
+					if (features[i].geometry.CLASS_NAME === gis.conf.finals.openLayers.point_classname) {
+						a.push(features[i]);
+					}
+				}
+				return a;
+			};
+
+			util.map.getLonLatsByPoints = function(points) {
+				var lonLat,
+					point,
+					a = [];
+				for (var i = 0; i < points.length; i++) {
+					point = points[i];
+					lonLat = new OpenLayers.LonLat(point.geometry.x, point.geometry.y);
+					a.push(lonLat);
+				}
+				return a;
+			};
+
             util.geojson = {};
 
             util.geojson.decode = function (organisationUnits, levelOrder) {