Commit 5f97c58e516d04c7fdfaee7b55e333903fa306d0
1 parent
d2f3db5c
Exists in
master
and in
7 other branches
Incluida opção de geração de relatório na ferramenta tabela
Showing
3 changed files
with
286 additions
and
4 deletions
Show diff stats
ferramentas/tabela/index.htm
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | <div id=guia2 >Marcados</div> |
| 12 | 12 | <div id=guia3 >Operações</div> |
| 13 | 13 | <div id=guia4 >Gráficos</div> |
| 14 | - <!---<div id=guia5 >Relatórios</div>---> | |
| 14 | + <div id=guia5 >Relatórios</div> | |
| 15 | 15 | </div> |
| 16 | 16 | <span id=geral style="left:0px;top:0px;"> |
| 17 | 17 | <div id=resultadotab style="position:relative;top:5px;left:0px"></div> |
| ... | ... | @@ -88,19 +88,29 @@ |
| 88 | 88 | <div id=agrupamento style="text-align:left;top:15px;left:5px;"> |
| 89 | 89 | </div> |
| 90 | 90 | <div style="position:relative;top:25px;left:0px"> |
| 91 | - <input style="cursor:pointer" type=checkbox id=calculaarea CHECKED /> | |
| 91 | + <input style="cursor:pointer" type=checkbox id=calculaarea /> | |
| 92 | 92 | Incluir cálculo de área |
| 93 | 93 | </div> |
| 94 | + <div style="position:relative;top:25px;left:0px"> | |
| 95 | + <input style="cursor:pointer" type=checkbox id=calculaestat /> | |
| 96 | + Incluir cálculo de estatísticas | |
| 97 | + </div> | |
| 98 | + <div style="position:relative;top:25px;left:0px"> | |
| 99 | + Excluir das estatísticas o valor | |
| 100 | + <input style="cursor:pointer" type=text id=excestat /> | |
| 101 | + </div> | |
| 94 | 102 | <div onclick="gerarelatorio()" style="position:relative;top:35px;left:0px;cursor:pointer"> |
| 95 | 103 | <input id=botao7 size=30 type=button value="Criar"/> |
| 96 | 104 | </div> |
| 97 | 105 | <form method=post style="display:none" id=relatorio action="relatorio.php" target="_blank" > |
| 98 | - <input type=hidden id=arearel name=arearel value=sim /> | |
| 106 | + <input type=hidden id=arearel name=arearel value=nao /> | |
| 107 | + <input type=hidden id=statrel name=statrel value=nao /> | |
| 99 | 108 | <input type=hidden id=temarel name=temarel value="" /> |
| 100 | 109 | <input type=hidden id=g_sid name=g_sid value="" /> |
| 101 | - <input type=hidden id=itemagruparel name=temaagruparel value="" /> | |
| 110 | + <input type=hidden id=itemagruparel name=itemagruparel value="" /> | |
| 102 | 111 | <input type=hidden id=itensrel name=itensrel value="" /> |
| 103 | 112 | <input type=hidden id=nomesrel name=nomesrel value="" /> |
| 113 | + <input type=hidden id=excluirvalor name=excluirvalor value="" /> | |
| 104 | 114 | </form> |
| 105 | 115 | </div> |
| 106 | 116 | </span> | ... | ... |
ferramentas/tabela/index.js
| ... | ... | @@ -1081,6 +1081,8 @@ function mostraFG(retorno) |
| 1081 | 1081 | function gerarelatorio() |
| 1082 | 1082 | { |
| 1083 | 1083 | $i("arearel").value = $i("calculaarea").checked |
| 1084 | + $i("statrel").value = $i("calculaestat").checked | |
| 1085 | + $i("excluirvalor").value = $i("excestat").value | |
| 1084 | 1086 | $i("temarel").value=tema |
| 1085 | 1087 | $i("g_sid").value=g_sid |
| 1086 | 1088 | $i("itemagruparel").value=$i("agrupaItem").value | ... | ... |
| ... | ... | @@ -0,0 +1,270 @@ |
| 1 | +<?php | |
| 2 | +session_name("i3GeoPHP"); | |
| 3 | +if (isset($g_sid)) | |
| 4 | +{session_id($g_sid);} | |
| 5 | +session_start(); | |
| 6 | +foreach(array_keys($_SESSION) as $k) | |
| 7 | +{ | |
| 8 | + eval("\$".$k."='".$_SESSION[$k]."';"); | |
| 9 | +} | |
| 10 | +include("../../classesphp/carrega_ext.php"); | |
| 11 | +include("../../classesphp/pega_variaveis.php"); | |
| 12 | +$temp = explode(",",$nomesrel); | |
| 13 | +$colunas = array(); | |
| 14 | +foreach($temp as $t) | |
| 15 | +{ | |
| 16 | + $t1=explode(";",$t); | |
| 17 | + $colunas[] = $t1[0]; | |
| 18 | +} | |
| 19 | +if($itemagruparel != "" && !in_array($itemagruparel,$colunas)) | |
| 20 | +{$colunas[] = $itemagruparel;} | |
| 21 | +$temp = explode(",",$itensrel); | |
| 22 | +$itensrel = array(); | |
| 23 | +foreach($temp as $t) | |
| 24 | +{ | |
| 25 | + $t1=explode(";",$t); | |
| 26 | + $itensrel[] = $t1[0]; | |
| 27 | +} | |
| 28 | +if($itemagruparel != "" && !in_array($itemagruparel,$itensrel)) | |
| 29 | +{$itensrel[] = $itemagruparel;} | |
| 30 | + | |
| 31 | +$mapa = ms_newMapObj($map_file); | |
| 32 | +$layer = $mapa->getlayerbyname($temarel); | |
| 33 | +$existesel = "nao"; | |
| 34 | +if (file_exists($map_file."qy")) | |
| 35 | +{$mapa->loadquery($map_file."qy");} | |
| 36 | +if ($layer->getNumresults() > 0){$existesel = "sim";} | |
| 37 | +if ($existesel == "nao") | |
| 38 | +{$layer->querybyrect($mapa->extent);} | |
| 39 | +$layer->open(); | |
| 40 | +//$registros[] = array(); | |
| 41 | +$res_count = $layer->getNumresults(); | |
| 42 | +for ($i = 0; $i < $res_count; $i++) | |
| 43 | +{ | |
| 44 | + $valitem = array(); | |
| 45 | + $result = $layer->getResult($i); | |
| 46 | + $shp_index = $result->shapeindex; | |
| 47 | + $shape = $layer->getshape(-1, $shp_index); | |
| 48 | + $grupo = ""; | |
| 49 | + foreach ($itensrel as $item) | |
| 50 | + { | |
| 51 | + $v = trim($shape->values[$item]); | |
| 52 | + if (function_exists("mb_convert_encoding")) | |
| 53 | + {$v = mb_convert_encoding($v,"UTF-8","ISO-8859-1");} | |
| 54 | + $valitem[$item] = $v; | |
| 55 | + } | |
| 56 | + if ($itemagruparel != "") | |
| 57 | + {$grupo = $valitem[$itemagruparel];} | |
| 58 | + if($arearel == "true") | |
| 59 | + { | |
| 60 | + $valitem["area"] = calculaarea($shape); | |
| 61 | + } | |
| 62 | + if ($itemagruparel == "") | |
| 63 | + $registros[] = $valitem; | |
| 64 | + else | |
| 65 | + { | |
| 66 | + if(!$registros[$grupo]) | |
| 67 | + $registros[$grupo]=array($valitem); | |
| 68 | + else | |
| 69 | + array_push($registros[$grupo],$valitem); | |
| 70 | + } | |
| 71 | +} | |
| 72 | +$fechou = $layer->close(); | |
| 73 | +?> | |
| 74 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
| 75 | +<html> | |
| 76 | +<head> | |
| 77 | +<title>i3Geo</title> | |
| 78 | +</head> | |
| 79 | +<style> | |
| 80 | +body,td | |
| 81 | +{ | |
| 82 | + text-align:left; | |
| 83 | + border: 0px solid #FFFFFF; | |
| 84 | + font-family: Verdana, Arial, Helvetica, sans-serif; | |
| 85 | + position:relative; | |
| 86 | + font-size:10pt; | |
| 87 | + padding:10px; | |
| 88 | +} | |
| 89 | + | |
| 90 | +</style> | |
| 91 | +<body> | |
| 92 | +<img src='../../imagens/i3geo1.jpg' /><br> | |
| 93 | +<?php | |
| 94 | +echo "<span style=font-size:18px; >Relatório do tema: <b>".$layer->getmetadata("TEMA")."</b><br></span>"; | |
| 95 | +$ocorrencias = count($registros); | |
| 96 | +echo "ocorrências: ".$ocorrencias."<br>"; | |
| 97 | +if ($itemagruparel == "") | |
| 98 | +{ | |
| 99 | + echo "<table>"; | |
| 100 | + $cor = "rgb(240,240,240)"; | |
| 101 | + echo "<tr style=background-color:yellow >"; | |
| 102 | + if($statrel == "true"){echo "<td></td>";} | |
| 103 | + foreach ($colunas as $c) | |
| 104 | + { | |
| 105 | + echo "<td>$c</td>"; | |
| 106 | + } | |
| 107 | + if($arearel == "true") | |
| 108 | + {echo "<td>área em ha</td>";} | |
| 109 | + foreach ($registros as $linhas) | |
| 110 | + { | |
| 111 | + if(count($linhas)>0) | |
| 112 | + { | |
| 113 | + echo "<tr style=background-color:$cor >"; | |
| 114 | + if ($statrel == "true") | |
| 115 | + echo "<td></td>"; | |
| 116 | + $conta = 0; | |
| 117 | + foreach($linhas as $v) | |
| 118 | + { | |
| 119 | + echo "<td>$v</td>"; | |
| 120 | + if ($statrel == "true") | |
| 121 | + { | |
| 122 | + $v = trim($v); | |
| 123 | + if(!is_numeric($v)){$v = 0;} | |
| 124 | + if ($v == $excluirvalor){$v = 0;} | |
| 125 | + $soma[$conta] = $soma[$conta] + $v; | |
| 126 | + } | |
| 127 | + $conta++; | |
| 128 | + } | |
| 129 | + echo "<tr>"; | |
| 130 | + if ($cor == "rgb(240,240,240)") | |
| 131 | + {$cor = "rgb(220,220,220)";} | |
| 132 | + else | |
| 133 | + {$cor = "rgb(240,240,240)";} | |
| 134 | + } | |
| 135 | + } | |
| 136 | + if ($statrel == "true") | |
| 137 | + { | |
| 138 | + echo "<tr style=background-color:orange >"; | |
| 139 | + echo "<td>soma</td>"; | |
| 140 | + foreach($soma as $s) | |
| 141 | + echo "<td>$s</td>"; | |
| 142 | + echo "</tr>"; | |
| 143 | + echo "<tr style=background-color:orange >"; | |
| 144 | + echo "<td>média</td>"; | |
| 145 | + foreach($soma as $s) | |
| 146 | + echo "<td>".($s / $ocorrencias)."</td>"; | |
| 147 | + echo "</tr>"; | |
| 148 | + } | |
| 149 | + echo "</table>"; | |
| 150 | +} | |
| 151 | +else | |
| 152 | +{ | |
| 153 | + $conta = -1; | |
| 154 | + $chaves = array_keys($registros); | |
| 155 | + sort($chaves); | |
| 156 | + foreach ($chaves as $chave) | |
| 157 | + { | |
| 158 | + //if(count($registro) < 1){continue;} | |
| 159 | + //var_dump($registros[$conta]); | |
| 160 | + $ocorrencias = count($registros[$chave]); | |
| 161 | + echo "<br><br><b>".$itemagruparel.": ".$chave."<br>ocorrências: ".$ocorrencias."<br></b>"; | |
| 162 | + //echo "<pre>";var_dump($registro); | |
| 163 | + echo "<table>"; | |
| 164 | + $cor = "rgb(240,240,240)"; | |
| 165 | + echo "<tr style=background-color:yellow >"; | |
| 166 | + if ($statrel == "true") | |
| 167 | + echo "<td></td>"; | |
| 168 | + foreach ($colunas as $c) | |
| 169 | + { | |
| 170 | + echo "<td>$c</td>"; | |
| 171 | + } | |
| 172 | + $soma = array(); | |
| 173 | + if($arearel == "true") | |
| 174 | + {echo "<td>área em ha</td>";} | |
| 175 | + echo "<tr>"; | |
| 176 | + foreach ($registros[$chave] as $linhas) | |
| 177 | + { | |
| 178 | + if (count($linhas) > 0 ) | |
| 179 | + { | |
| 180 | + //echo "<pre>";var_dump($linhas); | |
| 181 | + echo "<tr style=background-color:$cor >"; | |
| 182 | + if ($statrel == "true") | |
| 183 | + echo "<td></td>"; | |
| 184 | + $conta = 0; | |
| 185 | + foreach($linhas as $v) | |
| 186 | + { | |
| 187 | + echo "<td>$v</td>"; | |
| 188 | + if ($statrel == "true") | |
| 189 | + { | |
| 190 | + $v = trim($v); | |
| 191 | + if(!is_numeric($v)){$v = 0;} | |
| 192 | + if ($v == $excluirvalor){$v = 0;} | |
| 193 | + $soma[$conta] = $soma[$conta] + $v; | |
| 194 | + } | |
| 195 | + $conta++; | |
| 196 | + } | |
| 197 | + echo "<tr>"; | |
| 198 | + if ($cor == "rgb(240,240,240)") | |
| 199 | + {$cor = "rgb(220,220,220)";} | |
| 200 | + else | |
| 201 | + {$cor = "rgb(240,240,240)";} | |
| 202 | + } | |
| 203 | + } | |
| 204 | + if ($statrel == "true" && $ocorrencias>1 ) | |
| 205 | + { | |
| 206 | + echo "<tr style=background-color:orange >"; | |
| 207 | + echo "<td>soma</td>"; | |
| 208 | + foreach($soma as $s) | |
| 209 | + echo "<td>$s</td>"; | |
| 210 | + echo "</tr>"; | |
| 211 | + echo "<tr style=background-color:orange >"; | |
| 212 | + echo "<td>média</td>"; | |
| 213 | + foreach($soma as $s) | |
| 214 | + echo "<td>".($s / $ocorrencias)."</td>"; | |
| 215 | + echo "</tr>"; | |
| 216 | + } | |
| 217 | + echo "</table>"; | |
| 218 | + } | |
| 219 | + | |
| 220 | +} | |
| 221 | +function calculaarea($geo) | |
| 222 | +{ | |
| 223 | + global $postgis_con; | |
| 224 | + $v = versao(); | |
| 225 | + if (($v["principal"] != 5) && ($postgis_con == "")) | |
| 226 | + {return ("erro. Nao foi definida a conexao com o Postgis.");} | |
| 227 | + if ($v["principal"] != 5) | |
| 228 | + { | |
| 229 | + $pgconn = pg_connect($postgis_con); | |
| 230 | + $g = $geo->towkt(); | |
| 231 | + $sql = "select area(transform( GeomFromText('$g',4291),$srid_area))::float as aream"; | |
| 232 | + $result=pg_query($pgconn, $sql); | |
| 233 | + pg_close($pgconn); | |
| 234 | + $calculo = pg_fetch_all($result); | |
| 235 | + return $calculo[0]["aream"]; | |
| 236 | + } | |
| 237 | + else | |
| 238 | + { | |
| 239 | + $g = $geo->towkt(); | |
| 240 | + $shape = ms_shapeObjFromWkt($g); | |
| 241 | + $rect = $shape->bounds; | |
| 242 | + $projInObj = ms_newprojectionobj("proj=latlong"); | |
| 243 | + $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"); | |
| 244 | + $shape->project($projInObj, $projOutObj); | |
| 245 | + $s = $shape->towkt(); | |
| 246 | + $shape = ms_shapeObjFromWkt($s); | |
| 247 | + $area = $shape->getArea(); | |
| 248 | + return $area; | |
| 249 | + } | |
| 250 | +} | |
| 251 | +/* | |
| 252 | +function: versao | |
| 253 | + | |
| 254 | +Retorna a versão do Mapserver. | |
| 255 | +*/ | |
| 256 | + function versao() | |
| 257 | + { | |
| 258 | + $v = "5.0.0"; | |
| 259 | + $vs = explode(" ",ms_GetVersion()); | |
| 260 | + for ($i=0;$i<(count($vs));$i++) | |
| 261 | + { | |
| 262 | + if(strtolower($vs[$i]) == "version") | |
| 263 | + {$v = $vs[$i+1];} | |
| 264 | + } | |
| 265 | + $versao["completa"] = $v; | |
| 266 | + $v = explode(".",$v); | |
| 267 | + $versao["principal"] = $v[0]; | |
| 268 | + return $versao; | |
| 269 | + } | |
| 270 | +?> | |
| 0 | 271 | \ No newline at end of file | ... | ... |