Commit 76f1ce067a8c11e0554a2e4603eca605d99c06bb
1 parent
bed14ac4
Exists in
master
Otimização do programa ogc.php para carga melhor do cache
Showing
2 changed files
with
87 additions
and
70 deletions
Show diff stats
ms_configura.php
| ... | ... | @@ -212,7 +212,7 @@ buscarapida,conectarservicos,convertemapakml,cortina,editorsql,filtroarvore,geol |
| 212 | 212 | inseretxt,mostraexten,outputformat,perfil,tipoimagem |
| 213 | 213 | |
| 214 | 214 | */ |
| 215 | -$i3geoBlFerramentas = array("carregamapa"); | |
| 215 | +$i3geoBlFerramentas = array("carregamapa","saiku"); | |
| 216 | 216 | |
| 217 | 217 | /* |
| 218 | 218 | Variable: $ogrOutput | ... | ... |
ogc.php
| ... | ... | @@ -77,12 +77,50 @@ ogc.php?tema=bioma |
| 77 | 77 | ogc.php?tema=/var/www/i3geo/aplicmap/geral1debianv6.map&layers=mundo |
| 78 | 78 | |
| 79 | 79 | */ |
| 80 | -set_time_limit(0); | |
| 81 | -ini_set('memory_limit', '512M'); | |
| 82 | -include_once (dirname(__FILE__)."/classesphp/sani_request.php"); | |
| 80 | +include(dirname(__FILE__)."/classesphp/sani_request.php"); | |
| 81 | +include(dirname(__FILE__)."/ms_configura.php"); | |
| 82 | +$_GET = array_merge($_GET,$_POST); | |
| 83 | + | |
| 83 | 84 | if(isset($_GET["BBOX"])){ |
| 84 | 85 | $_GET["BBOX"] = str_replace(" ",",",$_GET["BBOX"]); |
| 85 | 86 | } |
| 87 | + | |
| 88 | +if(isset($_GET["tema"])){ | |
| 89 | + $tema = $_GET["tema"]; | |
| 90 | +} | |
| 91 | +if($_GET["id_medida_variavel"] != ""){ | |
| 92 | + $_GET["id_medida_variavel"] = filter_var ( $_GET["id_medida_variavel"], FILTER_SANITIZE_NUMBER_INT); | |
| 93 | +} | |
| 94 | +// | |
| 95 | +//compatibiliza variaveis | |
| 96 | +// | |
| 97 | +if(!isset($tema) && isset($_GET["layers"])){ | |
| 98 | + $tema = $_GET["layers"]; | |
| 99 | +} | |
| 100 | +if(!isset($tema) && isset($_GET["LAYERS"])){ | |
| 101 | + $tema = $_GET["LAYERS"]; | |
| 102 | +} | |
| 103 | +if(!isset($tema) && isset($_GET["LAYER"])){ | |
| 104 | + $tema = $_GET["LAYER"]; | |
| 105 | +} | |
| 106 | +if(!isset($tema) && isset($_GET["temas"])){ | |
| 107 | + $tema = $_GET["temas"]; | |
| 108 | +} | |
| 109 | +if(isset($_GET["typeName"])){ | |
| 110 | + $typename = $_GET["typeName"]; | |
| 111 | + if(!isset($tema)){ | |
| 112 | + $tema = $typename; | |
| 113 | + } | |
| 114 | +} | |
| 115 | +if(!isset($tema) && isset($_GET["typename"])){ | |
| 116 | + $tema = $_GET["typename"]; | |
| 117 | +} | |
| 118 | +// | |
| 119 | +//define um nome para o mapfile caso a origem seja o sistema de metadados estatisticos | |
| 120 | +// | |
| 121 | +if(isset($_GET["id_medida_variavel"]) && $_GET["id_medida_variavel"] != ""){ | |
| 122 | + $tema = "ogcmetaestat".$_GET["id_medida_variavel"]; | |
| 123 | +} | |
| 86 | 124 | if(isset($_GET["TileMatrix"])){ |
| 87 | 125 | $_GET["WIDTH"] = 256; |
| 88 | 126 | $_GET["HEIGHT"] = 256; |
| ... | ... | @@ -93,20 +131,30 @@ if(isset($_GET["TileMatrix"])){ |
| 93 | 131 | $res[] = $temp; |
| 94 | 132 | $temp = $temp / 2; |
| 95 | 133 | } |
| 96 | - //$_GET["tms"] = null; | |
| 97 | - $_GET["tms"] = "/wmts/".$_GET["layer"]."/".$_GET["TileMatrix"]."/".$_GET["TileCol"]."/".$_GET["TileRow"].".png"; | |
| 134 | + $_GET["tms"] = "/wmts/".$tema."/".$_GET["TileMatrix"]."/".$_GET["TileCol"]."/".$_GET["TileRow"].".png"; | |
| 98 | 135 | if($_GET["TileMatrix"]."/".$_GET["TileCol"]."/".$_GET["TileRow"] == "0/0/0" || $_GET["TileCol"] == -1 || $_GET["TileRow"]== -1){ |
| 99 | 136 | return; |
| 100 | 137 | } |
| 101 | 138 | $_GET["BBOX"] = $lon1.",".$lat1.",".$lon2.",".$lat2; |
| 102 | 139 | $_GET["SERVICE"] = "WMS"; |
| 103 | 140 | $_GET["REQUEST"] = "getMap"; |
| 104 | -} | |
| 105 | -$_GET = array_merge($_GET,$_POST); | |
| 106 | -$tema = $_GET["tema"]; | |
| 107 | -if($_GET["id_medida_variavel"] != ""){ | |
| 108 | - $_GET["id_medida_variavel"] = filter_var ( $_GET["id_medida_variavel"], FILTER_SANITIZE_NUMBER_INT); | |
| 141 | + | |
| 109 | 142 | } |
| 143 | +// | |
| 144 | +//verifica se a imagem existe se o cache estiver ligado | |
| 145 | +//se existir, carrega e sai | |
| 146 | +// | |
| 147 | +if(isset($_GET["tms"]) && $_GET["tms"] != "" && $_GET["DESLIGACACHE"] != "sim"){ | |
| 148 | + carregaCacheImagem($cachedir,$nomeMapfileTmp,$_GET["tms"]); | |
| 149 | +} | |
| 150 | +if($_GET["DESLIGACACHE"] != "sim" && isset($_GET["Z"]) && isset($_GET["X"])){ | |
| 151 | + $x = $_GET["X"]; | |
| 152 | + $y = $_GET["Y"]; | |
| 153 | + $z = $_GET["Z"]; | |
| 154 | + carregaCacheImagem($cachedir,$nomeMapfileTmp,"/googlemaps/$tema/$z/$x/$y"); | |
| 155 | +} | |
| 156 | +set_time_limit(0); | |
| 157 | +ini_set('memory_limit', '512M'); | |
| 110 | 158 | // |
| 111 | 159 | //caso nenhum parametros tenha sido enviado |
| 112 | 160 | // |
| ... | ... | @@ -126,8 +174,7 @@ if(isset($_GET["outputformat"]) && $_GET["outputformat"] != ""){ |
| 126 | 174 | $_GET["OUTPUTFORMAT"] = $_GET["outputformat"]; |
| 127 | 175 | } |
| 128 | 176 | $cache = true; |
| 129 | -//require_once(dirname(__FILE__)."/classesphp/carrega_ext.php"); | |
| 130 | -include(dirname(__FILE__)."/ms_configura.php"); | |
| 177 | + | |
| 131 | 178 | include(dirname(__FILE__)."/classesphp/funcoes_gerais.php"); |
| 132 | 179 | |
| 133 | 180 | if(isset($logExec) && $logExec["ogc"] == true){ |
| ... | ... | @@ -158,38 +205,6 @@ $protocolo = $protocolo[0]; |
| 158 | 205 | $protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME']; |
| 159 | 206 | $protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; |
| 160 | 207 | $urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]); |
| 161 | -// | |
| 162 | -//define um nome para o mapfile caso a origem seja o sistema de metadados estatisticos | |
| 163 | -// | |
| 164 | - | |
| 165 | -if(isset($_GET["id_medida_variavel"]) && $_GET["id_medida_variavel"] != ""){ | |
| 166 | - $tema = "ogcmetaestat".$_GET["id_medida_variavel"]; | |
| 167 | -} | |
| 168 | -// | |
| 169 | -//compatibiliza variaveis | |
| 170 | -// | |
| 171 | - | |
| 172 | -if(!isset($tema) && isset($_GET["layers"])){ | |
| 173 | - $tema = $_GET["layers"]; | |
| 174 | -} | |
| 175 | -if(!isset($tema) && isset($_GET["LAYERS"])){ | |
| 176 | - $tema = $_GET["LAYERS"]; | |
| 177 | -} | |
| 178 | -if(!isset($tema) && isset($_GET["LAYER"])){ | |
| 179 | - $tema = $_GET["LAYER"]; | |
| 180 | -} | |
| 181 | -if(!isset($tema) && isset($_GET["temas"])){ | |
| 182 | - $tema = $_GET["temas"]; | |
| 183 | -} | |
| 184 | -if(isset($_GET["typeName"])){ | |
| 185 | - $typename = $_GET["typeName"]; | |
| 186 | - if(!isset($tema)){ | |
| 187 | - $tema = $typename; | |
| 188 | - } | |
| 189 | -} | |
| 190 | -if(!isset($tema) && isset($_GET["typename"])){ | |
| 191 | - $tema = $_GET["typename"]; | |
| 192 | -} | |
| 193 | 208 | |
| 194 | 209 | // |
| 195 | 210 | //garante que layers possam ser especificados de diferentes maneiras |
| ... | ... | @@ -478,11 +493,6 @@ else{ |
| 478 | 493 | if($temai3geo == false){ |
| 479 | 494 | $l->set("status",MS_OFF); |
| 480 | 495 | } |
| 481 | - /* | |
| 482 | - if($cache == true && strtolower($l->getmetadata('cache')) == 'sim' && $tipo == '' && count($tema) == 1){ | |
| 483 | - carregaCacheImagem($_GET['BBOX'],$tx,$_GET['WIDTH'],$_GET['HEIGHT'],$cachedir); | |
| 484 | - } | |
| 485 | - */ | |
| 486 | 496 | $l->setmetadata("ows_title",pegaNome($l)); |
| 487 | 497 | $l->setmetadata("ows_srs",$listaepsg); |
| 488 | 498 | $l->set("group",""); |
| ... | ... | @@ -689,8 +699,7 @@ else{ |
| 689 | 699 | } |
| 690 | 700 | } |
| 691 | 701 | } |
| 692 | - //echo "<pre>".var_dump($codigosTema);exit; | |
| 693 | - | |
| 702 | + //echo "<pre>".var_dump($codigosTema);exit; | |
| 694 | 703 | foreach($codigosTema as $c){ |
| 695 | 704 | $codigoTema = $c["tema"]; |
| 696 | 705 | if(file_exists($locaplic."/temas/".$codigoTema.".map")){ |
| ... | ... | @@ -1116,6 +1125,7 @@ if(strtolower($OUTPUTFORMAT) == "csv"){ |
| 1116 | 1125 | exit; |
| 1117 | 1126 | } |
| 1118 | 1127 | //echo $req->getValue(1);exit; |
| 1128 | +ob_clean(); | |
| 1119 | 1129 | $oMap->owsdispatch($req); |
| 1120 | 1130 | $contenttype = ms_iostripstdoutbuffercontenttype(); |
| 1121 | 1131 | $buffer = ms_iogetStdoutBufferBytes(); |
| ... | ... | @@ -1163,14 +1173,17 @@ function carregaCacheImagem($cachedir,$map,$tms){ |
| 1163 | 1173 | $nome = $cachedir.$tms; |
| 1164 | 1174 | } |
| 1165 | 1175 | $nome = str_replace(".png","",$nome).".png"; |
| 1176 | + //TODO verificar esses cabecalhos e comparar com geoserver | |
| 1166 | 1177 | if(file_exists($nome)){ |
| 1167 | - header('Content-Length: '.filesize($nome)); | |
| 1178 | + ob_clean(); | |
| 1179 | + //header('Content-Length: '.filesize($nome)); | |
| 1180 | + header('Cache: '.$tms); | |
| 1168 | 1181 | header('Content-Type: image/png'); |
| 1169 | - header('Cache-Control: max-age=3600, must-revalidate'); | |
| 1170 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | |
| 1171 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | |
| 1172 | - $etag = md5_file($nome); | |
| 1173 | - header('Etag: '.$etag); | |
| 1182 | + //header('Cache-Control: max-age=3600, must-revalidate'); | |
| 1183 | + //header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | |
| 1184 | + //header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | |
| 1185 | + //$etag = md5_file($nome); | |
| 1186 | + //header('Etag: '.$etag); | |
| 1174 | 1187 | readfile($nome); |
| 1175 | 1188 | exit; |
| 1176 | 1189 | } |
| ... | ... | @@ -1205,11 +1218,12 @@ function salvaCacheImagem($cachedir,$map,$tms){ |
| 1205 | 1218 | imagepng($imgc,$nome); |
| 1206 | 1219 | } |
| 1207 | 1220 | chmod($nome,0744); |
| 1208 | - header('Content-Length: '.filesize($nome)); | |
| 1221 | + //header('Content-Length: '.filesize($nome)); | |
| 1222 | + ob_clean(); | |
| 1209 | 1223 | header('Content-Type: image/png'); |
| 1210 | - header('Cache-Control: max-age=3600, must-revalidate'); | |
| 1211 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | |
| 1212 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | |
| 1224 | + //header('Cache-Control: max-age=3600, must-revalidate'); | |
| 1225 | + //header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | |
| 1226 | + //header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | |
| 1213 | 1227 | readfile($nome); |
| 1214 | 1228 | exit; |
| 1215 | 1229 | } |
| ... | ... | @@ -1255,19 +1269,22 @@ function renderNocacheTms(){ |
| 1255 | 1269 | imagepng($imgc,$nomer); |
| 1256 | 1270 | } |
| 1257 | 1271 | if($i3georendermode == 0 || !isset($i3georendermode)){ |
| 1258 | - header('Content-Length: '.filesize($nomer)); | |
| 1272 | + ob_clean(); | |
| 1273 | + //header('Content-Length: '.filesize($nomer)); | |
| 1259 | 1274 | header('Content-Type: image/png'); |
| 1260 | - header('Cache-Control: max-age=3600, must-revalidate'); | |
| 1261 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | |
| 1262 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200); | |
| 1263 | - readfile($nomer); | |
| 1275 | + //header('Cache-Control: max-age=3600, must-revalidate'); | |
| 1276 | + //header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | |
| 1277 | + //header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200); | |
| 1278 | + readfile($nomer); | |
| 1279 | + exit; | |
| 1264 | 1280 | } |
| 1265 | 1281 | if($i3georendermode == 2){ |
| 1266 | 1282 | ob_clean(); |
| 1267 | - header('Cache-Control: public, max-age=22222222'); | |
| 1268 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT'); | |
| 1283 | + //header('Cache-Control: public, max-age=22222222'); | |
| 1284 | + //header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT'); | |
| 1269 | 1285 | header("X-Sendfile: $nomer"); |
| 1270 | - header("Content-type: image/png"); | |
| 1286 | + header("Content-type: image/png"); | |
| 1287 | + exit; | |
| 1271 | 1288 | } |
| 1272 | 1289 | } |
| 1273 | 1290 | function getfeatureinfoJson(){ | ... | ... |