function weldMaps2PNG_rotate($urls, $filename, $angle, $encode = true) { if (!$urls || $urls == "") { $e = new mb_exception("weldMaps2PNG_rotate: no maprequests delivered"); } $url = explode("___", $urls); $obj1 = new stripRequest($url[0]); $width = $obj1->get("width"); $height = $obj1->get("height"); //calculate rotated dimensions $neededWidth = round(abs(sin(deg2rad($angle)) * $height) + abs(cos(deg2rad($angle)) * $width)); $neededHeight = round(abs(sin(deg2rad($angle)) * $width) + abs(cos(deg2rad($angle)) * $height)); //modify requests for ($i = 0; $i < count($url); $i++) { $obj = new stripRequest($url[$i]); $obj->set("width", $neededWidth); $obj->set("height", $neededHeight); $map_extent = $obj->get("BBOX"); $coord = split(",", $map_extent); $coord = $this->enlargeExtent($coord, $width, $height, $neededWidth, $neededHeight); $obj->set("BBOX", implode(",", $coord)); $url[$i] = $obj->url; } //get image $urls = implode("___", $url); $this->weldMaps2PNG($urls, $filename, $encode); //rotate image $imagick = new Imagick(); $imagick->readImage($filename); $imagick->rotateImage(new ImagickPixel(), $angle); //get the new dimensions $imgWidth = $imagick->getImageWidth(); $imgHeight = $imagick->getImageHeight(); //crop empty areas $imagick->cropImage($width, $height, ($imgWidth - $width) / 2, ($imgHeight - $height) / 2); //write modified image $imagick->writeImage(); $image = imagecreatefrompng($filename); imagepng($image, $filename); }
public function decorate() { $overview_url = $_REQUEST["overview_url"]; $o_url = new stripRequest($overview_url); $width = $this->conf->width; $height = $this->conf->height; $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'))); $overview_url = $o_url->url; $urls = $_REQUEST["map_url"]; $array_urls = explode("___", $urls); //problem with false in some map_urls see http/plugins/mb_metadata_wmcPreview.php //exchange array_urls with array_urls without false entries - it depends on the scale hints - if not visible the map_url is false! $newArray_urls = array(); for ($i = 0; $i < count($array_urls); $i++) { if ($array_urls[$i] != 'false') { $newArray_urls[] = $array_urls[$i]; } } $array_urls = $newArray_urls; $this->pdf->logWmsRequests("overview", $array_urls); $myURL = new stripRequest($array_urls[0]); $myURL->set('bbox', $this->pdf->getMapExtent()); if ($this->angle != 0) { if (class_exists('weldOverview2PNG_rotate')) { $rotatedExtent = $this->rotatePoints(explode(",", $this->pdf->getMapExtent()), intval($this->angle)); for ($i == 0; $i < count($rotatedExtent); $i++) { $e = new mb_notice("mbOverviewDecorator: rotated extent: " . implode("|", $rotatedExtent[$i])); } $i = new weldOverview2PNG_rotate($overview_url, $myURL->url, $this->filename, $rotatedExtent); } else { $i = new weldOverview2PNG($overview_url, $myURL->url, $this->filename); $e = new mb_warning("mbOverviewDecorator: no rotation possible."); } } else { $i = new weldOverview2PNG($overview_url, $myURL->url, $this->filename); } $this->pdf->objPdf->Image($this->filename, $this->conf->x_ul, $this->conf->y_ul, $width, $height, 'png'); $this->pdf->unlink($this->filename); }
public function decorate() { $urls = $_REQUEST["map_url"]; $array_urls = explode("___", $urls); //problem with false in some map_urls see http/plugins/mb_metadata_wmcPreview.php //exchange array_urls with array_urls without false entries $newArray_urls = array(); for ($i = 0; $i < count($array_urls); $i++) { if ($array_urls[$i] != 'false') { $newArray_urls[] = $array_urls[$i]; } } $array_urls = $newArray_urls; $e = new mb_notice("print/classes/mbMapDecorator.php: array_urls[0]: " . $array_urls[0]); $width = $this->conf->width; $height = $this->conf->height; $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')); if (isset($_REQUEST["coordinates"]) && $_REQUEST["coordinates"] != "") { $mapPdfBbox = $_REQUEST["coordinates"]; } else { $mapPdfBbox = $myURL->get('BBOX'); } $e = new mb_notice("mbMapDecorator: coordinates: " . $mapPdfBbox); $this->pdf->setMapInfo($this->conf->x_ul, $this->conf->y_ul, $width, $height, $this->pdf->adjustBbox($this->conf, explode(",", $mapPdfBbox), $myURL->get('srs'))); $e = new mb_notice("mbMapDecorator: adjusted bbox: " . $this->pdf->getMapExtent()); 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->pdf->getMapExtent()); $array_urls[$i] = $m->url; } $this->pdf->logWmsRequests("maps", $array_urls); if ($this->angle != 0) { if (class_exists('weldMaps2PNG_rotate')) { $i = new weldMaps2PNG_rotate(implode("___", $array_urls), $this->filename, $this->angle, false); } else { $i = new weldMaps2PNG(implode("___", $array_urls), $this->filename, false); $e = new mb_warning("mbMapDecorator: no rotation possible."); } } else { $i = new weldMaps2PNG(implode("___", $array_urls), $this->filename, false); } $this->pdf->objPdf->Image($this->filename, $this->conf->x_ul, $this->conf->y_ul, $width, $height, 'png'); /* show coordinates ... */ if ($this->conf->coords == 1) { $coord = mb_split(",", $this->pdf->getMapExtent()); $myMinx = substr(round($coord[0]), 0, 4) . "" . substr(round($coord[0]), 4, 3) . " m Ost"; $myMiny = substr(round($coord[1]), 0, 4) . "" . substr(round($coord[1]), 4, 3) . " m Nord"; $myMaxx = substr(round($coord[2]), 0, 4) . "" . substr(round($coord[2]), 4, 3) . " m Ost"; $myMaxy = substr(round($coord[3]), 0, 4) . "" . substr(round($coord[3]), 4, 3) . " m Nord"; $this->pdf->objPdf->setTextColor(0, 0, 0); $this->pdf->objPdf->setFont($this->conf->coords_font_family, "", $this->conf->coords_font_size); #RotatedText($x, $y, $txt, $angle) $this->pdf->objPdf->RotatedText($this->conf->x_ul - 2, $this->conf->y_ul + $height, $myMinx, 90); $this->pdf->objPdf->Text($this->conf->x_ul, $this->conf->y_ul + $height + 3.5, $myMiny); $this->pdf->objPdf->RotatedText($this->conf->x_ul + $width + 2, $this->conf->y_ul, $myMaxx, 270); $this->pdf->objPdf->Text($this->conf->x_ul + $width - $this->pdf->objPdf->GetStringWidth($myMaxy), $this->conf->y_ul - 2, $myMaxy); } $this->pdf->unlink($this->filename); }
$permanentImage = ''; } $permanentImage_x = $array_permanentImage[1]; $permanentImage_y = $array_permanentImage[2]; $permanentImage_width = $array_permanentImage[3]; $permanentImage_height = $array_permanentImage[4]; $pdf->addPngFromFile($permanentImage, $permanentImage_x + $mapOffset_left, $mapOffset_bottom + $map_height - $permanentImage_y - $permanentImage_height, $permanentImage_width, $permanentImage_height); } } if ($overview === true) { // analyse overview url and draw rectangle with position $o_url = new stripRequest($overview_url); $overview_width = round($o_url->get("width")); $overview_height = round($o_url->get("height")); if ($factor > 1) { $o_url->set('width', intval($o_url->get('width')) * 4); $o_url->set('height', intval($o_url->get('height')) * 4); if (in_array($o_url->get('map'), $highqualitymapfiles)) { $o_url->set('map', preg_replace("/\\.map/", "_4.map", $o_url->get('map'))); $overview_url = $o_url->url; } } if ($matching == true) { $overview_url = preg_replace($pattern, $replacement, $overview_url); } if ($size == "A4" && $format == "portrait") { $overview_left = $a4p_overviewOffset_left; $overview_bottom = $a4p_overviewOffset_bottom; } elseif ($size == "A4" && $format == "landscape") { $overview_left = $a4l_overviewOffset_left; $overview_bottom = $a4l_overviewOffset_bottom;