Commit ade2ba06e62211ab44a8ed6c59fed66a73f3d859

Authored by Edmar Moretti
1 parent a750af35

Inclusão de 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
... ... @@ -275,15 +275,21 @@ class Metaestat{
275 275 $dadosAgregacao = $this->listaAgregaRegiaoFilho($dados["codigo_tipo_regiao"], $codigo_tipo_regiao);
276 276 $sqlgeo = "g.".$dadosAgregacao["colunaligacao_regiaopai"].",sum(d.".$dados["colunavalor"].") as ".$dados["colunavalor"];
277 277 }
278   - //TODO decidir se e soma ou media
  278 + $tipoconta = "";
  279 + if($dados["permitesoma"] == 1){
  280 + $tipoconta = "sum";
  281 + }
  282 + elseif($dados["permitemedia"] == 1){
  283 + $tipoconta = "mean";
  284 + }
279 285 if(empty($agruparpor)){
280 286 $sql .= " FROM ".$dados["esquemadb"].".".$dados["tabela"]." as d ";
281 287 $sqlgeo .= " FROM ".$dados["esquemadb"].".".$dados["tabela"]." as d,".$dadosgeo["esquemadb"].".".$dadosgeo["tabela"]." as g ";
282 288 }
283 289 else{
284 290 $sqlagrupamento = " SELECT d.".$agruparpor." FROM ".$dados["esquemadb"].".".$dados["tabela"]." as d group by ".$agruparpor." order by ".$agruparpor;
285   - $sqlgeo .= " FROM (SELECT sum(".$dados["colunavalor"].") as ".$dados["colunavalor"].",".$dados["colunaidgeo"].",".$agruparpor." FROM ".$dados["esquemadb"].".".$dados["tabela"] ." __dadosfiltro__ group by ".$agruparpor.",".$dados["colunaidgeo"].") as d, ".$dadosgeo["esquemadb"].".".$dadosgeo["tabela"]." as g";
286   - $sql .= " FROM (SELECT sum(".$dados["colunavalor"].") as ".$dados["colunavalor"].",".$dados["colunaidgeo"].",".$agruparpor." FROM ".$dados["esquemadb"].".".$dados["tabela"] ." __dadosfiltro__ group by ".$agruparpor.",".$dados["colunaidgeo"].") as d ";
  291 + $sqlgeo .= " FROM (SELECT $tipoconta(".$dados["colunavalor"].") as ".$dados["colunavalor"].",".$dados["colunaidgeo"].",".$agruparpor." FROM ".$dados["esquemadb"].".".$dados["tabela"] ." __dadosfiltro__ group by ".$agruparpor.",".$dados["colunaidgeo"].") as d, ".$dadosgeo["esquemadb"].".".$dadosgeo["tabela"]." as g";
  292 + $sql .= " FROM (SELECT $tipoconta(".$dados["colunavalor"].") as ".$dados["colunavalor"].",".$dados["colunaidgeo"].",".$agruparpor." FROM ".$dados["esquemadb"].".".$dados["tabela"] ." __dadosfiltro__ group by ".$agruparpor.",".$dados["colunaidgeo"].") as d ";
287 293 }
288 294 $dadosfiltro = "";
289 295 if(!empty($dados["filtro"])){
... ... @@ -324,8 +330,10 @@ class Metaestat{
324 330 //indicando onde deve comecar e terminar uma possivel clausula where
325 331 //ou com /*FA*//*FA*/
326 332 //para marcar que deve ser utilizado AND ao adicionar o filtro
  333 + //utiliza-se da mesma forma /*FAT*//*FAT*/ e /*FWT*//*FWT*/ para os filtros de tempo
327 334 //Layers adicionados aqui sao marcados com o metadata METAESTAT "SIM"
328 335 //O codigo_tipo_regiao e marcado com o metadata METAESTAT_CODIGO_TIPO_REGIAO
  336 + //O id da medida da variavel e marcado com o metadata ID_MEDIDA_VARIAVEL
329 337 $arq = $this->dir_tmp."/".$this->nomecache.".map";
330 338 if(!file_exists($arq)){
331 339 if(empty($tipolayer)){
... ... @@ -343,10 +351,10 @@ class Metaestat{
343 351 $sql = $this->sqlMedidaVariavel($id_medida_variavel,$todasascolunas,$agruparpor,$tipolayer,$codigo_tipo_regiao);
344 352 $sqlf = $sql["sqlmapserver"];
345 353 if(!empty($filtro)){
346   - $sqlf = str_replace("__filtro__"," AND ".$filtro." /*FA*//*FA*/",$sqlf);
  354 + $sqlf = str_replace("__filtro__"," AND ".$filtro." /*FA*//*FA*/ /*FAT*//*FAT*/",$sqlf);
347 355 }
348 356 else{
349   - $sqlf = str_replace("__filtro__","/*FW*//*FW*/",$sqlf);
  357 + $sqlf = str_replace("__filtro__","/*FW*//*FW*/ /*FWT*//*FWT*/",$sqlf);
350 358 }
351 359 $classes = "";
352 360 if(!empty($id_classificacao)){
... ... @@ -368,6 +376,7 @@ class Metaestat{
368 376 $dados[] = ' CLASSE "SIM"';
369 377 $dados[] = ' METAESTAT "SIM"';
370 378 $dados[] = ' METAESTAT_CODIGO_TIPO_REGIAO "'.$codigo_tipo_regiao.'"';
  379 + $dados[] = ' ID_MEDIDA_VARIAVEL "'.$id_medida_variavel.'"';
371 380 $dados[] = ' END';
372 381 if($classes == ""){
373 382 $dados[] = ' CLASS';
... ... @@ -426,7 +435,6 @@ class Metaestat{
426 435 $conexao = "user=".$conexao["usuario"]." password=".$conexao["senha"]." dbname=".$conexao["bancodedados"]." host=".$conexao["host"]." port=".$conexao["porta"]."";
427 436 $sqlf = $meta["colunageo"]." from (select * from ".$meta["esquemadb"].".".$meta["tabela"]." /*FW*//*FW*/) as foo using unique gid using srid=".$meta["srid"];
428 437  
429   - //FIXME calcular versao do symbolset
430 438 $dados[] = "MAP";
431 439 $dados[] = 'SYMBOLSET "'.$this->locaplic.'/symbols/simbolosv6.sym"';
432 440 $dados[] = 'FONTSET "'.$this->locaplic.'/symbols/fontes.txt"';
... ...
classesjs/classe_php.js
... ... @@ -71,7 +71,7 @@ do arquivo correspondente ao mapfile atualmente em uso
71 71 Quando classe_php.js é carregado, é criado o objeto cpJSON que necessita da biblioteca CPAINT. Esse objeto
72 72 é utilizado nas chamadas AJAX.
73 73  
74   -O objeto cpJSON possuí um método .call que executa a operação AJAX. Esse método utiliza basicamente dois parâmetros,
  74 +O objeto cpJSON possuí um método .call que executa a operação AJAX. Esse método utiliza basicamente dois parametros,
75 75 sendo o primeiro o endereço do programa PHP que será executado no servidor e o outro é o nome da função que irá
76 76 receber e processar os resultados do programa. Exemplo:
77 77  
... ... @@ -430,7 +430,7 @@ i3GEO.php = {
430 430 */
431 431 mudatamanho: function(funcao,altura,largura){
432 432 i3GEO.php.verifica();
433   - var p = i3GEO.configura.locaplic+"/ferrametas/opcoes_tamanho/exec.php",
  433 + var p = i3GEO.configura.locaplic+"/ferramentas/opcoes_tamanho/exec.php",
434 434 par = "funcao=mudatamanho&altura="+altura+"&largura="+largura+"&g_sid="+i3GEO.configura.sid,
435 435 retorno = function(retorno){
436 436 i3GEO.janela.fechaAguarde("mudatamanho");
... ...
classesjs/classe_util.js
... ... @@ -1854,7 +1854,7 @@ i3GEO.util = {
1854 1854 }
1855 1855 else
1856 1856 {temp = {dados:'<div class=erro >Ocorreu um erro</erro>',tipo:"erro"};}
1857   - funcao.apply(funcao,temp);
  1857 + funcao.call(temp);
1858 1858 };
1859 1859 i3GEO.php.listaValoresItensTema(monta,tema,itemTema);
1860 1860 },
... ... @@ -1960,7 +1960,7 @@ i3GEO.util = {
1960 1960 }
1961 1961 else
1962 1962 {temp = {dados:'<div class=erro >Ocorreu um erro</div>',tipo:"erro"};}
1963   - funcao.apply(funcao,temp);
  1963 + funcao.call(this,temp);
1964 1964 };
1965 1965 i3GEO.php.listaItensTema(monta,tema);
1966 1966 },
... ...
classesphp/classe_atributos.php
... ... @@ -349,8 +349,7 @@ class Atributos
349 349 if(!$this->layer){
350 350 return "erro";
351 351 }
352   - if($this->v < 6)
353   - {
  352 + if($this->v < 6){
354 353 $dadosDaClasse="nao";
355 354 }
356 355 $resultadoFinal = array();
... ... @@ -364,23 +363,20 @@ class Atributos
364 363 $fim = "";
365 364 }
366 365 //se tipo for igual a brasil, define a extens&atilde;o geogr&aacute;fica total
367   - if ($tipo == "brasil")
368   - {
  366 + if ($tipo == "brasil"){
369 367 $this->mapa = extPadrao($this->mapa);
370 368 }
371 369 $this->layer->set("template","none.htm");
372 370 $this->layer->setfilter("");
373   - if ($this->layer->data == "")
374   - {
  371 + if ($this->layer->data == ""){
375 372 return "erro. O tema n&atilde;o tem tabela";
376 373 }
377 374 //pega os valores
378   - if ((!isset($itemtema)) || ($itemtema == ""))
379   - {
  375 + if ((!isset($itemtema)) || ($itemtema == "")){
380 376 $items = pegaItens($this->layer,$this->mapa);
381 377 }
382   - else
383   - {$items[] = $itemtema;
  378 + else{
  379 + $items[] = $itemtema;
384 380 }
385 381 //pega os alias definidos no metadata itensdesc
386 382 if($this->layer->getmetadata("itensdesc") != ""){
... ... @@ -388,21 +384,19 @@ class Atributos
388 384 $aliasdesc = explode(",",$this->layer->getmetadata("itensdesc"));
389 385 $aliasitens = explode(",",$this->layer->getmetadata("itens"));
390 386 $aliasc = array_combine($aliasitens,$aliasdesc);
391   - if(strtoupper($this->layer->getmetadata("convcaracter")) == "NAO")
392   - {
  387 + if(strtoupper($this->layer->getmetadata("convcaracter")) == "NAO"){
393 388 $convC = false;
394 389 }
395   - else
396   - {$convC = true;
  390 + else{
  391 + $convC = true;
397 392 }
398 393 foreach($items as $i){
399 394 if($aliasc[$i]){
400   - if($convC)
401   - {
  395 + if($convC){
402 396 $alias[] = $this->converte($aliasc[$i]);
403 397 }
404   - else
405   - {$alias[] = $aliasc[$i];
  398 + else{
  399 + $alias[] = $aliasc[$i];
406 400 }
407 401 }
408 402 else{
... ... @@ -418,32 +412,25 @@ class Atributos
418 412 $res_count = count($shapes);
419 413 $registros = array();
420 414 //lista apenas os selecionados
421   - if(strtoupper($this->layer->getmetadata("convcaracter")) == "NAO")
422   - {
  415 + if(strtoupper($this->layer->getmetadata("convcaracter")) == "NAO"){
423 416 $convC = false;
424 417 }
425   - else
426   - {$convC = true;
  418 + else{
  419 + $convC = true;
427 420 }
428   - if ($tipolista == "selecionados")
429   - {
  421 + if ($tipolista == "selecionados"){
430 422 $chk = "CHECKED";
431   - if ($fim != "")
432   - {
433   - if (($res_count >= $fim) && ($fim < $res_count))
434   - {
  423 + if ($fim != ""){
  424 + if (($res_count >= $fim) && ($fim < $res_count)){
435 425 $res_count = $fim;
436 426 }
437 427 }
438   - for ($i = $inicio; $i < $res_count; ++$i)
439   - {
  428 + for ($i = $inicio; $i < $res_count; ++$i){
440 429 $valitem = array();
441 430 $shape = $shapes[$i];
442   - foreach ($items as $item)
443   - {
  431 + foreach ($items as $item){
444 432 $valori = trim($shape->values[$item]);
445   - if($convC == true)
446   - {
  433 + if($convC == true){
447 434 $valori = $this->converte($valori);
448 435 }
449 436 $valitem[] = array("item"=>$item,"valor"=>$valori);
... ... @@ -457,26 +444,22 @@ class Atributos
457 444 "nome"=>$nome
458 445 );
459 446 }
  447 +
460 448 $registros[] = array("indice"=>$indx,"valores"=>$valitem,"status"=>$chk,"classe"=>$classe);
461 449 }
462 450 $resultadoFinal[] = array("registros"=>$registros);
463 451 }
464   - if ($tipolista == "tudo")
465   - {
  452 + if ($tipolista == "tudo"){
466 453 //ini_set('memory_limit', '500M');
467 454 $shp_atual = array();
468   - for ($i = 0; $i < $res_count;++$i)
469   - {
  455 + for ($i = 0; $i < $res_count;++$i){
470 456 $shp_atual[$i] = $shapes[$i];;
471 457 }
472 458 $chk = "";
473   - if (@$this->layer->queryByrect($this->mapa->extent) == MS_SUCCESS)
474   - {
  459 + if (@$this->layer->queryByrect($this->mapa->extent) == MS_SUCCESS){
475 460 $res_count = $this->layer->getNumresults();
476   - if ($fim != "")
477   - {
478   - if (($res_count >= $fim) && ($fim < $res_count))
479   - {
  461 + if ($fim != ""){
  462 + if (($res_count >= $fim) && ($fim < $res_count)){
480 463 $res_count = $fim;
481 464 }
482 465 }
... ... @@ -484,8 +467,8 @@ class Atributos
484 467 if($sopen == MS_FAILURE){
485 468 return "erro";
486 469 }
487   - for ($i = $inicio; $i < $res_count; ++$i)
488   - {
  470 + $valoresunicos = array();
  471 + for ($i = $inicio; $i < $res_count; ++$i){
489 472 $valitem = array();
490 473 if($this->v == 6){
491 474 $shape = $this->layer->getShape($this->layer->getResult($i));
... ... @@ -496,26 +479,31 @@ class Atributos
496 479 $indx = $result->shapeindex;
497 480 $shape = $this->layer->getfeature($indx,-1);
498 481 }
499   - foreach ($items as $item)
500   - {
  482 +
  483 + foreach ($items as $item){
501 484 $valori = "";
502   - if(@$shape->values[$item])
503   - {
  485 + if(@$shape->values[$item]){
504 486 $valori = ($shape->values[$item]);
505 487 }
506   - if($convC == true)
507   - {
  488 + if($convC == true){
508 489 $valori = $this->converte($valori);
509 490 }
510   - $valitem[] = array("item"=>$item,"valor"=>$valori);
  491 + if($unico == "sim"){
  492 + if(!in_array($valori,$valoresunicos)){
  493 + $valitem[] = array("item"=>$item,"valor"=>$valori);
  494 + }
  495 + $valoresunicos[] = $valori;
  496 + }
  497 + else{
  498 + $valitem[] = array("item"=>$item,"valor"=>$valori);
  499 + }
511 500 }
512 501 //if (in_array($shp_index,$shp_atual))
513   - if(isset($shp_atual[$indx]))
514   - {
  502 + if(isset($shp_atual[$indx])){
515 503 $chk = "CHECKED";
516 504 }
517 505 $classe = "";
518   - if($dadosDaClasse == "sim"){
  506 + if($dadosDaClasse == "sim" && $unico != "sim"){
519 507 $indice = $this->layer->getClassIndex($shape);
520 508 $nome = $this->layer->getclass($indice)->name;
521 509 $classe = array(
... ... @@ -523,7 +511,9 @@ class Atributos
523 511 "nome"=>$nome
524 512 );
525 513 }
526   - $registros[] = array("indice"=>$indx,"valores"=>$valitem,"status"=>$chk,"classe"=>$classe);
  514 + if(count($valitem) > 0){
  515 + $registros[] = array("indice"=>$indx,"valores"=>$valitem,"status"=>$chk,"classe"=>$classe);
  516 + }
527 517 $chk = "";
528 518 }
529 519 $this->layer->close();
... ...
classesphp/mapa_controle.php
... ... @@ -1674,6 +1674,7 @@ Pega todos os valores dos itens de uma tabela de um tema.
1674 1674 if(!isset($fim)){$fim = "";}
1675 1675 if(!isset($tipolista)){$tipolista = "";}
1676 1676 if(!isset($itemtema)){$itemtema = "";}
  1677 + if(!isset($unico)){$unico = "";}
1677 1678 $legenda = "";
1678 1679 if(!isset($dadosDaClasse)){$dadosDaClasse = "nao";}
1679 1680 else{
... ... @@ -1686,7 +1687,7 @@ Pega todos os valores dos itens de uma tabela de um tema.
1686 1687 }
1687 1688 }
1688 1689 }
1689   - $retorno = $m->listaRegistros($itemtema,$tipo,"",$inicio,$fim,$tipolista,$dadosDaClasse);
  1690 + $retorno = $m->listaRegistros($itemtema,$tipo,$unico,$inicio,$fim,$tipolista,$dadosDaClasse);
1690 1691 $retorno["legenda"] = $legenda;
1691 1692 break;
1692 1693 /*
... ...
ferramentas/filtro/index.js
... ... @@ -254,7 +254,7 @@ i3GEOF.filtro = {
254 254 i3GEO.temaAtivo,
255 255 itemTema,
256 256 function(retorno){
257   - $i("i3GEOfiltrovalores").innerHTML = "<br><p class=paragrafo >Escolha o valor:"+retorno.dados+"</p>";
  257 + $i("i3GEOfiltrovalores").innerHTML = "<br><p class=paragrafo >Escolha o valor:"+this.dados+"</p>";
258 258 if ($i("i3GEOfiltrocbitens")){
259 259 $i("i3GEOfiltrocbitens").onchange = function()
260 260 {obj.value = this.value;};
... ...
ferramentas/metaestat/analise.php
... ... @@ -62,6 +62,15 @@ switch (strtoupper($funcao)){
62 62 break;
63 63 case "LISTACAMADASMETAESTAT":
64 64 $retorno = analise_listaCamadasMetaestat($map_file);
  65 + break;
  66 + case "LISTACAMADASFILTROTEMPO":
  67 + $retorno = analise_listaCamadasFiltroTempo($map_file);
  68 + break;
  69 + case "APLICAFILTROTEMPO":
  70 + $retorno = analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf);
  71 + break;
  72 + case "LISTAFILTROTEMPO":
  73 + $retorno = listaFiltroTempoRaiz($map_file,$nivel);
65 74 break;
66 75 }
67 76 if (!connection_aborted()){
... ... @@ -69,6 +78,106 @@ if (!connection_aborted()){
69 78 }
70 79 else
71 80 {exit();}
  81 +function listaFiltroTempoRaiz($map_file,$nivel){
  82 + $mapa = ms_newMapObj($map_file);
  83 + $layers = analise_listaLayersMetaestat($mapa);
  84 + $m = new Metaestat();
  85 + //pega os parametros de tempo
  86 + $filtros = array();
  87 + foreach($layers as $l){
  88 + $id_medida_variavel = $l->getmetadata("ID_MEDIDA_VARIAVEL");
  89 + if($id_medida_variavel != ""){
  90 + //pega os parametros que sao do tipo tempo (1, 2, e 3)
  91 + $parametros = $m->listaParametro($id_medida_variavel);
  92 + foreach($parametros as $parametro){
  93 + $id_parametro_medida_pai = "";
  94 + if($parametro["id_pai"] == $nivel && $parametro["tipo"] > 0 && $parametro["tipo"] < 4){
  95 + $filtros[] = $parametro;
  96 + }
  97 + }
  98 + }
  99 + }
  100 + return $filtros;
  101 +}
  102 +
  103 +//lista as camadas que possuem filtro temporais
  104 +function analise_listaCamadasFiltroTempo($map_file){
  105 + $mapa = ms_newMapObj($map_file);
  106 + $layers = analise_listaLayersMetaestat($mapa);
  107 + $m = new Metaestat();
  108 + //pega os parametros de tempo
  109 + $camadas = array();
  110 + foreach($layers as $l){
  111 + $id_medida_variavel = $l->getmetadata("ID_MEDIDA_VARIAVEL");
  112 + if($id_medida_variavel != ""){
  113 + //pega os parametros que sao do tipo tempo (1, 2, e 3)
  114 + $parametros = $m->listaParametro($id_medida_variavel);
  115 + foreach($parametros as $parametro){
  116 + $id_parametro_medida_pai = "";
  117 + if($parametro["id_pai"] == 0 && $parametro["tipo"] > 0 && $parametro["tipo"] < 4){
  118 + $camadas[] = array(
  119 + "layer"=>$l->name,
  120 + "nome"=>(mb_convert_encoding(($l->getmetadata("tema")),"UTF-8","ISO-8859-1"))
  121 + );
  122 + break;
  123 + }
  124 + }
  125 + }
  126 + }
  127 + return $camadas;
  128 +}
  129 +
  130 +function analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf){
  131 + $mapa = ms_newMapObj($map_file);
  132 + $layer = $mapa->getlayerbyname($tema);
  133 + $id_medida_variavel = $layer->getmetadata("ID_MEDIDA_VARIAVEL");
  134 + $data = $layer->data;
  135 + $m = new Metaestat();
  136 + //pega os parametros de tempo inicial
  137 + $par = explode(",",$pari);
  138 + $val = explode(",",$vali);
  139 + $filtro = array();
  140 + $n = count($par);
  141 + for($i=0;$i<$n;$i++){
  142 + $parametro = $m->listaParametro($id_medida_variavel,$par[$i]);
  143 + $filtro[] = "d.".$parametro["coluna"]." >= ".$val[$i]." ";
  144 + }
  145 + //pega os parametros de tempo final
  146 + $par = explode(",",$parf);
  147 + $val = explode(",",$valf);
  148 + $n = count($par);
  149 + for($i=0;$i<$n;$i++){
  150 + $parametro = $m->listaParametro($id_medida_variavel,$par[$i]);
  151 + $filtro[] = "d.".$parametro["coluna"]." <= ".$val[$i]." ";
  152 + }
  153 + $filtro = implode(" AND ",$filtro);
  154 + //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;
  179 + return "ok";
  180 +}
72 181 function analise_listaCamadasMetaestat($map_file){
73 182 $mapa = ms_newMapObj($map_file);
74 183 $layers = analise_listaLayersMetaestat($mapa);
... ... @@ -79,14 +188,17 @@ function analise_listaCamadasMetaestat($map_file){
79 188 return $camadas;
80 189 }
81 190 //se $tipo for igual a "" remove os filtros
82   -function analise_aplicafiltroregiao($map_file,$codigo_tipo_regiao,$codigo_regiao,$codigo_tipo_regiao_pai,$codigo_regiao_pai,$tipo){
  191 +function analise_aplicafiltroregiao($map_file,$codigo_tipo_regiao,$codigo_regiao,$codigo_tipo_regiao_pai,$codigo_regiao_pai,$tipo=""){
83 192 $mapa = ms_newMapObj($map_file);
84 193 $layers = analise_listaLayersMetaestat($mapa);
85   - $layers = analise_listaLayersRegiao($layers,$codigo_tipo_regiao);
  194 + if($codigo_tipo_regiao != ""){
  195 + $layers = analise_listaLayersRegiao($layers,$codigo_tipo_regiao);
  196 + }
86 197 if(count($layers) > 0){
87 198 $m = new Metaestat();
88 199 $regiao = $m->listaTipoRegiao($codigo_tipo_regiao);
89 200 //aplica o filtro considerando os codigos que definem a propria regiao
  201 + $filtro = "";
90 202 if($tipo == "regiaoatual"){
91 203 $filtro = $regiao["esquemadb"].".".$regiao["tabela"].".".$regiao["identificador"]."::text = '$codigo_regiao'";
92 204 }
... ... @@ -94,7 +206,7 @@ function analise_aplicafiltroregiao($map_file,$codigo_tipo_regiao,$codigo_regiao
94 206 //$filtro = $regiao["esquemadb"].".".$regiao["tabela"].".".$regiao["identificador"]."::text = '$codigo_regiao'";
95 207 $pai = $m->listaAgregaRegiaoFilho($codigo_tipo_regiao,$codigo_tipo_regiao_pai);
96 208 //var_dump($pai);exit;
97   - $filtro = $regiao["esquemadb"].".".$regiao["tabela"].".".$pai["colunaligacao_regiaopai"]."::text = '$codigo_regiao_pai'";
  209 + $filtro = "g.".$pai["colunaligacao_regiaopai"]."::text = '$codigo_regiao_pai'";
98 210 }
99 211 foreach($layers as $l){
100 212 $data = $l->data;
... ... @@ -115,7 +227,10 @@ function analise_aplicafiltroregiao($map_file,$codigo_tipo_regiao,$codigo_regiao
115 227 $data = $s[0]."/*FW*//*FW*/".$s[2];
116 228 }
117 229 else{
118   - $data = $s[0]."/*FW*/ WHERE ".$filtro." /*FW*/".$s[2];
  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*/ ");
119 234 }
120 235 }
121 236 }
... ...
ferramentas/metaestat/index.js
... ... @@ -35,6 +35,7 @@ if(typeof(i3GEOF) === &#39;undefined&#39;){
35 35  
36 36 Gerencia os componentes do m&oacute;dulo de gera&ccedil;&atilde;o de cartogramas estat&iacute;sticos
37 37 */
  38 +//TODO traduzir
38 39 i3GEOF.metaestat = {
39 40 /**
40 41 * Tipo de interface utilizada para construcao dos parametros
... ... @@ -113,11 +114,11 @@ i3GEOF.metaestat = {
113 114 imagemxy = i3GEO.util.pegaPosicaoObjeto($i(i3GEO.Interface.IDCORPO));
114 115 janela.moveTo(imagemxy[0]+(i3GEOF.metaestat.LEFT*2)+i3GEOF.metaestat.LARGURA+10,i3GEOF.metaestat.TOP);
115 116 },
116   - //TODO traduzir
117 117 html: function(){
118 118 var ins = '<div id="i3geoCartoAnaliseContainer" style="margin-left:5px;line-height:25px">' +
119 119 ' <button title="Localizar regi&atilde;o" onclick="i3GEO.mapa.dialogo.locregiao()"><img src="'+i3GEO.configura.locaplic+'/imagens/gisicons/open-street-maps.png" /></button>' +
120 120 ' <button title="Filtrar regi&atilde;o" onclick="i3GEO.mapa.dialogo.filtraregiao()"><img src="'+i3GEO.configura.locaplic+'/imagens/gisicons/open-street-maps-filtro.png" /></button>' +
  121 + ' <button title="Filtrar per&iacute;odo" onclick="i3GEOF.metaestat.analise.filtraPeriodo.inicia()"><img src="'+i3GEO.configura.locaplic+'/imagens/gisicons/open-street-maps-filtrotime.png" /></button>' +
121 122 ' <button title="Tabela com os dados" onclick="i3GEO.tema.dialogo.tabela()"><img src="'+i3GEO.configura.locaplic+'/imagens/gisicons/table.png" /></button>' +
122 123 ' <button title="Gr&aacute;fico interativo" onclick="i3GEO.analise.dialogo.graficoInterativo()"><img src="'+i3GEO.configura.locaplic+'/imagens/oxygen/22x22/view_statistics.png" /></button>' +
123 124 ' <button title="Opacidade" onclick="i3GEO.mapa.dialogo.opacidade()"><img src="'+i3GEO.configura.locaplic+'/imagens/gisicons/layer-opacity.png" /></button>' +
... ... @@ -149,7 +150,7 @@ i3GEOF.metaestat = {
149 150 };
150 151 i3GEO.php.listaCamadasMetaestat(temp);
151 152 },
152   - ativaGuiaLegenda: function(){
  153 + ativaEditorLegenda: function(){
153 154 if(i3GEO.temaAtivo == ""){
154 155 i3GEO.janela.tempoMsg("Nenhum tema est&aacute; ativo. Escolha um e depois clique na guia <b>Classes</b>");
155 156 }
... ... @@ -157,7 +158,7 @@ i3GEOF.metaestat = {
157 158 i3GEO.guias.mostraGuiaFerramenta('i3GEOlegendaguia2','i3GEOlegendaguia');
158 159 },
159 160 alteraLegenda: function(){
160   - i3GEO.util.dialogoFerramenta("i3GEO.tema.dialogo.editaLegenda()","legenda","legenda","index.js","i3GEOF.metaestat.analise.ativaGuiaLegenda()");
  161 + i3GEO.util.dialogoFerramenta("i3GEO.tema.dialogo.editaLegenda()","legenda","legenda","index.js","i3GEOF.metaestat.analise.ativaEditorLegenda()");
161 162 },
162 163 alteraCores: function(){
163 164 //listaColourRampAnaliseMetaestat e o id do elemento input que recebera a lista de cores
... ... @@ -169,7 +170,6 @@ i3GEOF.metaestat = {
169 170 if(i.value != ""){
170 171 var p,temp,cores = i.value;
171 172 temp = function(){
172   - i3GEO.janela.AGUARDEMODAL = false;
173 173 i3GEO.janela.fechaAguarde("aguardeAplicaCores");
174 174 i3GEO.atualiza();
175 175 i3GEO.Interface.atualizaTema("",i3GEO.temaAtivo);
... ... @@ -181,9 +181,172 @@ i3GEOF.metaestat = {
181 181 "&tema="+i3GEO.temaAtivo +
182 182 "&cores=" + cores;
183 183 i3GEO.janela.AGUARDEMODAL = true;
184   - i3GEO.janela.fechaAguarde("Aplicando...","aguardeAplicaCores");
  184 + i3GEO.janela.abreAguarde("Aplicando...","aguardeAplicaCores");
  185 + i3GEO.janela.AGUARDEMODAL = false;
185 186 i3GEO.util.ajaxGet(p,temp);
186 187 }
  188 + },
  189 + filtraPeriodo: {
  190 + //CAMADAS: "",
  191 + inicia: function(){
  192 + i3GEO.janela.tempoMsg("O filtro de per&iacute;odo s&oacute; pode ser aplicado nas camadas (vari&aacute;veis) que possuem dados temporais");
  193 + if($i("i3GEOF.filtraperiodo_corpo")){
  194 + return;
  195 + }
  196 + var minimiza,cabecalho,titulo,ins;
  197 + cabecalho = function(){
  198 + };
  199 + minimiza = function(){
  200 + i3GEO.janela.minimiza("i3GEOF.filtraperiodo");
  201 + };
  202 + //cria a janela flutuante
  203 + titulo = "Filtro&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>";
  204 + i3GEO.janela.cria(
  205 + "260px",
  206 + "340px",
  207 + "",
  208 + "",
  209 + "",
  210 + titulo,
  211 + "i3GEOF.filtraperiodo",
  212 + false,
  213 + "hd",
  214 + cabecalho,
  215 + minimiza
  216 + );
  217 + $i("i3GEOF.filtraperiodo_corpo").style.backgroundColor = "white";
  218 + ins = "" +
  219 + '<p class=paragrafo ><b>Camada que receber&aacute; o filtro:</b></p>' +
  220 + '<div id="i3GEOF.filtraperiodo.camadas" ></div>' +
  221 + '<p class=paragrafo ><b>In&iacute;cio do per&iacute;odo:</b></p>' +
  222 + '<div id="i3GEOF.filtraperiodo.Pi_0" ></div>' +
  223 + '<p class=paragrafo ><b>Fim do per&iacute;odo:</b></p>' +
  224 + '<div id="i3GEOF.filtraperiodo.Pf_0" ></div>' +
  225 + '<br><br><input id=i3geofiltraperiodoAplica type="button" value="Aplicar" />' +
  226 + '<input id=i3geofiltraperiodoRemove type="button" value="Remover" />';
  227 + $i("i3GEOF.filtraperiodo_corpo").innerHTML = ins;
  228 + new YAHOO.widget.Button(
  229 + "i3geofiltraperiodoAplica",
  230 + {onclick:{fn: i3GEOF.metaestat.analise.filtraPeriodo.adicionaFiltro}}
  231 + );
  232 + new YAHOO.widget.Button(
  233 + "i3geofiltraperiodoRemove",
  234 + {onclick:{fn: function(){}}}
  235 + );
  236 + i3GEOF.metaestat.analise.filtraPeriodo.comboCamadas();
  237 + },
  238 + comboCamadas: function(retorno){
  239 + var temp = function(retorno){
  240 + //i3GEOF.metaestat.analise.filtraPeriodo.CAMADAS = retorno.data;
  241 + var i,
  242 + n = retorno.data.length,
  243 + ins = '<select id="i3GEOF.filtraperiodo.comboCamada" onchange="javascript:i3GEOF.metaestat.analise.filtraPeriodo.comboParametrosReinicia();i3GEOF.metaestat.analise.filtraPeriodo.comboParametros()" style="width:220px;" id="i3GEOF.filtraperiodo.temas" ><option value="">---</option>';
  244 + for(i=0;i<n;i++){
  245 + ins += '<option value="'+retorno.data[i].layer+'" >'+retorno.data[i].nome+'</option>';
  246 + }
  247 + ins += "</select><br><br>";
  248 + $i("i3GEOF.filtraperiodo.camadas").innerHTML = ins;
  249 + };
  250 + i3GEO.util.ajaxGet(
  251 + i3GEO.configura.locaplic+"/ferramentas/metaestat/analise.php?funcao=listaCamadasFiltroTempo&g_sid="+i3GEO.configura.sid,
  252 + temp
  253 + );
  254 + },
  255 + comboParametrosReinicia: function(operacao){
  256 + $i("i3GEOF.filtraperiodo.Pi_0").innerHTML = "";
  257 + $i("i3GEOF.filtraperiodo.Pf_0").innerHTML = "";
  258 + },
  259 + comboParametros: function(){
  260 + if($i("i3GEOF.filtraperiodo.comboCamada").value == ""){
  261 + return;
  262 + }
  263 + if($i("i3GEOF.filtraperiodo.Pi_0").innerHTML == ""){
  264 + i3GEOF.metaestat.analise.filtraPeriodo.parametro(0);
  265 + return;
  266 + }
  267 + },
  268 + parametro: function(nivel){
  269 + var layer = $i("i3GEOF.filtraperiodo.comboCamada").value,
  270 + temp = function(retorno){
  271 + var n = retorno.data.length,
  272 + i,
  273 + ins = "";
  274 + if(retorno.data[0] && retorno.data[0].id_pai){
  275 + for(i=0;i<n;i++){
  276 + ins += "<option value='"+retorno.data[i].id_parametro_medida+"'>"+retorno.data[i].nome+"</option>";
  277 + }
  278 + $i("i3GEOF.filtraperiodo.Pi_"+nivel).innerHTML = "<p class=paragrafo>Nome do par&acirc;metro:<br>" +
  279 + "<select name='' onchange='i3GEOF.metaestat.analise.filtraPeriodo.valoresParametro(this.value,"+nivel+",\"Pi_"+nivel+"\")' style='wisth:150px;'>" +
  280 + "<option value='' >---</option>"+ins+"</select></p><div class=paragrafo id='Pi_"+nivel+"'></div>";
  281 + $i("i3GEOF.filtraperiodo.Pf_"+nivel).innerHTML = "<p class=paragrafo>Nome do par&acirc;metro:<br>" +
  282 + "<select name='' onchange='i3GEOF.metaestat.analise.filtraPeriodo.valoresParametro(this.value,"+nivel+",\"Pf_"+nivel+"\")' style='wisth:150px;'>" +
  283 + "<option value='' >---</option>"+ins+"</select></p><div class=paragrafo id='Pf_"+nivel+"'></div>";
  284 + }
  285 + };
  286 + i3GEO.util.ajaxGet(
  287 + i3GEO.configura.locaplic+"/ferramentas/metaestat/analise.php?funcao=listaFiltroTempo&g_sid="+i3GEO.configura.sid+"&layer="+layer+"&nivel="+nivel,
  288 + temp
  289 + );
  290 + },
  291 + valoresParametro: function(id_parametro_medida,nivel,onde){
  292 + if(id_parametro_medida === ""){
  293 + $i(onde).innerHTML = "";
  294 + return;
  295 + }
  296 + var temp = function(retorno){
  297 + var ins="",i=0,n = retorno.length;
  298 + ins += "<p class=paragrafo>Valor:<br>" +
  299 + "<select name='"+id_parametro_medida+"' onchange='i3GEOF.metaestat.analise.filtraPeriodo.parametro("+(nivel*1 + 1)+")' style='wisth:150px;background-color:yellow;'><option value=''>---</option>";
  300 + for(i=0;i<n;i++){
  301 + ins += "<option value='"+retorno[i]+"'>"+retorno[i]+"</option>";
  302 + }
  303 + $i(onde).innerHTML = ins+"</select>";
  304 + };
  305 + i3GEO.php.listaValoresParametroMedidaVariavel(id_parametro_medida,temp);
  306 + },
  307 + adicionaFiltro: function(){
  308 + var p,pini,pfim,
  309 + temp = function(retorno){
  310 + i3GEO.janela.fechaAguarde("aguardeAplicaFiltro");
  311 + i3GEO.Interface.atualizaMapa();
  312 + };
  313 + i3GEO.janela.AGUARDEMODAL = true;
  314 + i3GEO.janela.abreAguarde("aguardeAplicaFiltro","Aplicando...");
  315 + i3GEO.janela.AGUARDEMODAL = false;
  316 + //pega o filtro
  317 + pini = i3GEOF.metaestat.analise.filtraPeriodo.pegaParametros("i3GEOF.filtraperiodo.Pi_0");
  318 + pfim = i3GEOF.metaestat.analise.filtraPeriodo.pegaParametros("i3GEOF.filtraperiodo.Pf_0");
  319 + //
  320 + p = i3GEO.configura.locaplic+"/ferramentas/metaestat/analise.php?funcao=aplicaFiltroTempo" +
  321 + "&pari="+pini[0] +
  322 + "&vali="+pini[1] +
  323 + "&parf="+pfim[0] +
  324 + "&valf="+pfim[1] +
  325 + "&tema="+$i("i3GEOF.filtraperiodo.comboCamada").value +
  326 + "&g_sid="+i3GEO.configura.sid;
  327 + if(pini[0].length == 0 || pini[1].length == 0){
  328 + i3GEO.janela.fechaAguarde("aguardeAplicaFiltro");
  329 + return;
  330 + }
  331 + i3GEO.util.ajaxGet(p,temp);
  332 + },
  333 + pegaParametros:function(id){
  334 + var c = $i(id).getElementsByTagName("select"),
  335 + n = c.length,
  336 + par = [],
  337 + val = [],
  338 + i;
  339 + if(!c){
  340 + return [par,val];
  341 + }
  342 + for(i=0;i<n;i++){
  343 + if(c[i].name != "" && c[i].value != ""){
  344 + par.push(c[i].name);
  345 + val.push(c[i].value);
  346 + }
  347 + }
  348 + return [par,val];
  349 + }
187 350 }
188 351 },
189 352 classes:{
... ... @@ -486,14 +649,13 @@ i3GEOF.metaestat = {
486 649 }
487 650 },
488 651 editor: {
489   - //TODO incluir botao para remover registros
490 652 inicia: function(){
491 653 YAHOO.namespace("admin.container");
492 654 if(typeof(i3GEOF.metaestat.dicionario1) === 'undefined'){
493 655 i3GEO.util.scriptTag(
494   - i3GEO.configura.locaplic+"/ferramentas/metaestat/dicionario1.js",
495   - "i3GEOF.metaestat.editor.dependenciasjs0()",
496   - "i3GEOF.metaestat.dicionario1_script"
  656 + i3GEO.configura.locaplic+"/ferramentas/metaestat/dicionario1.js",
  657 + "i3GEOF.metaestat.editor.dependenciasjs0()",
  658 + "i3GEOF.metaestat.dicionario1_script"
497 659 );
498 660 }
499 661 else{
... ...
ferramentas/metaestat/locregiao.js
... ... @@ -230,7 +230,7 @@ i3GEOF.locregiao = {
230 230 temp = function(){
231 231 i3GEO.janela.AGUARDEMODAL = false;
232 232 i3GEO.janela.fechaAguarde("aguardeFiltroRegiao");
233   - i3GEO.Interface.redesenha();
  233 + i3GEO.Interface.atualizaMapa();
234 234 };
235 235 if($i("i3geoLocregiaoFiltroAplicaCk").checked === true){
236 236 tipo = "regiaopai";
... ... @@ -251,7 +251,7 @@ i3GEOF.locregiao = {
251 251 temp = function(){
252 252 i3GEO.janela.AGUARDEMODAL = false;
253 253 i3GEO.janela.fechaAguarde("aguardeFiltroRegiao");
254   - i3GEO.Interface.redesenha();
  254 + i3GEO.Interface.atualizaMapa();
255 255 };
256 256 i3GEO.janela.AGUARDEMODAL = true;
257 257 i3GEO.janela.abreAguarde("aguardeFiltroRegiao","Filtrando...");
... ...
imagens/gisicons/open-street-maps-filtrotime.png 0 → 100755

1.52 KB