Commit 959e458be4b0d152cbee9ce29f59588bbbb6b3f4
1 parent
36987e22
Exists in
master
and in
7 other branches
Inclusão de parâmetro no ms_configura para definição da pasta para armazenamento de cache
Showing
9 changed files
with
99 additions
and
49 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin/php/editormapfile.php
| ... | ... | @@ -174,19 +174,26 @@ switch (strtoupper($funcao)) |
| 174 | 174 | $mapfile = $locaplic."/temas/".$codigoMap.".map"; |
| 175 | 175 | $mapa = ms_newMapObj($mapfile); |
| 176 | 176 | $nomes = $mapa->getalllayernames(); |
| 177 | + if($cachedir != "") | |
| 178 | + {$d = $cachedir;} | |
| 179 | + else | |
| 180 | + {$d = $dir_tmp."/cache";} | |
| 177 | 181 | foreach($nomes as $nome) |
| 178 | 182 | { |
| 179 | - $dir = $dir_tmp."/cache/".$nome; | |
| 180 | - if (is_dir($dir)) { | |
| 181 | - $objects = scandir($dir); | |
| 182 | - foreach ($objects as $object) { | |
| 183 | - if ($object != "." && $object != "..") { | |
| 184 | - if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object); | |
| 183 | + $dirs[] = $d."/".$nome; | |
| 184 | + $dirs[] = $d."/googlemaps/".$nome; | |
| 185 | + foreach($dirs as $dir){ | |
| 186 | + if (is_dir($dir)) { | |
| 187 | + $objects = scandir($dir); | |
| 188 | + foreach ($objects as $object) { | |
| 189 | + if ($object != "." && $object != "..") { | |
| 190 | + if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object); | |
| 191 | + } | |
| 185 | 192 | } |
| 193 | + reset($objects); | |
| 194 | + rmdir($dir); | |
| 186 | 195 | } |
| 187 | - reset($objects); | |
| 188 | - rmdir($dir); | |
| 189 | - } | |
| 196 | + } | |
| 190 | 197 | } |
| 191 | 198 | retornaJSON("ok"); |
| 192 | 199 | exit; | ... | ... |
classesphp/funcoes_gerais.php
| ... | ... | @@ -2625,11 +2625,13 @@ Parametro: |
| 2625 | 2625 | |
| 2626 | 2626 | $dir_tmp {string} - Diretório temporário (no servidor) utilizado pelo mapserver. |
| 2627 | 2627 | |
| 2628 | +$$cachedir {string} - Diretório de cache temporário definido no ms_configura.php | |
| 2629 | + | |
| 2628 | 2630 | Retorno: |
| 2629 | 2631 | |
| 2630 | 2632 | {boleano} |
| 2631 | 2633 | */ |
| 2632 | -function criaDirMapa($dir_tmp) | |
| 2634 | +function criaDirMapa($dir_tmp,$cachedir="") | |
| 2633 | 2635 | { |
| 2634 | 2636 | if(!file_exists($dir_tmp)){ |
| 2635 | 2637 | @mkdir ($dir_tmp,0777); |
| ... | ... | @@ -2642,8 +2644,14 @@ function criaDirMapa($dir_tmp) |
| 2642 | 2644 | $mapfile = $dir_tmp."/".$tmpdirname."/".$tmpdirname.".map"; |
| 2643 | 2645 | $tmpimgname = "img".$tmpdirname; |
| 2644 | 2646 | @mkdir($dir_tmp."/comum",0777); |
| 2645 | - @mkdir($dir_tmp."/cache",0777); | |
| 2646 | - @mkdir($dir_tmp."/cache/googlemaps",0777); | |
| 2647 | + if($cachedir == ""){ | |
| 2648 | + @mkdir($dir_tmp."/cache",0777); | |
| 2649 | + @mkdir($dir_tmp."/cache/googlemaps",0777); | |
| 2650 | + } | |
| 2651 | + else{ | |
| 2652 | + @mkdir($cachedir,0777); | |
| 2653 | + @mkdir($cachedir."/googlemaps",0777); | |
| 2654 | + } | |
| 2647 | 2655 | if(file_exists($dir_tmp."/".$tmpdirname)) |
| 2648 | 2656 | return array($mapfile,$tmpdirname,$tmpimgname); |
| 2649 | 2657 | else | ... | ... |
classesphp/mapa_googlemaps.php
| ... | ... | @@ -89,6 +89,7 @@ if(!isset($_SESSION["map_file"])) |
| 89 | 89 | // |
| 90 | 90 | $map_fileX = $_SESSION["map_file"]; |
| 91 | 91 | $postgis_mapa = $_SESSION["postgis_mapa"]; |
| 92 | +$cachedir = $_SESSION["cachedir"]; | |
| 92 | 93 | // |
| 93 | 94 | //converte a requisição do tile em coordenadas geo |
| 94 | 95 | //http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#tile_numbers_to_lon.2Flat_2 |
| ... | ... | @@ -192,7 +193,7 @@ if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") |
| 192 | 193 | if($qy) |
| 193 | 194 | {$cache = false;} |
| 194 | 195 | if($cache == true) |
| 195 | -{carregaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} | |
| 196 | +{carregaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} | |
| 196 | 197 | |
| 197 | 198 | $map_size = explode(" ",$_GET["map_size"]); |
| 198 | 199 | $mapa->setsize($map_size[0],$map_size[1]); |
| ... | ... | @@ -286,7 +287,7 @@ if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") |
| 286 | 287 | } |
| 287 | 288 | else{ |
| 288 | 289 | if($cache == true) |
| 289 | - {$nomer = salvaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} | |
| 290 | + {$nomer = salvaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} | |
| 290 | 291 | else{ |
| 291 | 292 | if($img->imagepath == "") |
| 292 | 293 | {echo "Erro IMAGEPATH vazio";exit;} |
| ... | ... | @@ -301,27 +302,34 @@ else{ |
| 301 | 302 | echo header("Content-type: image/png \n\n"); |
| 302 | 303 | imagepng($img); |
| 303 | 304 | } |
| 304 | -function salvaCacheImagem($bbox,$layer,$map,$w,$h){ | |
| 305 | +function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ | |
| 305 | 306 | global $img,$map_size; |
| 306 | 307 | //layers que são sempre iguais |
| 308 | + //error_reporting(E_ALL); | |
| 307 | 309 | if($layer == "copyright" || $layer == "") |
| 308 | 310 | {$bbox = "";} |
| 309 | 311 | if($layer == "") |
| 310 | 312 | {$layer = "fundo";} |
| 311 | - $nomedir = dirname(dirname($map))."/cache/googlemaps/".$layer; | |
| 312 | - @mkdir($nomedir,0777); | |
| 313 | - $nome = $nomedir."/".$w.$h.$bbox.".png"; | |
| 313 | + if($cachedir == "") | |
| 314 | + {$cachedir = dirname(dirname($map))."/cache/googlemaps/".$layer;} | |
| 315 | + else | |
| 316 | + {$cachedir = $cachedir."/googlemaps/".$layer;} | |
| 317 | + @mkdir($cachedir,0777); | |
| 318 | + $nome = $cachedir."/".$w.$h.$bbox.".png"; | |
| 314 | 319 | if(!file_exists($nome)) |
| 315 | 320 | {$img->saveImage($nome);} |
| 316 | 321 | return $nome; |
| 317 | 322 | } |
| 318 | -function carregaCacheImagem($bbox,$layer,$map,$w,$h){ | |
| 323 | +function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ | |
| 319 | 324 | if($layer == "copyright" || $layer == "") |
| 320 | 325 | {$bbox = "";} |
| 321 | 326 | if($layer == "") |
| 322 | 327 | {$layer = "fundo";} |
| 323 | 328 | $nome = $w.$h.$bbox.".png"; |
| 324 | - $nome = dirname(dirname($map))."/cache/googlemaps/".$layer."/".$nome; | |
| 329 | + if($cachedir == "") | |
| 330 | + {$nome = dirname(dirname($map))."/cache/googlemaps/".$layer."/".$nome;} | |
| 331 | + else | |
| 332 | + {$nome = $cachedir."/googlemaps/".$layer."/".$nome;} | |
| 325 | 333 | if(file_exists($nome)) |
| 326 | 334 | { |
| 327 | 335 | if (!function_exists('imagepng')) | ... | ... |
classesphp/mapa_openlayers.php
| ... | ... | @@ -92,6 +92,7 @@ if(!isset($_SESSION["map_file"])) |
| 92 | 92 | //map_fileX é necessário caso register_globals = On no PHP.INI |
| 93 | 93 | $map_fileX = $_SESSION["map_file"]; |
| 94 | 94 | $postgis_mapa = $_SESSION["postgis_mapa"]; |
| 95 | +$cachedir = $_SESSION["cachedir"]; | |
| 95 | 96 | if(isset($_GET["tipolayer"]) && $_GET["tipolayer"] == "fundo") |
| 96 | 97 | {$map_fileX = str_replace(".map","fundo.map",$map_fileX);} |
| 97 | 98 | if(isset($_GET["BBOX"])) |
| ... | ... | @@ -168,7 +169,7 @@ if(strtolower($_GET["DESLIGACACHE"]) == "sim") |
| 168 | 169 | if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") |
| 169 | 170 | {$cache = false;} |
| 170 | 171 | if($cache == true) |
| 171 | -{carregaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} | |
| 172 | +{carregaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} | |
| 172 | 173 | |
| 173 | 174 | $map_size = explode(" ",$_GET["map_size"]); |
| 174 | 175 | $mapa->setsize($map_size[0],$map_size[1]); |
| ... | ... | @@ -286,7 +287,7 @@ if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") |
| 286 | 287 | } |
| 287 | 288 | else{ |
| 288 | 289 | if($cache == true) |
| 289 | - {$nomer = salvaCacheImagem($_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} | |
| 290 | + {$nomer = salvaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);} | |
| 290 | 291 | else{ |
| 291 | 292 | if($img->imagepath == "") |
| 292 | 293 | {echo "Erro IMAGEPATH vazio";exit;} |
| ... | ... | @@ -302,17 +303,20 @@ else{ |
| 302 | 303 | imagepng($img); |
| 303 | 304 | imagedestroy($img); |
| 304 | 305 | } |
| 305 | -function salvaCacheImagem($bbox,$layer,$map,$w,$h){ | |
| 306 | +function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ | |
| 306 | 307 | global $img,$map_size; |
| 308 | + //echo "oi".$cachedir;exit; | |
| 307 | 309 | //layers que são sempre iguais |
| 308 | 310 | if($layer == "copyright" || $layer == "") |
| 309 | 311 | {$bbox = "";} |
| 310 | 312 | if($layer == "") |
| 311 | 313 | {$layer = "fundo";} |
| 312 | - | |
| 313 | - $nomedir = dirname(dirname($map))."/cache/".$layer; | |
| 314 | - @mkdir($nomedir,0777); | |
| 315 | - $nome = $nomedir."/".$w.$h.$bbox.".png"; | |
| 314 | + if($cachedir == "") | |
| 315 | + {$cachedir = dirname(dirname($map))."/cache/".$layer;} | |
| 316 | + else | |
| 317 | + {$cachedir = $cachedir."/".$layer;} | |
| 318 | + @mkdir($cachedir,0777); | |
| 319 | + $nome = $cachedir."/".$w.$h.$bbox.".png"; | |
| 316 | 320 | if(!file_exists($nome)) |
| 317 | 321 | { |
| 318 | 322 | $img->saveImage($nome); |
| ... | ... | @@ -320,14 +324,17 @@ function salvaCacheImagem($bbox,$layer,$map,$w,$h){ |
| 320 | 324 | } |
| 321 | 325 | return $nome; |
| 322 | 326 | } |
| 323 | -function carregaCacheImagem($bbox,$layer,$map,$w,$h){ | |
| 327 | +function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ | |
| 324 | 328 | if($layer == "copyright" || $layer == "") |
| 325 | 329 | {$bbox = "";} |
| 326 | 330 | if($layer == "") |
| 327 | 331 | {$layer = "fundo";} |
| 328 | 332 | |
| 329 | 333 | $nome = $w.$h.$bbox.".png"; |
| 330 | - $nome = dirname(dirname($map))."/cache/".$layer."/".$nome; | |
| 334 | + if($cachedir == "") | |
| 335 | + {$nome = dirname(dirname($map))."/cache/".$layer."/".$nome;} | |
| 336 | + else | |
| 337 | + {$nome = $cachedir."/".$layer."/".$nome;} | |
| 331 | 338 | if(file_exists($nome)) |
| 332 | 339 | { |
| 333 | 340 | if (!function_exists('imagepng')) | ... | ... |
ms_configura.php
| ... | ... | @@ -398,6 +398,20 @@ if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) |
| 398 | 398 | Vc pode usar essa variável para customizar a inicialização do mapa. |
| 399 | 399 | */ |
| 400 | 400 | $base = ""; |
| 401 | + /* | |
| 402 | + Variable: cachedir | |
| 403 | + | |
| 404 | + Pasta onde ficarão armazenadas as imagens geradas pelo i3Geo para os LAYERS que permitem cache. | |
| 405 | + | |
| 406 | + Os layers que permitem cache são definidos no sistema de administração do i3Geo. | |
| 407 | + | |
| 408 | + Se cachedir for vazia, será utilizado o default do i3geo (diretório temporário) | |
| 409 | + | |
| 410 | + Exemplo | |
| 411 | + | |
| 412 | + $cachedir = 'c:/temp/cache'; | |
| 413 | + */ | |
| 414 | + $cachedir = "c:/temp/cache"; | |
| 401 | 415 | } |
| 402 | 416 | else //se for linux |
| 403 | 417 | { |
| ... | ... | @@ -433,5 +447,6 @@ else //se for linux |
| 433 | 447 | $conexaoadmin = "";//$locaplic."/admin/php/conexaopostgresql.php"; |
| 434 | 448 | $interfacePadrao = "openlayers.htm"; |
| 435 | 449 | $base = ""; |
| 450 | + $cachedir = ""; | |
| 436 | 451 | } |
| 437 | 452 | ?> |
| 438 | 453 | \ No newline at end of file | ... | ... |
ms_criamapa.php
| ... | ... | @@ -191,7 +191,7 @@ if(isset($idioma) && $idioma != "") |
| 191 | 191 | /* |
| 192 | 192 | Cria os diretórios temporários que serão utilizados pelo i3geo para armazenar as imagens e outros dados. |
| 193 | 193 | */ |
| 194 | -$diretorios = criaDirMapa($dir_tmp); | |
| 194 | +$diretorios = criaDirMapa($dir_tmp,$cachedir); | |
| 195 | 195 | if(!$diretorios) |
| 196 | 196 | {echo "<p style=color:red ><b>Não foi possível criar os diretórios temporários em $dir_tmp.</b></p>";exit;} |
| 197 | 197 | criaIndex(); |
| ... | ... | @@ -204,6 +204,7 @@ As variáveis vêm do arquivo ms_configura.php e são armazenadas em uma seção com |
| 204 | 204 | */ |
| 205 | 205 | if (!isset($mapext)){$mapext="";} |
| 206 | 206 | $editores_ = $editores; |
| 207 | +$cachedir_ = $cachedir; | |
| 207 | 208 | $dir_tmp_ = $dir_tmp; |
| 208 | 209 | $emailInstituicao_ = $emailInstituicao; |
| 209 | 210 | $locmapserv_ = $locmapserv; |
| ... | ... | @@ -261,6 +262,7 @@ isso pq algumas aplicações podem ser prejudicadas caso o aguarde seja mostrado |
| 261 | 262 | */ |
| 262 | 263 | $_SESSION["editores"] = $editores_; |
| 263 | 264 | $_SESSION["dir_tmp"] = $dir_tmp_; |
| 265 | +$_SESSION["cachedir"] = $cachedir_; | |
| 264 | 266 | $_SESSION["emailInstituicao"] = $emailInstituicao_; |
| 265 | 267 | $_SESSION["locmapserv"] = $locmapserv_; |
| 266 | 268 | $_SESSION["locaplic"] = $locaplic_; | ... | ... |
ogc.php
| ... | ... | @@ -208,7 +208,7 @@ if ($tipo == "" || $tipo == "metadados") |
| 208 | 208 | { |
| 209 | 209 | $l->set("name",$tx); |
| 210 | 210 | if($cache == true && strtolower($l->getmetadata("cache")) == "sim"){ |
| 211 | - carregaCacheImagem($_GET["BBOX"],$t,$_GET["WIDTH"],$_GET["HEIGHT"]); | |
| 211 | + carregaCacheImagem($_GET["BBOX"],$t,$_GET["WIDTH"],$_GET["HEIGHT"],$cachedir); | |
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | $l->setmetadata("gml_include_items","all"); |
| ... | ... | @@ -433,11 +433,13 @@ function ogc_imprimeListaDeTemas() |
| 433 | 433 | } |
| 434 | 434 | echo $imprimir."</body></html>"; |
| 435 | 435 | } |
| 436 | -function carregaCacheImagem($bbox,$layer,$w,$h){ | |
| 436 | +function carregaCacheImagem($bbox,$layer,$w,$h,$cachedir=""){ | |
| 437 | 437 | global $dir_tmp; |
| 438 | - | |
| 439 | 438 | $nome = $w.$h.$bbox.".png"; |
| 440 | - $nome = $dir_tmp."/cache/".$layer."/".$nome; | |
| 439 | + if($cachedir == "") | |
| 440 | + {$nome = $dir_tmp."/cache/".$layer."/".$nome;} | |
| 441 | + else | |
| 442 | + {$nome = $cachedir."/".$layer."/".$nome;} | |
| 441 | 443 | if(file_exists($nome)) |
| 442 | 444 | { |
| 443 | 445 | if (!function_exists('imagepng')) | ... | ... |
temas/biomashp.map
| 1 | -MAP | |
| 2 | - | |
| 3 | - | |
| 4 | - FONTSET "c:\ms4w\apache\htdocs\i3geo\symbols\fontes.txt" | |
| 5 | - SYMBOLSET "c:\ms4w\apache\htdocs\i3geo\symbols\simbolos.sym" | |
| 1 | +MAP | |
| 2 | + FONTSET "c:\ms4w\apache\htdocs\i3geo\symbols\fontes.txt" | |
| 3 | + SYMBOLSET "c:\ms4w\apache\htdocs\i3geo\symbols\simbolos.sym" | |
| 6 | 4 | LAYER |
| 7 | 5 | CONNECTION "" |
| 8 | 6 | DATA "c:\ms4w\apache\htdocs\i3geo\aplicmap\dados\biomas.shp" |
| ... | ... | @@ -10,30 +8,31 @@ MAP |
| 10 | 8 | GROUP "biomashp" |
| 11 | 9 | HEADER "teste.htm" |
| 12 | 10 | METADATA |
| 13 | - "cache" "" | |
| 14 | 11 | "ltempoitemimagem" "" |
| 15 | - "ltempoitemdescricao" "" | |
| 12 | + "cache" "SIM" | |
| 16 | 13 | "CLASSE" "SIM" |
| 17 | - "ltempoiteminicio" "" | |
| 14 | + "ltempoitemdescricao" "" | |
| 18 | 15 | "palletestep" "" |
| 19 | - "ltempoitemtip" "" | |
| 16 | + "ltempoiteminicio" "" | |
| 20 | 17 | "permitekmz" "sim" |
| 21 | - "ltempoitemtitulo" "" | |
| 22 | - "description_template" "" | |
| 18 | + "ltempoitemtip" "" | |
| 23 | 19 | "iconetema" "http://www.gpsdrive.de/development/map-icons/square.small/leisure/park.png" |
| 20 | + "description_template" "" | |
| 21 | + "ltempoitemtitulo" "" | |
| 24 | 22 | "ltempoitemlink" "" |
| 25 | - "extensao" "-44 -23 -39 -21" | |
| 26 | 23 | "palletefile" "" |
| 24 | + "extensao" "-44 -23 -39 -21" | |
| 27 | 25 | "NOMEORIGINAL" "" |
| 28 | - "ltempoformatodata" "" | |
| 29 | 26 | "permitedownload" "sim" |
| 27 | + "ltempoformatodata" "" | |
| 30 | 28 | "ltempoitemicone" "" |
| 31 | 29 | "download" "SIM" |
| 32 | - "permiteogc" "" | |
| 33 | 30 | "permitekml" "sim" |
| 31 | + "permiteogc" "" | |
| 32 | + "convcaracter" "" | |
| 34 | 33 | "TEMA" "bioma shp" |
| 35 | - "editorsql" "" | |
| 36 | 34 | "identifica" "NAO" |
| 35 | + "editorsql" "" | |
| 37 | 36 | "ltempoitemfim" "" |
| 38 | 37 | END |
| 39 | 38 | NAME "biomashp" |
| ... | ... | @@ -109,4 +108,6 @@ MAP |
| 109 | 108 | TITLE "" |
| 110 | 109 | END |
| 111 | 110 | END |
| 111 | + | |
| 112 | 112 | END |
| 113 | + | ... | ... |