Commit 7e00ed44ccfc71bdabaafd9ec8c1360fac10d581

Authored by Edmar Moretti
1 parent 0e42554a

Padronização da nomenclatura dos diretórios do cache para a interface googlemaps

admin/admin.db
No preview for this file type
classesphp/mapa_googlemaps.php
... ... @@ -62,30 +62,28 @@ i3geo/classesphp/mapa_googlemaps.php
62 62 //error_reporting(E_ALL);
63 63 error_reporting(0);
64 64 clearstatcache();
65   -if (!function_exists('ms_GetVersion'))
66   -{
67   - $s = PHP_SHLIB_SUFFIX;
68   - @dl( 'php_mapscript.'.$s );
69   - $ler_extensoes[] = 'php_mapscript';
70   -}
71 65 //verificação de segurança
72 66 $_SESSION = array();
73 67 session_name("i3GeoPHP");
74   -if(@$_GET["g_sid"])
75   -{session_id($_GET["g_sid"]);}
76   -else
77   -{ilegal();}
  68 +if(@$_GET["g_sid"]){
  69 + session_id($_GET["g_sid"]);
  70 +}
  71 +else{
  72 + ilegal();
  73 +}
78 74 session_start();
79   -if(@$_SESSION["fingerprint"])
80   -{
  75 +if(@$_SESSION["fingerprint"]){
81 76 $f = explode(",",$_SESSION["fingerprint"]);
82   - if (md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id()) != $f[0] && !in_array($_GET["telaR"],$f) )
83   - {ilegal();}
  77 + if (md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id()) != $f[0] && !in_array($_GET["telaR"],$f) ){
  78 + ilegal();
  79 + }
  80 +}
  81 +else{
  82 + exit;
  83 +}
  84 +if(!isset($_SESSION["map_file"])){
  85 + exit;
84 86 }
85   -else
86   -{exit;}
87   -if(!isset($_SESSION["map_file"]))
88   -{exit;}
89 87 //
90 88 $map_fileX = $_SESSION["map_file"];
91 89 $postgis_mapa = $_SESSION["postgis_mapa"];
... ... @@ -94,15 +92,16 @@ $cachedir = $_SESSION["cachedir"];
94 92 //converte a requisição do tile em coordenadas geo
95 93 //http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#tile_numbers_to_lon.2Flat_2
96 94 //
97   - $x = $_GET["X"];
98   - $y = $_GET["Y"];
99   - $n = pow(2, $_GET["Z"]);
100   - $lon1 = $x / $n * 360.0 - 180.0;
101   - $lat2 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n))));
102   - $x++;
103   - $y++;
104   - $lon2 = $x / $n * 360.0 - 180.0;
105   - $lat1 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n))));
  95 +$x = $_GET["X"];
  96 +$y = $_GET["Y"];
  97 +$z = $_GET["Z"];
  98 +$n = pow(2,$z);
  99 +$lon1 = $x / $n * 360.0 - 180.0;
  100 +$lat2 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n))));
  101 +$x++;
  102 +$y++;
  103 +$lon2 = $x / $n * 360.0 - 180.0;
  104 +$lat1 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n))));
106 105  
107 106 $projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137");
108 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");
... ... @@ -116,70 +115,59 @@ $poPoint2->project($projInObj, $projOutObj);
116 115 $_GET["BBOX"] = $poPoint1->x." ".$poPoint1->y." ".$poPoint2->x." ".$poPoint2->y;
117 116 $_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]);
118 117  
119   -if(!isset($_GET["WIDTH"]))
120   -{$_GET["WIDTH"] = "256";}
121   -if(!isset($_GET["HEIGHT"]))
122   -{$_GET["HEIGHT"] = "256";}
123   -$_GET["map_size"] = $_GET["WIDTH"]." ".$_GET["HEIGHT"];
124   -
125 118 $mapa = ms_newMapObj($map_fileX);
126 119 $ret = $mapa->extent;
127 120 $qyfile = dirname($map_fileX)."/".$_GET["layer"].".php";
128 121 $qy = file_exists($qyfile);
129 122 $cache = false;
130   -if(!isset($_GET["telaR"])){//no caso de projecoes remotas, o mapfile nao´e alterado
131   -
  123 +if(!isset($_GET["telaR"])){
  124 + //no caso de projecoes remotas, o mapfile nao´e alterado
132 125 $numlayers = $mapa->numlayers;
133   - for ($i=0;$i < $numlayers;++$i)
134   - {
  126 + for ($i=0;$i < $numlayers;++$i){
135 127 $l = $mapa->getlayer($i);
136 128 $layerName = $l->name;
137   - if ($l->getmetadata("classesnome") != "")
138   - {
139   - if(!function_exists("autoClasses"))
140   - {include_once("funcoes_gerais.php");}
141   - autoClasses($l,$mapa);
142   - }
143   - if($layerName != $_GET["layer"])
144   - {$l->set("status",MS_OFF);}
145   - if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != "")
146   - {
  129 + $l->set("status",MS_OFF);
  130 + if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != ""){
  131 + $l->set("template","none.htm");
147 132 $l->set("status",MS_DEFAULT);
148   - if (!empty($postgis_mapa))
149   - {
150   - if ($l->connectiontype == MS_POSTGIS)
151   - {
  133 + if ($l->getmetadata("classesnome") != ""){
  134 + if(!function_exists("autoClasses")){
  135 + include_once("funcoes_gerais.php");
  136 + }
  137 + autoClasses($l,$mapa);
  138 + }
  139 + if(!empty($postgis_mapa)){
  140 + if($l->connectiontype == MS_POSTGIS){
152 141 $lcon = $l->connection;
153   - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa))))
154   - {
155   - if(($lcon == " ") || ($lcon == ""))
156   - {$l->set("connection",$postgis_mapa);}
157   - else
158   - {$l->set("connection",$postgis_mapa[$lcon]);}
  142 + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
  143 + if(($lcon == " ") || ($lcon == "")){
  144 + $l->set("connection",$postgis_mapa);
  145 + }
  146 + else{
  147 + $l->set("connection",$postgis_mapa[$lcon]);
  148 + }
159 149 }
160 150 }
161 151 }
162   - if($l->getProjection() == "" )
163   - {$l->setProjection("proj=latlong,a=6378137,b=6378137");}
  152 + if($l->getProjection() == "" ){
  153 + $l->setProjection("proj=latlong,a=6378137,b=6378137");
  154 + }
164 155 }
165   - if($layerName == $_GET["layer"])
166   - {
167   - if(strtolower($l->getmetadata("cache")) == "sim")
168   - {
  156 + if($layerName == $_GET["layer"]){
  157 + if(strtolower($l->getmetadata("cache")) == "sim"){
169 158 $cache = true;
170 159 $nomecache = $l->getmetadata("nomeoriginal");
171   - if($nomecache == "")
172   - {$nomecache = $layerName;}
  160 + if($nomecache == ""){
  161 + $nomecache = $layerName;
  162 + }
173 163 }
174 164 }
175   - $l->set("template","none.htm");
176 165 }
177 166 }
178 167 else{
179 168 $mapa->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");
180 169 $numlayers = $mapa->numlayers;
181   - for ($i=0;$i < $numlayers;++$i)
182   - {
  170 + for ($i=0;$i < $numlayers;++$i){
183 171 $l = $mapa->getlayer($i);
184 172 if($l->getProjection() == "" )
185 173 {$l->setProjection("proj=latlong,a=6378137,b=6378137");}
... ... @@ -187,19 +175,16 @@ else{
187 175 }
188 176 if($_GET["layer"] == "")
189 177 {$cache = true;}
190   -if($_GET == false)
191   -{$cache = false;}
192   -if(strtolower($_GET["DESLIGACACHE"]) == "sim")
193   -{$cache = false;}
194   -if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum")
  178 +
  179 +if(($_GET == false) || ($qy) || (strtolower($_GET["DESLIGACACHE"]) == "sim"))
195 180 {$cache = false;}
196   -if($qy)
  181 +elseif(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum")
197 182 {$cache = false;}
198   -if($cache == true)
199   -{carregaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);}
200 183  
201   -$map_size = explode(" ",$_GET["map_size"]);
202   -$mapa->setsize($map_size[0],$map_size[1]);
  184 +if($cache == true){
  185 + carregaCacheImagem();
  186 +}
  187 +$mapa->setsize(256,256);
203 188 $mapext = explode(" ",$_GET["mapext"]);
204 189 $mapa->setExtent($mapext[0],$mapext[1],$mapext[2],$mapext[3]);
205 190  
... ... @@ -213,16 +198,16 @@ if(!isset($_GET[&quot;telaR&quot;])){
213 198 $escala->set("status",MS_OFF);
214 199 }
215 200 //
216   -//se o layer n&atilde;o for do tipo fundo
  201 +//se o layer nao for do tipo fundo
217 202 //
218 203 if($_GET["tipolayer"] != "fundo")
219 204 {$o->set("transparent",MS_TRUE);}
220 205 if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum")
221 206 {$o->setOption("QUANTIZE_FORCE","OFF");}
222   -if($qy != true)
223   -{$img = $mapa->draw();}
224   -else
225   -{
  207 +if($qy != true){
  208 + $img = $mapa->draw();
  209 +}
  210 +else{
226 211 $handle = fopen ($qyfile, "r");
227 212 $conteudo = fread ($handle, filesize ($qyfile));
228 213 fclose ($handle);
... ... @@ -275,8 +260,7 @@ else
275 260 }
276 261 }
277 262 }
278   -if (!function_exists('imagepng'))
279   -{
  263 +if (!function_exists('imagepng')){
280 264 $s = PHP_SHLIB_SUFFIX;
281 265 @dl( 'php_gd.'.$s );
282 266 if (!function_exists('imagepng'))
... ... @@ -284,8 +268,7 @@ if (!function_exists(&#39;imagepng&#39;))
284 268 if (!function_exists('imagepng'))
285 269 {$_GET["TIPOIMAGEM"] = "";}
286 270 }
287   -if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum")
288   -{
  271 +if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum"){
289 272 if($img->imagepath == "")
290 273 {echo "Erro IMAGEPATH vazio";exit;}
291 274 $nomer = ($img->imagepath)."filtroimgtemp".nomeRand().".png";
... ... @@ -299,46 +282,56 @@ if(trim($_GET[&quot;TIPOIMAGEM&quot;]) != &quot;&quot; &amp;&amp; trim($_GET[&quot;TIPOIMAGEM&quot;]) != &quot;nenhum&quot;)
299 282 imagepng($img);
300 283 }
301 284 else{
302   - /*
303   - if($cache == true)
304   - {$nomer = salvaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);}
305   - else{
306   - if($img->imagepath == "")
307   - {echo "Erro IMAGEPATH vazio";exit;}
308   - $nomer = ($img->imagepath)."imgtemp".nomeRand().".png";
309   - $img->saveImage($nomer);
310   - }
311   - header('Content-Length: '.filesize($nomer));
312   - header('Content-Type: image/png');
313   - fpassthru(fopen($nomer, 'rb'));
314   - exit;
315   - */
316 285 if($cache == true){
317   - $nomer = salvaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]);
  286 + $nomer = salvaCacheImagem();
318 287 header('Content-Length: '.filesize($nomer));
319 288 header('Content-Type: image/png');
320 289 header('Cache-Control: max-age=3600, must-revalidate');
321 290 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT');
322 291 header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200);
323   - //$etag = md5_file($nomer);
324   - //header('Etag: '.$etag);
325 292 fpassthru(fopen($nomer, 'rb'));
326 293 }
327   - else{
  294 + else{
328 295 if($img->imagepath == "")
329 296 {echo "Erro IMAGEPATH vazio";exit;}
330   - /*
331   - $nomer = ($img->imagepath)."imgtemp".nomeRand().".png";
332   - $img->saveImage($nomer);
333   - header('Content-Length: '.filesize($nomer));
334   - header('Content-Type: image/png');
335   - fpassthru(fopen($nomer, 'rb'));
336   - */
337 297 header('Content-Type: image/png');
338 298 $img->saveImage();
339 299 }
340 300 exit;
341 301 }
  302 +//$cachedir e definido no ms_configura.php
  303 +function salvaCacheImagem(){
  304 + global $img,$cachedir,$x,$y,$z,$map_fileX;
  305 + $layer = $_GET["layer"];
  306 + if($layer == "")
  307 + {$layer = "fundo";}
  308 + if($cachedir == ""){
  309 + $cachedir = dirname(dirname($map_fileX))."/cache";
  310 + }
  311 + $c = $cachedir."/googlemaps/$layer/$z/$x";
  312 + if(!file_exists($c."/$y.png")){
  313 + mkdir($cachedir."/googlemaps/$layer/$z/$x",0777,true);
  314 + $img->saveImage($c."/$y.png");
  315 + }
  316 + return $nome;
  317 +}
  318 +function carregaCacheImagem(){
  319 + global $img,$cachedir,$x,$y,$z,$map_fileX;
  320 + $layer = $_GET["layer"];
  321 + if($layer == "")
  322 + {$layer = "fundo";}
  323 + if($cachedir == ""){
  324 + $cachedir = dirname(dirname($map_fileX))."/cache";
  325 + }
  326 + $c = $cachedir."/googlemaps/$layer/$z/$x";
  327 + if(file_exists($c."/$y.png")){
  328 + header('Content-Length: '.filesize($c."/$y.png"));
  329 + header('Content-Type: image/png');
  330 + fpassthru(fopen($c."/$y.png", 'rb'));
  331 + exit;
  332 + }
  333 +}
  334 +/*
342 335 function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){
343 336 global $img,$map_size;
344 337 //layers que s&atilde;o sempre iguais
... ... @@ -367,14 +360,14 @@ function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){
367 360 {$nome = dirname(dirname($map))."/cache/googlemaps/".$layer."/".$nome;}
368 361 else
369 362 {$nome = $cachedir."/googlemaps/".$layer."/".$nome;}
370   - if(file_exists($nome))
371   - {
  363 + if(file_exists($nome)){
372 364 header('Content-Length: '.filesize($nome));
373 365 header('Content-Type: image/png');
374 366 fpassthru(fopen($nome, 'rb'));
375 367 exit;
376 368 }
377 369 }
  370 +*/
378 371 function nomeRand($n=10)
379 372 {
380 373 $nomes = "";
... ...
interface/googlemapsdebug.phtml
... ... @@ -135,7 +135,7 @@ i3GEO.barraDeBotoes.INCLUIBOTAO.barraedicao = false;
135 135 //i3GEO.barraDeBotoes.MAXBOTOES = 10;
136 136 //remove itens dos menus que n&atilde;o s&atilde;o necess&aacute;rios, j&aacute; que est&atilde;o como &iacute;cones na barra de bot&otilde;es
137 137 i3GEO.configura.oMenuData["submenus"]["janelas"] = [];
138   -i3GEO.gadgets.PARAMETROS.mostraMenuSuspenso.permiteLogin = false;
  138 +i3GEO.gadgets.PARAMETROS.mostraMenuSuspenso.permiteLogin = true;
139 139  
140 140 //barra de botoes normal. descomente para usar
141 141 /*
... ...
temas/_llocali.map
1   -MAP
2   - FONTSET "../symbols/fontes.txt"
3   - SYMBOLSET "../symbols/simbolos.sym"
4   - LAYER
5   - CONNECTION ""
6   - DATA "/var/www/i3geo/aplicmap/dados/locali.shp"
7   - METADATA
8   - "METAESTAT_ID_MEDIDA_VARIAVEL" ""
9   - "TIP" "TIPO,ANOCRIA,NOMELOC"
10   - "LTEMPOITEMIMAGEM" ""
11   - "CLASSE" "SIM"
12   - "LTEMPOITEMDESCRICAO" "TIPO"
13   - "LTEMPOITEMINICIO" "ANOCRIA"
14   - "palletestep" ""
15   - "permitekmz" "nao"
16   - "LTEMPOITEMTIP" "ANOCRIA"
17   - "temporizador" ""
18   - "iconetema" ""
19   - "LTEMPOITEMTITULO" "NOMELOC"
20   - "description_template" ""
21   - "LTEMPOITEMLINK" ""
22   - "METAESTAT_CODIGO_TIPO_REGIAO" ""
23   - "palletefile" ""
24   - "permitedownload" "sim"
25   - "LTEMPOFORMATODATA" "iso8601"
26   - "permitecomentario" ""
27   - "LTEMPOITEMICONE" ""
28   - "metaestat" ""
29   - "itembuscarapida" "NOMELOC"
30   - "arquivodownload" ""
31   - "arquivokmz" ""
32   - "permitekml" "sim"
33   - "permiteogc" "sim"
34   - "transitioneffect" "NAO"
35   - "TEMA" "Localidades (usar com timeline)"
36   - "editorsql" ""
37   - "LTEMPOCONVENCODE" "SIM"
38   - "LTEMPOITEMFIM" ""
39   - "legendaimg" ""
40   - END # METADATA
41   - NAME "_wlocali"
42   - STATUS DEFAULT
43   - TEMPLATE "none.htm"
44   - TILEITEM "location"
45   - TYPE POINT
46   - UNITS METERS
47   - CLASS
48   - NAME "Vila"
49   - EXPRESSION ('[TIPO]'eq'Vila')
50   - STYLE
51   - ANGLE 0
52   - COLOR 250 193 4
53   - OFFSET 0 0
54   - SIZE 4
55   - SYMBOL "ponto"
56   - END # STYLE
57   - END # CLASS
58   - CLASS
59   - NAME "Cidade"
60   - EXPRESSION ('[TIPO]'eq'Cidade')
61   - STYLE
62   - ANGLE 0
63   - COLOR 62 9 41
64   - OFFSET 0 0
65   - SIZE 6
66   - SYMBOL "ponto"
67   - END # STYLE
68   - END # CLASS
69   - CLASS
70   - NAME "Capital"
71   - EXPRESSION ('[TIPO]'eq'Capital')
72   - STYLE
73   - ANGLE 0
74   - COLOR 112 203 244
75   - OFFSET 0 0
76   - SIZE 6
77   - SYMBOL "capital"
78   - END # STYLE
79   - END # CLASS
80   - END # LAYER
81   -
82   -END # MAP
83   -
  1 +MAP
  2 + FONTSET "../symbols/fontes.txt"
  3 + SYMBOLSET "../symbols/simbolos.sym"
  4 + LAYER
  5 + CONNECTION ""
  6 + DATA "/var/www/i3geo/aplicmap/dados/locali.shp"
  7 + METADATA
  8 + "METAESTAT_ID_MEDIDA_VARIAVEL" ""
  9 + "cache" "SIM"
  10 + "LTEMPOITEMIMAGEM" ""
  11 + "TIP" "TIPO,ANOCRIA,NOMELOC"
  12 + "LTEMPOITEMDESCRICAO" "TIPO"
  13 + "CLASSE" "SIM"
  14 + "palletestep" ""
  15 + "LTEMPOITEMINICIO" "ANOCRIA"
  16 + "temporizador" ""
  17 + "LTEMPOITEMTIP" "ANOCRIA"
  18 + "permitekmz" "nao"
  19 + "description_template" ""
  20 + "LTEMPOITEMTITULO" "NOMELOC"
  21 + "iconetema" ""
  22 + "LTEMPOITEMLINK" ""
  23 + "METAESTAT_CODIGO_TIPO_REGIAO" ""
  24 + "palletefile" ""
  25 + "LTEMPOFORMATODATA" "iso8601"
  26 + "permitedownload" "sim"
  27 + "LTEMPOITEMICONE" ""
  28 + "permitecomentario" ""
  29 + "metaestat" ""
  30 + "itembuscarapida" "NOMELOC"
  31 + "arquivokmz" ""
  32 + "arquivodownload" ""
  33 + "transitioneffect" "NAO"
  34 + "permiteogc" "sim"
  35 + "permitekml" "sim"
  36 + "convcaracter" ""
  37 + "TEMA" "Localidades (usar com timeline)"
  38 + "LTEMPOCONVENCODE" "SIM"
  39 + "editorsql" ""
  40 + "legendaimg" ""
  41 + "LTEMPOITEMFIM" ""
  42 + END # METADATA
  43 + NAME "_wlocali"
  44 + STATUS DEFAULT
  45 + TEMPLATE "none.htm"
  46 + TYPE POINT
  47 + UNITS METERS
  48 + CLASS
  49 + NAME "Vila"
  50 + EXPRESSION ('[TIPO]'eq'Vila')
  51 + STYLE
  52 + ANGLE 0
  53 + COLOR 250 193 4
  54 + OFFSET 0 0
  55 + SIZE 4
  56 + SYMBOL "ponto"
  57 + END # STYLE
  58 + END # CLASS
  59 + CLASS
  60 + NAME "Cidade"
  61 + EXPRESSION ('[TIPO]'eq'Cidade')
  62 + STYLE
  63 + ANGLE 0
  64 + COLOR 62 9 41
  65 + OFFSET 0 0
  66 + SIZE 6
  67 + SYMBOL "ponto"
  68 + END # STYLE
  69 + END # CLASS
  70 + CLASS
  71 + NAME "Capital"
  72 + EXPRESSION ('[TIPO]'eq'Capital')
  73 + STYLE
  74 + ANGLE 0
  75 + COLOR 112 203 244
  76 + OFFSET 0 0
  77 + SIZE 6
  78 + SYMBOL "capital"
  79 + END # STYLE
  80 + END # CLASS
  81 + END # LAYER
  82 +
  83 +END # MAP
  84 +
... ...