Commit 9c9474a782a9682d5dcfbe6f10c7fab92a45dc71
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 +14,22 @@ if(empty($_GET)){ | ||
| 14 | &mapext = extensão geográfica xmin,ymin,xmax,ymax que será usada nas imagens<br> | 14 | &mapext = extensão geográfica xmin,ymin,xmax,ymax que será usada nas imagens<br> |
| 15 | &legenda = sim|nao<br> | 15 | &legenda = sim|nao<br> |
| 16 | &transparente = sim|nao<br> | 16 | &transparente = sim|nao<br> |
| 17 | + &operador = operador que será 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ém os valores para o filtro<br> | ||
| 17 | "; | 20 | "; |
| 18 | exit; | 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 | //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 | 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 | include("../../ms_configura.php"); | 25 | include("../../ms_configura.php"); |
| 22 | include("../../classesphp/funcoes_gerais.php"); | 26 | include("../../classesphp/funcoes_gerais.php"); |
| 23 | include("../../classesphp/pega_variaveis.php"); | 27 | include("../../classesphp/pega_variaveis.php"); |
| 24 | include("../../classesphp/carrega_ext.php"); | 28 | include("../../classesphp/carrega_ext.php"); |
| 29 | +$v = versao(); | ||
| 30 | +$vi = $v["inteiro"]; | ||
| 31 | +$v = $v["principal"]; | ||
| 32 | + | ||
| 25 | if($cache == "nao"){ | 33 | if($cache == "nao"){ |
| 26 | $nometemp = nomeRandomico(); | 34 | $nometemp = nomeRandomico(); |
| 27 | } else { | 35 | } else { |
| @@ -30,6 +38,24 @@ if($cache == "nao"){ | @@ -30,6 +38,24 @@ if($cache == "nao"){ | ||
| 30 | if(empty($tempo)){ | 38 | if(empty($tempo)){ |
| 31 | $tempo = 40; | 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 | $arqtemp = $dir_tmp."/".$nometemp; | 59 | $arqtemp = $dir_tmp."/".$nometemp; |
| 34 | if(file_exists($arqtemp.".gif")){ | 60 | if(file_exists($arqtemp.".gif")){ |
| 35 | $gifBinary = file_get_contents($arqtemp.".gif"); | 61 | $gifBinary = file_get_contents($arqtemp.".gif"); |
| @@ -42,15 +68,13 @@ if(file_exists($arqtemp.".gif")){ | @@ -42,15 +68,13 @@ if(file_exists($arqtemp.".gif")){ | ||
| 42 | // | 68 | // |
| 43 | //carrega o phpmapscript | 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 | if(!@dl('php_mapscript_48.dll')) | 73 | if(!@dl('php_mapscript_48.dll')) |
| 50 | dl('php_mapscript.dll'); | 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 | $versao = versao(); | 80 | $versao = versao(); |
| @@ -82,6 +106,7 @@ else{ | @@ -82,6 +106,7 @@ else{ | ||
| 82 | $base = $locaplic."/aplicmap/".$base; | 106 | $base = $locaplic."/aplicmap/".$base; |
| 83 | } | 107 | } |
| 84 | } | 108 | } |
| 109 | +//desenv /var/www/html/i3geo/i3geo/sage/camadas/base_linux.map | ||
| 85 | $mapa = ms_newMapObj($base); | 110 | $mapa = ms_newMapObj($base); |
| 86 | 111 | ||
| 87 | //remove as camadas do mapa base | 112 | //remove as camadas do mapa base |
| @@ -96,16 +121,23 @@ for ($i=0;$i < $numlayers;$i++){ | @@ -96,16 +121,23 @@ for ($i=0;$i < $numlayers;$i++){ | ||
| 96 | } | 121 | } |
| 97 | } | 122 | } |
| 98 | //ajusta o label | 123 | //ajusta o label |
| 124 | + | ||
| 99 | $copyright = $mapa->getlayerbyname("copyright"); | 125 | $copyright = $mapa->getlayerbyname("copyright"); |
| 100 | if($copyright != ""){ | 126 | if($copyright != ""){ |
| 101 | $classe = $copyright->getclass(0); | 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 | $label->updatefromstring("LABEL TYPE TRUETYPE END"); | 134 | $label->updatefromstring("LABEL TYPE TRUETYPE END"); |
| 104 | $label->set("font","arial"); | 135 | $label->set("font","arial"); |
| 105 | $label->set("size",15); | 136 | $label->set("size",15); |
| 106 | $label->updatefromstring("LABEL POSITION lr END"); | 137 | $label->updatefromstring("LABEL POSITION lr END"); |
| 107 | $label->updatefromstring('LABEL STYLE GEOMTRANSFORM "labelpoly" COLOR 255 255 255 END END'); | 138 | $label->updatefromstring('LABEL STYLE GEOMTRANSFORM "labelpoly" COLOR 255 255 255 END END'); |
| 108 | } | 139 | } |
| 140 | + | ||
| 109 | // | 141 | // |
| 110 | $mapa->save($arqtemp.".map"); | 142 | $mapa->save($arqtemp.".map"); |
| 111 | //adiciona ao mapa base as camadas do mapfile indicado em $tema | 143 | //adiciona ao mapa base as camadas do mapfile indicado em $tema |
| @@ -133,6 +165,7 @@ for ($i=0;$i < $numlayers;$i++){ | @@ -133,6 +165,7 @@ for ($i=0;$i < $numlayers;$i++){ | ||
| 133 | cloneInlineSymbol($layern,$nmapa,$mapa); | 165 | cloneInlineSymbol($layern,$nmapa,$mapa); |
| 134 | ms_newLayerObj($mapa, $layern); | 166 | ms_newLayerObj($mapa, $layern); |
| 135 | } | 167 | } |
| 168 | + | ||
| 136 | $mapa->save($arqtemp.".map"); | 169 | $mapa->save($arqtemp.".map"); |
| 137 | 170 | ||
| 138 | //aplica a extensao geografica | 171 | //aplica a extensao geografica |
| @@ -153,15 +186,16 @@ if ($ret != ""){ | @@ -153,15 +186,16 @@ if ($ret != ""){ | ||
| 153 | $mapa->setsize($w,$h); | 186 | $mapa->setsize($w,$h); |
| 154 | $sca = $mapa->scalebar; | 187 | $sca = $mapa->scalebar; |
| 155 | $sca->set("status",MS_OFF); | 188 | $sca->set("status",MS_OFF); |
| 189 | + | ||
| 156 | if($legenda == "sim"){ | 190 | if($legenda == "sim"){ |
| 157 | $leg = $mapa->legend; | 191 | $leg = $mapa->legend; |
| 158 | $leg->set("status",MS_EMBED); | 192 | $leg->set("status",MS_EMBED); |
| 159 | $cor = $leg->imagecolor; | 193 | $cor = $leg->imagecolor; |
| 160 | $cor->setrgb(250,250,250); | 194 | $cor->setrgb(250,250,250); |
| 161 | $labelleg = $leg->label; | 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 | //$leg->set("keyspacingy",10); | 199 | //$leg->set("keyspacingy",10); |
| 166 | $layer = $mapa->getlayerbyname($tema); | 200 | $layer = $mapa->getlayerbyname($tema); |
| 167 | $nclass = $layer->numclasses; | 201 | $nclass = $layer->numclasses; |
| @@ -172,69 +206,104 @@ if($legenda == "sim"){ | @@ -172,69 +206,104 @@ if($legenda == "sim"){ | ||
| 172 | } | 206 | } |
| 173 | } | 207 | } |
| 174 | } | 208 | } |
| 209 | + | ||
| 175 | $c = $mapa->imagecolor; | 210 | $c = $mapa->imagecolor; |
| 176 | $c->setrgb(-1,-1,-1); | 211 | $c->setrgb(-1,-1,-1); |
| 177 | $o = $mapa->outputformat; | 212 | $o = $mapa->outputformat; |
| 178 | $o->set("imagemode",MS_IMAGEMODE_RGBA); | 213 | $o->set("imagemode",MS_IMAGEMODE_RGBA); |
| 214 | + | ||
| 179 | if($transparente == "sim"){ | 215 | if($transparente == "sim"){ |
| 180 | $o->set("transparent",MS_TRUE); | 216 | $o->set("transparent",MS_TRUE); |
| 181 | } | 217 | } |
| 218 | + | ||
| 182 | $mapa->save($arqtemp.".map"); | 219 | $mapa->save($arqtemp.".map"); |
| 183 | $mapa = ms_newMapObj($arqtemp.".map"); | 220 | $mapa = ms_newMapObj($arqtemp.".map"); |
| 221 | +/* | ||
| 184 | if(validaAcessoTemas($arqtemp.".map",false) == true){ | 222 | if(validaAcessoTemas($arqtemp.".map",false) == true){ |
| 185 | echo "Existem temas restritos";exit; | 223 | echo "Existem temas restritos";exit; |
| 186 | } | 224 | } |
| 225 | +*/ | ||
| 187 | //pega a lista de valores unicos da $colunat | 226 | //pega a lista de valores unicos da $colunat |
| 188 | include_once("../../classesphp/classe_atributos.php"); | 227 | include_once("../../classesphp/classe_atributos.php"); |
| 189 | $m = new Atributos($arqtemp.".map",$tema); | 228 | $m = new Atributos($arqtemp.".map",$tema); |
| 229 | + | ||
| 190 | $lista = $m->listaUnicoRapida($colunat); | 230 | $lista = $m->listaUnicoRapida($colunat); |
| 191 | $listaunica = array(); | 231 | $listaunica = array(); |
| 192 | foreach($lista as $l){ | 232 | foreach($lista as $l){ |
| 233 | + $l = str_replace($nulos,"",$l); | ||
| 193 | if($l != ""){ | 234 | if($l != ""){ |
| 194 | $listaunica[] = $l; | 235 | $listaunica[] = $l; |
| 195 | } | 236 | } |
| 196 | } | 237 | } |
| 238 | +//$listaunica = array ("201501","201502","201503","201504","201505"); | ||
| 197 | //cria as imagens para cada periodo | 239 | //cria as imagens para cada periodo |
| 198 | $layer = $mapa->getlayerbyname($tema); | 240 | $layer = $mapa->getlayerbyname($tema); |
| 199 | 241 | ||
| 200 | $copyright = $mapa->getlayerbyname("copyright"); | 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 | if($copyright != ""){ | 250 | if($copyright != ""){ |
| 202 | $c = $copyright->getclass(0); | 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 | $imagens = array(); | 262 | $imagens = array(); |
| 206 | $duracao = array(); | 263 | $duracao = array(); |
| 207 | $objImagem = ""; | 264 | $objImagem = ""; |
| 208 | -//$listaunica = array($listaunica[1]); | 265 | + |
| 209 | foreach($listaunica as $d){ | 266 | foreach($listaunica as $d){ |
| 210 | if(strtoupper($colunat) == $colunat){ | 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 | else{ | 273 | else{ |
| 214 | - $filtro = "$colunat = '$d'"; | 274 | + $filtro = "$colunat $operador '$d'"; |
| 275 | + if($tipocolunat == "numerico"){ | ||
| 276 | + $filtro = "$colunat $operador $d"; | ||
| 277 | + } | ||
| 215 | } | 278 | } |
| 216 | $layer->setfilter($filtro); | 279 | $layer->setfilter($filtro); |
| 217 | - //$mapa->save($arqtemp.".map");echo $arqtemp;exit; | ||
| 218 | $nomec = $arqtemp.$d.".png"; | 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 | $label->updateFromString($s); | 284 | $label->updateFromString($s); |
| 223 | } | 285 | } |
| 224 | - if($objImagem == ""){ | ||
| 225 | - $objImagem = $mapa->draw(); | ||
| 226 | - $objImagem->saveImage($nomec); | ||
| 227 | - } | ||
| 228 | else{ | 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 | $imagens[] = $nomec; | 300 | $imagens[] = $nomec; |
| 234 | $duracao[] = $tempo; | 301 | $duracao[] = $tempo; |
| 235 | } | 302 | } |
| 236 | //junta as imagens no gif | 303 | //junta as imagens no gif |
| 304 | + | ||
| 237 | include("../../pacotes/gifcreator/GifCreator.php"); | 305 | include("../../pacotes/gifcreator/GifCreator.php"); |
| 306 | + | ||
| 238 | $gc = new GifCreator(); | 307 | $gc = new GifCreator(); |
| 239 | $gc->create($imagens, $duracao, 0); | 308 | $gc->create($imagens, $duracao, 0); |
| 240 | $gifBinary = $gc->getGif(); | 309 | $gifBinary = $gc->getGif(); |