svn commit: r133 - trunk/mapbender/http/php

arnulf at osgeo.org arnulf at osgeo.org
Sun Apr 23 09:08:46 EDT 2006


Author: arnulf
Date: 2006-04-23 13:08:46+0000
New Revision: 133

Modified:
   trunk/mapbender/http/php/mod_changeEPSG.php   (contents, props changed)
   trunk/mapbender/http/php/mod_changeEPSG_dynamic.php   (contents, props changed)

Log:
cleaned, added SVN headers

Modified: trunk/mapbender/http/php/mod_changeEPSG.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_changeEPSG.php?view=diff&rev=133&p1=trunk/mapbender/http/php/mod_changeEPSG.php&p2=trunk/mapbender/http/php/mod_changeEPSG.php&r1=132&r2=133
==============================================================================
--- trunk/mapbender/http/php/mod_changeEPSG.php	(original)
+++ trunk/mapbender/http/php/mod_changeEPSG.php	2006-04-23 13:08:46+0000
@@ -1,6 +1,6 @@
 <?php
-# $Id: mod_changeEPSG.php,v 1.13 2006/03/09 10:33:11 uli_rothstein Exp $
-# $Header: /cvsroot/mapbender/mapbender/http/php/mod_changeEPSG.php,v 1.13 2006/03/09 10:33:11 uli_rothstein Exp $
+# $Id$
+#
 # Copyright (C) 2002 CCGIS 
 #
 # This program is free software; you can redistribute it and/or modify
@@ -16,6 +16,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
 require("mb_validateSession.php");
 $gui_id = $_SESSION["mb_user_gui"];
 require_once("../../conf/mapbender.conf");
@@ -41,7 +42,7 @@
 <style type="text/css">
 <!--
 
-.epsg{
+epsg{
 	width:100px;
 	border: solid;
 }
@@ -51,149 +52,140 @@
 $sql = "SELECT e_target FROM gui_element WHERE e_id = 'changeEPSG' AND fkey_gui_id = '".$gui_id."'";
 $res = db_query($sql);
 
-# erst noch die History einbauen und dann nach dem Ursprungsextent suchen.....
 echo "<script type='text/javascript'>";
 echo "var myTarget = '".db_result($res,0,"e_target")."';";
 echo "</script>";
 
-
-###transform coordinates
+# transform coordinates
 if(isset($_REQUEST["srs"])){
-  require_once("../../conf/mapbender.conf");
-
-
-  $arraymapObj = split("###", $_REQUEST["srs"]);
-
-  echo "<script type='text/javascript'>";
-  echo "var newExtent = new Array();";
-
-  for($i=0; $i < count($arraymapObj); $i++){
-     $temp = split(",",$arraymapObj[$i]);
-     
-     if(SYS_DBTYPE=='pgsql'){
-		$con = db_connect($DBSERVER,$OWNER,$PW);
-
-	     $sqlMinx = "SELECT X(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as minx";
-	     $resMinx = db_query($sqlMinx);
-	     $minx = db_result($resMinx,0,"minx");
-	
-	     $sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as miny";
-	     $resMiny = db_query($sqlMiny);
-	     $miny = db_result($resMiny,0,"miny");
-	
-	     $sqlMaxx = "SELECT X(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxx";
-	     $resMaxx =db_query($sqlMaxx);
-	     $maxx = db_result($resMaxx,0,"maxx");
-	
-	     $sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxy";
-	     $resMaxy = db_query($sqlMaxy);
-	     $maxy = db_result($resMaxy,0,"maxy");
-
-     }else{
+	require_once("../../conf/mapbender.conf");
+	$arraymapObj = split("###", $_REQUEST["srs"]);
+	echo "<script type='text/javascript'>";
+	echo "var newExtent = new Array();";
+	for($i=0; $i < count($arraymapObj); $i++){
+		$temp = split(",",$arraymapObj[$i]);
+		if(SYS_DBTYPE=='pgsql'){
+			$con = db_connect($DBSERVER,$OWNER,$PW);
+			$sqlMinx = "SELECT X(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as minx";
+			$resMinx = db_query($sqlMinx);
+			$minx = db_result($resMinx,0,"minx");
+			
+			$sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as miny";
+			$resMiny = db_query($sqlMiny);
+			$miny = db_result($resMiny,0,"miny");
+			
+			$sqlMaxx = "SELECT X(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxx";
+			$resMaxx =db_query($sqlMaxx);
+			$maxx = db_result($resMaxx,0,"maxx");
+			
+			$sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxy";
+			$resMaxy = db_query($sqlMaxy);
+			$maxy = db_result($resMaxy,0,"maxy");
+		}else{
 			$con_string = "host=$GEOS_DBSERVER port=$GEOS_PORT dbname=$GEOS_DB user=$GEOS_OWNER password=$GEOS_PW";
 			$con = pg_connect($con_string) or die ("Error while connecting database");
-
-	     $sqlMinx = "SELECT X(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as minx";
-	     $resMinx = pg_query($con,$sqlMinx);
-	     $minx = pg_fetch_result($resMinx,0,"minx");
-	
-	     $sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as miny";
-	     $resMiny = pg_query($con,$sqlMiny);
-	     $miny = pg_fetch_result($resMiny,0,"miny");
-	
-	     $sqlMaxx = "SELECT X(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxx";
-	     $resMaxx = pg_query($con,$sqlMaxx);
-	     $maxx = pg_fetch_result($resMaxx,0,"maxx");
-	
-	     $sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxy";
-	     $resMaxy = pg_query($con,$sqlMaxy);
-	     $maxy = pg_fetch_result($resMaxy,0,"maxy");
-     }
-
-     #frameName, EPSG, minx, miny, maxx, maxy, width, height
-
-     $extenty = $maxy - $miny;
-     $extentx = $maxx - $minx;
-     $relation_px_x = $temp[6] / $temp[7];
-     $relation_px_y = $temp[7] / $temp[6];
-     $relation_bbox_x = $extentx / $extenty;
-
-     if($relation_bbox_x <= $relation_px_x){
-         $centerx = $minx + ($extentx/2);
-         $minx = $centerx - $relation_px_x * $extenty / 2;
-         $maxx = $centerx + $relation_px_x * $extenty / 2;
-     }
-     if($relation_bbox_x > $relation_px_x){
-         $centery = $miny + ($extenty/2);
-         $miny = $centery - $relation_px_y * $extentx / 2;
-         $maxy = $centery + $relation_px_y * $extentx / 2;
-     }
-     echo "newExtent[".$i."] = '".$temp[0].",".$_REQUEST["newSRS"].",".$minx.",".$miny.",".$maxx.",".$maxy."';";
-}
-  echo "</script>";
+			
+			$sqlMinx = "SELECT X(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as minx";
+			$resMinx = pg_query($con,$sqlMinx);
+			$minx = pg_fetch_result($resMinx,0,"minx");
+			
+			$sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as miny";
+			$resMiny = pg_query($con,$sqlMiny);
+			$miny = pg_fetch_result($resMiny,0,"miny");
+			
+			$sqlMaxx = "SELECT X(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxx";
+			$resMaxx = pg_query($con,$sqlMaxx);
+			$maxx = pg_fetch_result($resMaxx,0,"maxx");
+			
+			$sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxy";
+			$resMaxy = pg_query($con,$sqlMaxy);
+			$maxy = pg_fetch_result($resMaxy,0,"maxy");
+		}
+		$extenty = $maxy - $miny;
+		$extentx = $maxx - $minx;
+		$relation_px_x = $temp[6] / $temp[7];
+		$relation_px_y = $temp[7] / $temp[6];
+		$relation_bbox_x = $extentx / $extenty;
+
+		if($relation_bbox_x <= $relation_px_x){
+			$centerx = $minx + ($extentx/2);
+			$minx = $centerx - $relation_px_x * $extenty / 2;
+			$maxx = $centerx + $relation_px_x * $extenty / 2;
+		}
+		if($relation_bbox_x > $relation_px_x){
+			$centery = $miny + ($extenty/2);
+			$miny = $centery - $relation_px_y * $extentx / 2;
+			$maxy = $centery + $relation_px_y * $extentx / 2;
+		}
+		echo "newExtent[".$i."] = '".$temp[0].",".$_REQUEST["newSRS"].",".$minx.",".$miny.",".$maxx.",".$maxy."';";
+	}
+	echo "</script>";
 }
 else{
-   echo "<script type='text/javascript'>var newExtent = false;</script>";
+	echo "<script type='text/javascript'>var newExtent = false;</script>";
 }
 ?>
 <script type='text/javascript'>
 <!--
 if(newExtent == false){
- parent.mb_registerSubFunctions("window.frames['changeEPSG'].mod_changeEPSG_setBox()");
+	parent.mb_registerSubFunctions("window.frames['changeEPSG'].mod_changeEPSG_setBox()");
 }
+
 function mod_changeEPSG_init(){
 //frameName, EPSG, minx, miny, maxx, maxy, width, height
-   var exists = false;
-   if(newExtent){
-      for(var i=0; i<newExtent.length; i++){
-         var temp = newExtent[i].split(",");
-         if(temp[0] == myTarget){
-           for(var ii=0; ii<parent.mb_MapHistoryObj[temp[0]].length; ii++){
-              if(parent.mb_MapHistoryObj[temp[0]][ii].epsg == temp[1]){
-                 exists = ii;
-                 var goback = true;
-              }
-           }
-           var ind = parent.getMapObjIndexByName(temp[0]);
-           if(goback){
-              parent.mb_mapObj[ind].epsg = temp[1];
-              parent.mb_mapObj[ind].extent = parent.mb_MapHistoryObj[temp[0]][exists].extent;
-              parent.setMapRequest(temp[0]);
-           }
-           else{
-               parent.mb_mapObj[ind].epsg = temp[1];
-               parent.mb_mapObj[ind].extent = parseFloat(temp[2]) + "," + parseFloat(temp[3]) + "," + parseFloat(temp[4]) + "," + parseFloat(temp[5]);
-               parent.setMapRequest(temp[0]);
-           }
-         }
-         if(temp[0] != myTarget){
-           var ind = parent.getMapObjIndexByName(temp[0]);
-           parent.mb_mapObj[ind].epsg = temp[1];
-           parent.mb_mapObj[ind].extent = parseFloat(temp[2]) + "," + parseFloat(temp[3]) + "," + parseFloat(temp[4]) + "," + parseFloat(temp[5]);
-           parent.setMapRequest(temp[0]);
-         }
-      }
-   }
+	var exists = false;
+	if(newExtent){
+		for(var i=0; i<newExtent.length; i++){
+			var temp = newExtent[i].split(",");
+			if(temp[0] == myTarget){
+				for(var ii=0; ii<parent.mb_MapHistoryObj[temp[0]].length; ii++){
+					if(parent.mb_MapHistoryObj[temp[0]][ii].epsg == temp[1]){
+						exists = ii;
+						var goback = true;
+					}
+				}
+				var ind = parent.getMapObjIndexByName(temp[0]);
+				if(goback){
+					parent.mb_mapObj[ind].epsg = temp[1];
+					parent.mb_mapObj[ind].extent = parent.mb_MapHistoryObj[temp[0]][exists].extent;
+					parent.setMapRequest(temp[0]);
+				}
+				else{
+					parent.mb_mapObj[ind].epsg = temp[1];
+					parent.mb_mapObj[ind].extent = parseFloat(temp[2]) + "," + parseFloat(temp[3]) + "," + parseFloat(temp[4]) + "," + parseFloat(temp[5]);
+					parent.setMapRequest(temp[0]);
+				}
+			}
+			if(temp[0] != myTarget){
+				var ind = parent.getMapObjIndexByName(temp[0]);
+				parent.mb_mapObj[ind].epsg = temp[1];
+				parent.mb_mapObj[ind].extent = parseFloat(temp[2]) + "," + parseFloat(temp[3]) + "," + parseFloat(temp[4]) + "," + parseFloat(temp[5]);
+				parent.setMapRequest(temp[0]);
+			}
+		}
+	}
 }
+
 function mod_changeEPSG_setBox(){
-   var myEPSG = parent.mb_mapObj[0].epsg;
-   for(var i=0; i<document.forms[0].epsg.length; i++){
-      if(document.forms[0].epsg.options[i].value == myEPSG){
-         document.forms[0].epsg.selectedIndex = i;
-         isEPSG = true;
-      }
-   }
+	var myEPSG = parent.mb_mapObj[0].epsg;
+	for(var i=0; i<document.forms[0].epsg.length; i++){
+		if(document.forms[0].epsg.options[i].value == myEPSG){
+			document.forms[0].epsg.selectedIndex = i;
+			isEPSG = true;
+		}
+	}
 }
+
 function mod_changeEPSG(){
-    str_srs = "";
-    for(var i=0; i<parent.mb_mapObj.length; i++){
-      if(i>0){str_srs += "###";}
-      str_srs += parent.mb_mapObj[i].frameName + "," + parent.mb_mapObj[i].epsg + "," + parent.mb_mapObj[i].extent + ","+parent.mb_mapObj[i].width+","+parent.mb_mapObj[i].height;
-    }
-    document.forms[0].srs.value = str_srs;
-    var ind = document.forms[0].epsg.selectedIndex;
-    document.forms[0].newSRS.value = document.forms[0].epsg.options[ind].value;
-    document.forms[0].submit();
+	str_srs = "";
+	for(var i=0; i<parent.mb_mapObj.length; i++){
+		if(i>0){str_srs += "###";}
+		str_srs += parent.mb_mapObj[i].frameName + "," + parent.mb_mapObj[i].epsg + "," + parent.mb_mapObj[i].extent + ","+parent.mb_mapObj[i].width+","+parent.mb_mapObj[i].height;
+	}
+	document.forms[0].srs.value = str_srs;
+	var ind = document.forms[0].epsg.selectedIndex;
+	document.forms[0].newSRS.value = document.forms[0].epsg.options[ind].value;
+	document.forms[0].submit();
 }
 // -->
 </script>

Modified: trunk/mapbender/http/php/mod_changeEPSG_dynamic.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_changeEPSG_dynamic.php?view=diff&rev=133&p1=trunk/mapbender/http/php/mod_changeEPSG_dynamic.php&p2=trunk/mapbender/http/php/mod_changeEPSG_dynamic.php&r1=132&r2=133
==============================================================================
--- trunk/mapbender/http/php/mod_changeEPSG_dynamic.php	(original)
+++ trunk/mapbender/http/php/mod_changeEPSG_dynamic.php	2006-04-23 13:08:46+0000
@@ -1,6 +1,6 @@
 <?php
-# $Id: mod_changeEPSG_dynamic.php,v 1.8 2006/03/09 12:13:00 uli_rothstein Exp $
-# $Header: /cvsroot/mapbender/mapbender/http/php/mod_changeEPSG_dynamic.php,v 1.8 2006/03/09 12:13:00 uli_rothstein Exp $
+# $Id$
+#
 # Copyright (C) 2002 CCGIS 
 #
 # This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,6 @@
 require_once("../../conf/mapbender.conf");
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
 <html>
 <head>
 <meta name="author-mail" content="info at ccgis.de">
@@ -48,120 +47,111 @@
 db_select_db(DB,$con);
 $sql = "SELECT e_target FROM gui_element WHERE e_id = 'changeEPSG' AND fkey_gui_id = '".$gui_id."'";
 $res = db_query($sql);
-
-/*TW: EPSG_Code dynamic   ********************************************************************************************/
 $cnt_gui_wms = 0;
 $cnt_epsg_wms = 0;
 $cnt_layer_wms = 0;
 
-/*get allocated wms from allocated gui  ********************************************************************************************/								 
+/*get allocated wms from allocated gui  ********************************************************************************************/
 $sql_gui_wms = "SELECT fkey_wms_id FROM gui_wms WHERE fkey_gui_id IN (";
 $sql_gui_wms .= "'".$gui_id."'";
 $sql_gui_wms.= ") ORDER BY fkey_wms_id";
 # echo"$sql_gui_wms";
 $res_gui_wms = db_query($sql_gui_wms);
-                 while(db_fetch_row($res_gui_wms)){
-                    $fkey_gui_id[$cnt_gui_wms] = db_result($res_gui_wms,$cnt_gui_wms,"fkey_gui_id");
-                    $fkey_wms_id_1[$cnt_gui_wms] = db_result($res_gui_wms,$cnt_gui_wms,"fkey_wms_id");
-						        $cnt_gui_wms++;
-	}					 
-/*get allocated wms from allocated gui  ********************************************************************************************/							 
-	
-/*get allocated layer_id from allocated gui  ********************************************************************************************/								 
+while(db_fetch_row($res_gui_wms)){
+	$fkey_gui_id[$cnt_gui_wms] = db_result($res_gui_wms,$cnt_gui_wms,"fkey_gui_id");
+	$fkey_wms_id_1[$cnt_gui_wms] = db_result($res_gui_wms,$cnt_gui_wms,"fkey_wms_id");
+	$cnt_gui_wms++;
+}					 
+/*get allocated wms from allocated gui  ********************************************************************************************/
+/*get allocated layer_id from allocated gui  ********************************************************************************************/
 $sql_layer_wms = "SELECT  layer_id FROM layer WHERE fkey_wms_id IN (";
-
 for($i=0; $i<count($fkey_wms_id_1); $i++){
- if($i>0){ $sql_layer_wms .= ",";}
- $sql_layer_wms .= "'".$fkey_wms_id_1[$i]."'";
+	if($i>0){ $sql_layer_wms .= ",";}
+	$sql_layer_wms .= "'".$fkey_wms_id_1[$i]."'";
 }
 $sql_layer_wms.= ") ORDER BY layer_id";
 
 $res_layer_wms = db_query($sql_layer_wms);
-                 while($row = db_fetch_array($res_layer_wms)){
-                    $layer_id[$cnt_layer_wms] = $row["layer_id"];
-                    $fkey_wms_id[$cnt_layer_wms] = $row["fkey_wms_id"];
-                    $cnt_layer_wms++;
-}					 							 
-/*get allocated wms from allocated gui  ********************************************************************************************/							 
-	
-	
-/*get allocated epsg-code from allocated wms  ********************************************************************************************/								 
+while($row = db_fetch_array($res_layer_wms)){
+	$layer_id[$cnt_layer_wms] = $row["layer_id"];
+	$fkey_wms_id[$cnt_layer_wms] = $row["fkey_wms_id"];
+	$cnt_layer_wms++;
+}
+/*get allocated wms from allocated gui  ********************************************************************************************/
+
+/*get allocated epsg-code from allocated wms  ********************************************************************************************/
+
 #$sql_epsg_layer = "SELECT DISTINCT epsg FROM layer_epsg WHERE fkey_layer_id IN (";
 $sql_epsg_wms = "SELECT DISTINCT wms_srs FROM wms_srs WHERE fkey_wms_id IN (";
 for($i=0; $i<count($fkey_wms_id_1); $i++){
- if($i>0){ $sql_epsg_wms .= ",";}
-  $sql_epsg_wms .= "'".$fkey_wms_id_1[$i]."'";
-       }
+	if($i>0){ $sql_epsg_wms .= ",";}
+	$sql_epsg_wms .= "'".$fkey_wms_id_1[$i]."'";
+}
 $sql_epsg_wms.= ") ORDER BY wms_srs";
 
 $res_epsg_wms = db_query($sql_epsg_wms);
-                 while($row = db_fetch_array($res_epsg_wms)){
-                    $fkey_wms_id_2[$cnt_epsg_wms] = $row["fkey_wms_id"];
-                    $epsg_code[$cnt_epsg_wms] = $row["wms_srs"];
-                    $cnt_epsg_wms++;  //possible error because increment before echo statement
-		    echo"$epsg_code[$cnt_epsg_wms]";
-                 }		
+while($row = db_fetch_array($res_epsg_wms)){
+	$fkey_wms_id_2[$cnt_epsg_wms] = $row["fkey_wms_id"];
+	$epsg_code[$cnt_epsg_wms] = $row["wms_srs"];
+	$cnt_epsg_wms++;  //possible error because increment before echo statement
+	echo"$epsg_code[$cnt_epsg_wms]";
+}		
 
-								 
-# erst noch die History einbauen und dann nach dem Ursprungsextent suchen.....
 echo "<script type='text/javascript'>";
 echo "var myTarget = '".db_result($res,0,"e_target")."';";
 echo "</script>";
-###transform coordinates
+# transform coordinates
 if(isset($_REQUEST["srs"])){
-  require_once("../../conf/mapbender.conf");
-  $con = pg_connect ($con_string) or die ("Error while connecting database DBname");
-
-  $arraymapObj = split("###", $_REQUEST["srs"]);
-
-  echo "<script type='text/javascript'>";
-  echo "var newExtent = new Array();";
-
-  for($i=0; $i < count($arraymapObj); $i++){
-     $temp = split(",",$arraymapObj[$i]);
- 
-     $sqlMinx = "SELECT X(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as minx";
-     $resMinx = @pg_query($con,$sqlMinx);
-     $minx = pg_result($resMinx,0,"minx");
-
-     $sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as miny";
-     $resMiny = @pg_query($con,$sqlMiny);
-     $miny = pg_result($resMiny,0,"miny");
-
-     $sqlMaxx = "SELECT X(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxx";
-     $resMaxx = @pg_query($con,$sqlMaxx);
-     $maxx = pg_result($resMaxx,0,"maxx");
-
-     $sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxy";
-     $resMaxy = @pg_query($con,$sqlMaxy);		 
-     $maxy = pg_result($resMaxy,0,"maxy");
-
-
-     #frameName, EPSG, minx, miny, maxx, maxy, width, height
-
-     $extenty = $maxy - $miny;
-     $extentx = $maxx - $minx;
-     $relation_px_x = $temp[6] / $temp[7];
-     $relation_px_y = $temp[7] / $temp[6];
-     $relation_bbox_x = $extentx / $extenty;
-
-     if($relation_bbox_x <= $relation_px_x){
-         $centerx = $minx + ($extentx/2);
-         $minx = $centerx - $relation_px_x * $extenty / 2;
-         $maxx = $centerx + $relation_px_x * $extenty / 2;
-     }
-     if($relation_bbox_x > $relation_px_x){
-         $centery = $miny + ($extenty/2);
-         $miny = $centery - $relation_px_y * $extentx / 2;
-         $maxy = $centery + $relation_px_y * $extentx / 2;
-     }
-     echo "newExtent[".$i."] = '".$temp[0].",".$_REQUEST["newSRS"].",".$minx.",".$miny.",".$maxx.",".$maxy."';";
-
-}
-  echo "</script>";
+	require_once("../../conf/mapbender.conf");
+	$con = pg_connect ($con_string) or die ("Error while connecting database DBname");
+	
+	$arraymapObj = split("###", $_REQUEST["srs"]);
+	
+	echo "<script type='text/javascript'>";
+	echo "var newExtent = new Array();";
+	
+	for($i=0; $i < count($arraymapObj); $i++){
+		$temp = split(",",$arraymapObj[$i]);
+		
+		$sqlMinx = "SELECT X(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as minx";
+		$resMinx = @pg_query($con,$sqlMinx);
+		$minx = pg_result($resMinx,0,"minx");
+		
+		$sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(".$temp[2]." ".$temp[3].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as miny";
+		$resMiny = @pg_query($con,$sqlMiny);
+		$miny = pg_result($resMiny,0,"miny");
+		
+		$sqlMaxx = "SELECT X(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxx";
+		$resMaxx = @pg_query($con,$sqlMaxx);
+		$maxx = pg_result($resMaxx,0,"maxx");
+		
+		$sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$temp[4]." ".$temp[5].")',".str_replace("EPSG:","",$temp[1])."),".str_replace("EPSG:","",$_REQUEST["newSRS"]).")) as maxy";
+		$resMaxy = @pg_query($con,$sqlMaxy);		 
+		$maxy = pg_result($resMaxy,0,"maxy");
+	
+		$extenty = $maxy - $miny;
+		$extentx = $maxx - $minx;
+		$relation_px_x = $temp[6] / $temp[7];
+		$relation_px_y = $temp[7] / $temp[6];
+		$relation_bbox_x = $extentx / $extenty;
+		
+		if($relation_bbox_x <= $relation_px_x){
+			$centerx = $minx + ($extentx/2);
+			$minx = $centerx - $relation_px_x * $extenty / 2;
+			$maxx = $centerx + $relation_px_x * $extenty / 2;
+		}
+		if($relation_bbox_x > $relation_px_x){
+			$centery = $miny + ($extenty/2);
+			$miny = $centery - $relation_px_y * $extentx / 2;
+			$maxy = $centery + $relation_px_y * $extentx / 2;
+		}
+		echo "newExtent[".$i."] = '".$temp[0].",".$_REQUEST["newSRS"].",".$minx.",".$miny.",".$maxx.",".$maxy."';";
+		
+	}
+	echo "</script>";
 }
 else{
-   echo "<script type='text/javascript'>var newExtent = false;</script>";
+	echo "<script type='text/javascript'>var newExtent = false;</script>";
 }
 
 ?>
@@ -172,78 +162,76 @@
 }
 function mod_changeEPSG_init(){
 //frameName, EPSG, minx, miny, maxx, maxy, width, height
-   var exists = false;
-   if(newExtent){
-      for(var i=0; i<newExtent.length; i++){
-         var temp = newExtent[i].split(",");
-         if(temp[0] == myTarget){
-           for(var ii=0; ii<parent.mb_MapHistoryObj[temp[0]].length; ii++){
-              if(parent.mb_MapHistoryObj[temp[0]][ii].epsg == temp[1]){
-                 exists = ii;
-                 var goback = true;
-              }
-           }
-           var ind = parent.getMapObjIndexByName(temp[0]);
-           if(goback){
-              parent.mb_mapObj[ind].epsg = temp[1];
-              parent.mb_mapObj[ind].extent = parent.mb_MapHistoryObj[temp[0]][exists].extent;
-              parent.setMapRequest(temp[0]);
-           }
-           else{
-               parent.mb_mapObj[ind].epsg = temp[1];
-               parent.mb_mapObj[ind].extent = parseFloat(temp[2]) + "," + parseFloat(temp[3]) + "," + parseFloat(temp[4]) + "," + parseFloat(temp[5]);
-               parent.setMapRequest(temp[0]);
-           }
-         }
-         if(temp[0] != myTarget){
-           var ind = parent.getMapObjIndexByName(temp[0]);
-           parent.mb_mapObj[ind].epsg = temp[1];
-           parent.mb_mapObj[ind].extent = parseFloat(temp[2]) + "," + parseFloat(temp[3]) + "," + parseFloat(temp[4]) + "," + parseFloat(temp[5]);
-           parent.setMapRequest(temp[0]);
-         }
-      }
-   }
+	var exists = false;
+	if(newExtent){
+		for(var i=0; i<newExtent.length; i++){
+			var temp = newExtent[i].split(",");
+			if(temp[0] == myTarget){
+				for(var ii=0; ii<parent.mb_MapHistoryObj[temp[0]].length; ii++){
+					if(parent.mb_MapHistoryObj[temp[0]][ii].epsg == temp[1]){
+						exists = ii;
+						var goback = true;
+					}
+				}
+				var ind = parent.getMapObjIndexByName(temp[0]);
+				if(goback){
+					parent.mb_mapObj[ind].epsg = temp[1];
+					parent.mb_mapObj[ind].extent = parent.mb_MapHistoryObj[temp[0]][exists].extent;
+					parent.setMapRequest(temp[0]);
+				}
+				else{
+					parent.mb_mapObj[ind].epsg = temp[1];
+					parent.mb_mapObj[ind].extent = parseFloat(temp[2]) + "," + parseFloat(temp[3]) + "," + parseFloat(temp[4]) + "," + parseFloat(temp[5]);
+					parent.setMapRequest(temp[0]);
+				}
+			}
+			if(temp[0] != myTarget){
+				var ind = parent.getMapObjIndexByName(temp[0]);
+				parent.mb_mapObj[ind].epsg = temp[1];
+				parent.mb_mapObj[ind].extent = parseFloat(temp[2]) + "," + parseFloat(temp[3]) + "," + parseFloat(temp[4]) + "," + parseFloat(temp[5]);
+				parent.setMapRequest(temp[0]);
+			}
+		}
+	}
 }
 function mod_changeEPSG_setBox(){
-   var myEPSG = parent.mb_mapObj[0].epsg;
-   for(var i=0; i<document.forms[0].epsg.length; i++){
-      if(document.forms[0].epsg.options[i].value == myEPSG){
-         document.forms[0].epsg.selectedIndex = i;
-         isEPSG = true;
-      }
-   }
+	var myEPSG = parent.mb_mapObj[0].epsg;
+	for(var i=0; i<document.forms[0].epsg.length; i++){
+		if(document.forms[0].epsg.options[i].value == myEPSG){
+			document.forms[0].epsg.selectedIndex = i;
+			isEPSG = true;
+		}
+	}
 }
+
 function mod_changeEPSG(){
-    str_srs = "";
-    for(var i=0; i<parent.mb_mapObj.length; i++){
-      if(i>0){str_srs += "###";}
-      str_srs += parent.mb_mapObj[i].frameName + "," + parent.mb_mapObj[i].epsg + "," + parent.mb_mapObj[i].extent + ","+parent.mb_mapObj[i].width+","+parent.mb_mapObj[i].height;
-    }
-    document.forms[0].srs.value = str_srs;
-    var ind = document.forms[0].epsg.selectedIndex;
-    document.forms[0].newSRS.value = document.forms[0].epsg.options[ind].value;
-    document.forms[0].submit();
+	str_srs = "";
+	for(var i=0; i<parent.mb_mapObj.length; i++){
+	if(i>0){str_srs += "###";}
+		str_srs += parent.mb_mapObj[i].frameName + "," + parent.mb_mapObj[i].epsg + "," + parent.mb_mapObj[i].extent + ","+parent.mb_mapObj[i].width+","+parent.mb_mapObj[i].height;
+	}
+	document.forms[0].srs.value = str_srs;
+	var ind = document.forms[0].epsg.selectedIndex;
+	document.forms[0].newSRS.value = document.forms[0].epsg.options[ind].value;
+	document.forms[0].submit();
 }
 // -->
 </script>
 </head>
-
 <body leftmargin="1" topmargin="1" onload="mod_changeEPSG_init()" bgcolor="#0066cc">
- 
+
 <?php
-/*insert EPSG in selectbox************************************************************************************/
+/*insert EPSG into selectbox************************************************************************************/
 echo "<form action='" . $PHP_SELF . "?".SID."' method='post'>";
-#echo "<select  class='epsg' name='epsg' onChange='mod_changeEPSG()'><option value=\"\">undefined</option>";
 echo "<select  class='epsg' name='epsg' onChange='mod_changeEPSG()'>";
-		 for($i=0; $i<$cnt_epsg_wms; $i++){
-        echo "<option value='" . $epsg_code[$i] . "' ";
-           if($epsg && $epsg == $epsg_code[$i]){
-           }
-           echo ">" . $epsg_code[$i]  . "</option>";
-																 }
+for($i=0; $i<$cnt_epsg_wms; $i++){
+	echo "<option value='" . $epsg_code[$i] . "' ";
+	if($epsg && $epsg == $epsg_code[$i]){
+	}
+	echo ">" . $epsg_code[$i]  . "</option>";
+}
 echo "</select>";
 /*insert EPSG in selectbox************************************************************************************/
-#echo"<input type='text'size='30' name='srs' value=''>";
 echo"<input type='hidden' name='srs' value=''>";
 echo"<input type='hidden' name='newSRS' value=''>";
 echo"</form>"; 




More information about the Mapbender_commits mailing list