[Mapbender-commits] r1093 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Feb 8 09:43:21 EST 2007


Author: christoph
Date: 2007-02-08 09:43:21 -0500 (Thu, 08 Feb 2007)
New Revision: 1093

Modified:
   trunk/mapbender/http/javascripts/point.js
Log:
improved rounding function

Modified: trunk/mapbender/http/javascripts/point.js
===================================================================
--- trunk/mapbender/http/javascripts/point.js	2007-02-08 14:39:05 UTC (rev 1092)
+++ trunk/mapbender/http/javascripts/point.js	2007-02-08 14:43:21 UTC (rev 1093)
@@ -27,9 +27,7 @@
 		return new Point(this.x*c, this.y*c);
 	}
 	this.round = function(numOfDigits){
-		var tmpX = Math.round(this.x*Math.pow(10, parseInt(numOfDigits)))/Math.pow(10, parseInt(numOfDigits));
-		var tmpY = Math.round(this.y*Math.pow(10, parseInt(numOfDigits)))/Math.pow(10, parseInt(numOfDigits));
-		return new Point(tmpX, tmpY);
+		return new Point(roundToDigits(this.x, numOfDigits), roundToDigits(this.y, numOfDigits));
 	}
 	this.toString = function(){
 		return "(" + this.x + ", " + this.y + ")";
@@ -80,8 +78,11 @@
 	}
 	mb_mapObj[ind].extent = new_min.x +","+ new_min.y +","+ new_max.x  +","+ new_max.y;
 }
+function roundToDigits(aFloat, numberOfDigits) {
+	return Math.round(aFloat*Math.pow(10, parseInt(numberOfDigits)))/Math.pow(10, parseInt(numberOfDigits));
+}
 function cloneObject(a){
-	var z = new Array();
+	var z = [];
 	
 	for (attr in a) {
 		var b = a[attr];



More information about the Mapbender_commits mailing list