'; 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
'; } if (isset($map) && $map != "") { if(!isset($solegenda)){$solegenda = "nao";} if ($map == "todos") { $tipo = "todos"; $arqs = listaArquivos("temas"); $conta = 0; echo "
Número de mapas = ".(count($arqs["arquivos"]))." Faltam= ".(count($arqs["arquivos"])-$iniciar-10)."
"; if (!isset($iniciar)){$iniciar = 0;} sort($arqs["arquivos"]); 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);} } function verifica($map,$solegenda) { global $tipo,$locaplic,$postgis_mapa; 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(($tipo == "") || ($tipo == "todos")) echo "


Testando: $tema
";
	if(!file_exists($tema)){echo "Arquivo ".$map." não encontrado.";exit;}
	if ($tema != "")
	{
		if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
		{$mapa = ms_newMapObj("aplicmap/geral1windows.map");}
		else
		{$mapa = ms_newMapObj("aplicmap/geral1.map");}
		if(@ms_newMapObj($tema))
		{
			$nmapa = ms_newMapObj($tema);
		}
		else
		{
			echo "erro no arquivo $map 
"; $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 (isset($postgis_mapa)) { if (($postgis_mapa != "") || ($postgis_mapa != " ")) { if ($layern->connectiontype == MS_POSTGIS) { $lcon = $layern->connection; if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) { // //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição // if(($lcon == " ") || ($lcon == "")) { $layern->set("connection",$postgis_mapa); } else { $layern->set("connection",$postgis_mapa[$lcon]); } } } } } autoClasses(&$layern,$nmapa); 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; } $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); $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]); } } ?>