'; echo ''; echo ''; echo ''; echo ''; echo '
 
'; echo '
'; echo 'Nome do arquivo map existente no diretório i3geo/temas. Exemplo para uso manual da URL: testamapfile.php?map=biomashp (utilize "testamapfile.php?map=todos" na URL para testar todos de uma só vez)

'; echo '
Mostra apenas a legenda? sim não
'; $combo = "

"; } if (isset($map) && $map != "") { if(!isset($solegenda)){$solegenda = "nao";} if ($map == "todos") { $tipo = "todos"; $conta = 0; echo "
Número de mapas = ".(count($arqs["arquivos"]))." Faltam= ".(count($arqs["arquivos"])-$iniciar-10)."
"; if (!isset($iniciar)){$iniciar = 0;} foreach ($arqs["arquivos"] as $arq) { if (($conta >= $iniciar) && ($conta < $iniciar+10)) { $temp = explode(".",$arq); if($temp[1] == "map") verifica($arq,$solegenda); else {echo "
Arquivo $map não é válido.
";} } $conta++; } echo "


Próximos mapas"; } else {verifica($map,$solegenda);} } echo '
'; echo ''; echo ''; function verifica($map,$solegenda) { global $tipo,$locaplic,$postgis_mapa,$versao,$base; $mapUrl = $map; if ($tipo == "mini" && file_exists('temas/miniaturas/'.$map.".mini.png")) { Header("Content-type: image/png"); ImagePng(ImageCreateFromPNG('temas/miniaturas/'.$map.".mini.png")); exit; } if ($tipo == "grande" && file_exists('temas/miniaturas/'.$map.".grande.png")) { Header("Content-type: image/png"); ImagePng(ImageCreateFromPNG('temas/miniaturas/'.$map.".grande.png")); exit; } ms_ResetErrorList(); $tema = ""; if(file_exists($map)) {$tema = $map;} else { $map = str_replace("\\","/",$map); $map = basename($map); if (file_exists('temas/'.$map)) {$tema = 'temas/'.$map;} if (file_exists('temas/'.$map.'.map')) {$tema = 'temas/'.$map.".map";} if (file_exists('temas/'.$map.'.php')) {$tema = 'temas/'.$map.".php";} } if(($tipo == "") || ($tipo == "todos")) {echo "


Testando: $tema
";}
	if(!file_exists($tema))
	{$tema = $locaplic."/".$tema;}
	if(!file_exists($tema))
	{echo "Arquivo ".$map." não encontrado.";exit;}
	if ($tema != "")
	{
		if($base == "" or !isset($base)){
			$base = "";
			if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
			{$base = $locaplic."/aplicmap/geral1windowsv".$versao.".map";}
			else
			{
				if($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv'.$versao.'.map')){
					$base = "/var/www/i3geo/aplicmap/geral1debianv".$versao.".map";
				}
				if($base == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){
					$base = "/var/www/html/i3geo/aplicmap/geral1fedorav".$versao.".map";
				}
				if($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){
					$base = "/opt/www/html/i3geo/aplicmap/geral1v".$versao.".map";
				}
				if($base == "")
				{$base = $locaplic."/aplicmap/geral1v".$versao.".map";}
			}
		}
		else{
			if(!file_exists($base))
			{$base = $locaplic."/aplicmap/".$base;}
		}
		$mapa = ms_newMapObj($base);
		
		error_reporting(0);
		$temasn = $mapa->getAllLayerNames();
		foreach ($temasn as $teman)
		{
			$layern = $mapa->getLayerByName($teman);
			if (!empty($postgis_mapa))
			{
				if ($layern->connectiontype == MS_POSTGIS)
				{
					$lcon = $layern->connection;
					if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa))))
					{
						if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade
						{$layern->set("connection",$postgis_mapa);}
						else
						{$layern->set("connection",$postgis_mapa[$lcon]);}					
					}
				}
			}
		}
		if(!stristr($tema, '.php') === FALSE){
			echo "
Arquivo $tema é um programa PHP. O teste pode não funcionar.
"; include_once($locaplic."/".$tema); // //$pegarext deve guardar o nome da camada para ser usado mais abaixo // $pegarext = str_replace(".php","",$tema); $pegarext = str_replace("temas/","",$pegarext); eval($pegarext."(\$mapa);"); } else{ if(file_exists($mapUrl)) {$nmapa = ms_newMapObj($mapUrl);} else{ if(@ms_newMapObj($locaplic."/".$tema)) { $nmapa = ms_newMapObj($locaplic."/".$tema); } else { echo "erro no arquivo $map
"; echo "Obs.: em alguns testes o mapfile pode falhar se o endereço dos arquivos de símbolos estiverem
definidos de forma relativa ao invés de absoluta. Nesses casos, ao abrir o i3Geo,
o mapfile poderá funcionar.
"; $error = ms_GetErrorObj(); while($error && $error->code != MS_NOERR) { printf("
Error in %s: %s
\n", $error->routine, $error->message); $error = $error->next(); } return; } } $temasn = $nmapa->getAllLayerNames(); $dados = ""; foreach ($temasn as $teman) { $layern = $nmapa->getLayerByName($teman); $layern->set("status",MS_DEFAULT); if (!empty($postgis_mapa)) { if ($layern->connectiontype == MS_POSTGIS) { $lcon = $layern->connection; error_reporting(0); if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) { if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade {$layern->set("connection",$postgis_mapa);} else {$layern->set("connection",$postgis_mapa[$lcon]);} } } } autoClasses($layern,$nmapa); error_reporting(E_ALL); if($layern->classitem != "" && $layern->connectiontype == 7 && $layern->numclasses > 0 && $layern->getmetadata("wms_sld_body") == ""){ $tipotemp = $layern->type; $tiporep = $layern->getmetadata("tipooriginal"); $layern->set("type",MS_LAYER_POLYGON); if ($tiporep == "linear") {$layern->set("type",MS_LAYER_LINE);} if ($tiporep == "pontual") {$layern->set("type",MS_LAYER_POINT);} $sld = $layern->generateSLD(); if($sld != "") $layern->setmetadata("wms_sld_body",str_replace('"',"'",$sld)); $layern->set("type",$tipotemp); } ms_newLayerObj($mapa, $layern); if ($layern->data == "") $dados = $layern->connection; else $dados = $layern->data; $pegarext = $teman; } } zoomTema($pegarext,$mapa); if ($tipo == "mini") { $mapa->setsize(50,50); $sca = $mapa->scalebar; $sca->set("status",MS_OFF); } if ($tipo == "grande") { $mapa->setsize(300,300); $sca = $mapa->scalebar; $sca->set("status",MS_OFF); } if($tipo == "todos") { $mapa->setsize(150,150); $sca = $mapa->scalebar; $sca->set("status",MS_OFF); } $objImagem = @$mapa->draw(); $objImagemLegenda = @$mapa->drawLegend(); if (!$objImagem) { echo "Problemas ao gerar o mapa
"; $error = ""; $error = ms_GetErrorObj(); while($error && $error->code != MS_NOERR) { echo "
Error in %s: %s
", $error->routine, $error->message; $error = $error->next(); } return; } if($objImagem->imagepath == "") {echo "Erro IMAGEPATH vazio";} $nomec = ($objImagem->imagepath).nomeRandomico()."teste.png"; $objImagem->saveImage($nomec); $nomer = ($objImagem->imageurl).basename($nomec); $nomel = ($objImagemLegenda->imagepath).nomeRandomico()."testel.png"; $objImagemLegenda->saveImage($nomel); $nomerl = ($objImagemLegenda->imageurl).basename($nomel); if(($tipo == "") || ($tipo == "todos")) { if($solegenda == "nao") {echo "
";} echo ""; if($tipo == "todos") { echo "
".$dados."
"; } if($map != "todos") { echo "
Erros:
"; $error = ""; $error = ms_GetErrorObj(); while($error && $error->code != MS_NOERR) { echo "
Error in %s: %s
", $error->routine, $error->message; $error = $error->next(); } } } else { Header("Content-type: image/png"); ImagePng(ImageCreateFromPNG($nomec)); } //$objImagem->free(); } } function zoomTema($nomelayer,&$mapa) { $layer = $mapa->getlayerbyname($nomelayer); if($layer->data == "" && $layer->connection == "") {return;} $prjMapa = $mapa->getProjection(); $prjTema = $layer->getProjection(); $extatual = $mapa->extent; $ret = $layer->getmetadata("extensao"); if($layer->type > 2 && $ret == "") {return;} $ct = $layer->connectiontype; if(($ret == "") && ($ct != 1)) {return;} if ($ret == "") { $ret = $layer->getextent(); //reprojeta o retangulo if (($prjTema != "") && ($prjMapa != $prjTema)) { $projInObj = ms_newprojectionobj($prjTema); $projOutObj = ms_newprojectionobj($prjMapa); $ret->project($projInObj, $projOutObj); } $extatual->setextent($ret->minx,$ret->miny,$ret->maxx,$ret->maxy); } else { $ret = explode(" ",$ret); $extatual->setextent($ret[0],$ret[1],$ret[2],$ret[3]); } } ?>