Commit 9c9474a782a9682d5dcfbe6f10c7fab92a45dc71

Authored by Edmar Moretti
1 parent c296170a
Exists in master

Atualização da animação gif

Showing 1 changed file with 93 additions and 24 deletions   Show diff stats
ferramentas/animagif/exec.php
... ... @@ -14,14 +14,22 @@ if(empty($_GET)){
14 14 &mapext = extens&atilde;o geogr&aacute;fica xmin,ymin,xmax,ymax que ser&aacute; usada nas imagens<br>
15 15 &legenda = sim|nao<br>
16 16 &transparente = sim|nao<br>
  17 + &operador = operador que ser&aacute; utilizado no filtro. Por default utilza-se 'igual a'. Pode ser ainda lt (menor que) ou gt (maior que)<br>
  18 + &nulos = lista de valores, separados por ',' que não serão considerados ao aplicar o filtro, por exemplo &nulos=-, ,0<br>
  19 + &tipocolunat = string|numero tipo de dados existentes na coluna que cont&eacute;m os valores para o filtro<br>
17 20 ";
18 21 exit;
19 22 }
  23 +//http://localhost/i3geo/ferramentas/animagif/exec.php?operador=lt&nulos=-&transparente=nao&legenda=sim&tema=_llocalianimagif&colunat=ANOCRIA&w=500&h=500&mapext=-74%20-32%20-34%204
20 24 //http://localhost:8014/i3geo/ferramentas/animagif/exec.php?transparente=nao&legenda=sim&tema=dengue_casos_provaveis&colunat=semana_ano_epidemiologico&w=500&h=500&mapext=-74%20-32%20-34%204
21 25 include("../../ms_configura.php");
22 26 include("../../classesphp/funcoes_gerais.php");
23 27 include("../../classesphp/pega_variaveis.php");
24 28 include("../../classesphp/carrega_ext.php");
  29 +$v = versao();
  30 +$vi = $v["inteiro"];
  31 +$v = $v["principal"];
  32 +
25 33 if($cache == "nao"){
26 34 $nometemp = nomeRandomico();
27 35 } else {
... ... @@ -30,6 +38,24 @@ if($cache == &quot;nao&quot;){
30 38 if(empty($tempo)){
31 39 $tempo = 40;
32 40 }
  41 +if(empty($nulos)){
  42 + $nulos = "";
  43 +}
  44 +if(empty($tipocolunat)){
  45 + $tipocolunat = "string";
  46 +}
  47 +if(empty($operador)){
  48 + $operador = "=";
  49 +}
  50 +else{
  51 + if($operador == "lt"){
  52 + $operador = "<";
  53 + }
  54 + if($operador == "gt"){
  55 + $operador = ">";
  56 + }
  57 +}
  58 +$nulos = explode(",",$nulos);
33 59 $arqtemp = $dir_tmp."/".$nometemp;
34 60 if(file_exists($arqtemp.".gif")){
35 61 $gifBinary = file_get_contents($arqtemp.".gif");
... ... @@ -42,15 +68,13 @@ if(file_exists($arqtemp.&quot;.gif&quot;)){
42 68 //
43 69 //carrega o phpmapscript
44 70 //
45   -if (!function_exists('ms_GetVersion'))
46   -{
47   - if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
48   - {
  71 +if (!function_exists('ms_GetVersion')){
  72 + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){
49 73 if(!@dl('php_mapscript_48.dll'))
50 74 dl('php_mapscript.dll');
51 75 }
52   - else
53   - {dl('php_mapscript.so');
  76 + else{
  77 + dl('php_mapscript.so');
54 78 }
55 79 }
56 80 $versao = versao();
... ... @@ -82,6 +106,7 @@ else{
82 106 $base = $locaplic."/aplicmap/".$base;
83 107 }
84 108 }
  109 +//desenv /var/www/html/i3geo/i3geo/sage/camadas/base_linux.map
85 110 $mapa = ms_newMapObj($base);
86 111  
87 112 //remove as camadas do mapa base
... ... @@ -96,16 +121,23 @@ for ($i=0;$i &lt; $numlayers;$i++){
96 121 }
97 122 }
98 123 //ajusta o label
  124 +
99 125 $copyright = $mapa->getlayerbyname("copyright");
100 126 if($copyright != ""){
101 127 $classe = $copyright->getclass(0);
102   - $label = $classe->getLabel(0);
  128 + if($vi >= 60200){
  129 + $label = $classe->getLabel(0);
  130 + }
  131 + else{
  132 + $label = $classe->label;
  133 + }
103 134 $label->updatefromstring("LABEL TYPE TRUETYPE END");
104 135 $label->set("font","arial");
105 136 $label->set("size",15);
106 137 $label->updatefromstring("LABEL POSITION lr END");
107 138 $label->updatefromstring('LABEL STYLE GEOMTRANSFORM "labelpoly" COLOR 255 255 255 END END');
108 139 }
  140 +
109 141 //
110 142 $mapa->save($arqtemp.".map");
111 143 //adiciona ao mapa base as camadas do mapfile indicado em $tema
... ... @@ -133,6 +165,7 @@ for ($i=0;$i &lt; $numlayers;$i++){
133 165 cloneInlineSymbol($layern,$nmapa,$mapa);
134 166 ms_newLayerObj($mapa, $layern);
135 167 }
  168 +
136 169 $mapa->save($arqtemp.".map");
137 170  
138 171 //aplica a extensao geografica
... ... @@ -153,15 +186,16 @@ if ($ret != &quot;&quot;){
153 186 $mapa->setsize($w,$h);
154 187 $sca = $mapa->scalebar;
155 188 $sca->set("status",MS_OFF);
  189 +
156 190 if($legenda == "sim"){
157 191 $leg = $mapa->legend;
158 192 $leg->set("status",MS_EMBED);
159 193 $cor = $leg->imagecolor;
160 194 $cor->setrgb(250,250,250);
161 195 $labelleg = $leg->label;
162   - //$labelleg->set("type",MS_TRUETYPE);
163   - //$labelleg->set("font","arial");
164   - $labelleg->set("size",10);
  196 + $labelleg->set("type",MS_TRUETYPE);
  197 + $labelleg->set("font","arial");
  198 + $labelleg->set("size",12);
165 199 //$leg->set("keyspacingy",10);
166 200 $layer = $mapa->getlayerbyname($tema);
167 201 $nclass = $layer->numclasses;
... ... @@ -172,69 +206,104 @@ if($legenda == &quot;sim&quot;){
172 206 }
173 207 }
174 208 }
  209 +
175 210 $c = $mapa->imagecolor;
176 211 $c->setrgb(-1,-1,-1);
177 212 $o = $mapa->outputformat;
178 213 $o->set("imagemode",MS_IMAGEMODE_RGBA);
  214 +
179 215 if($transparente == "sim"){
180 216 $o->set("transparent",MS_TRUE);
181 217 }
  218 +
182 219 $mapa->save($arqtemp.".map");
183 220 $mapa = ms_newMapObj($arqtemp.".map");
  221 +/*
184 222 if(validaAcessoTemas($arqtemp.".map",false) == true){
185 223 echo "Existem temas restritos";exit;
186 224 }
  225 +*/
187 226 //pega a lista de valores unicos da $colunat
188 227 include_once("../../classesphp/classe_atributos.php");
189 228 $m = new Atributos($arqtemp.".map",$tema);
  229 +
190 230 $lista = $m->listaUnicoRapida($colunat);
191 231 $listaunica = array();
192 232 foreach($lista as $l){
  233 + $l = str_replace($nulos,"",$l);
193 234 if($l != ""){
194 235 $listaunica[] = $l;
195 236 }
196 237 }
  238 +//$listaunica = array ("201501","201502","201503","201504","201505");
197 239 //cria as imagens para cada periodo
198 240 $layer = $mapa->getlayerbyname($tema);
199 241  
200 242 $copyright = $mapa->getlayerbyname("copyright");
  243 +$classe = ms_newClassObj($copyright);
  244 +
  245 +$classet = ms_newClassObj($copyright);
  246 +$classet->title = " ";
  247 +
  248 +$mapa->moveLayerdown(0);
  249 +
201 250 if($copyright != ""){
202 251 $c = $copyright->getclass(0);
203   - $label = $c->getLabel(0);
  252 + if($vi >= 60200){
  253 + $label = $c->getLabel(0);
  254 + }
  255 + else{
  256 + $label = $c->label;
  257 + }
204 258 }
  259 +
  260 +//$classe = ms_newClassObj($copyright);
  261 +
205 262 $imagens = array();
206 263 $duracao = array();
207 264 $objImagem = "";
208   -//$listaunica = array($listaunica[1]);
  265 +
209 266 foreach($listaunica as $d){
210 267 if(strtoupper($colunat) == $colunat){
211   - $filtro = "(('[$colunat]' = '$d'))";
  268 + $filtro = "(('[$colunat]' $operador '$d'))";
  269 + if($tipocolunat == "numerico"){
  270 + $filtro = "(([$colunat] $operador $d))";
  271 + }
212 272 }
213 273 else{
214   - $filtro = "$colunat = '$d'";
  274 + $filtro = "$colunat $operador '$d'";
  275 + if($tipocolunat == "numerico"){
  276 + $filtro = "$colunat $operador $d";
  277 + }
215 278 }
216 279 $layer->setfilter($filtro);
217   - //$mapa->save($arqtemp.".map");echo $arqtemp;exit;
218 280 $nomec = $arqtemp.$d.".png";
219 281  
220   - $s = "LABEL TEXT '".$d."' END";
221   - if($copyright != ""){
  282 + if($copyright != "" && $vi >= 60300){
  283 + $s = "LABEL TEXT '".$d."' END";
222 284 $label->updateFromString($s);
223 285 }
224   - if($objImagem == ""){
225   - $objImagem = $mapa->draw();
226   - $objImagem->saveImage($nomec);
227   - }
228 286 else{
229   - $i = $mapa->draw();
230   - $objImagem->pasteImage($i,-1);
231   - $objImagem->saveImage($nomec);
  287 + $classe->title = $d;
  288 + }
  289 + if(!file_exists($nomec)){
  290 + if($objImagem == ""){
  291 + $objImagem = $mapa->draw();
  292 + $objImagem->saveImage($nomec);
  293 + }
  294 + else{
  295 + $i = $mapa->draw();
  296 + $objImagem->pasteImage($i,-1);
  297 + $objImagem->saveImage($nomec);
  298 + }
232 299 }
233 300 $imagens[] = $nomec;
234 301 $duracao[] = $tempo;
235 302 }
236 303 //junta as imagens no gif
  304 +
237 305 include("../../pacotes/gifcreator/GifCreator.php");
  306 +
238 307 $gc = new GifCreator();
239 308 $gc->create($imagens, $duracao, 0);
240 309 $gifBinary = $gc->getGif();
... ...