Commit 65fba7cd01dad4bf98aba8ee4865a242fa7e3b4b

Authored by Edmar Moretti
1 parent bc996ea6

Inclui opção para evitar cache de imagens do lado do navegador no mashup. Utiliz…

…a a opção de nocache no editor de mapfiles
admin/php/editortexto.php
@@ -50,11 +50,15 @@ body { @@ -50,11 +50,15 @@ body {
50 $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); 50 $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp);
51 chmod($nomeMapfileTmp,0777); 51 chmod($nomeMapfileTmp,0777);
52 unlink($nomeMapfileTmp); 52 unlink($nomeMapfileTmp);
53 - //echo $nomeMapfileTmp;exit;  
54 // 53 //
55 if($_POST["tipo"] == "gravar"){ 54 if($_POST["tipo"] == "gravar"){
56 $fp = fopen($mapfile,"w"); 55 $fp = fopen($mapfile,"w");
57 - fwrite($fp,$gravarTexto); 56 + if($fp == false){
  57 + echo "<span style=color:red <b>N&atilde;o foi poss&iacute;vel salvar o arquivo. Verifique as permiss&otilde;es ou se h&aacute; algum erro no mapfile</b></span><br><br>";
  58 + }
  59 + else{
  60 + fwrite($fp,$gravarTexto);
  61 + }
58 fclose($fp); 62 fclose($fp);
59 } 63 }
60 echo 'RGB: <input type=text value="clique" size=10 id="corrgb" onclick="i3GEO.util.abreCor(\'\',\'corrgb\',\'rgbSep\')" /><br><br>'; 64 echo 'RGB: <input type=text value="clique" size=10 id="corrgb" onclick="i3GEO.util.abreCor(\'\',\'corrgb\',\'rgbSep\')" /><br><br>';
@@ -64,17 +68,27 @@ body { @@ -64,17 +68,27 @@ body {
64 echo file_get_contents($mapfile); 68 echo file_get_contents($mapfile);
65 echo "</TEXTAREA>"; 69 echo "</TEXTAREA>";
66 $mapfile = str_replace("\\","/",$mapfile); 70 $mapfile = str_replace("\\","/",$mapfile);
67 - $mapa = ms_newMapObj($mapfile);  
68 - echo "<iframe id='mapaPreview' src='../../mashups/openlayers.php?DESLIGACACHE=sim&controles=navigation,panzoombar,scaleline,mouseposition&botoes=identifica&largura=490&fundo=".$mapfile."&temas=".$mapfile."' cols=100 rows=20 style='position:relative;top:2px;overflow:hidden;width:500px;height:500px;border:1px solid gray;'>"; 71 +
  72 + echo "<iframe id='mapaPreview' src='../../mashups/openlayers.php?nocache=sim&DESLIGACACHE=sim&controles=navigation,panzoombar,scaleline,mouseposition&botoes=identifica&largura=480&fundo=".$mapfile."&temas=".$mapfile."' cols=100 rows=20 style='position:relative;top:2px;overflow:hidden;width:500px;height:500px;border:1px solid gray;'>";
69 echo "</iframe>"; 73 echo "</iframe>";
70 echo "<input type=hidden name=tipo value=gravar />"; 74 echo "<input type=hidden name=tipo value=gravar />";
71 75
72 -  
73 - $n = $mapa->numlayers;  
74 - echo "<br><br>Colunas dos layers:<br><br>";  
75 - for($i=0;$i<$n;$i++){  
76 - $l = $mapa->getlayer($i);  
77 - echo $l->name.": ".(implode(",",pegaItens($l)))."<br><br>"; 76 + if(!@ms_newMapObj($mapfile)){
  77 + echo "<span style=color:red <b>N&atilde;o foi poss&iacute;vel criar o mapa. Verifique as permiss&otilde;es ou se h&aacute; algum erro no mapfile</b></span><br><br>";
  78 + }
  79 + else{
  80 + $mapa = ms_newMapObj($mapfile);
  81 + $n = $mapa->numlayers;
  82 + echo "<br><br>Colunas dos layers:<br><br>";
  83 + for($i=0;$i<$n;$i++){
  84 + if(@$mapa->getlayer($i)){
  85 + $l = $mapa->getlayer($i);
  86 + echo $l->name.": ".(implode(",",pegaItens($l)))."<br><br>";
  87 + }
  88 + else{
  89 + echo "<span style=color:red <b>N&atilde;o foi poss&iacute;vel criar o LAYER {$l->name}. Verifique as permiss&otilde;es ou se h&aacute; algum erro no mapfile</b></span><br><br>";
  90 + }
  91 + }
78 } 92 }
79 ?> 93 ?>
80 </form> 94 </form>
mashups/openlayers.php
@@ -8,6 +8,18 @@ include_once(dirname(__FILE__).&quot;/../ms_configura.php&quot;); @@ -8,6 +8,18 @@ include_once(dirname(__FILE__).&quot;/../ms_configura.php&quot;);
8 include_once(dirname(__FILE__)."/../classesphp/pega_variaveis.php"); 8 include_once(dirname(__FILE__)."/../classesphp/pega_variaveis.php");
9 include_once(dirname(__FILE__)."/../classesphp/carrega_ext.php"); 9 include_once(dirname(__FILE__)."/../classesphp/carrega_ext.php");
10 error_reporting(0); 10 error_reporting(0);
  11 +if(!empty($desligacache)){
  12 + $DESLIGACACHE = $desligacache;
  13 +}
  14 +//
  15 +//verifica se em cada camada deve ser inserido um parametro aleatorio para evitar cache de imagem do lado do cliente
  16 +//
  17 +if($nocache == "sim"){
  18 + $nocache = "a".mt_rand(0, 1000)."&";
  19 +}
  20 +else{
  21 + $nocache = "";
  22 +}
11 // 23 //
12 // recupera um mapa salvo no banco de administracao 24 // recupera um mapa salvo no banco de administracao
13 // 25 //
@@ -233,7 +245,7 @@ if($temas != &quot;&quot;){ @@ -233,7 +245,7 @@ if($temas != &quot;&quot;){
233 foreach($temas as $tema){ 245 foreach($temas as $tema){
234 $nomeLayer = str_replace(".map","",basename($tema)); 246 $nomeLayer = str_replace(".map","",basename($tema));
235 $nomeLayer = str_replace(".php","",$nomeLayer); 247 $nomeLayer = str_replace(".php","",$nomeLayer);
236 - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tema.'", "'.$servidor.'?tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{isBaseLayer:false})'; 248 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tema.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{isBaseLayer:false})';
237 } 249 }
238 } 250 }
239 else{ 251 else{
@@ -242,7 +254,7 @@ if($temas != &quot;&quot;){ @@ -242,7 +254,7 @@ if($temas != &quot;&quot;){
242 include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); 254 include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php");
243 $gm = new gvsig2mapfile($locaplic."/temas/".$tema.".gvp"); 255 $gm = new gvsig2mapfile($locaplic."/temas/".$tema.".gvp");
244 $gvsigview = $gm->getViewsNames(); 256 $gvsigview = $gm->getViewsNames();
245 - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$gvsigview[0].'", "../ogc.php?tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$tema.'",transparent: "true", format: "image/png"},{singleTile:false,visibility:true,isBaseLayer:false})'; 257 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$gvsigview[0].'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$tema.'",transparent: "true", format: "image/png"},{singleTile:false,visibility:true,isBaseLayer:false})';
246 } 258 }
247 else{ 259 else{
248 $nomeMap = ""; 260 $nomeMap = "";
@@ -300,9 +312,9 @@ if($temas != &quot;&quot;){ @@ -300,9 +312,9 @@ if($temas != &quot;&quot;){
300 if($nlayers == 1 && strtoupper($layern->getmetadata("cache")) == "SIM"){ 312 if($nlayers == 1 && strtoupper($layern->getmetadata("cache")) == "SIM"){
301 // nesse caso o layer e adicionado como TMS 313 // nesse caso o layer e adicionado como TMS
302 // tms leva os parametros do TMS 314 // tms leva os parametros do TMS
303 - $objOpenLayers[] = 'new OpenLayers.Layer.TMS("'.$tituloLayer.'", "../ogc.php?tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'",{tileOrigin: new OpenLayers.LonLat(-180, -90),serviceVersion:"&tms=",visibility:'.$visivel.',isBaseLayer:'.$ebase.',layername:"'.$nomeLayer.'",type:"png"})'; 315 + $objOpenLayers[] = 'new OpenLayers.Layer.TMS("'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'",{tileOrigin: new OpenLayers.LonLat(-180, -90),serviceVersion:"&tms=",visibility:'.$visivel.',isBaseLayer:'.$ebase.',layername:"'.$nomeLayer.'",type:"png"})';
304 // cria um clone WMS para efeitos de getfeatureinfo 316 // cria um clone WMS para efeitos de getfeatureinfo
305 - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{cloneTMS:"'.$nomeLayer.'",layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{displayInLayerSwitcher:false,singleTile:true,visibility:false,isBaseLayer:false})'; 317 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{cloneTMS:"'.$nomeLayer.'",layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{displayInLayerSwitcher:false,singleTile:true,visibility:false,isBaseLayer:false})';
306 } 318 }
307 else{ 319 else{
308 // $objOpenLayers[] = 'new OpenLayers.Layer.WMS( 320 // $objOpenLayers[] = 'new OpenLayers.Layer.WMS(
@@ -318,10 +330,10 @@ if($temas != &quot;&quot;){ @@ -318,10 +330,10 @@ if($temas != &quot;&quot;){
318 $visivel = "true"; 330 $visivel = "true";
319 } 331 }
320 if($tituloLayer != ""){ 332 if($tituloLayer != ""){
321 - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{singleTile:true,visibility:'.$visivel.',isBaseLayer:'.$ebase.'})'; 333 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{singleTile:true,visibility:'.$visivel.',isBaseLayer:'.$ebase.'})';
322 } 334 }
323 else{ 335 else{
324 - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{displayInLayerSwitcher:false,singleTile:true,visibility:'.$visivel.',isBaseLayer:'.$ebase.'})'; 336 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{displayInLayerSwitcher:false,singleTile:true,visibility:'.$visivel.',isBaseLayer:'.$ebase.'})';
325 } 337 }
326 } 338 }
327 } 339 }
@@ -366,6 +378,8 @@ function ajuda(){ @@ -366,6 +378,8 @@ function ajuda(){
366 ativalayerswicther (true|false) - inicia o mapa com a caixa de escolha das camadas (layerSwitcher) aberta ou n&atilde;o. Por default, inicia fechada 378 ativalayerswicther (true|false) - inicia o mapa com a caixa de escolha das camadas (layerSwitcher) aberta ou n&atilde;o. Por default, inicia fechada
367 ativarodadomouse (true|false) - ativa ou n&atilde;o o zoom com base na roda do mouse (default &eacute; true) 379 ativarodadomouse (true|false) - ativa ou n&atilde;o o zoom com base na roda do mouse (default &eacute; true)
368 legendahtml (true|false) - ativa ou n&atilde;o (default &eacute; false) a gera&ccedil;&atilde;o de legenda do tipo HTML no lugar de imagem png. Legendas HTML podem ser modificadas com base em CSS. A legenda &eacute; constru&iacute;da com o template i3geo/aplicmap/legendaOgc.html. 380 legendahtml (true|false) - ativa ou n&atilde;o (default &eacute; false) a gera&ccedil;&atilde;o de legenda do tipo HTML no lugar de imagem png. Legendas HTML podem ser modificadas com base em CSS. A legenda &eacute; constru&iacute;da com o template i3geo/aplicmap/legendaOgc.html.
  381 + desligacache (sim|nao) - desativa o uso do cache de imagens em disco do lado do servidor, for&ccedil;ando a renderiza&ccedil;&atilde;o dos tiles de cada camada em cada requisi&ccedil;&atilde;o
  382 + nocache (sim) - evita o uso de imagens em cache existentes no navegador do usu&aacute;rio
369 383
370 fundo - lista com os nomes, separados por ',' dos layers que ser&atilde;o usados como fundo para o mapa. Se n&atilde;o for definido, 384 fundo - lista com os nomes, separados por ',' dos layers que ser&atilde;o usados como fundo para o mapa. Se n&atilde;o for definido,
371 ser&aacute; usado o default. O primeiro da lista ser&aacute; o fundo ativo. Se na lista de temas de fundo estiver algum 385 ser&aacute; usado o default. O primeiro da lista ser&aacute; o fundo ativo. Se na lista de temas de fundo estiver algum
temas/_cursoaeroporto.map
1 -<<<<<<< .mine  
2 -MAP  
3 - FONTSET "../symbols/fontes.txt"  
4 - SYMBOLSET "../symbols/simbolosv6.sym"  
5 - LAYER  
6 - DATA "/var/www/i3geo/aplicmap/dados/sc22/AEROPORTO_CAMPO_DE_POUSO.shp"  
7 - METADATA  
8 - "CLASSE" "SIM"  
9 - "PLUGINI3GEO" '{"plugin":"heatmap","parametros":{"coluna":"1","radius":"15","max":"10"}}'  
10 - "TEMA" "Aeroportos SC22"  
11 - END # METADATA  
12 - NAME "_cursoaeroporto"  
13 - STATUS OFF  
14 - TEMPLATE "none.htm"  
15 - TILEITEM "location"  
16 - TYPE POINT  
17 - UNITS METERS  
18 - CLASS  
19 - NAME ""  
20 - STYLE  
21 - COLOR 255 0 0  
22 - OUTLINECOLOR 0 0 0  
23 - SIZE 15  
24 - SYMBOL "ponto"  
25 - END # STYLE  
26 - END # CLASS  
27 - END # LAYER  
28 -  
29 -END # MAP  
30 -  
31 -=======  
32 MAP 1 MAP
33 FONTSET "../symbols/fontes.txt" 2 FONTSET "../symbols/fontes.txt"
34 SYMBOLSET "../symbols/simbolosv6.sym" 3 SYMBOLSET "../symbols/simbolosv6.sym"
@@ -56,6 +25,4 @@ MAP @@ -56,6 +25,4 @@ MAP
56 END # CLASS 25 END # CLASS
57 END # LAYER 26 END # LAYER
58 27
59 -END # MAP  
60 -  
61 ->>>>>>> .r4835 28 +END # MAP
62 \ No newline at end of file 29 \ No newline at end of file
temas/_lbiomashp.map
1 -MAP  
2 - FONTSET "/var/www/i3geo/symbols/fontes.txt"  
3 - SYMBOLSET "/var/www/i3geo/symbols/simbolosv6.sym"  
4 - LAYER  
5 - CONNECTION ""  
6 - DATA "/var/www/i3geo/aplicmap/dados/biomas.shp"  
7 - METADATA  
8 - "METAESTAT_ID_MEDIDA_VARIAVEL" ""  
9 - "cache" "SIM"  
10 - "CLASSE" "SIM"  
11 - "permitekmz" "nao"  
12 - "METAESTAT_CODIGO_TIPO_REGIAO" ""  
13 - "permitedownload" "sim"  
14 - "metaestat" ""  
15 - "permitekml" "sim"  
16 - "permiteogc" "sim"  
17 - "TEMA" "Biomas shapefile (acentuação)"  
18 - "convcaracter" ""  
19 - END # METADATA  
20 - NAME "_lbiomashp"  
21 - PROCESSING "ITEMS=CD_LEGENDA"  
22 - STATUS OFF  
23 - TEMPLATE "none.htm"  
24 - TILEITEM "location"  
25 - OPACITY 90  
26 - TYPE POLYGON  
27 - UNITS METERS  
28 - CLASS  
29 - NAME "CAATINGA"  
30 - EXPRESSION ('[CD_LEGENDA]'eq'CAATINGA')  
31 - STYLE  
32 - COLOR 128 214 231  
33 - OUTLINECOLOR 255 255 255  
34 - END # STYLE  
35 - END # CLASS  
36 - CLASS  
37 - NAME "PAMPA"  
38 - EXPRESSION ('[CD_LEGENDA]'eq'PAMPA')  
39 - STYLE  
40 - COLOR 114 23 92  
41 - OUTLINECOLOR 255 255 255  
42 - END # STYLE  
43 - END # CLASS  
44 - CLASS  
45 - NAME "CERRADO"  
46 - EXPRESSION ('[CD_LEGENDA]'eq'CERRADO')  
47 - STYLE  
48 - COLOR 168 160 140  
49 - OUTLINECOLOR 255 255 255  
50 - END # STYLE  
51 - END # CLASS  
52 - CLASS  
53 - NAME "PANTANAL"  
54 - EXPRESSION ('[CD_LEGENDA]'eq'PANTANAL')  
55 - STYLE  
56 - COLOR 214 46 232  
57 - OUTLINECOLOR 255 255 255  
58 - END # STYLE  
59 - END # CLASS  
60 - CLASS  
61 - NAME "AMAZONIA"  
62 - EXPRESSION ('[CD_LEGENDA]'eq'AMAZONIA')  
63 - STYLE  
64 - COLOR 155 180 157  
65 - OUTLINECOLOR 255 255 255  
66 - END # STYLE  
67 - END # CLASS  
68 - CLASS  
69 - NAME "MATA ATLANTICA"  
70 - EXPRESSION ('[CD_LEGENDA]'eq'MATA ATLANTICA')  
71 - STYLE  
72 - COLOR 161 186 110  
73 - OUTLINECOLOR 255 255 255  
74 - END # STYLE  
75 - END # CLASS  
76 - END # LAYER  
77 -  
78 -END # MAP  
79 - 1 +MAP
  2 + FONTSET "/var/www/i3geo/symbols/fontes.txt"
  3 + SYMBOLSET "/var/www/i3geo/symbols/simbolosv6.sym"
  4 + LAYER
  5 + CONNECTION ""
  6 + DATA "/var/www/i3geo/aplicmap/dados/biomas.shp"
  7 + METADATA
  8 + "METAESTAT_ID_MEDIDA_VARIAVEL" ""
  9 + "cache" "SIM"
  10 + "CLASSE" "SIM"
  11 + "permitekmz" "nao"
  12 + "METAESTAT_CODIGO_TIPO_REGIAO" ""
  13 + "permitedownload" "sim"
  14 + "metaestat" ""
  15 + "permitekml" "sim"
  16 + "permiteogc" "sim"
  17 + "TEMA" "Biomas shapefile (acentuação)"
  18 + "convcaracter" ""
  19 + END # METADATA
  20 + NAME "_lbiomashp"
  21 + PROCESSING "ITEMS=CD_LEGENDA"
  22 + STATUS OFF
  23 + TEMPLATE "none.htm"
  24 + TILEITEM "location"
  25 + OPACITY 90
  26 + TYPE POLYGON
  27 + UNITS METERS
  28 + CLASS
  29 + NAME "CAATINGA"
  30 + EXPRESSION ('[CD_LEGENDA]'eq'CAATINGA')
  31 + STYLE
  32 + COLOR 0 255 0
  33 + OUTLINECOLOR 255 255 0
  34 + END # STYLE
  35 + END # CLASS
  36 + CLASS
  37 + NAME "PAMPA"
  38 + EXPRESSION ('[CD_LEGENDA]'eq'PAMPA')
  39 + STYLE
  40 + COLOR 114 23 92
  41 + OUTLINECOLOR 255 255 255
  42 + END # STYLE
  43 + END # CLASS
  44 + CLASS
  45 + NAME "CERRADO"
  46 + EXPRESSION ('[CD_LEGENDA]'eq'CERRADO')
  47 + STYLE
  48 + COLOR 168 160 140
  49 + OUTLINECOLOR 255 255 255
  50 + END # STYLE
  51 + END # CLASS
  52 + CLASS
  53 + NAME "PANTANAL"
  54 + EXPRESSION ('[CD_LEGENDA]'eq'PANTANAL')
  55 + STYLE
  56 + COLOR 214 46 232
  57 + OUTLINECOLOR 255 255 255
  58 + END # STYLE
  59 + END # CLASS
  60 + CLASS
  61 + NAME "AMAZONIA"
  62 + EXPRESSION ('[CD_LEGENDA]'eq'AMAZONIA')
  63 + STYLE
  64 + COLOR 155 180 157
  65 + OUTLINECOLOR 255 255 255
  66 + END # STYLE
  67 + END # CLASS
  68 + CLASS
  69 + NAME "MATA ATLANTICA"
  70 + EXPRESSION ('[CD_LEGENDA]'eq'MATA ATLANTICA')
  71 + STYLE
  72 + COLOR 161 186 110
  73 + OUTLINECOLOR 255 255 255
  74 + END # STYLE
  75 + END # CLASS
  76 + END # LAYER
  77 +
  78 +END # MAP
  79 +