Commit 79cdfce56b57c443dbf041ce622f4b6df8fdd3c4

Authored by Edmar Moretti
1 parent 5088b833

Criação de opção para inclusão de um prefixo no nome do LAYER quando o cache est…

…iver ativo. Dessa forma é possível evitar o uso de cache antigo após alterar as configurações de um layer
admin/catalogo/mapfile/renderizacao/exec.php
... ... @@ -37,12 +37,22 @@ $codigo = str_replace ( ".", "", $codigo );
37 37 $codigo = strip_tags ( $codigo );
38 38 $codigo = htmlspecialchars ( $codigo, ENT_QUOTES );
39 39  
  40 +if(isset($_POST ["cacheprefixo"])){
  41 + $cacheprefixo = $_POST ["cacheprefixo"];
  42 + $cacheprefixo = str_replace ( " ", "", \admin\php\funcoesAdmin\removeAcentos ( $cacheprefixo ) );
  43 + $cacheprefixo = str_replace ( ".", "", $cacheprefixo );
  44 + $cacheprefixo = strip_tags ( $cacheprefixo );
  45 + $cacheprefixo = htmlspecialchars ( $cacheprefixo, ENT_QUOTES );
  46 +} else {
  47 + $cacheprefixo = "";
  48 +}
  49 +
40 50 $id_tema = ( int ) $_POST ["id_tema"];
41 51  
42 52 $funcao = strtoupper ( $funcao );
43 53 switch ($funcao) {
44 54 case "ALTERAR" :
45   - $dados = \admin\catalogo\mapfile\renderizacao\alterar ( $_SESSION["locaplic"], $id_tema, $codigo, $_POST["cache"], $_POST["tiles"], $_POST["maxfeatures"], $_POST["cortepixels"]);
  55 + $dados = \admin\catalogo\mapfile\renderizacao\alterar ( $_SESSION["locaplic"], $id_tema, $codigo, $_POST["cache"], $_POST["tiles"], $_POST["maxfeatures"], $_POST["cortepixels"], $cacheprefixo);
46 56 if ($dados === false) {
47 57 header ( "HTTP/1.1 500 erro ao consultar banco de dados" );
48 58 }
... ...
admin/catalogo/mapfile/renderizacao/funcoes.php
... ... @@ -12,6 +12,7 @@ function listar($locaplic,$codigo){
12 12 exit ();
13 13 }
14 14 $dados = array ();
  15 + $dados["cacheprefixo"] = strtoupper($layer->getmetadata("cacheprefixo"));
15 16 $dados["cache"] = strtoupper($layer->getmetadata("cache"));
16 17 if($dados["cache"] == ""){
17 18 $dados["cache"] = "NAO";
... ... @@ -27,8 +28,8 @@ function listar($locaplic,$codigo){
27 28 }
28 29 return $dados;
29 30 }
30   -function alterar($locaplic, $id_tema, $codigo, $cache, $tiles, $maxfeatures, $cortepixels) {
31   - $arq = $locaplic . "/temas/" . $codigo . ".map";
  31 +function alterar($locaplic, $id_tema, $codigo, $cache, $tiles, $maxfeatures, $cortepixels, $cacheprefixo) {
  32 + $arq = $locaplic . "/temas/" . $codigo . ".map";
32 33 if (! file_exists ( $locaplic . "/temas/" . $codigo . ".map" )) {
33 34 return false;
34 35 }
... ... @@ -38,6 +39,7 @@ function alterar($locaplic, $id_tema, $codigo, $cache, $tiles, $maxfeatures, $co
38 39 return false;
39 40 }
40 41 $layer->setmetadata ( "cache", $cache );
  42 + $layer->setmetadata ( "cacheprefixo", $cacheprefixo );
41 43 $layer->setmetadata ( "tiles", $tiles );
42 44 $layer->setmetadata ( "cortepixels", $cortepixels );
43 45 if(empty($maxfeatures)){
... ...
admin/catalogo/mapfile/renderizacao/index.js
... ... @@ -24,84 +24,84 @@ Free Software Foundation, Inc., no endereço
24 24 */
25 25 i3GEOadmin.mapfile = {};
26 26 i3GEOadmin.renderizacao = {
27   - inicia: function(codigo, id_tema){
28   - i3GEOadmin.core.modalAguarde(true);
29   - $.post(
30   - "exec.php?funcao=lista",
31   - "codigo="+codigo
32   - )
33   - .done(
34   - function(data, status){
35   - i3GEOadmin.core.modalAguarde(false);
36   - var json = jQuery.parseJSON(data);
37   - $("#corpo").html(
38   - Mustache.to_html(
39   - $("#templateFormRenderizacao").html(),
40   - $.extend(
41   - {},
42   - i3GEOadmin.renderizacao.dicionario,
43   - json.dados,
44   - {
45   - "codigo": codigo,
46   - "id_tema": id_tema,
47   - "onSalvar": "i3GEOadmin.renderizacao.salvar",
48   - "cache": function(){
49   - var hash = {
50   - "sim": i3GEOadmin.renderizacao.dicionario.sim,
51   - "nao": i3GEOadmin.renderizacao.dicionario.nao,
52   - "NAO-sel" : "",
53   - "SIM-sel": ""
54   - };
55   - hash[json.dados.cache + "-sel"] = "selected";
56   - return Mustache.to_html(
57   - $("#templateOpcoesPublicado").html(),
58   - hash
59   - );
60   - },
61   - "tiles": function(){
62   - var hash = {
63   - "sim": i3GEOadmin.renderizacao.dicionario.sim,
64   - "nao": i3GEOadmin.renderizacao.dicionario.nao,
65   - "NAO-sel" : "",
66   - "SIM-sel": ""
67   - };
68   - hash[json.dados.tiles + "-sel"] = "selected";
69   - return Mustache.to_html(
70   - $("#templateOpcoesPublicado").html(),
71   - hash
72   - );
73   - }
74   - }
75   - )
76   - )
77   - );
78   - $.material.init();
79   - }
80   - )
81   - .fail(
82   - function(data){
83   - i3GEOadmin.core.modalAguarde(false);
84   - i3GEOadmin.core.mostraErro(data.status + " " +data.statusText);
85   - }
  27 + inicia: function(codigo, id_tema){
  28 + i3GEOadmin.core.modalAguarde(true);
  29 + $.post(
  30 + "exec.php?funcao=lista",
  31 + "codigo="+codigo
  32 + )
  33 + .done(
  34 + function(data, status){
  35 + i3GEOadmin.core.modalAguarde(false);
  36 + var json = jQuery.parseJSON(data);
  37 + $("#corpo").html(
  38 + Mustache.to_html(
  39 + $("#templateFormRenderizacao").html(),
  40 + $.extend(
  41 + {},
  42 + i3GEOadmin.renderizacao.dicionario,
  43 + json.dados,
  44 + {
  45 + "codigo": codigo,
  46 + "id_tema": id_tema,
  47 + "onSalvar": "i3GEOadmin.renderizacao.salvar",
  48 + "cache": function(){
  49 + var hash = {
  50 + "sim": i3GEOadmin.renderizacao.dicionario.sim,
  51 + "nao": i3GEOadmin.renderizacao.dicionario.nao,
  52 + "NAO-sel" : "",
  53 + "SIM-sel": ""
  54 + };
  55 + hash[json.dados.cache + "-sel"] = "selected";
  56 + return Mustache.to_html(
  57 + $("#templateOpcoesPublicado").html(),
  58 + hash
  59 + );
  60 + },
  61 + "tiles": function(){
  62 + var hash = {
  63 + "sim": i3GEOadmin.renderizacao.dicionario.sim,
  64 + "nao": i3GEOadmin.renderizacao.dicionario.nao,
  65 + "NAO-sel" : "",
  66 + "SIM-sel": ""
  67 + };
  68 + hash[json.dados.tiles + "-sel"] = "selected";
  69 + return Mustache.to_html(
  70 + $("#templateOpcoesPublicado").html(),
  71 + hash
  72 + );
  73 + }
  74 + }
  75 + )
  76 + )
86 77 );
87   - },
88   - salvar: function(codigo,id_tema){
89   - var parametros = $("#form-edicao-renderizacao").serialize();
90   - i3GEOadmin.core.modalAguarde(true);
91   - $.post(
92   - "exec.php?funcao=alterar",
93   - "codigo=" + codigo + "&id_tema="+ id_tema+"&"+parametros
94   - )
95   - .done(
96   - function(data, status){
97   - i3GEOadmin.renderizacao.inicia(codigo,id_tema);
98   - }
99   - )
100   - .fail(
101   - function(data){
102   - i3GEOadmin.core.modalAguarde(false);
103   - i3GEOadmin.core.mostraErro(data.status + " " +data.statusText);
104   - }
105   - );
106   - }
  78 + $.material.init();
  79 + }
  80 + )
  81 + .fail(
  82 + function(data){
  83 + i3GEOadmin.core.modalAguarde(false);
  84 + i3GEOadmin.core.mostraErro(data.status + " " +data.statusText);
  85 + }
  86 + );
  87 + },
  88 + salvar: function(codigo,id_tema){
  89 + var parametros = $("#form-edicao-renderizacao").serialize();
  90 + i3GEOadmin.core.modalAguarde(true);
  91 + $.post(
  92 + "exec.php?funcao=alterar",
  93 + "codigo=" + codigo + "&id_tema="+ id_tema+"&"+parametros
  94 + )
  95 + .done(
  96 + function(data, status){
  97 + i3GEOadmin.renderizacao.inicia(codigo,id_tema);
  98 + }
  99 + )
  100 + .fail(
  101 + function(data){
  102 + i3GEOadmin.core.modalAguarde(false);
  103 + i3GEOadmin.core.mostraErro(data.status + " " +data.statusText);
  104 + }
  105 + );
  106 + }
107 107 };
108 108 \ No newline at end of file
... ...
admin/catalogo/mapfile/renderizacao/templates/templateFormRenderizacao.php
... ... @@ -21,6 +21,21 @@
21 21 <div class="col-md-12">
22 22 <div class="form-group form-group-lg">
23 23 <div class="col-md-6">
  24 + <label class="control-label" for="cacheprefixo">
  25 + {{{cacheprefixoTitulo}}}
  26 + </label>
  27 + <p class="small">
  28 + {{{Cacheprefixo}}}
  29 + </p>
  30 + </div>
  31 + <div class="col-md-6">
  32 + <input title="{{{cacheprefixoTitulo}}}" type="text" value="{{{cacheprefixo}}}" class="form-control" name="cacheprefixo" >
  33 + </div>
  34 + </div>
  35 + </div>
  36 + <div class="col-md-12">
  37 + <div class="form-group form-group-lg">
  38 + <div class="col-md-6">
24 39 <label class="control-label" for="tiles">
25 40 {{{tilesTitulo}}}
26 41 </label>
... ...
admin/dicionario/editormapfile.js
... ... @@ -586,5 +586,15 @@ i3GEOadmin.mapfile.dicionario = {
586 586 pt : "<p><b>Mudan&ccedil;as na vers&atilde;o 7 do Mapserver</b></p><li>N&atilde;o permite o uso do tipo de layer ANNOTATION. Voc&ecirc; deve substituir por um dos tipos permitidos (POINT, LINE, POLYGON...).</li><li>Ao usar CLUSTER substitua Cluster:FeatureCount por Cluster_FeatureCount.</li>",
587 587 en : "<p><b>Changes in Mapserver 7</b></p><li>It does not allow to use ANNOTATION layer type. You must replace it with one of the allowed types (POINT, LINE, POLYGON ...).</li><li>When using CLUSTER replace Cluster: FeatureCount with Cluster_FeatureCount.</li>",
588 588 es : "<p><b>Cambios en la versi&oacute;n 7 de Mapserver</b></p><li>No permite el uso del layer del tipo ANNOTATION. Usted debe reemplazarlo por uno de los tipos permitidos (POINT, LINE, POLYGON ...).</li><li>Al utilizar CLUSTER, reemplace Cluster: FeatureCount por Cluster_FeatureCount.</li>"
  589 + } ],
  590 + 'cacheprefixoTitulo' : [ {
  591 + pt : "Prefixo utilizado para o cache",
  592 + en : "",
  593 + es : ""
  594 + } ],
  595 + 'Cacheprefixo' : [ {
  596 + pt : "Prefixo (texto sem caracteres especiais e sem espa&ccedil;os em branco) que ser&aacute; utilizado para dar nome ao arquivo de armazenamento de cache. Voc&ecirc; pode alterar esse prefixo quando for necess&aacute;rio utilizar um novo cache, por exemplo, quando for feita alguma altera&ccedil;&atilde;o na simbologia da camada.",
  597 + en : "",
  598 + es : ""
589 599 } ]
590 600 };
... ...
classesphp/classe_legenda.php
... ... @@ -335,7 +335,7 @@ class Legenda
335 335 $legenda = array();
336 336 for ($i = 0; $i < $numlayers; ++ $i) {
337 337 $la = $this->mapa->getlayer($i);
338   - if (strtoupper($la->getmetadata("ESCONDIDO")) == "SIM") {
  338 + if (strtoupper($la->getmetadata("CLASSE")) == "NAO" || strtoupper($la->getmetadata("ESCONDIDO")) == "SIM") {
339 339 $la->set("status", MS_OFF);
340 340 }
341 341 $desligarLayer = array();
... ...
classesphp/classe_mapa.php
... ... @@ -292,7 +292,8 @@ class Mapa
292 292 "utfgrid",
293 293 "maxscaledenom",
294 294 "minscaledenom",
295   - "group"
  295 + "group",
  296 + "cacheprefixo"
296 297 );
297 298 foreach ($this->layers as $oLayer) {
298 299 $sel = "nao";
... ... @@ -530,7 +531,8 @@ class Mapa
530 531 $utfgrid,
531 532 $oLayer->maxscaledenom,
532 533 $oLayer->minscaledenom,
533   - $oLayer->group
  534 + $oLayer->group,
  535 + $oLayer->getmetadata("cacheprefixo")
534 536 );
535 537 }
536 538 }
... ...
classesphp/mapa_googlemaps.php
... ... @@ -88,6 +88,9 @@ if (@$_SESSION[&quot;fingerprint&quot;]) {
88 88 if (! isset($_SESSION["map_file"])) {
89 89 exit();
90 90 }
  91 +if(!isset($_GET["cacheprefixo"])){
  92 + $_GET["cacheprefixo"] = "";
  93 +}
91 94 $map_fileX = $_SESSION["map_file"];
92 95 $postgis_mapa = $_SESSION["postgis_mapa"];
93 96 $cachedir = $_SESSION["cachedir"];
... ... @@ -483,6 +486,7 @@ function salvaCacheImagem()
483 486 if ($layer == "") {
484 487 $layer = "fundo";
485 488 }
  489 + $layer = $_GET["cacheprefixo"] . $layer;
486 490 if ($cachedir == "") {
487 491 $cachedir = dirname(dirname($map_fileX)) . "/cache";
488 492 }
... ... @@ -511,6 +515,7 @@ function carregaCacheImagem()
511 515 if ($layer == "") {
512 516 $layer = "fundo";
513 517 }
  518 + $layer = $_GET["cacheprefixo"] . $layer;
514 519 if ($cachedir == "") {
515 520 $cachedir = dirname(dirname($map_fileX)) . "/cache";
516 521 }
... ...
classesphp/mapa_openlayers.php
... ... @@ -61,6 +61,9 @@ if (! function_exists(&#39;ms_GetVersion&#39;)) {
61 61 }
62 62 error_reporting(0);
63 63 inicializa();
  64 +if(!isset($_GET["cacheprefixo"])){
  65 + $_GET["cacheprefixo"] = "";
  66 +}
64 67 //
65 68 // calcula a extensao geografica com base no x,y,z
66 69 // nos casos do modo notile, a requisicao e feita como se fosse um wms
... ... @@ -115,6 +118,10 @@ if (isset($_GET[&quot;TileMatrix&quot;])) {
115 118 }
116 119  
117 120 $_GET["tms"] = "/wmts/" . $_GET["layer"] . "/" . $z . "/" . $x . "/" . $y . ".png";
  121 + if($_GET["cacheprefixo"] != ""){
  122 + $_GET["tms"] = "/wmts/" . $_GET["cacheprefixo"] . $_GET["layer"] . "/" . $z . "/" . $x . "/" . $y . ".png";
  123 + }
  124 +
118 125 if ($z . "/" . $x . "/" . $y == "0/0/0" || $x == - 1 || $y == - 1) {
119 126 return;
120 127 }
... ... @@ -514,9 +521,13 @@ function salvaCacheImagem($cachedir, $map, $tms)
514 521 {
515 522 global $img, $cortePixels;
516 523 if ($cachedir == "") {
517   - $nome = dirname(dirname($map)) . "/cache" . $tms;
  524 +
  525 + $nome = dirname(dirname($map)) . "/cache" . $tms;
  526 +
518 527 } else {
519   - $nome = $cachedir . $tms;
  528 +
  529 + $nome = $cachedir . $tms;
  530 +
520 531 }
521 532 $nome = str_replace(".png", "", $nome);
522 533 $nome = $nome . ".png";
... ... @@ -564,7 +575,6 @@ function carregaCacheImagem($cachedir, $map, $tms, $i3georendermode = 0, $format
564 575  
565 576 exit();
566 577 }
567   -
568 578 }
569 579  
570 580 function nomeRand($n = 10)
... ...
ferramentas/carregamapa/upload.php
... ... @@ -92,6 +92,7 @@ if (isset($_FILES[&#39;i3GEOcarregamapafilemap&#39;][&#39;name&#39;]) &amp;&amp; strlen(basename($_FILES
92 92 $numlayers = $mapt->numlayers;
93 93 for ($i=0;$i < $numlayers;$i++){
94 94 $layert = $mapt->getlayer($i);
  95 + $layert->setmetadata("cache","nao");
95 96 //
96 97 //verifica se existe o tema em i3geo/temas
97 98 //
... ...
js/interface.js
... ... @@ -1059,7 +1059,7 @@ i3GEO.Interface =
1059 1059 }
1060 1060  
1061 1061 if (camada.cache) {
1062   - urllayer = url + "&cache=" + camada.cache;
  1062 + urllayer = url + "&cache=" + camada.cache + "&cacheprefixo=" + camada.cacheprefixo;
1063 1063 } else {
1064 1064 urllayer = url + "&cache=nao";
1065 1065 }
... ...
temas/_lbiomashp.map
... ... @@ -8,37 +8,39 @@ MAP
8 8 CONNECTION ""
9 9 DATA "/var/www/i3geo/aplicmap/dados/biomas.shp"
10 10 METADATA
11   - "cache" "nao"
  11 + "cache" "SIM"
  12 + "cacheprefixo" "prefixo"
12 13 "CLASSE" "SIM"
13 14 "animagif" ""
14 15 "permitekmz" "SIM"
15 16 "ITENSDESC" "Teste de acentuação"
16   - "editavel" ""
17   - "ESCALA" "250000"
18 17 "TILES" "SIM"
  18 + "ESCALA" "250000"
  19 + "editavel" ""
19 20 "extensao" "-73.990940816816 -33.74827031115 -34.822855820777 5.272224303909"
20 21 "FUNCOESJS" '[{"titulo":"teste fake"},{"titulo":"teste de nome de uma função","script":"../aplicmap/dados/testefuncaojs.js","funcao":"funcao1","parametros":["CD_LEGENDA"]}]'
21 22 "permitedownload" "SIM"
22 23 "permitecomentario" "NAO"
23 24 "escondido" "NAO"
24   - "esquematabelaeditavel" ""
25 25 "download" "SIM"
  26 + "esquematabelaeditavel" ""
26 27 "UTFDATA" ""
27 28 "itembuscarapida" "CD_LEGENDA"
28   - "tme" ""
29 29 "ITENS" "CD_LEGENDA"
30   - "transitioneffect" "NAO"
31   - "permiteogc" "SIM"
  30 + "TIP" "CD_LEGENDA"
  31 + "ITENSDESC" "CD_LEGENDA"
  32 + "tme" ""
32 33 "permitekml" "SIM"
33   - "TEMA" "Biomas shapefile (acentuação)"
  34 + "permiteogc" "SIM"
  35 + "transitioneffect" "NAO"
34 36 "convcaracter" "SIM"
35   - "colunageometria" ""
  37 + "TEMA" "Biomas shapefile (acentuação)"
36 38 "colunaidunico" ""
37   - "identifica" "sim"
38   - "storymap" ""
  39 + "colunageometria" ""
  40 + "identifica" "nao"
39 41 "tabelaeditavel" ""
  42 + "storymap" ""
40 43 END # METADATA
41   - #MAXSCALEDENOM 5000000
42 44 NAME "_lbiomashp"
43 45 PROCESSING "ITEMS=CD_LEGENDA"
44 46 PROCESSING "LABEL_NO_CLIP=True"
... ...