[Mapbender-commits] r5265 - branches/2.6/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Jan 4 09:48:33 EST 2010


Author: christoph
Date: 2010-01-04 09:48:32 -0500 (Mon, 04 Jan 2010)
New Revision: 5265

Modified:
   branches/2.6/http/javascripts/map_obj.js
Log:
http://trac.osgeo.org/mapbender/ticket/557

Modified: branches/2.6/http/javascripts/map_obj.js
===================================================================
--- branches/2.6/http/javascripts/map_obj.js	2010-01-04 14:47:24 UTC (rev 5264)
+++ branches/2.6/http/javascripts/map_obj.js	2010-01-04 14:48:32 UTC (rev 5265)
@@ -532,15 +532,6 @@
 		this.setMapRequest();
 	};
 	
-	var performUnknownCalculation = function (value) {
-		return Math.pow(10,(
-			Math.round(
-				Math.log(value)/
-				Math.log(10)
-			)
-		));
-	};
-	
 	this.convertPixelToReal = function (aPoint) {
 		var arrayBBox = this.extent.split(",");
 		var minX = parseFloat(arrayBBox[0]);
@@ -553,23 +544,16 @@
 		var deltaY = xtenty/this.height;
 		var roundx, roundy;
 
-		if(deltaX > 0){
-			roundx = 1/performUnknownCalculation(deltaX);
-		}
-		else{
-			roundx = performUnknownCalculation(deltaX);
-		}
-		if(deltaY > 0){
-			roundy = 1/performUnknownCalculation(deltaY);
-		}
-		else{
-			roundy =  performUnknownCalculation(deltaY);
-		}	
+		var digitsX = Math.round(Math.log(deltaX)/Math.log(10));
+		var digitsY = Math.round(Math.log(deltaY)/Math.log(10));
+		var roundX = Math.pow(10, -digitsX);
+		var roundY = Math.pow(10, -digitsY);
+		
 		var posX = parseFloat(minX + (aPoint.x / this.width) * xtentx);
 		var posY = parseFloat(maxY - (aPoint.y / this.height) * xtenty);
-		posX = Math.round(posX * roundx) / roundx;
-		posY = Math.round(posY * roundy) / roundy;
-		return new Point(posX, posY);
+		posX = Math.round(posX * roundX) / roundX;
+		posY = Math.round(posY * roundY) / roundY;
+		return new Point(posX.toFixed(-digitsX), posY.toFixed(-digitsY));
 	};
 	
 	/**



More information about the Mapbender_commits mailing list