[Mapbender-commits] r3434 - in branches/print_dev/http: classes
print/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Jan 13 05:22:53 EST 2009
Author: mschulz
Date: 2009-01-13 05:22:53 -0500 (Tue, 13 Jan 2009)
New Revision: 3434
Modified:
branches/print_dev/http/classes/class_map.php
branches/print_dev/http/print/classes/mbMapDecorator.php
Log:
added Mapbender map bbox adjustment
Modified: branches/print_dev/http/classes/class_map.php
===================================================================
--- branches/print_dev/http/classes/class_map.php 2009-01-13 08:41:38 UTC (rev 3433)
+++ branches/print_dev/http/classes/class_map.php 2009-01-13 10:22:53 UTC (rev 3434)
@@ -45,7 +45,7 @@
public function getWidth () {
return $this->width;
}
-
+
/**
* @param $value Integer
*/
@@ -90,7 +90,38 @@
public function getExtent () {
return $this->extent;
}
-
+
+ /**
+ *
+ * @return Mapbender_bbox extent information
+ */
+ public function getExtentInfo () {
+ return array($this->extent->min->x, $this->extent->min->y, $this->extent->max->x, $this->extent->max->y);
+ }
+
+ /**
+ * converts the extent of the map so that the maximum extent will be displayed
+ *
+ */
+ public function calculateExtent($aMapbenderBbox) {
+ $relation_px_x = $this->getWidth() / $this->getHeight();
+ $relation_px_y = $this->getHeight() / $this->getWidth();
+ $extentx = ($aMapbenderBbox->max->x - $aMapbenderBbox->min->x);
+ $extenty = ($aMapbenderBbox->max->y - $aMapbenderBbox->min->y);
+ $centerx = $aMapbenderBbox->min->x + $extentx/2;
+ $centery = $aMapbenderBbox->min->y + $extenty/2;
+ $relation_bbox_x = $extentx / $extenty;
+ if($relation_bbox_x <= $relation_px_x){
+ $aMapbenderBbox->min->x = $centerx - $relation_px_x * $extenty / 2;
+ $aMapbenderBbox->max->x = $centerx + $relation_px_x * $extenty / 2;
+ }
+ if($relation_bbox_x > $relation_px_x){
+ $aMapbenderBbox->min->y = $centery - $relation_px_y * $extentx / 2;
+ $aMapbenderBbox->max->y = $centery + $relation_px_y * $extentx / 2;
+ }
+ $this->setExtent($aMapbenderBbox);
+ }
+
/**
*
* @return String EPSG code of the map.
Modified: branches/print_dev/http/print/classes/mbMapDecorator.php
===================================================================
--- branches/print_dev/http/print/classes/mbMapDecorator.php 2009-01-13 08:41:38 UTC (rev 3433)
+++ branches/print_dev/http/print/classes/mbMapDecorator.php 2009-01-13 10:22:53 UTC (rev 3434)
@@ -2,6 +2,7 @@
require_once(dirname(__FILE__)."/../../classes/class_stripRequest.php");
require_once(dirname(__FILE__)."/../../classes/class_weldMaps2PNG.php");
+require_once(dirname(__FILE__)."/../../classes/class_map.php");
class mbMapDecorator extends mbTemplatePdfDecorator {
@@ -20,18 +21,30 @@
$height = $this->conf->height;
$res = $this->pdf->k*($this->conf->res_dpi/72);
$myURL = new stripRequest($array_urls[0]);
- $this->mapExtent = $myURL->get('BBOX');
+ $e = new mb_notice("mbMapDecorator: original bbox: ".$myURL->get('BBOX'));
+ $this->mapExtent = $this->adjustBbox(explode(",",$myURL->get('BBOX')), $myURL->get('srs'));
+ $e = new mb_notice("mbMapDecorator: adjusted bbox: ".$this->mapExtent);
for($i=0; $i<count($array_urls); $i++){
$m = new stripRequest($array_urls[$i]);
$m->set('width',(intval($width*$res)));
$m->set('height',(intval($height*$res)));
+ $m->set('bbox', $this->mapExtent);
$array_urls[$i] = $m->url;
}
$i = new weldMaps2PNG(implode("___",$array_urls),$this->filename);
$this->pdf->Image($this->filename, $this->conf->x_ul, $this->conf->y_ul, $width, $height,'png');
+ }
+
+ protected function adjustBbox($aBboxArray, $aSrsString) {
+ $aMbBbox = new Mapbender_bbox($aBboxArray[0],$aBboxArray[1],$aBboxArray[2],$aBboxArray[3],$aSrsString);
+ $aMap = new Map();
+ $aMap->setWidth($this->conf->width);
+ $aMap->setHeight($this->conf->height);
+ $aMap->calculateExtent($aMbBbox);
+ $adjustedMapExt = $aMap->getExtentInfo();
+ return implode(",",$adjustedMapExt);
}
}
-
-?>
+?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list