Commit d9c89cf3775b69c066b1dcc440b3734c875df586
1 parent
c53f9f28
Exists in
master
and in
7 other branches
$1
Showing
5 changed files
with
128 additions
and
48 deletions
Show diff stats
admin/admin.db
No preview for this file type
classesphp/classe_analise.php
| ... | ... | @@ -2041,7 +2041,7 @@ $temaPo - Tema poligonal. |
| 2041 | 2041 | |
| 2042 | 2042 | $locaplic - Localização do I3geo |
| 2043 | 2043 | */ |
| 2044 | - function nptPol($temaPt,$temaPo,$locaplic) | |
| 2044 | + function nptPol($temaPt,$temaPo,$locaplic,$somaritem="") | |
| 2045 | 2045 | { |
| 2046 | 2046 | //error_reporting(0); |
| 2047 | 2047 | set_time_limit(180); |
| ... | ... | @@ -2064,45 +2064,81 @@ $locaplic - Localização do I3geo |
| 2064 | 2064 | $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON); |
| 2065 | 2065 | // cria o dbf |
| 2066 | 2066 | $def = array(); |
| 2067 | - foreach ($itenspo as $ni) | |
| 2068 | - {$def[] = array(substr($ni, 0, 10),"C","254");} | |
| 2067 | + foreach ($itenspo as $ni){ | |
| 2068 | + $def[] = array(substr($ni, 0, 10),"C","254"); | |
| 2069 | + } | |
| 2069 | 2070 | $def[] = array("npontos","N","10","0"); |
| 2070 | - if($this->dbaseExiste == false) | |
| 2071 | - {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} | |
| 2072 | - else | |
| 2073 | - {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} | |
| 2071 | + $def[] = array("soma","N","10","0"); | |
| 2072 | + $def[] = array("media","N","10","0"); | |
| 2073 | + if($this->dbaseExiste == false){ | |
| 2074 | + $db = xbase_create($nomeshp.".dbf", $def);xbase_close($db); | |
| 2075 | + } | |
| 2076 | + else{ | |
| 2077 | + $db = dbase_create($nomeshp.".dbf", $def);dbase_close($db); | |
| 2078 | + } | |
| 2074 | 2079 | //acrescenta os pontos no novo shapefile |
| 2075 | 2080 | $dbname = $nomeshp.".dbf"; |
| 2076 | - if($this->dbaseExiste == false) | |
| 2077 | - $db=xbase_open($dbname,2); | |
| 2078 | - else | |
| 2079 | - $db=dbase_open($dbname,2); | |
| 2081 | + if($this->dbaseExiste == false){ | |
| 2082 | + $db=xbase_open($dbname,2); | |
| 2083 | + } | |
| 2084 | + else{ | |
| 2085 | + $db=dbase_open($dbname,2); | |
| 2086 | + } | |
| 2080 | 2087 | $shapes = retornaShapesMapext($layerPo,$this->mapa); |
| 2081 | - foreach($shapes as $shape) | |
| 2082 | - { | |
| 2088 | + foreach($shapes as $shape){ | |
| 2083 | 2089 | $novoreg = array(); |
| 2084 | - foreach($itenspo as $ipo) | |
| 2085 | - {$novoreg[] = $shape->values[$ipo];} | |
| 2090 | + foreach($itenspo as $ipo){ | |
| 2091 | + $novoreg[] = $shape->values[$ipo]; | |
| 2092 | + } | |
| 2086 | 2093 | $layerPt->querybyshape($shape); |
| 2087 | - $novoreg[] = $layerPt->getNumresults(); | |
| 2094 | + if($somaritem != ""){ | |
| 2095 | + $soma = 0; | |
| 2096 | + $layerPt->open(); | |
| 2097 | + $res_count = $layerPt->getNumresults(); | |
| 2098 | + for ($i = 0; $i < $res_count; ++$i){ | |
| 2099 | + if($this->v == 6){ | |
| 2100 | + $s = $layerPt->getShape($layerPt->getResult($i)); | |
| 2101 | + } | |
| 2102 | + else{ | |
| 2103 | + $result = $layerPt->getResult($i); | |
| 2104 | + $shp_index = $result->shapeindex; | |
| 2105 | + $s = $layerPt->getfeature($shp_index,-1); | |
| 2106 | + } | |
| 2107 | + $soma += $s->values[$somaritem]; | |
| 2108 | + } | |
| 2109 | + $fechou = $layerPt->close(); | |
| 2110 | + $novoreg[] = $res_count; | |
| 2111 | + $novoreg[] = $soma; | |
| 2112 | + $novoreg[] = $soma / $res_count; | |
| 2113 | + } | |
| 2114 | + else{ | |
| 2115 | + $novoreg[] = $layerPt->getNumresults(); | |
| 2116 | + $novoreg[] = 0; | |
| 2117 | + $novoreg[] = 0; | |
| 2118 | + } | |
| 2088 | 2119 | $novoshpf->addShape($shape); |
| 2089 | - if($this->dbaseExiste == false) | |
| 2090 | - xbase_add_record($db,$novoreg); | |
| 2091 | - else | |
| 2092 | - dbase_add_record($db,$novoreg); | |
| 2120 | + if($this->dbaseExiste == false){ | |
| 2121 | + xbase_add_record($db,$novoreg); | |
| 2122 | + } | |
| 2123 | + else{ | |
| 2124 | + dbase_add_record($db,$novoreg); | |
| 2125 | + } | |
| 2126 | + } | |
| 2127 | + if($this->dbaseExiste == false){ | |
| 2128 | + xbase_close($db); | |
| 2129 | + } | |
| 2130 | + else{ | |
| 2131 | + dbase_close($db); | |
| 2093 | 2132 | } |
| 2094 | - if($this->dbaseExiste == false) | |
| 2095 | - xbase_close($db); | |
| 2096 | - else | |
| 2097 | - dbase_close($db); | |
| 2098 | 2133 | //adiciona o novo tema no mapa |
| 2099 | 2134 | $novolayer = criaLayer($this->mapa,MS_LAYER_POLYGON,MS_DEFAULT,"N pontos",$metaClasse="SIM",false); |
| 2100 | 2135 | $novolayer->set("data",$nomeshp.".shp"); |
| 2101 | 2136 | $novolayer->setmetadata("DOWNLOAD","SIM"); |
| 2102 | 2137 | $novolayer->setmetadata("TEMALOCAL","SIM"); |
| 2103 | 2138 | $novolayer->set("opacity","80"); |
| 2104 | - if (file_exists($this->qyfile)) | |
| 2105 | - {unlink ($this->qyfile);} | |
| 2139 | + if (file_exists($this->qyfile)){ | |
| 2140 | + unlink ($this->qyfile); | |
| 2141 | + } | |
| 2106 | 2142 | return("ok"); |
| 2107 | 2143 | } |
| 2108 | 2144 | /* | ... | ... |
ferramentas/nptpol/dicionario.js
ferramentas/nptpol/exec.php
| ... | ... | @@ -19,7 +19,7 @@ Salva o mapa acrescentando um novo layer com o resultado. |
| 19 | 19 | include_once(dirname(__FILE__)."/../../classesphp/classe_analise.php"); |
| 20 | 20 | copiaSeguranca($map_file); |
| 21 | 21 | $m = new Analise($map_file,$tema,$locaplic,$ext); |
| 22 | - $retorno = $m->nptPol($temaPt,$temaPo,$locaplic); | |
| 22 | + $retorno = $m->nptPol($temaPt,$temaPo,$locaplic,$somaritem); | |
| 23 | 23 | $m->salva(); |
| 24 | 24 | $_SESSION["contadorsalva"]++; |
| 25 | 25 | break; | ... | ... |
ferramentas/nptpol/index.js
| ... | ... | @@ -153,6 +153,10 @@ i3GEOF.nptpol = { |
| 153 | 153 | t1: function(){ |
| 154 | 154 | var ins = "<p class='paragrafo' >"+$trad(4,i3GEOF.nptpol.dicionario)+":<br>"; |
| 155 | 155 | ins += "<div style='text-align:left;' id='i3GEOnptpolDivPontos' ></div><br>"; |
| 156 | + | |
| 157 | + ins += "<p class='paragrafo' >"+$trad(8,i3GEOF.nptpol.dicionario)+":<br>"; | |
| 158 | + ins += "<div id=i3GEOnptpolondeItens style='text-align:left;display:block' >-</div><br>"; | |
| 159 | + | |
| 156 | 160 | ins += "<p class='paragrafo' >"+$trad(5,i3GEOF.nptpol.dicionario)+":<br>"; |
| 157 | 161 | ins += "<div style='text-align:left;' id='i3GEOnptpolDivPoligonos' ></div>"; |
| 158 | 162 | i3GEO.util.proximoAnterior("i3GEOF.nptpol.t0()","i3GEOF.nptpol.t2()",ins,"i3GEOF.nptpol.t1","i3GEOnptpolresultado"); |
| ... | ... | @@ -183,20 +187,22 @@ i3GEOF.nptpol = { |
| 183 | 187 | {return;} |
| 184 | 188 | i3GEOF.nptpol.aguarde.visibility = "visible"; |
| 185 | 189 | var p, |
| 186 | - cp, | |
| 187 | - fim = function(retorno){ | |
| 188 | - if (retorno.data==undefined ) | |
| 189 | - {$i("i3GEOnptpolfim").innerHTML = "<p class='paragrafo' >Erro";} | |
| 190 | - else | |
| 191 | - {i3GEO.atualiza();} | |
| 192 | - i3GEOF.nptpol.aguarde.visibility = "hidden"; | |
| 193 | - }, | |
| 194 | - ext; | |
| 190 | + cp, | |
| 191 | + somaritem = $i("i3GEOnptpoltemasItem").value, | |
| 192 | + fim = function(retorno){ | |
| 193 | + if (retorno.data==undefined ) | |
| 194 | + {$i("i3GEOnptpolfim").innerHTML = "<p class='paragrafo' >Erro";} | |
| 195 | + else | |
| 196 | + {i3GEO.atualiza();} | |
| 197 | + i3GEOF.nptpol.aguarde.visibility = "hidden"; | |
| 198 | + }, | |
| 199 | + ext; | |
| 195 | 200 | if(i3GEO.Interface.ATUAL === "googlemaps") |
| 196 | 201 | {ext = i3GEO.Interface.googlemaps.bbox();} |
| 197 | 202 | else |
| 198 | 203 | {ext = i3GEO.parametros.mapexten;} |
| 199 | 204 | p = i3GEO.configura.locaplic+"/ferramentas/nptpol/exec.php?g_sid="+i3GEO.configura.sid+"&funcao=nptPol&temaPt="+$i("i3GEOnptpolPontos").value+"&temaPo="+$i("i3GEOnptpolPoligonos").value+"&ext="+ext; |
| 205 | + p += "&somaritem="+somaritem; | |
| 200 | 206 | cp = new cpaint(); |
| 201 | 207 | cp.set_response_type("JSON"); |
| 202 | 208 | cp.call(p,"nptpol",fim); |
| ... | ... | @@ -216,15 +222,20 @@ i3GEOF.nptpol = { |
| 216 | 222 | i3GEO.util.comboTemas( |
| 217 | 223 | "i3GEOnptpolPontos", |
| 218 | 224 | function(retorno){ |
| 219 | - $i("i3GEOnptpolDivPontos").innerHTML = retorno.dados; | |
| 220 | - $i("i3GEOnptpolDivPontos").style.display = "block"; | |
| 221 | - if ($i("i3GEOnptpolPontos")){ | |
| 222 | - $i("i3GEOnptpolPontos").onchange = function(){ | |
| 223 | - i3GEO.mapa.ativaTema($i("i3GEOnptpolPontos").value); | |
| 224 | - }; | |
| 225 | + $i("i3GEOnptpolDivPontos").innerHTML = retorno.dados; | |
| 226 | + $i("i3GEOnptpolDivPontos").style.display = "block"; | |
| 227 | + if ($i("i3GEOnptpolPontos")){ | |
| 228 | + $i("i3GEOnptpolPontos").onchange = function(){ | |
| 229 | + var v = $i("i3GEOnptpolPontos").value; | |
| 230 | + i3GEO.mapa.ativaTema(v); | |
| 231 | + if(v != ""){ | |
| 232 | + i3GEOF.nptpol.comboItens(); | |
| 233 | + } | |
| 234 | + }; | |
| 225 | 235 | } |
| 226 | 236 | if(i3GEO.temaAtivo !== ""){ |
| 227 | 237 | $i("i3GEOnptpolPontos").value = i3GEO.temaAtivo; |
| 238 | + i3GEOF.nptpol.comboItens(); | |
| 228 | 239 | } |
| 229 | 240 | }, |
| 230 | 241 | "i3GEOnptpolDivPontos", |
| ... | ... | @@ -246,12 +257,12 @@ i3GEOF.nptpol = { |
| 246 | 257 | i3GEO.util.comboTemas( |
| 247 | 258 | "i3GEOnptpolPoligonos", |
| 248 | 259 | function(retorno){ |
| 249 | - $i("i3GEOnptpolDivPoligonos").innerHTML = retorno.dados; | |
| 250 | - $i("i3GEOnptpolDivPoligonos").style.display = "block"; | |
| 251 | - if ($i("i3GEOnptpolPoligonos")){ | |
| 252 | - $i("i3GEOnptpolPoligonos").onchange = function(){ | |
| 253 | - i3GEO.mapa.ativaTema($i("i3GEOnptpolPoligonos").value); | |
| 254 | - }; | |
| 260 | + $i("i3GEOnptpolDivPoligonos").innerHTML = retorno.dados; | |
| 261 | + $i("i3GEOnptpolDivPoligonos").style.display = "block"; | |
| 262 | + if ($i("i3GEOnptpolPoligonos")){ | |
| 263 | + $i("i3GEOnptpolPoligonos").onchange = function(){ | |
| 264 | + i3GEO.mapa.ativaTema($i("i3GEOnptpolPoligonos").value); | |
| 265 | + }; | |
| 255 | 266 | } |
| 256 | 267 | if(i3GEO.temaAtivo !== ""){ |
| 257 | 268 | $i("i3GEOnptpolPoligonos").value = i3GEO.temaAtivo; |
| ... | ... | @@ -262,5 +273,32 @@ i3GEOF.nptpol = { |
| 262 | 273 | false, |
| 263 | 274 | "poligonos" |
| 264 | 275 | ); |
| 276 | + }, | |
| 277 | + /* | |
| 278 | + Function: comboItens | |
| 279 | + | |
| 280 | + Cria um combo para escolha de um item do tema | |
| 281 | + | |
| 282 | + Veja: | |
| 283 | + | |
| 284 | + <i3GEO.util.comboItens> | |
| 285 | + | |
| 286 | + */ | |
| 287 | + comboItens: function(){ | |
| 288 | + var tema = $i("i3GEOnptpolPontos").value; | |
| 289 | + if(tema != ""){ | |
| 290 | + i3GEO.util.comboItens( | |
| 291 | + "i3GEOnptpoltemasItem", | |
| 292 | + tema, | |
| 293 | + function(retorno){ | |
| 294 | + $i("i3GEOnptpolondeItens").innerHTML = retorno.dados; | |
| 295 | + $i("i3GEOnptpolondeItens").style.display = "block"; | |
| 296 | + }, | |
| 297 | + "i3GEOnptpolondeItens" | |
| 298 | + ); | |
| 299 | + } | |
| 300 | + else{ | |
| 301 | + $i("i3GEOnptpolondeItens").innerHTML = "-"; | |
| 302 | + } | |
| 265 | 303 | } |
| 266 | 304 | }; |
| 267 | 305 | \ No newline at end of file | ... | ... |