Commit 9d2551163250643c13a6ee5aaf66c34c1372cc5a
1 parent
53b87b7b
Exists in
master
and in
7 other branches
V6 - inclusão de rotina para corte de imagens na hora de gerar o cache. O Objeti…
…vo é evitar os efeitos de corte de símbolos nas bordas de tiles.
Showing
3 changed files
with
40 additions
and
7 deletions
Show diff stats
classesphp/mapa_googlemaps.php
| ... | ... | @@ -152,6 +152,13 @@ if(!isset($_GET["telaR"])){ |
| 152 | 152 | if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != ""){ |
| 153 | 153 | $l->set("template","none.htm"); |
| 154 | 154 | $l->set("status",MS_DEFAULT); |
| 155 | + // | |
| 156 | + //numero de pixels que serao considerados para corte da imagem no caso de cache ativo e tema de pontos | |
| 157 | + // | |
| 158 | + $cortePixels = 0; | |
| 159 | + if ($l->getmetadata("cortepixels") != ""){ | |
| 160 | + $cortePixels = $l->getmetadata("cortepixels"); | |
| 161 | + } | |
| 155 | 162 | //@TODO verificar se foi corrigido em versoes novas do mapserver |
| 156 | 163 | //corrige um bug do mapserver que nao calcula a escala direito |
| 157 | 164 | $l->set("maxscaledenom",$l->maxscaledenom * 100000); |
| ... | ... | @@ -271,6 +278,23 @@ if($_GET["tipolayer"] != "fundo") |
| 271 | 278 | {$o->set("transparent",MS_TRUE);} |
| 272 | 279 | if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") |
| 273 | 280 | {$o->setOption("QUANTIZE_FORCE","OFF");} |
| 281 | + | |
| 282 | +// | |
| 283 | +//se o layer foi marcado para corte altera os parametros para ampliar o mapa | |
| 284 | +//antes de gerar a imagem | |
| 285 | +// | |
| 286 | +if($cortePixels > 0){ | |
| 287 | + //$imagemBranco = $mapa->prepareImage(); | |
| 288 | + $escalaInicial = $mapa->scaledenom; | |
| 289 | + $extensaoInicial = $mapa->extent; | |
| 290 | + | |
| 291 | + $wh = 256+($cortePixels*2); | |
| 292 | + $mapa->setsize($wh,$wh); | |
| 293 | + $ponto = new pointObj(); | |
| 294 | + $ponto->setxy(($wh/2),($wh/2)); | |
| 295 | + $mapa->zoomScale($escalaInicial, $ponto, $wh, $wh, $extensaoInicial); | |
| 296 | +} | |
| 297 | + | |
| 274 | 298 | if($qy != true){ |
| 275 | 299 | $img = $mapa->draw(); |
| 276 | 300 | } |
| ... | ... | @@ -402,7 +426,7 @@ else{ |
| 402 | 426 | } |
| 403 | 427 | //$cachedir e definido no ms_configura.php |
| 404 | 428 | function salvaCacheImagem(){ |
| 405 | - global $img,$cachedir,$x,$y,$z,$map_fileX; | |
| 429 | + global $img,$cachedir,$x,$y,$z,$map_fileX,$cortePixels; | |
| 406 | 430 | $layer = $_GET["layer"]; |
| 407 | 431 | if($layer == "") |
| 408 | 432 | {$layer = "fundo";} |
| ... | ... | @@ -413,6 +437,15 @@ function salvaCacheImagem(){ |
| 413 | 437 | if(!file_exists($c."/$y.png")){ |
| 414 | 438 | mkdir($cachedir."/googlemaps/$layer/$z/$x",0777,true); |
| 415 | 439 | $img->saveImage($c."/$y.png"); |
| 440 | + // | |
| 441 | + //corta a imagem gerada para voltar ao tamanho normal | |
| 442 | + // | |
| 443 | + if($cortePixels > 0){ | |
| 444 | + $img = imagecreatefrompng($c."/$y.png"); | |
| 445 | + $imgc = imagecreate(256,256); | |
| 446 | + imagecopy( $imgc, $img, 0 , 0 , $cortePixels , $cortePixels , 256, 256 ); | |
| 447 | + imagepng($imgc,$nome); | |
| 448 | + } | |
| 416 | 449 | chmod($cachedir."/googlemaps/$layer/$z/$x",0777); |
| 417 | 450 | chmod($c."/$y.png",0777); |
| 418 | 451 | } |
| ... | ... | @@ -507,4 +540,4 @@ function versaoMS() |
| 507 | 540 | $versao["principal"] = $v[0]; |
| 508 | 541 | return $versao; |
| 509 | 542 | } |
| 510 | -?> | |
| 511 | 543 | \ No newline at end of file |
| 544 | +?> | ... | ... |
classesphp/mapa_openlayers.php
| ... | ... | @@ -90,7 +90,7 @@ if(!empty($_GET["request"])){ |
| 90 | 90 | $_GET["REQUEST"] = $_GET["request"]; |
| 91 | 91 | } |
| 92 | 92 | // |
| 93 | -//resolve o problema da seleção na versão nova do mapserver | |
| 93 | +//resolve o problema da selecao nas versoes mais recentes nova do mapserver | |
| 94 | 94 | // |
| 95 | 95 | $qyfile = dirname($map_fileX)."/".$_GET["layer"].".php"; |
| 96 | 96 | $qy = file_exists($qyfile); |
| ... | ... | @@ -103,7 +103,7 @@ if($qy == false && $_GET["cache"] == "sim" && $_GET["DESLIGACACHE"] != "sim"){ |
| 103 | 103 | |
| 104 | 104 | // |
| 105 | 105 | //map_fileX e para o caso register_globals = On no PHP.INI |
| 106 | - | |
| 106 | +// | |
| 107 | 107 | if(isset($_GET["tipolayer"]) && $_GET["tipolayer"] == "fundo"){ |
| 108 | 108 | $map_fileX = str_replace(".map","fundo.map",$map_fileX); |
| 109 | 109 | } |
| ... | ... | @@ -241,7 +241,7 @@ if(!isset($_GET["telaR"])){ |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // |
| 244 | -//se o layer não for do tipo fundo | |
| 244 | +//se o layer nao for do tipo fundo | |
| 245 | 245 | // |
| 246 | 246 | if($_GET["tipolayer"] != "fundo") |
| 247 | 247 | {$o->set("transparent",MS_TRUE);} |
| ... | ... | @@ -506,4 +506,4 @@ function ilegal(){ |
| 506 | 506 | imagepng($img); |
| 507 | 507 | exit; |
| 508 | 508 | } |
| 509 | -?> | |
| 510 | 509 | \ No newline at end of file |
| 510 | +?> | ... | ... |
temas/_llocali.map