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,6 +124,9 @@ switch (strtoupper($funcao)){ | ||
| 124 | case "LISTALAYERSAGRUPADOS": | 124 | case "LISTALAYERSAGRUPADOS": |
| 125 | $retorno = listaLayersAgrupados($map_file); | 125 | $retorno = listaLayersAgrupados($map_file); |
| 126 | break; | 126 | break; |
| 127 | + case "JUNTAMEDIDASVARIAVEIS": | ||
| 128 | + $retorno = juntaMedidasVariaveis($map_file,$layerNames,$nome); | ||
| 129 | + break; | ||
| 127 | case "ADICIONALIMITEREGIAO": | 130 | case "ADICIONALIMITEREGIAO": |
| 128 | if(empty($outlinecolor)){ | 131 | if(empty($outlinecolor)){ |
| 129 | $outlinecolor = "255,0,0"; | 132 | $outlinecolor = "255,0,0"; |
| @@ -501,7 +504,7 @@ function analise_listaCamadasFiltroTempo($map_file){ | @@ -501,7 +504,7 @@ function analise_listaCamadasFiltroTempo($map_file){ | ||
| 501 | function analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf){ | 504 | function analise_aplicaFiltroTempo($map_file,$tema,$pari,$vali,$parf,$valf){ |
| 502 | $mapa = ms_newMapObj($map_file); | 505 | $mapa = ms_newMapObj($map_file); |
| 503 | $layer = $mapa->getlayerbyname($tema); | 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 | $data = $layer->data; | 508 | $data = $layer->data; |
| 506 | $m = new Metaestat(); | 509 | $m = new Metaestat(); |
| 507 | //pega os parametros de tempo inicial | 510 | //pega os parametros de tempo inicial |
| @@ -563,15 +566,21 @@ function analise_listaCamadasMetaestat($map_file){ | @@ -563,15 +566,21 @@ function analise_listaCamadasMetaestat($map_file){ | ||
| 563 | /** | 566 | /** |
| 564 | * Lista os objetos layers do mapa atual que sao originarias do sistema de metadados | 567 | * Lista os objetos layers do mapa atual que sao originarias do sistema de metadados |
| 565 | * @param arquivo mapfile do mapa atual | 568 | * @param arquivo mapfile do mapa atual |
| 569 | + * @excluiderivados exclui da lista os layers marcados como derivados de outros layers do sistema metaestat | ||
| 566 | * @return Array com os layers | 570 | * @return Array com os layers |
| 567 | */ | 571 | */ |
| 568 | -function analise_listaLayersMetaestat($mapa){ | 572 | +function analise_listaLayersMetaestat($mapa,$excluiderivados = false){ |
| 569 | $c = $mapa->numlayers; | 573 | $c = $mapa->numlayers; |
| 570 | $layers = array(); | 574 | $layers = array(); |
| 571 | for ($i=0;$i < $c;++$i){ | 575 | for ($i=0;$i < $c;++$i){ |
| 572 | $l = $mapa->getlayer($i); | 576 | $l = $mapa->getlayer($i); |
| 573 | if($l->getmetadata("METAESTAT") == "SIM"){ | 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 | return $layers; | 586 | return $layers; |
| @@ -641,8 +650,54 @@ function analise_aplicafiltroregiao($map_file,$codigo_tipo_regiao,$codigo_regiao | @@ -641,8 +650,54 @@ function analise_aplicafiltroregiao($map_file,$codigo_tipo_regiao,$codigo_regiao | ||
| 641 | * @return Nome do layer criado | 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 | * Lista os nomes dos layers originados do sistema METAESTAT. | 703 | * Lista os nomes dos layers originados do sistema METAESTAT. |
| @@ -656,7 +711,7 @@ function listaLayersAgrupados($map_file){ | @@ -656,7 +711,7 @@ function listaLayersAgrupados($map_file){ | ||
| 656 | $tipos[1] = "linha"; | 711 | $tipos[1] = "linha"; |
| 657 | $tipos[2] = "poligono"; | 712 | $tipos[2] = "poligono"; |
| 658 | $mapa = ms_newMapObj($map_file); | 713 | $mapa = ms_newMapObj($map_file); |
| 659 | - $layers = analise_listaLayersMetaestat($mapa); | 714 | + $layers = analise_listaLayersMetaestat($mapa,true); |
| 660 | $m = new Metaestat(); | 715 | $m = new Metaestat(); |
| 661 | $camadas = array(); | 716 | $camadas = array(); |
| 662 | foreach($layers as $l){ | 717 | foreach($layers as $l){ |
ferramentas/metaestat/index.js
| @@ -339,10 +339,10 @@ i3GEOF.metaestat = { | @@ -339,10 +339,10 @@ i3GEOF.metaestat = { | ||
| 339 | } | 339 | } |
| 340 | var aplica,minimiza,cabecalho,titulo,ins,n,i,lista = "<table class=lista4 >"; | 340 | var aplica,minimiza,cabecalho,titulo,ins,n,i,lista = "<table class=lista4 >"; |
| 341 | aplica = function(){ | 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 | n = ics.length; | 343 | n = ics.length; |
| 344 | for(i=0;i<n;i++){ | 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 | lista.push(ics[i].value); | 346 | lista.push(ics[i].value); |
| 347 | } | 347 | } |
| 348 | } | 348 | } |
| @@ -352,7 +352,7 @@ i3GEOF.metaestat = { | @@ -352,7 +352,7 @@ i3GEOF.metaestat = { | ||
| 352 | } | 352 | } |
| 353 | i3GEO.janela.abreAguarde("aguardeBuscaDados","Aguarde..."); | 353 | i3GEO.janela.abreAguarde("aguardeBuscaDados","Aguarde..."); |
| 354 | p = i3GEO.configura.locaplic+"/ferramentas/metaestat/analise.php?g_sid="+i3GEO.configura.sid + | 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 | atualiza = function(){ | 356 | atualiza = function(){ |
| 357 | i3GEO.janela.fechaAguarde("aguardeBuscaDados"); | 357 | i3GEO.janela.fechaAguarde("aguardeBuscaDados"); |
| 358 | i3GEO.atualiza(); | 358 | i3GEO.atualiza(); |
| @@ -382,12 +382,14 @@ i3GEOF.metaestat = { | @@ -382,12 +382,14 @@ i3GEOF.metaestat = { | ||
| 382 | $i("i3GEOF.junta_corpo").style.backgroundColor = "white"; | 382 | $i("i3GEOF.junta_corpo").style.backgroundColor = "white"; |
| 383 | n = retorno.data.length; | 383 | n = retorno.data.length; |
| 384 | for(i=0;i<n;i++){ | 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 | lista += "</table>"; | 387 | lista += "</table>"; |
| 388 | ins = "" + | 388 | ins = "" + |
| 389 | '<p class=paragrafo ><b>Escolha as camadas de mesmo tipo e região:</b></p>' + | 389 | '<p class=paragrafo ><b>Escolha as camadas de mesmo tipo e região:</b></p>' + |
| 390 | lista + | 390 | lista + |
| 391 | + '<br><p class=paragrafo >Nome da nova camada</p>' + | ||
| 392 | + $inputText("","","i3GEOFjuntaNovoNome","",30,'') + | ||
| 391 | '<br><br><input id=i3geojuntaAplica type="button" value="Aplicar" />'; | 393 | '<br><br><input id=i3geojuntaAplica type="button" value="Aplicar" />'; |
| 392 | $i("i3GEOF.junta_corpo").innerHTML = ins; | 394 | $i("i3GEOF.junta_corpo").innerHTML = ins; |
| 393 | new YAHOO.widget.Button( | 395 | new YAHOO.widget.Button( |