[Mapbender-commits] r8110 - in branches/2.7/http: plugins
print/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Sep 7 03:56:31 EDT 2011
Author: verenadiewald
Date: 2011-09-07 00:56:31 -0700 (Wed, 07 Sep 2011)
New Revision: 8110
Added:
branches/2.7/http/print/classes/mbPermanentImgDecorator.php
Modified:
branches/2.7/http/plugins/mb_print.php
branches/2.7/http/print/classes/mbTemplatePdf.php
Log:
http://trac.osgeo.org/mapbender/ticket/825
Modified: branches/2.7/http/plugins/mb_print.php
===================================================================
--- branches/2.7/http/plugins/mb_print.php 2011-09-07 07:51:32 UTC (rev 8109)
+++ branches/2.7/http/plugins/mb_print.php 2011-09-07 07:56:31 UTC (rev 8110)
@@ -469,9 +469,25 @@
}
updateFormField(formData, "measured_x_values", tmp_x);
updateFormField(formData, "measured_y_values", tmp_y);
- }
+ }
+
+ //write the permanent highlight image, if defined
+ if ($("img.mapSymbol").length > 0) {
+ var imgSrc = $("img.mapSymbol").attr("src");
+
+ var TopLeftPos = $("img.mapSymbol").position();
+ var TopLeftRealPos = makeClickPos2RealWorldPos(myTarget, TopLeftPos.left, TopLeftPos.top);
+
+ var BottomRightPos = $("img.mapSymbol").position();
+ BottomRightPos.top = BottomRightPos.top + $("img.mapSymbol").height();
+ BottomRightPos.left = BottomRightPos.left + $("img.mapSymbol").width();
+ var BottomRightRealPos = makeClickPos2RealWorldPos(myTarget, BottomRightPos.left, BottomRightPos.top);
+
+
+ var permanentImg = imgSrc + "___" + TopLeftRealPos[0] + "___" + TopLeftRealPos[1] + "___" + BottomRightRealPos[0] + "___" + BottomRightRealPos[1];
+ updateFormField(formData, "mypermanentImage", permanentImg);
+ }
-
if (f.map_url.value!="") {
//return true;
} else {
Added: branches/2.7/http/print/classes/mbPermanentImgDecorator.php
===================================================================
--- branches/2.7/http/print/classes/mbPermanentImgDecorator.php (rev 0)
+++ branches/2.7/http/print/classes/mbPermanentImgDecorator.php 2011-09-07 07:56:31 UTC (rev 8110)
@@ -0,0 +1,96 @@
+<?php
+class mbPermanentImgDecorator extends mbTemplatePdfDecorator {
+
+ protected $pageElementType = "permanentImage";
+ protected $elementId;
+
+ public function __construct($pdfObj, $elementId, $mapConf, $controls) {
+ parent::__construct($pdfObj, $mapConf, $controls);
+ $this->elementId = $elementId;
+ $this->override();
+ $this->decorate();
+ }
+
+ public function override() {}
+
+ public function decorate() {
+ global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
+ global $yAxisOrientation;
+ $yAxisOrientation = 1;
+
+ if (isset($_REQUEST["mypermanentImage"]) && $_REQUEST["mypermanentImage"] != "") {
+ $permanentImgStr = $_REQUEST["mypermanentImage"];
+ $e = new mb_notice("mbPermanentImgDecorator: mypermanentImage values: ".$permanentImgStr);
+ }
+ else {
+ return "No mypermanentImage values found.";
+ }
+
+ $array_permanentImage = explode("___", $_REQUEST["mypermanentImage"]);
+ $coord = mb_split(",",$this->pdf->getMapExtent());
+ $mapInfo = $this->pdf->getMapInfo();
+ $mapOffset_left = $mapInfo["x_ul"];
+ $mapOffset_bottom = $mapInfo["y_ul"];
+ $map_height = $mapInfo["height"];
+ $map_width = $mapInfo["width"];
+
+ # mypermanentImage (highlight symbol from geometry.js)
+ if(count($array_permanentImage)>0){
+ $permanentImage = $array_permanentImage[0];
+ if($permanentImage=='false'){
+ $permanentImage='';
+ }
+ $permanentImage_upperLeft_x = $array_permanentImage[1] ;
+ $permanentImage_upperLeft_y = $array_permanentImage[2] ;
+ $permanentImage_bottomRight_x = $array_permanentImage[3] ;
+ $permanentImage_bottomRight_y = $array_permanentImage[4] ;
+
+
+
+ $real_width = $coord[2] - $coord[0];
+ $ratio = $map_width / $real_width;
+
+ $real_left = $permanentImage_upperLeft_x - $coord[0];
+ $left = $mapOffset_left + ($real_left * $ratio);
+
+ $real_right = $permanentImage_bottomRight_x - $coord[0];
+ $right = $mapOffset_right + ($real_right * $ratio);
+
+ $width = abs($left - $right);
+ $width = 20;
+
+ // delta map height in coords
+ $real_height = $coord[3] - $coord[1];
+ // ratio betwen map height in pt and map height in coord
+ $ratio = ($map_height / $real_height);
+
+ // top position in coords
+ $real_top = $permanentImage_upperLeft_y - $coord[1];
+ // top position in pt
+ $top = ($map_height - ($real_top * $ratio));
+
+ $real_bottom = $permanentImage_bottomRight_y - $coord[1];
+ // top position in pt
+ $bottom = ($map_height - ($real_bottom * $ratio));
+
+ $height = abs($top - $bottom);
+ $height = 20;
+
+
+
+$n = new mb_notice("mbPermanentImgDecorator: map_height :".$map_height);
+$n = new mb_notice("mbPermanentImgDecorator: real_height :".$real_height);
+$n = new mb_notice("mbPermanentImgDecorator: ratio :".$ratio);
+$n = new mb_notice("mbPermanentImgDecorator: target_height ============".$target_height);
+
+$n = new mb_notice("mbPermanentImgDecorator: left ============".$left);
+$n = new mb_notice("mbPermanentImgDecorator: top ============".$top);
+ $this->pdf->objPdf->Image($permanentImage, $left, $top, $width, $height, 'png');
+
+ }
+ }
+
+
+}
+
+?>
\ No newline at end of file
Modified: branches/2.7/http/print/classes/mbTemplatePdf.php
===================================================================
--- branches/2.7/http/print/classes/mbTemplatePdf.php 2011-09-07 07:51:32 UTC (rev 8109)
+++ branches/2.7/http/print/classes/mbTemplatePdf.php 2011-09-07 07:56:31 UTC (rev 8110)
@@ -66,8 +66,9 @@
$this->objPdf->useTemplate($tplidx);
foreach ($pageConf->elements as $pageElementId => $pageElementConf) {
- switch ($pageElementConf->type) {
- case "map":
+
+ switch ($pageElementConf->type) {
+ case "map":
$err = new mbMapDecorator($this, $pageElementId, $pageElementConf, $controls);
break;
case "overview":
@@ -87,7 +88,10 @@
break;
case "legend":
$err = new mbLegendDecorator($this, $pageElementId, $pageElementConf, $controls);
- break;
+ break;
+ case "permanentImage":
+ $err = new mbPermanentImgDecorator($this, $pageElementId, $pageElementConf, $controls);
+ break;
}
}
More information about the Mapbender_commits
mailing list