Commit 8bcce97ed9ea62f27360ac53b4dd60532b10a553
1 parent
1498ff89
Exists in
master
and in
7 other branches
i3geosaude - inclusão de templates para escolha na lista de mapas salvos no banc…
…o e geração automática de miniatura do mapa
Showing
1 changed file
with
51 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
1 | +<?php | ||
2 | +/* | ||
3 | + * Gera uma miniatura de um mapfile salvo no banco de dados | ||
4 | + * Verifica se a imagem existe, caso contrario cria uma no diretorio temporario | ||
5 | + * | ||
6 | + * @param restauramapa - id do mapa a ser restaurado | ||
7 | + * @param w | ||
8 | + * @param h | ||
9 | + */ | ||
10 | +include_once (dirname(__FILE__)."/../../ms_configura.php"); | ||
11 | +include_once (dirname(__FILE__)."/../../classesphp/funcoes_gerais.php"); | ||
12 | +$base = restauraMapaAdmin($_GET["restauramapa"],$dir_tmp); | ||
13 | + | ||
14 | +$nomeImagem = dirname($base)."/".str_replace(".map","","restauramapa".$_GET["restauramapa"])."_miniatura.png"; | ||
15 | + | ||
16 | +if(!file_exists($nomeImagem)){ | ||
17 | + $mapa = ms_newMapObj($base); | ||
18 | + if (isset($postgis_mapa)){ | ||
19 | + if ($postgis_mapa != ""){ | ||
20 | + $numlayers = $mapa->numlayers; | ||
21 | + for ($i=0;$i < $numlayers;$i++){ | ||
22 | + $layern = $mapa->getlayer($i); | ||
23 | + if (!empty($postgis_mapa)){ | ||
24 | + if ($layern->connectiontype == MS_POSTGIS){ | ||
25 | + $lcon = $layern->connection; | ||
26 | + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ | ||
27 | + if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade | ||
28 | + {$layern->set("connection",$postgis_mapa); | ||
29 | + } | ||
30 | + else{ | ||
31 | + $layern->set("connection",$postgis_mapa[$lcon]); | ||
32 | + } | ||
33 | + } | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + } | ||
38 | + } | ||
39 | + $mapa->setsize($_GET["w"],$_GET["h"]); | ||
40 | + $sca = $mapa->scalebar; | ||
41 | + $sca->set("status",MS_OFF); | ||
42 | + $objImagemM = @$mapa->draw(); | ||
43 | + $objImagemM->saveImage($nomeImagem); | ||
44 | + | ||
45 | +} | ||
46 | +header('Content-Length: '.filesize($nomeImagem)); | ||
47 | +header('Content-Type: image/png'); | ||
48 | +header('Cache-Control: public, max-age=22222222'); | ||
49 | +header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT'); | ||
50 | +fpassthru(fopen($nomeImagem, 'rb')); | ||
51 | +?> | ||
0 | \ No newline at end of file | 52 | \ No newline at end of file |