Commit 9fd9dd18128a53cf0ebd79d3c037f1f304e0a2df

Authored by Edmar Moretti
1 parent ade2ba06

Inclusão opção para remover o filtro de tempo na opção de análise do sistema metaestat

admin/admin.db
No preview for this file type
admin/php/classe_metaestat.php
@@ -302,17 +302,7 @@ class Metaestat{ @@ -302,17 +302,7 @@ class Metaestat{
302 $sqlgeo = str_replace("__dadosfiltro__",$dadosfiltro,$sqlgeo); 302 $sqlgeo = str_replace("__dadosfiltro__",$dadosfiltro,$sqlgeo);
303 //join com a tabela geo 303 //join com a tabela geo
304 $j = " d.".$dados["colunaidgeo"]."::text = g.".$dadosgeo["identificador"]."::text"; 304 $j = " d.".$dados["colunaidgeo"]."::text = g.".$dadosgeo["identificador"]."::text";
305 - /*  
306 - if($filtro){  
307 - $sqlgeo .= " AND ".$j;  
308 - }  
309 - else{  
310 - $sqlgeo .= " WHERE ".$j;  
311 - }  
312 - */  
313 - //if($filtro == false){  
314 - $sqlgeo .= " WHERE ".$j;  
315 - //} 305 + $sqlgeo .= " WHERE ".$j;
316 //atencao: cuidado ao alterar essa string pois ') as foo' pode ser usado para replace em outras funcoes 306 //atencao: cuidado ao alterar essa string pois ') as foo' pode ser usado para replace em outras funcoes
317 $colunas = $this->colunasTabela($dados["codigo_estat_conexao"],$dados["esquemadb"],$dados["tabela"]); 307 $colunas = $this->colunasTabela($dados["codigo_estat_conexao"],$dados["esquemadb"],$dados["tabela"]);
318 //@TODO - agregacao com uma regiao maior 308 //@TODO - agregacao com uma regiao maior
@@ -346,15 +336,13 @@ class Metaestat{ @@ -346,15 +336,13 @@ class Metaestat{
346 $titulolayer = mb_convert_encoding($titulolayer,"ISO-8859-1",mb_detect_encoding($titulolayer)); 336 $titulolayer = mb_convert_encoding($titulolayer,"ISO-8859-1",mb_detect_encoding($titulolayer));
347 $conexao = $this->listaConexao($meta["codigo_estat_conexao"],true); 337 $conexao = $this->listaConexao($meta["codigo_estat_conexao"],true);
348 $conexao = "user=".$conexao["usuario"]." password=".$conexao["senha"]." dbname=".$conexao["bancodedados"]." host=".$conexao["host"]." port=".$conexao["porta"].""; 338 $conexao = "user=".$conexao["usuario"]." password=".$conexao["senha"]." dbname=".$conexao["bancodedados"]." host=".$conexao["host"]." port=".$conexao["porta"]."";
349 - //echo $conexao;exit;  
350 - //echo "$id_medida_variavel,$todasascolunas,$agruparpor,$tipolayer,$codigo_tipo_regiao";exit;  
351 $sql = $this->sqlMedidaVariavel($id_medida_variavel,$todasascolunas,$agruparpor,$tipolayer,$codigo_tipo_regiao); 339 $sql = $this->sqlMedidaVariavel($id_medida_variavel,$todasascolunas,$agruparpor,$tipolayer,$codigo_tipo_regiao);
352 $sqlf = $sql["sqlmapserver"]; 340 $sqlf = $sql["sqlmapserver"];
353 if(!empty($filtro)){ 341 if(!empty($filtro)){
354 $sqlf = str_replace("__filtro__"," AND ".$filtro." /*FA*//*FA*/ /*FAT*//*FAT*/",$sqlf); 342 $sqlf = str_replace("__filtro__"," AND ".$filtro." /*FA*//*FA*/ /*FAT*//*FAT*/",$sqlf);
355 } 343 }
356 else{ 344 else{
357 - $sqlf = str_replace("__filtro__","/*FW*//*FW*/ /*FWT*//*FWT*/",$sqlf); 345 + $sqlf = str_replace("__filtro__"," /*FA*//*FA*/ /*FAT*//*FAT*/",$sqlf);
358 } 346 }
359 $classes = ""; 347 $classes = "";
360 if(!empty($id_classificacao)){ 348 if(!empty($id_classificacao)){
ferramentas/metaestat/analise.php
@@ -69,6 +69,9 @@ switch (strtoupper($funcao)){ @@ -69,6 +69,9 @@ switch (strtoupper($funcao)){
69 case "APLICAFILTROTEMPO": 69 case "APLICAFILTROTEMPO":
70 $retorno = analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf); 70 $retorno = analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf);
71 break; 71 break;
  72 + case "REMOVEFILTROTEMPO":
  73 + $retorno = analise_removeFiltroTempo($map_file,$tema);
  74 + break;
72 case "LISTAFILTROTEMPO": 75 case "LISTAFILTROTEMPO":
73 $retorno = listaFiltroTempoRaiz($map_file,$nivel); 76 $retorno = listaFiltroTempoRaiz($map_file,$nivel);
74 break; 77 break;
@@ -126,7 +129,6 @@ function analise_listaCamadasFiltroTempo($map_file){ @@ -126,7 +129,6 @@ function analise_listaCamadasFiltroTempo($map_file){
126 } 129 }
127 return $camadas; 130 return $camadas;
128 } 131 }
129 -  
130 function analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf){ 132 function analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf){
131 $mapa = ms_newMapObj($map_file); 133 $mapa = ms_newMapObj($map_file);
132 $layer = $mapa->getlayerbyname($tema); 134 $layer = $mapa->getlayerbyname($tema);
@@ -152,30 +154,21 @@ function analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf){ @@ -152,30 +154,21 @@ function analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf){
152 } 154 }
153 $filtro = implode(" AND ",$filtro); 155 $filtro = implode(" AND ",$filtro);
154 //substitui as strings de filtro no mapfile 156 //substitui as strings de filtro no mapfile
155 - //verifica se o sql existente necessita de where  
156 - $where = false;  
157 - if (strpos($data, "/*FW*/") === true){  
158 - $where = true;  
159 - }  
160 - //se where for verdadeiro, verifica se ja existe o where no filtro normal  
161 - if($where == true){  
162 - if(strpos($data, "/*FW*//*FW*/") === true){  
163 - //nesse caso o where deve ir no filtro de tempo  
164 - $s = explode("/*FWT*/",$data);  
165 - $data = $s[0]."/*FWT*/ WHERE ".$filtro." /*FWT*/".$s[2];  
166 - }  
167 - else{  
168 - //nesse caso o where ja existe  
169 - $s = explode("/*FWT*/",$data);  
170 - $data = $s[0]."/*FWT*/ ".$filtro." /*FWT*/".$s[2];  
171 - }  
172 - }  
173 - else{  
174 -  
175 - }  
176 - //se where for falso, inclui o filtro de tempo normalmente  
177 -  
178 - echo $data;exit; 157 + $s = explode("/*FAT*/",$data);
  158 + $data = $s[0]."/*FAT*/ AND ".$filtro." /*FAT*/".$s[2];
  159 + $layer->set("data",$data);
  160 + $mapa->save($map_file);
  161 + return "ok";
  162 +}
  163 +function analise_removeFiltroTempo($map_file,$tema){
  164 + $mapa = ms_newMapObj($map_file);
  165 + $layer = $mapa->getlayerbyname($tema);
  166 + $data = $layer->data;
  167 + //substitui as strings de filtro no mapfile
  168 + $s = explode("/*FAT*/",$data);
  169 + $data = $s[0]."/*FAT*//*FAT*/".$s[2];
  170 + $layer->set("data",$data);
  171 + $mapa->save($map_file);
179 return "ok"; 172 return "ok";
180 } 173 }
181 function analise_listaCamadasMetaestat($map_file){ 174 function analise_listaCamadasMetaestat($map_file){
@@ -220,20 +213,6 @@ function analise_aplicafiltroregiao($map_file,$codigo_tipo_regiao,$codigo_regiao @@ -220,20 +213,6 @@ function analise_aplicafiltroregiao($map_file,$codigo_tipo_regiao,$codigo_regiao
220 $data = $s[0]."/*FA*/ AND ".$filtro." /*FA*/".$s[2]; 213 $data = $s[0]."/*FA*/ AND ".$filtro." /*FA*/".$s[2];
221 } 214 }
222 } 215 }
223 - else{  
224 - $s = explode("/*FW*/",$data);  
225 - if(count($s) > 1){  
226 - if($tipo == ""){  
227 - $data = $s[0]."/*FW*//*FW*/".$s[2];  
228 - }  
229 - else{  
230 -  
231 - $data = $s[0]."/*FW*/ WHERE ".$filtro." /*FW*/".$s[2];  
232 - //para o caso de ja existir a clausula where no filtro de tempo  
233 - $data = str_replace("/*FWT*/ WHERE ","/*FWT*/ ");  
234 - }  
235 - }  
236 - }  
237 $l->set("data",$data); 216 $l->set("data",$data);
238 } 217 }
239 } 218 }
ferramentas/metaestat/index.js
@@ -305,6 +305,7 @@ i3GEOF.metaestat = { @@ -305,6 +305,7 @@ i3GEOF.metaestat = {
305 i3GEO.php.listaValoresParametroMedidaVariavel(id_parametro_medida,temp); 305 i3GEO.php.listaValoresParametroMedidaVariavel(id_parametro_medida,temp);
306 }, 306 },
307 adicionaFiltro: function(){ 307 adicionaFiltro: function(){
  308 + i3GEO.janela.tempoMsg("O filtro de tempo não modifica as camadas que foram criadas considerando-se uma data específica");
308 var p,pini,pfim, 309 var p,pini,pfim,
309 temp = function(retorno){ 310 temp = function(retorno){
310 i3GEO.janela.fechaAguarde("aguardeAplicaFiltro"); 311 i3GEO.janela.fechaAguarde("aguardeAplicaFiltro");
@@ -330,6 +331,20 @@ i3GEOF.metaestat = { @@ -330,6 +331,20 @@ i3GEOF.metaestat = {
330 } 331 }
331 i3GEO.util.ajaxGet(p,temp); 332 i3GEO.util.ajaxGet(p,temp);
332 }, 333 },
  334 + removeFiltro: function(){
  335 + var p,
  336 + temp = function(retorno){
  337 + i3GEO.janela.fechaAguarde("aguardeAplicaFiltro");
  338 + i3GEO.Interface.atualizaMapa();
  339 + };
  340 + i3GEO.janela.AGUARDEMODAL = true;
  341 + i3GEO.janela.abreAguarde("aguardeAplicaFiltro","Aplicando...");
  342 + i3GEO.janela.AGUARDEMODAL = false;
  343 + p = i3GEO.configura.locaplic+"/ferramentas/metaestat/analise.php?funcao=removeFiltroTempo" +
  344 + "&tema="+$i("i3GEOF.filtraperiodo.comboCamada").value +
  345 + "&g_sid="+i3GEO.configura.sid;
  346 + i3GEO.util.ajaxGet(p,temp);
  347 + },
333 pegaParametros:function(id){ 348 pegaParametros:function(id){
334 var c = $i(id).getElementsByTagName("select"), 349 var c = $i(id).getElementsByTagName("select"),
335 n = c.length, 350 n = c.length,