[Mapbender-commits] r8089 - in branches/2.7/http/print: . classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Aug 31 08:15:29 EDT 2011


Author: verenadiewald
Date: 2011-08-31 05:15:28 -0700 (Wed, 31 Aug 2011)
New Revision: 8089

Modified:
   branches/2.7/http/print/classes/mbMeasureDecorator.php
   branches/2.7/http/print/print_functions.php
Log:
http://trac.osgeo.org/mapbender/ticket/855

Modified: branches/2.7/http/print/classes/mbMeasureDecorator.php
===================================================================
--- branches/2.7/http/print/classes/mbMeasureDecorator.php	2011-08-31 09:38:50 UTC (rev 8088)
+++ branches/2.7/http/print/classes/mbMeasureDecorator.php	2011-08-31 12:15:28 UTC (rev 8089)
@@ -41,7 +41,7 @@
 		$map_width = $mapInfo["width"];
 		
 		// get the arrays, be aware of the different y-axis values
-		$theFullArr = makeCoordPairs($x_value_str, $y_value_str);
+		$theFullArr = makeCoordPairsForFpdi($x_value_str, $y_value_str);
 		foreach ($theFullArr as $oneFullArr) {
 			$e = new mb_notice("mbMeasureDecorator: coordinates: ".implode(" ",array_values($oneFullArr)));
 		}
@@ -60,9 +60,9 @@
 		$this->pdf->objPdf->ClippingRect($mapOffset_left, $mapOffset_bottom, $map_width, $map_height, false);
 		if ($isClosed) {
 			$this->pdf->objPdf->Polygon($thePolyArr);
-		}
+                }
 		else {
-			$theStrokePointPairs = makeStrokePointPairs($theFullArr);
+                	$theStrokePointPairs = makeStrokePointPairs($theFullArr);
 			for($i = 0; $i < count($theStrokePointPairs); $i++) {
 				$line = $theStrokePointPairs[$i];
 				$e = new mb_notice("mbMeasureDecorator: line coordinates: ".implode(" ",$line));

Modified: branches/2.7/http/print/print_functions.php
===================================================================
--- branches/2.7/http/print/print_functions.php	2011-08-31 09:38:50 UTC (rev 8088)
+++ branches/2.7/http/print/print_functions.php	2011-08-31 12:15:28 UTC (rev 8089)
@@ -22,7 +22,7 @@
  * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
  */
 function makeCoordPairs($x_values, $y_values) {
-  $arr_x = explode(",", $x_values);
+        $arr_x = explode(",", $x_values);
 	$arr_y = explode(",", $y_values);
 	$x_elems = count($arr_x);
 	$y_elems = count($arr_y);
@@ -31,20 +31,38 @@
 	
 	if ($x_elems == $y_elems) {
 	  for ($i = 0; $i < $x_elems; $i ++) {
-		  $the_return_arr[$i] = array(
-			                        "real_x" => $arr_x[$i],
-															"real_y" => $arr_y[$i],
-															"pdf_x"  => transformForPDF($arr_x[$i], "x"),
-															"pdf_y"  => transformForPDF($arr_y[$i], "y")
-															);
-		}
+            $the_return_arr[$i] = array(
+                "real_x" => $arr_x[$i],
+                "real_y" => $arr_y[$i],
+                "pdf_x"  => transformForPDF($arr_x[$i], "x"),
+                "pdf_y"  => transformForPDF($arr_y[$i], "y"));
+            }
 	}
 	
 	return $the_return_arr;
 } // end of function makeCoordPairs
 
+function makeCoordPairsForFpdi($x_values, $y_values) {
+        $arr_x = explode(",", $x_values);
+	$arr_y = explode(",", $y_values);
+	$x_elems = count($arr_x);
+	$y_elems = count($arr_y);
 
+	$the_return_arr = array();
 
+	if ($x_elems == $y_elems) {
+	  for ($i = 0; $i < $x_elems; $i ++) {
+            $the_return_arr[$i] = array(
+                "real_x" => $arr_x[$i],
+                "real_y" => $arr_y[$i],
+                "pdf_x"  => transformForPDFFpdi($arr_x[$i], "x"),
+                "pdf_y"  => transformForPDFFpdi($arr_y[$i], "y"));
+            }
+	}
+
+	return $the_return_arr;
+} // end of function makeCoordPairsForFpdi
+
 /**
  * Transforms given realworld-coordinate according to its type (X or Y) 
  * into a pdf-coordinate. Needs the variables $mapOffset_left, $mapOffset_bottom,
@@ -75,7 +93,7 @@
 		case 'y':
 		  // calculate pdf y-pos:
 			$real_shown_height = $coord[3] - $coord[1];
-			$ratio_to_display  = $map_height / $real_shown_height;
+			$ratio_to_display  = ($map_height / $real_shown_height);
 			$target_height     = $theRealCoord - $coord[1];
 			$thePDFvalue       = $mapOffset_bottom + ($target_height * $ratio_to_display);
 		  break;
@@ -87,9 +105,50 @@
 	return $thePDFvalue;
 } // end of function transformForPDF
 
+/**
+ * Use for new template print with lib fpdi:
+ * Transforms given realworld-coordinate according to its type (X or Y)
+ * into a pdf-coordinate. Needs the variables $mapOffset_left, $mapOffset_bottom,
+ * $map_height, $map_width, $coord to be defined in a global scope.
+ *
+ * @param float the realworld coordinate
+ * @param string type of coordinate either 'X' or 'Y'
+ *
+ * @see makeCoordPairsForFpdi [needs this function]
+ *
+ * @return float the pdf-coordinate
+ *
+ * @author V. Diewald
+ */
+function transformForPDFFpdi ($theRealCoord, $theType) {
+  global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
 
+	$thePDFvalue = "";
 
+	switch (mb_strtolower($theType)) {
+	  case 'x':
+		  // calculate pdf x-pos:
+			$real_shown_width = $coord[2] - $coord[0];
+			$ratio_to_display = $map_width / $real_shown_width;
+			$target_width     = $theRealCoord - $coord[0];
+			$thePDFvalue      = $mapOffset_left + ($target_width * $ratio_to_display);
+			break;
+		case 'y':
+		  // calculate pdf y-pos:
+			$real_shown_height = $coord[3] - $coord[1];
+			$ratio_to_display  = ($map_height / $real_shown_height);
+			$target_height     = $theRealCoord - $coord[1];
+			$thePDFvalue       = $mapOffset_bottom +($map_height- ($target_height * $ratio_to_display));
+		  break;
+		default:
+		  // a non valid parameter was given
+		  $thePDFvalue = $theRealCoord;
+      break;
+	}
+	return $thePDFvalue;
+} // end of function transformForPDFFpdi
 
+
 /**
  * extracts PDF-relevant information from a full coordinates array 
  * and returns a transformed array



More information about the Mapbender_commits mailing list