[Mapbender-commits] r3844 - in branches/print_dev/http: classes print print/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Mar 30 09:52:15 EDT 2009


Author: mschulz
Date: 2009-03-30 09:52:15 -0400 (Mon, 30 Mar 2009)
New Revision: 3844

Modified:
   branches/print_dev/http/classes/class_map.php
   branches/print_dev/http/print/classes/mbMapDecorator.php
   branches/print_dev/http/print/classes/mbOverviewDecorator.php
   branches/print_dev/http/print/classes/mbParagraphDecorator.php
   branches/print_dev/http/print/classes/mbTemplatePdf.php
   branches/print_dev/http/print/classes/mbTextDecorator.php
   branches/print_dev/http/print/testConfigTemplate.json
Log:
fix bugs in extent and scale calculations

Modified: branches/print_dev/http/classes/class_map.php
===================================================================
--- branches/print_dev/http/classes/class_map.php	2009-03-30 07:24:14 UTC (rev 3843)
+++ branches/print_dev/http/classes/class_map.php	2009-03-30 13:52:15 UTC (rev 3844)
@@ -84,14 +84,23 @@
 		return $this->frameName;	
 	}
 	
+	/**
+	 * 
+	 * @return
+	 */
 	public function addZoomFullExtent ($aMapbenderBbox) {
 		$e = new mb_exception("adding new box: " . $aMapbenderBbox);
 		array_push($this->zoomFullExtentArray, $aMapbenderBbox);
 	}
 	
+	/**
+	 * 
+	 * @return array of Mapbender bounding boxes
+	 */
 	public function getZoomFullExtentArray () {
 		return $this->zoomFullExtentArray;
 	}
+	
 	/**
 	 * @param $value String
 	 */
@@ -158,11 +167,11 @@
 			$scale = ($dist / sqrt(2)) * ($mapResolutionDpi * 100);
 		}
 		else {
-			$xtenty = $bbox[3]) - $bbox[1]);
+			$xtenty = $bbox[3] - $bbox[1];
 			$scale = ($xtenty / $this->getHeight()) * ($mapResolutionDpi * 100);
 		}
 		return round($scale);
-	};	
+	}	
 	
 	
 	/**

Modified: branches/print_dev/http/print/classes/mbMapDecorator.php
===================================================================
--- branches/print_dev/http/print/classes/mbMapDecorator.php	2009-03-30 07:24:14 UTC (rev 3843)
+++ branches/print_dev/http/print/classes/mbMapDecorator.php	2009-03-30 13:52:15 UTC (rev 3844)
@@ -32,6 +32,7 @@
 		}
 		
 		foreach ($this->overrideMembersFromRequest as $overrideMemberFromRequest) {
+			/* take the value of the config in every case */
 			$this->{$overrideMemberFromRequest} = $this->conf->{$overrideMemberFromRequest};
 			foreach ($idsFromRequest as $requestKey => $memberId) {
 				$e = new mb_notice("mbMapDecorator: before override: set ".$memberId." to ".$requestKey);
@@ -39,6 +40,7 @@
 					$this->{$overrideMemberFromRequest} = $_REQUEST[$requestKey];
 					$e = new mb_notice("mbMapDecorator: override from Request: ".$overrideMemberFromRequest." to ".$this->{$overrideMemberFromRequest});
 				}
+				/* this else branch is not necessary anymore */
 				else {
 					$this->{$overrideMemberFromRequest} = $this->conf->{$memberId};
 					$e = new mb_notice("mbMapDecorator: override from conf: ".$overrideMemberFromRequest." to ".$this->conf->{$memberId});
@@ -55,7 +57,7 @@
 		$res = $this->pdf->objPdf->k * ($this->res_dpi/72);
 		$myURL = new stripRequest($array_urls[0]);
 		$e = new mb_notice("mbMapDecorator: original bbox: ".$myURL->get('BBOX'));
-		$this->pdf->setMapInfo($this->conf->x_ul, $this->conf->y_ul, $width, $height, $this->pdf->adjustBbox($this->conf, explode(",",$myURL->get('BBOX')), $myURL->get('srs')));
+		$this->pdf->setMapInfo($this->conf->x_ul, $this->conf->y_ul, round($width*$res), round($height*$res), $this->pdf->adjustBbox(round($width*$res), round($height*$res), explode(",",$myURL->get('BBOX')), $myURL->get('srs'), $this->res_dpi));
 		$e = new mb_notice("mbMapDecorator: adjusted bbox: ".$this->pdf->getMapExtent());
 		for($i=0; $i<count($array_urls); $i++){
 			$m = new stripRequest($array_urls[$i]);

Modified: branches/print_dev/http/print/classes/mbOverviewDecorator.php
===================================================================
--- branches/print_dev/http/print/classes/mbOverviewDecorator.php	2009-03-30 07:24:14 UTC (rev 3843)
+++ branches/print_dev/http/print/classes/mbOverviewDecorator.php	2009-03-30 13:52:15 UTC (rev 3844)
@@ -27,7 +27,7 @@
 		$res = $this->pdf->objPdf->k*($this->conf->res_dpi/72);		
 		$o_url->set('width',intval($width*$res));
 		$o_url->set('height',intval($height*$res));
-		$o_url->set('bbox', $this->pdf->adjustBbox($this->conf, explode(",",$o_url->get('BBOX')), $o_url->get('srs')));
+		$o_url->set('bbox', $this->pdf->adjustBbox(intval($width*$res), intval($height*$res), explode(",",$o_url->get('BBOX')), $o_url->get('srs'), $this->conf->res_dpi));
 		$overview_url = $o_url->url;	
 
 		$urls = $_REQUEST["map_url"];

Modified: branches/print_dev/http/print/classes/mbParagraphDecorator.php
===================================================================
--- branches/print_dev/http/print/classes/mbParagraphDecorator.php	2009-03-30 07:24:14 UTC (rev 3843)
+++ branches/print_dev/http/print/classes/mbParagraphDecorator.php	2009-03-30 13:52:15 UTC (rev 3844)
@@ -41,6 +41,7 @@
 	}
 	
 	public function decorate() {
+		/* some of these values should or could be set in the config */
 		$this->pdf->objPdf->setTextColor(0, 0, 0);
 		$this->pdf->objPdf->setFillColor(255, 255, 255);
 		$this->pdf->objPdf->setDrawColor(0, 0, 0);

Modified: branches/print_dev/http/print/classes/mbTemplatePdf.php
===================================================================
--- branches/print_dev/http/print/classes/mbTemplatePdf.php	2009-03-30 07:24:14 UTC (rev 3843)
+++ branches/print_dev/http/print/classes/mbTemplatePdf.php	2009-03-30 13:52:15 UTC (rev 3844)
@@ -42,13 +42,14 @@
 		return $this->mapinfo["extent"];
 	}	
 
-	public function adjustBbox($elementConf, $aBboxArray, $aSrsString) {
+	public function adjustBbox($mapWidthPx, $mapHeightPx, $aBboxArray, $aSrsString, $mapResolution) {
 		$aMbBbox = new Mapbender_bbox($aBboxArray[0],$aBboxArray[1],$aBboxArray[2],$aBboxArray[3],$aSrsString);
 		$aMap = new Map();
-		$aMap->setWidth($elementConf->width);
-		$aMap->setHeight($elementConf->height);
+		$aMap->setWidth($mapWidthPx);
+		$aMap->setHeight($mapHeightPx);
 		$aMap->calculateExtent($aMbBbox);
-		$this->mapinfo["scale"] = $aMap->getScale($elementConf->res_dpi);
+		$this->mapinfo["scale"] = $aMap->getScale($mapResolution);
+		$e = new mb_notice("mbTemplatePdf: setting mapScale to ".$this->mapinfo["scale"]);
 		$adjustedMapExt = $aMap->getExtentInfo();
 		return implode(",",$adjustedMapExt);
 	}	

Modified: branches/print_dev/http/print/classes/mbTextDecorator.php
===================================================================
--- branches/print_dev/http/print/classes/mbTextDecorator.php	2009-03-30 07:24:14 UTC (rev 3843)
+++ branches/print_dev/http/print/classes/mbTextDecorator.php	2009-03-30 13:52:15 UTC (rev 3844)
@@ -32,7 +32,8 @@
 					$this->{$overrideMemberFromRequest} = date("d.m.y");
 					break;
 				case "scale": 
-					$this->{$overrideMemberFromRequest} = "1 : ".$_REQUEST["map_scale"];
+					$mapInfoScale = $this->pdf->getMapInfo();
+					$this->{$overrideMemberFromRequest} = "1 : ".$mapInfoScale["scale"];
 					break;
 				default:
 					$this->{$overrideMemberFromRequest} = $this->conf->{$overrideMemberFromRequest};

Modified: branches/print_dev/http/print/testConfigTemplate.json
===================================================================
--- branches/print_dev/http/print/testConfigTemplate.json	2009-03-30 07:24:14 UTC (rev 3843)
+++ branches/print_dev/http/print/testConfigTemplate.json	2009-03-30 13:52:15 UTC (rev 3844)
@@ -113,6 +113,14 @@
 	    		"fill" : 1,
 	    		"border_width" : 0.5
 	   			},
+	   		"scale" : {
+    			"type" : "text", 
+    			"x_ul" : 49.2,
+	    		"y_ul" : 10.4,
+	    		"font_family" : "Arial",
+	    		"font_size" : 14,
+				"value" : "scale"
+	   		},
 	   		"nordpfeil" : {
     			"type" : "image", 
     			"x_ul" : 280.1,



More information about the Mapbender_commits mailing list