[Mapbender-commits] r4572 - in trunk/mapbender/http: javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Aug 28 10:23:45 EDT 2009


Author: christoph
Date: 2009-08-28 10:23:45 -0400 (Fri, 28 Aug 2009)
New Revision: 4572

Modified:
   trunk/mapbender/http/javascripts/mod_changeEPSG.js
   trunk/mapbender/http/php/mod_changeEPSG_server.php
Log:


Modified: trunk/mapbender/http/javascripts/mod_changeEPSG.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_changeEPSG.js	2009-08-28 14:23:02 UTC (rev 4571)
+++ trunk/mapbender/http/javascripts/mod_changeEPSG.js	2009-08-28 14:23:45 UTC (rev 4572)
@@ -54,6 +54,11 @@
 }
 
 $(this).change(function () {
+	var srsValue = $("#"+options.id).get(0).value;
+	if (srsValue === "") {
+		return;
+	}
+	
 	var srsArray = [];
 	for (var i = 0; i < mb_mapObj.length; i++) {
 		var currentSrs = {
@@ -65,10 +70,19 @@
 		};
 		srsArray.push(currentSrs);
 	}
-
-	var srsValue = $("#"+options.id).get(0).value;
-	if (srsValue === "") {
-		return;
+	for (var i = 0; i < wms.length; i++) {
+		var ext = wms[i].getBoundingBoxBySrs(mb_mapObj[0].epsg);
+		if (ext === null) {
+			continue;
+		}
+		var currentSrs = {
+			"wms" : wms[i].wms_id,
+			"epsg" : mb_mapObj[0].epsg,
+			"extent" : ext.toString(),
+			"width" : mb_mapObj[0].width,
+			"height" : mb_mapObj[0].height
+		};
+		srsArray.push(currentSrs);
 	}
 
 	var req = new Mapbender.Ajax.Request({
@@ -80,7 +94,6 @@
 		},
 		callback: function (obj, success, message) {
 			if (!success) {
-				alert(message);
 				new Mapbender.Exception(message);
 				return;
 			}
@@ -88,6 +101,24 @@
 			var newExtent = obj;
 			
 			for (var i = 0; i < newExtent.length; i++) {
+				if (newExtent[i].wms) {
+					for (var j = 0; j < wms.length; j++) {
+						if (parseInt(wms[j].wms_id, 10) === parseInt(newExtent[i].wms, 10)) {
+							wms[j].setBoundingBoxBySrs(
+								newExtent[i].newSrs,
+								new Extent(
+									parseFloat(newExtent[i].minx),
+									parseFloat(newExtent[i].miny),
+									parseFloat(newExtent[i].maxx),
+									parseFloat(newExtent[i].maxy)
+								)
+							);
+							break;
+						}
+					}
+					continue;
+				}
+
 				//
 				// use the previous extent of the overview
 				//
@@ -106,7 +137,8 @@
 					if (goback) {
 						map.setSrs({
 							srs: newExtent[i].newSrs, 
-							extent: map.mb_MapHistoryObj[exists].extent
+							extent: map.mb_MapHistoryObj[exists].extent,
+							displayWarning: false
 						});
 					}
 					else{
@@ -117,7 +149,8 @@
 								parseFloat(newExtent[i].miny), 
 								parseFloat(newExtent[i].maxx),
 								parseFloat(newExtent[i].maxy)
-							)
+							),
+							displayWarning: false
 						});
 					}
 				}
@@ -139,4 +172,4 @@
 		} 
 	});
 	req.send();
-});
\ No newline at end of file
+});

Modified: trunk/mapbender/http/php/mod_changeEPSG_server.php
===================================================================
--- trunk/mapbender/http/php/mod_changeEPSG_server.php	2009-08-28 14:23:02 UTC (rev 4571)
+++ trunk/mapbender/http/php/mod_changeEPSG_server.php	2009-08-28 14:23:45 UTC (rev 4572)
@@ -52,38 +52,38 @@
 					$con = db_connect($DBSERVER,$OWNER,$PW);
 					$sqlMinx = "SELECT X(transform(GeometryFromText('POINT(".$extArray[0]." ".$extArray[1].")',".$oldEPSG."),".$newEPSG.")) as minx";
 					$resMinx = db_query($sqlMinx);
-					$minx = db_result($resMinx,0,"minx");
+					$minx = floatval(db_result($resMinx,0,"minx"));
 					
 					$sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(".$extArray[0]." ".$extArray[1].")',".$oldEPSG."),".$newEPSG.")) as miny";
 					$resMiny = db_query($sqlMiny);
-					$miny = db_result($resMiny,0,"miny");
+					$miny = floatval(db_result($resMiny,0,"miny"));
 					
 					$sqlMaxx = "SELECT X(transform(GeometryFromText('POINT(".$extArray[2]." ".$extArray[3].")',".$oldEPSG."),".$newEPSG.")) as maxx";
 					$resMaxx = db_query($sqlMaxx);
-					$maxx = db_result($resMaxx,0,"maxx");
+					$maxx = floatval(db_result($resMaxx,0,"maxx"));
 					
 					$sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$extArray[2]." ".$extArray[3].")',".$oldEPSG."),".$newEPSG.")) as maxy";
 					$resMaxy = db_query($sqlMaxy);
-					$maxy = db_result($resMaxy,0,"maxy");
+					$maxy = floatval(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(".$extArray[0]." ".$extArray[1].")',".$oldEPSG."),".$newEPSG.")) as minx";
 					$resMinx = pg_query($con,$sqlMinx);
-					$minx = pg_fetch_result($resMinx,0,"minx");
+					$minx = floatval(pg_fetch_result($resMinx,0,"minx"));
 					
 					$sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(".$extArray[0]." ".$extArray[1].")',".$oldEPSG."),".$newEPSG.")) as miny";
 					$resMiny = pg_query($con,$sqlMiny);
-					$miny = pg_fetch_result($resMiny,0,"miny");
+					$miny = floatval(pg_fetch_result($resMiny,0,"miny"));
 					
 					$sqlMaxx = "SELECT X(transform(GeometryFromText('POINT(".$extArray[2]." ".$extArray[3].")',".$oldEPSG."),".$newEPSG.")) as maxx";
 					$resMaxx = pg_query($con,$sqlMaxx);
-					$maxx = pg_fetch_result($resMaxx,0,"maxx");
+					$maxx = floatval(pg_fetch_result($resMaxx,0,"maxx"));
 					
 					$sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$extArray[2]." ".$extArray[3].")',".$oldEPSG."),".$newEPSG.")) as maxy";
 					$resMaxy = pg_query($con,$sqlMaxy);
-					$maxy = pg_fetch_result($resMaxy,0,"maxy");
+					$maxy = floatval(pg_fetch_result($resMaxy,0,"maxy"));
 				}
 				$extenty = $maxy - $miny;
 				$extentx = $maxx - $minx;
@@ -101,14 +101,27 @@
 					$miny = $centery - $relation_px_y * $extentx / 2;
 					$maxy = $centery + $relation_px_y * $extentx / 2;
 				}
-				$epsgObj[$i] = array(
-					"frameName" => $currentEpsg->frameName,
-					"newSrs" => $newSrs,
-					"minx" => $minx,
-					"miny" => $miny,
-					"maxx" => $maxx,
-					"maxy" => $maxy
-				);
+
+				if ($currentEpsg->frameName) {
+					$epsgObj[$i] = array(
+						"frameName" => $currentEpsg->frameName,
+						"newSrs" => $newSrs,
+						"minx" => $minx,
+						"miny" => $miny,
+						"maxx" => $maxx,
+						"maxy" => $maxy
+					);
+				}
+				else {
+					$epsgObj[$i] = array(
+						"wms" => $currentEpsg->wms,
+						"newSrs" => $newSrs,
+						"minx" => $minx,
+						"miny" => $miny,
+						"maxx" => $maxx,
+						"maxy" => $maxy
+					);
+				}
 			}
 			else {
 				$ajaxResponse->setSuccess(false);
@@ -126,4 +139,4 @@
 }
 
 $ajaxResponse->send();
-?>
\ No newline at end of file
+?>



More information about the Mapbender_commits mailing list