function loadpng($imgurl) { $obj = new stripRequest($imgurl); $x = new connector($imgurl); // $f = $obj->get("format"); $im = @imagecreatefromstring($x->file); if (!$im) { $im = false; $e = new mb_exception("weldMaps2PNG: unable to load image: " . $imgurl); } return $im; }
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); }
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); }
function getImage($imageTyp_imp, $outputKind = '') { $imageTyp = ""; $imageTyp = $imageTyp_imp; if ($imageTyp == 'jpg') { $imageTyp = 'jpeg'; } if (!$this->urls || $this->urls == "") { $e = new mb_exception("weldMaps2Image: no maprequests delivered"); } $obj1 = new stripRequest($this->urls[0]); $width = $obj1->get("width"); $height = $obj1->get("height"); $wms_srs = $obj1->get("srs"); $wms_bbox = $obj1->get("bbox"); $wms_format = $obj1->getFormat(); $image = imagecreatetruecolor($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); ImageFilledRectangle($image, 0, 0, $width, $height, $white); for ($i = 0; $i < count($this->urls); $i++) { $obj = new stripRequest($this->urls[$i]); if ($imageTyp == 'geotiff') { $this->urls[$i] = $obj->setFormat($wms_format); } else { $this->urls[$i] = $obj->setFormat($imageTyp); } $this->urls[$i] = $obj->encodeGET(); $img = $this->loadImage($this->urls[$i]); if ($img != false) { imagecopy($image, $img, 0, 0, 0, 0, $width, $height); } else { $e = new mb_exception("weldMaps2Image: unable to load image: " . $this->urls[$i]); } } $filename = $this->array_file['dir'] . "/"; $timestamp = time(); $filenameOnly = $this->array_file['filename'] . md5($timestamp); if ($imageTyp == 'png') { $filenameOnly .= '.png'; $filename .= $filenameOnly; imagepng($image, $filename); $this->downloadLink($filenameOnly); } else { if ($imageTyp == 'jpeg') { $filenameOnly .= '.jpeg'; $filename .= $filenameOnly; imagejpeg($image, $filename); $this->downloadLink($filenameOnly); } else { if ($imageTyp == 'geotiff') { $filenameOnly .= '.' . $wms_format; $filename .= $filenameOnly; if ($wms_format == 'png') { imagepng($image, $filename); } else { if ($wms_format == 'jpeg') { imagejpeg($image, $filename); } else { $e = new mb_exception("weldMaps2Image: unable to generate temp-Image for getiff: " . $filename); } } // gdal_translate... $wms_bbox = str_replace(',', ' ', $wms_bbox); $filename_tif = str_replace($wms_format, 'tif', $filenameOnly); $tmp_dir = $this->array_file['dir'] . "/"; $array_bbox = explode(" ", $wms_bbox); $wms_bbox = $array_bbox[0] . " " . $array_bbox[3] . " " . $array_bbox[2] . " " . $array_bbox[1]; /* * @security_patch exec done * Added escapeshellcmd() */ $cmd = "gdal_translate -a_srs " . $wms_srs . " -a_ullr " . $wms_bbox . " " . $tmp_dir . $filenameOnly . " " . $tmp_dir . $filename_tif; exec(escapeshellcmd($cmd)); $this->downloadLink($filename_tif); } else { } } } }
function makeRealWorld2mapPos($url, $rw_posx, $rw_posy) { $obj = new stripRequest($url); $width = $obj->get("width"); $height = $obj->get("height"); #$e = new mb_exception("weld_url: ".$url); #$e = new mb_exception("w: ".$width."height".$height); $arrayBBox = explode(",", $obj->get("BBOX")); $minX = $arrayBBox[0]; $minY = $arrayBBox[1]; $maxX = $arrayBBox[2]; $maxY = $arrayBBox[3]; #$e = new mb_exception("------- minx: ".$minX." miny:".$minY." maxx:".$maxX." maxy:".$maxY."----------"); $xtentx = $maxX - $minX; $xtenty = $maxY - $minY; $pixPos_x = ($rw_posx - $minX) / $xtentx * $width; $pixPos_y = ($maxY - $rw_posy) / $xtenty * $height; $pixPos = array($pixPos_x, $pixPos_y); return $pixPos; }
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); }
/** * Helper function to generate temporary images for each URL * * @param <string> a single URL which represents a maprequest */ function loadpng($imgurl) { $obj = new stripRequest($imgurl); $f = $obj->get("format"); /** * react on format * @todo create switch? * @todo handle as reg-exp? * @todo instanciate $im as false or null? */ if (mb_strtolower($f) == 'image/png' || mb_strtolower($f) == 'png') { $im = @ImageCreateFromPNG($imgurl); } if (mb_strtolower($f) == 'image/jpeg' || mb_strtolower($f) == 'jpeg') { $im = @ImageCreateFromJPEG($imgurl); } if (mb_strtolower($f) == 'image/gif' || mb_strtolower($f) == 'gif') { $im = @ImageCreateFromGIF($imgurl); } if (!$im) { $im = false; $e = new mb_exception("weldMaps2PNG: unable to load image: " . $imgurl); } // return the temporary image return $im; }
$array_permanentImage = explode("___", $_REQUEST["mypermanentImage"]); if (count($array_permanentImage) > 0) { $permanentImage = $array_permanentImage[0]; if ($permanentImage == 'false') { $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;
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_stripRequest.php"; require_once dirname(__FILE__) . "/../classes/class_connector.php"; if ($_GET["url"]) { $mr = new stripRequest(urldecode($_GET["url"])); } else { $mr = new stripRequest($_POST["url"]); } $nmr = $mr->encodeGET(); $isOwsproxyRequest = mb_strpos($nmr, OWSPROXY) === 0; if ($isOwsproxyRequest) { header("Location: " . $nmr); } else { $x = new connector($nmr); if (empty($x->file)) { //close window if featureInfo has no result //echo "<body onLoad=\"javascript:window.close()\">"; echo ""; } else { // Uebergabe von MB Nutzername/Passwort fuer ALB-Auskunft - rw. $pattern = "/(.*?)(name\\s?=\\s?[\"|\\']usr[\"|\\'] \\s*value\\s?=\\s?[\"|\\'][a-zA-Z0-9_*]+[\"|\\'])(.*?)/"; $content = $x->file;