public function decorate()
 {
     include dirname(__FILE__) . "/../print_functions.php";
     global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
     global $yAxisOrientation;
     $yAxisOrientation = 1;
     if (isset($_REQUEST["measured_x_values"]) && $_REQUEST["measured_x_values"] != "") {
         $x_value_str = $_REQUEST["measured_x_values"];
         $y_value_str = $_REQUEST["measured_y_values"];
         $e = new mb_notice("mbMeasureDecorator: x values: " . $x_value_str);
         $e = new mb_notice("mbMeasureDecorator: y values: " . $y_value_str);
     } else {
         return "No measurements found.";
     }
     $coord = mb_split(",", $this->pdf->getMapExtent());
     $mapInfo = $this->pdf->getMapInfo();
     foreach ($mapInfo as $k => $v) {
         $e = new mb_notice("mbMeasureDecorator: mapInfo: " . $k . "=" . $v);
     }
     $mapOffset_left = $mapInfo["x_ul"];
     $mapOffset_bottom = $mapInfo["y_ul"];
     $map_height = $mapInfo["height"];
     $map_width = $mapInfo["width"];
     // get the arrays, be aware of the different y-axis values
     $theFullArr = makeCoordPairsForFpdi($x_value_str, $y_value_str);
     foreach ($theFullArr as $oneFullArr) {
         $e = new mb_notice("mbMeasureDecorator: coordinates: " . implode(" ", array_values($oneFullArr)));
     }
     $thePolyArr = makePolyFromCoord($theFullArr);
     $e = new mb_notice("mbMeasureDecorator: coordinates: " . implode(" ", $thePolyArr));
     if (isClosedPolygon($theFullArr)) {
         $isClosed = TRUE;
     } else {
         $isClosed = FALSE;
     }
     $nr_of_points = count($theFullArr);
     $e = new mb_notice("mbMeasureDecorator: closed polygon: " . $isClosed);
     $this->pdf->objPdf->ClippingRect($mapOffset_left, $mapOffset_bottom, $map_width, $map_height, false);
     if ($isClosed) {
         $this->pdf->objPdf->Polygon($thePolyArr);
     } else {
         $theStrokePointPairs = makeStrokePointPairs($theFullArr);
         for ($i = 0; $i < count($theStrokePointPairs); $i++) {
             $line = $theStrokePointPairs[$i];
             $e = new mb_notice("mbMeasureDecorator: line coordinates: " . implode(" ", $line));
             if ($i != count($theStrokePointPairs) - 1) {
                 $this->pdf->objPdf->Line($line[0], $line[1], $line[2], $line[3]);
             }
         }
     }
     $this->pdf->objPdf->UnsetClipping();
 }
/**
 * Adds the measured item to the PDF output.
 * 
 * @param object reference (!) to the current ezPDF-Object
 * @param string commaseperated X-Values of polygon / line
 * @param string commaseperated Y-Values of polygon / line
 * @param array configuration settings.
 *
 * @return void nothing
 *
 * @see makeCoordPairs
 * @see isClosedPolygon
 * @see makeStrokePointPairs
 * @see makePolyFromCoord
 * @see transformForPDF
 * @see makeCoordPairs
 *
 * @author M. Jansen <*****@*****.**>, 2006-05-26
 */
function addMeasuredItem($thePDF, $x_value_str, $y_value_str, $theConfArray = array())
{
    // get global variable:
    global $legendFilenameUserPolygon;
    // create legend image:
    $legend_width = 17;
    $leg_img = imagecreate($legend_width, $legend_width);
    // save previous state:
    $thePDF->saveState();
    // save colors for legend:
    if (!defined("MAP_HAS_USER_POLYGON")) {
        define("MAP_HAS_USER_POLYGON", "test");
    }
    // get the arrays
    $theFullArr = makeCoordPairs($x_value_str, $y_value_str);
    $thePolyArr = makePolyFromCoord($theFullArr);
    if (isClosedPolygon($theFullArr)) {
        $isClosed = TRUE;
    } else {
        $isClosed = FALSE;
    }
    $nr_of_points = count($theFullArr);
    // is fill option set?
    // wenn der erste und letzte punkt nicht �bereinstimmen,
    // so muss in jedem Falle dofill auf 0 gesetzt werden
    if ($theConfArray['do_fill'] != '' && $isClosed) {
        $doFill = 1;
        // which color to use for filling?
        if (is_array($theConfArray['fill_color']) && $theConfArray['fill_color']['r'] != '' && $theConfArray['fill_color']['g'] != '' && $theConfArray['fill_color']['b'] != '') {
            $thePDF->setColor($theConfArray['fill_color']['r'], $theConfArray['fill_color']['g'], $theConfArray['fill_color']['b']);
            $legend_image_fill = $theConfArray['fill_color']['r'] . "," . $theConfArray['fill_color']['g'] . "," . $theConfArray['fill_color']['b'];
            // color to legend file
            $bg_color = imagecolorallocate($leg_img, round($theConfArray['fill_color']['r'] * 255), round($theConfArray['fill_color']['g'] * 255), round($theConfArray['fill_color']['b'] * 255));
        } else {
            $thePDF->setColor(0, 0, 0);
            // color to legend file
            $bg_color = imagecolorallocate($leg_img, 0, 0, 0);
        }
    } else {
        $doFill = 0;
        // color to legend file
        $bg_color = imagecolorallocate($leg_img, -1, -1, -1);
    }
    // Do we need to stroke (outline)?
    if ($theConfArray['do_stroke'] != '') {
        // which color to use for filling?
        if (is_array($theConfArray['stroke_color']) && $theConfArray['stroke_color']['r'] != '' && $theConfArray['stroke_color']['g'] != '' && $theConfArray['stroke_color']['b'] != '') {
            $thePDF->setStrokeColor($theConfArray['stroke_color']['r'], $theConfArray['stroke_color']['g'], $theConfArray['stroke_color']['b']);
            $thePDF->setLineStyle($theConfArray['line_style']['width'], $theConfArray['line_style']['cap'], $theConfArray['line_style']['join'], $theConfArray['line_style']['dash']);
            $theStrokePointPairs = makeStrokePointPairs($theFullArr);
            for ($i = 0; $i < count($theStrokePointPairs); $i++) {
                $line = $theStrokePointPairs[$i];
                if ($i != count($theStrokePointPairs) - 1 || $isClosed) {
                    $thePDF->line($line[0], $line[1], $line[2], $line[3]);
                    $stroke_color_legend_image = imagecolorallocate($leg_img, round($theConfArray['stroke_color']['r'] * 255), round($theConfArray['stroke_color']['g'] * 255), round($theConfArray['stroke_color']['b'] * 255));
                    if (is_array($theConfArray['line_style']['dash']) && $theConfArray['line_style']['dash'][1] != "" && $theConfArray['line_style']['dash'][1] != 0) {
                        imagedashedline($leg_img, 0, 0, $legend_width - 1, 0, $stroke_color_legend_image);
                        imagedashedline($leg_img, $legend_width - 1, 1, $legend_width - 1, $legend_width - 1, $stroke_color_legend_image);
                        imagedashedline($leg_img, 0, 0, 0, $legend_width - 1, $stroke_color_legend_image);
                        imagedashedline($leg_img, 0, $legend_width - 1, $legend_width - 1, $legend_width - 1, $stroke_color_legend_image);
                    } else {
                        imageline($leg_img, 0, 0, $legend_width - 1, 0, $stroke_color_legend_image);
                        imageline($leg_img, $legend_width - 1, 0, $legend_width - 1, $legend_width - 1, $stroke_color_legend_image);
                        imageline($leg_img, $legend_width - 1, $legend_width - 1, 0, $legend_width - 1, $stroke_color_legend_image);
                        imageline($leg_img, 0, $legend_width - 1, 0, 0, $stroke_color_legend_image);
                    }
                }
            }
        }
    }
    $thePDF->polygon($thePolyArr, $nr_of_points, $doFill);
    // eventually create the file:
    imagepng($leg_img, $legendFilenameUserPolygon);
    $thePDF->restoreState();
}