Commit ef39184d1376bdd5dc72e39ef9c8ca33061c17ad

Authored by Edmar Moretti
1 parent 02c67b0c
Exists in master

--no commit message

classesphp/classe_mapa.php
@@ -270,7 +270,8 @@ class Mapa @@ -270,7 +270,8 @@ class Mapa
270 "colunaidunico", 270 "colunaidunico",
271 "cortepixels", 271 "cortepixels",
272 "plugini3geo", 272 "plugini3geo",
273 - "link_tema" 273 + "link_tema",
  274 + "ferramentas"
274 ); 275 );
275 foreach ($this->layers as $oLayer){ 276 foreach ($this->layers as $oLayer){
276 $sel = "nao"; 277 $sel = "nao";
@@ -430,6 +431,19 @@ class Mapa @@ -430,6 +431,19 @@ class Mapa
430 if($link_tema == "" && $oLayer->getmetadata("link_tema") != ""){ 431 if($link_tema == "" && $oLayer->getmetadata("link_tema") != ""){
431 $link_tema = $oLayer->getmetadata("link_tema"); 432 $link_tema = $oLayer->getmetadata("link_tema");
432 } 433 }
  434 + //TODO colocar aqui os parametros da linha do tempo???
  435 + //
  436 + //parametros para ferramentas especiaifcas
  437 + //
  438 + $ferramentas = array();
  439 + //mapa 3d
  440 + if($oLayer->getmetadata("tme") != ""){
  441 + $f = $oLayer->getmetadata("tme");
  442 + if (!mb_detect_encoding($f,"UTF-8",true)){
  443 + $f = mb_convert_encoding($f,"UTF-8","ISO-8859-1");
  444 + }
  445 + $ferramentas["tme"] = json_decode($f);
  446 + }
433 //formatacao antiga, antes da versao 6.0 447 //formatacao antiga, antes da versao 6.0
434 /* 448 /*
435 $temas[] = array( 449 $temas[] = array(
@@ -516,7 +530,8 @@ class Mapa @@ -516,7 +530,8 @@ class Mapa
516 $oLayer->getmetadata("COLUNAIDUNICO"), 530 $oLayer->getmetadata("COLUNAIDUNICO"),
517 $cortepixels, 531 $cortepixels,
518 $plugini3geo, 532 $plugini3geo,
519 - $link_tema 533 + $link_tema,
  534 + $ferramentas
520 ); 535 );
521 } 536 }
522 } 537 }
@@ -1091,7 +1106,7 @@ class Mapa @@ -1091,7 +1106,7 @@ class Mapa
1091 //tem erro na versão 6 do Mapserver. Já abri um ticket no trac da OSGEO 1106 //tem erro na versão 6 do Mapserver. Já abri um ticket no trac da OSGEO
1092 $nlayer = criaLayer($this->mapa,MS_LAYER_LINE,MS_DEFAULT,"Grade de coordenadas","SIM"); 1107 $nlayer = criaLayer($this->mapa,MS_LAYER_LINE,MS_DEFAULT,"Grade de coordenadas","SIM");
1093 ms_newgridobj($nlayer); 1108 ms_newgridobj($nlayer);
1094 - 1109 +
1095 $nlayer->grid->set("labelformat", "DDMMSS"); 1110 $nlayer->grid->set("labelformat", "DDMMSS");
1096 $nlayer->grid->set("maxinterval", $intervalo); 1111 $nlayer->grid->set("maxinterval", $intervalo);
1097 $classe = $nlayer->getclass(0); 1112 $classe = $nlayer->getclass(0);
@@ -1117,7 +1132,7 @@ class Mapa @@ -1117,7 +1132,7 @@ class Mapa
1117 else{ 1132 else{
1118 $label = $classe->label; 1133 $label = $classe->label;
1119 } 1134 }
1120 - 1135 +
1121 $label->set("size",$tamanhotexto); 1136 $label->set("size",$tamanhotexto);
1122 $label->set("type",MS_BITMAP); 1137 $label->set("type",MS_BITMAP);
1123 if ($fonte != "bitmap") { 1138 if ($fonte != "bitmap") {
@@ -1305,7 +1320,7 @@ class Mapa @@ -1305,7 +1320,7 @@ class Mapa
1305 $nNome = str_replace(".map","",basename($nomemap)); 1320 $nNome = str_replace(".map","",basename($nomemap));
1306 $nlayer->setmetadata("arquivotemaoriginal",$nNome); 1321 $nlayer->setmetadata("arquivotemaoriginal",$nNome);
1307 $nlayer->setmetadata("nomeoriginal",$nlayer->name); 1322 $nlayer->setmetadata("nomeoriginal",$nlayer->name);
1308 - 1323 +
1309 $nlayer->set("name",$nomeunico[$n]); 1324 $nlayer->set("name",$nomeunico[$n]);
1310 //altera o nome do grupo se existir 1325 //altera o nome do grupo se existir
1311 if ($nlayer->group != " " && $nlayer->group != "" ){ 1326 if ($nlayer->group != " " && $nlayer->group != "" ){
@@ -1351,8 +1366,14 @@ class Mapa @@ -1351,8 +1366,14 @@ class Mapa
1351 for ($i = $numlayers-1;$i > 0;$i--){ 1366 for ($i = $numlayers-1;$i > 0;$i--){
1352 $layerAbaixo = $this->mapa->getlayer($i); 1367 $layerAbaixo = $this->mapa->getlayer($i);
1353 $tipo = $layerAbaixo->type; 1368 $tipo = $layerAbaixo->type;
1354 - if($tipo == 2 && ($layerAbaixo->getclass(0)->getstyle(0)->color->red == -1) && ($l->getclass(0)->getstyle(0)->color->red != -1)) {  
1355 - $tipo = 0;//vai subir 1369 + if($layerAbaixo->numclasses > 0 && $l->numclasses > 0){
  1370 + $c = $layerAbaixo->getclass(0);
  1371 + $c1 = $l->getclass(0);
  1372 + if($c->numstyles > 0 && $c1->numstyles > 0){
  1373 + if($tipo == 2 && ($c->getstyle(0)->color->red == -1) && ($c1->getstyle(0)->color->red != -1)) {
  1374 + $tipo = 0;//vai subir
  1375 + }
  1376 + }
1356 } 1377 }
1357 if (($tipo != 2) && ($tipo != 3)){ 1378 if (($tipo != 2) && ($tipo != 3)){
1358 $nummove++; 1379 $nummove++;
classesphp/funcoes_gerais.php
@@ -443,7 +443,8 @@ Envia para o navegador uma imagem. Utilizado na tag IMG em arquivos HTML @@ -443,7 +443,8 @@ Envia para o navegador uma imagem. Utilizado na tag IMG em arquivos HTML
443 function echoimg($arquivo,$tipo){ 443 function echoimg($arquivo,$tipo){
444 echo header("Content-type: image/png \n\n"); 444 echo header("Content-type: image/png \n\n");
445 header('Content-Length: '.filesize($arquivo)); 445 header('Content-Length: '.filesize($arquivo));
446 - fpassthru(fopen($arquivo, 'rb')); 446 + //fpassthru(fopen($arquivo, 'rb'));
  447 + readfile($arquivo);
447 exit; 448 exit;
448 } 449 }
449 /* 450 /*
@@ -2201,6 +2202,7 @@ function getRGBpallete($rule, $value){ @@ -2201,6 +2202,7 @@ function getRGBpallete($rule, $value){
2201 $b=$rule["b0"] + round(($rule["b1"]-$rule["b0"])*$escala, 0); 2202 $b=$rule["b0"] + round(($rule["b1"]-$rule["b0"])*$escala, 0);
2202 return array($r,$g,$b); 2203 return array($r,$g,$b);
2203 } 2204 }
  2205 +//TODO verificar ao fechar versao
2204 /* 2206 /*
2205 Function: removeAcentos 2207 Function: removeAcentos
2206 2208
@@ -2216,7 +2218,7 @@ Retorno: @@ -2216,7 +2218,7 @@ Retorno:
2216 */ 2218 */
2217 function removeAcentos($var) 2219 function removeAcentos($var)
2218 { 2220 {
2219 - $a = array('�', 'Á', 'Â', 'Ã', '�', '�', '�', 'Ç', '�', 'É', 'Ê', '�', '�', 'Í', '�', '�', '�', '�', '�', '�', 'Ô', 'Õ', '�', '�', '�', 'Ú', '�', '�', '�', '�', '�', 'á', 'â', 'ã', '�', '�', '�', 'ç', '�', 'é', 'ê', '�', '�', 'í', '�', '�', '�', '�', '�', 'ô', 'õ', '�', '�', '�', 'ú', '�', '�', '�', '�', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', '�', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', '?', '?', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', '?', '?', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', '?', 'O', 'o', 'O', 'o', 'O', 'o', '�', '�', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', '�', '�', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', '�', 'Z', 'z', 'Z', 'z', '�', '�', '?', '�', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', '?', '?', '?', '?', '?', '?'); 2221 + $a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'Ð', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', '?', '?', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', '?', '?', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', '?', 'O', 'o', 'O', 'o', 'O', 'o', 'Œ', 'œ', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'Š', 'š', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Ÿ', 'Z', 'z', 'Z', 'z', 'Ž', 'ž', '?', 'ƒ', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', '?', '?', '?', '?', '?', '?');
2220 $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o'); 2222 $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
2221 return str_replace($a, $b, $var); 2223 return str_replace($a, $b, $var);
2222 } 2224 }
classesphp/mapa_googlemaps.php
@@ -511,7 +511,8 @@ function carregaCacheImagem(){ @@ -511,7 +511,8 @@ function carregaCacheImagem(){
511 header('Content-Type: image/png'); 511 header('Content-Type: image/png');
512 header('Cache-Control: public, max-age=22222222'); 512 header('Cache-Control: public, max-age=22222222');
513 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT'); 513 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT');
514 - fpassthru(fopen($nome, 'rb')); 514 + //fpassthru(fopen($nome, 'rb'));
  515 + readfile($nome);
515 } 516 }
516 else{ 517 else{
517 header('Cache-Control: public, max-age=22222222'); 518 header('Cache-Control: public, max-age=22222222');
classesphp/mapa_openlayers.php
@@ -92,7 +92,7 @@ if(isset($_GET["X"])){ @@ -92,7 +92,7 @@ if(isset($_GET["X"])){
92 $z = intval((0.703125 / $res) / 4) + 1; 92 $z = intval((0.703125 / $res) / 4) + 1;
93 $x = floor((($box[0] + 180) / 360) * pow(2, $z)); 93 $x = floor((($box[0] + 180) / 360) * pow(2, $z));
94 $y = floor((1 - log(tan(deg2rad($box[3])) + 1 / cos(deg2rad($box[3]))) / pi()) /2 * pow(2, $z)); 94 $y = floor((1 - log(tan(deg2rad($box[3])) + 1 / cos(deg2rad($box[3]))) / pi()) /2 * pow(2, $z));
95 - 95 +
96 $_GET["WIDTH"] = 256; 96 $_GET["WIDTH"] = 256;
97 $_GET["HEIGHT"] = 256; 97 $_GET["HEIGHT"] = 256;
98 $_GET["tms"] = "/".$_GET["layer"]."/".$z."/".$x."/".$y.".png"; 98 $_GET["tms"] = "/".$_GET["layer"]."/".$z."/".$x."/".$y.".png";
@@ -413,7 +413,8 @@ else{ @@ -413,7 +413,8 @@ else{
413 //header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); 413 //header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT');
414 header('Cache-Control: public, max-age=22222222'); 414 header('Cache-Control: public, max-age=22222222');
415 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT'); 415 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT');
416 - fpassthru(fopen($nomer, 'rb')); 416 + //fpassthru(fopen($nomer, 'rb'));
  417 + readfile($nomer);
417 } 418 }
418 } 419 }
419 else{ 420 else{
@@ -501,7 +502,8 @@ function carregaCacheImagem($cachedir,$map,$tms,$i3georendermode=0){ @@ -501,7 +502,8 @@ function carregaCacheImagem($cachedir,$map,$tms,$i3georendermode=0){
501 header('Cache-Control: public, max-age=22222222'); 502 header('Cache-Control: public, max-age=22222222');
502 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT'); 503 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT');
503 //header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); 504 //header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200);
504 - fpassthru(fopen($nome, 'rb')); 505 + //fpassthru(fopen($nome, 'rb'));
  506 + readfile($nome);
505 } 507 }
506 else{ 508 else{
507 header('Cache-Control: public, max-age=22222222'); 509 header('Cache-Control: public, max-age=22222222');
ferramentas/parametrossql/ogc.php
@@ -459,7 +459,8 @@ function renderNocacheTms(){ @@ -459,7 +459,8 @@ function renderNocacheTms(){
459 header('Cache-Control: max-age=3600, must-revalidate'); 459 header('Cache-Control: max-age=3600, must-revalidate');
460 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); 460 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT');
461 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200); 461 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200);
462 - fpassthru(fopen($nomer, 'rb')); 462 + //fpassthru(fopen($nomer, 'rb'));
  463 + readfile($nomer);
463 } 464 }
464 if($i3georendermode == 2){ 465 if($i3georendermode == 2){
465 ob_clean(); 466 ob_clean();
@@ -488,7 +489,8 @@ function carregaCacheImagem($cachedir,$map,$tms, $plugin, $tema){ @@ -488,7 +489,8 @@ function carregaCacheImagem($cachedir,$map,$tms, $plugin, $tema){
488 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); 489 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200);
489 $etag = md5_file($nome); 490 $etag = md5_file($nome);
490 header('Etag: '.$etag); 491 header('Etag: '.$etag);
491 - fpassthru(fopen($nome, 'rb')); 492 + //fpassthru(fopen($nome, 'rb'));
  493 + readfile($nome);
492 exit; 494 exit;
493 } 495 }
494 } 496 }
@@ -527,7 +529,8 @@ function salvaCacheImagem($cachedir,$map,$tms, $plugin, $tema){ @@ -527,7 +529,8 @@ function salvaCacheImagem($cachedir,$map,$tms, $plugin, $tema){
527 header('Cache-Control: max-age=3600, must-revalidate'); 529 header('Cache-Control: max-age=3600, must-revalidate');
528 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); 530 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT');
529 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); 531 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200);
530 - fpassthru(fopen($nome, 'rb')); 532 + //fpassthru(fopen($nome, 'rb'));
  533 + readfile($nome);
531 exit; 534 exit;
532 } 535 }
533 536
ferramentas/salvamapa/geraminiatura.php
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 /* 2 /*
3 * Gera uma miniatura de um mapfile salvo no banco de dados 3 * Gera uma miniatura de um mapfile salvo no banco de dados
4 * Verifica se a imagem existe, caso contrario cria uma no diretorio temporario 4 * Verifica se a imagem existe, caso contrario cria uma no diretorio temporario
5 - * 5 + *
6 * @param restauramapa - id do mapa a ser restaurado 6 * @param restauramapa - id do mapa a ser restaurado
7 * @param w 7 * @param w
8 * @param h 8 * @param h
@@ -47,5 +47,6 @@ header('Content-Length: '.filesize($nomeImagem)); @@ -47,5 +47,6 @@ header('Content-Length: '.filesize($nomeImagem));
47 header('Content-Type: image/png'); 47 header('Content-Type: image/png');
48 header('Cache-Control: public, max-age=22222222'); 48 header('Cache-Control: public, max-age=22222222');
49 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT'); 49 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT');
50 -fpassthru(fopen($nomeImagem, 'rb')); 50 +//fpassthru(fopen($nomeImagem, 'rb'));
  51 +readfile($nomeImagem);
51 ?> 52 ?>
52 \ No newline at end of file 53 \ No newline at end of file
mashups/openlayers.php
@@ -277,7 +277,7 @@ if($temas != ""){ @@ -277,7 +277,7 @@ if($temas != ""){
277 if(in_array($tema,$visiveis)){ 277 if(in_array($tema,$visiveis)){
278 $visivel = "true"; 278 $visivel = "true";
279 } 279 }
280 - if($nlayers == 1 && strtoupper($layern->getmetadata("cache")) == "SIM" && $layern->getmetadata("PLUGINI3GEO") == ""){ 280 + if(strtolower($DESLIGACACHE) != "sim" && $nlayers == 1 && strtoupper($layern->getmetadata("cache")) == "SIM" && $layern->getmetadata("PLUGINI3GEO") == ""){
281 if($layern->type != 2 && $layern->type != 3){ 281 if($layern->type != 2 && $layern->type != 3){
282 $opacidade = 1; 282 $opacidade = 1;
283 } 283 }
@@ -646,7 +646,7 @@ if(!i3GEO.configura){ @@ -646,7 +646,7 @@ if(!i3GEO.configura){
646 } 646 }
647 ?> 647 ?>
648 i3GEO.editorOL.inicia(); 648 i3GEO.editorOL.inicia();
649 - 649 +
650 function adicionaPluginI3geo(camada,visivel){ 650 function adicionaPluginI3geo(camada,visivel){
651 if(!camada.cache){ 651 if(!camada.cache){
652 camada["cache"] = "NAO"; 652 camada["cache"] = "NAO";
@@ -77,9 +77,16 @@ ogc.php?tema=/var/www/i3geo/aplicmap/geral1debianv6.map&layers=mundo @@ -77,9 +77,16 @@ ogc.php?tema=/var/www/i3geo/aplicmap/geral1debianv6.map&layers=mundo
77 77
78 ogc.php?intervalo=0,50 78 ogc.php?intervalo=0,50
79 */ 79 */
  80 +$_GET = array_merge($_GET,$_POST);
80 // 81 //
81 -//validações e includes  
82 -// 82 +//caso nenhum parametros tenha sido enviado
  83 +//
  84 +if(count($_GET) == 0){
  85 + $tipo="metadados";
  86 + $_GET["REQUEST"] = "getCapabilities";
  87 + $_GET["request"] = "getCapabilities";
  88 + $_GET["SERVICE"] = "WMS";
  89 +}
83 // 90 //
84 //compatibiliza chamadas fora do padrao 91 //compatibiliza chamadas fora do padrao
85 // 92 //
@@ -89,175 +96,158 @@ if(isset($_GET["outputFormat"]) && $_GET["outputFormat"] != ""){ @@ -89,175 +96,158 @@ if(isset($_GET["outputFormat"]) && $_GET["outputFormat"] != ""){
89 if(isset($_GET["outputformat"]) && $_GET["outputformat"] != ""){ 96 if(isset($_GET["outputformat"]) && $_GET["outputformat"] != ""){
90 $_GET["OUTPUTFORMAT"] = $_GET["outputformat"]; 97 $_GET["OUTPUTFORMAT"] = $_GET["outputformat"];
91 } 98 }
92 -if(strtolower($OUTPUTFORMAT) == "geojson"){  
93 - $OUTPUTFORMAT = "json";  
94 -}  
95 $cache = true; 99 $cache = true;
96 -require_once(dirname(__FILE__)."/classesphp/carrega_ext.php"); 100 +//require_once(dirname(__FILE__)."/classesphp/carrega_ext.php");
97 include(dirname(__FILE__)."/ms_configura.php"); 101 include(dirname(__FILE__)."/ms_configura.php");
98 include(dirname(__FILE__)."/classesphp/pega_variaveis.php"); 102 include(dirname(__FILE__)."/classesphp/pega_variaveis.php");
99 include(dirname(__FILE__)."/classesphp/funcoes_gerais.php"); 103 include(dirname(__FILE__)."/classesphp/funcoes_gerais.php");
100 -//para o caso da requisicao kml  
101 -if(strtolower($OUTPUTFORMAT) == "kml" || strtolower($OUTPUTFORMAT) == "kmz"){  
102 - //http://localhost/i3geo/pacotes/kmlmapserver/kmlservice.php?request=kmz&map=_lbiomashp&typename=_lbiomashp  
103 - if(!isset($tema) && isset($layers)){  
104 - $tema = $layers; 104 +//
  105 +//imprime na tela a ajuda
  106 +//
  107 +if(isset($ajuda)){
  108 + ogc_imprimeAjuda();
  109 + exit;
  110 +}
  111 +//
  112 +//pega os enderecos para compor a url de chamada do gerador de web services
  113 +//
  114 +$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']);
  115 +$protocolo = $protocolo[0];
  116 +$protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'];
  117 +$protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT'];
  118 +$urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]);
  119 +//
  120 +//imprime na tela a lista de temas disponiveis
  121 +//
  122 +if(isset($lista) && $lista != ""){
  123 + include_once(dirname(__FILE__)."/classesphp/classe_menutemas.php");
  124 + if($lista == "temas"){
  125 + ogc_imprimeListaDeTemas();
105 } 126 }
106 - $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema;  
107 - header("Location:".$urln); 127 + if($lista == "temaswfs"){
  128 + ogc_imprimeListaDeTemasWfs();
  129 + }
108 exit; 130 exit;
109 } 131 }
110 - 132 +//
111 //define um nome para o mapfile caso a origem seja o sistema de metadados estatisticos 133 //define um nome para o mapfile caso a origem seja o sistema de metadados estatisticos
112 -if(isset($id_medida_variavel)){  
113 - $tema = "ogcmetaestat".$id_medida_variavel;  
114 - $_GET["layers"] = $tema;  
115 - $_GET["LAYERS"] = $tema;  
116 -}  
117 -if(!isset($temas) && isset($tema)){  
118 - $temas = $tema; 134 +//
  135 +if(isset($id_medida_variavel) && $id_medida_variavel != ""){
  136 + $tema = "ogcmetaestat".$id_medida_variavel;
119 } 137 }
120 -if(isset($typeName)){  
121 - $typename = $typeName; 138 +//
  139 +//compatibiliza variaveis
  140 +//
  141 +if(!isset($tema) && isset($layers)){
  142 + $tema = $layers;
122 } 143 }
123 -if(!isset($temas) && isset($typename)){  
124 - $temas = $typename; 144 +if(!isset($tema) && isset($LAYERS)){
  145 + $tema = $LAYERS;
  146 +}
  147 +if(!isset($tema) && isset($temas)){
  148 + $tema = $temas;
  149 +}
  150 +if(isset($typeName)){
  151 + $typename = $typeName;
  152 +}
  153 +if(!isset($tema) && isset($typename)){
125 $tema = $typename; 154 $tema = $typename;
126 } 155 }
  156 +//
  157 +//garante que layers possam ser especificados de diferentes maneiras
  158 +//
  159 +$_GET["layers"] = $tema;
  160 +$_GET["LAYERS"] = $tema;
  161 +$layers = $tema;
  162 +//
  163 +//verifica o OUTPUTFORMAT e o cache de arquivo
  164 +//
  165 +if(!empty($OUTPUTFORMAT)){
  166 + carregaCacheArquivo();
  167 +}
  168 +//
  169 +//para o caso da requisicao kml
  170 +//
  171 +if(strtolower($OUTPUTFORMAT) == "kml" || strtolower($OUTPUTFORMAT) == "kmz"){
  172 + $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema;
  173 + header("Location:".$urln);
  174 + exit;
  175 +}
  176 +//
  177 +//usa o epsg correto ao inves do apelido inventado pelo Google
  178 +//
  179 +if($_GET["SRS"] == "EPSG:900913" || $_GET["srs"] == "EPSG:900913"){
  180 + $_GET["SRS"] = "EPSG:3857";
  181 + $_GET["srs"] = "EPSG:3857";
  182 +}
  183 +if(!isset($_GET["srs"]) && !isset($_GET["SRS"])){
  184 + $_GET["srs"] = "EPSG:4326";
  185 + $_GET["SRS"] = "EPSG:4326";
  186 +}
  187 +//
  188 +//trata geojson da mesma forma que json
  189 +//
  190 +if(strtolower($OUTPUTFORMAT) == "geojson"){
  191 + $OUTPUTFORMAT = "json";
  192 +}
127 // 193 //
128 //recupera um mapa salvo no banco de administracao 194 //recupera um mapa salvo no banco de administracao
129 // 195 //
130 if(!empty($restauramapa)){ 196 if(!empty($restauramapa)){
131 - $xbase = restauraMapaAdmin($restauramapa,$dir_tmp);  
132 - $m = ms_newMapObj($xbase);  
133 - $w = $m->web;  
134 - $w->set("imagepath",dirname($w->imagepath)."/");  
135 - $w->set("imageurl",dirname($w->imageurl)."/");  
136 - //apaga algumas camadas  
137 - $l = $m->getlayerbyname("rosadosventos");  
138 - if($l != ""){  
139 - $l->set("status",MS_DELETE);  
140 - }  
141 - $l = $m->getlayerbyname("copyright");  
142 - if($l != ""){  
143 - $l->set("status",MS_DELETE);  
144 - }  
145 - $m->save($xbase);  
146 - //$fundo = $xbase;  
147 - $temas = $xbase;  
148 - $_GET["tema"] = $temas;  
149 - $_GET["layers"] = "";  
150 - $l = $m->getlayer(0);  
151 - $_GET["LAYERS"] = $l->name; 197 + restauraMapaSalvo();
152 } 198 }
153 // 199 //
154 -//para operar como o Geoserver 200 +//para operar como o Geoserver, abre o openlayers
155 // 201 //
156 if(isset($format) && strtolower($format) == "application/openlayers"){ 202 if(isset($format) && strtolower($format) == "application/openlayers"){
157 - //var_dump($_SERVER);exit;  
158 - if(!isset($layers)){  
159 - $layers = $temas;  
160 - }  
161 - $urln = dirname($_SERVER["PHP_SELF"])."/mashups/openlayers.php?temas=".$layers."&layers=".$layers."&mapext=".$bbox."&botoes=pan,zoombox,zoomtot,identifica"; 203 + $urln = dirname($_SERVER["PHP_SELF"])."/mashups/openlayers.php?layers=".$layers."&mapext=".$bbox."&botoes=pan,zoombox,zoomtot,identifica";
162 //echo $urln;exit; 204 //echo $urln;exit;
163 if(!headers_sent()){ 205 if(!headers_sent()){
164 header("Location:".$urln); 206 header("Location:".$urln);
165 } 207 }
166 else{ 208 else{
167 echo "<meta http-equiv='refresh' content='0;url=$urln'>"; 209 echo "<meta http-equiv='refresh' content='0;url=$urln'>";
168 - }  
169 -}  
170 -//  
171 -//pega os endere&ccedil;os para compor a url de chamada do gerador de web services  
172 -//ogc.php  
173 -//  
174 -$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']);  
175 -$protocolo = $protocolo[0];  
176 -$protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'];  
177 -$protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT'];  
178 -$urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]);  
179 -//  
180 -//imprime na tela a ajuda  
181 -//  
182 -if(isset($ajuda)){  
183 - ogc_imprimeAjuda();  
184 - exit;  
185 -}  
186 -//  
187 -//imprime na tela a lista de temas dispon&iacute;veis  
188 -//  
189 -if(isset($lista) && $lista == "temas"){  
190 - include_once(dirname(__FILE__)."/classesphp/classe_menutemas.php");  
191 - ogc_imprimeListaDeTemas();  
192 - exit;  
193 -}  
194 -if(isset($lista) && $lista == "temaswfs"){  
195 - include_once(dirname(__FILE__)."/classesphp/classe_menutemas.php");  
196 - ogc_imprimeListaDeTemasWfs();  
197 - exit; 210 + }
  211 + //exit....
198 } 212 }
199 // 213 //
200 -//cria o web service 214 +//pega a versao do Mapserver
201 // 215 //
202 error_reporting(0); 216 error_reporting(0);
203 $versao = versao(); 217 $versao = versao();
204 $versao = $versao["principal"]; 218 $versao = $versao["principal"];
205 -if($_GET["SRS"] == "EPSG:900913"){  
206 - $_GET["SRS"] = "EPSG:3857";  
207 -} 219 +
208 $req = ms_newowsrequestobj(); 220 $req = ms_newowsrequestobj();
209 $tipo = ""; 221 $tipo = "";
210 -$_GET = array_merge($_GET,$_POST); 222 +
211 if(isset($_GET["sld"]) || isset($_GET["filter"])){ 223 if(isset($_GET["sld"]) || isset($_GET["filter"])){
212 $cache = false; 224 $cache = false;
213 } 225 }
214 -if(!isset($_GET["srs"]) && !isset($_GET["SRS"])){  
215 - $_GET["srs"] = "EPSG:4326";  
216 -} 226 +//
  227 +//inclui todos os parametros na requisicao e aproveita para verificar getcapabilities
  228 +//
217 foreach ($_GET as $k=>$v){ 229 foreach ($_GET as $k=>$v){
218 $req->setParameter(strtoupper($k), $v); 230 $req->setParameter(strtoupper($k), $v);
219 if(strtolower($v) == "getcapabilities"){ 231 if(strtolower($v) == "getcapabilities"){
220 $tipo = "metadados"; 232 $tipo = "metadados";
221 $cache = false; 233 $cache = false;
222 } 234 }
223 - if(strtolower($k) == "layers" && empty($_GET["tema"])){  
224 - $tema = $v;  
225 - }  
226 - if(strtolower($k) == "layer" && empty($_GET["tema"])){  
227 - $tema = $v;  
228 - }  
229 } 235 }
  236 +//
  237 +//cria uma lista de epsgs para o getcapabilities
  238 +//
230 $req->setParameter("srsName",$req->getValueByName("SRS")); 239 $req->setParameter("srsName",$req->getValueByName("SRS"));
231 $listaepsg = $req->getValueByName("SRS")." EPSG:4618 EPSG:4291 EPSG:4326 EPSG:22521 EPSG:22522 EPSG:22523 EPSG:22524 EPSG:22525 EPSG:29101 EPSG:29119 EPSG:29120 EPSG:29121 EPSG:29122 EPSG:29177 EPSG:29178 EPSG:29179 EPSG:29180 EPSG:29181 EPSG:29182 EPSG:29183 EPSG:29184 EPSG:29185"; 240 $listaepsg = $req->getValueByName("SRS")." EPSG:4618 EPSG:4291 EPSG:4326 EPSG:22521 EPSG:22522 EPSG:22523 EPSG:22524 EPSG:22525 EPSG:29101 EPSG:29119 EPSG:29120 EPSG:29121 EPSG:29122 EPSG:29177 EPSG:29178 EPSG:29179 EPSG:29180 EPSG:29181 EPSG:29182 EPSG:29183 EPSG:29184 EPSG:29185";
232 -//echo $listaepsg;exit;  
233 -if(count($_GET) == 0){  
234 - $tipo="intervalo";  
235 - $req->setParameter("REQUEST", "getCapabilities");  
236 - $req->setParameter("SERVICE", "WMS");  
237 - $cache = false;  
238 -}  
239 -if(isset($tema) && $tipo != "metadados"){  
240 - $tipo = "";  
241 -} 241 +
242 if(isset($version) && !isset($VERSION)){ 242 if(isset($version) && !isset($VERSION)){
243 $VERSION = $version; 243 $VERSION = $version;
244 } 244 }
245 if(!isset($VERSION)){ 245 if(!isset($VERSION)){
246 $req->setParameter("VeRsIoN","1.1.1"); 246 $req->setParameter("VeRsIoN","1.1.1");
247 } 247 }
248 -if (!isset($intervalo)){  
249 - $intervalo = "0,5000";  
250 -}  
251 -else{  
252 - $tipo = "intervalo";  
253 -}  
254 -if(!isset($tema)){  
255 - if(!isset($intervalo)){  
256 - $intervalo = "0,5000";  
257 - }  
258 - $tipo = "intervalo";  
259 -} 248 +//
260 //nome do mapfile que ficara em cache 249 //nome do mapfile que ficara em cache
  250 +//
261 $agora = intval(time() / 1000); 251 $agora = intval(time() / 1000);
262 //acrescenta ao nome a indicacao do tipo de TMS 252 //acrescenta ao nome a indicacao do tipo de TMS
263 if(isset($_GET["tms"])){ 253 if(isset($_GET["tms"])){
@@ -266,7 +256,6 @@ if(isset($_GET[&quot;tms&quot;])){ @@ -266,7 +256,6 @@ if(isset($_GET[&quot;tms&quot;])){
266 if(isset($_GET["Z"]) && isset($_GET["X"])){ 256 if(isset($_GET["Z"]) && isset($_GET["X"])){
267 $agora .= "google"; 257 $agora .= "google";
268 } 258 }
269 -  
270 // 259 //
271 //se o outputformat for definido, evita o cahce de arquivo 260 //se o outputformat for definido, evita o cahce de arquivo
272 //o mesmo se existir filtro para o layer 261 //o mesmo se existir filtro para o layer
@@ -278,9 +267,7 @@ if(isset($_GET[&quot;DESLIGACACHE&quot;]) &amp;&amp; $_GET[&quot;DESLIGACACHE&quot;] == &quot;sim&quot;){ @@ -278,9 +267,7 @@ if(isset($_GET[&quot;DESLIGACACHE&quot;]) &amp;&amp; $_GET[&quot;DESLIGACACHE&quot;] == &quot;sim&quot;){
278 $agora = time(); 267 $agora = time();
279 $cache = false; 268 $cache = false;
280 } 269 }
281 -$nomeMapfileTmp = $dir_tmp."/ogc_".md5($tema.($req->getValueByName("SRS")))."_".$agora.".map";  
282 -$nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp);  
283 -$nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); 270 +$nomeMapfileTmp = $dir_tmp."/ogc_".md5(implode("",$_GET))."_".$agora.".map";
284 //essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao 271 //essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao
285 $cortePixels = 0; 272 $cortePixels = 0;
286 if(file_exists($nomeMapfileTmp) && $tipo == ""){ 273 if(file_exists($nomeMapfileTmp) && $tipo == ""){
@@ -295,7 +282,7 @@ else{ @@ -295,7 +282,7 @@ else{
295 } 282 }
296 $proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://"; 283 $proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://";
297 $server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; 284 $server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
298 - $or = $proto.$server.$_SERVER['PHP_SELF']; 285 + $or = $urli3geo."/ogc.php";
299 if((isset($tema)) && ($tema != "") && ($tipo=="metadados")){ 286 if((isset($tema)) && ($tema != "") && ($tipo=="metadados")){
300 $or = $or."?tema=".$tema."&"; 287 $or = $or."?tema=".$tema."&";
301 } 288 }
@@ -309,8 +296,8 @@ else{ @@ -309,8 +296,8 @@ else{
309 $oMap->setmetadata("wms_attribution_logourl_format","image/png"); 296 $oMap->setmetadata("wms_attribution_logourl_format","image/png");
310 $oMap->setmetadata("wms_attribution_logourl_height","56"); 297 $oMap->setmetadata("wms_attribution_logourl_height","56");
311 $oMap->setmetadata("wms_attribution_logourl_width","85"); 298 $oMap->setmetadata("wms_attribution_logourl_width","85");
312 - $oMap->setmetadata("wms_attribution_logourl_href",$proto.$server.dirname($_SERVER['PHP_SELF'])."/imagens/i3geo.png");  
313 - $oMap->setmetadata("wms_attribution_onlineresource",$proto.$server.dirname($_SERVER['PHP_SELF'])); 299 + $oMap->setmetadata("wms_attribution_logourl_href",$urli3geo."/imagens/i3geo.png");
  300 + $oMap->setmetadata("wms_attribution_onlineresource",$urli3geo);
314 $oMap->setmetadata("wms_attribution_title",$tituloInstituicao); 301 $oMap->setmetadata("wms_attribution_title",$tituloInstituicao);
315 $oMap->setmetadata("ows_enable_request","*"); 302 $oMap->setmetadata("ows_enable_request","*");
316 //parametro mandatario 303 //parametro mandatario
@@ -320,8 +307,8 @@ else{ @@ -320,8 +307,8 @@ else{
320 $e = $oMap->extent; 307 $e = $oMap->extent;
321 $extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); 308 $extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy);
322 //gera o mapa 309 //gera o mapa
323 - if ($tipo == "" || $tipo == "metadados"){  
324 - $tema = explode(" ",$tema); 310 + if ($tema != ""){
  311 + $listatema = explode(" ",$tema);
325 //para o caso do tema ser um arquivo mapfile existente em uma pasta qualquer 312 //para o caso do tema ser um arquivo mapfile existente em uma pasta qualquer
326 //$temai3geo = true indica que o layer ser&aacute; buscado na pasta i3geo/temas 313 //$temai3geo = true indica que o layer ser&aacute; buscado na pasta i3geo/temas
327 $temai3geo = true; 314 $temai3geo = true;
@@ -331,7 +318,7 @@ else{ @@ -331,7 +318,7 @@ else{
331 $temai3geo = false; 318 $temai3geo = false;
332 $nmap->setmetadata("ows_enable_request","*"); 319 $nmap->setmetadata("ows_enable_request","*");
333 } 320 }
334 - foreach ($tema as $tx){ 321 + foreach ($listatema as $tx){
335 $extensao = ".map"; 322 $extensao = ".map";
336 if($temai3geo == true && file_exists($locaplic."/temas/".$tx.".php")){ 323 if($temai3geo == true && file_exists($locaplic."/temas/".$tx.".php")){
337 $extensao = ".php"; 324 $extensao = ".php";
@@ -364,8 +351,7 @@ else{ @@ -364,8 +351,7 @@ else{
364 $nmap = ms_newMapobj($locaplic."/temas/".$tx.".map"); 351 $nmap = ms_newMapobj($locaplic."/temas/".$tx.".map");
365 $nmap->setmetadata("ows_enable_request","*"); 352 $nmap->setmetadata("ows_enable_request","*");
366 } 353 }
367 - if($temai3geo == false || empty($layers))  
368 - { 354 + if($temai3geo == false || empty($layers)){
369 $ts = $nmap->getalllayernames(); 355 $ts = $nmap->getalllayernames();
370 $nmap->setmetadata("ows_enable_request","*"); 356 $nmap->setmetadata("ows_enable_request","*");
371 } 357 }
@@ -473,7 +459,7 @@ else{ @@ -473,7 +459,7 @@ else{
473 $oMap = $gm->addLayers($oMap,$gv,$dataView["layerNames"]); 459 $oMap = $gm->addLayers($oMap,$gv,$dataView["layerNames"]);
474 } 460 }
475 $numlayers = $oMap->numlayers; 461 $numlayers = $oMap->numlayers;
476 - $layers = array(); 462 + $lys = array();
477 //$layers[] = "default"; 463 //$layers[] = "default";
478 for ($i=0;$i < $numlayers;$i++){ 464 for ($i=0;$i < $numlayers;$i++){
479 $l = $oMap->getlayer($i); 465 $l = $oMap->getlayer($i);
@@ -484,7 +470,7 @@ else{ @@ -484,7 +470,7 @@ else{
484 $l->setmetadata("ows_srs",$listaepsg); 470 $l->setmetadata("ows_srs",$listaepsg);
485 $l->setmetadata("ows_title",$l->getmetadata("TEMA")); 471 $l->setmetadata("ows_title",$l->getmetadata("TEMA"));
486 $l->set("status",MS_OFF); 472 $l->set("status",MS_OFF);
487 - $layers[] = $l->name; 473 + $lys[] = $l->name;
488 if(file_exists($locaplic."/temas/miniaturas/".$tx.".map.mini.png")){ 474 if(file_exists($locaplic."/temas/miniaturas/".$tx.".map.mini.png")){
489 $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$tx.".map.mini.png"; 475 $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$tx.".map.mini.png";
490 $l->setmetadata("wms_attribution_logourl_format","image/png"); 476 $l->setmetadata("wms_attribution_logourl_format","image/png");
@@ -511,13 +497,13 @@ else{ @@ -511,13 +497,13 @@ else{
511 $cortePixels = $l->getmetadata("cortepixels"); 497 $cortePixels = $l->getmetadata("cortepixels");
512 } 498 }
513 } 499 }
514 - $req->setParameter("LAYERS", implode(",",$layers)); 500 + $req->setParameter("LAYERS", implode(",",$lys));
515 $req->setParameter("STYLES", ""); 501 $req->setParameter("STYLES", "");
516 - //r_dump($req);exit;  
517 } 502 }
518 } 503 }
519 } 504 }
520 - else{ 505 + else{
  506 + $intervalo = "0,5000";
521 $conta = 0; 507 $conta = 0;
522 $int = explode(",",$intervalo); 508 $int = explode(",",$intervalo);
523 $codigosTema = array(); 509 $codigosTema = array();
@@ -533,10 +519,10 @@ else{ @@ -533,10 +519,10 @@ else{
533 if(strtolower($grupo["ogc"]) == "sim"){ 519 if(strtolower($grupo["ogc"]) == "sim"){
534 foreach($grupo["subgrupos"] as $sgrupo){ 520 foreach($grupo["subgrupos"] as $sgrupo){
535 if(strtolower($sgrupo["ogc"]) == "sim"){ 521 if(strtolower($sgrupo["ogc"]) == "sim"){
536 - $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]);  
537 - foreach($temas as $tema){  
538 - if(strtolower($tema["ogc"]) == "sim"){  
539 - $codigosTema[] = array("tema"=>$tema["tid"],"fonte"=>$tema["link"]); 522 + $lts = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]);
  523 + foreach($lts as $t){
  524 + if(strtolower($t["ogc"]) == "sim"){
  525 + $codigosTema[] = array("tema"=>$t["tid"],"fonte"=>$t["link"]);
540 } 526 }
541 } 527 }
542 } 528 }
@@ -544,10 +530,6 @@ else{ @@ -544,10 +530,6 @@ else{
544 } 530 }
545 } 531 }
546 } 532 }
547 - //echo "<pre>";  
548 - //var_dump($codigosTema);  
549 - //exit;  
550 -  
551 foreach($codigosTema as $c){ 533 foreach($codigosTema as $c){
552 $codigoTema = $c["tema"]; 534 $codigoTema = $c["tema"];
553 if(file_exists($locaplic."/temas/".$codigoTema.".map")){ 535 if(file_exists($locaplic."/temas/".$codigoTema.".map")){
@@ -555,48 +537,41 @@ else{ @@ -555,48 +537,41 @@ else{
555 $nmap = ms_newMapobj($locaplic."/temas/".$codigoTema.".map"); 537 $nmap = ms_newMapobj($locaplic."/temas/".$codigoTema.".map");
556 $nmap->setmetadata("ows_enable_request","*"); 538 $nmap->setmetadata("ows_enable_request","*");
557 $ts = $nmap->getalllayernames(); 539 $ts = $nmap->getalllayernames();
558 - if (count($ts) == 1){  
559 - foreach ($ts as $t){  
560 - if ($oMap->getlayerbyname($t) == ""){  
561 - $conta++;  
562 - if (($conta >= $int[0]) && ($conta <= $int[1])){  
563 - $l = $nmap->getlayerbyname($t);  
564 - $extensao = $l->getmetadata("EXTENSAO");  
565 - if($extensao == ""){  
566 - $extensao = $extensaoMap;  
567 - }  
568 - $l->setmetadata("wms_extent",$extensao);  
569 -  
570 - $l->setmetadata("ows_title",pegaNome($l));  
571 - $l->setmetadata("ows_srs",$listaepsg);  
572 - $l->set("status",MS_OFF);  
573 - $l->setmetadata("gml_include_items","all");  
574 - $l->set("dump",MS_TRUE);  
575 - $l->setmetadata("WMS_INCLUDE_ITEMS","all");  
576 - $l->setmetadata("WFS_INCLUDE_ITEMS","all");  
577 - if($l->getmetadata("ows_metadataurl_href") == ""){  
578 - $l->setmetadata("ows_metadataurl_href",$c["fonte"]);  
579 - $l->setmetadata("ows_metadataurl_type","TC211");  
580 - $l->setmetadata("ows_metadataurl_format","text/html");  
581 - }  
582 - if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){  
583 - $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png";  
584 - $l->setmetadata("wms_attribution_logourl_format","image/png");  
585 - $l->setmetadata("wms_attribution_logourl_height","50");  
586 - $l->setmetadata("wms_attribution_logourl_width","50");  
587 - $l->setmetadata("wms_attribution_logourl_href",$mini);  
588 - }  
589 - //  
590 - //numero de pixels que serao considerados para corte da imagem no caso de cache ativo e tema de pontos  
591 - //  
592 - if ($l->getmetadata("cortepixels") != ""){  
593 - $cortePixels = $l->getmetadata("cortepixels");  
594 - }  
595 - cloneInlineSymbol($l,$nmap,$oMap);  
596 - ms_newLayerObj($oMap, $l);  
597 -  
598 - } 540 + foreach ($ts as $t){
  541 + if ($oMap->getlayerbyname($t) == ""){
  542 + $l = $nmap->getlayerbyname($t);
  543 + $extensao = $l->getmetadata("EXTENSAO");
  544 + if($extensao == ""){
  545 + $extensao = $extensaoMap;
599 } 546 }
  547 + $l->setmetadata("wms_extent",$extensao);
  548 + $l->setmetadata("ows_title",pegaNome($l));
  549 + $l->setmetadata("ows_srs",$listaepsg);
  550 + $l->set("status",MS_OFF);
  551 + $l->setmetadata("gml_include_items","all");
  552 + $l->set("dump",MS_TRUE);
  553 + $l->setmetadata("WMS_INCLUDE_ITEMS","all");
  554 + $l->setmetadata("WFS_INCLUDE_ITEMS","all");
  555 + if($l->getmetadata("ows_metadataurl_href") == ""){
  556 + $l->setmetadata("ows_metadataurl_href",$c["fonte"]);
  557 + $l->setmetadata("ows_metadataurl_type","TC211");
  558 + $l->setmetadata("ows_metadataurl_format","text/html");
  559 + }
  560 + if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){
  561 + $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png";
  562 + $l->setmetadata("wms_attribution_logourl_format","image/png");
  563 + $l->setmetadata("wms_attribution_logourl_height","50");
  564 + $l->setmetadata("wms_attribution_logourl_width","50");
  565 + $l->setmetadata("wms_attribution_logourl_href",$mini);
  566 + }
  567 + //
  568 + //numero de pixels que serao considerados para corte da imagem no caso de cache ativo e tema de pontos
  569 + //
  570 + if ($l->getmetadata("cortepixels") != ""){
  571 + $cortePixels = $l->getmetadata("cortepixels");
  572 + }
  573 + cloneInlineSymbol($l,$nmap,$oMap);
  574 + ms_newLayerObj($oMap, $l);
600 } 575 }
601 } 576 }
602 } 577 }
@@ -611,8 +586,20 @@ else{ @@ -611,8 +586,20 @@ else{
611 } 586 }
612 } 587 }
613 } 588 }
  589 + //
  590 + //a imagem do mapa recebera a legenda
  591 + //
  592 + if((isset($legenda)) && (strtolower($legenda) == "sim")){
  593 + $leg = $oMap->legend;
  594 + $leg->set("status",MS_EMBED);
  595 + }
614 $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename)); 596 $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename));
615 $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); 597 $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename));
  598 + //
  599 + //caso seja download ou json ou csv
  600 + //
  601 + processaOutputformatMapfile();
  602 +
616 $oMap->save($nomeMapfileTmp); 603 $oMap->save($nomeMapfileTmp);
617 $oMap = ms_newMapobj($nomeMapfileTmp); 604 $oMap = ms_newMapobj($nomeMapfileTmp);
618 } 605 }
@@ -788,10 +775,10 @@ if(strtolower($req-&gt;getValueByName(&quot;REQUEST&quot;)) == &quot;getlegendgraphic&quot;){ @@ -788,10 +775,10 @@ if(strtolower($req-&gt;getValueByName(&quot;REQUEST&quot;)) == &quot;getlegendgraphic&quot;){
788 if (function_exists("mb_convert_encoding")){ 775 if (function_exists("mb_convert_encoding")){
789 $leg = mb_convert_encoding($leg,"UTF-8","ISO-8859-1"); 776 $leg = mb_convert_encoding($leg,"UTF-8","ISO-8859-1");
790 } 777 }
791 - echo $leg;exit; 778 + echo $leg;
  779 + exit;
792 } 780 }
793 - }  
794 - 781 + }
795 } 782 }
796 if(strtolower($req->getValueByName("REQUEST")) == "getfeature"){ 783 if(strtolower($req->getValueByName("REQUEST")) == "getfeature"){
797 $l = $oMap->getlayer(0); 784 $l = $oMap->getlayer(0);
@@ -814,54 +801,11 @@ if(strtolower($req-&gt;getValueByName(&quot;REQUEST&quot;)) == &quot;getfeatureinfo&quot;){ @@ -814,54 +801,11 @@ if(strtolower($req-&gt;getValueByName(&quot;REQUEST&quot;)) == &quot;getfeatureinfo&quot;){
814 $_GET["SRS"] = "EPSG:3857"; 801 $_GET["SRS"] = "EPSG:3857";
815 } 802 }
816 } 803 }
817 -//  
818 -//altera os caminhos das imagens  
819 -//  
820 -if((isset($legenda)) && (strtolower($legenda) == "sim")){  
821 - $leg = $oMap->legend;  
822 - $leg->set("status",MS_EMBED);  
823 -} 804 +
  805 +ms_ioinstallstdouttobuffer();
824 // 806 //
825 -//altera o outputformat 807 +//verifica parametro outputformat e ajusta a requisicao
826 // 808 //
827 -if(isset($OUTPUTFORMAT)){  
828 - if(strtolower($OUTPUTFORMAT) == "shape-zip"){  
829 - $l = $oMap->getlayer(0);  
830 - $n = $l->name;  
831 - $oMap->selectOutputFormat("shape-zip");  
832 - $oMap->outputformat->setOption("STORAGE", "memory");  
833 - $oMap->outputformat->setOption("FORM", "zip");  
834 - $oMap->outputformat->setOption("FILENAME", $n.".zip");  
835 - $l->setmetadata("wfs_getfeature_formatlist","shape-zip");  
836 - $oMap->save($nomeMapfileTmp);  
837 - if(strtolower($request) != "getcapabilities"){  
838 - header('Content-Disposition: attachment; filename='.$n.'.zip');  
839 - }  
840 - }  
841 - if(strtolower($OUTPUTFORMAT) == "csv"){  
842 - $l = $oMap->getlayer(0);  
843 - $n = $l->name."-csv";  
844 - $oMap->selectOutputFormat("csv");  
845 - $oMap->outputformat->setOption("STORAGE", "memory");  
846 - $oMap->outputformat->setOption("FILENAME", $n.".zip");  
847 - $oMap->outputformat->setOption("FORM", "zip");  
848 - $l->setmetadata("wfs_getfeature_formatlist","csv");  
849 - $oMap->save($nomeMapfileTmp);  
850 - if(strtolower($request) != "getcapabilities"){  
851 - header('Content-Disposition: attachment; filename='.$n.'.zip');  
852 - }  
853 - }  
854 - if(strtolower($OUTPUTFORMAT) == "geojson"){  
855 - $l = $oMap->getlayer(0);  
856 - $oMap->selectOutputFormat("geojson");  
857 - $l->setmetadata("wfs_getfeature_formatlist","geojson");  
858 - $oMap->save($nomeMapfileTmp);  
859 - header("Content-type: application/json; subtype=geojson");  
860 - }  
861 -}  
862 -ms_ioinstallstdouttobuffer();  
863 -  
864 -//verifica parametro outputformat  
865 if(strtolower($req->getValueByName("REQUEST")) == "getmap" && $req->getValueByName("format") == ""){ 809 if(strtolower($req->getValueByName("REQUEST")) == "getmap" && $req->getValueByName("format") == ""){
866 $req->setParameter("format","image/png"); 810 $req->setParameter("format","image/png");
867 } 811 }
@@ -870,54 +814,13 @@ if(strtolower($req-&gt;getValueByName(&quot;REQUEST&quot;)) == &quot;getfeatureinfo&quot; &amp;&amp; $_GET[&quot;inf @@ -870,54 +814,13 @@ if(strtolower($req-&gt;getValueByName(&quot;REQUEST&quot;)) == &quot;getfeatureinfo&quot; &amp;&amp; $_GET[&quot;inf
870 } 814 }
871 //json conforme cesium 815 //json conforme cesium
872 if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["info_format"] == "application/json"){ 816 if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["info_format"] == "application/json"){
873 - $req->setParameter("info_format","application/vnd.ogc.gml");  
874 - $oMap->owsdispatch($req);  
875 - ms_iostripstdoutbuffercontentheaders();  
876 - ob_clean();  
877 - $r = ms_iogetstdoutbufferstring();  
878 - //$r = converteenc($r);  
879 - $nome = $oMap->getlayer(0)->name;  
880 - $xml = simplexml_load_string($r);  
881 -  
882 - $json = json_encode($xml);  
883 - $r = json_decode($json,TRUE);  
884 - $propriedades = $r[$nome."_layer"];  
885 - $propriedades = $propriedades[$nome."_feature"];  
886 - $propriedades = converteenc(json_encode($propriedades));  
887 - $propriedades = json_decode($propriedades);  
888 - $n = array();  
889 - $n[] = array (  
890 - "type" => "FeatureCollection",  
891 - "features" => array(  
892 - array(  
893 - "type"=>"Feature",  
894 - "id" => "",  
895 - "geometry" => array(),  
896 - "properties" => array(  
897 - $propriedades  
898 - ),  
899 - "geometry_name" => ""  
900 - )  
901 - )  
902 - );  
903 - header("Content-type: application/json");  
904 - $json = json_encode($n[0]);  
905 - //verifica a substituicao de alias  
906 - $itens = $oMap->getlayer(0)->getmetadata("ITENS"); // itens  
907 - $itensdesc = $oMap->getlayer(0)->getmetadata("ITENSDESC"); // descri&ccedil;&atilde;o dos itens  
908 - $itens = explode(",",$itens);  
909 - $itensdesc = explode(",",converteenc($itensdesc));  
910 - $n = count($itens);  
911 - for($i = 0; $i < $n; $i++){  
912 - $json = str_ireplace($itens[$i],$itensdesc[$i],$json);  
913 - }  
914 - echo $json; 817 + getfeatureinfoJson();
915 exit; 818 exit;
916 } 819 }
917 -  
918 $oMap->owsdispatch($req); 820 $oMap->owsdispatch($req);
919 821
920 -$contenttype = ms_iostripstdoutbuffercontenttype(); 822 +$contenttype = ms_iostripstdoutbuffercontenttype();
  823 +
921 if(strtolower($request) == "getcapabilities"){ 824 if(strtolower($request) == "getcapabilities"){
922 header('Content-Disposition: attachment; filename=getcapabilities.xml'); 825 header('Content-Disposition: attachment; filename=getcapabilities.xml');
923 } 826 }
@@ -925,12 +828,45 @@ if(strtolower($request) == &quot;getcapabilities&quot;){ @@ -925,12 +828,45 @@ if(strtolower($request) == &quot;getcapabilities&quot;){
925 if(!isset($OUTPUTFORMAT)){ 828 if(!isset($OUTPUTFORMAT)){
926 header("Content-type: $contenttype"); 829 header("Content-type: $contenttype");
927 } 830 }
928 -if(strtolower($OUTPUTFORMAT) == "geojson"){  
929 - ms_iostripstdoutbuffercontentheaders();  
930 - header("Content-type: application/json; subtype=geojson"); 831 +
  832 +//precisa limpar o cabecalho
  833 +if(strtolower($OUTPUTFORMAT) == "geojson" || strtolower($OUTPUTFORMAT) == "json"){
  834 + ms_iostripstdoutbuffercontentheaders();
  835 + //grava em disco
  836 + $arq = $dir_tmp."/".$tema.".json";
  837 + $contents = ms_iogetstdoutbufferstring();
  838 + file_put_contents($arq,$contents);
  839 + //envia para download
  840 + header("Content-type: application/json; subtype=geojson");
  841 + ms_iogetStdoutBufferBytes();
  842 + ms_ioresethandlers();
  843 + exit;
931 } 844 }
  845 +if(strtolower($OUTPUTFORMAT) == "shape-zip"){
  846 + //grava em disco
  847 + $arq = $dir_tmp."/".$tema."_shapefile.zip";
  848 + $contents = ms_iogetstdoutbufferstring();
  849 + file_put_contents($arq,$contents);
  850 + //envia para download
  851 + header('Content-Disposition: attachment; filename='.$tema.'_shapefile.zip');
  852 + ms_iogetStdoutBufferBytes();
  853 + ms_ioresethandlers();
  854 + exit;
  855 +}
  856 +if(strtolower($OUTPUTFORMAT) == "csv"){
  857 + //grava em disco
  858 + $arq = $dir_tmp."/".$tema.".csv";
  859 + $contents = ms_iogetstdoutbufferstring();
  860 + file_put_contents($arq,$contents);
  861 + //envia para download
  862 + header('Content-Disposition: attachment; filename='.$tema.'.csv');
  863 + header("Content-type: text/csv");
  864 + ms_iogetStdoutBufferBytes();
  865 + ms_ioresethandlers();
  866 + exit;
  867 +}
  868 +$buffer = ms_iogetStdoutBufferBytes();
932 869
933 -$buffer = ms_iogetStdoutBufferBytes();  
934 ms_ioresethandlers(); 870 ms_ioresethandlers();
935 // 871 //
936 //fun&ccedil;&otilde;es 872 //fun&ccedil;&otilde;es
@@ -949,16 +885,17 @@ function ogc_pegaListaDeMenus(){ @@ -949,16 +885,17 @@ function ogc_pegaListaDeMenus(){
949 } 885 }
950 function ogc_imprimeAjuda(){ 886 function ogc_imprimeAjuda(){
951 echo "<pre><b>Construtor de web services do I3Geo.</b><br><br>"; 887 echo "<pre><b>Construtor de web services do I3Geo.</b><br><br>";
952 - echo "Esse utilit&aacute;rio usa os arquivos mapfiles existentes em <br>";  
953 - echo "i3geo/temas para gerar web services no padr&atilde;o OGC.<br>"; 888 + echo "Esse programa usa os arquivos mapfiles existentes em <br>";
  889 + echo "i3geo/temas para gerar web services OGC.<br>";
954 echo "Para escolher um tema, utilize:<br>"; 890 echo "Para escolher um tema, utilize:<br>";
955 echo "ogc.php?lista=temas - para listar os temas dispon&iacute;veis<br>"; 891 echo "ogc.php?lista=temas - para listar os temas dispon&iacute;veis<br>";
956 - echo "Para usar esse web service, al&eacute;m dos par&acirc;metros normais, vc dever&aacute; incluir o par&acirc;metro &tema=,<br>";  
957 - echo "ou seja,http://[host]/i3geo/ogc.php?tema=[c&oacute;digo do tema]<br>";  
958 - echo "no lugar do c&ocaute;digo pode ser especificado tamb&eacute;m um arquivo mapfile qualquer. Nesse caso, deve ser digitado o caminho completo no servidor<br><br>";  
959 - echo "Utilize o sistema de administra&ccedil;&atilde;o do i3Geo para configurar quais os temas da pasta i3geo/temas podem ser utilizados.";  
960 - echo "Utilize o parametro &intervalo=0,20 para definir o n&uacute;mero de temas desejado na fun&ccedil;&atilde;o getcapabilities.";  
961 - echo "Utilize o parametro restauramapa para indicar o ID de um mapa salvo no banco de dados de administra&ccedil;&atilde;o para utiliz&aacute;-lo como um WMS"; 892 + echo "Para usar esse web service voce pode usar o parametro &tema=,<br>";
  893 + echo "ou seja,http://[host]/i3geo/ogc.php?tema=[codigo do tema]<br>";
  894 + echo "no lugar do codigo pode ser especificado um arquivo mapfile qualquer. ";
  895 + echo "Nesse caso, deve ser digitado o caminho completo no servidor<br><br>";
  896 + echo "Utilize o sistema de administracao do i3Geo para configurar quais os temas da pasta i3geo/temas podem ser utilizados.<br><br>";
  897 + echo "Utilize o parametro restauramapa para indicar o ID de um mapa salvo no banco <br>";
  898 + echo "de dados de administracao para utiliza-lo como um WMS";
962 } 899 }
963 function ogc_imprimeListaDeTemas(){ 900 function ogc_imprimeListaDeTemas(){
964 global $urli3geo,$perfil,$locaplic; 901 global $urli3geo,$perfil,$locaplic;
@@ -975,17 +912,17 @@ function ogc_imprimeListaDeTemas(){ @@ -975,17 +912,17 @@ function ogc_imprimeListaDeTemas(){
975 foreach($grupo["subgrupos"] as $sgrupo){ 912 foreach($grupo["subgrupos"] as $sgrupo){
976 if(strtolower($sgrupo["ogc"]) == "sim"){ 913 if(strtolower($sgrupo["ogc"]) == "sim"){
977 $imprimesubgrupo = $sgrupo["nome"]; 914 $imprimesubgrupo = $sgrupo["nome"];
978 - $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]);  
979 - foreach($temas as $tema){  
980 - if(strtolower($tema["ogc"]) == "sim"){ 915 + $lts = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]);
  916 + foreach($lts as $t){
  917 + if(strtolower($t["ogc"]) == "sim"){
981 $imprimir .= texto2iso($imprimegrupo)."->".texto2iso($imprimesubgrupo)."<br>"; 918 $imprimir .= texto2iso($imprimegrupo)."->".texto2iso($imprimesubgrupo)."<br>";
982 $imprimir .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; 919 $imprimir .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
983 - $imprimir .= "<span style=color:red >".$tema["tid"]."</span>";  
984 - $imprimir .= "&nbsp;-&nbsp;".texto2iso($tema["nome"])."&nbsp";  
985 - $imprimir .= "&nbsp;<a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&service=wms&request=getcapabilities' >Getcapabilities</a>";  
986 - $imprimir .= "&nbsp;<a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&SRS=EPSG:4618&WIDTH=500&HEIGHT=500&BBOX=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&FORMAT=image/png&service=wms&version=1.1.0&request=getmap&layers=".$tema["tid"]."' >GetMap </a>";  
987 - if($tema["link"] != " ")  
988 - $imprimir .= "&nbsp;&nbsp;<a href='".$tema["link"]."' >fonte</a>"; 920 + $imprimir .= "<span style=color:red >".$t["tid"]."</span>";
  921 + $imprimir .= "&nbsp;-&nbsp;".texto2iso($t["nome"])."&nbsp";
  922 + $imprimir .= "&nbsp;<a href='".$urli3geo."/ogc.php?tema=".$t["tid"]."&service=wms&request=getcapabilities' >Getcapabilities</a>";
  923 + $imprimir .= "&nbsp;<a href='".$urli3geo."/ogc.php?tema=".$t["tid"]."&SRS=EPSG:4618&WIDTH=500&HEIGHT=500&BBOX=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&FORMAT=image/png&service=wms&version=1.1.0&request=getmap&layers=".$t["tid"]."' >GetMap </a>";
  924 + if($t["link"] != " ")
  925 + $imprimir .= "&nbsp;&nbsp;<a href='".$t["link"]."' >fonte</a>";
989 $imprimir .= "<br>"; 926 $imprimir .= "<br>";
990 } 927 }
991 } 928 }
@@ -1011,17 +948,17 @@ function ogc_imprimeListaDeTemasWfs(){ @@ -1011,17 +948,17 @@ function ogc_imprimeListaDeTemasWfs(){
1011 foreach($grupo["subgrupos"] as $sgrupo){ 948 foreach($grupo["subgrupos"] as $sgrupo){
1012 if(strtolower($sgrupo["ogc"]) == "sim"){ 949 if(strtolower($sgrupo["ogc"]) == "sim"){
1013 $imprimesubgrupo = $sgrupo["nome"]; 950 $imprimesubgrupo = $sgrupo["nome"];
1014 - $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]);  
1015 - foreach($temas as $tema){  
1016 - if(strtolower($tema["ogc"]) == "sim" && strtolower($tema["down"]) !== "nao"){ 951 + $lts = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]);
  952 + foreach($lts as $t){
  953 + if(strtolower($t["ogc"]) == "sim" && strtolower($t["down"]) !== "nao"){
1017 $imprimir .= $imprimegrupo."->".$imprimesubgrupo."<br>"; 954 $imprimir .= $imprimegrupo."->".$imprimesubgrupo."<br>";
1018 $imprimir .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; 955 $imprimir .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
1019 - $imprimir .= "<span style=color:red >".$tema["tid"]."</span>";  
1020 - $imprimir .= "&nbsp;-&nbsp;".$tema["nome"]."&nbsp";  
1021 - $imprimir .= "&nbsp;<a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&service=wfs&request=getcapabilities' >Getcapabilities</a>";  
1022 - $imprimir .= "&nbsp;<a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&SRS=EPSG:4618&service=wfs&version=1.1.0&request=getfeature&typename=".$tema["tid"]."' >Getfeature </a>";  
1023 - if($tema["link"] != " ")  
1024 - $imprimir .= "&nbsp;&nbsp;<a href='".$tema["link"]."' >fonte</a>"; 956 + $imprimir .= "<span style=color:red >".$t["tid"]."</span>";
  957 + $imprimir .= "&nbsp;-&nbsp;".$t["nome"]."&nbsp";
  958 + $imprimir .= "&nbsp;<a href='".$urli3geo."/ogc.php?tema=".$t["tid"]."&service=wfs&request=getcapabilities' >Getcapabilities</a>";
  959 + $imprimir .= "&nbsp;<a href='".$urli3geo."/ogc.php?tema=".$t["tid"]."&SRS=EPSG:4618&service=wfs&version=1.1.0&request=getfeature&typename=".$t["tid"]."' >Getfeature </a>";
  960 + if($t["link"] != " ")
  961 + $imprimir .= "&nbsp;&nbsp;<a href='".$t["link"]."' >fonte</a>";
1025 $imprimir .= "<br>"; 962 $imprimir .= "<br>";
1026 } 963 }
1027 } 964 }
@@ -1048,7 +985,7 @@ function carregaCacheImagem($cachedir,$map,$tms){ @@ -1048,7 +985,7 @@ function carregaCacheImagem($cachedir,$map,$tms){
1048 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); 985 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200);
1049 $etag = md5_file($nome); 986 $etag = md5_file($nome);
1050 header('Etag: '.$etag); 987 header('Etag: '.$etag);
1051 - fpassthru(fopen($nome, 'rb')); 988 + readfile($nome);
1052 exit; 989 exit;
1053 } 990 }
1054 } 991 }
@@ -1084,7 +1021,7 @@ function salvaCacheImagem($cachedir,$map,$tms){ @@ -1084,7 +1021,7 @@ function salvaCacheImagem($cachedir,$map,$tms){
1084 header('Cache-Control: max-age=3600, must-revalidate'); 1021 header('Cache-Control: max-age=3600, must-revalidate');
1085 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); 1022 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT');
1086 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); 1023 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200);
1087 - fpassthru(fopen($nome, 'rb')); 1024 + readfile($nome);
1088 exit; 1025 exit;
1089 } 1026 }
1090 function texto2iso($texto){ 1027 function texto2iso($texto){
@@ -1135,7 +1072,7 @@ function renderNocacheTms(){ @@ -1135,7 +1072,7 @@ function renderNocacheTms(){
1135 header('Cache-Control: max-age=3600, must-revalidate'); 1072 header('Cache-Control: max-age=3600, must-revalidate');
1136 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); 1073 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT');
1137 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200); 1074 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200);
1138 - fpassthru(fopen($nomer, 'rb')); 1075 + readfile($nomer);
1139 } 1076 }
1140 if($i3georendermode == 2){ 1077 if($i3georendermode == 2){
1141 ob_clean(); 1078 ob_clean();
@@ -1145,6 +1082,129 @@ function renderNocacheTms(){ @@ -1145,6 +1082,129 @@ function renderNocacheTms(){
1145 header("Content-type: image/png"); 1082 header("Content-type: image/png");
1146 } 1083 }
1147 } 1084 }
  1085 +function getfeatureinfoJson(){
  1086 + global $req, $oMap;
  1087 + $req->setParameter("info_format","application/vnd.ogc.gml");
  1088 + $oMap->owsdispatch($req);
  1089 + ms_iostripstdoutbuffercontentheaders();
  1090 + ob_clean();
  1091 + $r = ms_iogetstdoutbufferstring();
  1092 + //$r = converteenc($r);
  1093 + $nome = $oMap->getlayer(0)->name;
  1094 + $xml = simplexml_load_string($r);
  1095 +
  1096 + $json = json_encode($xml);
  1097 + $r = json_decode($json,TRUE);
  1098 + $propriedades = $r[$nome."_layer"];
  1099 + $propriedades = $propriedades[$nome."_feature"];
  1100 + $propriedades = converteenc(json_encode($propriedades));
  1101 + $propriedades = json_decode($propriedades);
  1102 + $n = array();
  1103 + $n[] = array (
  1104 + "type" => "FeatureCollection",
  1105 + "features" => array(
  1106 + array(
  1107 + "type"=>"Feature",
  1108 + "id" => "",
  1109 + "geometry" => array(),
  1110 + "properties" => array(
  1111 + $propriedades
  1112 + ),
  1113 + "geometry_name" => ""
  1114 + )
  1115 + )
  1116 + );
  1117 + header("Content-type: application/json");
  1118 + $json = json_encode($n[0]);
  1119 + //verifica a substituicao de alias
  1120 + $itens = $oMap->getlayer(0)->getmetadata("ITENS"); // itens
  1121 + $itensdesc = $oMap->getlayer(0)->getmetadata("ITENSDESC"); // descri&ccedil;&atilde;o dos itens
  1122 + $itens = explode(",",$itens);
  1123 + $itensdesc = explode(",",converteenc($itensdesc));
  1124 + $n = count($itens);
  1125 + for($i = 0; $i < $n; $i++){
  1126 + $json = str_ireplace($itens[$i],$itensdesc[$i],$json);
  1127 + }
  1128 + echo $json;
  1129 +}
  1130 +function processaOutputformatMapfile(){
  1131 + global $OUTPUTFORMAT, $oMap, $tema;
  1132 + if(strtolower($OUTPUTFORMAT) == "shape-zip"){
  1133 + $l = $oMap->getlayer(0);
  1134 + $n = $l->name;
  1135 + $oMap->selectOutputFormat("shape-zip");
  1136 + $oMap->outputformat->setOption("STORAGE", "filesystem");
  1137 + $oMap->outputformat->setOption("FORM", "zip");
  1138 + $oMap->outputformat->setOption("FILENAME", $tema."_shapefile.zip");
  1139 + $l->setmetadata("wfs_getfeature_formatlist","shape-zip");
  1140 + }
  1141 + if(strtolower($OUTPUTFORMAT) == "csv"){
  1142 + $l = $oMap->getlayer(0);
  1143 + $n = $l->name."-csv";
  1144 + $oMap->selectOutputFormat("csv");
  1145 + $oMap->outputformat->setOption("STORAGE", "filesystem");
  1146 + $oMap->outputformat->setOption("FILENAME", $tema.".csv");
  1147 + $oMap->outputformat->setOption("FORM", "simple");
  1148 + $l->setmetadata("wfs_getfeature_formatlist","csv");
  1149 + }
  1150 + if(strtolower($OUTPUTFORMAT) == "geojson" || strtolower($OUTPUTFORMAT) == "json"){
  1151 + $l = $oMap->getlayer(0);
  1152 + $oMap->selectOutputFormat("geojson");
  1153 + $l->setmetadata("wfs_getfeature_formatlist","geojson");
  1154 + }
  1155 +}
  1156 +function carregaCacheArquivo(){
  1157 + global $dir_tmp, $tema, $OUTPUTFORMAT;
  1158 + if(strtolower($OUTPUTFORMAT) == "shape-zip"){
  1159 + $arq = $dir_tmp."/".$tema."_shapefile.zip";
  1160 + if(file_exists($arq)){
  1161 + header('Content-Disposition: attachment; filename='.$tema.'_shapefile.zip');
  1162 + readfile($arq);
  1163 + exit;
  1164 + }
  1165 + }
  1166 + if(strtolower($OUTPUTFORMAT) == "csv"){
  1167 + $arq = $dir_tmp."/".$tema.".csv";
  1168 + if(file_exists($arq)){
  1169 + header('Content-Disposition: attachment; filename='.$tema.'.csv');
  1170 + header("Content-type: text/csv");
  1171 + readfile($arq);
  1172 + exit;
  1173 + }
  1174 + }
  1175 + if(strtolower($OUTPUTFORMAT) == "geojson" || strtolower($OUTPUTFORMAT) == "json"){
  1176 + $arq = $dir_tmp."/".$tema.".json";
  1177 + if(file_exists($arq)){
  1178 + header("Content-type: application/json; subtype=geojson");
  1179 + readfile($arq);
  1180 + exit;
  1181 + }
  1182 + }
  1183 +}
  1184 +function restauraMapaSalvo(){
  1185 + global $restauramapa, $dir_tmp, $tema;
  1186 + $xbase = restauraMapaAdmin($restauramapa,$dir_tmp);
  1187 + $m = ms_newMapObj($xbase);
  1188 + $w = $m->web;
  1189 + $w->set("imagepath",dirname($w->imagepath)."/");
  1190 + $w->set("imageurl",dirname($w->imageurl)."/");
  1191 + //apaga algumas camadas
  1192 + $l = $m->getlayerbyname("rosadosventos");
  1193 + if($l != ""){
  1194 + $l->set("status",MS_DELETE);
  1195 + }
  1196 + $l = $m->getlayerbyname("copyright");
  1197 + if($l != ""){
  1198 + $l->set("status",MS_DELETE);
  1199 + }
  1200 + $m->save($xbase);
  1201 + //$fundo = $xbase;
  1202 + $tema = $xbase;
  1203 + $_GET["tema"] = $xbase;
  1204 + $_GET["layers"] = "";
  1205 + $l = $m->getlayer(0);
  1206 + $_GET["LAYERS"] = $l->name;
  1207 +}
1148 function converteenc($texto){ 1208 function converteenc($texto){
1149 if (!mb_detect_encoding($texto,"UTF-8",true)){ 1209 if (!mb_detect_encoding($texto,"UTF-8",true)){
1150 $texto = mb_convert_encoding($texto,"UTF-8","ISO-8859-1"); 1210 $texto = mb_convert_encoding($texto,"UTF-8","ISO-8859-1");