[Mapbender-commits] r2177 - branches/2.4.5/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Mar 5 10:37:16 EST 2008


Author: christoph
Date: 2008-03-05 10:37:16 -0500 (Wed, 05 Mar 2008)
New Revision: 2177

Removed:
   branches/2.4.5/http/classes/class_weldMaps2Image.php
Log:
feature freeze, rejected

Deleted: branches/2.4.5/http/classes/class_weldMaps2Image.php
===================================================================
--- branches/2.4.5/http/classes/class_weldMaps2Image.php	2008-03-05 15:36:30 UTC (rev 2176)
+++ branches/2.4.5/http/classes/class_weldMaps2Image.php	2008-03-05 15:37:16 UTC (rev 2177)
@@ -1,211 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# 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__)."/class_stripRequest.php");
-require_once(dirname(__FILE__)."/class_mb_exception.php");
-require_once(dirname(__FILE__)."/class_connector.php");
-include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
- 
- /*
-  * Class generats Images (jpegs/pngs/geotiff) 
-  * of Image-URL-Array
-  * For geotiff export gdal is necessary
-  * 
-  */
- class weldMaps2Image{
- 	
-	var $urls = array();
-	var $filename; 	
- 	
- 	function weldMaps2Image($urls, $array_file){
- 		$this->urls = $urls;
-  		$this->array_file = $array_file;
- 	}
- 	
- 	
-	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'];
-			$cmd = "gdal_translate -a_srs ".$wms_srs." -a_ullr ".$wms_bbox." ".$tmp_dir.$filenameOnly." ".$tmp_dir.$filename_tif;
-			exec($cmd);
-			
-			echo "<br>";
-			$this->downloadLink($filenameOnly);
-					
-		}else {
-			
-		}
-		
-		
-	}
-	
-	function loadImage ($imgurl) {
-
-		$x = new connector($imgurl);		
-		$im = @imagecreatefromstring($x->file);
-		if(!$im){
-			$im = false;
-			$e = new mb_exception("weldMaps2Image: unable to load image: ".$imgurl);
-		}  
-		return $im;
-		
-	}
- 	
- 	function downloadLink($downloadFilename){
- 		
-
-		$dwDir  = $this->array_file['dir']."/";
-		$dwFilename = $downloadFilename;
-		
-		
-		if(!(bool)$dwFilename) {
-			die("No filename given.");
-		}
-		
-		if((int)strpos($dwFilename,"..") !== 0) {
-			die("Illegal filename given.");
-		}
-		
-		$img = $dwDir."/".$dwFilename; 
-		
-		if(!file_exists($img) || !is_readable($img)) {
-			die("An error occured.");
-			
-		}
-		
-		$now_date = date("Ymd_His");
-		
-		switch(substr($dwFilename,-4)) {
-			case ".png":
-				$filename = "map_export__".$now_date.".png";
-				header('Content-Type: image/png');
-				break;
-			case "jpeg":
-				$filename = "map_export__".$now_date.".jpeg";
-				header('Content-Type: image/jpeg');
-				break;
-			case ".tif";
-				$filename = "map_export__".$now_date.".tif";
-				header('Content-Type: image/tif');
-				break;
-			default:
-				die("An error occured.");
-		}
-
- 		if(file_exists($img) && is_file($img)) {
-				header("Content-Disposition: attachment; filename=\"".$filename."\"");
-
-				readfile($img); 
-		} else {
-			    die('Error: The file '.$img.' does not exist!');
-			}
-
- 	}
- 	
- }
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
-?>



More information about the Mapbender_commits mailing list