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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Nov 24 05:46:43 EST 2011


Author: armin11
Date: 2011-11-24 02:46:43 -0800 (Thu, 24 Nov 2011)
New Revision: 8213

Modified:
   trunk/mapbender/http/javascripts/mod_coords_div.php
Log:
Show dms values for epsg:4326 and epsg:4258 in module mod_coords_div.php.

Modified: trunk/mapbender/http/javascripts/mod_coords_div.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_coords_div.php	2011-11-22 12:01:31 UTC (rev 8212)
+++ trunk/mapbender/http/javascripts/mod_coords_div.php	2011-11-24 10:46:43 UTC (rev 8213)
@@ -66,6 +66,10 @@
 	}
 	var pos = mod_showCoords_div_mapObj.convertPixelToReal(click);
 	mod_showCoords_div_fix = "Selection: " + pos.x + " / " +  pos.y;
+	if (mod_showCoords_div_mapObj.epsg =='EPSG:4326' ||  mod_showCoords_div_mapObj.epsg=="EPSG:4258") {
+		strDMS = dec2dms(pos.x) + " / " + dec2dms(pos.y);
+		 mod_showCoords_div_fix += " - " + strDMS;
+	}
 	mod_showCoord_write(pos.x,pos.y);
 }
 function mod_showCoords_div_display(e){
@@ -76,9 +80,31 @@
 	var pos = makeClickPos2RealWorldPos(mod_showCoords_div_target, click.x, click.y);
 	mod_showCoord_write(pos[0],pos[1]);
 }
+
+function round(x, n) {
+	if (n < 1 || n > 14) return false;
+	var e = Math.pow(10, n);
+	var k = (Math.round(x * e) / e).toString();
+	if (k.indexOf('.') == -1) k += '.';
+	k += e.toString().substring(1);
+	return k.substring(0, k.indexOf('.') + n+1);
+}
+
+function dec2dms(x) {
+		xD = Math.floor(x); //full deegrees
+		xM = (x-xD) * 60; //decimal minutes
+		xS = (xM-Math.floor(xM)) * 60;//decimal seconds
+		return xD + "°" + Math.floor(xM) + "'" + round(xS,4) + "''";
+}
+
+
 function mod_showCoord_write(x,y){
 	if(document.getElementById(displayTarget)){
 		var str = x + " / " +  y;
+		if (mod_showCoords_div_mapObj.epsg =='EPSG:4326' ||  mod_showCoords_div_mapObj.epsg=="EPSG:4258") {
+			strDMS = dec2dms(x) + " / " + dec2dms(y);
+			str += " - " + strDMS;
+		}
 		if(mod_showCoords_div_fix != ""){
 			str += "<div>" + mod_showCoords_div_fix + "</div>";
 		}



More information about the Mapbender_commits mailing list