Commit d9c89cf3775b69c066b1dcc440b3734c875df586

Authored by Edmar Moretti
1 parent c53f9f28

$1

admin/admin.db
No preview for this file type
classesphp/classe_analise.php
@@ -2041,7 +2041,7 @@ $temaPo - Tema poligonal. @@ -2041,7 +2041,7 @@ $temaPo - Tema poligonal.
2041 2041
2042 $locaplic - Localização do I3geo 2042 $locaplic - Localização do I3geo
2043 */ 2043 */
2044 - function nptPol($temaPt,$temaPo,$locaplic) 2044 + function nptPol($temaPt,$temaPo,$locaplic,$somaritem="")
2045 { 2045 {
2046 //error_reporting(0); 2046 //error_reporting(0);
2047 set_time_limit(180); 2047 set_time_limit(180);
@@ -2064,45 +2064,81 @@ $locaplic - Localização do I3geo @@ -2064,45 +2064,81 @@ $locaplic - Localização do I3geo
2064 $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON); 2064 $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON);
2065 // cria o dbf 2065 // cria o dbf
2066 $def = array(); 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 $def[] = array("npontos","N","10","0"); 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 //acrescenta os pontos no novo shapefile 2079 //acrescenta os pontos no novo shapefile
2075 $dbname = $nomeshp.".dbf"; 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 $shapes = retornaShapesMapext($layerPo,$this->mapa); 2087 $shapes = retornaShapesMapext($layerPo,$this->mapa);
2081 - foreach($shapes as $shape)  
2082 - { 2088 + foreach($shapes as $shape){
2083 $novoreg = array(); 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 $layerPt->querybyshape($shape); 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 $novoshpf->addShape($shape); 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 //adiciona o novo tema no mapa 2133 //adiciona o novo tema no mapa
2099 $novolayer = criaLayer($this->mapa,MS_LAYER_POLYGON,MS_DEFAULT,"N pontos",$metaClasse="SIM",false); 2134 $novolayer = criaLayer($this->mapa,MS_LAYER_POLYGON,MS_DEFAULT,"N pontos",$metaClasse="SIM",false);
2100 $novolayer->set("data",$nomeshp.".shp"); 2135 $novolayer->set("data",$nomeshp.".shp");
2101 $novolayer->setmetadata("DOWNLOAD","SIM"); 2136 $novolayer->setmetadata("DOWNLOAD","SIM");
2102 $novolayer->setmetadata("TEMALOCAL","SIM"); 2137 $novolayer->setmetadata("TEMALOCAL","SIM");
2103 $novolayer->set("opacity","80"); 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 return("ok"); 2142 return("ok");
2107 } 2143 }
2108 /* 2144 /*
ferramentas/nptpol/dicionario.js
@@ -41,5 +41,11 @@ pt:&quot;Calcular&quot;, @@ -41,5 +41,11 @@ pt:&quot;Calcular&quot;,
41 en:"", 41 en:"",
42 es:"", 42 es:"",
43 it:"" 43 it:""
  44 +}],
  45 +8: [{
  46 +pt:"(Opcional) Item da tabela que ser&aacute; somado",
  47 +en:"",
  48 +es:"",
  49 +it:""
44 }] 50 }]
45 }; 51 };
46 \ No newline at end of file 52 \ No newline at end of file
ferramentas/nptpol/exec.php
@@ -19,7 +19,7 @@ Salva o mapa acrescentando um novo layer com o resultado. @@ -19,7 +19,7 @@ Salva o mapa acrescentando um novo layer com o resultado.
19 include_once(dirname(__FILE__)."/../../classesphp/classe_analise.php"); 19 include_once(dirname(__FILE__)."/../../classesphp/classe_analise.php");
20 copiaSeguranca($map_file); 20 copiaSeguranca($map_file);
21 $m = new Analise($map_file,$tema,$locaplic,$ext); 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 $m->salva(); 23 $m->salva();
24 $_SESSION["contadorsalva"]++; 24 $_SESSION["contadorsalva"]++;
25 break; 25 break;
ferramentas/nptpol/index.js
@@ -153,6 +153,10 @@ i3GEOF.nptpol = { @@ -153,6 +153,10 @@ i3GEOF.nptpol = {
153 t1: function(){ 153 t1: function(){
154 var ins = "<p class='paragrafo' >"+$trad(4,i3GEOF.nptpol.dicionario)+":<br>"; 154 var ins = "<p class='paragrafo' >"+$trad(4,i3GEOF.nptpol.dicionario)+":<br>";
155 ins += "<div style='text-align:left;' id='i3GEOnptpolDivPontos' ></div><br>"; 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 ins += "<p class='paragrafo' >"+$trad(5,i3GEOF.nptpol.dicionario)+":<br>"; 160 ins += "<p class='paragrafo' >"+$trad(5,i3GEOF.nptpol.dicionario)+":<br>";
157 ins += "<div style='text-align:left;' id='i3GEOnptpolDivPoligonos' ></div>"; 161 ins += "<div style='text-align:left;' id='i3GEOnptpolDivPoligonos' ></div>";
158 i3GEO.util.proximoAnterior("i3GEOF.nptpol.t0()","i3GEOF.nptpol.t2()",ins,"i3GEOF.nptpol.t1","i3GEOnptpolresultado"); 162 i3GEO.util.proximoAnterior("i3GEOF.nptpol.t0()","i3GEOF.nptpol.t2()",ins,"i3GEOF.nptpol.t1","i3GEOnptpolresultado");
@@ -183,20 +187,22 @@ i3GEOF.nptpol = { @@ -183,20 +187,22 @@ i3GEOF.nptpol = {
183 {return;} 187 {return;}
184 i3GEOF.nptpol.aguarde.visibility = "visible"; 188 i3GEOF.nptpol.aguarde.visibility = "visible";
185 var p, 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 if(i3GEO.Interface.ATUAL === "googlemaps") 200 if(i3GEO.Interface.ATUAL === "googlemaps")
196 {ext = i3GEO.Interface.googlemaps.bbox();} 201 {ext = i3GEO.Interface.googlemaps.bbox();}
197 else 202 else
198 {ext = i3GEO.parametros.mapexten;} 203 {ext = i3GEO.parametros.mapexten;}
199 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; 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 cp = new cpaint(); 206 cp = new cpaint();
201 cp.set_response_type("JSON"); 207 cp.set_response_type("JSON");
202 cp.call(p,"nptpol",fim); 208 cp.call(p,"nptpol",fim);
@@ -216,15 +222,20 @@ i3GEOF.nptpol = { @@ -216,15 +222,20 @@ i3GEOF.nptpol = {
216 i3GEO.util.comboTemas( 222 i3GEO.util.comboTemas(
217 "i3GEOnptpolPontos", 223 "i3GEOnptpolPontos",
218 function(retorno){ 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 if(i3GEO.temaAtivo !== ""){ 236 if(i3GEO.temaAtivo !== ""){
227 $i("i3GEOnptpolPontos").value = i3GEO.temaAtivo; 237 $i("i3GEOnptpolPontos").value = i3GEO.temaAtivo;
  238 + i3GEOF.nptpol.comboItens();
228 } 239 }
229 }, 240 },
230 "i3GEOnptpolDivPontos", 241 "i3GEOnptpolDivPontos",
@@ -246,12 +257,12 @@ i3GEOF.nptpol = { @@ -246,12 +257,12 @@ i3GEOF.nptpol = {
246 i3GEO.util.comboTemas( 257 i3GEO.util.comboTemas(
247 "i3GEOnptpolPoligonos", 258 "i3GEOnptpolPoligonos",
248 function(retorno){ 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 if(i3GEO.temaAtivo !== ""){ 267 if(i3GEO.temaAtivo !== ""){
257 $i("i3GEOnptpolPoligonos").value = i3GEO.temaAtivo; 268 $i("i3GEOnptpolPoligonos").value = i3GEO.temaAtivo;
@@ -262,5 +273,32 @@ i3GEOF.nptpol = { @@ -262,5 +273,32 @@ i3GEOF.nptpol = {
262 false, 273 false,
263 "poligonos" 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 \ No newline at end of file 305 \ No newline at end of file