Commit ba84fc025367b63e50ed4323294f78ea33685d59

Authored by Edmar Moretti
1 parent aac035bd
Exists in master

Inclusão da opção cluster na legenda e correção na aplicação de offset em estilos

classesphp/classe_legenda.php
... ... @@ -1106,6 +1106,12 @@ class Legenda
1106 1106 case "width":
1107 1107 $estilo->set("width",$valor);
1108 1108 continue;
  1109 + case "offsetx":
  1110 + $estilo->set("offsetx",$valor);
  1111 + continue;
  1112 + case "offsety":
  1113 + $estilo->set("offsety",$valor);
  1114 + continue;
1109 1115 case "opacity":
1110 1116 $estilo->set("opacity",$valor);
1111 1117 continue;
... ...
classesphp/classe_temas.php
... ... @@ -1296,5 +1296,30 @@ Adiciona LABEL em uma classe de um tema
1296 1296 $this->layer->setMetaData("cache","");
1297 1297 }
1298 1298 }
  1299 + function criaCluster ($group = "",$filter = "",$maxdistance=5,$region='rectangle',$buffer=0){
  1300 + if($group != ""){
  1301 + $group = "('[".$group."]')";
  1302 + }
  1303 + $cluster = $this->layer->cluster;
  1304 +
  1305 + $par = "BUFFER $buffer REGION $region MAXDISTANCE $maxdistance";
  1306 + if($group != ""){
  1307 + $par .= " GROUP ".$group;
  1308 + }
  1309 + if($filter != ""){
  1310 + $par .= " FILTER ".$filter;
  1311 + }
  1312 + $cluster->updateFromString("CLUSTER $par END");
  1313 + $this->layer->setMetaData("cache","");
  1314 + $this->layer->setMetadata("tiles","NAO");
  1315 + $this->layer->setMetadata("cortepixels",0);
  1316 + }
  1317 + function removeCluster(){
  1318 + $cluster = $this->layer->cluster;
  1319 + $this->layer->updatefromstring("LAYER CLUSTER END END");
  1320 + $this->layer->setMetaData("cache","");
  1321 + $this->layer->setMetadata("tiles","NAO");
  1322 + $this->layer->setMetadata("cortepixels",0);
  1323 + }
1299 1324 }
1300 1325 ?>
... ...
classesphp/funcoes_gerais.php
... ... @@ -2826,7 +2826,10 @@ function restauraMapaAdmin($id_mapa,$dir_tmp){
2826 2826 //verifica se existem parametros junto com o registro
2827 2827 $registro = explode(",",$registro);
2828 2828 $mapfile = $registro[0];
2829   - $s = fwrite($baseh,base64_decode($mapfile));
  2829 + //adapta para versoes novas do mapserver
  2830 + $mapfile = base64_decode($mapfile);
  2831 + $mapfile = str_replace("TYPE ANNOTATION","TYPE POINT",$mapfile);
  2832 + $s = fwrite($baseh,$mapfile);
2830 2833 fclose($baseh);
2831 2834 }
2832 2835 $dbh = null;
... ...
ferramentas/legenda/dicionario.js
... ... @@ -45,7 +45,7 @@ i3GEOF.legenda.dicionario =
45 45 ],
46 46 'importaExportaSLD' : [
47 47 {
48   - pt : "Importar/exportar SLD",
  48 + pt : "SLD",
49 49 en : "",
50 50 es : ""
51 51 }
... ... @@ -793,5 +793,54 @@ i3GEOF.legenda.dicionario =
793 793 en : "",
794 794 es : ""
795 795 }
796   - ]
  796 + ],
  797 + "cluster" : [
  798 + {
  799 + pt : "Cluster",
  800 + en : "",
  801 + es : ""
  802 + }
  803 + ],
  804 + "ClusterMaxdistance" : [
  805 + {
  806 + pt : "Distância (pixels) máxima entre os pontos que será considerada para permitir o agrupamento",
  807 + en : "",
  808 + es : ""
  809 + }
  810 + ],
  811 + "ClusterBuffer" : [
  812 + {
  813 + pt : "Distância em pixel, no entorno da extensão geográfica do mapa ou dos tiles, se for o caso, que extende a área de pesuisa dos pontos para formação do agrupamento",
  814 + en : "",
  815 + es : ""
  816 + }
  817 + ],
  818 + "ClusterFilter" : [
  819 + {
  820 + pt : "Filtro que será aplicado para restringir os pontos que podem participar do agrupamento. A sintaxe do filtro é a mesma utilizada na definição das expressões que definem cada classe (ver o editor de classes)",
  821 + en : "",
  822 + es : ""
  823 + }
  824 + ],
  825 + "ClusterRegion" : [
  826 + {
  827 + pt : "Tipo de forma que será utilizada na definição da região de busca dos pontos que formarão o agrupamento",
  828 + en : "",
  829 + es : ""
  830 + }
  831 + ],
  832 + "ClusterGroup" : [
  833 + {
  834 + pt : "Item que será utilizado para separar os diferentes agrupamentos",
  835 + en : "",
  836 + es : ""
  837 + }
  838 + ],
  839 + "remover" : [
  840 + {
  841 + pt : "Remover",
  842 + en : "",
  843 + es : ""
  844 + }
  845 + ]
797 846 };
... ...
ferramentas/legenda/exec.php
... ... @@ -98,6 +98,25 @@ Acrescenta a contagem de elementos em cada classe.
98 98 if (!$r){$r = "erro.Erro legenda nao disponivel";}
99 99 $retorno = $r;
100 100 break;
  101 + case "APLICARCLUSTER":
  102 + include_once(dirname(__FILE__)."/../../classesphp/classe_temas.php");
  103 + $m = new Temas($map_file,$tema);
  104 + $l = $m->mapa->getlayerbyname($tema);
  105 + if($filter != ""){
  106 + $filter = base64decode($filter);
  107 + }
  108 + $m->criaCluster($group,$filter,$maxdistance,$region,$buffer);
  109 + $m->salva();
  110 + $retorno = "ok";
  111 + break;
  112 + case "REMOVERCLUSTER":
  113 + include_once(dirname(__FILE__)."/../../classesphp/classe_temas.php");
  114 + $m = new Temas($map_file,$tema);
  115 + $l = $m->mapa->getlayerbyname($tema);
  116 + $m->removeCluster();
  117 + $m->salva();
  118 + $retorno = "ok";
  119 + break;
101 120 }
102 121 if (!connection_aborted()){
103 122 if(isset($map_file) && isset($postgis_mapa) && $map_file != "")
... ...
ferramentas/legenda/index.js
... ... @@ -135,6 +135,10 @@ i3GEOF.legenda =
135 135 $i(iddiv).innerHTML += i3GEOF.legenda.html();
136 136 i3GEO.guias.mostraGuiaFerramenta("i3GEOlegendaguia1", "i3GEOlegendaguia");
137 137 // eventos das guias
  138 + $i("i3GEOlegendaguia7").onclick = function() {
  139 + i3GEOF.legenda.ativaAplicar("none");
  140 + i3GEO.guias.mostraGuiaFerramenta("i3GEOlegendaguia7", "i3GEOlegendaguia");
  141 + };
138 142 $i("i3GEOlegendaguia6").onclick = function() {
139 143 i3GEOF.legenda.ativaAplicar("none");
140 144 i3GEO.guias.mostraGuiaFerramenta("i3GEOlegendaguia6", "i3GEOlegendaguia");
... ... @@ -159,6 +163,21 @@ i3GEOF.legenda =
159 163 i3GEOF.legenda.ativaAplicar("none");
160 164 i3GEO.guias.mostraGuiaFerramenta("i3GEOlegendaguia5", "i3GEOlegendaguia");
161 165 };
  166 +
  167 + var b = new YAHOO.widget.Button("i3GEOlegendabotaoAplicarCluster", {
  168 + onclick : {
  169 + fn : i3GEOF.legenda.aplicarCluster
  170 + }
  171 + });
  172 + b.addClass("rodar");
  173 +
  174 + var b = new YAHOO.widget.Button("i3GEOlegendabotaoRemoverCluster", {
  175 + onclick : {
  176 + fn : i3GEOF.legenda.removerCluster
  177 + }
  178 + });
  179 + b.addClass("rodar");
  180 +
162 181 var b = new YAHOO.widget.Button("i3GEOlegendabotao1", {
163 182 onclick : {
164 183 fn : i3GEOF.legenda.mudaLegenda
... ... @@ -357,29 +376,7 @@ i3GEOF.legenda =
357 376 b.addClass("abrir100");
358 377 i3GEOF.legenda.ativaFoco();
359 378 i3GEOF.legenda.mostralegenda();
360   - i3GEO.util.comboItens("", i3GEOF.legenda.tema, function(retorno) {
361   - if ($i("i3GEOlegendaitensValorUnico")) {
362   - $i("i3GEOlegendaitensValorUnico").innerHTML = retorno.dados;
363   - }
364   - if ($i("i3GEOlegendaClassesValorUnico")) {
365   - $i("i3GEOlegendaClassesValorUnico").innerHTML = retorno.dados;
366   - }
367   - if ($i("i3GEOlegendaitensMetade")) {
368   - $i("i3GEOlegendaitensMetade").innerHTML = retorno.dados;
369   - }
370   - if ($i("i3GEOlegendaitensMetadeId")) {
371   - $i("i3GEOlegendaitensMetadeId").innerHTML = retorno.dados;
372   - }
373   - if ($i("i3GEOlegendaitensMedia")) {
374   - $i("i3GEOlegendaitensMedia").innerHTML = retorno.dados;
375   - }
376   - if ($i("i3GEOlegendaitensValorClass")) {
377   - $i("i3GEOlegendaitensValorClass").innerHTML = retorno.dados;
378   - }
379   - if ($i("i3GEOlegendaitensValorQuartil")) {
380   - $i("i3GEOlegendaitensValorQuartil").innerHTML = retorno.dados;
381   - }
382   - });
  379 + i3GEOF.legenda.montaCombosItens();
383 380 if (i3GEO.arvoreDeCamadas.pegaTema(i3GEOF.legenda.tema).classe && i3GEO.arvoreDeCamadas.pegaTema(i3GEOF.legenda.tema).classe
384 381 .toLowerCase() == "nao") {
385 382 $i("i3GEOFlegendamostra").checked = false;
... ... @@ -494,6 +491,7 @@ i3GEOF.legenda =
494 491 * Função executada após ocorrer alguma alteração efetiva da legenda do mapa
495 492 */
496 493 aposAlterarLegenda : function() {
  494 + i3GEO.arvoreDeCamadas.CAMADAS = [];
497 495 i3GEO.atualiza();
498 496 i3GEO.Interface.atualizaTema("", i3GEOF.legenda.tema);
499 497 i3GEO.arvoreDeCamadas.atualizaLegenda(i3GEOF.legenda.tema);
... ... @@ -1930,7 +1928,7 @@ i3GEOF.legenda =
1930 1928 + "' id='i3GEOlegendamaxsize' />"
1931 1929 + "</form></div>"
1932 1930  
1933   - + "<br><img style='float:left;' onclick='i3GEOF.legenda.aplicaTodasClasses(\"offsetx\",\"i3GEOlegendasymbolname\")' title='"
  1931 + + "<br><img style='float:left;' onclick='i3GEOF.legenda.aplicaTodasClasses(\"offsetx\",\"i3GEOlegendaoffsetx\")' title='"
1934 1932 + $trad('aplicatodos', i3GEOF.legenda.dicionario)
1935 1933 + "' src='"
1936 1934 + i3GEO.configura.locaplic
... ... @@ -1945,7 +1943,7 @@ i3GEOF.legenda =
1945 1943 + "' id='i3GEOlegendaoffsetx' />"
1946 1944 + "</form></div>"
1947 1945  
1948   - + "<br><img style='float:left;' onclick='i3GEOF.legenda.aplicaTodasClasses(\"offsety\",\"i3GEOlegendasymbolname\")' title='"
  1946 + + "<br><img style='float:left;' onclick='i3GEOF.legenda.aplicaTodasClasses(\"offsety\",\"i3GEOlegendaoffsety\")' title='"
1949 1947 + $trad('aplicatodos', i3GEOF.legenda.dicionario)
1950 1948 + "' src='"
1951 1949 + i3GEO.configura.locaplic
... ... @@ -2280,5 +2278,73 @@ i3GEOF.legenda =
2280 2278 cp.set_response_type("JSON");
2281 2279 cp.call(p, "foo", temp);
2282 2280 });
  2281 + },
  2282 + aplicarCluster : function(){
  2283 + var temp = function() {
  2284 + i3GEOF.legenda.aposAlterarLegenda();
  2285 + i3GEOF.legenda.montaCombosItens();
  2286 + }, p, cp;
  2287 + p =
  2288 + i3GEO.configura.locaplic + "/ferramentas/legenda/exec.php?g_sid="
  2289 + + i3GEO.configura.sid
  2290 + + "&funcao=aplicarCluster"
  2291 + + "&maxdistance="
  2292 + + $i("i3GEOlegendaClusterMaxdistance").value
  2293 + + "&buffer="
  2294 + + $i("i3GEOlegendaClusterBuffer").value
  2295 + + "&filter="
  2296 + + i3GEO.util.base64encode($i("i3GEOlegendaClusterFilter").value)
  2297 + + "&region="
  2298 + + $i("i3GEOlegendaClusterRegion").value
  2299 + + "&group="
  2300 + + $i("i3GEOlegendaitensCluster").getElementsByTagName("select")[0].value
  2301 + + "&tema="
  2302 + + i3GEOF.legenda.tema;
  2303 + cp = new cpaint();
  2304 + cp.set_response_type("JSON");
  2305 + cp.call(p, "foo", temp);
  2306 + },
  2307 + removerCluster : function(){
  2308 + var temp = function() {
  2309 + i3GEOF.legenda.montaCombosItens();
  2310 + i3GEOF.legenda.aposAlterarLegenda();
  2311 + }, p, cp;
  2312 + p =
  2313 + i3GEO.configura.locaplic + "/ferramentas/legenda/exec.php?g_sid="
  2314 + + i3GEO.configura.sid
  2315 + + "&funcao=removerCluster"
  2316 + + "&tema="
  2317 + + i3GEOF.legenda.tema;
  2318 + cp = new cpaint();
  2319 + cp.set_response_type("JSON");
  2320 + cp.call(p, "foo", temp);
  2321 + },
  2322 + montaCombosItens : function(){
  2323 + i3GEO.util.comboItens("", i3GEOF.legenda.tema, function(retorno) {
  2324 + if ($i("i3GEOlegendaitensValorUnico")) {
  2325 + $i("i3GEOlegendaitensValorUnico").innerHTML = retorno.dados;
  2326 + }
  2327 + if ($i("i3GEOlegendaClassesValorUnico")) {
  2328 + $i("i3GEOlegendaClassesValorUnico").innerHTML = retorno.dados;
  2329 + }
  2330 + if ($i("i3GEOlegendaitensMetade")) {
  2331 + $i("i3GEOlegendaitensMetade").innerHTML = retorno.dados;
  2332 + }
  2333 + if ($i("i3GEOlegendaitensMetadeId")) {
  2334 + $i("i3GEOlegendaitensMetadeId").innerHTML = retorno.dados;
  2335 + }
  2336 + if ($i("i3GEOlegendaitensMedia")) {
  2337 + $i("i3GEOlegendaitensMedia").innerHTML = retorno.dados;
  2338 + }
  2339 + if ($i("i3GEOlegendaitensValorClass")) {
  2340 + $i("i3GEOlegendaitensValorClass").innerHTML = retorno.dados;
  2341 + }
  2342 + if ($i("i3GEOlegendaitensCluster")) {
  2343 + $i("i3GEOlegendaitensCluster").innerHTML = retorno.dados;
  2344 + }
  2345 + if ($i("i3GEOlegendaitensValorQuartil")) {
  2346 + $i("i3GEOlegendaitensValorQuartil").innerHTML = retorno.dados;
  2347 + }
  2348 + });
2283 2349 }
2284 2350 };
2285 2351 \ No newline at end of file
... ...
ferramentas/legenda/template_mst.html
... ... @@ -43,9 +43,51 @@
43 43 </a>
44 44 </div>
45 45 </li>
  46 + <li>
  47 + <div id='i3GEOlegendaguia7' style='text-align: center; left: 0px;'>
  48 + <a>
  49 + <em>{{{cluster}}}</em>
  50 + </a>
  51 + </div>
  52 + </li>
46 53 </ul>
47 54 </div>
48 55 <br>
  56 +<div id='i3GEOlegendaguia7obj' style='width: 99%; text-align: left;'>
  57 + <p class='paragrafo'>{{{ClusterMaxdistance}}}:</p>
  58 + <div class='i3geoForm i3geoFormIconeNumero'>
  59 + <input type='number' id='i3GEOlegendaClusterMaxdistance' value='5' />
  60 + </div>
  61 + <br>
  62 + <p class='paragrafo'>{{{ClusterBuffer}}}:</p>
  63 + <div class='i3geoForm i3geoFormIconeNumero'>
  64 + <input type='number' id='i3GEOlegendaClusterBuffer' value='0' />
  65 + </div>
  66 + <br>
  67 + <p class='paragrafo'>{{{ClusterFilter}}}:</p>
  68 + <div class='i3geoForm i3geoFormIconeNumero'>
  69 + <input type='text' id='i3GEOlegendaClusterFilter' value='' />
  70 + </div>
  71 + <br>
  72 + <p class='paragrafo'>{{{ClusterRegion}}}</p>
  73 + <div class='styled-select'>
  74 + <select id='i3GEOlegendaClusterRegion'>
  75 + <option value='rectangle'>rectangle</option>
  76 + <option value='ellipse'>ellipse</option>
  77 + </select>
  78 + </div>
  79 + <br>
  80 + <p class='paragrafo'>{{{ClusterGroup}}}</p>
  81 + <div id='i3GEOlegendaitensCluster' class='styled-select'></div>
  82 + <br>
  83 + <p class='paragrafo'>
  84 + <input id='i3GEOlegendabotaoAplicarCluster' size='35' type='button' value='{{{aplicar}}}'>
  85 + </p>
  86 + <br>
  87 + <p class='paragrafo'>
  88 + <input id='i3GEOlegendabotaoRemoverCluster' size='35' type='button' value='{{{remover}}}'>
  89 + </p>
  90 +</div>
49 91 <div id='i3GEOlegendaguia6obj' style='width: 99%; text-align: left;'>
50 92 <p class='paragrafo'>
51 93 &nbsp;
... ...