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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon May 17 14:10:06 EDT 2010


Author: abhishek
Date: 2010-05-17 14:10:03 -0400 (Mon, 17 May 2010)
New Revision: 6207

Modified:
   trunk/mapbender/http/javascripts/map_obj.js
Log:


Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js	2010-05-17 11:52:17 UTC (rev 6206)
+++ trunk/mapbender/http/javascripts/map_obj.js	2010-05-17 18:10:03 UTC (rev 6207)
@@ -907,24 +907,26 @@
      * @return scale
      * @type integer
      */
-    this.getScale = function(){
+        this.getScale = function(){
         var scale;
         var bbox = this.extent.toString().split(",");
-        var xtenty;
         if (this.epsg == "EPSG:4326") {
-            var pxLenx = (parseFloat(bbox[2]) - parseFloat(bbox[0])) / this.getWidth();
-            var pxLeny = (parseFloat(bbox[3]) - parseFloat(bbox[1])) / this.getHeight();
-            var lat_from = ((parseFloat(bbox[3]) - parseFloat(bbox[1]) / 2) * Math.PI) / 180;
-            var lat_to = ((parseFloat(bbox[3]) - parseFloat(bbox[1]) / 2 + pxLeny) * Math.PI) / 180;
-            var lon_from = ((parseFloat(bbox[2]) - parseFloat(bbox[0]) / 2) * Math.PI) / 180;
-            var lon_to = ((parseFloat(bbox[2]) - parseFloat(bbox[0]) / 2 + pxLeny) * Math.PI) / 180;
-            var dist = 6371229 * Math.acos(Math.sin(lat_from) * Math.sin(lat_to) + Math.cos(lat_from) * Math.cos(lat_to) * Math.cos(lon_from - lon_to));
-            scale = (dist / Math.SQRT2) * (mb_resolution * 100);
-        }
-        else {
+           // xl_length and yl_length refers to linear widths on horizontal and vertical axes
+           var xl_length=(parseFloat(bbox[3]) - parseFloat(bbox[1]));
+           var yl_length=(parseFloat(bbox[2]) - parseFloat(bbox[0]));
+        
+           // xa_length and ya_length refers to angular width on horizontal and vertical axes
+           var xa_length=(xl_length*360)/(2*Math.PI*6378137);
+           var ya_length=(xl_length*360)/(2*Math.PI*6378137);
+        
+           scale=((xl_length/this.getHeight())/mb_resolution);    
+           }
+         
+           else {
             xtenty = parseFloat(bbox[3]) - parseFloat(bbox[1]);
             scale = (xtenty / this.getHeight()) * (mb_resolution * 100);
-        }
+        }       
+            
         return parseInt(Math.round(scale), 10);
     };
     



More information about the Mapbender_commits mailing list