svn commit: r945 - trunk/mapbender/http/javascripts/mod_insertLayerPreviewIntoDb.php

christoph at osgeo.org christoph at osgeo.org
Thu Nov 23 07:51:51 EST 2006


Author: christoph
Date: 2006-11-23 12:51:50+0000
New Revision: 945

Modified:
   trunk/mapbender/http/javascripts/mod_insertLayerPreviewIntoDb.php

Log:
improved scaling of bbox

Modified: trunk/mapbender/http/javascripts/mod_insertLayerPreviewIntoDb.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_insertLayerPreviewIntoDb.php?view=diff&rev=945&p1=trunk/mapbender/http/javascripts/mod_insertLayerPreviewIntoDb.php&p2=trunk/mapbender/http/javascripts/mod_insertLayerPreviewIntoDb.php&r1=944&r2=945
==============================================================================
--- trunk/mapbender/http/javascripts/mod_insertLayerPreviewIntoDb.php	(original)
+++ trunk/mapbender/http/javascripts/mod_insertLayerPreviewIntoDb.php	2006-11-23 12:51:50+0000
@@ -27,15 +27,6 @@
 
 
 function escByteA($binData) {
-  /**
-   * \134 = 92 = backslash, \000 = 00 = NULL, \047 = 39 = Single Quote
-   *
-   * str_replace() replaces the searches array in order.
-   * Therefore, we must
-   * process the 'backslash' character first. If we process it last, it'll
-   * replace all the escaped backslashes from the other searches that came
-   * before. tomATminnesota.com
-   */
    $search = array();
    $replace = array();
    array_push($search, chr(92)); 
@@ -72,7 +63,8 @@
 		$map_img = file_get_contents($mapurl);	
 		$legend_img = file_get_contents($legendurl);	
 
-		$rlp_4326_box = array(6.10988942079081,48.987785376052,8.58790010810365,50.9273496139233);
+//		$rlp_4326_box = array(6.10988942079081,48.987785376052,8.58790010810365,50.9273496139233);
+		$rlp_4326_box = array(6.05,48.9,8.6,50.96);
 		
 		$sql = "SELECT * FROM layer_epsg WHERE fkey_layer_id = $1 AND epsg = 'EPSG:4326'";
 		$v = array($layer_id);
@@ -98,33 +90,35 @@
 				$extent_layer_id = $layer_id;
 			}
 		}
-		if ($layer_4326_box[0] < $rlp_4326_box[0] || $layer_4326_box[2] > $rlp_4326_box[2]) {
+
+		if ($layer_4326_box[0] <= $rlp_4326_box[0] || $layer_4326_box[2] >= $rlp_4326_box[2] || $layer_4326_box[1] <= $rlp_4326_box[1] || $layer_4326_box[3] >= $rlp_4326_box[3]) {
 			if ($layer_4326_box[0] < $rlp_4326_box[0]) {
 				$rlp_4326_box[0] = $layer_4326_box[0]; 
 			}
 			if ($layer_4326_box[2] > $rlp_4326_box[2]) {
 				$rlp_4326_box[2] = $layer_4326_box[2]; 
 			}
-			$d_x = $rlp_4326_box[2] - $rlp_4326_box[0]; 
-			$new_minx = $rlp_4326_box[0] - 0.1*($d_x);
-			$new_maxx = $rlp_4326_box[2] + 0.1*($d_x);
-			if ($new_minx < -180) $rlp_4326_box[0] = -180; else $rlp_4326_box[0] = $new_minx;
-			if ($new_maxx > 180) $rlp_4326_box[2] = 180; else $rlp_4326_box[2] = $new_maxx;
-		}
-		if ($layer_4326_box[1] < $rlp_4326_box[1] || $layer_4326_box[3] > $rlp_4326_box[3]) {
 			if ($layer_4326_box[1] < $rlp_4326_box[1]) {
 				$rlp_4326_box[1] = $layer_4326_box[1]; 
 			}
 			if ($layer_4326_box[3] > $rlp_4326_box[3]) {
 				$rlp_4326_box[3] = $layer_4326_box[3]; 
 			}
-			$d_y = $rlp_4326_box[3] - $rlp_4326_box[1]; 
-			$new_miny = $rlp_4326_box[1] - 0.1*($d_y);
-			$new_maxy = $rlp_4326_box[3] + 0.1*($d_y);
+
+			$d_x = $rlp_4326_box[2] - $rlp_4326_box[0]; 
+			$d_y = $rlp_4326_box[3] - $rlp_4326_box[1];
+			
+			$new_minx = $rlp_4326_box[0] - 0.05*($d_x);
+			$new_maxx = $rlp_4326_box[2] + 0.05*($d_x);
+			$new_miny = $rlp_4326_box[1] - 0.05*($d_y);
+			$new_maxy = $rlp_4326_box[3] + 0.05*($d_y);
+
+			if ($new_minx < -180) $rlp_4326_box[0] = -180; else $rlp_4326_box[0] = $new_minx;
+			if ($new_maxx > 180) $rlp_4326_box[2] = 180; else $rlp_4326_box[2] = $new_maxx;
 			if ($new_miny < -90) $rlp_4326_box[1] = -90; else $rlp_4326_box[1] = $new_miny;
 			if ($new_maxy > 90) $rlp_4326_box[3] = 90; else $rlp_4326_box[3] = $new_maxy;
 		}
-		
+//		echo "<script>prompt('link', 'http://212.79.172.107/cgi-bin/mapserv?map=/data/umn/service_layer.map&VERSION=1.1.1&REQUEST=GetMap&SERVICE=WMS&LAYERS=rlp,ows_layer&STYLES=&SRS=EPSG:4326&BBOX=".$rlp_4326_box[0].",".$rlp_4326_box[1].",".$rlp_4326_box[2].",".$rlp_4326_box[3]."&WIDTH=600&HEIGHT=600&FORMAT=image/png&BGCOLOR=0xffffff&TRANSPARENT=TRUE&EXCEPTIONS=application/vnd.ogc.se_inimage&layer_id=".$extent_layer_id."');</script>";
 		$extent_img = file_get_contents("http://212.79.172.107/cgi-bin/mapserv?map=/data/umn/service_layer.map&VERSION=1.1.1&REQUEST=GetMap&SERVICE=WMS&LAYERS=rlp,ows_layer&STYLES=&SRS=EPSG:4326&BBOX=".$rlp_4326_box[0].",".$rlp_4326_box[1].",".$rlp_4326_box[2].",".$rlp_4326_box[3]."&WIDTH=120&HEIGHT=120&FORMAT=image/png&BGCOLOR=0xffffff&TRANSPARENT=TRUE&EXCEPTIONS=application/vnd.ogc.se_inimage&layer_id=".$extent_layer_id);
 
 		$sql = "SELECT * FROM layer_preview WHERE fkey_layer_id = $1";




More information about the Mapbender_commits mailing list