Commit d4bcea5ae8f24ad422bb8e9d2ef321b943b957aa
1 parent
0922b760
Exists in
master
and in
6 other branches
Correção na ativação de camadas que possuem parametros sql, evitando que o statu…
…s seja sempre inserido como DEFAULT
Showing
6 changed files
with
1796 additions
and
1746 deletions
Show diff stats
classesphp/classe_metaestatinfo.php
... | ... | @@ -510,6 +510,7 @@ class MetaestatInfo{ |
510 | 510 | $this->nomecache = $this->nomecache . $this->nomeRandomico(5); |
511 | 511 | } |
512 | 512 | $arq = $this->dir_tmp."/".$this->nomecache.".map"; |
513 | + | |
513 | 514 | if(!file_exists($arq)){ |
514 | 515 | $meta = $this->listaMedidaVariavel("",$id_medida_variavel); |
515 | 516 | //evita agregar regioes qd nao e necessario |
... | ... | @@ -578,14 +579,14 @@ class MetaestatInfo{ |
578 | 579 | $titulo = array(); |
579 | 580 | //adiciona as classes novas |
580 | 581 | $expressao[] = "([".$item."]<=".($calc["quartil1"]).")"; |
581 | - $titulo[] = "Quartil 1: <=".$calc["quartil1"]; | |
582 | + $titulo[] = "<=".round($calc["quartil1"],3); | |
582 | 583 | $expressao[] = "(([".$item."]>".($calc["quartil1"]).")and([".$item."]<=".($calc["quartil2"])."))"; |
583 | - $titulo[] = "Quartil 2: >".$calc["quartil1"]." e <= ".$calc["quartil2"]; | |
584 | + $titulo[] = "> ".round($calc["quartil1"],3)." e <= ".round($calc["quartil2"],3); | |
584 | 585 | if($calc["quartil3"] != 0){ |
585 | 586 | $expressao[] = "(([".$item."]>".($calc["quartil2"]).")and([".$item."]<=".($calc["quartil3"])."))"; |
586 | - $titulo[] = "Quartil 3: >".$calc["quartil2"]." e <= ".$calc["quartil3"]; | |
587 | + $titulo[] = "> ".round($calc["quartil2"],3)." e <= ".round($calc["quartil3"],3); | |
587 | 588 | $expressao[] = "([".$item."]>".($calc["quartil3"]).")"; |
588 | - $titulo[] = "Quartil 4: >".$calc["quartil3"]; | |
589 | + $titulo[] = "> ".round($calc["quartil3"],3); | |
589 | 590 | } |
590 | 591 | if($calc["quartil1"] > 0){ |
591 | 592 | $classes[] = array( |
... | ... | @@ -736,6 +737,7 @@ class MetaestatInfo{ |
736 | 737 | fwrite($fp,$dado."\n"); |
737 | 738 | } |
738 | 739 | } |
740 | + | |
739 | 741 | return array("mapfile"=>$arq,"layer"=>$this->nomecache,"titulolayer"=>$titulolayer); |
740 | 742 | } |
741 | 743 | /** | ... | ... |
classesphp/mapa_controle.php
... | ... | @@ -249,6 +249,7 @@ if ($funcao == "criaMapa") { |
249 | 249 | cpjson($id); |
250 | 250 | return; |
251 | 251 | } |
252 | + | |
252 | 253 | if (! isset($map_file)) { |
253 | 254 | // nesse caso é necessário criar o diretório temporário e iniciar o mapa |
254 | 255 | // $cp->set_data(array("erro"=>"linkquebrado")); | ... | ... |
classesphp/mapa_inicia.php
1 | -<?php | |
2 | -/* | |
3 | -Title: mapa_inicia.php | |
4 | - | |
5 | -Inicia um novo mapa. | |
6 | - | |
7 | -Gera as imagens necessárias para abrir o mapa e calcula um conjunto de variáveis necessárias | |
8 | -ao funcionamento do i3Geo. Os dados são devolvidos como um objeto json. Conforme a interface | |
9 | -que será utilizada pelo mapa, são feitos ajustes específicos. | |
10 | - | |
11 | -Licenca: | |
12 | - | |
13 | -GPL2 | |
14 | - | |
15 | -i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
16 | - | |
17 | -Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
18 | -Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | |
19 | - | |
20 | -Este programa é software livre; você pode redistribuí-lo | |
21 | -e/ou modificá-lo sob os termos da Licença Pública Geral | |
22 | -GNU conforme publicada pela Free Software Foundation; | |
23 | - | |
24 | -Este programa é distribuído na expectativa de que seja útil, | |
25 | -porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
26 | -de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
27 | -Consulte a Licença Pública Geral do GNU para mais detalhes. | |
28 | -Você deve ter recebido uma copia da Licença Pública Geral do | |
29 | -GNU junto com este programa; se não, escreva para a | |
30 | -Free Software Foundation, Inc., no endereço | |
31 | -59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
32 | - | |
33 | -Arquivo: | |
34 | - | |
35 | -i3geo/classesphp/mapa_inicia.php | |
36 | -*/ | |
37 | - | |
38 | -/* | |
39 | -Function: iniciaMapa | |
40 | - | |
41 | -Inicia um mapa e obtém os parâmetros necessários para o funcionamento da interface HTML. | |
42 | - | |
43 | -Para permitir a troca dinâmica de interfaces, são gravados no mapfile os METADATA status e opacity, com o prefixo "ol" para OpenLayers e "gm" para Google Maps e Earth | |
44 | - | |
45 | -Globais: | |
46 | - | |
47 | -$interface - nome da interface que será utilizada pelo mapa padrao|openlayers|googlemaps|googleearth|flamingo . O valor de $interface é também armazenado no metadata "interface" do objeto Map, podendo ser utilizada em outros programas do i3Geo. | |
48 | - | |
49 | -$openid - indica se o usuário foi ou não autenticado em alguma rede social (veja i3geo/pacotes/openid) | |
50 | - | |
51 | -$interfacePadrao - interface definida em ms_configura.php | |
52 | - | |
53 | -$navegadoresLocais - array que indica quais usuários podem navegar no servidor | |
54 | - | |
55 | -$cp - Objeto CPAINT. | |
56 | - | |
57 | -$map_file - Arquivo map file. | |
58 | - | |
59 | -$mapext - Extensão geográfica do mapa. | |
60 | - | |
61 | -$w - Largura da imagem do mapa. | |
62 | - | |
63 | -$h - Altura da imagem do mapa. | |
64 | - | |
65 | -$R_path - Variável definida no arquivo ms_configura.php que indica se o software R está instalado. | |
66 | - | |
67 | -$locmapserv - Variável definida no arquivo ms_configura.php que indica nome do mapserver cgi. | |
68 | - | |
69 | -$kmlurl - url de um arquivo kml que será inserido no mapa. Válido para a interface google maps | |
70 | - | |
71 | -Retorno: | |
72 | - | |
73 | -{JSON} | |
74 | - | |
75 | -(start code) | |
76 | - | |
77 | -{ | |
78 | - variaveis:, | |
79 | - temas:[{ | |
80 | - "name":, | |
81 | - "status":, | |
82 | - "tema":, | |
83 | - "transparency":, | |
84 | - "type":, | |
85 | - "sel":, | |
86 | - "escala":, | |
87 | - "download":, | |
88 | - "features":, | |
89 | - "connectiontype":, | |
90 | - "zoomtema":, | |
91 | - "contextoescala":, | |
92 | - "etiquetas":, | |
93 | - "identifica":, | |
94 | - "editorsql":, | |
95 | - "escondido": | |
96 | - }] | |
97 | -} | |
98 | - | |
99 | -(end) | |
100 | -*/ | |
101 | -function iniciaMapa() | |
102 | -{ | |
103 | - global $googleApiKey,$i3geoPermiteLogin, $dir_tmp, $logExec, $postgis_mapa,$statusFerramentas,$saikuUrl,$emailInstituicao,$openid,$interfacePadrao,$mensagemInicia,$kmlurl,$tituloInstituicao,$tempo,$navegadoresLocais,$locaplic,$map_file,$mapext,$w,$h,$R_path,$locmapserv,$utilizacgi,$expoeMapfile,$interface; | |
104 | - // | |
105 | - //verifica se algum tema e restrito a determinado usuario | |
106 | - //as funcoes de validacao encontram-se em funcoes_gerais.php | |
107 | - // | |
108 | - if(!function_exists("validaAcessoTemas")){ | |
109 | - include_once("funcoes_gerais.php"); | |
110 | - } | |
111 | - validaAcessoTemas($map_file); | |
112 | - | |
113 | - if($dir_tmp != "" && isset($logExec) && $logExec["init"] == true){ | |
114 | - i3GeoLog("prog: iniciaMapa interface: $interface",$dir_tmp); | |
115 | - } | |
116 | - | |
117 | - if(!isset($kmlurl)){ | |
118 | - $kmlurl = ""; | |
119 | - } | |
120 | - //error_reporting(0); | |
121 | - if(!isset($interface)){ | |
122 | - $interface = ""; | |
123 | - } | |
124 | - if($interface == "openlayers"){ | |
125 | - $m = ms_newMapObj($map_file); | |
126 | - $e = $m->extent; | |
127 | - $ext = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | |
128 | - $c = $m->numlayers; | |
129 | - for ($i=0;$i < $c;++$i){ | |
130 | - $layer = $m->getlayer($i); | |
131 | - if($layer->status == 2){ | |
132 | - $layer->setmetadata("olstatus","DEFAULT"); | |
133 | - } | |
134 | - else{ | |
135 | - $layer->setmetadata("olstatus","OFF"); | |
136 | - } | |
137 | - $layer->setmetadata("olopacity",$layer->opacity); | |
138 | - //error_log($layer->name); | |
139 | - } | |
140 | - $m->save($map_file); | |
141 | - } | |
142 | - if($interface == "googlemaps") | |
143 | - { | |
144 | - $m = ms_newMapObj($map_file); | |
145 | - $e = $m->extent; | |
146 | - $ext = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | |
147 | - if($interface == "googlemaps"){ | |
148 | - $m->setProjection("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m"); | |
149 | - } | |
150 | - $c = $m->numlayers; | |
151 | - for ($i=0;$i < $c;++$i) | |
152 | - { | |
153 | - $layer = $m->getlayer($i); | |
154 | - if($layer->status == 2) | |
155 | - {$layer->setmetadata("gmstatus","DEFAULT");} | |
156 | - else | |
157 | - {$layer->setmetadata("gmstatus","OFF");} | |
158 | - $layer->setmetadata("gmopacity",$layer->opacity); | |
159 | - if($layer->name == "mundo" || $layer->name == "estados") | |
160 | - {$layer->set("status",MS_OFF);} | |
161 | - if($layer->type == MS_LAYER_POLYGON || $layer->type == MS_LAYER_RASTER) | |
162 | - { | |
163 | - if($layer->opacity == "" || $layer->opacity == 100) | |
164 | - { | |
165 | - $layer->set("opacity",50); | |
166 | - } | |
167 | - } | |
168 | - if($layer->name == "rosadosventos" || $layer->name == "copyright") | |
169 | - {$layer->set("status",MS_DELETE);} | |
170 | - } | |
171 | - $temp = $m->scalebar; | |
172 | - $temp->set("status",MS_OFF); | |
173 | - $c = $m->imagecolor; | |
174 | - $c->setrgb(255,255,255); | |
175 | - if($interface == "googleearth") | |
176 | - { | |
177 | - $m->selectOutputFormat("jpeg"); | |
178 | - $of = $m->outputformat; | |
179 | - $of->set("driver","AGG/PNG"); | |
180 | - } | |
181 | - else | |
182 | - {$of = $m->outputformat;} | |
183 | - $of->set("imagemode",MS_IMAGEMODE_RGBA); | |
184 | - $of->set("transparent",MS_ON); | |
185 | - $m->save($map_file); | |
186 | - } | |
187 | - $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | |
188 | - $protocolo = $protocolo[0]; | |
189 | - $protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; | |
190 | - $urli3geo = str_replace("/classesphp/mapa_controle.php","",$protocolo.$_SERVER["PHP_SELF"]); | |
191 | - //altera o tamanho do query map para ficar igual ao do mapa | |
192 | - include_once("classe_mapa.php"); | |
193 | - //error_reporting(0); | |
194 | - if(!function_exists("sobeAnno")){ | |
195 | - include_once("funcoes_gerais.php"); | |
196 | - } | |
197 | - sobeAnno($map_file); | |
198 | - $m = new Mapa($map_file); | |
199 | - if(isset($w)) | |
200 | - { | |
201 | - $m->mudaQS($w,$h); | |
202 | - $m = new Mapa($map_file); | |
203 | - $m->mapa->setsize($w,$h); | |
204 | - } | |
205 | - //error_reporting(0); | |
206 | - // | |
207 | - //verifica se a legenda deve ser embebida no mapa | |
208 | - // | |
209 | - $legenda = $m->mapa->legend; | |
210 | - $legenda->set("status",MS_OFF); | |
211 | - // | |
212 | - //salva as alterações feitas | |
213 | - // | |
214 | - $m->mapa->setmetadata("ows_enable_request","*"); | |
215 | - $m->salva(); | |
216 | - // | |
217 | - //cuidado ao mexer aqui | |
218 | - //o mapa precisa ser salvo para registrar a extensão geográfica | |
219 | - // | |
220 | - //$imgo = $m->mapa->draw(); | |
221 | - $imgo = $m->mapa->prepareImage(); | |
222 | - $m->salva($map_file); | |
223 | - //$e = $m->mapa->extent; | |
224 | - //$ext = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | |
225 | - $escalaMapa = $m->mapa->scaledenom; | |
226 | - $celula = $m->mapa->cellsize; | |
227 | - // | |
228 | - //pega os parametros de cada tema | |
229 | - // | |
230 | - $qyfile = str_replace(".map",".qy",$map_file); | |
231 | - $arqsel = (file_exists($qyfile)) ? true : false; | |
232 | - $m = New Mapa($map_file,$locaplic); | |
233 | - $temas = $m->parametrosTemas(); | |
234 | - $versao = versao(); | |
235 | - $temp = $m->mapa->scalebar; | |
236 | - $temp->set("status",MS_OFF); | |
237 | - $of = $m->mapa->outputformat; | |
238 | - $of->set("imagemode",MS_IMAGEMODE_RGBA); | |
239 | - $of->setOption("QUANTIZE_FORCE","OFF"); | |
240 | - $of->set("driver","AGG/PNG"); | |
241 | - $m->mapa->setmetadata("interface",$interface); | |
242 | - $m->salva(); | |
243 | - $nomes = nomeRandomico(12); | |
244 | - if($imgo->imagepath == "") | |
245 | - {echo "Erro IMAGEPATH vazio";exit;} | |
246 | - $nomer = ($imgo->imagepath)."mapa".$nomes.".png"; | |
247 | - //$imgo->saveImage($nomer); | |
248 | - if (isset($utilizacgi) && strtolower($utilizacgi) == "sim") | |
249 | - {$nomer = $locmapserv."?map=".$map_file."&mode=map";} | |
250 | - else | |
251 | - {$nomer = ($imgo->imageurl).basename($nomer);} | |
252 | - //pega a cor de fundo do mapa | |
253 | - $c = $m->mapa->imagecolor; | |
254 | - $cordefundo = $c->red.",".$c->green.",".$c->blue; | |
255 | - //pega o texto de copyright | |
256 | - $copyright = ""; | |
257 | - $lc = @$m->mapa->getlayerbyname("copyright"); | |
258 | - if($lc != "" && $lc->status == MS_DEFAULT ){ | |
259 | - if($versao["principal"] >= 6){ | |
260 | - $shape = $lc->getShape(new resultObj(0)); | |
261 | - $copyright = $shape->text; | |
262 | - } | |
263 | - else{ | |
264 | - $shape = $lc->getfeature(0,-1); | |
265 | - $copyright = $shape->text; | |
266 | - } | |
267 | - } | |
268 | - $res["editor"] = "nao"; | |
269 | - // | |
270 | - //papeis do usuario se estiver logado | |
271 | - // | |
272 | - $res["papeis"] = array(); | |
273 | - $logado = "nao"; | |
274 | - $res["i3geoPermiteLogin"] = "sim"; | |
275 | - if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
276 | - $_COOKIE = array(); | |
277 | - $res["i3geoPermiteLogin"] = "nao"; | |
278 | - } | |
279 | - if(!empty($_COOKIE["i3geocodigologin"])){ | |
280 | - session_write_close(); | |
281 | - session_name("i3GeoLogin"); | |
282 | - session_id($_COOKIE["i3geocodigologin"]); | |
283 | - session_start(); | |
284 | - //var_dump($_SESSION);exit; | |
285 | - $logado = "sim"; | |
286 | - if(!empty($_SESSION["usuario"]) && $_SESSION["usuario"] == $_COOKIE["i3geousuariologin"]){ | |
287 | - $res["papeis"] = $_SESSION["papeis"]; | |
288 | - } | |
289 | - else{ | |
290 | - $logado = "nao"; | |
291 | - } | |
292 | - //verifica se o usuario logado pode ver as opcoes de edicao do sistema de admin dentro do mapa | |
293 | - foreach($res["papeis"] as $p){ | |
294 | - if($p < 3){ | |
295 | - $res["editor"] = "sim"; | |
296 | - } | |
297 | - } | |
298 | - } | |
299 | - // | |
300 | - $res["mapexten"] = $ext; | |
301 | - $res["mapscale"] = $escalaMapa; | |
302 | - $res["mapres"] = $m->mapa->resolution; | |
303 | - $res["pixelsize"] = $celula; | |
304 | - //TODO depreciar na documentacao e ms_configura | |
305 | - /* | |
306 | - if ((isset($expoeMapfile)) && ($expoeMapfile == "nao")) | |
307 | - {$res["mapfile"] = "";} | |
308 | - else | |
309 | - {$res["mapfile"] = $map_file;} | |
310 | - */ | |
311 | - $res["mapfile"] = ""; | |
312 | - $res["cgi"] = "";//$locmapserv; | |
313 | - $res["extentTotal"] = $ext; | |
314 | - $res["mapimagem"] = "";//$nomer; | |
315 | - $geoip = "nao"; | |
316 | - if (file_exists($locaplic."/pacotes/geoip") && file_exists($locaplic."/pacotes/geoip/GeoLiteCity.dat")) | |
317 | - {$geoip = "sim";} | |
318 | - $res["geoip"] = $geoip; | |
319 | - $res["listavisual"] = (file_exists($locaplic."/imagens/visual")) ? implode(",",listaDiretorios($locaplic."/imagens/visual")) : ""; | |
320 | - //TODO depreciar na documentacao | |
321 | - $res["utilizacgi"] = "nao";//$utilizacgi; | |
322 | - $res["versaoms"] = $versao["principal"]; | |
323 | - $res["versaomscompleta"] = $versao["completa"]; | |
324 | - $res["versaoint"] = $versao["inteiro"]; | |
325 | - $res["mensagens"] = $m->pegaMensagens(); | |
326 | - $res["r"] = (isset($R_path)) ? "sim" : "nao"; | |
327 | - $res["extentref"] = ""; | |
328 | - $res["kmlurl"] = $kmlurl; | |
329 | - $res["mensageminicia"] = $mensagemInicia; | |
330 | - $res["interfacePadrao"] = $interfacePadrao; | |
331 | - $res["w"] = $w; | |
332 | - $res["h"] = $h; | |
333 | - $res["titulo"] = $tituloInstituicao; | |
334 | - $res["tempo"] = microtime(1) - $tempo; | |
335 | - $res["erro"] = ''; | |
336 | - $res["mappath"] = "";//$imgo->imagepath; | |
337 | - $res["mapurl"] = "";//$imgo->imageurl; | |
338 | - $res["navegacaoDir"] = $navegadoresLocais; | |
339 | - if($openid == true) | |
340 | - {$res["autenticadoopenid"] = "sim";} | |
341 | - else | |
342 | - {$res["autenticadoopenid"] = "nao";} | |
343 | - $res["emailInstituicao"] = $emailInstituicao; | |
344 | - $res["cordefundo"] = $cordefundo; | |
345 | - $res["copyright"] = $copyright; | |
346 | - $res["logado"] = $logado; | |
347 | - $res["saikuUrl"] = $saikuUrl; | |
348 | - $res["statusFerramentas"] = $statusFerramentas; | |
349 | - $res["googleApiKey"] = $googleApiKey; | |
350 | - //parametros de inicializacao armazenados com o mapa quando o usuario utiliza a opcao de salvar mapa no nbanco de dados | |
351 | - $customizacoesinit = $m->mapa->getmetadata("CUSTOMIZACOESINIT"); | |
352 | - $res["editavel"] = $m->mapa->getmetadata("EDITAVEL"); | |
353 | - $m->mapa->setmetadata("CUSTOMIZACOESINIT",""); | |
354 | - $m->salva(); | |
355 | - restauraCon($map_file,$postgis_mapa); | |
356 | - copy($map_file,(str_replace(".map","reinc.map",$map_file))); | |
357 | - copy($map_file,(str_replace(".map","seguranca.map",$map_file))); | |
358 | - ob_clean(); | |
359 | - cpjson(array("variaveis"=>$res,"temas"=>$temas,"customizacoesinit"=>$customizacoesinit)); | |
360 | -} | |
1 | +<?php | |
2 | + | |
3 | +/* | |
4 | + * Title: mapa_inicia.php | |
5 | + * | |
6 | + * Inicia um novo mapa. | |
7 | + * | |
8 | + * Gera as imagens necessárias para abrir o mapa e calcula um conjunto de variáveis necessárias | |
9 | + * ao funcionamento do i3Geo. Os dados são devolvidos como um objeto json. Conforme a interface | |
10 | + * que será utilizada pelo mapa, são feitos ajustes específicos. | |
11 | + * | |
12 | + * Licenca: | |
13 | + * | |
14 | + * GPL2 | |
15 | + * | |
16 | + * i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
17 | + * | |
18 | + * Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
19 | + * Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | |
20 | + * | |
21 | + * Este programa é software livre; você pode redistribuí-lo | |
22 | + * e/ou modificá-lo sob os termos da Licença Pública Geral | |
23 | + * GNU conforme publicada pela Free Software Foundation; | |
24 | + * | |
25 | + * Este programa é distribuído na expectativa de que seja útil, | |
26 | + * porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
27 | + * de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
28 | + * Consulte a Licença Pública Geral do GNU para mais detalhes. | |
29 | + * Você deve ter recebido uma copia da Licença Pública Geral do | |
30 | + * GNU junto com este programa; se não, escreva para a | |
31 | + * Free Software Foundation, Inc., no endereço | |
32 | + * 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
33 | + * | |
34 | + * Arquivo: | |
35 | + * | |
36 | + * i3geo/classesphp/mapa_inicia.php | |
37 | + */ | |
38 | + | |
39 | +/* | |
40 | + * Function: iniciaMapa | |
41 | + * | |
42 | + * Inicia um mapa e obtém os parâmetros necessários para o funcionamento da interface HTML. | |
43 | + * | |
44 | + * Para permitir a troca dinâmica de interfaces, são gravados no mapfile os METADATA status e opacity, com o prefixo "ol" para OpenLayers e "gm" para Google Maps e Earth | |
45 | + * | |
46 | + * Globais: | |
47 | + * | |
48 | + * $interface - nome da interface que será utilizada pelo mapa padrao|openlayers|googlemaps|googleearth|flamingo . O valor de $interface é também armazenado no metadata "interface" do objeto Map, podendo ser utilizada em outros programas do i3Geo. | |
49 | + * | |
50 | + * $openid - indica se o usuário foi ou não autenticado em alguma rede social (veja i3geo/pacotes/openid) | |
51 | + * | |
52 | + * $interfacePadrao - interface definida em ms_configura.php | |
53 | + * | |
54 | + * $navegadoresLocais - array que indica quais usuários podem navegar no servidor | |
55 | + * | |
56 | + * $cp - Objeto CPAINT. | |
57 | + * | |
58 | + * $map_file - Arquivo map file. | |
59 | + * | |
60 | + * $mapext - Extensão geográfica do mapa. | |
61 | + * | |
62 | + * $w - Largura da imagem do mapa. | |
63 | + * | |
64 | + * $h - Altura da imagem do mapa. | |
65 | + * | |
66 | + * $R_path - Variável definida no arquivo ms_configura.php que indica se o software R está instalado. | |
67 | + * | |
68 | + * $locmapserv - Variável definida no arquivo ms_configura.php que indica nome do mapserver cgi. | |
69 | + * | |
70 | + * $kmlurl - url de um arquivo kml que será inserido no mapa. Válido para a interface google maps | |
71 | + * | |
72 | + * Retorno: | |
73 | + * | |
74 | + * {JSON} | |
75 | + * | |
76 | + * (start code) | |
77 | + * | |
78 | + * { | |
79 | + * variaveis:, | |
80 | + * temas:[{ | |
81 | + * "name":, | |
82 | + * "status":, | |
83 | + * "tema":, | |
84 | + * "transparency":, | |
85 | + * "type":, | |
86 | + * "sel":, | |
87 | + * "escala":, | |
88 | + * "download":, | |
89 | + * "features":, | |
90 | + * "connectiontype":, | |
91 | + * "zoomtema":, | |
92 | + * "contextoescala":, | |
93 | + * "etiquetas":, | |
94 | + * "identifica":, | |
95 | + * "editorsql":, | |
96 | + * "escondido": | |
97 | + * }] | |
98 | + * } | |
99 | + * | |
100 | + * (end) | |
101 | + */ | |
102 | +function iniciaMapa() | |
103 | +{ | |
104 | + global $googleApiKey, $i3geoPermiteLogin, $dir_tmp, $logExec, $postgis_mapa, $statusFerramentas, $saikuUrl, $emailInstituicao, $openid, $interfacePadrao, $mensagemInicia, $kmlurl, $tituloInstituicao, $tempo, $navegadoresLocais, $locaplic, $map_file, $mapext, $w, $h, $R_path, $locmapserv, $utilizacgi, $expoeMapfile, $interface; | |
105 | + // | |
106 | + // verifica se algum tema e restrito a determinado usuario | |
107 | + // as funcoes de validacao encontram-se em funcoes_gerais.php | |
108 | + // | |
109 | + if (! function_exists("validaAcessoTemas")) { | |
110 | + include_once ("funcoes_gerais.php"); | |
111 | + } | |
112 | + validaAcessoTemas($map_file); | |
113 | + | |
114 | + if ($dir_tmp != "" && isset($logExec) && $logExec["init"] == true) { | |
115 | + i3GeoLog("prog: iniciaMapa interface: $interface", $dir_tmp); | |
116 | + } | |
117 | + | |
118 | + if (! isset($kmlurl)) { | |
119 | + $kmlurl = ""; | |
120 | + } | |
121 | + // error_reporting(0); | |
122 | + if (! isset($interface)) { | |
123 | + $interface = ""; | |
124 | + } | |
125 | + if ($interface == "openlayers") { | |
126 | + $m = ms_newMapObj($map_file); | |
127 | + $e = $m->extent; | |
128 | + $ext = ($e->minx) . " " . ($e->miny) . " " . ($e->maxx) . " " . ($e->maxy); | |
129 | + $c = $m->numlayers; | |
130 | + for ($i = 0; $i < $c; ++ $i) { | |
131 | + $layer = $m->getlayer($i); | |
132 | + if ($layer->status == 2) { | |
133 | + $layer->setmetadata("olstatus", "DEFAULT"); | |
134 | + } else { | |
135 | + $layer->setmetadata("olstatus", "OFF"); | |
136 | + } | |
137 | + $layer->setmetadata("olopacity", $layer->opacity); | |
138 | + // error_log($layer->name); | |
139 | + } | |
140 | + $m->save($map_file); | |
141 | + } | |
142 | + if ($interface == "googlemaps") { | |
143 | + $m = ms_newMapObj($map_file); | |
144 | + $e = $m->extent; | |
145 | + $ext = ($e->minx) . " " . ($e->miny) . " " . ($e->maxx) . " " . ($e->maxy); | |
146 | + if ($interface == "googlemaps") { | |
147 | + $m->setProjection("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m"); | |
148 | + } | |
149 | + $c = $m->numlayers; | |
150 | + for ($i = 0; $i < $c; ++ $i) { | |
151 | + $layer = $m->getlayer($i); | |
152 | + if ($layer->status == 2) { | |
153 | + $layer->setmetadata("gmstatus", "DEFAULT"); | |
154 | + } else { | |
155 | + $layer->setmetadata("gmstatus", "OFF"); | |
156 | + } | |
157 | + $layer->setmetadata("gmopacity", $layer->opacity); | |
158 | + if ($layer->name == "mundo" || $layer->name == "estados") { | |
159 | + $layer->set("status", MS_OFF); | |
160 | + } | |
161 | + if ($layer->type == MS_LAYER_POLYGON || $layer->type == MS_LAYER_RASTER) { | |
162 | + if ($layer->opacity == "" || $layer->opacity == 100) { | |
163 | + $layer->set("opacity", 50); | |
164 | + } | |
165 | + } | |
166 | + if ($layer->name == "rosadosventos" || $layer->name == "copyright") { | |
167 | + $layer->set("status", MS_DELETE); | |
168 | + } | |
169 | + } | |
170 | + $temp = $m->scalebar; | |
171 | + $temp->set("status", MS_OFF); | |
172 | + $c = $m->imagecolor; | |
173 | + $c->setrgb(255, 255, 255); | |
174 | + if ($interface == "googleearth") { | |
175 | + $m->selectOutputFormat("jpeg"); | |
176 | + $of = $m->outputformat; | |
177 | + $of->set("driver", "AGG/PNG"); | |
178 | + } else { | |
179 | + $of = $m->outputformat; | |
180 | + } | |
181 | + $of->set("imagemode", MS_IMAGEMODE_RGBA); | |
182 | + $of->set("transparent", MS_ON); | |
183 | + $m->save($map_file); | |
184 | + } | |
185 | + $protocolo = explode("/", $_SERVER['SERVER_PROTOCOL']); | |
186 | + $protocolo = $protocolo[0]; | |
187 | + $protocolo = strtolower($protocolo) . '://' . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT']; | |
188 | + $urli3geo = str_replace("/classesphp/mapa_controle.php", "", $protocolo . $_SERVER["PHP_SELF"]); | |
189 | + // altera o tamanho do query map para ficar igual ao do mapa | |
190 | + include_once ("classe_mapa.php"); | |
191 | + // error_reporting(0); | |
192 | + if (! function_exists("sobeAnno")) { | |
193 | + include_once ("funcoes_gerais.php"); | |
194 | + } | |
195 | + sobeAnno($map_file); | |
196 | + $m = new Mapa($map_file); | |
197 | + if (isset($w)) { | |
198 | + $m->mudaQS($w, $h); | |
199 | + $m = new Mapa($map_file); | |
200 | + $m->mapa->setsize($w, $h); | |
201 | + } | |
202 | + // error_reporting(0); | |
203 | + // | |
204 | + // verifica se a legenda deve ser embebida no mapa | |
205 | + // | |
206 | + $legenda = $m->mapa->legend; | |
207 | + $legenda->set("status", MS_OFF); | |
208 | + // | |
209 | + // salva as alterações feitas | |
210 | + // | |
211 | + $m->mapa->setmetadata("ows_enable_request", "*"); | |
212 | + $m->salva(); | |
213 | + // | |
214 | + // cuidado ao mexer aqui | |
215 | + // o mapa precisa ser salvo para registrar a extensão geográfica | |
216 | + // | |
217 | + // $imgo = $m->mapa->draw(); | |
218 | + $imgo = $m->mapa->prepareImage(); | |
219 | + $m->salva($map_file); | |
220 | + // $e = $m->mapa->extent; | |
221 | + // $ext = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | |
222 | + $escalaMapa = $m->mapa->scaledenom; | |
223 | + $celula = $m->mapa->cellsize; | |
224 | + // | |
225 | + // pega os parametros de cada tema | |
226 | + // | |
227 | + $qyfile = str_replace(".map", ".qy", $map_file); | |
228 | + $arqsel = (file_exists($qyfile)) ? true : false; | |
229 | + $m = new Mapa($map_file, $locaplic); | |
230 | + $temas = $m->parametrosTemas(); | |
231 | + $versao = versao(); | |
232 | + $temp = $m->mapa->scalebar; | |
233 | + $temp->set("status", MS_OFF); | |
234 | + $of = $m->mapa->outputformat; | |
235 | + $of->set("imagemode", MS_IMAGEMODE_RGBA); | |
236 | + $of->setOption("QUANTIZE_FORCE", "OFF"); | |
237 | + $of->set("driver", "AGG/PNG"); | |
238 | + $m->mapa->setmetadata("interface", $interface); | |
239 | + $m->salva(); | |
240 | + $nomes = nomeRandomico(12); | |
241 | + if ($imgo->imagepath == "") { | |
242 | + echo "Erro IMAGEPATH vazio"; | |
243 | + exit(); | |
244 | + } | |
245 | + $nomer = ($imgo->imagepath) . "mapa" . $nomes . ".png"; | |
246 | + // $imgo->saveImage($nomer); | |
247 | + if (isset($utilizacgi) && strtolower($utilizacgi) == "sim") { | |
248 | + $nomer = $locmapserv . "?map=" . $map_file . "&mode=map"; | |
249 | + } else { | |
250 | + $nomer = ($imgo->imageurl) . basename($nomer); | |
251 | + } | |
252 | + // pega a cor de fundo do mapa | |
253 | + $c = $m->mapa->imagecolor; | |
254 | + $cordefundo = $c->red . "," . $c->green . "," . $c->blue; | |
255 | + // pega o texto de copyright | |
256 | + $copyright = ""; | |
257 | + $lc = @$m->mapa->getlayerbyname("copyright"); | |
258 | + if ($lc != "" && $lc->status == MS_DEFAULT) { | |
259 | + if ($versao["principal"] >= 6) { | |
260 | + $shape = $lc->getShape(new resultObj(0)); | |
261 | + $copyright = $shape->text; | |
262 | + } else { | |
263 | + $shape = $lc->getfeature(0, - 1); | |
264 | + $copyright = $shape->text; | |
265 | + } | |
266 | + } | |
267 | + $res["editor"] = "nao"; | |
268 | + // | |
269 | + // papeis do usuario se estiver logado | |
270 | + // | |
271 | + $res["papeis"] = array(); | |
272 | + $logado = "nao"; | |
273 | + $res["i3geoPermiteLogin"] = "sim"; | |
274 | + if (isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false) { | |
275 | + $_COOKIE = array(); | |
276 | + $res["i3geoPermiteLogin"] = "nao"; | |
277 | + } | |
278 | + if (! empty($_COOKIE["i3geocodigologin"])) { | |
279 | + session_write_close(); | |
280 | + session_name("i3GeoLogin"); | |
281 | + session_id($_COOKIE["i3geocodigologin"]); | |
282 | + session_start(); | |
283 | + // var_dump($_SESSION);exit; | |
284 | + $logado = "sim"; | |
285 | + if (! empty($_SESSION["usuario"]) && $_SESSION["usuario"] == $_COOKIE["i3geousuariologin"]) { | |
286 | + $res["papeis"] = $_SESSION["papeis"]; | |
287 | + } else { | |
288 | + $logado = "nao"; | |
289 | + } | |
290 | + // verifica se o usuario logado pode ver as opcoes de edicao do sistema de admin dentro do mapa | |
291 | + foreach ($res["papeis"] as $p) { | |
292 | + if ($p < 3) { | |
293 | + $res["editor"] = "sim"; | |
294 | + } | |
295 | + } | |
296 | + } | |
297 | + // | |
298 | + $res["mapexten"] = $ext; | |
299 | + $res["mapscale"] = $escalaMapa; | |
300 | + $res["mapres"] = $m->mapa->resolution; | |
301 | + $res["pixelsize"] = $celula; | |
302 | + // TODO depreciar na documentacao e ms_configura | |
303 | + /* | |
304 | + * if ((isset($expoeMapfile)) && ($expoeMapfile == "nao")) | |
305 | + * {$res["mapfile"] = "";} | |
306 | + * else | |
307 | + * {$res["mapfile"] = $map_file;} | |
308 | + */ | |
309 | + $res["mapfile"] = ""; | |
310 | + $res["cgi"] = ""; // $locmapserv; | |
311 | + $res["extentTotal"] = $ext; | |
312 | + $res["mapimagem"] = ""; // $nomer; | |
313 | + $geoip = "nao"; | |
314 | + if (file_exists($locaplic . "/pacotes/geoip") && file_exists($locaplic . "/pacotes/geoip/GeoLiteCity.dat")) { | |
315 | + $geoip = "sim"; | |
316 | + } | |
317 | + $res["geoip"] = $geoip; | |
318 | + $res["listavisual"] = (file_exists($locaplic . "/imagens/visual")) ? implode(",", listaDiretorios($locaplic . "/imagens/visual")) : ""; | |
319 | + // TODO depreciar na documentacao | |
320 | + $res["utilizacgi"] = "nao"; // $utilizacgi; | |
321 | + $res["versaoms"] = $versao["principal"]; | |
322 | + $res["versaomscompleta"] = $versao["completa"]; | |
323 | + $res["versaoint"] = $versao["inteiro"]; | |
324 | + $res["mensagens"] = $m->pegaMensagens(); | |
325 | + $res["r"] = (isset($R_path)) ? "sim" : "nao"; | |
326 | + $res["extentref"] = ""; | |
327 | + $res["kmlurl"] = $kmlurl; | |
328 | + $res["mensageminicia"] = $mensagemInicia; | |
329 | + $res["interfacePadrao"] = $interfacePadrao; | |
330 | + $res["w"] = $w; | |
331 | + $res["h"] = $h; | |
332 | + $res["titulo"] = $tituloInstituicao; | |
333 | + $res["tempo"] = microtime(1) - $tempo; | |
334 | + $res["erro"] = ''; | |
335 | + $res["mappath"] = ""; // $imgo->imagepath; | |
336 | + $res["mapurl"] = ""; // $imgo->imageurl; | |
337 | + $res["navegacaoDir"] = $navegadoresLocais; | |
338 | + if ($openid == true) { | |
339 | + $res["autenticadoopenid"] = "sim"; | |
340 | + } else { | |
341 | + $res["autenticadoopenid"] = "nao"; | |
342 | + } | |
343 | + $res["emailInstituicao"] = $emailInstituicao; | |
344 | + $res["cordefundo"] = $cordefundo; | |
345 | + $res["copyright"] = $copyright; | |
346 | + $res["logado"] = $logado; | |
347 | + $res["saikuUrl"] = $saikuUrl; | |
348 | + $res["statusFerramentas"] = $statusFerramentas; | |
349 | + $res["googleApiKey"] = $googleApiKey; | |
350 | + // parametros de inicializacao armazenados com o mapa quando o usuario utiliza a opcao de salvar mapa no nbanco de dados | |
351 | + $customizacoesinit = $m->mapa->getmetadata("CUSTOMIZACOESINIT"); | |
352 | + $res["editavel"] = $m->mapa->getmetadata("EDITAVEL"); | |
353 | + $m->mapa->setmetadata("CUSTOMIZACOESINIT", ""); | |
354 | + $m->salva(); | |
355 | + restauraCon($map_file, $postgis_mapa); | |
356 | + copy($map_file, (str_replace(".map", "reinc.map", $map_file))); | |
357 | + copy($map_file, (str_replace(".map", "seguranca.map", $map_file))); | |
358 | + ob_clean(); | |
359 | + cpjson(array( | |
360 | + "variaveis" => $res, | |
361 | + "temas" => $temas, | |
362 | + "customizacoesinit" => $customizacoesinit | |
363 | + )); | |
364 | +} | |
361 | 365 | ?> | ... | ... |
ferramentas/parametrossql/exec.php
... | ... | @@ -99,7 +99,9 @@ switch (strtoupper($funcao)) |
99 | 99 | } |
100 | 100 | $layer->set("data",$data); |
101 | 101 | } |
102 | - $layer->set("status",MS_DEFAULT); | |
102 | + if(isset($_GET["ativacamada"])){ | |
103 | + $layer->set("status",MS_DEFAULT); | |
104 | + } | |
103 | 105 | $layer->setmetadata("PLUGINI3GEO",'{"plugin":"parametrossql","ativo":"sim"}'); |
104 | 106 | $layer->setmetadata("TEMA",$layer1->getmetadata("TEMA")." - ".$titulos); |
105 | 107 | //$layer->set("name","plugin".nomeRandomico()); | ... | ... |
ferramentas/parametrossql/index.js
... | ... | @@ -163,6 +163,7 @@ i3GEOF.parametrossql = { |
163 | 163 | }; |
164 | 164 | p = i3GEO.configura.locaplic+"/ferramentas/parametrossql/exec.php?g_sid="+i3GEO.configura.sid |
165 | 165 | + "&funcao=aplicar" |
166 | + + "&ativacamada=sim" | |
166 | 167 | + "&tema=" + camada.name |
167 | 168 | + "&chaves=&valores=" + par.join(","); |
168 | 169 | cp = new cpaint(); | ... | ... |
ms_criamapa.php
1 | -<?php | |
2 | -/* | |
3 | -Title: Inicializa o i3Geo via URL ms_criamapa.php | |
4 | - | |
5 | -Esse é o programa principal de inicialização, podendo ser chamado diretamente pelo navegador web. | |
6 | - | |
7 | -Cria os diretórios temporários em ms_tmp, incluindo o mapfile (http://mapserver.org/mapfile/index.html#mapfile) que será a base para o funcionamento do mapa. | |
8 | - | |
9 | -Com o uso de parâmetros é possível alterar o processo padrão de criação do mapa, como por exemplo, podem ser adicionadas novas camadas ou modificada a abrangência espacial do mapa. | |
10 | - | |
11 | -A inicialização padrão abrirá uma interface HTML com todas as funcionalidades disponíveis, porém é possível escolher qualquer outro HTML para a apresentação do mapa. | |
12 | - | |
13 | -No diretório i3geo/interface estão os arquivos HTML que formatam a apresentação do mapa. Além desses arquivos, podem ser criados outros, conforme a necessidade do usuário. | |
14 | - | |
15 | -Os parâmetros podem ser utilizados na chamada do i3geo via navegador, p.e., | |
16 | - | |
17 | -http://localhost/i3geo/ms_criamapa.php?temasa=estadosl | |
18 | - | |
19 | -A ordem dos parâmetros não é importante, mas o primeiro deve ser precedido de "?". Os demais parâmetros devem ser acrescentados sempre precedidos de "&", p.e., | |
20 | - | |
21 | -http://localhost/i3geo/ms_criamapa.php?temasa=estadosl bioma&layers=estadosl bioma | |
22 | - | |
23 | -Caso a inicialização do i3geo ocorra por um outro programa PHP, o ms_criamapa.php deve ser executado via include. Nesse caso, os parâmetros devem ser especificados como variáveis, p.e., | |
24 | - | |
25 | -$temasa="bioma"; | |
26 | - | |
27 | -include("ms_criamapa.php"); | |
28 | - | |
29 | -Observações: | |
30 | - | |
31 | -Os cookies passados ao servidor são eliminados com a linha | |
32 | - | |
33 | -$_COOKIE = array(); | |
34 | - | |
35 | -Se a sua aplicação precisa de cookies, comente essa linha do programa. | |
36 | - | |
37 | -A interface HTML padrão de abertura do mapa é definido em uma variável no arquivo ms_configura.php, podendo ser alterada se necessário. | |
38 | - | |
39 | -Link: | |
40 | - | |
41 | -http://localhost/i3geo/ms_criamapa.php | |
42 | - | |
43 | -Licença: | |
44 | - | |
45 | -GPL2 | |
46 | - | |
47 | -i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
48 | - | |
49 | -Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
50 | -Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | |
51 | - | |
52 | -Este programa é software livre; você pode redistribuí-lo | |
53 | -e/ou modificá-lo sob os termos da Licença Pública Geral | |
54 | -GNU conforme publicada pela Free Software Foundation; | |
55 | - | |
56 | -Este programa é distribuído na expectativa de que seja útil, | |
57 | -porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
58 | -de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
59 | -Consulte a Licença Pública Geral do GNU para mais detalhes. | |
60 | -Você deve ter recebido uma cópia da Licença Pública Geral do | |
61 | -GNU junto com este programa; se não, escreva para a | |
62 | -Free Software Foundation, Inc., no endereço | |
63 | -59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
64 | - | |
65 | -Arquivo: i3geo/ms_criamapa.php | |
66 | - | |
67 | -Parâmetros: | |
68 | - | |
69 | -base - arquivo mapfile que servirá de base para a criação do mapa. Por default, são utilizados os arquivos existentes em i3geo/aplicmap (geral1windows, geral1,...) | |
70 | - Essa variável pode ser definida em ms_configura também. Se não estiver definida em nenhum lugar, o i3Geo tentará descobrir o arquivo adequado a ser utilizado. Você pode utilizar essa opção para abrir um mapa com as camadas que você quiser, mas para evitar redundâncias, prefira o uso de &temasa | |
71 | - | |
72 | -temasa - lista, separada por espaços, com os nomes dos arquivos map ou gvsig que serão adicionados ao mapa. Se o arquivo não estiver no diretório i3geo/temas, o nome deve incluir o caminho completo no servidor. O arquivo pode conter mais de um layer pois todos os existentes serão adicionados ao mapa. Por default, todos os layers encontrados nos mapfiles são adicionados ao mapa com o status de desenho em OFF. | |
73 | - | |
74 | -layers - lista, separada por espaços, com os nomes dos layers que serão ligados. A lista deve conter os nomes dos layers e não os nomes dos mapfiles acrescentados ao mapa. Por exemplo, ao adicionar com "temasa" um mapfile chamado "transporte" que contenha os layers "estradas" e "ferrovias" os dois layers serão adicionados ao mapa. Para que esses dois layers fiquem visíveis no mapa deve-se utilizar &layers=estradas ferrovias. | |
75 | - | |
76 | -desligar - lista com os nomes dos temas que serão forçados a inicializar desligados, ou seja, com STATUS OFF | |
77 | - | |
78 | -mapext - extensao geografica que será utilizada. Por padrão, a extensão geográfica é definida para abranger o Brasil todo. Para alterar o padrão deve-se utilizar o parâmetro mapext para especificar a nova abrangência. Essa abrangência deve ser definida em coordenadas no formato décimos de grau e na projeção geográfica. Exemplo: &mapext=-54 -30 -50 -12. Observe que a ordem dos valores são xmin ymin xmax ymax | |
79 | - | |
80 | -interface - nome da interface que será utilizada para abrir o mapa. As interfaces são arquivos HTML que podem estar no diretório aplicmap. Por default, utiliza-se o geral.htm. Vc pode copiar esse html e alterá-lo para customizar o mapa. Para chamar o html customizado, utilize ms_criamapa.php?interface=meumapa.htm | |
81 | - | |
82 | -perfil - perfil utilizado para restringir os menus de temas. ms_criamapa.php?perfil=usuário1 | |
83 | - | |
84 | -caminho - caminho relativo que indica o local onde a interface do mapa esta localizada. | |
85 | - | |
86 | -pontos - lista de coordenadas x e y que serão adicionadas como pontos no mapa. | |
87 | - | |
88 | -nometemapontos - nome do tema de pontos | |
89 | - | |
90 | -linhas - lista de coordenadas x e y que serão adicionadas como linhas no mapa. As coordenadas de linhas diferentes devem ser separadas por ",", por exemplo: -54 -12 -50 -12,-50 -1 -50 -2 -50 -3 | |
91 | - | |
92 | -nometemalinhas - nome do tema de linhas | |
93 | - | |
94 | -poligonos - lista de coordenadas x e y que serão adicionadas como polígonos no mapa. As coordenadas dos vértices de polígonos diferentes devem ser separadas por ",". | |
95 | - | |
96 | -nometemapoligonos - nome do tema de polígonos | |
97 | - | |
98 | -simbolo - nome do símbolo que será utilizado para desenhar os elementos inseridos (veja arquivo de símbolos em i3geo/symbols) | |
99 | - | |
100 | -corsimbolo - cor do símbolo definido em RGB separados por espaço ou vírgula | |
101 | - | |
102 | -tamanhosimbolo - tamanho do símbolo em pixels | |
103 | - | |
104 | -wkt - insere elementos no mapa com coordenadas definidas em wkt | |
105 | - | |
106 | -nometemawkt - nome do tema em wkt | |
107 | - | |
108 | -idioma - idioma da interface (veja os idiomas disponíveis em classe_idioma.js) | |
109 | - | |
110 | -kmlurl - url de um arquivo KML que será incluido no mapa. Válido apenas na interface google maps | |
111 | - | |
112 | -url_wms - endereço de um WMS (será incluido como uma camada no mapa) | |
113 | - | |
114 | -layer_wms - nome do layer | |
115 | - | |
116 | -style_wms - estilo do layer | |
117 | - | |
118 | -nome_wms - nome da camada (titulo) | |
119 | - | |
120 | -srs_wms - código da projeção | |
121 | - | |
122 | -image_wms - tipo de imagem disponível | |
123 | - | |
124 | -versao_wms - Versão do WMS (necessário quando da inclusão de uma camada WMS diretamente pela URL) | |
125 | - | |
126 | -restauramapa - id do mapa armazenado no sistema de administracao e que será restaurado para ser aberto novamente | |
127 | - | |
128 | -filtros - filtros podem ser adicionados incluindo o parametro da seguinte forma: &map_layer_<nomedotema>_filter= | |
129 | - | |
130 | - Exemplo de filtro | |
131 | - | |
132 | - http://localhost/i3geo/ms_criamapa.php?temasa=_lbiomashp&map_layer__lbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA'))&temasa=_lbiomashp | |
133 | - | |
134 | - no caso de camadas Postgis basta usar map_layer__lbiomashp_filter=cd_legenda='CAATINGA' | |
135 | - | |
136 | - largura - largura em pixel do mapa | |
137 | - | |
138 | - altura - altura em pixels do mapa | |
139 | - | |
140 | - DESLIGACACHE - sim|nao forca o desligamento do cache em todos os layers | |
141 | -*/ | |
142 | - | |
143 | -if(isset($_GET["ajuda"])){ | |
144 | - echo "<pre>"; | |
145 | - echo" | |
1 | +<?php | |
2 | +/* | |
3 | + * Title: Inicializa o i3Geo via URL ms_criamapa.php | |
4 | + * | |
5 | + * Esse é o programa principal de inicialização, podendo ser chamado diretamente pelo navegador web. | |
6 | + * | |
7 | + * Cria os diretórios temporários em ms_tmp, incluindo o mapfile (http://mapserver.org/mapfile/index.html#mapfile) que será a base para o funcionamento do mapa. | |
8 | + * | |
9 | + * Com o uso de parâmetros é possível alterar o processo padrão de criação do mapa, como por exemplo, podem ser adicionadas novas camadas ou modificada a abrangência espacial do mapa. | |
10 | + * | |
11 | + * A inicialização padrão abrirá uma interface HTML com todas as funcionalidades disponíveis, porém é possível escolher qualquer outro HTML para a apresentação do mapa. | |
12 | + * | |
13 | + * No diretório i3geo/interface estão os arquivos HTML que formatam a apresentação do mapa. Além desses arquivos, podem ser criados outros, conforme a necessidade do usuário. | |
14 | + * | |
15 | + * Os parâmetros podem ser utilizados na chamada do i3geo via navegador, p.e., | |
16 | + * | |
17 | + * http://localhost/i3geo/ms_criamapa.php?temasa=estadosl | |
18 | + * | |
19 | + * A ordem dos parâmetros não é importante, mas o primeiro deve ser precedido de "?". Os demais parâmetros devem ser acrescentados sempre precedidos de "&", p.e., | |
20 | + * | |
21 | + * http://localhost/i3geo/ms_criamapa.php?temasa=estadosl bioma&layers=estadosl bioma | |
22 | + * | |
23 | + * Caso a inicialização do i3geo ocorra por um outro programa PHP, o ms_criamapa.php deve ser executado via include. Nesse caso, os parâmetros devem ser especificados como variáveis, p.e., | |
24 | + * | |
25 | + * $temasa="bioma"; | |
26 | + * | |
27 | + * include("ms_criamapa.php"); | |
28 | + * | |
29 | + * Observações: | |
30 | + * | |
31 | + * Os cookies passados ao servidor são eliminados com a linha | |
32 | + * | |
33 | + * $_COOKIE = array(); | |
34 | + * | |
35 | + * Se a sua aplicação precisa de cookies, comente essa linha do programa. | |
36 | + * | |
37 | + * A interface HTML padrão de abertura do mapa é definido em uma variável no arquivo ms_configura.php, podendo ser alterada se necessário. | |
38 | + * | |
39 | + * Link: | |
40 | + * | |
41 | + * http://localhost/i3geo/ms_criamapa.php | |
42 | + * | |
43 | + * Licença: | |
44 | + * | |
45 | + * GPL2 | |
46 | + * | |
47 | + * i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
48 | + * | |
49 | + * Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
50 | + * Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | |
51 | + * | |
52 | + * Este programa é software livre; você pode redistribuí-lo | |
53 | + * e/ou modificá-lo sob os termos da Licença Pública Geral | |
54 | + * GNU conforme publicada pela Free Software Foundation; | |
55 | + * | |
56 | + * Este programa é distribuído na expectativa de que seja útil, | |
57 | + * porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
58 | + * de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
59 | + * Consulte a Licença Pública Geral do GNU para mais detalhes. | |
60 | + * Você deve ter recebido uma cópia da Licença Pública Geral do | |
61 | + * GNU junto com este programa; se não, escreva para a | |
62 | + * Free Software Foundation, Inc., no endereço | |
63 | + * 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
64 | + * | |
65 | + * Arquivo: i3geo/ms_criamapa.php | |
66 | + * | |
67 | + * Parâmetros: | |
68 | + * | |
69 | + * base - arquivo mapfile que servirá de base para a criação do mapa. Por default, são utilizados os arquivos existentes em i3geo/aplicmap (geral1windows, geral1,...) | |
70 | + * Essa variável pode ser definida em ms_configura também. Se não estiver definida em nenhum lugar, o i3Geo tentará descobrir o arquivo adequado a ser utilizado. Você pode utilizar essa opção para abrir um mapa com as camadas que você quiser, mas para evitar redundâncias, prefira o uso de &temasa | |
71 | + * | |
72 | + * temasa - lista, separada por espaços, com os nomes dos arquivos map ou gvsig que serão adicionados ao mapa. Se o arquivo não estiver no diretório i3geo/temas, o nome deve incluir o caminho completo no servidor. O arquivo pode conter mais de um layer pois todos os existentes serão adicionados ao mapa. Por default, todos os layers encontrados nos mapfiles são adicionados ao mapa com o status de desenho em OFF. | |
73 | + * | |
74 | + * layers - lista, separada por espaços, com os nomes dos layers que serão ligados. A lista deve conter os nomes dos layers e não os nomes dos mapfiles acrescentados ao mapa. Por exemplo, ao adicionar com "temasa" um mapfile chamado "transporte" que contenha os layers "estradas" e "ferrovias" os dois layers serão adicionados ao mapa. Para que esses dois layers fiquem visíveis no mapa deve-se utilizar &layers=estradas ferrovias. | |
75 | + * | |
76 | + * desligar - lista com os nomes dos temas que serão forçados a inicializar desligados, ou seja, com STATUS OFF | |
77 | + * | |
78 | + * mapext - extensao geografica que será utilizada. Por padrão, a extensão geográfica é definida para abranger o Brasil todo. Para alterar o padrão deve-se utilizar o parâmetro mapext para especificar a nova abrangência. Essa abrangência deve ser definida em coordenadas no formato décimos de grau e na projeção geográfica. Exemplo: &mapext=-54 -30 -50 -12. Observe que a ordem dos valores são xmin ymin xmax ymax | |
79 | + * | |
80 | + * interface - nome da interface que será utilizada para abrir o mapa. As interfaces são arquivos HTML que podem estar no diretório aplicmap. Por default, utiliza-se o geral.htm. Vc pode copiar esse html e alterá-lo para customizar o mapa. Para chamar o html customizado, utilize ms_criamapa.php?interface=meumapa.htm | |
81 | + * | |
82 | + * perfil - perfil utilizado para restringir os menus de temas. ms_criamapa.php?perfil=usuário1 | |
83 | + * | |
84 | + * caminho - caminho relativo que indica o local onde a interface do mapa esta localizada. | |
85 | + * | |
86 | + * pontos - lista de coordenadas x e y que serão adicionadas como pontos no mapa. | |
87 | + * | |
88 | + * nometemapontos - nome do tema de pontos | |
89 | + * | |
90 | + * linhas - lista de coordenadas x e y que serão adicionadas como linhas no mapa. As coordenadas de linhas diferentes devem ser separadas por ",", por exemplo: -54 -12 -50 -12,-50 -1 -50 -2 -50 -3 | |
91 | + * | |
92 | + * nometemalinhas - nome do tema de linhas | |
93 | + * | |
94 | + * poligonos - lista de coordenadas x e y que serão adicionadas como polígonos no mapa. As coordenadas dos vértices de polígonos diferentes devem ser separadas por ",". | |
95 | + * | |
96 | + * nometemapoligonos - nome do tema de polígonos | |
97 | + * | |
98 | + * simbolo - nome do símbolo que será utilizado para desenhar os elementos inseridos (veja arquivo de símbolos em i3geo/symbols) | |
99 | + * | |
100 | + * corsimbolo - cor do símbolo definido em RGB separados por espaço ou vírgula | |
101 | + * | |
102 | + * tamanhosimbolo - tamanho do símbolo em pixels | |
103 | + * | |
104 | + * wkt - insere elementos no mapa com coordenadas definidas em wkt | |
105 | + * | |
106 | + * nometemawkt - nome do tema em wkt | |
107 | + * | |
108 | + * idioma - idioma da interface (veja os idiomas disponíveis em classe_idioma.js) | |
109 | + * | |
110 | + * kmlurl - url de um arquivo KML que será incluido no mapa. Válido apenas na interface google maps | |
111 | + * | |
112 | + * url_wms - endereço de um WMS (será incluido como uma camada no mapa) | |
113 | + * | |
114 | + * layer_wms - nome do layer | |
115 | + * | |
116 | + * style_wms - estilo do layer | |
117 | + * | |
118 | + * nome_wms - nome da camada (titulo) | |
119 | + * | |
120 | + * srs_wms - código da projeção | |
121 | + * | |
122 | + * image_wms - tipo de imagem disponível | |
123 | + * | |
124 | + * versao_wms - Versão do WMS (necessário quando da inclusão de uma camada WMS diretamente pela URL) | |
125 | + * | |
126 | + * restauramapa - id do mapa armazenado no sistema de administracao e que será restaurado para ser aberto novamente | |
127 | + * | |
128 | + * filtros - filtros podem ser adicionados incluindo o parametro da seguinte forma: &map_layer_<nomedotema>_filter= | |
129 | + * | |
130 | + * Exemplo de filtro | |
131 | + * | |
132 | + * http://localhost/i3geo/ms_criamapa.php?temasa=_lbiomashp&map_layer__lbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA'))&temasa=_lbiomashp | |
133 | + * | |
134 | + * no caso de camadas Postgis basta usar map_layer__lbiomashp_filter=cd_legenda='CAATINGA' | |
135 | + * | |
136 | + * largura - largura em pixel do mapa | |
137 | + * | |
138 | + * altura - altura em pixels do mapa | |
139 | + * | |
140 | + * DESLIGACACHE - sim|nao forca o desligamento do cache em todos os layers | |
141 | + */ | |
142 | +if (isset($_GET["ajuda"])) { | |
143 | + echo "<pre>"; | |
144 | + echo " | |
146 | 145 | Parâmetros: |
147 | 146 | |
148 | 147 | base - arquivo mapfile que servirá de base para a criação do mapa. Por default, são utilizados os arquivos existentes em i3geo/aplicmap (geral1windows, geral1,...) |
... | ... | @@ -215,1239 +214,1280 @@ filtros - filtros podem ser adicionados incluindo o parametro da seguinte forma: |
215 | 214 | largura - largura em pixel do mapa |
216 | 215 | |
217 | 216 | altura - altura em pixels do mapa |
218 | - "; | |
219 | - exit; | |
220 | -} | |
221 | -//$_COOKIE = array(); | |
222 | - | |
223 | -// | |
224 | -//quando $funcao existe, é pq o ms_criamapa.php está | |
225 | -//sendo utilizado como um include em classesphp/mapa_controle.php | |
226 | -// | |
227 | - | |
228 | -if(!isset($funcao)){ | |
229 | - ob_end_clean(); | |
230 | - /* | |
231 | - Carrega as extensões PHP | |
232 | - | |
233 | - Carrega as extensões utilizadas no programa de inicialização. | |
234 | - A carga das extensões geralmente é necessária nas instalações windows (ms4w) ou quando as mesmas não são carregadas pela própria inicialização do PHP. | |
235 | - */ | |
236 | - include_once (dirname(__FILE__)."/classesphp/carrega_ext.php"); | |
237 | - /* | |
238 | - Include dos arquivos PHP. | |
239 | - | |
240 | - Inclui os programas php com funções utilizadas pelo ms_criamapa.php | |
241 | - */ | |
242 | - include_once (dirname(__FILE__)."/classesphp/sani_request.php"); | |
243 | - include_once (dirname(__FILE__)."/classesphp/funcoes_gerais.php"); | |
244 | - if(!isset($_GET["interface"])){ | |
245 | - $_GET["interface"] = ""; | |
246 | - } | |
247 | - $interface = $_GET["interface"]; | |
248 | -} | |
249 | -$parurl = array_merge($_GET,$_POST); | |
250 | -// | |
251 | -//$base pode vir do ms_configura ou da URL | |
252 | -//o ms_configura pode ter sido inserido antes | |
253 | -// | |
254 | -if(empty($base) && !empty($parurl["base"])){ | |
255 | - $base = $parurl["base"]; | |
256 | -} | |
257 | - | |
258 | -ms_ResetErrorList(); | |
259 | -$metaestatids = @$parurl["metaestatids"]; | |
260 | -$temasa = @$parurl["temasa"]; | |
261 | -$layers = @$parurl["layers"]; | |
262 | -$desligar = @$parurl["desligar"]; | |
263 | -$mapext = @$parurl["mapext"]; | |
264 | -$executa = "";//$parurl["executa"]; | |
265 | -$perfil = @$parurl["perfil"]; | |
266 | -$caminho = @$parurl["caminho"]; | |
267 | -$pontos = @$parurl["pontos"]; | |
268 | -$nometemapontos = @$parurl["nometemapontos"]; | |
269 | -$linhas = @$parurl["linhas"]; | |
270 | -$nometemalinhas = @$parurl["nometemalinhas"]; | |
271 | -$poligonos = @$parurl["poligonos"]; | |
272 | -$nometemapoligonos = @$parurl["nometemapoligonos"]; | |
273 | -$simbolo = @$parurl["simbolo"]; | |
274 | -$corsimbolo = @$parurl["corsimbolo"]; | |
275 | -$tamanhosimbolo = @$parurl["tamanhosimbolo"]; | |
276 | -$wkt = @$parurl["wkt"]; | |
277 | -$nometemawkt = @$parurl["nometemawkt"]; | |
278 | -$idioma = @$parurl["idioma"]; | |
279 | -$kmlurl = @$parurl["kmlurl"]; | |
280 | -$url_wms = @$parurl["url_wms"]; | |
281 | -$layer_wms = @$parurl["layer_wms"]; | |
282 | -$style_wms = @$parurl["style_wms"]; | |
283 | -$nome_wms = @$parurl["nome_wms"]; | |
284 | -$srs_wms = @$parurl["srs_wms"]; | |
285 | -$image_wms = @$parurl["image_wms"]; | |
286 | -$versao_wms = @$parurl["versao_wms"]; | |
287 | -$gvsigview = @$parurl["gvsigview"]; | |
288 | -$restauramapa = @$parurl["restauramapa"]; | |
289 | - | |
290 | -$versao = versao(); | |
291 | -$versao = $versao["principal"]; | |
292 | - | |
293 | -// | |
294 | -//a variável $base pode ser definida em ms_configura, mas a preferência é pela definição já existente | |
295 | -//por isso, $base é guardada em uma variável e retomada apos o include de ms_configura.php | |
296 | -//se restauramapa estiver definido, usa o mapfile guardado no banco de administracao como a base | |
297 | -// | |
298 | -if(!isset($dir_tmp)){ | |
299 | - include_once (dirname(__FILE__)."/ms_configura.php"); | |
300 | - if(!empty($parurl["base"])){ | |
301 | - $base = $parurl["base"]; | |
302 | - } | |
303 | - if(!empty($parurl["interface"])){ | |
304 | - $interface = $parurl["interface"]; | |
305 | - } | |
306 | -} | |
307 | -if(isset($logExec) && $logExec["init"] == true){ | |
308 | - i3GeoLog("prog: ms_criamapa url: ".implode("&",array_merge($_GET,$_POST)),$dir_tmp); | |
309 | -} | |
310 | -if(!empty($restauramapa)){ | |
311 | - $base = restauraMapaAdmin($restauramapa,$dir_tmp); | |
312 | - $m = ms_newMapObj($base); | |
313 | - $w = $m->web; | |
314 | - $w->set("imagepath",dirname($w->imagepath)."/"); | |
315 | - $w->set("imageurl",dirname($w->imageurl)."/"); | |
316 | - $m->save($base); | |
317 | -}else{ | |
318 | - if(isset($base)){ | |
319 | - $tempBaseX = $base; | |
320 | - } | |
321 | - if(isset($tempBaseX) && $tempBaseX != ""){ | |
322 | - $base = $tempBaseX; | |
323 | - } | |
324 | -} | |
325 | -//verifica se o usuario trocou a senha do master | |
326 | -if($_SERVER['SERVER_NAME'] != "localhost" && ($i3geomaster[0]["usuario"] == "admin" && $i3geomaster[0]["senha"] == "admin") ){ | |
327 | - echo json_encode(array("bloqueado"=>"Bloqueado. ATENCAO!!! Acesso bloqueado: edite o arquivo i3geo/ms_configura.php e altere o login e senha da variavel i3geomaster")); | |
328 | - exit; | |
329 | -} | |
330 | -/* | |
331 | -Define o cookie para o idioma da interface | |
332 | -*/ | |
333 | -if(isset($idioma) && $idioma != ""){ | |
334 | - setcookie("i3geolingua", $idioma); | |
335 | -} | |
336 | -/* | |
337 | -Cria os diretorios temporários que serão utilizados pelo i3geo para armazenar as imagens e outros dados. | |
338 | -*/ | |
339 | -$diretorios = criaDirMapa($dir_tmp,$cachedir); | |
340 | -if(!$diretorios){ | |
341 | - echo "<p style=color:red ><b>Não foi possível criar os diretórios temporários em $dir_tmp.</b></p>"; | |
342 | - exit; | |
343 | -} | |
344 | -criaIndex($dir_tmp,$diretorios); | |
345 | -$tmpfname = $diretorios[0]; | |
346 | -$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | |
347 | -/* | |
348 | -Prepara as variáveis que serão incluidas na seção | |
349 | - | |
350 | -As variáveis vêm do arquivo ms_configura.php e são armazenadas em uma seção com nome específico para o i3geo. | |
351 | -*/ | |
352 | -if (!isset($mapext) || empty($mapext)){ | |
353 | - $mapext=""; | |
354 | -} | |
355 | -else{ | |
356 | - $mapext = str_replace(","," ",$mapext); | |
357 | - setcookie("i3geoUltimaExtensao", $mapext); | |
358 | -} | |
359 | -$saikuUrl_ = $saikuUrl; | |
360 | -$cachedir_ = $cachedir; | |
361 | -$dir_tmp_ = $dir_tmp; | |
362 | -$emailInstituicao_ = $emailInstituicao; | |
363 | -$locmapserv_ = $locmapserv; | |
364 | -$locaplic_ = $locaplic; | |
365 | -//$locsistemas_ = $locsistemas; | |
366 | -//$locidentifica_ = $locidentifica; | |
367 | -$R_path_ = $R_path; | |
368 | -$mapext_ = $mapext; | |
369 | - | |
370 | -$debug_ = @$debug; | |
371 | -$ler_extensoes_ = $ler_extensoes; | |
372 | -$postgis_mapa_ = $postgis_mapa; | |
373 | -$tituloInstituicao_ = $tituloInstituicao; | |
374 | -//$atlasxml_ = $atlasxml; | |
375 | -$expoeMapfile_ = $expoeMapfile; | |
376 | -$googleApiKey_ = $googleApiKey; | |
377 | -$mensagemInicia_ = $mensagemInicia; | |
378 | -$interfacePadrao_ = $interfacePadrao; | |
379 | -if(empty($interface)){ | |
380 | - $interface_ = $interfacePadrao; | |
381 | -} | |
382 | -if(isset($kmlurl)){ | |
383 | - $kmlurl_ = $kmlurl; | |
384 | -} | |
385 | -// | |
386 | -//se houver string de conexão para substituição | |
387 | -//o modo cgi não irá funcionar | |
388 | -// | |
389 | -if($postgis_mapa != ""){ | |
390 | - $utilizacgi = "nao"; | |
391 | -} | |
392 | -if(!isset($perfil)){ | |
393 | - $perfil=""; | |
394 | -} | |
395 | -$perfil_ = $perfil; | |
396 | -$utilizacgi_ = $utilizacgi; | |
397 | -if ((isset($navegadoresLocais)) && ($navegadoresLocais != "")){ | |
398 | - $navegadoresLocais_ = "sim"; | |
399 | -} | |
400 | -else{ | |
401 | - $navegadoresLocais_ = "nao"; | |
402 | -} | |
403 | -if(empty($i3georendermode)){ | |
404 | - $i3georendermode_ = 0; | |
405 | -} | |
406 | -else{ | |
407 | - $i3georendermode_ = $i3georendermode; | |
408 | -} | |
409 | -if(empty($statusFerramentas)){ | |
410 | - $statusFerramentas_ = array(); | |
411 | -} | |
412 | -else{ | |
413 | - $statusFerramentas_ = $statusFerramentas; | |
414 | -} | |
415 | -if(empty($logExec)){ | |
416 | - $logExec_ = ""; | |
417 | -} | |
418 | -else{ | |
419 | - $logExec_ = $logExec; | |
420 | -} | |
421 | -if(!isset($i3geoPermiteLogin)){ | |
422 | - $i3geoPermiteLogin_ = ""; | |
423 | -} | |
424 | -else{ | |
425 | - $i3geoPermiteLogin_ = $i3geoPermiteLogin; | |
426 | -} | |
427 | -/* | |
428 | -Inicia a seção | |
429 | - | |
430 | -O i3geo inicia uma seção específica no servidor, denominada i3GeoPHP. | |
431 | -Se já houver uma seção aberta, em função de outro browser estar ativo, cria uma nova. Faz a cópia das variáveis definidas para itens da seção. | |
432 | -*/ | |
433 | -session_name("i3GeoPHP"); | |
434 | -session_start(); | |
435 | -//echo $_SESSION["map_file"];exit; | |
436 | -if (!isset($g_sid)){$g_sid="";} | |
437 | -if(isset($_SESSION["map_file"]) || $g_sid != "" || $g_sid == "undefined"){ | |
438 | - session_regenerate_id(); | |
439 | - $_SESSION = array(); | |
440 | -} | |
441 | -/* | |
442 | -Aguarde | |
443 | - | |
444 | -Monta a apresentação do aguarde. | |
445 | - | |
446 | -Aqui é necessário verificar se $executa está definido | |
447 | -isso pq algumas aplicações podem ser prejudicadas caso o aguarde seja mostrado | |
448 | -*/ | |
449 | -$_SESSION["dir_tmp"] = $dir_tmp_; | |
450 | -$_SESSION["cachedir"] = $cachedir_; | |
451 | -$_SESSION["emailInstituicao"] = $emailInstituicao_; | |
452 | -$_SESSION["locmapserv"] = $locmapserv_; | |
453 | -$_SESSION["locaplic"] = $locaplic_; | |
454 | -$_SESSION["R_path"] = $R_path_; | |
455 | -$_SESSION["mapext"] = $mapext_; | |
456 | -$_SESSION["debug"] = $debug_; | |
457 | -$_SESSION["ler_extensoes"] = $ler_extensoes_; | |
458 | -$_SESSION["postgis_mapa"] = $postgis_mapa_; | |
459 | -$_SESSION["perfil"] = $perfil_; | |
460 | -$_SESSION["navegadoresLocais"] = $navegadoresLocais_; | |
461 | -$_SESSION["utilizacgi"] = $utilizacgi_; | |
462 | -$_SESSION["tituloInstituicao"] = $tituloInstituicao_; | |
463 | -$_SESSION["expoeMapfile"] = $expoeMapfile; | |
464 | -$_SESSION["googleApiKey"] = $googleApiKey_; | |
465 | -$_SESSION["mensagemInicia"] = $mensagemInicia_; | |
466 | -$_SESSION["interfacePadrao"] = $interfacePadrao_; | |
467 | -$_SESSION["logExec"] = $logExec_; | |
468 | -$_SESSION["i3geoPermiteLogin"] = $i3geoPermiteLogin_; | |
469 | -if(!isset($customDir)){ | |
470 | - $customDir = ""; | |
471 | -} | |
472 | -$_SESSION["customDir"] = $customDir; | |
473 | -if(isset($interface_)){ | |
474 | - $_SESSION["interface"] = $interface_; | |
475 | -} | |
476 | -if(isset($kmlurl_)){ | |
477 | - $_SESSION["kmlurl"] = $kmlurl_; | |
478 | -} | |
479 | -//rotina de segurança, ver http://shiflett.org/articles/the-truth-about-sessions | |
480 | -$fingerprint = 'I3GEOSEC' . $_SERVER['HTTP_USER_AGENT']; | |
481 | -$_SESSION['fingerprint'] = md5($fingerprint . session_id()); | |
482 | -$_SESSION["mapdir"] = $diretorios[1]; | |
483 | -$_SESSION["imgdir"] = $diretorios[2]; | |
484 | -$_SESSION["contadorsalva"] = 0;//essa variavel e utilizada pela ferramenta telaremota. Toda vez que o mapa e salvo, acrescenta 1 (veja classesphp/mapa_controle.php) | |
485 | -$_SESSION["i3georendermode"] = $i3georendermode_; | |
486 | -$_SESSION["saikuUrl"] = $saikuUrl_; | |
487 | -$_SESSION["logExec"] = $logExec_; | |
488 | -$_SESSION["i3geoPermiteLogin"] = $i3geoPermiteLogin_; | |
489 | - | |
490 | -//sao arrays | |
491 | -$postgis_mapa = $postgis_mapa_; | |
492 | -$_SESSION["statusFerramentas"] = $statusFerramentas_; | |
493 | -/* | |
494 | -Define os arquivos .map | |
495 | - | |
496 | -Seleciona os arquivos mapfile que serão carregados como base conforme o tipo de sistema operacional. | |
497 | - | |
498 | -A variável $base pode ser definida como um parâmetro na inicialização, caso contrário será utilizado o valor definido em ms_configura.php ou o i3Geo tentará descobrir o melhor arquivo a ser usado, conforme o que existir em i3geo/aplicmap. | |
499 | - | |
500 | -Os arquivos .map padrão são armazenados em i3geo/aplicmap. | |
501 | -O arquivo é lido conforma a característica do sistema operacional. | |
502 | - | |
503 | -*/ | |
504 | -$versao = versao(); | |
505 | -$versao = $versao["principal"]; | |
506 | -if(!isset($base) || $base == ""){ | |
507 | - if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){ | |
508 | - $base = $locaplic."/aplicmap/geral1windowsv".$versao.".map"; | |
509 | - } | |
510 | - else{ | |
511 | - if($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv'.$versao.'.map')){ | |
512 | - $base = "/var/www/i3geo/aplicmap/geral1debianv".$versao.".map"; | |
513 | - } | |
514 | - if($base == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){ | |
515 | - $base = "/var/www/html/i3geo/aplicmap/geral1fedorav".$versao.".map"; | |
516 | - } | |
517 | - if($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){ | |
518 | - $base = "/opt/www/html/i3geo/aplicmap/geral1v".$versao.".map"; | |
519 | - } | |
520 | - if($base == ""){ | |
521 | - $base = $locaplic."/aplicmap/geral1v".$versao.".map"; | |
522 | - } | |
523 | - } | |
524 | -} | |
525 | -//error_log($base); | |
526 | -//if(!isset($estadosl)) | |
527 | -//{$estadosl = "estadosl";} | |
528 | -/* | |
529 | -Cria os objetos map que serão processados | |
530 | - | |
531 | -O arquivo definido em $base é lido como um objeto map. Esse objeto será processado para incluir novos layers e alterar outros parâmetros definidos pelo usuário. | |
532 | -*/ | |
533 | -if (file_exists($base)){ | |
534 | - $map = ms_newMapObj($base); | |
535 | - $mapn = ms_newMapObj($base); | |
536 | -} | |
537 | -else{ | |
538 | - $map = ms_newMapObj($locaplic."/aplicmap/".$base.".map"); | |
539 | - $mapn = ms_newMapObj($locaplic."/aplicmap/".$base.".map"); | |
540 | -} | |
541 | - | |
542 | -/* | |
543 | -Parâmetros adicionais. | |
544 | - | |
545 | -Processa os parâmetros para a inicialização verificando se foram passados pela URL ou não. | |
546 | -*/ | |
547 | -if (!isset($mapext)){ | |
548 | - $mapext = $map->extent->minx." ".$map->extent->miny." ".$map->extent->maxx." ".$map->extent->maxy; | |
549 | -} | |
550 | -//arquivo com a imagem de referência | |
551 | -if (!isset ($map_reference_image)){ | |
552 | - $map_reference_image = $map->reference->image; | |
553 | -} | |
554 | -//extensão geográfica da imagem do mapa de referência | |
555 | -if (!isset ($map_reference_extent)){ | |
556 | - $map_reference_extent = $map->reference->extent->minx." ".$map->reference->extent->miny." ".$map->reference->extent->maxx." ".$map->reference->extent->maxy; | |
557 | -} | |
558 | -if(empty($interface)){ | |
559 | - if(!isset($interfacePadrao)){ | |
560 | - $interfacePadrao = "ol.htm"; | |
561 | - } | |
562 | - $interface = $interfacePadrao; | |
563 | -} | |
564 | - | |
565 | -if(isset($layers) && !isset($temasa)){ | |
566 | - $temasa = $layers; | |
567 | -} | |
568 | - | |
569 | -incluiTemasIniciais(); | |
570 | - | |
571 | -if(isset($layers)){ | |
572 | - ligaTemas(); | |
573 | -} | |
574 | -if(isset($desligar)){ | |
575 | - desligaTemasIniciais(); | |
576 | -} | |
577 | -if (isset($map_reference_image)){ | |
578 | - $mapn->reference->set("image",$map_reference_image); | |
579 | -} | |
580 | -$extr = $mapn->reference->extent; | |
581 | -if (isset($map_reference_extent)){ | |
582 | - $temp = explode(" ",$map_reference_extent); | |
583 | - foreach ($temp as $t) { | |
584 | - if ($t != ""){ | |
585 | - $newext[] = $t; | |
586 | - } | |
587 | - } | |
588 | - if (count($newext) == 4){ | |
589 | - $extr->setextent($newext[0], $newext[1], $newext[2], $newext[3]); | |
590 | - } | |
591 | -} | |
592 | -$ext = $mapn->extent; | |
593 | -$newext = array(); | |
594 | -if ((isset($mapext)) && ($mapext != "")){ | |
595 | - $temp = explode(" ",$mapext); | |
596 | - foreach ($temp as $t) { | |
597 | - if ($t != ""){ | |
598 | - $newext[] = $t; | |
599 | - } | |
600 | - } | |
601 | - if (count($newext) == 4){ | |
602 | - $ext->setextent($newext[0], $newext[1], $newext[2], $newext[3]); | |
603 | - } | |
604 | -} | |
605 | -else{ | |
606 | - //algumas aplicacoes usam essa variavel (SAIKU) | |
607 | - $mapext = $ext->minx." ".$ext->miny." ".$ext->maxx." ".$ext->maxy; | |
608 | -} | |
609 | - | |
610 | -/* | |
611 | -Configura os endereços corretos no mapfile. | |
612 | - | |
613 | -Altera as propriedades imagepath e imageurl corrigindo os caminhos padrão conforme o diretório criado para armazenar o mapa de trabalho. | |
614 | -*/ | |
615 | - | |
616 | -$w = $mapn->web; | |
617 | -$atual = $w->imagepath; | |
618 | -$w->set("imagepath",$atual.$diretorios[2]."/"); | |
619 | -$atual = $w->imageurl; | |
620 | -$w->set("imageurl",$atual.$diretorios[2]."/"); | |
621 | - | |
622 | -$projecao = pegaProjecaoDefault("proj4"); | |
623 | -if($projecao != ""){ | |
624 | - $mapn->setProjection($projecao); | |
625 | -} | |
626 | -//aplica o tamanho do mapa | |
627 | -if(isset($parurl["largura"]) && isset($parurl["altura"])){ | |
628 | - $mapn->setsize($parurl["largura"],$parurl["altura"]); | |
629 | -} | |
630 | - | |
631 | -$tmpfname = str_replace(".map","",$tmpfname).".map"; | |
632 | -$salvo = $mapn->save($tmpfname); | |
633 | - | |
634 | -$_SESSION["imgurl"] = strtolower($protocolo[0])."://".$_SERVER['HTTP_HOST'].$atual.$diretorios[2]."/"; | |
635 | -$_SESSION["tmpurl"] = strtolower($protocolo[0])."://".$_SERVER['HTTP_HOST'].$atual; | |
636 | -$_SESSION["map_file"] = $tmpfname; | |
637 | -$_SESSION["mapext"] = $mapext; | |
638 | -if (isset($executa)){ | |
639 | - if (file_exists($executa)){ | |
640 | - //include_once ($executa); | |
641 | - } | |
642 | - if (function_exists($executa)){ | |
643 | - //eval($executa."();"); | |
644 | - } | |
645 | -} | |
646 | -if(isset($wkt)){ | |
647 | - insereWKTUrl(); | |
648 | -} | |
649 | - | |
650 | -if(isset($pontos)){ | |
651 | - inserePontosUrl(); | |
652 | -} | |
653 | - | |
654 | -if(isset($linhas)){ | |
655 | - insereLinhasUrl(); | |
656 | -} | |
657 | - | |
658 | -if(isset($poligonos)){ | |
659 | - inserePoligonosUrl(); | |
660 | -} | |
661 | - | |
662 | -if(isset($url_wms)){ | |
663 | - incluiTemaWms(); | |
664 | -} | |
665 | - | |
666 | -adaptaLayers($tmpfname,$versao); | |
667 | - | |
668 | -//if (file_exists($locaplic."/pacotes/geoip") && file_exists($locaplic."/pacotes/geoip/GeoLiteCity.dat")){ | |
669 | -// require_once(dirname(__FILE__)."/ms_registraip.php"); | |
670 | -//} | |
671 | -if ($interface != "mashup"){ | |
672 | - abreInterface($interface,$caminho); | |
673 | -} | |
674 | - | |
675 | -/* | |
676 | -Adapta os dados de cada layer. | |
677 | - | |
678 | -Faz alterações em cada layer caso sejam necessárias. | |
679 | -*/ | |
680 | -function adaptaLayers($tmpfname,$versao){ | |
681 | - global $parurl; | |
682 | - $mapa = ms_newMapObj($tmpfname); | |
683 | - $path = $mapa->shapepath; | |
684 | - $numlayers = $mapa->numlayers; | |
685 | - for($i=0;$i<$numlayers;++$i){ | |
686 | - $layer = $mapa->getLayer($i); | |
687 | - $ok = true; | |
688 | - if ($layer->connection == ""){ | |
689 | - $ok = false; | |
690 | - $d = $layer->data; | |
691 | - if((file_exists($d)) || (file_exists($d.".shp"))){ | |
692 | - $ok = true; | |
693 | - } | |
694 | - else{ | |
695 | - if((file_exists($path."/".$d)) || (file_exists($path."/".$d.".shp"))){ | |
696 | - $ok = true; | |
697 | - } | |
698 | - } | |
699 | - } | |
700 | - if ($ok == false){ | |
701 | - $layer->set("status",MS_OFF); | |
702 | - } | |
703 | - //para impedir erros na legenda | |
704 | - if($layer->getmetadata("classe") == ""){ | |
705 | - $layer->setmetadata("classe",""); | |
706 | - } | |
707 | - if($versao > 5){ | |
708 | - $pr = $layer->getProcessing(); | |
709 | - if(!in_array("LABEL_NO_CLIP=True",$pr)){ | |
710 | - $layer->setprocessing("LABEL_NO_CLIP=True"); | |
711 | - } | |
712 | - if(!in_array("POLYLINE_NO_CLIP=True",$pr)){ | |
713 | - $layer->setprocessing("POLYLINE_NO_CLIP=True"); | |
714 | - } | |
715 | - | |
716 | - } | |
717 | - // | |
718 | - //verifica se deve aplicar filtro | |
719 | - // | |
720 | - $filtro = @$parurl["map_layer_".$layer->name."_filter"]; | |
721 | - if(!empty($filtro)){ | |
722 | - $layer->setmetadata("CACHE","nao"); | |
723 | - $layer->setfilter($filtro); | |
724 | - } | |
725 | - corrigeLayerPath($layer,$mapa); | |
726 | - } | |
727 | - $mapa->save($tmpfname); | |
728 | - erroCriacao(); | |
729 | -} | |
730 | -/* | |
731 | -Redireciona para o HTML definido em $interface, abrindo o mapa | |
732 | -*/ | |
733 | -function abreInterface($interface,$caminho){ | |
734 | - $nomeInterface = explode(".",basename($interface)); | |
735 | - if (count(explode(".php",$interface)) > 1){ | |
736 | - if(file_exists($caminho."interface/".$interface)){ | |
737 | - include_once($caminho."interface/".$interface); | |
738 | - } | |
739 | - exit; | |
740 | - } | |
741 | - else{ | |
742 | - if(file_exists($caminho."interface/".$interface)){ | |
743 | - $urln = $caminho."interface/".$interface."?&".session_id(); | |
744 | - } | |
745 | - else{ | |
746 | - $urln = $interface."?&".session_id(); | |
747 | - } | |
748 | - if(!headers_sent()){ | |
749 | - header("Location:".$urln); | |
750 | - } | |
751 | - else{ | |
752 | - echo "<meta http-equiv='refresh' content='0;url=$urln'>"; | |
753 | - } | |
754 | - } | |
755 | -} | |
756 | -/* | |
757 | -Desliga os temas definidos na variável $desligar | |
758 | -*/ | |
759 | -function desligaTemasIniciais() | |
760 | -{ | |
761 | - global $desligar,$mapn; | |
762 | - $layers = str_replace(','," ",$desligar); | |
763 | - $lista = explode(" ", $layers); | |
764 | - foreach ($lista as $l) | |
765 | - { | |
766 | - if ($l == "") | |
767 | - {continue;} | |
768 | - if(@$mapn->getLayerByName($l)) | |
769 | - {$layern = $mapn->getLayerByName($l);$layern->set("status",MS_OFF);} | |
770 | - $grupos = $mapn->getLayersIndexByGroup($l); | |
771 | - if(count($grupos) > 0) | |
772 | - { | |
773 | - for ($i = 0;$i < count($grupos);++$i) | |
774 | - { | |
775 | - $layern = $mapn->getLayer($grupos[$i]); | |
776 | - if(strtolower($layern->group) == strtolower($l)) | |
777 | - { | |
778 | - $layern->set("status",MS_OFF); | |
779 | - } | |
780 | - } | |
781 | - } | |
782 | - } | |
783 | - erroCriacao(); | |
784 | -} | |
785 | -/* | |
786 | -Liga os temas definidos na variável $layers | |
787 | -*/ | |
788 | -function ligaTemas() | |
789 | -{ | |
790 | - global $layers,$mapn; | |
791 | - if (isset($layers)) | |
792 | - { | |
793 | - $layers = str_replace(','," ",$layers); | |
794 | - $lista = explode(" ", $layers); | |
795 | - foreach ($lista as $l) | |
796 | - { | |
797 | - if ($l == "") | |
798 | - {continue;} | |
799 | - if(@$mapn->getLayerByName($l)) | |
800 | - {$layern = $mapn->getLayerByName($l);$layern->set("status",MS_DEFAULT);} | |
801 | - $grupos = $mapn->getLayersIndexByGroup($l); | |
802 | - if(count($grupos) > 0) | |
803 | - { | |
804 | - for ($i = 0;$i < count($grupos);++$i) | |
805 | - { | |
806 | - $layern = $mapn->getLayer($grupos[$i]); | |
807 | - if(strtolower($layern->group) == strtolower($l)) | |
808 | - { | |
809 | - $layern->set("status",MS_DEFAULT); | |
810 | - } | |
811 | - } | |
812 | - } | |
813 | - } | |
814 | - } | |
815 | - erroCriacao(); | |
816 | -} | |
817 | -/* | |
818 | -Inclui os temas definidos na variável $temasa | |
819 | - | |
820 | -Os temas devem estar em i3geo/temas | |
821 | -*/ | |
822 | -function incluiTemasIniciais(){ | |
823 | - global $temasa,$mapn,$locaplic,$metaestatids,$layers; | |
824 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'){ | |
825 | - $temasdir = $locaplic."\\temas"; | |
826 | - } | |
827 | - else { | |
828 | - $temasdir = $locaplic."/temas"; | |
829 | - } | |
830 | - if (!isset($temasa)){ | |
831 | - $temasa = ""; | |
832 | - } | |
833 | - $temasa = str_replace(','," ",$temasa); | |
834 | - $alayers = explode(" ",$temasa); | |
835 | - if(isset($metaestatids)){ | |
836 | - //localhost/i3geo/ms_criamapa.php?metaestatids=25,12&layers=25 | |
837 | - include_once (dirname(__FILE__) . "/classesphp/classe_metaestatinfo.php"); | |
838 | - $metaestatids = str_replace(','," ",$metaestatids); | |
839 | - $metaestatids = explode(" ",$metaestatids); | |
840 | - $metaestatidsligados = $layers; | |
841 | - $metaestatidsligados = str_replace(','," ",$metaestatidsligados); | |
842 | - $metaestatidsligados = explode(" ",$metaestatidsligados); | |
843 | - foreach($metaestatids as $metaestatid){ | |
844 | - //$_pg["filtro"] = str_replace('"', "'", $_pg["filtro"]); | |
845 | - $m = new MetaestatInfo(); | |
846 | - | |
847 | - $parametros = $m->listaParametro($metaestatid,"","",true,true); | |
848 | - //id_parametro_medida,coluna | |
849 | - $filtroPar = array(); | |
850 | - foreach($parametros as $parametro){ | |
851 | - $valoresparametro = $m->valorUnicoMedidaVariavel($metaestatid,$parametro["coluna"]); | |
852 | - $valormaior = $valoresparametro[count($valoresparametro) - 1]; | |
853 | - $filtroPar[] = " ".$parametro["coluna"] . "::text = '" . $valormaior[$parametro["coluna"]] . "' "; | |
854 | - } | |
855 | - //var_dump($filtroPar);exit; | |
856 | - $mapfilemetaestat = $m->mapfileMedidaVariavel( | |
857 | - $metaestatid, | |
858 | - implode(" AND ",$filtroPar), | |
859 | - 0, | |
860 | - "polygon", | |
861 | - "", | |
862 | - "", | |
863 | - "", | |
864 | - "", | |
865 | - "", | |
866 | - false, | |
867 | - false | |
868 | - ); | |
869 | - //array(3) { ["mapfile"]=> string(52) "/tmp/ms_tmp/AAAAc20ad4d76fe97759aa27a0c99bff6710.map" ["layer"]=> string(36) "AAAAc20ad4d76fe97759aa27a0c99bff6710" ["titulolayer"]=> string(0) "" } | |
870 | - //var_dump ($mapfilemetaestat); | |
871 | - //exit; | |
872 | - array_push($alayers,$mapfilemetaestat["mapfile"]); | |
873 | - | |
874 | - if(in_array($metaestatid,$metaestatidsligados)){ | |
875 | - $maptemp = @ms_newMapObj($mapfilemetaestat["mapfile"]); | |
876 | - $maptemp->getlayerbyname($mapfilemetaestat["layer"])->set("status",MS_DEFAULT); | |
877 | - $maptemp->save($mapfilemetaestat["mapfile"]); | |
878 | - } | |
879 | - } | |
880 | - } | |
881 | - | |
882 | - $existeraster = false; | |
883 | - foreach ($alayers as $arqt) { | |
884 | - $arqtemp = ""; | |
885 | - $arqt = trim($arqt); | |
886 | - if ($arqt == "") | |
887 | - {continue;} | |
888 | - $extensao = ".map"; | |
889 | - if(file_exists($arqt)){ | |
890 | - $arqtemp = $arqt; | |
891 | - } | |
892 | - if ((strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) && (file_exists($locaplic."\\aplicmap\\".$arqt.$extensao))){ | |
893 | - $arqtemp = $locaplic."\\aplicmap\\".$arqt.$extensao; | |
894 | - } | |
895 | - elseif (file_exists($locaplic."/aplicmap/".$arqt.$extensao)){ | |
896 | - $arqtemp = $locaplic."/aplicmap/".$arqt.$extensao; | |
897 | - } | |
898 | - if ((strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) && (file_exists($temasdir."\\".$arqt.$extensao))){ | |
899 | - $arqtemp = $temasdir."\\".$arqt.$extensao; | |
900 | - } | |
901 | - elseif (file_exists($temasdir."/".$arqt.$extensao)){ | |
902 | - $arqtemp = $temasdir."/".$arqt.$extensao; | |
903 | - } | |
904 | - if($arqtemp == ""){ | |
905 | - //echo "<br>Impossível acessar tema $arqtemp"; | |
906 | - } | |
907 | - else{ | |
908 | - if ($extensao == ".map" && !@ms_newMapObj($arqtemp)){ | |
909 | - echo "<br>Problemas com a camada $arqtemp<br>"; | |
910 | - } | |
911 | - else{ | |
912 | - $maptemp = @ms_newMapObj($arqtemp); | |
913 | - for($i=0;$i<($maptemp->numlayers);++$i){ | |
914 | - //error_reporting(0); | |
915 | - $layern = $maptemp->getLayer($i); | |
916 | - if($layern->type == MS_LAYER_RASTER) | |
917 | - {$existeraster = true;} | |
918 | - if ($layern->name == "estadosl"){ | |
919 | - $layern->set("data",$locaplic."/aplicmap/dados/estados.shp"); | |
920 | - } | |
921 | - $layern->setmetadata("nomeoriginal",$layern->name); | |
922 | - $nNome = str_replace(".map","",basename($arqtemp)); | |
923 | - $layern->setmetadata("arquivotemaoriginal",$nNome); | |
924 | - autoClasses($layern,$mapn); | |
925 | - // | |
926 | - //necessário para não alterar a extensão do mapa por esse parâmetro | |
927 | - // | |
928 | - $layern->setmetadata("aplicaextensao",""); | |
929 | - //cria e aplica sld se for wms e existirem classes | |
930 | - if($layern->classitem != "" && $layern->connectiontype == 7 && $layern->numclasses > 0 && $layern->getmetadata("wms_sld_body") == ""){ | |
931 | - $tipotemp = $layern->type; | |
932 | - $statustemp = $layern->status; | |
933 | - $tiporep = $layern->getmetadata("tipooriginal"); | |
934 | - $layern->set("type",MS_LAYER_POLYGON); | |
935 | - if ($tiporep == "linear") | |
936 | - {$layern->set("type",MS_LAYER_LINE);} | |
937 | - if ($tiporep == "pontual") | |
938 | - {$layern->set("type",MS_LAYER_POINT);} | |
939 | - $layern->set("status",MS_DEFAULT); | |
940 | - $sld = $layern->generateSLD(); | |
941 | - if($sld != "") | |
942 | - $layern->setmetadata("wms_sld_body",str_replace('"',"'",$sld)); | |
943 | - $layern->set("type",$tipotemp); | |
944 | - $layern->set("status",$statustemp); | |
945 | - } | |
946 | - cloneInlineSymbol($layern,$maptemp,$mapn); | |
947 | - $layerAdicionado = ms_newLayerObj($mapn, $layern); | |
948 | - //echo $layern->name; | |
949 | - corrigeLayerGrid($layern,$layerAdicionado); | |
950 | - } | |
951 | - } | |
952 | - } | |
953 | - } | |
954 | - erroCriacao(); | |
955 | -} | |
956 | -/* | |
957 | -Cria os arquivos vazios index.htm e index.html nos diretorios temporários | |
958 | -*/ | |
959 | -function criaIndex($dir_tmp,$diretorios) | |
960 | -{ | |
961 | - if (!file_exists($dir_tmp."/index.htm")) | |
962 | - { | |
963 | - $f = fopen($dir_tmp."/index.htm","x"); | |
964 | - fclose($f); | |
965 | - $f = fopen($dir_tmp."/index.html","x"); | |
966 | - fclose($f); | |
967 | - $f = fopen($dir_tmp."/".$diretorios[1]."/index.html","x"); | |
968 | - fclose($f); | |
969 | - $f = fopen($dir_tmp."/".$diretorios[1]."/index.htm","x"); | |
970 | - fclose($f); | |
971 | - $f = fopen($dir_tmp."/".$diretorios[2]."/index.html","x"); | |
972 | - fclose($f); | |
973 | - $f = fopen($dir_tmp."/".$diretorios[2]."/index.htm","x"); | |
974 | - fclose($f); | |
975 | - } | |
976 | - if (!file_exists($dir_tmp."/index.htm")) | |
977 | - { | |
978 | - echo "Erro. Não foi possível gravar no diretório temporário"; | |
979 | - exit; | |
980 | - } | |
981 | -} | |
982 | -/* | |
983 | -Mostra a mensagem de aguarde | |
984 | -*/ | |
985 | -function mostraAguarde() | |
986 | -{ | |
987 | - global $interface,$mensagemInicia,$tituloInstituicao; | |
988 | - if (!isset($interface)) | |
989 | - { | |
990 | - echo "<html><head>"; | |
991 | - echo '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"></head>'; | |
992 | - echo "<title>".$tituloInstituicao."</title>"; | |
993 | - echo '<div id="aguarde"><center>'; | |
994 | - echo '<p class=paguarde style="font-family: Verdana, Arial, Helvetica, sans-serif;color:black;text-align:center;font-size:12pt"><b>'.$mensagemInicia.'</b><br> Aguarde...preparando o mapa</p>'; | |
995 | - echo '<table><tr>'; | |
996 | - echo "<td colspan=3 ><center><img src='".dirname(__FILE__)."/imagens/i3geo1.jpg'></td></tr>"; | |
997 | - echo "<tr><td><center><img src='".dirname(__FILE__)."/imagens/pspb.png'></td>"; | |
998 | - echo "<td><center><img src='".dirname(__FILE__)."/imagens/mapserv.png'></td>"; | |
999 | - echo "<td><center><img src='".dirname(__FILE__)."/imagens/yui-logo.png'></td>"; | |
1000 | - echo "<td><center><a href='http://mapas.mma.gov.br/download' target=blank ><img src='".dirname(__FILE__)."/imagens/somerights20_pt.gif' ></a></td>"; | |
1001 | - echo "</tr></table>"; | |
1002 | - echo '<BODY bgcolor="white" style="background-color:white">'; | |
1003 | - } | |
1004 | -} | |
1005 | -/* | |
1006 | -Insere elementos no mapa a partir de uma string definida em wkt | |
1007 | -*/ | |
1008 | -function insereWKTUrl() | |
1009 | -{ | |
1010 | - global $tamanhosimbolo,$simbolo,$corsimbolo,$wkt,$nometemawkt,$dir_tmp,$imgdir,$tmpfname,$locaplic; | |
1011 | - include_once "pacotes/phpxbase/api_conversion.php"; | |
1012 | - if (!isset($nometemapontos)) | |
1013 | - {$nometemapontos="WKT";} | |
1014 | - if ($nometemapontos == "") | |
1015 | - {$nometemapontos="WKT";} | |
1016 | - // | |
1017 | - //cria o shape file | |
1018 | - // | |
1019 | - $shape = ms_shapeObjFromWkt($wkt); | |
1020 | - $tipol = $shape->type; | |
1021 | - if($tipol == 0){$tipol = 3;} | |
1022 | - $nomeshp = $dir_tmp."/".$imgdir."/wkts"; | |
1023 | - // cria o dbf | |
1024 | - $def = array(); | |
1025 | - $items = array("COORD"); | |
1026 | - foreach ($items as $ni) | |
1027 | - {$def[] = array($ni,"C","254");} | |
1028 | - if(!function_exists(dbase_create)) | |
1029 | - {xbase_create($nomeshp.".dbf", $def);} | |
1030 | - else | |
1031 | - {dbase_create($nomeshp.".dbf", $def);} | |
1032 | - $dbname = $nomeshp.".dbf"; | |
1033 | - $db=xbase_open($dbname,2); | |
1034 | - if ($tipol == 1) | |
1035 | - {$novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_ARC);} | |
1036 | - if ($tipol == 3) | |
1037 | - {$novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_MULTIPOINT);} | |
1038 | - if ($tipol == 2) | |
1039 | - {$novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON);} | |
1040 | - $reg[] = ""; | |
1041 | - $novoshpf->addShape($shape); | |
1042 | - xbase_add_record($db,$reg); | |
1043 | - $novoshpf->free(); | |
1044 | - xbase_close($db); | |
1045 | - //adiciona o layer | |
1046 | - $mapa = ms_newMapObj($tmpfname); | |
1047 | - $layer = ms_newLayerObj($mapa); | |
1048 | - $layer->set("name","wktins"); | |
1049 | - $layer->set("data",$nomeshp.".shp"); | |
1050 | - $layer->setmetadata("DOWNLOAD","sim"); | |
1051 | - $layer->setmetadata("temalocal","sim"); | |
1052 | - $layer->setmetadata("tema",$nometemawkt); | |
1053 | - $layer->setmetadata("classe","sim"); | |
1054 | - $layer->set("type",$shape->type); | |
1055 | - $layer->set("status",MS_DEFAULT); | |
1056 | - $classe = ms_newClassObj($layer); | |
1057 | - $classe->set("name"," "); | |
1058 | - $estilo = ms_newStyleObj($classe); | |
1059 | - if($shape->type == 0) | |
1060 | - { | |
1061 | - if(!isset($simbolo)) | |
1062 | - $estilo->set("symbolname","ponto"); | |
1063 | - if(!isset($tamanhosimbolo)) | |
1064 | - $estilo->set("size",6); | |
1065 | - } | |
1066 | - if($shape->type == 1) | |
1067 | - { | |
1068 | - if(!isset($simbolo)) | |
1069 | - $estilo->set("symbolname","linha"); | |
1070 | - if(!isset($tamanhosimbolo)) | |
1071 | - $estilo->set("size",3); | |
1072 | - } | |
1073 | - if($shape->type == 2) | |
1074 | - {$layer->set("opacity","50");} | |
1075 | - | |
1076 | - $cor = $estilo->color; | |
1077 | - if(!isset($corsimbolo)) | |
1078 | - {$corsimbolo ="255,0,0";} | |
1079 | - $corsimbolo = str_replace(" ",",",$corsimbolo); | |
1080 | - $corsimbolo = explode(",",$corsimbolo); | |
1081 | - $cor->setRGB($corsimbolo[0],$corsimbolo[1],$corsimbolo[2]); | |
1082 | - | |
1083 | - $salvo = $mapa->save($tmpfname); | |
1084 | - erroCriacao(); | |
1085 | -} | |
1086 | -/* | |
1087 | -Insere um tema do tipo ponto | |
1088 | - | |
1089 | -*/ | |
1090 | -function inserePontosUrl() | |
1091 | -{ | |
1092 | - global $pontos,$tamanhosimbolo,$simbolo,$corsimbolo,$nometemapontos,$dir_tmp,$imgdir,$tmpfname,$locaplic; | |
1093 | - include_once "pacotes/phpxbase/api_conversion.php"; | |
1094 | - if (!isset($nometemapontos)) | |
1095 | - {$nometemapontos="Pontos";} | |
1096 | - if ($nometemapontos == "") | |
1097 | - {$nometemapontos="Pontos";} | |
1098 | - // | |
1099 | - //cria o shape file | |
1100 | - // | |
1101 | - $tipol = MS_SHP_POINT; | |
1102 | - $nomeshp = $dir_tmp."/".$imgdir."/".nomeRandomico(); | |
1103 | - // cria o dbf | |
1104 | - $def = array(); | |
1105 | - $items = array("COORD"); | |
1106 | - foreach ($items as $ni) | |
1107 | - {$def[] = array($ni,"C","254");} | |
1108 | - if(!function_exists(dbase_create)){ | |
1109 | - xbase_create($nomeshp.".dbf", $def); | |
1110 | - } | |
1111 | - else{ | |
1112 | - dbase_create($nomeshp.".dbf", $def); | |
1113 | - } | |
1114 | - $dbname = $nomeshp.".dbf"; | |
1115 | - $db=xbase_open($dbname,2); | |
1116 | - $novoshpf = ms_newShapefileObj($nomeshp, $tipol); | |
1117 | - $pontos = explode(" ",trim($pontos)); | |
1118 | - if(count($pontos) == 1){ | |
1119 | - $pontos = explode(",",trim($pontos[0])); | |
1120 | - } | |
1121 | - foreach ($pontos as $p){ | |
1122 | - if (is_numeric($p)){ | |
1123 | - $pontosn[] = $p; | |
1124 | - } | |
1125 | - } | |
1126 | - $pontos = $pontosn; | |
1127 | - for ($ci = 0;$ci < count($pontos);$ci=$ci+2){ | |
1128 | - $reg = array(); | |
1129 | - $reg[] = $pontos[$ci]." ".$pontos[$ci+1]; | |
1130 | - $shape = ms_newShapeObj($tipol); | |
1131 | - $linha = ms_newLineObj(); | |
1132 | - $linha->addXY($pontos[$ci],$pontos[$ci+1]); | |
1133 | - $shape->add($linha); | |
1134 | - $novoshpf->addShape($shape); | |
1135 | - xbase_add_record($db,$reg); | |
1136 | - } | |
1137 | - $novoshpf->free(); | |
1138 | - xbase_close($db); | |
1139 | - //adiciona o layer | |
1140 | - $mapa = ms_newMapObj($tmpfname); | |
1141 | - $layer = ms_newLayerObj($mapa); | |
1142 | - $layer->set("name","pontoins"); | |
1143 | - $layer->set("data",$nomeshp.".shp"); | |
1144 | - $layer->setmetadata("DOWNLOAD","sim"); | |
1145 | - $layer->setmetadata("tema",$nometemapontos); | |
1146 | - $layer->setmetadata("classe","sim"); | |
1147 | - $layer->setmetadata("temalocal","sim"); | |
1148 | - $layer->setmetadata("ATLAS","nao"); | |
1149 | - $layer->set("type",MS_LAYER_POINT); | |
1150 | - $layer->set("status",MS_DEFAULT); | |
1151 | - $classe = ms_newClassObj($layer); | |
1152 | - $classe->set("name"," "); | |
1153 | - $estilo = ms_newStyleObj($classe); | |
1154 | - | |
1155 | - if(!isset($simbolo)) | |
1156 | - {$simbolo = "ponto";} | |
1157 | - $estilo->set("symbolname",$simbolo); | |
1158 | - if(!isset($tamanhosimbolo)) | |
1159 | - {$tamanhosimbolo = 6;} | |
1160 | - $estilo->set("size",$tamanhosimbolo); | |
1161 | - $cor = $estilo->color; | |
1162 | - if(!isset($corsimbolo)) | |
1163 | - {$corsimbolo ="255,0,0";} | |
1164 | - $corsimbolo = str_replace(" ",",",$corsimbolo); | |
1165 | - $corsimbolo = explode(",",$corsimbolo); | |
1166 | - $cor->setRGB($corsimbolo[0],$corsimbolo[1],$corsimbolo[2]); | |
1167 | - | |
1168 | - $salvo = $mapa->save($tmpfname); | |
1169 | - erroCriacao(); | |
1170 | -} | |
1171 | -/* | |
1172 | -Insere um tema do tipo linear | |
1173 | - | |
1174 | -As linhas devem ter os pontos separados por espaços e cada linha separada por vírgula | |
1175 | - | |
1176 | -*/ | |
1177 | -function insereLinhasUrl() | |
1178 | -{ | |
1179 | - global $tamanhosimbolo,$simbolo,$corsimbolo,$linhas,$nometemalinhas,$dir_tmp,$imgdir,$tmpfname,$locaplic; | |
1180 | - include_once "pacotes/phpxbase/api_conversion.php"; | |
1181 | - if (!isset($nometemalinhas)) | |
1182 | - {$nometemalinhas="Linhas";} | |
1183 | - if ($nometemalinhas == "") | |
1184 | - {$nometemalinhas="Linhas";} | |
1185 | - // | |
1186 | - //cria o shape file | |
1187 | - // | |
1188 | - $tipol = MS_SHP_ARC; | |
1189 | - $nomeshp = $dir_tmp."/".$imgdir."/".nomeRandomico(); | |
1190 | - // cria o dbf | |
1191 | - $def = array(); | |
1192 | - $items = array("COORD"); | |
1193 | - foreach ($items as $ni){ | |
1194 | - $def[] = array($ni,"C","254"); | |
1195 | - } | |
1196 | - if(!function_exists(dbase_create)){ | |
1197 | - xbase_create($nomeshp.".dbf", $def); | |
1198 | - } | |
1199 | - else{ | |
1200 | - dbase_create($nomeshp.".dbf", $def); | |
1201 | - } | |
1202 | - $dbname = $nomeshp.".dbf"; | |
1203 | - $db=xbase_open($dbname,2); | |
1204 | - $novoshpf = ms_newShapefileObj($nomeshp, $tipol); | |
1205 | - $linhas = explode(",",trim($linhas)); | |
1206 | - $pontosLinhas = array(); //guarda os pontos de cada linha em arrays | |
1207 | - foreach ($linhas as $l){ | |
1208 | - $tempPTs = explode(" ",trim($l)); | |
1209 | - $temp = array(); | |
1210 | - foreach ($tempPTs as $p){ | |
1211 | - if (is_numeric($p)){ | |
1212 | - $temp[] = $p; | |
1213 | - } | |
1214 | - } | |
1215 | - $pontosLinhas[] = $temp; | |
1216 | - } | |
1217 | - foreach ($pontosLinhas as $ptsl){ | |
1218 | - $linhas = $ptsl; | |
1219 | - $shape = ms_newShapeObj(MS_SHAPE_LINE); | |
1220 | - $linha = ms_newLineObj(); | |
1221 | - $reg = array(); | |
1222 | - $reg[] = implode(",",$ptsl); | |
1223 | - for ($ci = 0;$ci < count($linhas);$ci=$ci+2){ | |
1224 | - $linha->addXY($linhas[$ci],$linhas[$ci+1]); | |
1225 | - | |
1226 | - } | |
1227 | - $shape->add($linha); | |
1228 | - $novoshpf->addShape($shape); | |
1229 | - xbase_add_record($db,$reg); | |
1230 | - } | |
1231 | - $novoshpf->free(); | |
1232 | - xbase_close($db); | |
1233 | - //adiciona o layer | |
1234 | - $mapa = ms_newMapObj($tmpfname); | |
1235 | - $layer = ms_newLayerObj($mapa); | |
1236 | - $layer->set("name","linhains"); | |
1237 | - $layer->set("data",$nomeshp.".shp"); | |
1238 | - $layer->setmetadata("DOWNLOAD","sim"); | |
1239 | - $layer->setmetadata("temalocal","sim"); | |
1240 | - $layer->setmetadata("tema",$nometemalinhas); | |
1241 | - $layer->setmetadata("classe","sim"); | |
1242 | - $layer->setmetadata("ATLAS","nao"); | |
1243 | - $layer->set("type",MS_LAYER_LINE); | |
1244 | - $layer->set("status",MS_DEFAULT); | |
1245 | - $classe = ms_newClassObj($layer); | |
1246 | - $classe->set("name"," "); | |
1247 | - $estilo = ms_newStyleObj($classe); | |
1248 | - | |
1249 | - if(isset($simbolo)){ | |
1250 | - $simbolo = "linha"; | |
1251 | - $estilo->set("symbolname",$simbolo); | |
1252 | - } | |
1253 | - if(!isset($tamanhosimbolo)){ | |
1254 | - $tamanhosimbolo = 4; | |
1255 | - } | |
1256 | - $estilo->set("width",$tamanhosimbolo); | |
1257 | - $cor = $estilo->color; | |
1258 | - if(!isset($corsimbolo)) | |
1259 | - {$corsimbolo ="255,0,0";} | |
1260 | - $corsimbolo = str_replace(" ",",",$corsimbolo); | |
1261 | - $corsimbolo = explode(",",$corsimbolo); | |
1262 | - $cor->setRGB($corsimbolo[0],$corsimbolo[1],$corsimbolo[2]); | |
1263 | - | |
1264 | - $salvo = $mapa->save($tmpfname); | |
1265 | - erroCriacao(); | |
1266 | -} | |
1267 | -/* | |
1268 | -Insere um tema poligonal. | |
1269 | - | |
1270 | -Os polígonos devem ter os pontos separados por espaços e cada polígono separado por vírgula | |
1271 | -*/ | |
1272 | -function inserePoligonosUrl() | |
1273 | -{ | |
1274 | - global $tamanhosimbolo,$simbolo,$corsimbolo,$poligonos,$nometemapoligonos,$dir_tmp,$imgdir,$tmpfname,$locaplic; | |
1275 | - include_once "pacotes/phpxbase/api_conversion.php"; | |
1276 | - if (!isset($nometemapoligonos)) | |
1277 | - {$nometemapoligonos="Poligonos";} | |
1278 | - if ($nometemapoligonos == "") | |
1279 | - {$nometemapoligonos="Poligonos";} | |
1280 | - // | |
1281 | - //cria o shape file | |
1282 | - // | |
1283 | - $tipol = MS_SHP_POLYGON; | |
1284 | - $nomeshp = $dir_tmp."/".$imgdir."/".nomeRandomico(); | |
1285 | - // cria o dbf | |
1286 | - $def = array(); | |
1287 | - $items = array("COORD"); | |
1288 | - foreach ($items as $ni) | |
1289 | - {$def[] = array($ni,"C","254");} | |
1290 | - if(!function_exists(dbase_create)) | |
1291 | - {xbase_create($nomeshp.".dbf", $def);} | |
1292 | - else | |
1293 | - {dbase_create($nomeshp.".dbf", $def);} | |
1294 | - $dbname = $nomeshp.".dbf"; | |
1295 | - $db=xbase_open($dbname,2); | |
1296 | - $novoshpf = ms_newShapefileObj($nomeshp, $tipol); | |
1297 | - $linhas = explode(",",trim($poligonos)); | |
1298 | - $pontosLinhas = array(); //guarda os pontos de cada linha em arrays | |
1299 | - foreach ($linhas as $l) | |
1300 | - { | |
1301 | - $tempPTs = explode(" ",trim($l)); | |
1302 | - $temp = array(); | |
1303 | - foreach ($tempPTs as $p) | |
1304 | - if (is_numeric($p)){$temp[] = $p;} | |
1305 | - $pontosLinhas[] = $temp; | |
1306 | - } | |
1307 | - foreach ($pontosLinhas as $ptsl) | |
1308 | - { | |
1309 | - $linhas = $ptsl; | |
1310 | - $shape = ms_newShapeObj(MS_SHAPE_POLYGON); | |
1311 | - $linha = ms_newLineObj(); | |
1312 | - $reg = array(); | |
1313 | - $reg[] = ""; | |
1314 | - for ($ci = 0;$ci < count($linhas);$ci=$ci+2) | |
1315 | - { | |
1316 | - $linha->addXY($linhas[$ci],$linhas[$ci+1]); | |
1317 | - } | |
1318 | - $shape->add($linha); | |
1319 | - $novoshpf->addShape($shape); | |
1320 | - xbase_add_record($db,$reg); | |
1321 | - } | |
1322 | - $novoshpf->free(); | |
1323 | - xbase_close($db); | |
1324 | - //adiciona o layer | |
1325 | - $mapa = ms_newMapObj($tmpfname); | |
1326 | - $layer = ms_newLayerObj($mapa); | |
1327 | - $layer->set("name","linhains"); | |
1328 | - $layer->set("data",$nomeshp.".shp"); | |
1329 | - $layer->setmetadata("DOWNLOAD","sim"); | |
1330 | - $layer->setmetadata("temalocal","sim"); | |
1331 | - $layer->setmetadata("tema",$nometemapoligonos); | |
1332 | - $layer->setmetadata("classe","sim"); | |
1333 | - $layer->setmetadata("ATLAS","nao"); | |
1334 | - $layer->set("type",MS_LAYER_POLYGON); | |
1335 | - $layer->set("opacity","50"); | |
1336 | - $layer->set("status",MS_DEFAULT); | |
1337 | - $classe = ms_newClassObj($layer); | |
1338 | - $classe->set("name"," "); | |
1339 | - $estilo = ms_newStyleObj($classe); | |
1340 | - | |
1341 | - $cor = $estilo->color; | |
1342 | - if(!isset($corsimbolo)) | |
1343 | - {$corsimbolo ="255,0,0";} | |
1344 | - $corsimbolo = str_replace(" ",",",$corsimbolo); | |
1345 | - $corsimbolo = explode(",",$corsimbolo); | |
1346 | - $cor->setRGB($corsimbolo[0],$corsimbolo[1],$corsimbolo[2]); | |
1347 | - | |
1348 | - $salvo = $mapa->save($tmpfname); | |
1349 | - erroCriacao(); | |
1350 | -} | |
1351 | -/* | |
1352 | -Inclui no mapa um tema do tipo WMS | |
1353 | -*/ | |
1354 | -function incluiTemaWms() | |
1355 | -{ | |
1356 | - global $nome_wms,$url_wms,$layer_wms,$style_wms,$srs_wms,$image_wms,$versao_wms,$tmpfname,$locaplic; | |
1357 | - include_once ($locaplic."/classesphp/classe_mapa.php"); | |
1358 | - if(!$nome_wms) | |
1359 | - {$nome = $layer_wms." ".$style_wms;} | |
1360 | - else | |
1361 | - $nome = $nome_wms; | |
1362 | - $m = new Mapa($tmpfname); | |
1363 | - $m->adicionatemawms($layer_wms,$url_wms,$style_wms,$srs_wms,$image_wms,$locaplic,"",$versao_wms,$nome,"","","","","nao","text/plain",""); | |
1364 | - $salvo = $m->salva($tmpfname); | |
1365 | - //echo $tmpfname;exit; | |
1366 | - erroCriacao(); | |
1367 | -} | |
1368 | -/* | |
1369 | -Projeto gvsig | |
1370 | -*/ | |
1371 | -function incluiMapaGvsig($gvsiggvp,$gvsigview=""){ | |
1372 | - | |
1373 | -} | |
1374 | -/* | |
1375 | -Captura e mostra os erros de processamento do mapserver | |
1376 | -*/ | |
1377 | -function erroCriacao(){ | |
1378 | - $error = ms_GetErrorObj(); | |
1379 | - while($error && $error->code != MS_NOERR) | |
1380 | - { | |
1381 | - printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message); | |
1382 | - $error = $error->next(); | |
1383 | - } | |
1384 | - ms_ResetErrorList(); | |
1385 | -} | |
1386 | -/* | |
1387 | -Cria os diretórios temporários para a aplicação. | |
1388 | - | |
1389 | -Parametro: | |
1390 | - | |
1391 | -$dir_tmp {string} - Diretório temporário (no servidor) utilizado pelo mapserver. | |
1392 | - | |
1393 | -$cachedir {string} - Diretório de cache temporário definido no ms_configura.php | |
1394 | - | |
1395 | -Retorno: | |
1396 | - | |
1397 | -{boleano} | |
1398 | -*/ | |
1399 | -function criaDirMapa($dir_tmp,$cachedir=""){ | |
1400 | - if(empty($dir_tmp)){ | |
1401 | - return false; | |
1402 | - } | |
1403 | - if(!file_exists($dir_tmp)){ | |
1404 | - @mkdir ($dir_tmp,0744); | |
1405 | - } | |
1406 | - if(file_exists($dir_tmp)){ | |
1407 | - foreach(glob($dir_tmp . '/{,.}*.php', GLOB_BRACE) as $f) { | |
1408 | - unlink ($f); | |
1409 | - } | |
1410 | - $tmpdirname = nomeRandomico(); | |
1411 | - $crdir = @mkdir ($dir_tmp."/".$tmpdirname,0744); | |
1412 | - chmod($dir_tmp."/".$tmpdirname,0744); | |
1413 | - $crdiri = @mkdir ($dir_tmp."/img".$tmpdirname,0744); | |
1414 | - chmod($dir_tmp."/img".$tmpdirname,0744); | |
1415 | - $mapfile = $dir_tmp."/".$tmpdirname."/".$tmpdirname.".map"; | |
1416 | - $tmpimgname = "img".$tmpdirname; | |
1417 | - if(!file_exists($dir_tmp."/comum")){ | |
1418 | - @mkdir($dir_tmp."/comum",0744); | |
1419 | - } | |
1420 | - if(!file_exists($dir_tmp."/saiku-datasources")){ | |
1421 | - //utilizado para armazenar os arquivos de fonte de dados do SAIKU | |
1422 | - @mkdir($dir_tmp."/saiku-datasources",0744); | |
1423 | - chmod($dir_tmp."/saiku-datasources",0744); | |
1424 | - } | |
1425 | - // | |
1426 | - if($cachedir == ""){ | |
1427 | - if(!file_exists($dir_tmp."/cache")){ | |
1428 | - @mkdir($dir_tmp."/cache",0744); | |
1429 | - chmod($dir_tmp."/cache",0744); | |
1430 | - @mkdir($dir_tmp."/cache/googlemaps",0744); | |
1431 | - chmod($dir_tmp."/cache/googlemaps",0744); | |
1432 | - } | |
1433 | - } | |
1434 | - else{ | |
1435 | - if(!file_exists($cachedir)){ | |
1436 | - @mkdir($cachedir,0744); | |
1437 | - chmod($cachedir,0744); | |
1438 | - @mkdir($cachedir."/googlemaps",0744); | |
1439 | - chmod($cachedir."/googlemaps",0744); | |
1440 | - } | |
1441 | - } | |
1442 | - if(file_exists($dir_tmp."/".$tmpdirname)){ | |
1443 | - return array($mapfile,$tmpdirname,$tmpimgname); | |
1444 | - } | |
1445 | - else{ | |
1446 | - return false; | |
1447 | - } | |
1448 | - } | |
1449 | - else{ | |
1450 | - return false; | |
1451 | - } | |
1452 | -} | |
1453 | -?> | |
217 | + "; | |
218 | + exit(); | |
219 | +} | |
220 | +// $_COOKIE = array(); | |
221 | + | |
222 | +// | |
223 | +// quando $funcao existe, é pq o ms_criamapa.php está | |
224 | +// sendo utilizado como um include em classesphp/mapa_controle.php | |
225 | +// | |
226 | + | |
227 | +if (! isset($funcao)) { | |
228 | + ob_end_clean(); | |
229 | + /* | |
230 | + * Carrega as extensões PHP | |
231 | + * | |
232 | + * Carrega as extensões utilizadas no programa de inicialização. | |
233 | + * A carga das extensões geralmente é necessária nas instalações windows (ms4w) ou quando as mesmas não são carregadas pela própria inicialização do PHP. | |
234 | + */ | |
235 | + include_once (dirname(__FILE__) . "/classesphp/carrega_ext.php"); | |
236 | + /* | |
237 | + * Include dos arquivos PHP. | |
238 | + * | |
239 | + * Inclui os programas php com funções utilizadas pelo ms_criamapa.php | |
240 | + */ | |
241 | + include_once (dirname(__FILE__) . "/classesphp/sani_request.php"); | |
242 | + include_once (dirname(__FILE__) . "/classesphp/funcoes_gerais.php"); | |
243 | + if (! isset($_GET["interface"])) { | |
244 | + $_GET["interface"] = ""; | |
245 | + } | |
246 | + $interface = $_GET["interface"]; | |
247 | +} | |
248 | +$parurl = array_merge($_GET, $_POST); | |
249 | +// | |
250 | +// $base pode vir do ms_configura ou da URL | |
251 | +// o ms_configura pode ter sido inserido antes | |
252 | +// | |
253 | +if (empty($base) && ! empty($parurl["base"])) { | |
254 | + $base = $parurl["base"]; | |
255 | +} | |
256 | + | |
257 | +ms_ResetErrorList(); | |
258 | +$metaestatids = @$parurl["metaestatids"]; | |
259 | +$temasa = @$parurl["temasa"]; | |
260 | +$layers = @$parurl["layers"]; | |
261 | +$desligar = @$parurl["desligar"]; | |
262 | +$mapext = @$parurl["mapext"]; | |
263 | +$executa = ""; // $parurl["executa"]; | |
264 | +$perfil = @$parurl["perfil"]; | |
265 | +$caminho = @$parurl["caminho"]; | |
266 | +$pontos = @$parurl["pontos"]; | |
267 | +$nometemapontos = @$parurl["nometemapontos"]; | |
268 | +$linhas = @$parurl["linhas"]; | |
269 | +$nometemalinhas = @$parurl["nometemalinhas"]; | |
270 | +$poligonos = @$parurl["poligonos"]; | |
271 | +$nometemapoligonos = @$parurl["nometemapoligonos"]; | |
272 | +$simbolo = @$parurl["simbolo"]; | |
273 | +$corsimbolo = @$parurl["corsimbolo"]; | |
274 | +$tamanhosimbolo = @$parurl["tamanhosimbolo"]; | |
275 | +$wkt = @$parurl["wkt"]; | |
276 | +$nometemawkt = @$parurl["nometemawkt"]; | |
277 | +$idioma = @$parurl["idioma"]; | |
278 | +$kmlurl = @$parurl["kmlurl"]; | |
279 | +$url_wms = @$parurl["url_wms"]; | |
280 | +$layer_wms = @$parurl["layer_wms"]; | |
281 | +$style_wms = @$parurl["style_wms"]; | |
282 | +$nome_wms = @$parurl["nome_wms"]; | |
283 | +$srs_wms = @$parurl["srs_wms"]; | |
284 | +$image_wms = @$parurl["image_wms"]; | |
285 | +$versao_wms = @$parurl["versao_wms"]; | |
286 | +$gvsigview = @$parurl["gvsigview"]; | |
287 | +$restauramapa = @$parurl["restauramapa"]; | |
288 | + | |
289 | +$versao = versao(); | |
290 | +$versao = $versao["principal"]; | |
291 | + | |
292 | +// | |
293 | +// a variável $base pode ser definida em ms_configura, mas a preferência é pela definição já existente | |
294 | +// por isso, $base é guardada em uma variável e retomada apos o include de ms_configura.php | |
295 | +// se restauramapa estiver definido, usa o mapfile guardado no banco de administracao como a base | |
296 | +// | |
297 | +if (! isset($dir_tmp)) { | |
298 | + include_once (dirname(__FILE__) . "/ms_configura.php"); | |
299 | + if (! empty($parurl["base"])) { | |
300 | + $base = $parurl["base"]; | |
301 | + } | |
302 | + if (! empty($parurl["interface"])) { | |
303 | + $interface = $parurl["interface"]; | |
304 | + } | |
305 | +} | |
306 | +if (isset($logExec) && $logExec["init"] == true) { | |
307 | + i3GeoLog("prog: ms_criamapa url: " . implode("&", array_merge($_GET, $_POST)), $dir_tmp); | |
308 | +} | |
309 | +if (! empty($restauramapa)) { | |
310 | + $base = restauraMapaAdmin($restauramapa, $dir_tmp); | |
311 | + $m = ms_newMapObj($base); | |
312 | + $w = $m->web; | |
313 | + $w->set("imagepath", dirname($w->imagepath) . "/"); | |
314 | + $w->set("imageurl", dirname($w->imageurl) . "/"); | |
315 | + $m->save($base); | |
316 | +} else { | |
317 | + if (isset($base)) { | |
318 | + $tempBaseX = $base; | |
319 | + } | |
320 | + if (isset($tempBaseX) && $tempBaseX != "") { | |
321 | + $base = $tempBaseX; | |
322 | + } | |
323 | +} | |
324 | +// verifica se o usuario trocou a senha do master | |
325 | +if ($_SERVER['SERVER_NAME'] != "localhost" && ($i3geomaster[0]["usuario"] == "admin" && $i3geomaster[0]["senha"] == "admin")) { | |
326 | + echo json_encode(array( | |
327 | + "bloqueado" => "Bloqueado. ATENCAO!!! Acesso bloqueado: edite o arquivo i3geo/ms_configura.php e altere o login e senha da variavel i3geomaster" | |
328 | + )); | |
329 | + exit(); | |
330 | +} | |
331 | +/* | |
332 | + * Define o cookie para o idioma da interface | |
333 | + */ | |
334 | +if (isset($idioma) && $idioma != "") { | |
335 | + setcookie("i3geolingua", $idioma); | |
336 | +} | |
337 | +/* | |
338 | + * Cria os diretorios temporários que serão utilizados pelo i3geo para armazenar as imagens e outros dados. | |
339 | + */ | |
340 | +$diretorios = criaDirMapa($dir_tmp, $cachedir); | |
341 | +if (! $diretorios) { | |
342 | + echo "<p style=color:red ><b>Não foi possível criar os diretórios temporários em $dir_tmp.</b></p>"; | |
343 | + exit(); | |
344 | +} | |
345 | +criaIndex($dir_tmp, $diretorios); | |
346 | +$tmpfname = $diretorios[0]; | |
347 | +$protocolo = explode("/", $_SERVER['SERVER_PROTOCOL']); | |
348 | +/* | |
349 | + * Prepara as variáveis que serão incluidas na seção | |
350 | + * | |
351 | + * As variáveis vêm do arquivo ms_configura.php e são armazenadas em uma seção com nome específico para o i3geo. | |
352 | + */ | |
353 | +if (! isset($mapext) || empty($mapext)) { | |
354 | + $mapext = ""; | |
355 | +} else { | |
356 | + $mapext = str_replace(",", " ", $mapext); | |
357 | + setcookie("i3geoUltimaExtensao", $mapext); | |
358 | +} | |
359 | +$saikuUrl_ = $saikuUrl; | |
360 | +$cachedir_ = $cachedir; | |
361 | +$dir_tmp_ = $dir_tmp; | |
362 | +$emailInstituicao_ = $emailInstituicao; | |
363 | +$locmapserv_ = $locmapserv; | |
364 | +$locaplic_ = $locaplic; | |
365 | +// $locsistemas_ = $locsistemas; | |
366 | +// $locidentifica_ = $locidentifica; | |
367 | +$R_path_ = $R_path; | |
368 | +$mapext_ = $mapext; | |
369 | + | |
370 | +$debug_ = @$debug; | |
371 | +$ler_extensoes_ = $ler_extensoes; | |
372 | +$postgis_mapa_ = $postgis_mapa; | |
373 | +$tituloInstituicao_ = $tituloInstituicao; | |
374 | +// $atlasxml_ = $atlasxml; | |
375 | +$expoeMapfile_ = $expoeMapfile; | |
376 | +$googleApiKey_ = $googleApiKey; | |
377 | +$mensagemInicia_ = $mensagemInicia; | |
378 | +$interfacePadrao_ = $interfacePadrao; | |
379 | +if (empty($interface)) { | |
380 | + $interface_ = $interfacePadrao; | |
381 | +} | |
382 | +if (isset($kmlurl)) { | |
383 | + $kmlurl_ = $kmlurl; | |
384 | +} | |
385 | +// | |
386 | +// se houver string de conexão para substituição | |
387 | +// o modo cgi não irá funcionar | |
388 | +// | |
389 | +if ($postgis_mapa != "") { | |
390 | + $utilizacgi = "nao"; | |
391 | +} | |
392 | +if (! isset($perfil)) { | |
393 | + $perfil = ""; | |
394 | +} | |
395 | +$perfil_ = $perfil; | |
396 | +$utilizacgi_ = $utilizacgi; | |
397 | +if ((isset($navegadoresLocais)) && ($navegadoresLocais != "")) { | |
398 | + $navegadoresLocais_ = "sim"; | |
399 | +} else { | |
400 | + $navegadoresLocais_ = "nao"; | |
401 | +} | |
402 | +if (empty($i3georendermode)) { | |
403 | + $i3georendermode_ = 0; | |
404 | +} else { | |
405 | + $i3georendermode_ = $i3georendermode; | |
406 | +} | |
407 | +if (empty($statusFerramentas)) { | |
408 | + $statusFerramentas_ = array(); | |
409 | +} else { | |
410 | + $statusFerramentas_ = $statusFerramentas; | |
411 | +} | |
412 | +if (empty($logExec)) { | |
413 | + $logExec_ = ""; | |
414 | +} else { | |
415 | + $logExec_ = $logExec; | |
416 | +} | |
417 | +if (! isset($i3geoPermiteLogin)) { | |
418 | + $i3geoPermiteLogin_ = ""; | |
419 | +} else { | |
420 | + $i3geoPermiteLogin_ = $i3geoPermiteLogin; | |
421 | +} | |
422 | +/* | |
423 | + * Inicia a seção | |
424 | + * | |
425 | + * O i3geo inicia uma seção específica no servidor, denominada i3GeoPHP. | |
426 | + * Se já houver uma seção aberta, em função de outro browser estar ativo, cria uma nova. Faz a cópia das variáveis definidas para itens da seção. | |
427 | + */ | |
428 | +session_name("i3GeoPHP"); | |
429 | +session_start(); | |
430 | +// echo $_SESSION["map_file"];exit; | |
431 | +if (! isset($g_sid)) { | |
432 | + $g_sid = ""; | |
433 | +} | |
434 | +if (isset($_SESSION["map_file"]) || $g_sid != "" || $g_sid == "undefined") { | |
435 | + session_regenerate_id(); | |
436 | + $_SESSION = array(); | |
437 | +} | |
438 | +/* | |
439 | + * Aguarde | |
440 | + * | |
441 | + * Monta a apresentação do aguarde. | |
442 | + * | |
443 | + * Aqui é necessário verificar se $executa está definido | |
444 | + * isso pq algumas aplicações podem ser prejudicadas caso o aguarde seja mostrado | |
445 | + */ | |
446 | +$_SESSION["dir_tmp"] = $dir_tmp_; | |
447 | +$_SESSION["cachedir"] = $cachedir_; | |
448 | +$_SESSION["emailInstituicao"] = $emailInstituicao_; | |
449 | +$_SESSION["locmapserv"] = $locmapserv_; | |
450 | +$_SESSION["locaplic"] = $locaplic_; | |
451 | +$_SESSION["R_path"] = $R_path_; | |
452 | +$_SESSION["mapext"] = $mapext_; | |
453 | +$_SESSION["debug"] = $debug_; | |
454 | +$_SESSION["ler_extensoes"] = $ler_extensoes_; | |
455 | +$_SESSION["postgis_mapa"] = $postgis_mapa_; | |
456 | +$_SESSION["perfil"] = $perfil_; | |
457 | +$_SESSION["navegadoresLocais"] = $navegadoresLocais_; | |
458 | +$_SESSION["utilizacgi"] = $utilizacgi_; | |
459 | +$_SESSION["tituloInstituicao"] = $tituloInstituicao_; | |
460 | +$_SESSION["expoeMapfile"] = $expoeMapfile; | |
461 | +$_SESSION["googleApiKey"] = $googleApiKey_; | |
462 | +$_SESSION["mensagemInicia"] = $mensagemInicia_; | |
463 | +$_SESSION["interfacePadrao"] = $interfacePadrao_; | |
464 | +$_SESSION["logExec"] = $logExec_; | |
465 | +$_SESSION["i3geoPermiteLogin"] = $i3geoPermiteLogin_; | |
466 | +if (! isset($customDir)) { | |
467 | + $customDir = ""; | |
468 | +} | |
469 | +$_SESSION["customDir"] = $customDir; | |
470 | +if (isset($interface_)) { | |
471 | + $_SESSION["interface"] = $interface_; | |
472 | +} | |
473 | +if (isset($kmlurl_)) { | |
474 | + $_SESSION["kmlurl"] = $kmlurl_; | |
475 | +} | |
476 | +// rotina de segurança, ver http://shiflett.org/articles/the-truth-about-sessions | |
477 | +$fingerprint = 'I3GEOSEC' . $_SERVER['HTTP_USER_AGENT']; | |
478 | +$_SESSION['fingerprint'] = md5($fingerprint . session_id()); | |
479 | +$_SESSION["mapdir"] = $diretorios[1]; | |
480 | +$_SESSION["imgdir"] = $diretorios[2]; | |
481 | +$_SESSION["contadorsalva"] = 0; // essa variavel e utilizada pela ferramenta telaremota. Toda vez que o mapa e salvo, acrescenta 1 (veja classesphp/mapa_controle.php) | |
482 | +$_SESSION["i3georendermode"] = $i3georendermode_; | |
483 | +$_SESSION["saikuUrl"] = $saikuUrl_; | |
484 | +$_SESSION["logExec"] = $logExec_; | |
485 | +$_SESSION["i3geoPermiteLogin"] = $i3geoPermiteLogin_; | |
486 | + | |
487 | +// sao arrays | |
488 | +$postgis_mapa = $postgis_mapa_; | |
489 | +$_SESSION["statusFerramentas"] = $statusFerramentas_; | |
490 | +/* | |
491 | + * Define os arquivos .map | |
492 | + * | |
493 | + * Seleciona os arquivos mapfile que serão carregados como base conforme o tipo de sistema operacional. | |
494 | + * | |
495 | + * A variável $base pode ser definida como um parâmetro na inicialização, caso contrário será utilizado o valor definido em ms_configura.php ou o i3Geo tentará descobrir o melhor arquivo a ser usado, conforme o que existir em i3geo/aplicmap. | |
496 | + * | |
497 | + * Os arquivos .map padrão são armazenados em i3geo/aplicmap. | |
498 | + * O arquivo é lido conforma a característica do sistema operacional. | |
499 | + * | |
500 | + */ | |
501 | +$versao = versao(); | |
502 | +$versao = $versao["principal"]; | |
503 | +if (! isset($base) || $base == "") { | |
504 | + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { | |
505 | + $base = $locaplic . "/aplicmap/geral1windowsv" . $versao . ".map"; | |
506 | + } else { | |
507 | + if ($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv' . $versao . '.map')) { | |
508 | + $base = "/var/www/i3geo/aplicmap/geral1debianv" . $versao . ".map"; | |
509 | + } | |
510 | + if ($base == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) { | |
511 | + $base = "/var/www/html/i3geo/aplicmap/geral1fedorav" . $versao . ".map"; | |
512 | + } | |
513 | + if ($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) { | |
514 | + $base = "/opt/www/html/i3geo/aplicmap/geral1v" . $versao . ".map"; | |
515 | + } | |
516 | + if ($base == "") { | |
517 | + $base = $locaplic . "/aplicmap/geral1v" . $versao . ".map"; | |
518 | + } | |
519 | + } | |
520 | +} | |
521 | +// error_log($base); | |
522 | +// if(!isset($estadosl)) | |
523 | +// {$estadosl = "estadosl";} | |
524 | +/* | |
525 | + * Cria os objetos map que serão processados | |
526 | + * | |
527 | + * O arquivo definido em $base é lido como um objeto map. Esse objeto será processado para incluir novos layers e alterar outros parâmetros definidos pelo usuário. | |
528 | + */ | |
529 | +if (file_exists($base)) { | |
530 | + $map = ms_newMapObj($base); | |
531 | + $mapn = ms_newMapObj($base); | |
532 | +} else { | |
533 | + $map = ms_newMapObj($locaplic . "/aplicmap/" . $base . ".map"); | |
534 | + $mapn = ms_newMapObj($locaplic . "/aplicmap/" . $base . ".map"); | |
535 | +} | |
536 | + | |
537 | +/* | |
538 | + * Parâmetros adicionais. | |
539 | + * | |
540 | + * Processa os parâmetros para a inicialização verificando se foram passados pela URL ou não. | |
541 | + */ | |
542 | +if (! isset($mapext)) { | |
543 | + $mapext = $map->extent->minx . " " . $map->extent->miny . " " . $map->extent->maxx . " " . $map->extent->maxy; | |
544 | +} | |
545 | +// arquivo com a imagem de referência | |
546 | +if (! isset($map_reference_image)) { | |
547 | + $map_reference_image = $map->reference->image; | |
548 | +} | |
549 | +// extensão geográfica da imagem do mapa de referência | |
550 | +if (! isset($map_reference_extent)) { | |
551 | + $map_reference_extent = $map->reference->extent->minx . " " . $map->reference->extent->miny . " " . $map->reference->extent->maxx . " " . $map->reference->extent->maxy; | |
552 | +} | |
553 | +if (empty($interface)) { | |
554 | + if (! isset($interfacePadrao)) { | |
555 | + $interfacePadrao = "ol.htm"; | |
556 | + } | |
557 | + $interface = $interfacePadrao; | |
558 | +} | |
559 | + | |
560 | +if (isset($layers) && ! isset($temasa)) { | |
561 | + $temasa = $layers; | |
562 | +} | |
563 | + | |
564 | +incluiTemasIniciais(); | |
565 | + | |
566 | +if (isset($layers)) { | |
567 | + ligaTemas(); | |
568 | +} | |
569 | +if (isset($desligar)) { | |
570 | + desligaTemasIniciais(); | |
571 | +} | |
572 | +if (isset($map_reference_image)) { | |
573 | + $mapn->reference->set("image", $map_reference_image); | |
574 | +} | |
575 | +$extr = $mapn->reference->extent; | |
576 | +if (isset($map_reference_extent)) { | |
577 | + $temp = explode(" ", $map_reference_extent); | |
578 | + foreach ($temp as $t) { | |
579 | + if ($t != "") { | |
580 | + $newext[] = $t; | |
581 | + } | |
582 | + } | |
583 | + if (count($newext) == 4) { | |
584 | + $extr->setextent($newext[0], $newext[1], $newext[2], $newext[3]); | |
585 | + } | |
586 | +} | |
587 | +$ext = $mapn->extent; | |
588 | +$newext = array(); | |
589 | +if ((isset($mapext)) && ($mapext != "")) { | |
590 | + $temp = explode(" ", $mapext); | |
591 | + foreach ($temp as $t) { | |
592 | + if ($t != "") { | |
593 | + $newext[] = $t; | |
594 | + } | |
595 | + } | |
596 | + if (count($newext) == 4) { | |
597 | + $ext->setextent($newext[0], $newext[1], $newext[2], $newext[3]); | |
598 | + } | |
599 | +} else { | |
600 | + // algumas aplicacoes usam essa variavel (SAIKU) | |
601 | + $mapext = $ext->minx . " " . $ext->miny . " " . $ext->maxx . " " . $ext->maxy; | |
602 | +} | |
603 | + | |
604 | +/* | |
605 | + * Configura os endereços corretos no mapfile. | |
606 | + * | |
607 | + * Altera as propriedades imagepath e imageurl corrigindo os caminhos padrão conforme o diretório criado para armazenar o mapa de trabalho. | |
608 | + */ | |
609 | + | |
610 | +$w = $mapn->web; | |
611 | +$atual = $w->imagepath; | |
612 | +$w->set("imagepath", $atual . $diretorios[2] . "/"); | |
613 | +$atual = $w->imageurl; | |
614 | +$w->set("imageurl", $atual . $diretorios[2] . "/"); | |
615 | + | |
616 | +$projecao = pegaProjecaoDefault("proj4"); | |
617 | +if ($projecao != "") { | |
618 | + $mapn->setProjection($projecao); | |
619 | +} | |
620 | +// aplica o tamanho do mapa | |
621 | +if (isset($parurl["largura"]) && isset($parurl["altura"])) { | |
622 | + $mapn->setsize($parurl["largura"], $parurl["altura"]); | |
623 | +} | |
624 | + | |
625 | +$tmpfname = str_replace(".map", "", $tmpfname) . ".map"; | |
626 | +$salvo = $mapn->save($tmpfname); | |
627 | + | |
628 | +$_SESSION["imgurl"] = strtolower($protocolo[0]) . "://" . $_SERVER['HTTP_HOST'] . $atual . $diretorios[2] . "/"; | |
629 | +$_SESSION["tmpurl"] = strtolower($protocolo[0]) . "://" . $_SERVER['HTTP_HOST'] . $atual; | |
630 | +$_SESSION["map_file"] = $tmpfname; | |
631 | +$_SESSION["mapext"] = $mapext; | |
632 | +if (isset($executa)) { | |
633 | + if (file_exists($executa)) { | |
634 | + // include_once ($executa); | |
635 | + } | |
636 | + if (function_exists($executa)) { | |
637 | + // eval($executa."();"); | |
638 | + } | |
639 | +} | |
640 | +if (isset($wkt)) { | |
641 | + insereWKTUrl(); | |
642 | +} | |
643 | + | |
644 | +if (isset($pontos)) { | |
645 | + inserePontosUrl(); | |
646 | +} | |
647 | + | |
648 | +if (isset($linhas)) { | |
649 | + insereLinhasUrl(); | |
650 | +} | |
651 | + | |
652 | +if (isset($poligonos)) { | |
653 | + inserePoligonosUrl(); | |
654 | +} | |
655 | + | |
656 | +if (isset($url_wms)) { | |
657 | + incluiTemaWms(); | |
658 | +} | |
659 | + | |
660 | +adaptaLayers($tmpfname, $versao); | |
661 | + | |
662 | +// if (file_exists($locaplic."/pacotes/geoip") && file_exists($locaplic."/pacotes/geoip/GeoLiteCity.dat")){ | |
663 | +// require_once(dirname(__FILE__)."/ms_registraip.php"); | |
664 | +// } | |
665 | +if ($interface != "mashup") { | |
666 | + abreInterface($interface, $caminho); | |
667 | +} | |
668 | + | |
669 | +/* | |
670 | + * Adapta os dados de cada layer. | |
671 | + * | |
672 | + * Faz alterações em cada layer caso sejam necessárias. | |
673 | + */ | |
674 | +function adaptaLayers($tmpfname, $versao) | |
675 | +{ | |
676 | + global $parurl; | |
677 | + $mapa = ms_newMapObj($tmpfname); | |
678 | + $path = $mapa->shapepath; | |
679 | + $numlayers = $mapa->numlayers; | |
680 | + for ($i = 0; $i < $numlayers; ++ $i) { | |
681 | + $layer = $mapa->getLayer($i); | |
682 | + $ok = true; | |
683 | + if ($layer->connection == "") { | |
684 | + $ok = false; | |
685 | + $d = $layer->data; | |
686 | + if ((file_exists($d)) || (file_exists($d . ".shp"))) { | |
687 | + $ok = true; | |
688 | + } else { | |
689 | + if ((file_exists($path . "/" . $d)) || (file_exists($path . "/" . $d . ".shp"))) { | |
690 | + $ok = true; | |
691 | + } | |
692 | + } | |
693 | + } | |
694 | + if ($ok == false) { | |
695 | + $layer->set("status", MS_OFF); | |
696 | + } | |
697 | + // para impedir erros na legenda | |
698 | + if ($layer->getmetadata("classe") == "") { | |
699 | + $layer->setmetadata("classe", ""); | |
700 | + } | |
701 | + if ($versao > 5) { | |
702 | + $pr = $layer->getProcessing(); | |
703 | + if (! in_array("LABEL_NO_CLIP=True", $pr)) { | |
704 | + $layer->setprocessing("LABEL_NO_CLIP=True"); | |
705 | + } | |
706 | + if (! in_array("POLYLINE_NO_CLIP=True", $pr)) { | |
707 | + $layer->setprocessing("POLYLINE_NO_CLIP=True"); | |
708 | + } | |
709 | + } | |
710 | + // | |
711 | + // verifica se deve aplicar filtro | |
712 | + // | |
713 | + $filtro = @$parurl["map_layer_" . $layer->name . "_filter"]; | |
714 | + if (! empty($filtro)) { | |
715 | + $layer->setmetadata("CACHE", "nao"); | |
716 | + $layer->setfilter($filtro); | |
717 | + } | |
718 | + corrigeLayerPath($layer, $mapa); | |
719 | + } | |
720 | + $mapa->save($tmpfname); | |
721 | + erroCriacao(); | |
722 | +} | |
723 | + | |
724 | +/* | |
725 | + * Redireciona para o HTML definido em $interface, abrindo o mapa | |
726 | + */ | |
727 | +function abreInterface($interface, $caminho) | |
728 | +{ | |
729 | + $nomeInterface = explode(".", basename($interface)); | |
730 | + if (count(explode(".php", $interface)) > 1) { | |
731 | + if (file_exists($caminho . "interface/" . $interface)) { | |
732 | + include_once ($caminho . "interface/" . $interface); | |
733 | + } | |
734 | + exit(); | |
735 | + } else { | |
736 | + if (file_exists($caminho . "interface/" . $interface)) { | |
737 | + $urln = $caminho . "interface/" . $interface . "?&" . session_id(); | |
738 | + } else { | |
739 | + $urln = $interface . "?&" . session_id(); | |
740 | + } | |
741 | + if (! headers_sent()) { | |
742 | + header("Location:" . $urln); | |
743 | + } else { | |
744 | + echo "<meta http-equiv='refresh' content='0;url=$urln'>"; | |
745 | + } | |
746 | + } | |
747 | +} | |
748 | + | |
749 | +/* | |
750 | + * Desliga os temas definidos na variável $desligar | |
751 | + */ | |
752 | +function desligaTemasIniciais() | |
753 | +{ | |
754 | + global $desligar, $mapn; | |
755 | + $layers = str_replace(',', " ", $desligar); | |
756 | + $lista = explode(" ", $layers); | |
757 | + foreach ($lista as $l) { | |
758 | + if ($l == "") { | |
759 | + continue; | |
760 | + } | |
761 | + if (@$mapn->getLayerByName($l)) { | |
762 | + $layern = $mapn->getLayerByName($l); | |
763 | + $layern->set("status", MS_OFF); | |
764 | + } | |
765 | + $grupos = $mapn->getLayersIndexByGroup($l); | |
766 | + if (count($grupos) > 0) { | |
767 | + for ($i = 0; $i < count($grupos); ++ $i) { | |
768 | + $layern = $mapn->getLayer($grupos[$i]); | |
769 | + if (strtolower($layern->group) == strtolower($l)) { | |
770 | + $layern->set("status", MS_OFF); | |
771 | + } | |
772 | + } | |
773 | + } | |
774 | + } | |
775 | + erroCriacao(); | |
776 | +} | |
777 | + | |
778 | +/* | |
779 | + * Liga os temas definidos na variável $layers | |
780 | + */ | |
781 | +function ligaTemas() | |
782 | +{ | |
783 | + global $layers, $mapn; | |
784 | + if (isset($layers)) { | |
785 | + $layers = str_replace(',', " ", $layers); | |
786 | + $lista = explode(" ", $layers); | |
787 | + foreach ($lista as $l) { | |
788 | + if ($l == "") { | |
789 | + continue; | |
790 | + } | |
791 | + if (@$mapn->getLayerByName($l)) { | |
792 | + $layern = $mapn->getLayerByName($l); | |
793 | + $layern->set("status", MS_DEFAULT); | |
794 | + } | |
795 | + $grupos = $mapn->getLayersIndexByGroup($l); | |
796 | + if (count($grupos) > 0) { | |
797 | + for ($i = 0; $i < count($grupos); ++ $i) { | |
798 | + $layern = $mapn->getLayer($grupos[$i]); | |
799 | + if (strtolower($layern->group) == strtolower($l)) { | |
800 | + $layern->set("status", MS_DEFAULT); | |
801 | + } | |
802 | + } | |
803 | + } | |
804 | + } | |
805 | + } | |
806 | + erroCriacao(); | |
807 | +} | |
808 | + | |
809 | +/* | |
810 | + * Inclui os temas definidos na variável $temasa | |
811 | + * | |
812 | + * Os temas devem estar em i3geo/temas | |
813 | + */ | |
814 | +function incluiTemasIniciais() | |
815 | +{ | |
816 | + global $temasa, $mapn, $locaplic, $metaestatids, $layers; | |
817 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { | |
818 | + $temasdir = $locaplic . "\\temas"; | |
819 | + } else { | |
820 | + $temasdir = $locaplic . "/temas"; | |
821 | + } | |
822 | + if (! isset($temasa)) { | |
823 | + $temasa = ""; | |
824 | + } | |
825 | + $temasa = str_replace(',', " ", $temasa); | |
826 | + $alayers = explode(" ", $temasa); | |
827 | + if (isset($metaestatids)) { | |
828 | + // localhost/i3geo/ms_criamapa.php?metaestatids=25,12&layers=25 | |
829 | + include_once (dirname(__FILE__) . "/classesphp/classe_metaestatinfo.php"); | |
830 | + $metaestatids = str_replace(',', " ", $metaestatids); | |
831 | + $metaestatids = explode(" ", $metaestatids); | |
832 | + $metaestatidsligados = $layers; | |
833 | + $metaestatidsligados = str_replace(',', " ", $metaestatidsligados); | |
834 | + $metaestatidsligados = explode(" ", $metaestatidsligados); | |
835 | + foreach ($metaestatids as $metaestatid) { | |
836 | + // $_pg["filtro"] = str_replace('"', "'", $_pg["filtro"]); | |
837 | + $m = new MetaestatInfo(); | |
838 | + | |
839 | + $parametros = $m->listaParametro($metaestatid, "", "", true, true); | |
840 | + // id_parametro_medida,coluna | |
841 | + $filtroPar = array(); | |
842 | + $tituloPar = array(); | |
843 | + foreach ($parametros as $parametro) { | |
844 | + $valoresparametro = $m->valorUnicoMedidaVariavel($metaestatid, $parametro["coluna"]); | |
845 | + //var_dump($valoresparametro); | |
846 | + //exit(); | |
847 | + $valormaior = $valoresparametro[count($valoresparametro) - 1]; | |
848 | + $filtroPar[] = " " . $parametro["coluna"] . "::text = '" . $valormaior[$parametro["coluna"]] . "' "; | |
849 | + $tituloPar[] = $parametro["coluna"] . ": " . $valormaior[$parametro["coluna"]]; | |
850 | + } | |
851 | + $dadosMedida = $m->listaMedidaVariavel("", $metaestatid); | |
852 | + // var_dump($dadosMedida);exit; | |
853 | + $tituloCamada = mb_convert_encoding($dadosMedida["nomemedida"],"ISO-8859-1",mb_detect_encoding($dadosMedida["nomemedida"])); | |
854 | + if(count($tituloPar)>0){ | |
855 | + $tituloCamada = $tituloCamada." (".implode(" ,",$tituloPar)." )"; | |
856 | + } | |
857 | + $mapfilemetaestat = $m->mapfileMedidaVariavel($metaestatid, implode(" AND ", $filtroPar), 0, "polygon", $tituloCamada, "", "", "", "", false, false); | |
858 | + // array(3) { ["mapfile"]=> string(52) "/tmp/ms_tmp/AAAAc20ad4d76fe97759aa27a0c99bff6710.map" ["layer"]=> string(36) "AAAAc20ad4d76fe97759aa27a0c99bff6710" ["titulolayer"]=> string(0) "" } | |
859 | + // var_dump ($mapfilemetaestat); | |
860 | + // exit; | |
861 | + array_push($alayers, $mapfilemetaestat["mapfile"]); | |
862 | + | |
863 | + if (in_array($metaestatid, $metaestatidsligados)) { | |
864 | + $maptemp = @ms_newMapObj($mapfilemetaestat["mapfile"]); | |
865 | + $maptemp->getlayerbyname($mapfilemetaestat["layer"])->set("status", MS_DEFAULT); | |
866 | + $maptemp->save($mapfilemetaestat["mapfile"]); | |
867 | + } | |
868 | + } | |
869 | + } | |
870 | + | |
871 | + $existeraster = false; | |
872 | + foreach ($alayers as $arqt) { | |
873 | + $arqtemp = ""; | |
874 | + $arqt = trim($arqt); | |
875 | + if ($arqt == "") { | |
876 | + continue; | |
877 | + } | |
878 | + $extensao = ".map"; | |
879 | + if (file_exists($arqt)) { | |
880 | + $arqtemp = $arqt; | |
881 | + } | |
882 | + if ((strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) && (file_exists($locaplic . "\\aplicmap\\" . $arqt . $extensao))) { | |
883 | + $arqtemp = $locaplic . "\\aplicmap\\" . $arqt . $extensao; | |
884 | + } elseif (file_exists($locaplic . "/aplicmap/" . $arqt . $extensao)) { | |
885 | + $arqtemp = $locaplic . "/aplicmap/" . $arqt . $extensao; | |
886 | + } | |
887 | + if ((strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) && (file_exists($temasdir . "\\" . $arqt . $extensao))) { | |
888 | + $arqtemp = $temasdir . "\\" . $arqt . $extensao; | |
889 | + } elseif (file_exists($temasdir . "/" . $arqt . $extensao)) { | |
890 | + $arqtemp = $temasdir . "/" . $arqt . $extensao; | |
891 | + } | |
892 | + if ($arqtemp == "") { | |
893 | + // echo "<br>Impossível acessar tema $arqtemp"; | |
894 | + } else { | |
895 | + if ($extensao == ".map" && ! @ms_newMapObj($arqtemp)) { | |
896 | + echo "<br>Problemas com a camada $arqtemp<br>"; | |
897 | + } else { | |
898 | + $maptemp = @ms_newMapObj($arqtemp); | |
899 | + for ($i = 0; $i < ($maptemp->numlayers); ++ $i) { | |
900 | + // error_reporting(0); | |
901 | + $layern = $maptemp->getLayer($i); | |
902 | + if ($layern->type == MS_LAYER_RASTER) { | |
903 | + $existeraster = true; | |
904 | + } | |
905 | + if ($layern->name == "estadosl") { | |
906 | + $layern->set("data", $locaplic . "/aplicmap/dados/estados.shp"); | |
907 | + } | |
908 | + $layern->setmetadata("nomeoriginal", $layern->name); | |
909 | + $nNome = str_replace(".map", "", basename($arqtemp)); | |
910 | + $layern->setmetadata("arquivotemaoriginal", $nNome); | |
911 | + autoClasses($layern, $mapn); | |
912 | + // | |
913 | + // necessário para não alterar a extensão do mapa por esse parâmetro | |
914 | + // | |
915 | + $layern->setmetadata("aplicaextensao", ""); | |
916 | + // cria e aplica sld se for wms e existirem classes | |
917 | + if ($layern->classitem != "" && $layern->connectiontype == 7 && $layern->numclasses > 0 && $layern->getmetadata("wms_sld_body") == "") { | |
918 | + $tipotemp = $layern->type; | |
919 | + $statustemp = $layern->status; | |
920 | + $tiporep = $layern->getmetadata("tipooriginal"); | |
921 | + $layern->set("type", MS_LAYER_POLYGON); | |
922 | + if ($tiporep == "linear") { | |
923 | + $layern->set("type", MS_LAYER_LINE); | |
924 | + } | |
925 | + if ($tiporep == "pontual") { | |
926 | + $layern->set("type", MS_LAYER_POINT); | |
927 | + } | |
928 | + $layern->set("status", MS_DEFAULT); | |
929 | + $sld = $layern->generateSLD(); | |
930 | + if ($sld != "") | |
931 | + $layern->setmetadata("wms_sld_body", str_replace('"', "'", $sld)); | |
932 | + $layern->set("type", $tipotemp); | |
933 | + $layern->set("status", $statustemp); | |
934 | + } | |
935 | + cloneInlineSymbol($layern, $maptemp, $mapn); | |
936 | + $layerAdicionado = ms_newLayerObj($mapn, $layern); | |
937 | + // echo $layern->name; | |
938 | + corrigeLayerGrid($layern, $layerAdicionado); | |
939 | + } | |
940 | + } | |
941 | + } | |
942 | + } | |
943 | + erroCriacao(); | |
944 | +} | |
945 | + | |
946 | +/* | |
947 | + * Cria os arquivos vazios index.htm e index.html nos diretorios temporários | |
948 | + */ | |
949 | +function criaIndex($dir_tmp, $diretorios) | |
950 | +{ | |
951 | + if (! file_exists($dir_tmp . "/index.htm")) { | |
952 | + $f = fopen($dir_tmp . "/index.htm", "x"); | |
953 | + fclose($f); | |
954 | + $f = fopen($dir_tmp . "/index.html", "x"); | |
955 | + fclose($f); | |
956 | + $f = fopen($dir_tmp . "/" . $diretorios[1] . "/index.html", "x"); | |
957 | + fclose($f); | |
958 | + $f = fopen($dir_tmp . "/" . $diretorios[1] . "/index.htm", "x"); | |
959 | + fclose($f); | |
960 | + $f = fopen($dir_tmp . "/" . $diretorios[2] . "/index.html", "x"); | |
961 | + fclose($f); | |
962 | + $f = fopen($dir_tmp . "/" . $diretorios[2] . "/index.htm", "x"); | |
963 | + fclose($f); | |
964 | + } | |
965 | + if (! file_exists($dir_tmp . "/index.htm")) { | |
966 | + echo "Erro. Não foi possível gravar no diretório temporário"; | |
967 | + exit(); | |
968 | + } | |
969 | +} | |
970 | + | |
971 | +/* | |
972 | + * Mostra a mensagem de aguarde | |
973 | + */ | |
974 | +function mostraAguarde() | |
975 | +{ | |
976 | + global $interface, $mensagemInicia, $tituloInstituicao; | |
977 | + if (! isset($interface)) { | |
978 | + echo "<html><head>"; | |
979 | + echo '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"></head>'; | |
980 | + echo "<title>" . $tituloInstituicao . "</title>"; | |
981 | + echo '<div id="aguarde"><center>'; | |
982 | + echo '<p class=paguarde style="font-family: Verdana, Arial, Helvetica, sans-serif;color:black;text-align:center;font-size:12pt"><b>' . $mensagemInicia . '</b><br> Aguarde...preparando o mapa</p>'; | |
983 | + echo '<table><tr>'; | |
984 | + echo "<td colspan=3 ><center><img src='" . dirname(__FILE__) . "/imagens/i3geo1.jpg'></td></tr>"; | |
985 | + echo "<tr><td><center><img src='" . dirname(__FILE__) . "/imagens/pspb.png'></td>"; | |
986 | + echo "<td><center><img src='" . dirname(__FILE__) . "/imagens/mapserv.png'></td>"; | |
987 | + echo "<td><center><img src='" . dirname(__FILE__) . "/imagens/yui-logo.png'></td>"; | |
988 | + echo "<td><center><a href='http://mapas.mma.gov.br/download' target=blank ><img src='" . dirname(__FILE__) . "/imagens/somerights20_pt.gif' ></a></td>"; | |
989 | + echo "</tr></table>"; | |
990 | + echo '<BODY bgcolor="white" style="background-color:white">'; | |
991 | + } | |
992 | +} | |
993 | + | |
994 | +/* | |
995 | + * Insere elementos no mapa a partir de uma string definida em wkt | |
996 | + */ | |
997 | +function insereWKTUrl() | |
998 | +{ | |
999 | + global $tamanhosimbolo, $simbolo, $corsimbolo, $wkt, $nometemawkt, $dir_tmp, $imgdir, $tmpfname, $locaplic; | |
1000 | + include_once "pacotes/phpxbase/api_conversion.php"; | |
1001 | + if (! isset($nometemapontos)) { | |
1002 | + $nometemapontos = "WKT"; | |
1003 | + } | |
1004 | + if ($nometemapontos == "") { | |
1005 | + $nometemapontos = "WKT"; | |
1006 | + } | |
1007 | + // | |
1008 | + // cria o shape file | |
1009 | + // | |
1010 | + $shape = ms_shapeObjFromWkt($wkt); | |
1011 | + $tipol = $shape->type; | |
1012 | + if ($tipol == 0) { | |
1013 | + $tipol = 3; | |
1014 | + } | |
1015 | + $nomeshp = $dir_tmp . "/" . $imgdir . "/wkts"; | |
1016 | + // cria o dbf | |
1017 | + $def = array(); | |
1018 | + $items = array( | |
1019 | + "COORD" | |
1020 | + ); | |
1021 | + foreach ($items as $ni) { | |
1022 | + $def[] = array( | |
1023 | + $ni, | |
1024 | + "C", | |
1025 | + "254" | |
1026 | + ); | |
1027 | + } | |
1028 | + if (! function_exists(dbase_create)) { | |
1029 | + xbase_create($nomeshp . ".dbf", $def); | |
1030 | + } else { | |
1031 | + dbase_create($nomeshp . ".dbf", $def); | |
1032 | + } | |
1033 | + $dbname = $nomeshp . ".dbf"; | |
1034 | + $db = xbase_open($dbname, 2); | |
1035 | + if ($tipol == 1) { | |
1036 | + $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_ARC); | |
1037 | + } | |
1038 | + if ($tipol == 3) { | |
1039 | + $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_MULTIPOINT); | |
1040 | + } | |
1041 | + if ($tipol == 2) { | |
1042 | + $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON); | |
1043 | + } | |
1044 | + $reg[] = ""; | |
1045 | + $novoshpf->addShape($shape); | |
1046 | + xbase_add_record($db, $reg); | |
1047 | + $novoshpf->free(); | |
1048 | + xbase_close($db); | |
1049 | + // adiciona o layer | |
1050 | + $mapa = ms_newMapObj($tmpfname); | |
1051 | + $layer = ms_newLayerObj($mapa); | |
1052 | + $layer->set("name", "wktins"); | |
1053 | + $layer->set("data", $nomeshp . ".shp"); | |
1054 | + $layer->setmetadata("DOWNLOAD", "sim"); | |
1055 | + $layer->setmetadata("temalocal", "sim"); | |
1056 | + $layer->setmetadata("tema", $nometemawkt); | |
1057 | + $layer->setmetadata("classe", "sim"); | |
1058 | + $layer->set("type", $shape->type); | |
1059 | + $layer->set("status", MS_DEFAULT); | |
1060 | + $classe = ms_newClassObj($layer); | |
1061 | + $classe->set("name", " "); | |
1062 | + $estilo = ms_newStyleObj($classe); | |
1063 | + if ($shape->type == 0) { | |
1064 | + if (! isset($simbolo)) | |
1065 | + $estilo->set("symbolname", "ponto"); | |
1066 | + if (! isset($tamanhosimbolo)) | |
1067 | + $estilo->set("size", 6); | |
1068 | + } | |
1069 | + if ($shape->type == 1) { | |
1070 | + if (! isset($simbolo)) | |
1071 | + $estilo->set("symbolname", "linha"); | |
1072 | + if (! isset($tamanhosimbolo)) | |
1073 | + $estilo->set("size", 3); | |
1074 | + } | |
1075 | + if ($shape->type == 2) { | |
1076 | + $layer->set("opacity", "50"); | |
1077 | + } | |
1078 | + | |
1079 | + $cor = $estilo->color; | |
1080 | + if (! isset($corsimbolo)) { | |
1081 | + $corsimbolo = "255,0,0"; | |
1082 | + } | |
1083 | + $corsimbolo = str_replace(" ", ",", $corsimbolo); | |
1084 | + $corsimbolo = explode(",", $corsimbolo); | |
1085 | + $cor->setRGB($corsimbolo[0], $corsimbolo[1], $corsimbolo[2]); | |
1086 | + | |
1087 | + $salvo = $mapa->save($tmpfname); | |
1088 | + erroCriacao(); | |
1089 | +} | |
1090 | + | |
1091 | +/* | |
1092 | + * Insere um tema do tipo ponto | |
1093 | + * | |
1094 | + */ | |
1095 | +function inserePontosUrl() | |
1096 | +{ | |
1097 | + global $pontos, $tamanhosimbolo, $simbolo, $corsimbolo, $nometemapontos, $dir_tmp, $imgdir, $tmpfname, $locaplic; | |
1098 | + include_once "pacotes/phpxbase/api_conversion.php"; | |
1099 | + if (! isset($nometemapontos)) { | |
1100 | + $nometemapontos = "Pontos"; | |
1101 | + } | |
1102 | + if ($nometemapontos == "") { | |
1103 | + $nometemapontos = "Pontos"; | |
1104 | + } | |
1105 | + // | |
1106 | + // cria o shape file | |
1107 | + // | |
1108 | + $tipol = MS_SHP_POINT; | |
1109 | + $nomeshp = $dir_tmp . "/" . $imgdir . "/" . nomeRandomico(); | |
1110 | + // cria o dbf | |
1111 | + $def = array(); | |
1112 | + $items = array( | |
1113 | + "COORD" | |
1114 | + ); | |
1115 | + foreach ($items as $ni) { | |
1116 | + $def[] = array( | |
1117 | + $ni, | |
1118 | + "C", | |
1119 | + "254" | |
1120 | + ); | |
1121 | + } | |
1122 | + if (! function_exists(dbase_create)) { | |
1123 | + xbase_create($nomeshp . ".dbf", $def); | |
1124 | + } else { | |
1125 | + dbase_create($nomeshp . ".dbf", $def); | |
1126 | + } | |
1127 | + $dbname = $nomeshp . ".dbf"; | |
1128 | + $db = xbase_open($dbname, 2); | |
1129 | + $novoshpf = ms_newShapefileObj($nomeshp, $tipol); | |
1130 | + $pontos = explode(" ", trim($pontos)); | |
1131 | + if (count($pontos) == 1) { | |
1132 | + $pontos = explode(",", trim($pontos[0])); | |
1133 | + } | |
1134 | + foreach ($pontos as $p) { | |
1135 | + if (is_numeric($p)) { | |
1136 | + $pontosn[] = $p; | |
1137 | + } | |
1138 | + } | |
1139 | + $pontos = $pontosn; | |
1140 | + for ($ci = 0; $ci < count($pontos); $ci = $ci + 2) { | |
1141 | + $reg = array(); | |
1142 | + $reg[] = $pontos[$ci] . " " . $pontos[$ci + 1]; | |
1143 | + $shape = ms_newShapeObj($tipol); | |
1144 | + $linha = ms_newLineObj(); | |
1145 | + $linha->addXY($pontos[$ci], $pontos[$ci + 1]); | |
1146 | + $shape->add($linha); | |
1147 | + $novoshpf->addShape($shape); | |
1148 | + xbase_add_record($db, $reg); | |
1149 | + } | |
1150 | + $novoshpf->free(); | |
1151 | + xbase_close($db); | |
1152 | + // adiciona o layer | |
1153 | + $mapa = ms_newMapObj($tmpfname); | |
1154 | + $layer = ms_newLayerObj($mapa); | |
1155 | + $layer->set("name", "pontoins"); | |
1156 | + $layer->set("data", $nomeshp . ".shp"); | |
1157 | + $layer->setmetadata("DOWNLOAD", "sim"); | |
1158 | + $layer->setmetadata("tema", $nometemapontos); | |
1159 | + $layer->setmetadata("classe", "sim"); | |
1160 | + $layer->setmetadata("temalocal", "sim"); | |
1161 | + $layer->setmetadata("ATLAS", "nao"); | |
1162 | + $layer->set("type", MS_LAYER_POINT); | |
1163 | + $layer->set("status", MS_DEFAULT); | |
1164 | + $classe = ms_newClassObj($layer); | |
1165 | + $classe->set("name", " "); | |
1166 | + $estilo = ms_newStyleObj($classe); | |
1167 | + | |
1168 | + if (! isset($simbolo)) { | |
1169 | + $simbolo = "ponto"; | |
1170 | + } | |
1171 | + $estilo->set("symbolname", $simbolo); | |
1172 | + if (! isset($tamanhosimbolo)) { | |
1173 | + $tamanhosimbolo = 6; | |
1174 | + } | |
1175 | + $estilo->set("size", $tamanhosimbolo); | |
1176 | + $cor = $estilo->color; | |
1177 | + if (! isset($corsimbolo)) { | |
1178 | + $corsimbolo = "255,0,0"; | |
1179 | + } | |
1180 | + $corsimbolo = str_replace(" ", ",", $corsimbolo); | |
1181 | + $corsimbolo = explode(",", $corsimbolo); | |
1182 | + $cor->setRGB($corsimbolo[0], $corsimbolo[1], $corsimbolo[2]); | |
1183 | + | |
1184 | + $salvo = $mapa->save($tmpfname); | |
1185 | + erroCriacao(); | |
1186 | +} | |
1187 | + | |
1188 | +/* | |
1189 | + * Insere um tema do tipo linear | |
1190 | + * | |
1191 | + * As linhas devem ter os pontos separados por espaços e cada linha separada por vírgula | |
1192 | + * | |
1193 | + */ | |
1194 | +function insereLinhasUrl() | |
1195 | +{ | |
1196 | + global $tamanhosimbolo, $simbolo, $corsimbolo, $linhas, $nometemalinhas, $dir_tmp, $imgdir, $tmpfname, $locaplic; | |
1197 | + include_once "pacotes/phpxbase/api_conversion.php"; | |
1198 | + if (! isset($nometemalinhas)) { | |
1199 | + $nometemalinhas = "Linhas"; | |
1200 | + } | |
1201 | + if ($nometemalinhas == "") { | |
1202 | + $nometemalinhas = "Linhas"; | |
1203 | + } | |
1204 | + // | |
1205 | + // cria o shape file | |
1206 | + // | |
1207 | + $tipol = MS_SHP_ARC; | |
1208 | + $nomeshp = $dir_tmp . "/" . $imgdir . "/" . nomeRandomico(); | |
1209 | + // cria o dbf | |
1210 | + $def = array(); | |
1211 | + $items = array( | |
1212 | + "COORD" | |
1213 | + ); | |
1214 | + foreach ($items as $ni) { | |
1215 | + $def[] = array( | |
1216 | + $ni, | |
1217 | + "C", | |
1218 | + "254" | |
1219 | + ); | |
1220 | + } | |
1221 | + if (! function_exists(dbase_create)) { | |
1222 | + xbase_create($nomeshp . ".dbf", $def); | |
1223 | + } else { | |
1224 | + dbase_create($nomeshp . ".dbf", $def); | |
1225 | + } | |
1226 | + $dbname = $nomeshp . ".dbf"; | |
1227 | + $db = xbase_open($dbname, 2); | |
1228 | + $novoshpf = ms_newShapefileObj($nomeshp, $tipol); | |
1229 | + $linhas = explode(",", trim($linhas)); | |
1230 | + $pontosLinhas = array(); // guarda os pontos de cada linha em arrays | |
1231 | + foreach ($linhas as $l) { | |
1232 | + $tempPTs = explode(" ", trim($l)); | |
1233 | + $temp = array(); | |
1234 | + foreach ($tempPTs as $p) { | |
1235 | + if (is_numeric($p)) { | |
1236 | + $temp[] = $p; | |
1237 | + } | |
1238 | + } | |
1239 | + $pontosLinhas[] = $temp; | |
1240 | + } | |
1241 | + foreach ($pontosLinhas as $ptsl) { | |
1242 | + $linhas = $ptsl; | |
1243 | + $shape = ms_newShapeObj(MS_SHAPE_LINE); | |
1244 | + $linha = ms_newLineObj(); | |
1245 | + $reg = array(); | |
1246 | + $reg[] = implode(",", $ptsl); | |
1247 | + for ($ci = 0; $ci < count($linhas); $ci = $ci + 2) { | |
1248 | + $linha->addXY($linhas[$ci], $linhas[$ci + 1]); | |
1249 | + } | |
1250 | + $shape->add($linha); | |
1251 | + $novoshpf->addShape($shape); | |
1252 | + xbase_add_record($db, $reg); | |
1253 | + } | |
1254 | + $novoshpf->free(); | |
1255 | + xbase_close($db); | |
1256 | + // adiciona o layer | |
1257 | + $mapa = ms_newMapObj($tmpfname); | |
1258 | + $layer = ms_newLayerObj($mapa); | |
1259 | + $layer->set("name", "linhains"); | |
1260 | + $layer->set("data", $nomeshp . ".shp"); | |
1261 | + $layer->setmetadata("DOWNLOAD", "sim"); | |
1262 | + $layer->setmetadata("temalocal", "sim"); | |
1263 | + $layer->setmetadata("tema", $nometemalinhas); | |
1264 | + $layer->setmetadata("classe", "sim"); | |
1265 | + $layer->setmetadata("ATLAS", "nao"); | |
1266 | + $layer->set("type", MS_LAYER_LINE); | |
1267 | + $layer->set("status", MS_DEFAULT); | |
1268 | + $classe = ms_newClassObj($layer); | |
1269 | + $classe->set("name", " "); | |
1270 | + $estilo = ms_newStyleObj($classe); | |
1271 | + | |
1272 | + if (isset($simbolo)) { | |
1273 | + $simbolo = "linha"; | |
1274 | + $estilo->set("symbolname", $simbolo); | |
1275 | + } | |
1276 | + if (! isset($tamanhosimbolo)) { | |
1277 | + $tamanhosimbolo = 4; | |
1278 | + } | |
1279 | + $estilo->set("width", $tamanhosimbolo); | |
1280 | + $cor = $estilo->color; | |
1281 | + if (! isset($corsimbolo)) { | |
1282 | + $corsimbolo = "255,0,0"; | |
1283 | + } | |
1284 | + $corsimbolo = str_replace(" ", ",", $corsimbolo); | |
1285 | + $corsimbolo = explode(",", $corsimbolo); | |
1286 | + $cor->setRGB($corsimbolo[0], $corsimbolo[1], $corsimbolo[2]); | |
1287 | + | |
1288 | + $salvo = $mapa->save($tmpfname); | |
1289 | + erroCriacao(); | |
1290 | +} | |
1291 | + | |
1292 | +/* | |
1293 | + * Insere um tema poligonal. | |
1294 | + * | |
1295 | + * Os polígonos devem ter os pontos separados por espaços e cada polígono separado por vírgula | |
1296 | + */ | |
1297 | +function inserePoligonosUrl() | |
1298 | +{ | |
1299 | + global $tamanhosimbolo, $simbolo, $corsimbolo, $poligonos, $nometemapoligonos, $dir_tmp, $imgdir, $tmpfname, $locaplic; | |
1300 | + include_once "pacotes/phpxbase/api_conversion.php"; | |
1301 | + if (! isset($nometemapoligonos)) { | |
1302 | + $nometemapoligonos = "Poligonos"; | |
1303 | + } | |
1304 | + if ($nometemapoligonos == "") { | |
1305 | + $nometemapoligonos = "Poligonos"; | |
1306 | + } | |
1307 | + // | |
1308 | + // cria o shape file | |
1309 | + // | |
1310 | + $tipol = MS_SHP_POLYGON; | |
1311 | + $nomeshp = $dir_tmp . "/" . $imgdir . "/" . nomeRandomico(); | |
1312 | + // cria o dbf | |
1313 | + $def = array(); | |
1314 | + $items = array( | |
1315 | + "COORD" | |
1316 | + ); | |
1317 | + foreach ($items as $ni) { | |
1318 | + $def[] = array( | |
1319 | + $ni, | |
1320 | + "C", | |
1321 | + "254" | |
1322 | + ); | |
1323 | + } | |
1324 | + if (! function_exists(dbase_create)) { | |
1325 | + xbase_create($nomeshp . ".dbf", $def); | |
1326 | + } else { | |
1327 | + dbase_create($nomeshp . ".dbf", $def); | |
1328 | + } | |
1329 | + $dbname = $nomeshp . ".dbf"; | |
1330 | + $db = xbase_open($dbname, 2); | |
1331 | + $novoshpf = ms_newShapefileObj($nomeshp, $tipol); | |
1332 | + $linhas = explode(",", trim($poligonos)); | |
1333 | + $pontosLinhas = array(); // guarda os pontos de cada linha em arrays | |
1334 | + foreach ($linhas as $l) { | |
1335 | + $tempPTs = explode(" ", trim($l)); | |
1336 | + $temp = array(); | |
1337 | + foreach ($tempPTs as $p) | |
1338 | + if (is_numeric($p)) { | |
1339 | + $temp[] = $p; | |
1340 | + } | |
1341 | + $pontosLinhas[] = $temp; | |
1342 | + } | |
1343 | + foreach ($pontosLinhas as $ptsl) { | |
1344 | + $linhas = $ptsl; | |
1345 | + $shape = ms_newShapeObj(MS_SHAPE_POLYGON); | |
1346 | + $linha = ms_newLineObj(); | |
1347 | + $reg = array(); | |
1348 | + $reg[] = ""; | |
1349 | + for ($ci = 0; $ci < count($linhas); $ci = $ci + 2) { | |
1350 | + $linha->addXY($linhas[$ci], $linhas[$ci + 1]); | |
1351 | + } | |
1352 | + $shape->add($linha); | |
1353 | + $novoshpf->addShape($shape); | |
1354 | + xbase_add_record($db, $reg); | |
1355 | + } | |
1356 | + $novoshpf->free(); | |
1357 | + xbase_close($db); | |
1358 | + // adiciona o layer | |
1359 | + $mapa = ms_newMapObj($tmpfname); | |
1360 | + $layer = ms_newLayerObj($mapa); | |
1361 | + $layer->set("name", "linhains"); | |
1362 | + $layer->set("data", $nomeshp . ".shp"); | |
1363 | + $layer->setmetadata("DOWNLOAD", "sim"); | |
1364 | + $layer->setmetadata("temalocal", "sim"); | |
1365 | + $layer->setmetadata("tema", $nometemapoligonos); | |
1366 | + $layer->setmetadata("classe", "sim"); | |
1367 | + $layer->setmetadata("ATLAS", "nao"); | |
1368 | + $layer->set("type", MS_LAYER_POLYGON); | |
1369 | + $layer->set("opacity", "50"); | |
1370 | + $layer->set("status", MS_DEFAULT); | |
1371 | + $classe = ms_newClassObj($layer); | |
1372 | + $classe->set("name", " "); | |
1373 | + $estilo = ms_newStyleObj($classe); | |
1374 | + | |
1375 | + $cor = $estilo->color; | |
1376 | + if (! isset($corsimbolo)) { | |
1377 | + $corsimbolo = "255,0,0"; | |
1378 | + } | |
1379 | + $corsimbolo = str_replace(" ", ",", $corsimbolo); | |
1380 | + $corsimbolo = explode(",", $corsimbolo); | |
1381 | + $cor->setRGB($corsimbolo[0], $corsimbolo[1], $corsimbolo[2]); | |
1382 | + | |
1383 | + $salvo = $mapa->save($tmpfname); | |
1384 | + erroCriacao(); | |
1385 | +} | |
1386 | + | |
1387 | +/* | |
1388 | + * Inclui no mapa um tema do tipo WMS | |
1389 | + */ | |
1390 | +function incluiTemaWms() | |
1391 | +{ | |
1392 | + global $nome_wms, $url_wms, $layer_wms, $style_wms, $srs_wms, $image_wms, $versao_wms, $tmpfname, $locaplic; | |
1393 | + include_once ($locaplic . "/classesphp/classe_mapa.php"); | |
1394 | + if (! $nome_wms) { | |
1395 | + $nome = $layer_wms . " " . $style_wms; | |
1396 | + } else | |
1397 | + $nome = $nome_wms; | |
1398 | + $m = new Mapa($tmpfname); | |
1399 | + $m->adicionatemawms($layer_wms, $url_wms, $style_wms, $srs_wms, $image_wms, $locaplic, "", $versao_wms, $nome, "", "", "", "", "nao", "text/plain", ""); | |
1400 | + $salvo = $m->salva($tmpfname); | |
1401 | + // echo $tmpfname;exit; | |
1402 | + erroCriacao(); | |
1403 | +} | |
1404 | + | |
1405 | +/* | |
1406 | + * Projeto gvsig | |
1407 | + */ | |
1408 | +function incluiMapaGvsig($gvsiggvp, $gvsigview = "") | |
1409 | +{} | |
1410 | + | |
1411 | +/* | |
1412 | + * Captura e mostra os erros de processamento do mapserver | |
1413 | + */ | |
1414 | +function erroCriacao() | |
1415 | +{ | |
1416 | + $error = ms_GetErrorObj(); | |
1417 | + while ($error && $error->code != MS_NOERR) { | |
1418 | + printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message); | |
1419 | + $error = $error->next(); | |
1420 | + } | |
1421 | + ms_ResetErrorList(); | |
1422 | +} | |
1423 | + | |
1424 | +/* | |
1425 | + * Cria os diretórios temporários para a aplicação. | |
1426 | + * | |
1427 | + * Parametro: | |
1428 | + * | |
1429 | + * $dir_tmp {string} - Diretório temporário (no servidor) utilizado pelo mapserver. | |
1430 | + * | |
1431 | + * $cachedir {string} - Diretório de cache temporário definido no ms_configura.php | |
1432 | + * | |
1433 | + * Retorno: | |
1434 | + * | |
1435 | + * {boleano} | |
1436 | + */ | |
1437 | +function criaDirMapa($dir_tmp, $cachedir = "") | |
1438 | +{ | |
1439 | + if (empty($dir_tmp)) { | |
1440 | + return false; | |
1441 | + } | |
1442 | + if (! file_exists($dir_tmp)) { | |
1443 | + @mkdir($dir_tmp, 0744); | |
1444 | + } | |
1445 | + if (file_exists($dir_tmp)) { | |
1446 | + foreach (glob($dir_tmp . '/{,.}*.php', GLOB_BRACE) as $f) { | |
1447 | + unlink($f); | |
1448 | + } | |
1449 | + $tmpdirname = nomeRandomico(); | |
1450 | + $crdir = @mkdir($dir_tmp . "/" . $tmpdirname, 0744); | |
1451 | + chmod($dir_tmp . "/" . $tmpdirname, 0744); | |
1452 | + $crdiri = @mkdir($dir_tmp . "/img" . $tmpdirname, 0744); | |
1453 | + chmod($dir_tmp . "/img" . $tmpdirname, 0744); | |
1454 | + $mapfile = $dir_tmp . "/" . $tmpdirname . "/" . $tmpdirname . ".map"; | |
1455 | + $tmpimgname = "img" . $tmpdirname; | |
1456 | + if (! file_exists($dir_tmp . "/comum")) { | |
1457 | + @mkdir($dir_tmp . "/comum", 0744); | |
1458 | + } | |
1459 | + if (! file_exists($dir_tmp . "/saiku-datasources")) { | |
1460 | + // utilizado para armazenar os arquivos de fonte de dados do SAIKU | |
1461 | + @mkdir($dir_tmp . "/saiku-datasources", 0744); | |
1462 | + chmod($dir_tmp . "/saiku-datasources", 0744); | |
1463 | + } | |
1464 | + // | |
1465 | + if ($cachedir == "") { | |
1466 | + if (! file_exists($dir_tmp . "/cache")) { | |
1467 | + @mkdir($dir_tmp . "/cache", 0744); | |
1468 | + chmod($dir_tmp . "/cache", 0744); | |
1469 | + @mkdir($dir_tmp . "/cache/googlemaps", 0744); | |
1470 | + chmod($dir_tmp . "/cache/googlemaps", 0744); | |
1471 | + } | |
1472 | + } else { | |
1473 | + if (! file_exists($cachedir)) { | |
1474 | + @mkdir($cachedir, 0744); | |
1475 | + chmod($cachedir, 0744); | |
1476 | + @mkdir($cachedir . "/googlemaps", 0744); | |
1477 | + chmod($cachedir . "/googlemaps", 0744); | |
1478 | + } | |
1479 | + } | |
1480 | + if (file_exists($dir_tmp . "/" . $tmpdirname)) { | |
1481 | + return array( | |
1482 | + $mapfile, | |
1483 | + $tmpdirname, | |
1484 | + $tmpimgname | |
1485 | + ); | |
1486 | + } else { | |
1487 | + return false; | |
1488 | + } | |
1489 | + } else { | |
1490 | + return false; | |
1491 | + } | |
1492 | +} | |
1493 | +?> | |
1454 | 1494 | \ No newline at end of file | ... | ... |