Commit 73a089dc5bf9aa3f96df7cafa7c63717e03bcc92
1 parent
114ebd45
Exists in
master
and in
7 other branches
--no commit message
Showing
3 changed files
with
66 additions
and
9 deletions
Show diff stats
admin/admin.db
No preview for this file type
ferramentas/metaestat/analise.php
| ... | ... | @@ -124,6 +124,9 @@ switch (strtoupper($funcao)){ |
| 124 | 124 | case "LISTALAYERSAGRUPADOS": |
| 125 | 125 | $retorno = listaLayersAgrupados($map_file); |
| 126 | 126 | break; |
| 127 | + case "JUNTAMEDIDASVARIAVEIS": | |
| 128 | + $retorno = juntaMedidasVariaveis($map_file,$layerNames,$nome); | |
| 129 | + break; | |
| 127 | 130 | case "ADICIONALIMITEREGIAO": |
| 128 | 131 | if(empty($outlinecolor)){ |
| 129 | 132 | $outlinecolor = "255,0,0"; |
| ... | ... | @@ -501,7 +504,7 @@ function analise_listaCamadasFiltroTempo($map_file){ |
| 501 | 504 | function analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf){ |
| 502 | 505 | $mapa = ms_newMapObj($map_file); |
| 503 | 506 | $layer = $mapa->getlayerbyname($tema); |
| 504 | - $id_medida_variavel = $layer->getmetadata("ID_MEDIDA_VARIAVEL"); | |
| 507 | + $id_medida_variavel = $layer->getmetadata("METAESTAT_ID_MEDIDA_VARIAVEL"); | |
| 505 | 508 | $data = $layer->data; |
| 506 | 509 | $m = new Metaestat(); |
| 507 | 510 | //pega os parametros de tempo inicial |
| ... | ... | @@ -563,15 +566,21 @@ function analise_listaCamadasMetaestat($map_file){ |
| 563 | 566 | /** |
| 564 | 567 | * Lista os objetos layers do mapa atual que sao originarias do sistema de metadados |
| 565 | 568 | * @param arquivo mapfile do mapa atual |
| 569 | + * @excluiderivados exclui da lista os layers marcados como derivados de outros layers do sistema metaestat | |
| 566 | 570 | * @return Array com os layers |
| 567 | 571 | */ |
| 568 | -function analise_listaLayersMetaestat($mapa){ | |
| 572 | +function analise_listaLayersMetaestat($mapa,$excluiderivados = false){ | |
| 569 | 573 | $c = $mapa->numlayers; |
| 570 | 574 | $layers = array(); |
| 571 | 575 | for ($i=0;$i < $c;++$i){ |
| 572 | 576 | $l = $mapa->getlayer($i); |
| 573 | 577 | if($l->getmetadata("METAESTAT") == "SIM"){ |
| 574 | - $layers[] = $l; | |
| 578 | + if($excluiderivados == false){ | |
| 579 | + $layers[] = $l; | |
| 580 | + } | |
| 581 | + elseif ($l->getmetadata("METAESTAT_DERIVADO") != "sim"){ | |
| 582 | + $layers[] = $l; | |
| 583 | + } | |
| 575 | 584 | } |
| 576 | 585 | } |
| 577 | 586 | return $layers; |
| ... | ... | @@ -641,8 +650,54 @@ function analise_aplicafiltroregiao($map_file,$codigo_tipo_regiao,$codigo_regiao |
| 641 | 650 | * @return Nome do layer criado |
| 642 | 651 | * |
| 643 | 652 | */ |
| 644 | -function juntaMedidasVariaveis($map_file,$layerNames){ | |
| 653 | +function juntaMedidasVariaveis($map_file,$layerNames,$nome){ | |
| 654 | + //o sql que faz acesso aos dados e marcado com /*SE*//*SE*/ | |
| 655 | + $mapa = ms_newMapObj($map_file); | |
| 656 | + $layernames = explode(",",$layerNames); | |
| 657 | + $sqlLayers = array(); | |
| 658 | + $conta = 0; | |
| 659 | + $m = new Metaestat(); | |
| 660 | + $colunasValor = array(); | |
| 661 | + $colunasIdentificador = array(); | |
| 662 | + $sqls = array(); | |
| 663 | + $nomesLayers = array(); | |
| 664 | + foreach($layernames as $layername){ | |
| 665 | + $l = $mapa->getlayerbyname($layername); | |
| 666 | + $s = explode("/*SE*/",$l->data); | |
| 667 | + //pega o sql e da define um alias | |
| 668 | + $sqls[] = $s[1]." as tabela".$conta; | |
| 669 | + // | |
| 670 | + $id_medida_variavel = $l->getmetadata("METAESTAT_ID_MEDIDA_VARIAVEL"); | |
| 671 | + $nomesLayers[] = $l->getmetadata("tema"); | |
| 672 | + $medidavariavel = $m->listaMedidaVariavel("",$id_medida_variavel); | |
| 673 | + //pega o nome da coluna que contem os valores e a coluna de ligacao | |
| 674 | + $colunasValor[] = $medidavariavel["colunavalor"]; | |
| 675 | + $colunasIdentificador[] = $medidavariavel["colunaidgeo"]; | |
| 676 | + //pega valores do primeiro layer para a tabela0 | |
| 677 | + if($conta == 0){ | |
| 678 | + $codigo_tipo_regiao = $l->getmetadata("METAESTAT_CODIGO_TIPO_REGIAO"); | |
| 679 | + $gid = $medidavariavel["colunaidunico"]; | |
| 680 | + } | |
| 681 | + $conta++; | |
| 682 | + } | |
| 683 | + //coluna com a geometria | |
| 684 | + $regiao = $m->listaTipoRegiao($codigo_tipo_regiao); | |
| 685 | + $n = count($sqls); | |
| 645 | 686 | |
| 687 | + $cwhere = array(); | |
| 688 | + for($i=1;$i<$n;$i++){ | |
| 689 | + $cwhere[] = "tabela0.".$colunasIdentificador[0]." = "."tabela".$i.".".$colunasIdentificador[$i]; | |
| 690 | + } | |
| 691 | + $colunasDados = array(); | |
| 692 | + for($i=0;$i<$n;$i++){ | |
| 693 | + $colunasDados[] = "tabela".$i.".".$colunasValor[$i]." as valorTema".$i; | |
| 694 | + } | |
| 695 | + $sqlfinal = "SELECT tabela0.".$gid.",tabela0.".$regiao["colunageo"]." as the_geom,".implode(",",$colunasDados)." from ".implode(",",$sqls)." WHERE "; | |
| 696 | + $sqlfinal .= implode($cwhere," AND "); | |
| 697 | + $sqlfinal = str_replace("/*FA*/","",$sqlfinal); | |
| 698 | + $sqlfinal = str_replace("/*FAT*/","",$sqlfinal); | |
| 699 | + $data = "SELECT the_geom from ($sqlfinal) as foo using unique $gid using srid=".$regiao["srid"]; | |
| 700 | + return $data; | |
| 646 | 701 | } |
| 647 | 702 | /** |
| 648 | 703 | * Lista os nomes dos layers originados do sistema METAESTAT. |
| ... | ... | @@ -656,7 +711,7 @@ function listaLayersAgrupados($map_file){ |
| 656 | 711 | $tipos[1] = "linha"; |
| 657 | 712 | $tipos[2] = "poligono"; |
| 658 | 713 | $mapa = ms_newMapObj($map_file); |
| 659 | - $layers = analise_listaLayersMetaestat($mapa); | |
| 714 | + $layers = analise_listaLayersMetaestat($mapa,true); | |
| 660 | 715 | $m = new Metaestat(); |
| 661 | 716 | $camadas = array(); |
| 662 | 717 | foreach($layers as $l){ | ... | ... |
ferramentas/metaestat/index.js
| ... | ... | @@ -339,10 +339,10 @@ i3GEOF.metaestat = { |
| 339 | 339 | } |
| 340 | 340 | var aplica,minimiza,cabecalho,titulo,ins,n,i,lista = "<table class=lista4 >"; |
| 341 | 341 | aplica = function(){ |
| 342 | - var atualiza,p,lista,i,ics = $i("i3GEOF.junta_corpo").getElementsByTagName("input"); | |
| 342 | + var atualiza,p,lista = [],i,ics = $i("i3GEOF.junta_corpo").getElementsByTagName("input"); | |
| 343 | 343 | n = ics.length; |
| 344 | 344 | for(i=0;i<n;i++){ |
| 345 | - if(ics[i].type == "checkbox" && ics[i].checked == true){ | |
| 345 | + if(ics[i].type == "checkbox" && ics[i].checked === true){ | |
| 346 | 346 | lista.push(ics[i].value); |
| 347 | 347 | } |
| 348 | 348 | } |
| ... | ... | @@ -352,7 +352,7 @@ i3GEOF.metaestat = { |
| 352 | 352 | } |
| 353 | 353 | i3GEO.janela.abreAguarde("aguardeBuscaDados","Aguarde..."); |
| 354 | 354 | p = i3GEO.configura.locaplic+"/ferramentas/metaestat/analise.php?g_sid="+i3GEO.configura.sid + |
| 355 | - "&funcao=juntaMedidasVariaveis&layerNames=".lista.join(","); | |
| 355 | + "&funcao=juntaMedidasVariaveis&layerNames="+lista.join(",")+"&nome="+$i("i3GEOFjuntaNovoNome").value; | |
| 356 | 356 | atualiza = function(){ |
| 357 | 357 | i3GEO.janela.fechaAguarde("aguardeBuscaDados"); |
| 358 | 358 | i3GEO.atualiza(); |
| ... | ... | @@ -382,12 +382,14 @@ i3GEOF.metaestat = { |
| 382 | 382 | $i("i3GEOF.junta_corpo").style.backgroundColor = "white"; |
| 383 | 383 | n = retorno.data.length; |
| 384 | 384 | for(i=0;i<n;i++){ |
| 385 | - lista += "<tr><td><input style=cursor:pointer type=checkbox id='"+retorno.data[i].layer+"' ></td><td>"+retorno.data[i].tema+"</td></tr>"; | |
| 385 | + lista += "<tr><td><input style=cursor:pointer type=checkbox value='"+retorno.data[i].layer+"' ></td><td>"+retorno.data[i].tema+"</td></tr>"; | |
| 386 | 386 | } |
| 387 | 387 | lista += "</table>"; |
| 388 | 388 | ins = "" + |
| 389 | 389 | '<p class=paragrafo ><b>Escolha as camadas de mesmo tipo e região:</b></p>' + |
| 390 | 390 | lista + |
| 391 | + '<br><p class=paragrafo >Nome da nova camada</p>' + | |
| 392 | + $inputText("","","i3GEOFjuntaNovoNome","",30,'') + | |
| 391 | 393 | '<br><br><input id=i3geojuntaAplica type="button" value="Aplicar" />'; |
| 392 | 394 | $i("i3GEOF.junta_corpo").innerHTML = ins; |
| 393 | 395 | new YAHOO.widget.Button( | ... | ... |