extent; $extatual->setextent((min($e[0],$e[2])),(min($e[1],$e[3])),(max($e[0],$e[2])),(max($e[1],$e[3]))); } $layer = $mapa->getlayerbyname($temarel); $layer->set("template","none.html"); $existesel = "nao"; /* if (file_exists($map_file."qy")) {$mapa->loadquery($map_file."qy");} */ carregaquery2($map_file,$layer,$mapa); if ($layer->getNumresults() > 0){$existesel = "sim";} if ($existesel == "nao") {$layer->querybyrect($mapa->extent);} $layer->open(); if(strtoupper($layer->getmetadata("convcaracter")) == "NAO") {$convC = false;} else {$convC = true;} //$registros[] = array(); $res_count = $layer->getNumresults(); for ($i = 0; $i < $res_count; $i++) { $valitem = array(); if($versao == 6) {$shape = $layer->getShape($layer->getResult($i));} else{$shape = $layer->getFeature($layer->getResult($i)->shapeindex);} $grupo = ""; foreach ($itensrel as $item) { $v = trim($shape->values[$item]); if (function_exists("mb_convert_encoding") && $convC == true) {$v = mb_convert_encoding($v,"UTF-8","ISO-8859-1");} $valitem[$item] = $v; } if ($itemagruparel != "") {$grupo = $valitem[$itemagruparel];} if($arearel == "true") { $valitem["area"] = calculaarea($shape); } if ($itemagruparel == "") $registros[] = $valitem; else { if(!$registros[$grupo]) $registros[$grupo]=array($valitem); else array_push($registros[$grupo],$valitem); } } $fechou = $layer->close(); restauraCon($map_file,$postgis_mapa); if(isset($tiporel) && $tiporel == "csv") { echo "
";
	echo implode(";",explode(",",$nomesrel));
	if($arearel == "true")
	{echo ";área em ha \n";}
	else
	{echo "\n";}
	foreach ($registros as $linhas)
	{echo implode(";",$linhas)."\n";}
	exit;
}
?>



i3Geo




Relatório do tema: ".$layer->getmetadata("TEMA")."
"; $ocorrencias = count($registros); echo "ocorrências: ".$ocorrencias."
"; if ($itemagruparel == "") { echo ""; $cor = "rgb(240,240,240)"; echo ""; if($statrel == "true"){echo "";} foreach ($colunas as $c) {echo "";} if($arearel == "true") {echo "";} foreach ($registros as $linhas) { if(count($linhas)>0) { echo ""; if ($statrel == "true") echo ""; $conta = 0; foreach($linhas as $v) { if(is_numeric(trim($v))) {echo "";} else {echo "";} if ($statrel == "true") { $v = trim($v); if(!is_numeric($v)){$v = 0;} if ($v == $excluirvalor){$v = 0;} $soma[$conta] = $soma[$conta] + $v; } $conta++; } echo ""; if ($cor == "rgb(240,240,240)") {$cor = "rgb(220,220,220)";} else {$cor = "rgb(240,240,240)";} } } if ($statrel == "true") { echo ""; echo ""; foreach($soma as $s) echo ""; echo ""; echo ""; echo ""; foreach($soma as $s) echo ""; echo ""; } echo "
$cárea em ha
".number_format($v,2,",",".")."$v
soma".number_format($s,2,",",".")."
média".number_format(($s / $ocorrencias),2,",",".")."
"; } else { $conta = -1; $chaves = array_keys($registros); sort($chaves); foreach ($chaves as $chave) { //if(count($registro) < 1){continue;} //var_dump($registros[$conta]); $ocorrencias = count($registros[$chave]); echo "

".$itemagruparel.": ".$chave."
ocorrências: ".$ocorrencias."
"; //echo "
";var_dump($registro);
		echo "";
		$cor = "rgb(240,240,240)";
		echo "";
		if ($statrel == "true")
		echo "";
		foreach ($colunas as $c)
		{
			echo "";
		}
		$soma = array();
		if($arearel == "true")
		{echo "";}
		echo "";
		foreach ($registros[$chave] as $linhas)
		{
			if (count($linhas) > 0 )
			{
				//echo "
";var_dump($linhas);
				echo "
"; if ($statrel == "true") echo ""; $conta = 0; foreach($linhas as $v) { if(is_numeric(trim($v))) {echo "";} else {echo "";} if ($statrel == "true") { $v = trim($v); if(!is_numeric($v)){$v = 0;} if ($v == $excluirvalor){$v = 0;} $soma[$conta] = $soma[$conta] + $v; } $conta++; } echo ""; if ($cor == "rgb(240,240,240)") {$cor = "rgb(220,220,220)";} else {$cor = "rgb(240,240,240)";} } } if ($statrel == "true" && $ocorrencias>1 ) { echo ""; echo ""; foreach($soma as $s) echo ""; echo ""; echo ""; echo ""; foreach($soma as $s) echo ""; echo ""; } echo "
$cárea em ha
".number_format($v,2,",",".")."$v
soma".number_format($s,2,",",".")."
média".number_format(($s / $ocorrencias),2,",",".")."
"; } } function calculaarea($geo) { global $postgis_con; $v = versao(); if (($v["principal"] < 5) && ($postgis_con == "")) {return ("erro. É necessária uma versão maior que 5.0 do Mapserver.");} $g = $geo->towkt(); $shape = ms_shapeObjFromWkt($g); $rect = $shape->bounds; $projInObj = ms_newprojectionobj("proj=latlong"); $projOutObj = ms_newprojectionobj("proj=laea,lat_0=".$rect->miny.",lon_0=".$rect->minx.",x_0=500000,y_0=10000000,ellps=GRS67,units=m,no_defs"); $shape->project($projInObj, $projOutObj); $s = $shape->towkt(); $shape = ms_shapeObjFromWkt($s); $area = $shape->getArea(); return $area / 10000; } ?>