Commit a00fad965ca93ce4ab39f9a6981788483f7627b3

Authored by Edmar Moretti
1 parent 7e00ed44

Implementação da nomenclatura do padrão TMS para o cache de imagens

admin/admin.db
No preview for this file type
aplicmap/ogcwsv6.map
@@ -93,7 +93,8 @@ MAP @@ -93,7 +93,8 @@ MAP
93 "ows_city" "Brasilia" 93 "ows_city" "Brasilia"
94 "ows_contactperson" "Web Master" 94 "ows_contactperson" "Web Master"
95 "ows_addresstype" "uri" 95 "ows_addresstype" "uri"
96 - "ows_context_version" "1.0.0" 96 + "ows_context_version" "1.1.0"
  97 + "wms_getcapabilities_version" "1.1.0"
97 "ows_abstract" "Web services gerados da base de dados do i3Geo. Para chamar um tema especificamente, veja o sistema de ajuda, digitando no navegador web ogc.php?ajuda=, para uma lista compacta de todos os servicos, digite ogc.php?lista=temas" 98 "ows_abstract" "Web services gerados da base de dados do i3Geo. Para chamar um tema especificamente, veja o sistema de ajuda, digitando no navegador web ogc.php?ajuda=, para uma lista compacta de todos os servicos, digite ogc.php?lista=temas"
98 "ows_contactposition" "Administrador do sitio web" 99 "ows_contactposition" "Administrador do sitio web"
99 "ows_stateorprovince" "DF" 100 "ows_stateorprovince" "DF"
classesjs/classe_interface.js
@@ -987,13 +987,10 @@ i3GEO.Interface = { @@ -987,13 +987,10 @@ i3GEO.Interface = {
987 temp = camada.type === 0 ? opcoes.gutter = 20 : opcoes.gutter = 0; 987 temp = camada.type === 0 ? opcoes.gutter = 20 : opcoes.gutter = 0;
988 temp = camada.transitioneffect === "nao" ? opcoes.transitionEffect = "null" : opcoes.transitionEffect = "resize"; 988 temp = camada.transitioneffect === "nao" ? opcoes.transitionEffect = "null" : opcoes.transitionEffect = "resize";
989 // 989 //
990 - //layers marcados com o metadata wms_tile com valor 1 sao inseridos com Layer.TileCache 990 + //layers marcados com o metadata wmstile com valor 1 sao inseridos com Layer.TileCache
991 // 991 //
992 if(camada.connectiontype === 7 && camada.wmsurl !== "" && camada.usasld.toLowerCase() != "sim"){ 992 if(camada.connectiontype === 7 && camada.wmsurl !== "" && camada.usasld.toLowerCase() != "sim"){
993 urllayer = camada.wmsurl+"&r="+Math.random(); 993 urllayer = camada.wmsurl+"&r="+Math.random();
994 - /**  
995 - * TODO não funciona  
996 - */  
997 if(camada.wmstile == 1){ 994 if(camada.wmstile == 1){
998 layer = new OpenLayers.Layer.TMS(camada.name, camada.wmsurl,{isBaseLayer:false,layername:camada.wmsname,type:'png'}); 995 layer = new OpenLayers.Layer.TMS(camada.name, camada.wmsurl,{isBaseLayer:false,layername:camada.wmsname,type:'png'});
999 } 996 }
@@ -1009,17 +1006,40 @@ i3GEO.Interface = { @@ -1009,17 +1006,40 @@ i3GEO.Interface = {
1009 else{ 1006 else{
1010 temp = camada.type === 3 ? opcoes.singleTile = false : opcoes.singleTile = !(i3GEO.Interface.openlayers.TILES); 1007 temp = camada.type === 3 ? opcoes.singleTile = false : opcoes.singleTile = !(i3GEO.Interface.openlayers.TILES);
1011 } 1008 }
1012 - if(camada.wmstile == 1){  
1013 - layer = new OpenLayers.Layer.TileCache(camada.name, urllayer,{LAYERS:camada.name,map_imagetype:i3GEO.Interface.OUTPUTFORMAT},opcoes); 1009 + if(opcoes.singleTile === true){
  1010 + layer = new OpenLayers.Layer.WMS(
  1011 + camada.name,
  1012 + urllayer,
  1013 + {
  1014 + LAYERS:camada.name,
  1015 + format:camada.wmsformat,
  1016 + transparent:true
  1017 + },
  1018 + opcoes
  1019 + );
  1020 + //layer = new OpenLayers.Layer.TileCache(camada.name, urllayer,{LAYERS:camada.name,map_imagetype:i3GEO.Interface.OUTPUTFORMAT},opcoes);
1014 } 1021 }
1015 else{ 1022 else{
1016 - layer = new OpenLayers.Layer.WMS(camada.name, urllayer,{LAYERS:camada.name,map_imagetype:i3GEO.Interface.OUTPUTFORMAT},opcoes); 1023 + layer = new OpenLayers.Layer.TMS(
  1024 + camada.name,
  1025 + urllayer,
  1026 + {
  1027 + isBaseLayer:false,
  1028 + serviceVersion:"&tms=",
  1029 + type:"png",
  1030 + layername:camada.name,
  1031 + map_imagetype:i3GEO.Interface.OUTPUTFORMAT,
  1032 + tileOrigin: new OpenLayers.LonLat(-180, -90)
  1033 + },
  1034 + opcoes
  1035 + );
1017 } 1036 }
1018 } 1037 }
1019 } 1038 }
1020 catch(e){} 1039 catch(e){}
1021 - if(camada.escondido.toLowerCase() === "sim")  
1022 - {layer.transitionEffect = "null";} 1040 + if(camada.escondido.toLowerCase() === "sim"){
  1041 + layer.transitionEffect = "null";
  1042 + }
1023 i3geoOL.addLayer(layer); 1043 i3geoOL.addLayer(layer);
1024 } 1044 }
1025 else 1045 else
classesphp/mapa_googlemaps.php
@@ -102,6 +102,8 @@ $x++; @@ -102,6 +102,8 @@ $x++;
102 $y++; 102 $y++;
103 $lon2 = $x / $n * 360.0 - 180.0; 103 $lon2 = $x / $n * 360.0 - 180.0;
104 $lat1 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n)))); 104 $lat1 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n))));
  105 +$x--;
  106 +$y--;
105 107
106 $projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137"); 108 $projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137");
107 $projOutObj = ms_newprojectionobj("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"); 109 $projOutObj = ms_newprojectionobj("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");
@@ -156,10 +158,6 @@ if(!isset($_GET["telaR"])){ @@ -156,10 +158,6 @@ if(!isset($_GET["telaR"])){
156 if($layerName == $_GET["layer"]){ 158 if($layerName == $_GET["layer"]){
157 if(strtolower($l->getmetadata("cache")) == "sim"){ 159 if(strtolower($l->getmetadata("cache")) == "sim"){
158 $cache = true; 160 $cache = true;
159 - $nomecache = $l->getmetadata("nomeoriginal");  
160 - if($nomecache == ""){  
161 - $nomecache = $layerName;  
162 - }  
163 } 161 }
164 } 162 }
165 } 163 }
@@ -312,6 +310,7 @@ function salvaCacheImagem(){ @@ -312,6 +310,7 @@ function salvaCacheImagem(){
312 if(!file_exists($c."/$y.png")){ 310 if(!file_exists($c."/$y.png")){
313 mkdir($cachedir."/googlemaps/$layer/$z/$x",0777,true); 311 mkdir($cachedir."/googlemaps/$layer/$z/$x",0777,true);
314 $img->saveImage($c."/$y.png"); 312 $img->saveImage($c."/$y.png");
  313 + chmod($c."/$y.png",0777);
315 } 314 }
316 return $nome; 315 return $nome;
317 } 316 }
classesphp/mapa_openlayers.php
@@ -62,16 +62,39 @@ error_reporting(0); @@ -62,16 +62,39 @@ error_reporting(0);
62 //carrega dados da seção, verifica segurança 62 //carrega dados da seção, verifica segurança
63 inicializa(); 63 inicializa();
64 // 64 //
65 -//map_fileX é necessário caso register_globals = On no PHP.INI 65 +//calcula a extensao geografica com base no x,y,z
  66 +//nos casos do modo notile, a requisicao e feita como se fosse um wms
  67 +//quando for do tipo tms $_GET["tms"] contem os parametros do tile
  68 +if(isset($_GET["tms"])){
  69 + $_GET["WIDTH"] = 256;
  70 + $_GET["HEIGHT"] = 256;
  71 + $temp = explode("/",$_GET["tms"]);
  72 + $z = $temp[2];
  73 + $x = $temp[3];
  74 + $y = str_replace(".png","",$temp[4]);
  75 +
  76 + $n = pow(2,$z+1);
  77 + $lon1 = $x / $n * 360.0 - 180.0;
  78 + $lon2 = ($x+1) / $n * 360.0 - 180.0;
  79 + $n = pow(2,$z);
  80 + $lat1 = $y / $n * 180.0 - 90.0;
  81 + $lat2 = ($y+1) / $n * 180.0 - 90.0;
  82 + $_GET["BBOX"] = $lon1." ".$lat1." ".$lon2." ".$lat2;
  83 +}
  84 +
  85 +//
  86 +//map_fileX e para o caso register_globals = On no PHP.INI
66 $map_fileX = $_SESSION["map_file"]; 87 $map_fileX = $_SESSION["map_file"];
67 -if(isset($_GET["tipolayer"]) && $_GET["tipolayer"] == "fundo")  
68 -{$map_fileX = str_replace(".map","fundo.map",$map_fileX);} 88 +if(isset($_GET["tipolayer"]) && $_GET["tipolayer"] == "fundo"){
  89 + $map_fileX = str_replace(".map","fundo.map",$map_fileX);
  90 +}
69 $postgis_mapa = $_SESSION["postgis_mapa"]; 91 $postgis_mapa = $_SESSION["postgis_mapa"];
70 $cachedir = $_SESSION["cachedir"]; 92 $cachedir = $_SESSION["cachedir"];
71 if(isset($_GET["BBOX"])){ 93 if(isset($_GET["BBOX"])){
72 $_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]); 94 $_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]);
73 $_GET["map_size"] = $_GET["WIDTH"]." ".$_GET["HEIGHT"]; 95 $_GET["map_size"] = $_GET["WIDTH"]." ".$_GET["HEIGHT"];
74 } 96 }
  97 +$_GET["TIPOIMAGEM"] = trim($_GET["TIPOIMAGEM"]);
75 $mapa = ms_newMapObj($map_fileX); 98 $mapa = ms_newMapObj($map_fileX);
76 // 99 //
77 //resolve o problema da seleção na versão nova do mapserver 100 //resolve o problema da seleção na versão nova do mapserver
@@ -84,28 +107,24 @@ $qy = file_exists($qyfile); @@ -84,28 +107,24 @@ $qy = file_exists($qyfile);
84 if(!isset($_GET["telaR"])){//no caso de projecoes remotas, o mapfile nao e alterado 107 if(!isset($_GET["telaR"])){//no caso de projecoes remotas, o mapfile nao e alterado
85 $numlayers = $mapa->numlayers; 108 $numlayers = $mapa->numlayers;
86 $cache = false; 109 $cache = false;
87 - for($i = 0;$i < $numlayers;++$i)  
88 - { 110 + for($i = 0;$i < $numlayers;++$i){
89 $l = $mapa->getLayer($i); 111 $l = $mapa->getLayer($i);
90 - if ($l->getmetadata("classesnome") != "")  
91 - {  
92 - if(!function_exists("autoClasses"))  
93 - {include_once("funcoes_gerais.php");}  
94 - autoClasses($l,$mapa);  
95 - }  
96 $layerName = $l->name; 112 $layerName = $l->name;
97 - if($layerName != $_GET["layer"])  
98 - {$l->set("status",MS_OFF);}  
99 - if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != "")  
100 - { 113 + if($layerName != $_GET["layer"]){
  114 + $l->set("status",MS_OFF);
  115 + }
  116 + if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != ""){
  117 + if ($l->getmetadata("classesnome") != ""){
  118 + if(!function_exists("autoClasses"))
  119 + {include_once("funcoes_gerais.php");}
  120 + autoClasses($l,$mapa);
  121 + }
101 $l->set("status",MS_DEFAULT); 122 $l->set("status",MS_DEFAULT);
102 - if (!empty($postgis_mapa))  
103 - {  
104 - if ($l->connectiontype == MS_POSTGIS)  
105 - { 123 + $l->set("template","none.htm");
  124 + if (!empty($postgis_mapa)){
  125 + if ($l->connectiontype == MS_POSTGIS){
106 $lcon = $l->connection; 126 $lcon = $l->connection;
107 - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa))))  
108 - { 127 + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
109 if(($lcon == " ") || ($lcon == "")) 128 if(($lcon == " ") || ($lcon == ""))
110 {$l->set("connection",$postgis_mapa);} 129 {$l->set("connection",$postgis_mapa);}
111 else 130 else
@@ -114,17 +133,15 @@ if(!isset($_GET[&quot;telaR&quot;])){//no caso de projecoes remotas, o mapfile nao e alter @@ -114,17 +133,15 @@ if(!isset($_GET[&quot;telaR&quot;])){//no caso de projecoes remotas, o mapfile nao e alter
114 } 133 }
115 } 134 }
116 } 135 }
117 - if($layerName == $_GET["layer"])  
118 - {  
119 - if(strtolower($l->getmetadata("cache")) == "sim")  
120 - { 136 + if($layerName == $_GET["layer"]){
  137 + if(strtolower($l->getmetadata("cache")) == "sim"){
121 $cache = true; 138 $cache = true;
122 $nomecache = $l->getmetadata("nomeoriginal"); 139 $nomecache = $l->getmetadata("nomeoriginal");
123 - if($nomecache == "")  
124 - {$nomecache = $layerName;} 140 + if($nomecache == ""){
  141 + $nomecache = $layerName;
  142 + }
125 } 143 }
126 } 144 }
127 - $l->set("template","none.htm");  
128 if($_GET["REQUEST"] == "GetFeatureInfo" || $_GET["REQUEST"] == "getfeature"){ 145 if($_GET["REQUEST"] == "GetFeatureInfo" || $_GET["REQUEST"] == "getfeature"){
129 $l->setmetadata("gml_include_items","all"); 146 $l->setmetadata("gml_include_items","all");
130 $l->setmetadata("WMS_INCLUDE_ITEMS","all"); 147 $l->setmetadata("WMS_INCLUDE_ITEMS","all");
@@ -135,21 +152,22 @@ if(!isset($_GET[&quot;telaR&quot;])){//no caso de projecoes remotas, o mapfile nao e alter @@ -135,21 +152,22 @@ if(!isset($_GET[&quot;telaR&quot;])){//no caso de projecoes remotas, o mapfile nao e alter
135 } 152 }
136 } 153 }
137 } 154 }
  155 +if (!function_exists('imagepng'))
  156 +{$_GET["TIPOIMAGEM"] = "";}
  157 +
138 if($_GET["layer"] == "") 158 if($_GET["layer"] == "")
139 {$cache = true;} 159 {$cache = true;}
140 -if($_GET == false)  
141 -{$cache = false;}  
142 -if(!empty($_GET["DESLIGACACHE"])){  
143 - if(strtolower($_GET["DESLIGACACHE"]) == "sim")  
144 - {$cache = false;} 160 +
  161 +if(($_GET == false) || ($qy) || (strtolower($_GET["DESLIGACACHE"]) == "sim")){
  162 + $cache = false;
145 } 163 }
146 -if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") 164 +elseif($_GET["TIPOIMAGEM"] != "" && $_GET["TIPOIMAGEM"] != "nenhum")
147 {$cache = false;} 165 {$cache = false;}
148 -if($qy)  
149 -{$cache = false;}  
150 -if($cache == true)  
151 -{carregaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);}  
152 166
  167 +if($cache == true){
  168 + //carregaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);
  169 + carregaCacheImagem($cachedir,$map,$tms);
  170 +}
153 $map_size = explode(" ",$_GET["map_size"]); 171 $map_size = explode(" ",$_GET["map_size"]);
154 $mapa->setsize($map_size[0],$map_size[1]); 172 $mapa->setsize($map_size[0],$map_size[1]);
155 if(isset($_GET["mapext"])){ 173 if(isset($_GET["mapext"])){
@@ -191,11 +209,9 @@ if(!isset($_GET[&quot;telaR&quot;])){ @@ -191,11 +209,9 @@ if(!isset($_GET[&quot;telaR&quot;])){
191 // 209 //
192 if($_GET["tipolayer"] != "fundo") 210 if($_GET["tipolayer"] != "fundo")
193 {$o->set("transparent",MS_TRUE);} 211 {$o->set("transparent",MS_TRUE);}
194 -  
195 if($qy != true) 212 if($qy != true)
196 {$img = $mapa->draw();} 213 {$img = $mapa->draw();}
197 -else  
198 -{ 214 +else{
199 $handle = fopen ($qyfile, "r"); 215 $handle = fopen ($qyfile, "r");
200 $conteudo = fread ($handle, filesize ($qyfile)); 216 $conteudo = fread ($handle, filesize ($qyfile));
201 fclose ($handle); 217 fclose ($handle);
@@ -240,17 +256,8 @@ else @@ -240,17 +256,8 @@ else
240 } 256 }
241 $cache = false; 257 $cache = false;
242 } 258 }
243 -if (!function_exists('imagepng'))  
244 -{  
245 - $s = PHP_SHLIB_SUFFIX;  
246 - @dl( 'php_gd.'.$s );  
247 - if (!function_exists('imagepng'))  
248 - {@dl( 'php_gd2.'.$s );}  
249 - if (!function_exists('imagepng'))  
250 - {$_GET["TIPOIMAGEM"] = "";}  
251 -}  
252 -if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum")  
253 -{ 259 +
  260 +if($_GET["TIPOIMAGEM"] != "" && $_GET["TIPOIMAGEM"] != "nenhum"){
254 if($img->imagepath == "") 261 if($img->imagepath == "")
255 {echo "Erro IMAGEPATH vazio";exit;} 262 {echo "Erro IMAGEPATH vazio";exit;}
256 $nomer = ($img->imagepath)."filtroimgtemp".nomeRand().".png"; 263 $nomer = ($img->imagepath)."filtroimgtemp".nomeRand().".png";
@@ -266,53 +273,58 @@ if(trim($_GET[&quot;TIPOIMAGEM&quot;]) != &quot;&quot; &amp;&amp; trim($_GET[&quot;TIPOIMAGEM&quot;]) != &quot;nenhum&quot;) @@ -266,53 +273,58 @@ if(trim($_GET[&quot;TIPOIMAGEM&quot;]) != &quot;&quot; &amp;&amp; trim($_GET[&quot;TIPOIMAGEM&quot;]) != &quot;nenhum&quot;)
266 } 273 }
267 else{ 274 else{
268 if($cache == true){ 275 if($cache == true){
269 - $nomer = salvaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]); 276 + //$nomer = salvaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);
  277 + $nomer = salvaCacheImagem($cachedir,$map_fileX,$_GET["tms"]);
270 header('Content-Length: '.filesize($nomer)); 278 header('Content-Length: '.filesize($nomer));
271 header('Content-Type: image/png'); 279 header('Content-Type: image/png');
272 header('Cache-Control: max-age=3600, must-revalidate'); 280 header('Cache-Control: max-age=3600, must-revalidate');
273 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); 281 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT');
274 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200); 282 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200);
275 - //$etag = md5_file($nomer);  
276 - //header('Etag: '.$etag);  
277 fpassthru(fopen($nomer, 'rb')); 283 fpassthru(fopen($nomer, 'rb'));
278 } 284 }
279 else{ 285 else{
280 if($img->imagepath == "") 286 if($img->imagepath == "")
281 {echo "Erro IMAGEPATH vazio";exit;} 287 {echo "Erro IMAGEPATH vazio";exit;}
282 - /*  
283 - $nomer = ($img->imagepath)."imgtemp".nomeRand().".png";  
284 - $img->saveImage($nomer);  
285 - header('Content-Length: '.filesize($nomer));  
286 - header('Content-Type: image/png');  
287 - fpassthru(fopen($nomer, 'rb'));  
288 - */  
289 header('Content-Type: image/png'); 288 header('Content-Type: image/png');
290 $img->saveImage(); 289 $img->saveImage();
291 } 290 }
292 exit; 291 exit;
293 } 292 }
294 -function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){  
295 - global $img,$map_size;  
296 - //echo "oi".$cachedir;exit;  
297 - //layers que s&atilde;o sempre iguais  
298 - if($layer == "copyright" || $layer == "")  
299 - {$bbox = "";}  
300 - if($layer == "")  
301 - {$layer = "fundo";}  
302 - if($cachedir == "")  
303 - {$cachedir = dirname(dirname($map))."/cache/".$layer;}  
304 - else  
305 - {$cachedir = $cachedir."/".$layer;}  
306 - $nome = $cachedir."/".$w.$h.$bbox.".png";  
307 - if(!file_exists($nome))  
308 - {  
309 - @mkdir($cachedir,0777);  
310 - $img->saveImage($nome);  
311 - chmod($nome,0777); 293 +function salvaCacheImagem($cachedir,$map,$tms){
  294 + global $img;
  295 + if($cachedir == ""){
  296 + $nome = dirname(dirname($map))."/cache".$tms;
  297 + }
  298 + else{
  299 + $nome = $cachedir.$tms;
312 } 300 }
313 - return $nome; 301 + if(!file_exists($nome)){
  302 + @mkdir(dirname($nome),0777,true);
  303 + $img->saveImage($nome);
  304 + chmod($nome,0777);
  305 + }
  306 + return $nome;
  307 +}
  308 +function carregaCacheImagem($cachedir,$map,$tms){
  309 + if($cachedir == ""){
  310 + $nome = dirname(dirname($map))."/cache".$tms;
  311 + }
  312 + else{
  313 + $nome = $cachedir.$tms;
  314 + }
  315 + if(file_exists($nome)){
  316 + header('Content-Length: '.filesize($nome));
  317 + header('Content-Type: image/png');
  318 + header('Cache-Control: max-age=3600, must-revalidate');
  319 + header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT');
  320 + header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200);
  321 + $etag = md5_file($nome);
  322 + header('Etag: '.$etag);
  323 + fpassthru(fopen($nome, 'rb'));
  324 + exit;
  325 + }
314 } 326 }
315 -function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ 327 +function XcarregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){
316 if($layer == "copyright" || $layer == "") 328 if($layer == "copyright" || $layer == "")
317 {$bbox = "";} 329 {$bbox = "";}
318 if($layer == "") 330 if($layer == "")
@@ -322,28 +334,7 @@ function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ @@ -322,28 +334,7 @@ function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){
322 {$nome = dirname(dirname($map))."/cache/".$layer."/".$nome;} 334 {$nome = dirname(dirname($map))."/cache/".$layer."/".$nome;}
323 else 335 else
324 {$nome = $cachedir."/".$layer."/".$nome;} 336 {$nome = $cachedir."/".$layer."/".$nome;}
325 - if(file_exists($nome))  
326 - {  
327 -/*  
328 - header('Accept-Ranges: bytes');  
329 - header('Content-Length: '.filesize($nome));  
330 - header('Content-Type: image/png');  
331 - ob_start;  
332 - ob_flush();  
333 - readfile($nome);  
334 - exit;  
335 -  
336 - ob_start();  
337 - // assuming you have image data in $imagedata  
338 - $img = file_get_contents($nome);  
339 - $length = strlen($img);  
340 - header('Accept-Ranges: bytes');  
341 - header('Content-Length: '.$length);  
342 - header('Content-Type: image/png');  
343 - print($img);  
344 - ob_end_flush();  
345 - exit;  
346 -*/ 337 + if(file_exists($nome)){
347 header('Content-Length: '.filesize($nome)); 338 header('Content-Length: '.filesize($nome));
348 header('Content-Type: image/png'); 339 header('Content-Type: image/png');
349 header('Cache-Control: max-age=3600, must-revalidate'); 340 header('Cache-Control: max-age=3600, must-revalidate');
@@ -393,23 +384,15 @@ function filtraImg($nomer,$tipoimagem){ @@ -393,23 +384,15 @@ function filtraImg($nomer,$tipoimagem){
393 } 384 }
394 function inicializa(){ 385 function inicializa(){
395 clearstatcache(); 386 clearstatcache();
396 - //$_COOKIE = array();  
397 - if (!function_exists('ms_GetVersion')){  
398 - $s = PHP_SHLIB_SUFFIX;  
399 - @dl( 'php_mapscript.'.$s );  
400 - $ler_extensoes[] = 'php_mapscript';  
401 - }  
402 - //verifica&ccedil;&atilde;o de seguran&ccedil;a  
403 - //$_SESSION = array();  
404 session_name("i3GeoPHP"); 387 session_name("i3GeoPHP");
405 - if(@$_GET["g_sid"])  
406 - {session_id($_GET["g_sid"]);}  
407 - else  
408 - {ilegal();} 388 + if(@$_GET["g_sid"]){
  389 + session_id($_GET["g_sid"]);
  390 + }
  391 + else{
  392 + ilegal();
  393 + }
409 session_start(); 394 session_start();
410 - //var_dump($_SESSION);exit;  
411 - if(@$_SESSION["fingerprint"])  
412 - { 395 + if(@$_SESSION["fingerprint"]){
413 $f = explode(",",$_SESSION["fingerprint"]); 396 $f = explode(",",$_SESSION["fingerprint"]);
414 if (md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id()) != $f[0] && !in_array($_GET["telaR"],$f) ) 397 if (md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id()) != $f[0] && !in_array($_GET["telaR"],$f) )
415 {ilegal();} 398 {ilegal();}
temas/_llocali.map
@@ -6,7 +6,7 @@ MAP @@ -6,7 +6,7 @@ MAP
6 DATA "/var/www/i3geo/aplicmap/dados/locali.shp" 6 DATA "/var/www/i3geo/aplicmap/dados/locali.shp"
7 METADATA 7 METADATA
8 "METAESTAT_ID_MEDIDA_VARIAVEL" "" 8 "METAESTAT_ID_MEDIDA_VARIAVEL" ""
9 - "cache" "SIM" 9 + "cache" ""
10 "LTEMPOITEMIMAGEM" "" 10 "LTEMPOITEMIMAGEM" ""
11 "TIP" "TIPO,ANOCRIA,NOMELOC" 11 "TIP" "TIPO,ANOCRIA,NOMELOC"
12 "LTEMPOITEMDESCRICAO" "TIPO" 12 "LTEMPOITEMDESCRICAO" "TIPO"
temas/_ltesteinclude.map 0 → 100644
@@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
  1 +MAP
  2 + FONTSET "../symbols/fontes.txt"
  3 + SYMBOLSET "../symbols/simbolos.sym"
  4 + LAYER
  5 + #CONNECTION "user=postgres password=postgres dbname=geosaude host=localhost port=5432"
  6 + INCLUDE "include.map"
  7 + CONNECTIONTYPE POSTGIS
  8 + DATA "the_geom from (select * from i3geo_metaestat.bairros) as foo using unique gid using srid=4326"
  9 + METADATA
  10 + "METAESTAT_ID_MEDIDA_VARIAVEL" ""
  11 + "ID_MEDIDA_VARIAVEL" ""
  12 + "cache" ""
  13 + "CLASSE" "SIM"
  14 + "permitekmz" "nao"
  15 + "METAESTAT_CODIGO_TIPO_REGIAO" ""
  16 + "permitedownload" "sim"
  17 + "metaestat" ""
  18 + "permiteogc" "sim"
  19 + "permitekml" "sim"
  20 + "TEMA" "Bairros IBGE"
  21 + "convcaracter" ""
  22 + END # METADATA
  23 + NAME "w_bairros"
  24 + STATUS DEFAULT
  25 + TEMPLATE "none.htm"
  26 + TILEITEM "location"
  27 + TYPE POLYGON
  28 + UNITS METERS
  29 + CLASS
  30 + NAME ""
  31 + STYLE
  32 + ANGLE 0
  33 + OFFSET 0 0
  34 + OUTLINECOLOR 255 0 0
  35 + SYMBOL "p0"
  36 + END # STYLE
  37 + STYLE
  38 + ANGLE 0
  39 + COLOR 255 255 255
  40 + OFFSET 0 0
  41 + OPACITY 20
  42 + END # STYLE
  43 + END # CLASS
  44 + END # LAYER
  45 +
  46 +END # MAP
  47 +
temas/include.map 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +CONNECTION "user=postgres password=postgres dbname=geosaude host=localhost port=5432"
0 \ No newline at end of file 2 \ No newline at end of file