climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1500908 - /incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers/WorldMapCtrl.js
Date Mon, 08 Jul 2013 19:46:59 GMT
Author: joyce
Date: Mon Jul  8 19:46:58 2013
New Revision: 1500908

URL: http://svn.apache.org/r1500908
Log:
CLIMATE-176 - Fix indentation in WorldMapCtrl

- Invert the if-statement that checks to ensure that the map has been
  initialized in $rootScope. This removes a level of indentation from
  the majority of the function and prevents this indentation error in
  the future.

Modified:
    incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers/WorldMapCtrl.js

Modified: incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers/WorldMapCtrl.js
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers/WorldMapCtrl.js?rev=1500908&r1=1500907&r2=1500908&view=diff
==============================================================================
--- incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers/WorldMapCtrl.js (original)
+++ incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers/WorldMapCtrl.js Mon Jul 
8 19:46:58 2013
@@ -29,56 +29,54 @@ function($rootScope, $scope, selectedDat
  			$rootScope.rectangleGroup.clearLayers();
  		}
 
-		// Don't process if we don't have any datasets added!!
-		if ($scope.datasets.length == 0)
+		// Don't process if we don't have any datasets added or if the map doesn't exist!!
+		if ($scope.datasets.length == 0 || !("map" in $rootScope))
 			return;
  		
- 		if ("map" in $rootScope) {
- 			// Create Group to add all rectangles to map
- 			$rootScope.rectangleGroup = L.layerGroup();
- 			
- 			// Loop through datasets and add rectangles to Group 
-			var i = -1;
- 			angular.forEach($scope.datasets, function(dataset) {
-				// Keep track of dataset count for displaying colors
-				i++;
-
-				// If the user disabled the overlay then get out of here!
-				if (!dataset.shouldDisplay)
-					return;
-
- 				// Get bounds from dataset 
- 				var maplatlon = dataset.latlonVals;
- 				var bounds = [[maplatlon.latMax, maplatlon.lonMin], [maplatlon.latMin, maplatlon.lonMax]];
-
- 				var polygon = L.rectangle(bounds,{
-					stroke: false,
-					fillColor: $rootScope.fillColors[i],
- 				    fillOpacity: 0.3
- 				});
-
- 				// Add layer to Group
- 				$rootScope.rectangleGroup.addLayer(polygon);
- 			});
-
-			// Draw user selected region
-			if ($scope.regionParams.areValid) {
-
-				var bounds = [[$scope.regionParams.latMax, $scope.regionParams.lonMin],
-							  [$scope.regionParams.latMin, $scope.regionParams.lonMax]];
-
-				var polygon = L.rectangle(bounds, {
-					color: '#000000',
-					opacity: 1.0,
-					fill: false,
-				});
+		// Create Group to add all rectangles to map
+		$rootScope.rectangleGroup = L.layerGroup();
+		
+		// Loop through datasets and add rectangles to Group 
+		var i = -1;
+		angular.forEach($scope.datasets, function(dataset) {
+			// Keep track of dataset count for displaying colors
+			i++;
+
+			// If the user disabled the overlay then get out of here!
+			if (!dataset.shouldDisplay)
+				return;
+
+			// Get bounds from dataset 
+			var maplatlon = dataset.latlonVals;
+			var bounds = [[maplatlon.latMax, maplatlon.lonMin], [maplatlon.latMin, maplatlon.lonMax]];
+
+			var polygon = L.rectangle(bounds,{
+				stroke: false,
+				fillColor: $rootScope.fillColors[i],
+				fillOpacity: 0.3
+			});
+
+			// Add layer to Group
+			$rootScope.rectangleGroup.addLayer(polygon);
+		});
+
+		// Draw user selected region
+		if ($scope.regionParams.areValid) {
+
+			var bounds = [[$scope.regionParams.latMax, $scope.regionParams.lonMin],
+						  [$scope.regionParams.latMin, $scope.regionParams.lonMax]];
+
+			var polygon = L.rectangle(bounds, {
+				color: '#000000',
+				opacity: 1.0,
+				fill: false,
+			});
 
-				$rootScope.rectangleGroup.addLayer(polygon);
-			}
+			$rootScope.rectangleGroup.addLayer(polygon);
+		}
 
- 			// Add rectangle Group to map
- 			$rootScope.rectangleGroup.addTo($rootScope.map);
- 		}
+		// Add rectangle Group to map
+		$rootScope.rectangleGroup.addTo($rootScope.map);
 
 		// Calculate the overlap region and set the map to show the new overlap
 		var latMin = -90,
@@ -98,7 +96,6 @@ function($rootScope, $scope, selectedDat
 
 		var overlapBounds = [[latMax, lonMin], [latMin, lonMax]];
 		$rootScope.map.fitBounds(overlapBounds, {padding: [5, 5]});
-
 	};
 
 	$scope.$on('redrawOverlays', function(event, parameters) {



Mime
View raw message