Commit 4f6ca0a95ba568c567bce6f00b4ee006f39b27e4
1 parent
c654b90f
Exists in
master
and in
7 other branches
Inclusão do programa geraminiatura.php e alteração no programa testamapfile.php …
…para manter miniaturas em cache. As miniaturas são mostradas na árvore de temas do i3geo
Showing
43 changed files
with
197 additions
and
1 deletions
Show diff stats
@@ -0,0 +1,184 @@ | @@ -0,0 +1,184 @@ | ||
1 | +<?php | ||
2 | +/* | ||
3 | +Title: Gera miniaturas. | ||
4 | + | ||
5 | +Gera as miniaturas dos mapas baseado nos mapfiles existentes em i3geo/temas. As miniaturas são utilizadas no i3geo na guia temas para mostrar um preview de cada tema. | ||
6 | + | ||
7 | +File: i3geo/geraminiatura.php | ||
8 | + | ||
9 | +About: Licença | ||
10 | + | ||
11 | +I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | ||
12 | + | ||
13 | +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | ||
14 | +Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br | ||
15 | + | ||
16 | +Colaboração: Luis Henrique Weirich de Matos | ||
17 | + | ||
18 | +Este programa é software livre; você pode redistribuí-lo | ||
19 | +e/ou modificá-lo sob os termos da Licença Pública Geral | ||
20 | +GNU conforme publicada pela Free Software Foundation; | ||
21 | +tanto a versão 2 da Licença. | ||
22 | +Este programa é distribuído na expectativa de que seja útil, | ||
23 | +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | ||
24 | +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | ||
25 | +Consulte a Licença Pública Geral do GNU para mais detalhes. | ||
26 | +Você deve ter recebido uma cópia da Licença Pública Geral do | ||
27 | +GNU junto com este programa; se não, escreva para a | ||
28 | +Free Software Foundation, Inc., no endereço | ||
29 | +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
30 | + | ||
31 | +About: Exemplo | ||
32 | + | ||
33 | +geraminiatura.php?tipo=mini | ||
34 | + | ||
35 | +Parameters: | ||
36 | + | ||
37 | +tipo - tipo de retorno mini|grande | ||
38 | +*/ | ||
39 | +set_time_limit(300); | ||
40 | +ini_set('max_execution_time', 300); | ||
41 | +include("ms_configura.php"); | ||
42 | +include("classesphp/funcoes_gerais.php"); | ||
43 | +require_once("classesphp/pega_variaveis.php"); | ||
44 | +include_once ("classesphp/carrega_ext.php"); | ||
45 | +// | ||
46 | +//carrega o phpmapscript | ||
47 | +// | ||
48 | +if (!function_exists('ms_GetVersion')) | ||
49 | +{ | ||
50 | + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) | ||
51 | + { | ||
52 | + if(!@dl('php_mapscript_48.dll')) | ||
53 | + dl('php_mapscript.dll'); | ||
54 | + } | ||
55 | + else | ||
56 | + {dl('php_mapscript.so');} | ||
57 | +} | ||
58 | +ms_ResetErrorList(); | ||
59 | +if (!isset($tipo)) | ||
60 | +{echo "tipo não definido";exit;} | ||
61 | +$arqs = listaArquivos("temas"); | ||
62 | +foreach ($arqs["arquivos"] as $arq) | ||
63 | +{ | ||
64 | + $temp = explode(".",$arq); | ||
65 | + if($temp[1] == "map") | ||
66 | + verifica($arq); | ||
67 | + else | ||
68 | + {echo "<br>Arquivo <i>$map</i> não é válido. <br>";} | ||
69 | +} | ||
70 | +function verifica($map) | ||
71 | +{ | ||
72 | + global $tipo,$locaplic; | ||
73 | + ms_ResetErrorList(); | ||
74 | + $tema = ""; | ||
75 | + $map = str_replace("\\","/",$map); | ||
76 | + $map = basename($map); | ||
77 | + if (file_exists('temas/'.$map)) | ||
78 | + {$tema = 'temas/'.$map;} | ||
79 | + if (file_exists('temas/'.$map.'.map')) | ||
80 | + {$tema = 'temas/'.$map.".map";} | ||
81 | + if($tipo == "mini") | ||
82 | + {if(file_exists('temas/'.$map.'.mini.png')){exit;}} | ||
83 | + if($tipo == "grande") | ||
84 | + {if(file_exists('temas/'.$map.'.grande.png')){exit;}} | ||
85 | + if ($tema != "") | ||
86 | + { | ||
87 | + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) | ||
88 | + {$mapa = ms_newMapObj("aplicmap/geral1windows.map");} | ||
89 | + else | ||
90 | + {$mapa = ms_newMapObj("aplicmap/geral1.map");} | ||
91 | + if(@ms_newMapObj($tema)) | ||
92 | + {$nmapa = ms_newMapObj($tema);} | ||
93 | + else | ||
94 | + { | ||
95 | + echo "erro no arquivo $map <br>"; | ||
96 | + return; | ||
97 | + } | ||
98 | + $temasn = $nmapa->getAllLayerNames(); | ||
99 | + $dados = ""; | ||
100 | + foreach ($temasn as $teman) | ||
101 | + { | ||
102 | + $layern = $nmapa->getLayerByName($teman); | ||
103 | + $layern->set("status",MS_DEFAULT); | ||
104 | + ms_newLayerObj($mapa, $layern); | ||
105 | + if ($layern->data == "") | ||
106 | + $dados = $layern->connection; | ||
107 | + else | ||
108 | + $dados = $layern->data; | ||
109 | + $pegarext = $teman; | ||
110 | + } | ||
111 | + if (isset($postgis_mapa)) | ||
112 | + { | ||
113 | + if ($postgis_mapa != "") | ||
114 | + { | ||
115 | + $numlayers = $mapa->numlayers; | ||
116 | + for ($i=0;$i < $numlayers;$i++) | ||
117 | + { | ||
118 | + $layer = $mapa->getlayer($i); | ||
119 | + if ($layer->connectiontype == MS_POSTGIS) | ||
120 | + { | ||
121 | + if ($layer->connection == " ") | ||
122 | + { | ||
123 | + $layer->set("connection",$postgis_mapa); | ||
124 | + } | ||
125 | + } | ||
126 | + } | ||
127 | + } | ||
128 | + } | ||
129 | + zoomTema($pegarext,&$mapa); | ||
130 | + if ($tipo == "mini") | ||
131 | + { | ||
132 | + $mapa->setsize(50,50); | ||
133 | + $sca = $mapa->scalebar; | ||
134 | + $sca->set("status",MS_OFF); | ||
135 | + } | ||
136 | + if ($tipo == "grande") | ||
137 | + { | ||
138 | + $mapa->setsize(300,300); | ||
139 | + $sca = $mapa->scalebar; | ||
140 | + $sca->set("status",MS_OFF); | ||
141 | + } | ||
142 | + $objImagem = @$mapa->draw(); | ||
143 | + if (!$objImagem) | ||
144 | + {echo "Problemas ao gerar o mapa<br>";return;} | ||
145 | + if($tipo=="mini") | ||
146 | + $nomec = ($objImagem->imagepath).$map.".mini.png"; | ||
147 | + if($tipo=="grande") | ||
148 | + $nomec = ($objImagem->imagepath).$map.".grande.png"; | ||
149 | + $objImagem->saveImage($nomec); | ||
150 | + $objImagem->free(); | ||
151 | + } | ||
152 | +} | ||
153 | +function zoomTema($nomelayer,&$mapa) | ||
154 | +{ | ||
155 | + $layer = $mapa->getlayerbyname($nomelayer); | ||
156 | + if($layer->type > 2) | ||
157 | + {return;} | ||
158 | + $prjMapa = $mapa->getProjection(); | ||
159 | + $prjTema = $layer->getProjection(); | ||
160 | + $extatual = $mapa->extent; | ||
161 | + $ret = $layer->getmetadata("extensao"); | ||
162 | + $ct = $layer->connectiontype; | ||
163 | + if(($ret == "") && ($ct != 1)) | ||
164 | + {return;} | ||
165 | + if ($ret == "") | ||
166 | + { | ||
167 | + $ret = $layer->getextent(); | ||
168 | + //reprojeta o retangulo | ||
169 | + if (($prjTema != "") && ($prjMapa != $prjTema)) | ||
170 | + { | ||
171 | + $projInObj = ms_newprojectionobj($prjTema); | ||
172 | + $projOutObj = ms_newprojectionobj($prjMapa); | ||
173 | + $ret->project($projInObj, $projOutObj); | ||
174 | + } | ||
175 | + $extatual->setextent($ret->minx,$ret->miny,$ret->maxx,$ret->maxy); | ||
176 | + } | ||
177 | + else | ||
178 | + { | ||
179 | + $ret = explode(" ",$ret); | ||
180 | + $extatual->setextent($ret[0],$ret[1],$ret[2],$ret[3]); | ||
181 | + } | ||
182 | +} | ||
183 | + | ||
184 | +?> | ||
0 | \ No newline at end of file | 185 | \ No newline at end of file |
4.9 KB
618 Bytes
4.28 KB
582 Bytes
5.41 KB
634 Bytes
4.26 KB
578 Bytes
4.8 KB
605 Bytes
4.7 KB
10.1 KB
508 Bytes
3.21 KB
428 Bytes
3.21 KB
428 Bytes
5.48 KB
608 Bytes
3.21 KB
431 Bytes
3.21 KB
431 Bytes
3.21 KB
431 Bytes
3.21 KB
428 Bytes
3.21 KB
428 Bytes
3.21 KB
428 Bytes
3.21 KB
428 Bytes
3.21 KB
428 Bytes
3.21 KB
428 Bytes
3.21 KB
428 Bytes
3.21 KB
428 Bytes
testamapfile.php
@@ -93,7 +93,19 @@ if (isset($map) && $map != "") | @@ -93,7 +93,19 @@ if (isset($map) && $map != "") | ||
93 | } | 93 | } |
94 | function verifica($map) | 94 | function verifica($map) |
95 | { | 95 | { |
96 | - global $tipo; | 96 | + global $tipo,$locaplic; |
97 | + if ($tipo == "mini" && file_exists('temas/'.$map.".mini.png")) | ||
98 | + { | ||
99 | + Header("Content-type: image/png"); | ||
100 | + ImagePng(ImageCreateFromPNG('temas/'.$map.".mini.png")); | ||
101 | + exit; | ||
102 | + } | ||
103 | + if ($tipo == "grande" && file_exists('temas/'.$map.".grande.png")) | ||
104 | + { | ||
105 | + Header("Content-type: image/png"); | ||
106 | + ImagePng(ImageCreateFromPNG('temas/'.$map.".grande.png")); | ||
107 | + exit; | ||
108 | + } | ||
97 | ms_ResetErrorList(); | 109 | ms_ResetErrorList(); |
98 | $tema = ""; | 110 | $tema = ""; |
99 | $map = str_replace("\\","/",$map); | 111 | $map = str_replace("\\","/",$map); |