Commit 08cf2a604b9f91ff370a4412fae8d13a72b0ec03

Authored by Edmar Moretti
1 parent 512d5080

Inclusão de formulário para definição dos parâmetros de construção automática de…

… classes na ferramenta legenda.
admin/admin.db
No preview for this file type
admin1/catalogo/mapfile/conexao/ogc/exec.php
@@ -61,13 +61,7 @@ switch ($funcao) { @@ -61,13 +61,7 @@ switch ($funcao) {
61 61
62 outros 62 outros
63 63
64 - $dados["classesitem"] = $layer->getmetadata("classesitem");  
65 - $dados["classesnome"] = $layer->getmetadata("classesnome");  
66 - $dados["classescor"] = $layer->getmetadata("classescor");  
67 - $dados["classessimbolo"] = $layer->getmetadata("classessimbolo");  
68 - $dados["classestamanho"] = $layer->getmetadata("classestamanho");  
69 - $dados["palletefile"] = $layer->getmetadata("palletefile");  
70 - $dados["palletestep"] = $layer->getmetadata("palletestep"); 64 +
71 $dados["description_template"] = $layer->getmetadata("description_template"); 65 $dados["description_template"] = $layer->getmetadata("description_template");
72 $dados["editorsql"] = $layer->getmetadata("editorsql"); 66 $dados["editorsql"] = $layer->getmetadata("editorsql");
73 */ 67 */
admin1/catalogo/mapfile/editor/funcoes.php
@@ -23,9 +23,10 @@ function textoMapfile($codigo) { @@ -23,9 +23,10 @@ function textoMapfile($codigo) {
23 // isso e necessario para manter a consistencia caso o usuario altere manualmente os valores 23 // isso e necessario para manter a consistencia caso o usuario altere manualmente os valores
24 // cria o objeto map 24 // cria o objeto map
25 $mapa = ms_newMapObj ( $mapfile ); 25 $mapa = ms_newMapObj ( $mapfile );
26 - $layer = $mapa->getlayerbyname ( $codigo ); 26 + $layer = @$mapa->getlayerbyname ( $codigo );
  27 + $erro = "";
27 if ($layer == "") { 28 if ($layer == "") {
28 - return "<br><span style='color:red;'>Aten&ccedil;&atilde;o: n&atilde;o existe nenhum LAYER com NAME igual a " . $codigo . "</span><br>"; 29 + $erro = "Aten&ccedil;&atilde;o: n&atilde;o existe nenhum LAYER com NAME igual a " . $codigo;
29 } else { 30 } else {
30 // pega o metadata 31 // pega o metadata
31 $meta = $layer->getmetadata ( "permitedownload" ); 32 $meta = $layer->getmetadata ( "permitedownload" );
@@ -53,10 +54,12 @@ function textoMapfile($codigo) { @@ -53,10 +54,12 @@ function textoMapfile($codigo) {
53 } 54 }
54 $texto = file_get_contents ( $mapfile ); 55 $texto = file_get_contents ( $mapfile );
55 if (mb_detect_encoding ( $texto, 'UTF-8, ISO-8859-1' ) == "ISO-8859-1") { 56 if (mb_detect_encoding ( $texto, 'UTF-8, ISO-8859-1' ) == "ISO-8859-1") {
56 - return utf8_encode ( $texto );  
57 - } else {  
58 - return $texto; 57 + $texto = utf8_encode ( $texto );
59 } 58 }
  59 + return array (
  60 + "texto" => $texto,
  61 + "erro"=> $erro
  62 + );
60 } 63 }
61 function salvaMapfile() { 64 function salvaMapfile() {
62 global $dbhw, $codigo, $gravarTexto; 65 global $dbhw, $codigo, $gravarTexto;
admin1/catalogo/mapfile/editor/index.php
@@ -94,13 +94,14 @@ $textoMapfile = \admin\catalogo\mapfile\editor\textoMapfile ( $codigo ); @@ -94,13 +94,14 @@ $textoMapfile = \admin\catalogo\mapfile\editor\textoMapfile ( $codigo );
94 </div> 94 </div>
95 <div class="row center-block"> 95 <div class="row center-block">
96 <div class="col-md-12 well"> 96 <div class="col-md-12 well">
  97 + <span style="color:red;"><?php echo $textoMapfile["erro"]; ?></span>
97 <form action="index.php?codigo=<?php echo $codigo;?>&id_tema=<?php echo $id_tema;?>" method="post"> 98 <form action="index.php?codigo=<?php echo $codigo;?>&id_tema=<?php echo $id_tema;?>" method="post">
98 <TEXTAREA id=editor name=texto style='font-size: 16px; width: 100%; float: left; border: 2px dotted lightgray;'> 99 <TEXTAREA id=editor name=texto style='font-size: 16px; width: 100%; float: left; border: 2px dotted lightgray;'>
99 - <?php echo $textoMapfile; ?> 100 + <?php echo $textoMapfile["texto"]; ?>
100 </TEXTAREA> 101 </TEXTAREA>
101 </form> 102 </form>
102 <!-- para calcular a altura do textarea --> 103 <!-- para calcular a altura do textarea -->
103 - <pre id="editortemp" style="font-size: 16px; display: block; visibility: hidden;"><?php echo $textoMapfile; ?></pre> 104 + <pre id="editortemp" style="font-size: 16px; display: block; visibility: hidden;"><?php echo $textoMapfile["texto"]; ?></pre>
104 </div> 105 </div>
105 </div> 106 </div>
106 </div> 107 </div>
ferramentas/legenda/dicionario.js
@@ -856,5 +856,50 @@ i3GEOF.legenda.dicionario = @@ -856,5 +856,50 @@ i3GEOF.legenda.dicionario =
856 en : "", 856 en : "",
857 es : "" 857 es : ""
858 } 858 }
859 - ] 859 + ],
  860 + 'autoClasses' : [ {
  861 + pt : "&Eacute; poss&iacute;vel a gera&ccedil;&atilde;o de classes automaticamente por meio da defini&ccedil;&atilde;o de colunas na tabela de atributos do tema que armazenam as informa&ccedil;&otilde;es sobre cor, tamanho, etc.",
  862 + en : "",
  863 + es : ""
  864 + } ],
  865 + 'classesitem' : [ {
  866 + pt : "Qual a coluna da tabela que identifica unicamente cada classe. Para cada valor ser&aacute; criada uma classe. O tema que utiliza a gera&ccedil;&atilde;o de classes de forma autom&aacute;tica, deve ter definido apenas uma classe. Essa classe ser&aacute; utilizada como padr&atilde;o para gera&ccedil;&atilde;o das demais.",
  867 + en : "",
  868 + es : ""
  869 + } ],
  870 + 'classesnome' : [ {
  871 + pt : "Nome da coluna que ser&aacute; utilizada para compor o nome das classes geradas automaticamente.",
  872 + en : "",
  873 + es : ""
  874 + } ],
  875 + 'classescor' : [ {
  876 + pt : "Nome da coluna que definir&aacute; a cor do s&iacute;mbolo utilizado em cada classe. As cores devem ser definidas em RGB.",
  877 + en : "",
  878 + es : ""
  879 + } ],
  880 + 'classessimbolo' : [ {
  881 + pt : "Nome da coluna que definir&aacute; o s&iacute;mbolo utilizado em cada classe.",
  882 + en : "",
  883 + es : ""
  884 + } ],
  885 + 'classestamanho' : [ {
  886 + pt : "Nome da coluna que definir&aacute; o tamanho de cada s&iacute;mbolo.",
  887 + en : "",
  888 + es : ""
  889 + } ],
  890 + 'palletefile' : [ {
  891 + pt : "Palete de cores. Endere&ccedil;o do arquivo no servidor (opcional)",
  892 + en : "",
  893 + es : ""
  894 + } ],
  895 + 'palletestep' : [ {
  896 + pt : "Quantas cores em cada n&iacute;vel da palete (opcional)",
  897 + en : "",
  898 + es : ""
  899 + } ],
  900 + "colunasTxt" : [ {
  901 + pt : "Itens dispon&iacute;veis",
  902 + en : "",
  903 + es : ""
  904 + } ]
860 }; 905 };
ferramentas/legenda/exec.php
@@ -7,6 +7,39 @@ verificaBlFerramentas(basename(dirname(__FILE__)),$i3geoBlFerramentas,false); @@ -7,6 +7,39 @@ verificaBlFerramentas(basename(dirname(__FILE__)),$i3geoBlFerramentas,false);
7 $retorno = ""; //string que ser&aacute; retornada ao browser via JSON 7 $retorno = ""; //string que ser&aacute; retornada ao browser via JSON
8 switch (strtoupper($funcao)) 8 switch (strtoupper($funcao))
9 { 9 {
  10 + case "PARAMETROSAUTO":
  11 + $map = ms_newMapObj($map_file);
  12 + $layer = $map->getlayerbyname($tema);
  13 + $retorno = array();
  14 + $retorno["classesitem"] = $layer->getmetadata("classesitem");
  15 + $retorno["classesnome"] = $layer->getmetadata("classesnome");
  16 + $retorno["classescor"] = $layer->getmetadata("classescor");
  17 + $retorno["classessimbolo"] = $layer->getmetadata("classessimbolo");
  18 + $retorno["classestamanho"] = $layer->getmetadata("classestamanho");
  19 + $retorno["palletefile"] = $layer->getmetadata("palletefile");
  20 + $retorno["palletestep"] = $layer->getmetadata("palletestep");
  21 + $sopen = $layer->open();
  22 + if($sopen != MS_FAILURE){
  23 + $items = $layer->getItems();
  24 + }
  25 + else{
  26 + $items = array();
  27 + }
  28 + $retorno["colunas"] = implode(",",$items);
  29 + break;
  30 + case "SALVAPARAMETROSAUTO":
  31 + $map = ms_newMapObj($map_file);
  32 + $layer = $map->getlayerbyname($tema);
  33 + $layer->setmetadata("classesitem",$_GET["classesitem"]);
  34 + $layer->setmetadata("classesnome",$_GET["classesnome"]);
  35 + $layer->setmetadata("classescor",$_GET["classescor"]);
  36 + $layer->setmetadata("classessimbolo",$_GET["classessimbolo"]);
  37 + $layer->setmetadata("classestamanho",$_GET["classestamanho"]);
  38 + $layer->setmetadata("palletefile",$_GET["palletefile"]);
  39 + $layer->setmetadata("palletestep",$_GET["palletestep"]);
  40 + $map->save($map_file);
  41 + $retorno = "ok";
  42 + break;
10 /* 43 /*
11 Valor: TEMA2SLD 44 Valor: TEMA2SLD
12 45
ferramentas/legenda/index.js
@@ -135,6 +135,11 @@ i3GEOF.legenda = @@ -135,6 +135,11 @@ i3GEOF.legenda =
135 $i(iddiv).innerHTML += i3GEOF.legenda.html(); 135 $i(iddiv).innerHTML += i3GEOF.legenda.html();
136 i3GEO.guias.mostraGuiaFerramenta("i3GEOlegendaguia1", "i3GEOlegendaguia"); 136 i3GEO.guias.mostraGuiaFerramenta("i3GEOlegendaguia1", "i3GEOlegendaguia");
137 // eventos das guias 137 // eventos das guias
  138 + $i("i3GEOlegendaguia8").onclick = function() {
  139 + i3GEOF.legenda.ativaAplicar("none");
  140 + i3GEO.guias.mostraGuiaFerramenta("i3GEOlegendaguia8", "i3GEOlegendaguia");
  141 + i3GEOF.legenda.parametrosAuto();
  142 + };
138 $i("i3GEOlegendaguia7").onclick = function() { 143 $i("i3GEOlegendaguia7").onclick = function() {
139 i3GEOF.legenda.ativaAplicar("none"); 144 i3GEOF.legenda.ativaAplicar("none");
140 i3GEO.guias.mostraGuiaFerramenta("i3GEOlegendaguia7", "i3GEOlegendaguia"); 145 i3GEO.guias.mostraGuiaFerramenta("i3GEOlegendaguia7", "i3GEOlegendaguia");
@@ -192,6 +197,13 @@ i3GEOF.legenda = @@ -192,6 +197,13 @@ i3GEOF.legenda =
192 }); 197 });
193 b.addClass("rodar"); 198 b.addClass("rodar");
194 199
  200 + var b = new YAHOO.widget.Button("i3GEOlegendabotaoAplicarAuto", {
  201 + onclick : {
  202 + fn : i3GEOF.legenda.salvaParametrosAuto
  203 + }
  204 + });
  205 + b.addClass("rodar");
  206 +
195 var b = new YAHOO.widget.Button("i3GEOlegendabotao1", { 207 var b = new YAHOO.widget.Button("i3GEOlegendabotao1", {
196 onclick : { 208 onclick : {
197 fn : i3GEOF.legenda.mudaLegenda 209 fn : i3GEOF.legenda.mudaLegenda
@@ -456,7 +468,7 @@ i3GEOF.legenda = @@ -456,7 +468,7 @@ i3GEOF.legenda =
456 + i3GEO.configura.locaplic 468 + i3GEO.configura.locaplic
457 + "/ajuda_usuario.php?idcategoria=5&idajuda=41' ><b> </b></a></div></div></div>"; 469 + "/ajuda_usuario.php?idcategoria=5&idajuda=41' ><b> </b></a></div></div></div>";
458 janela = 470 janela =
459 - i3GEO.janela.cria("540px", "350px", "", "", "", titulo, "i3GEOF.legenda", false, "hd", cabecalho, minimiza, function() { 471 + i3GEO.janela.cria("590px", "350px", "", "", "", titulo, "i3GEOF.legenda", false, "hd", cabecalho, minimiza, function() {
460 i3GEO.guias.ajustaGuiaFerramenta("i3GEOF.legenda", "i3GEOlegenda"); 472 i3GEO.guias.ajustaGuiaFerramenta("i3GEOF.legenda", "i3GEOlegenda");
461 }, true, "", "", "nao"); 473 }, true, "", "", "nao");
462 divid = janela[2].id; 474 divid = janela[2].id;
@@ -2429,5 +2441,55 @@ i3GEOF.legenda = @@ -2429,5 +2441,55 @@ i3GEOF.legenda =
2429 $i("i3GEOlegendaitensValorQuartil").innerHTML = retorno.dados; 2441 $i("i3GEOlegendaitensValorQuartil").innerHTML = retorno.dados;
2430 } 2442 }
2431 }); 2443 });
  2444 + },
  2445 + parametrosAuto : function() {
  2446 + i3GEOF.legenda.aguarde.visibility = "visible";
  2447 + var p = i3GEO.configura.locaplic+"/ferramentas/legenda/exec.php?g_sid="+i3GEO.configura.sid+"&funcao=parametrosauto&tema=" + i3GEOF.legenda.tema,
  2448 + cp = new cpaint(),
  2449 + temp = function(retorno){
  2450 + try{
  2451 + if(retorno.data !== ""){
  2452 + $i("i3GEOlegendaAutocolunas").innerHTML = retorno.data.colunas;
  2453 + $i("i3GEOlegendaAutoclassesitem").value = retorno.data.classesitem;
  2454 + $i("i3GEOlegendaAutoclassesnome").value = retorno.data.classesnome;
  2455 + $i("i3GEOlegendaAutoclassescor").value = retorno.data.classescor;
  2456 + $i("i3GEOlegendaAutoclassessimbolo").value = retorno.data.classessimbolo;
  2457 + $i("i3GEOlegendaAutoclassestamanho").value = retorno.data.classestamanho;
  2458 + $i("i3GEOlegendaAutopalletefile").value = retorno.data.palletefile;
  2459 + $i("i3GEOlegendaAutopalletestep").value = retorno.data.palletestep;
  2460 + }
  2461 + i3GEOF.legenda.aguarde.visibility = "hidden";
  2462 + }catch(e){
  2463 + i3GEO.janela.tempoMsg("Erro. "+e);
  2464 + i3GEOF.legenda.aguarde.visibility = "hidden";
  2465 + }
  2466 + };
  2467 + cp.set_response_type("JSON");
  2468 + cp.call(p,"foo",temp);
  2469 + },
  2470 + salvaParametrosAuto: function(){
  2471 + if(i3GEOF.legenda.aguarde.visibility === "visible"){
  2472 + return;
  2473 + }
  2474 + i3GEOF.legenda.aguarde.visibility = "visible";
  2475 + var temp,
  2476 + p,
  2477 + cp;
  2478 + temp = function(){
  2479 + i3GEOF.legenda.aguarde.visibility = "hidden";
  2480 + i3GEOF.legenda.aposAlterarLegenda();
  2481 + };
  2482 + p = i3GEO.configura.locaplic+"/ferramentas/legenda/exec.php?g_sid="+i3GEO.configura.sid+"&funcao=salvaparametrosauto&tema=" + i3GEOF.legenda.tema
  2483 + + "&classesitem=" + $i("i3GEOlegendaAutoclassesitem").value
  2484 + + "&classesnome=" + $i("i3GEOlegendaAutoclassesnome").value
  2485 + + "&classescor=" + $i("i3GEOlegendaAutoclassescor").value
  2486 + + "&classessimbolo=" + $i("i3GEOlegendaAutoclassessimbolo").value
  2487 + + "&classestamanho=" + $i("i3GEOlegendaAutoclassestamanho").value
  2488 + + "&palletefile=" + $i("i3GEOlegendaAutopalletefile").value
  2489 + + "&palletestep=" + $i("i3GEOlegendaAutopalletestep").value;
  2490 +
  2491 + cp = new cpaint();
  2492 + cp.set_response_type("JSON");
  2493 + cp.call(p,"foo",temp);
2432 } 2494 }
2433 }; 2495 };
2434 \ No newline at end of file 2496 \ No newline at end of file
ferramentas/legenda/template_mst.html
@@ -50,9 +50,63 @@ @@ -50,9 +50,63 @@
50 </a> 50 </a>
51 </div> 51 </div>
52 </li> 52 </li>
  53 + <li>
  54 + <div id='i3GEOlegendaguia8' style='text-align: center; left: 0px;'>
  55 + <a>
  56 + <em>Auto</em>
  57 + </a>
  58 + </div>
  59 + </li>
53 </ul> 60 </ul>
54 </div> 61 </div>
55 <br> 62 <br>
  63 +<div id='i3GEOlegendaguia8obj' style='width: 99%; text-align: left;'>
  64 + <p class='paragrafo'>{{{colunasTxt}}}:</p>
  65 + <div id="i3GEOlegendaAutocolunas">
  66 + </div>
  67 + <br>
  68 + <p class='paragrafo'>{{{autoClasses}}}</p>
  69 + <br>
  70 + <p class='paragrafo'>{{{classesitem}}}:</p>
  71 + <div class='styled-select'>
  72 + <input type='text' id='i3GEOlegendaAutoclassesitem' value='' />
  73 + </div>
  74 + <br>
  75 + <p class='paragrafo'>{{{classesnome}}}:</p>
  76 + <div class='styled-select'>
  77 + <input type='text' id='i3GEOlegendaAutoclassesnome' value='' />
  78 + </div>
  79 + <br>
  80 + <p class='paragrafo'>{{{classescor}}}:</p>
  81 + <div class='styled-select'>
  82 + <input type='text' id='i3GEOlegendaAutoclassescor' value='' />
  83 + </div>
  84 + <br>
  85 + <p class='paragrafo'>{{{classessimbolo}}}:</p>
  86 + <div class='styled-select'>
  87 + <input type='text' id='i3GEOlegendaAutoclassessimbolo' value='' />
  88 + </div>
  89 + <br>
  90 + <p class='paragrafo'>{{{classestamanho}}}:</p>
  91 + <div class='styled-select'>
  92 + <input type='text' id='i3GEOlegendaAutoclassestamanho' value='' />
  93 + </div>
  94 + <br>
  95 + <p class='paragrafo'>{{{palletefile}}}:</p>
  96 + <div class='styled-select'>
  97 + <input type='text' id='i3GEOlegendaAutopalletefile' value='' />
  98 + </div>
  99 + <br>
  100 + <p class='paragrafo'>{{{palletestep}}}:</p>
  101 + <div class='styled-select'>
  102 + <input type='text' id='i3GEOlegendaAutopalletestep' value='' />
  103 + </div>
  104 + <br>
  105 + <p class='paragrafo'>
  106 + <input id='i3GEOlegendabotaoAplicarAuto' size='35' type='button' value='{{{aplicar}}}'>
  107 + </p>
  108 + <br>
  109 +</div>
56 <div id='i3GEOlegendaguia7obj' style='width: 99%; text-align: left;'> 110 <div id='i3GEOlegendaguia7obj' style='width: 99%; text-align: left;'>
57 <p class='paragrafo'>{{{ClusterMaxdistance}}}:</p> 111 <p class='paragrafo'>{{{ClusterMaxdistance}}}:</p>
58 <div class='i3geoForm i3geoFormIconeNumero'> 112 <div class='i3geoForm i3geoFormIconeNumero'>
temas/_lautolegenda_exemplo.map
1 -MAP  
2 - FONTSET "../symbols/fontes.txt"  
3 - SYMBOLSET "../symbols/simbolos.sym"  
4 - LAYER  
5 - DATA "/var/www/i3geo/aplicmap/dados/biomas.shp"  
6 - METADATA  
7 - "METAESTAT_ID_MEDIDA_VARIAVEL" ""  
8 - "ltempoitemimagem" ""  
9 - "cache" "SIM"  
10 - "ltempoitemdescricao" ""  
11 - "CLASSE" "SIM"  
12 - "ltempoiteminicio" ""  
13 - "palletestep" ""  
14 - "ltempoitemtip" ""  
15 - "permitekmz" "nao"  
16 - "iconetema" ""  
17 - "ltempoitemtitulo" ""  
18 - "description_template" ""  
19 - "ITENSDESC" "Nome"  
20 - "ltempoitemlink" ""  
21 - "CLASSESNOME" "CD_LEGENDA"  
22 - "METAESTAT_CODIGO_TIPO_REGIAO" ""  
23 - "palletefile" ""  
24 - "ltempoformatodata" ""  
25 - "permitedownload" "sim"  
26 - "ltempoitemicone" ""  
27 - "CLASSESITEM" "ID"  
28 - "metaestat" ""  
29 - "CLASSESCOR" "COR"  
30 - "arquivodownload" ""  
31 - "ITENS" "CD_LEGENDA"  
32 - "permiteogc" "sim"  
33 - "permitekml" "sim"  
34 - "TEMA" "_Teste de geração automática de classes em dados vetoriais"  
35 - "editorsql" ""  
36 - "ltempoitemfim" ""  
37 - END # METADATA  
38 - NAME "_wautolegenda_exemplo"  
39 - STATUS OFF  
40 - TEMPLATE "none.htm"  
41 - TILEITEM "location"  
42 - TYPE POLYGON  
43 - UNITS METERS  
44 - CLASS  
45 - STYLE  
46 - ANGLE 0  
47 - OFFSET 0 0  
48 - OUTLINECOLOR 250 50 50  
49 - END # STYLE  
50 - END # CLASS  
51 - END # LAYER  
52 -  
53 -END # MAP  
54 - 1 + MAP
  2 + FONTSET "../symbols/fontes.txt"
  3 + SYMBOLSET "../symbols/simbolos.sym"
  4 + LAYER
  5 + DATA "/var/www/i3geo/aplicmap/dados/biomas.shp"
  6 + METADATA
  7 + "cache" "SIM"
  8 + "ltempoitemdescricao" ""
  9 + "CLASSE" "SIM"
  10 + "ltempoiteminicio" ""
  11 + "ltempoitemtip" ""
  12 + "permitekmz" "nao"
  13 + "ITENSDESC" "Nome"
  14 + "CLASSESNOME" "CD_LEGENDA"
  15 + "permitedownload" "sim"
  16 + "CLASSESITEM" "ID"
  17 + "CLASSESCOR" "COR"
  18 + "ITENS" "CD_LEGENDA"
  19 + "permiteogc" "sim"
  20 + "permitekml" "sim"
  21 + "TEMA" "_Teste de geração automática de classes em dados vetoriais"
  22 + END # METADATA
  23 + NAME "_lautolegenda_exemplo"
  24 + STATUS OFF
  25 + TEMPLATE "none.htm"
  26 + TILEITEM "location"
  27 + TYPE POLYGON
  28 + UNITS METERS
  29 + CLASS
  30 + STYLE
  31 + ANGLE 0
  32 + OFFSET 0 0
  33 + OUTLINECOLOR 250 50 50
  34 + END # STYLE
  35 + END # CLASS
  36 + END # LAYER
  37 +END # MAP
  38 +
55 \ No newline at end of file 39 \ No newline at end of file