[Mapbender-commits] r3185 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Nov 6 10:03:17 EST 2008
Author: christoph
Date: 2008-11-06 10:03:17 -0500 (Thu, 06 Nov 2008)
New Revision: 3185
Modified:
trunk/mapbender/http/javascripts/map.js
Log:
return false if no layers are valid (there has been a change in the WMS class)
Modified: trunk/mapbender/http/javascripts/map.js
===================================================================
--- trunk/mapbender/http/javascripts/map.js 2008-11-06 15:00:53 UTC (rev 3184)
+++ trunk/mapbender/http/javascripts/map.js 2008-11-06 15:03:17 UTC (rev 3185)
@@ -688,28 +688,24 @@
}
//scale
function mb_getScale(frameName) {
-
- var myScale = eventBeforeGetScale.trigger({"frameName":frameName});
-/*
- for(var i=0; i<mb_GetScalePreFunctions.length; i++){
- var myScale = eval(mb_GetScalePreFunctions[i]);
+ var ind = getMapObjIndexByName(frameName);
+ var bbox = mb_mapObj[ind].extent.split(",");
+ var scale;
+ var xtenty;
+ if(mb_mapObj[ind].epsg=="EPSG:4326"){
+ var pxLenx = (parseFloat(bbox[2])-parseFloat(bbox[0]))/mb_mapObj[ind].width;
+ var pxLeny = (parseFloat(bbox[3])-parseFloat(bbox[1]))/mb_mapObj[ind].height;
+ 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{
+ xtenty = parseFloat(bbox[3]) - parseFloat(bbox[1]);
+ scale = (xtenty / mb_mapObj[ind].height) * (mb_resolution * 100);
}
-*/
- if(typeof(myScale) == "number"){
- var Y_str = myScale;
- }
- else{
- var ind = getMapObjIndexByName(frameName);
- var arrayBBox = mb_mapObj[ind].extent.split(",");
- var xtenty = parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
- var scaleY = (xtenty / mb_mapObj[ind].height) *(mb_resolution * 100);
- if (scaleY<1){
- var Y_str = scaleY;
- }else{
- var Y_str = Math.round(scaleY);
- }
- }
- return Y_str;
+ return Math.round(scale);
}
function mb_repaintScale(frameName, x, y, scale){
More information about the Mapbender_commits
mailing list