Commit c2dea8ae31c51d1f57ed3610b99c66c242b58cb4
1 parent
3892bacd
Exists in
master
and in
7 other branches
Inclusão de formulário para seleção de variáveis na interface carto_ol.htm
Showing
6 changed files
with
200 additions
and
11 deletions
Show diff stats
admin/php/classe_metaestat.php
| ... | ... | @@ -223,7 +223,6 @@ class Metaestat{ |
| 223 | 223 | else{ |
| 224 | 224 | $colunageo = $dadosgeo["colunacentroide"]; |
| 225 | 225 | } |
| 226 | - | |
| 227 | 226 | if($todasascolunas == 0){ |
| 228 | 227 | $sql = " SELECT d.".$dados["colunavalor"].",d.".$dados["colunaidgeo"]; |
| 229 | 228 | if(!empty($agruparpor)){ |
| ... | ... | @@ -240,6 +239,7 @@ class Metaestat{ |
| 240 | 239 | $sqlgeo .= " FROM ".$dados["esquemadb"].".".$dados["tabela"]." as d,".$dadosgeo["esquemadb"].".".$dadosgeo["tabela"]." as g "; |
| 241 | 240 | } |
| 242 | 241 | else{ |
| 242 | + $sqlagrupamento = " SELECT d.".$agruparpor." FROM ".$dados["esquemadb"].".".$dados["tabela"]." as d group by ".$agruparpor." order by ".$agruparpor; | |
| 243 | 243 | $sqlgeo .= " FROM (SELECT sum(".$dados["colunavalor"].") as ".$dados["colunavalor"].",".$dados["colunaidgeo"].",".$agruparpor." FROM ".$dados["esquemadb"].".".$dados["tabela"] ." group by ".$agruparpor.",".$dados["colunaidgeo"].") as d, ".$dadosgeo["esquemadb"].".".$dadosgeo["tabela"]." as g"; |
| 244 | 244 | $sql .= " FROM (SELECT sum(".$dados["colunavalor"].") as ".$dados["colunavalor"].",".$dados["colunaidgeo"].",".$agruparpor." FROM ".$dados["esquemadb"].".".$dados["tabela"] ." group by ".$agruparpor.",".$dados["colunaidgeo"].") as d "; |
| 245 | 245 | } |
| ... | ... | @@ -259,7 +259,7 @@ class Metaestat{ |
| 259 | 259 | //atencao: cuidado ao alterar essa string pois ') as foo' pode ser usado para replace em outras funcoes |
| 260 | 260 | $sqlgeo = $colunageo." from ($sqlgeo) as foo using unique ".$dados["colunaidgeo"]." using srid=".$dadosgeo["srid"]; |
| 261 | 261 | $colunas = $this->colunasTabela($dados["codigo_estat_conexao"],$dados["esquemadb"],$dados["tabela"]); |
| 262 | - return array("sql"=>$sql,"sqlmapserver"=>$sqlgeo,"filtro"=>$filtro,"colunas"=>$colunas); | |
| 262 | + return array("sqlagrupamento"=>$sqlagrupamento,"sql"=>$sql,"sqlmapserver"=>$sqlgeo,"filtro"=>$filtro,"colunas"=>$colunas); | |
| 263 | 263 | } |
| 264 | 264 | function mapfileMedidaVariavel($id_medida_variavel,$filtro="",$todasascolunas = 0,$tipolayer="polygon",$titulolayer="",$id_classificacao="",$agruparpor=""){ |
| 265 | 265 | if(empty($tipolayer)){ |
| ... | ... | @@ -406,6 +406,21 @@ class Metaestat{ |
| 406 | 406 | } |
| 407 | 407 | return false; |
| 408 | 408 | } |
| 409 | + function valorUnicoMedidaVariavel($id_medida_variavel,$coluna){ | |
| 410 | + $sqlf = $this->sqlMedidaVariavel($id_medida_variavel,0,$coluna); | |
| 411 | + $sqlf = $sqlf["sqlagrupamento"]; | |
| 412 | + $metaVariavel = $this->listaMedidaVariavel("",$id_medida_variavel); | |
| 413 | + if(!empty($metaVariavel["codigo_estat_conexao"])){ | |
| 414 | + $c = $this->listaConexao($metaVariavel["codigo_estat_conexao"],true); | |
| 415 | + $dbhold = $this->dbh; | |
| 416 | + $dbh = new PDO('pgsql:dbname='.$c["bancodedados"].';user='.$c["usuario"].';password='.$c["senha"].';host='.$c["host"].';port='.$c["porta"]); | |
| 417 | + $this->dbh = $dbh; | |
| 418 | + $res = $this->execSQL($sqlf); | |
| 419 | + $this->dbh = $dbhold; | |
| 420 | + return $res; | |
| 421 | + } | |
| 422 | + return false; | |
| 423 | + } | |
| 409 | 424 | function sumarioMedidaVariavel($id_medida_variavel,$filtro="",$agruparpor=""){ |
| 410 | 425 | if(!empty($agruparpor)){ |
| 411 | 426 | $dados = $this->dadosMedidaVariavel($id_medida_variavel,$filtro,1); |
| ... | ... | @@ -961,7 +976,17 @@ class Metaestat{ |
| 961 | 976 | //echo $sql;exit; |
| 962 | 977 | return $this->execSQL($sql,$id_parametro_medida); |
| 963 | 978 | } |
| 964 | - | |
| 979 | + function listaValoresParametro($id_parametro_medida){ | |
| 980 | + $parametro = $this->listaParametro("",$id_parametro_medida); | |
| 981 | + //$medida = $this->listaMedidaVariavel("",$parametro["id_medida_variavel"]); | |
| 982 | + $sm = $this->valorUnicoMedidaVariavel($parametro["id_medida_variavel"],$parametro["coluna"]); | |
| 983 | + $nsm = array(); | |
| 984 | + foreach($sm as $s){ | |
| 985 | + $nsm[] = $s[$parametro["coluna"]]; | |
| 986 | + } | |
| 987 | + return $nsm; | |
| 988 | + exit; | |
| 989 | + } | |
| 965 | 990 | /* |
| 966 | 991 | Function: listaTipoPeriodo |
| 967 | 992 | ... | ... |
admin/php/metaestat.php
| ... | ... | @@ -151,6 +151,11 @@ switch (strtoupper($funcao)) |
| 151 | 151 | retornaJSON($m->listaParametro($id_medida_variavel,$id_parametro_medida)); |
| 152 | 152 | exit; |
| 153 | 153 | break; |
| 154 | + case "LISTAVALORESPARAMETRO": | |
| 155 | + $m = new Metaestat(); | |
| 156 | + retornaJSON($m->listaValoresParametro($id_parametro_medida)); | |
| 157 | + exit; | |
| 158 | + break; | |
| 154 | 159 | /* |
| 155 | 160 | Valor: LISTAUNIDADEMEDIDA |
| 156 | 161 | ... | ... |
classesjs/classe_cartograma.js
| ... | ... | @@ -39,8 +39,8 @@ i3GEO.cartograma = { |
| 39 | 39 | INTERFACE: "flutuante", |
| 40 | 40 | TOP: 50, |
| 41 | 41 | LEFT: 100, |
| 42 | - LARGURA: 250, | |
| 43 | - ALTURA: 100, | |
| 42 | + LARGURA: 260, | |
| 43 | + ALTURA: 300, | |
| 44 | 44 | inicia: function(iddiv){ |
| 45 | 45 | if(!iddiv){ |
| 46 | 46 | iddiv = "i3geoCartoParametros_corpo"; |
| ... | ... | @@ -58,9 +58,9 @@ i3GEO.cartograma = { |
| 58 | 58 | var onde = $i("i3geoCartoVariaveis"), |
| 59 | 59 | temp = function(dados){ |
| 60 | 60 | var n = dados.length, |
| 61 | - ins = "", | |
| 61 | + ins = '<p class="paragrafo" >'+$trad("x58")+'</p>', | |
| 62 | 62 | i; |
| 63 | - ins = "<select style='width:"+(i3GEO.cartograma.LARGURA - 10)+"px' onchange=''><option value=''>---</option>"; | |
| 63 | + ins += "<select style='width:"+(i3GEO.cartograma.LARGURA - 20)+"px' onchange='i3GEO.cartograma.comboVariaveisOnchange(this)'><option value=''>---</option>"; | |
| 64 | 64 | for(i=0;i<n;i++){ |
| 65 | 65 | ins += "<option title='"+dados[i].descricao+"' value='"+dados[i].codigo_variavel+"'>"+dados[i].nome+"</option>"; |
| 66 | 66 | } |
| ... | ... | @@ -73,11 +73,143 @@ i3GEO.cartograma = { |
| 73 | 73 | i3GEO.cartograma.aguarde(onde); |
| 74 | 74 | i3GEO.php.listaVariavel(temp); |
| 75 | 75 | }, |
| 76 | + comboVariaveisOnchange: function(combo){ | |
| 77 | + if(combo.value != ""){ | |
| 78 | + i3GEO.cartograma.comboMedidasVariavel(combo.value); | |
| 79 | + } | |
| 80 | + else{ | |
| 81 | + $i("i3geoCartoMedidasVariavel").innerHTML = ""; | |
| 82 | + $i("i3geoCartoParametrosMedidasVariavel").innerHTML = ""; | |
| 83 | + } | |
| 84 | + }, | |
| 85 | + comboMedidasVariavel: function(codigo_variavel){ | |
| 86 | + var onde = $i("i3geoCartoMedidasVariavel"), | |
| 87 | + temp = function(dados){ | |
| 88 | + var n = dados.length, | |
| 89 | + ins = '<p class="paragrafo" >'+$trad("x59")+'</p>', | |
| 90 | + i; | |
| 91 | + ins += "<select style='width:"+(i3GEO.cartograma.LARGURA - 20)+"px' onchange='i3GEO.cartograma.comboMedidaVariavelOnchange(this)'><option value=''>---</option>"; | |
| 92 | + for(i=0;i<n;i++){ | |
| 93 | + ins += "<option value='"+dados[i].id_medida_variavel+"'>"+dados[i].nomemedida+"</option>"; | |
| 94 | + } | |
| 95 | + ins += "</select>"; | |
| 96 | + if(onde){ | |
| 97 | + onde.innerHTML = ins; | |
| 98 | + } | |
| 99 | + return ins; | |
| 100 | + }; | |
| 101 | + i3GEO.cartograma.aguarde(onde); | |
| 102 | + i3GEO.php.listaMedidaVariavel(codigo_variavel,temp); | |
| 103 | + }, | |
| 104 | + comboMedidaVariavelOnchange: function(combo){ | |
| 105 | + if(combo.value != ""){ | |
| 106 | + i3GEO.cartograma.parametros.lista(combo.value); | |
| 107 | + } | |
| 108 | + else{ | |
| 109 | + $i("i3geoCartoParametrosMedidasVariavel").innerHTML = ""; | |
| 110 | + } | |
| 111 | + }, | |
| 112 | + parametros: { | |
| 113 | + //guarda a lista de parametros | |
| 114 | + dados: [], | |
| 115 | + //obtem a lista com os parametros da medida | |
| 116 | + //cria os combos para os parametros que sao pai de todos | |
| 117 | + lista: function(id_medida_variavel){ | |
| 118 | + var temp = function(dados){ | |
| 119 | + i3GEO.cartograma.parametros.dados = dados; | |
| 120 | + i3GEO.cartograma.parametros.combos("0"); | |
| 121 | + }; | |
| 122 | + i3GEO.php.listaParametrosMedidaVariavel(id_medida_variavel,temp); | |
| 123 | + }, | |
| 124 | + //cria um combo para escolher os valores de um parametro | |
| 125 | + combos: function(nivel){ | |
| 126 | + var dados = i3GEO.cartograma.parametros.dados, | |
| 127 | + n = dados.length, | |
| 128 | + onde = $i("i3geoCartoParametrosMedidasVariavel"), | |
| 129 | + idpar,idcombo,i,novoel,teste; | |
| 130 | + //cria o combo para o parametro cujo id_pai for do nivel escolhido | |
| 131 | + for(i=0;i<n;i++){ | |
| 132 | + if(dados[i].id_pai == nivel){ | |
| 133 | + idpar = "parametro_"+dados[i].id_parametro_medida; | |
| 134 | + idcombo = "parametro_"+dados[i].id_parametro_medida+"_"+nivel; | |
| 135 | + teste = i3GEO.cartograma.parametros.retornaIdPai(dados[i].id_parametro_medida); | |
| 136 | + if(teste != false){ | |
| 137 | + idpar = "parametro_"+teste; | |
| 138 | + } | |
| 139 | + if(!$i(idpar)){ | |
| 140 | + novoel = document.createElement("div"); | |
| 141 | + novoel.id = idpar; | |
| 142 | + novoel.className = "paragrafo"; | |
| 143 | + onde.appendChild(novoel); | |
| 144 | + onde = novoel; | |
| 145 | + } | |
| 146 | + onde = $i(idpar); | |
| 147 | + if(!$i(idcombo)){ | |
| 148 | + novoel = document.createElement("div"); | |
| 149 | + novoel.id = idcombo; | |
| 150 | + novoel.className = "paragrafo"; | |
| 151 | + onde.appendChild(novoel); | |
| 152 | + i3GEO.cartograma.parametros.valoresCombo(dados[i].id_parametro_medida,dados[i].nome,nivel,onde); | |
| 153 | + } | |
| 154 | + } | |
| 155 | + } | |
| 156 | + }, | |
| 157 | + valoresCombo: function(id_parametro_medida,titulo,nivel,onde){ | |
| 158 | + var temp = function(dados){ | |
| 159 | + var n = dados.length, | |
| 160 | + ins = "", | |
| 161 | + oc = "'i3GEO.cartograma.parametros.combos(\""+id_parametro_medida+"\")'", | |
| 162 | + filho = i3GEO.cartograma.parametros.retornaIdFilho(id_parametro_medida), | |
| 163 | + i,novoel; | |
| 164 | + if(filho == false){ | |
| 165 | + oc = ""; | |
| 166 | + } | |
| 167 | + ins = "<p class=paragrafo >"+titulo+"</p>"; | |
| 168 | + ins += "<select style='background:beige;width:"+(i3GEO.cartograma.LARGURA - 20)+"px' onchange="+oc+" ><option value=''>---</option>"; | |
| 169 | + for(i=0;i<n;i++){ | |
| 170 | + ins += "<option value='"+dados[i]+"'>"+dados[i]+"</option>"; | |
| 171 | + } | |
| 172 | + ins += "</select>"; | |
| 173 | + novoel = document.createElement("div"); | |
| 174 | + novoel.className = "paragrafo"; | |
| 175 | + novoel.innerHTML = ins; | |
| 176 | + onde.appendChild(novoel); | |
| 177 | + }; | |
| 178 | + i3GEO.php.listaValoresParametroMedidaVariavel(id_parametro_medida,temp); | |
| 179 | + }, | |
| 180 | + //retorna o id do parametro que e filho de um outro parametro | |
| 181 | + retornaIdFilho:function(pai){ | |
| 182 | + var dados = i3GEO.cartograma.parametros.dados, | |
| 183 | + n = dados.length, | |
| 184 | + i; | |
| 185 | + for(i=0;i<n;i++){ | |
| 186 | + if(dados[i].id_pai == pai){ | |
| 187 | + return dados[i].id_parametro_medida; | |
| 188 | + } | |
| 189 | + } | |
| 190 | + return false; | |
| 191 | + }, | |
| 192 | + //retorna o id do parametro que e pai de um outro parametro | |
| 193 | + retornaIdPai:function(filho){ | |
| 194 | + var dados = i3GEO.cartograma.parametros.dados, | |
| 195 | + n = dados.length, | |
| 196 | + i; | |
| 197 | + for(i=0;i<n;i++){ | |
| 198 | + if(dados[i].id_parametro_medida == filho){ | |
| 199 | + return dados[i].id_pai; | |
| 200 | + } | |
| 201 | + } | |
| 202 | + return false; | |
| 203 | + } | |
| 204 | + }, | |
| 76 | 205 | html: function(){ |
| 77 | 206 | var ins = '<div id="i3geoCartoVariaveisContainer" >' + |
| 78 | - '<p class="paragrafo" >'+$trad("x58")+'</p>' + | |
| 79 | 207 | '<div class="paragrafo" id="i3geoCartoVariaveis" >' + |
| 80 | 208 | '</div>' + |
| 209 | + '<div class="paragrafo" id="i3geoCartoMedidasVariavel" >' + | |
| 210 | + '</div>' + | |
| 211 | + '<div class="paragrafo" id="i3geoCartoParametrosMedidasVariavel" >' + | |
| 212 | + '</div>' + | |
| 81 | 213 | '</div>'; |
| 82 | 214 | return ins; |
| 83 | 215 | }, | ... | ... |
classesjs/classe_php.js
| ... | ... | @@ -1429,4 +1429,31 @@ i3GEO.php = { |
| 1429 | 1429 | var p = i3GEO.configura.locaplic+"/admin/php/metaestat.php?funcao=listaVariavel&g_sid="+i3GEO.configura.sid; |
| 1430 | 1430 | i3GEO.util.ajaxGet(p,funcao); |
| 1431 | 1431 | }, |
| 1432 | + /* | |
| 1433 | + Function: listaMedidaVariavel | |
| 1434 | + | |
| 1435 | + Obtém a lista medidas de uma variável do sistema de metadados estatísticos | |
| 1436 | + */ | |
| 1437 | + listaMedidaVariavel: function(codigo_variavel,funcao){ | |
| 1438 | + var p = i3GEO.configura.locaplic+"/admin/php/metaestat.php?funcao=listaMedidaVariavel&codigo_variavel="+codigo_variavel+"&g_sid="+i3GEO.configura.sid; | |
| 1439 | + i3GEO.util.ajaxGet(p,funcao); | |
| 1440 | + }, | |
| 1441 | + /* | |
| 1442 | + Function: listaParametrosMedidaVariavel | |
| 1443 | + | |
| 1444 | + Obtém a lista de parâmetros de uma medida de uma variável do sistema de metadados estatísticos | |
| 1445 | + */ | |
| 1446 | + listaParametrosMedidaVariavel: function(id_medida_variavel,funcao){ | |
| 1447 | + var p = i3GEO.configura.locaplic+"/admin/php/metaestat.php?funcao=listaParametro&id_medida_variavel="+id_medida_variavel+"&g_sid="+i3GEO.configura.sid; | |
| 1448 | + i3GEO.util.ajaxGet(p,funcao); | |
| 1449 | + }, | |
| 1450 | + /* | |
| 1451 | + Function: listaValoresParametroMedidaVariavel | |
| 1452 | + | |
| 1453 | + Obtém a lista de valores de um parâmetro de uma medida de uma variável do sistema de metadados estatísticos | |
| 1454 | + */ | |
| 1455 | + listaValoresParametroMedidaVariavel: function(id_parametro_medida,funcao){ | |
| 1456 | + var p = i3GEO.configura.locaplic+"/admin/php/metaestat.php?funcao=listaValoresParametro&id_parametro_medida="+id_parametro_medida+"&g_sid="+i3GEO.configura.sid; | |
| 1457 | + i3GEO.util.ajaxGet(p,funcao); | |
| 1458 | + } | |
| 1432 | 1459 | }; |
| 1433 | 1460 | \ No newline at end of file | ... | ... |
classesjs/dicionario.js
interface/carto_ol.htm
| ... | ... | @@ -172,8 +172,8 @@ i3GEO.inicia(); |
| 172 | 172 | i3GEO.cartograma.INTERFACE = "flutuante"; |
| 173 | 173 | i3GEO.cartograma.TOP = 50; |
| 174 | 174 | i3GEO.cartograma.LEFT = 100; |
| 175 | -i3GEO.cartograma.LARGURA = 250; | |
| 176 | -i3GEO.cartograma.ALTURA = 100; | |
| 175 | +i3GEO.cartograma.LARGURA = 260; | |
| 176 | +i3GEO.cartograma.ALTURA = 300; | |
| 177 | 177 | i3GEO.cartograma.inicia(); |
| 178 | 178 | </script> |
| 179 | 179 | </body> | ... | ... |