[Mapbender-commits] r5264 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Jan 4 09:47:26 EST 2010
Author: christoph
Date: 2010-01-04 09:47:24 -0500 (Mon, 04 Jan 2010)
New Revision: 5264
Modified:
trunk/mapbender/http/javascripts/map_obj.js
Log:
http://trac.osgeo.org/mapbender/ticket/557
Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js 2010-01-04 13:31:08 UTC (rev 5263)
+++ trunk/mapbender/http/javascripts/map_obj.js 2010-01-04 14:47:24 UTC (rev 5264)
@@ -637,11 +637,6 @@
this.setMapRequest();
};
- var performUnknownCalculation = function(value){
- return Math.pow(10, (Math.round(Math.log(value) /
- Math.log(10))));
- };
-
this.convertPixelToReal = function(aPoint, referenceExtent){
if (arguments.length === 2) {
var arrayBBox = referenceExtent.toString().split(",");
@@ -659,23 +654,17 @@
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 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);
+ 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.toFixed(-digitsX), posY.toFixed(-digitsY));
+
};
/**
More information about the Mapbender_commits
mailing list