Commit 7e7021ac3c86165e88fe0da6a172cbe1f4150346
1 parent
77785f14
Exists in
master
and in
7 other branches
Otimização da geração do serviço OGC por meio do uso de cache
Showing
1 changed file
with
244 additions
and
227 deletions
Show diff stats
ogc.php
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | 4 | ||
| 5 | Gera web services nos padrões OGC para os temas existentes na pasta i3geo/temas | 5 | Gera web services nos padrões OGC para os temas existentes na pasta i3geo/temas |
| 6 | 6 | ||
| 7 | -A lista de projeções mostradas na função getcapabilities é definida na variável $listaepsg. Edite essa variável diretamente no programa | 7 | +A lista de projeções mostradas na função getcapabilities é definida na variável $listaepsg. Edite essa variável diretamente no programa |
| 8 | se forem necessárias outras projeções além das existentes | 8 | se forem necessárias outras projeções além das existentes |
| 9 | 9 | ||
| 10 | Licença: | 10 | Licença: |
| @@ -65,8 +65,7 @@ $cache = true; | @@ -65,8 +65,7 @@ $cache = true; | ||
| 65 | require_once(__DIR__."/classesphp/carrega_ext.php"); | 65 | require_once(__DIR__."/classesphp/carrega_ext.php"); |
| 66 | include(__DIR__."/ms_configura.php"); | 66 | include(__DIR__."/ms_configura.php"); |
| 67 | include(__DIR__."/classesphp/pega_variaveis.php"); | 67 | include(__DIR__."/classesphp/pega_variaveis.php"); |
| 68 | -if(!isset($temas) && isset($tema)) | ||
| 69 | -{ | 68 | +if(!isset($temas) && isset($tema)){ |
| 70 | $temas = $tema; | 69 | $temas = $tema; |
| 71 | } | 70 | } |
| 72 | // | 71 | // |
| @@ -173,37 +172,7 @@ for($i=0;$i<$n;$i++){ | @@ -173,37 +172,7 @@ for($i=0;$i<$n;$i++){ | ||
| 173 | } | 172 | } |
| 174 | exit; | 173 | exit; |
| 175 | */ | 174 | */ |
| 176 | -$oMap = ms_newMapobj($locaplic."/aplicmap/ogcwsv".$versao.".map"); | ||
| 177 | -// | ||
| 178 | -//altera os caminhos das imagens | ||
| 179 | -// | ||
| 180 | -if((isset($legenda)) && (strtolower($legenda) == "sim")){ | ||
| 181 | - $leg = $oMap->legend; | ||
| 182 | - $leg->set("status",MS_EMBED); | ||
| 183 | - $cache = false; | ||
| 184 | -} | ||
| 185 | -$proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://"; | ||
| 186 | -$server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; | ||
| 187 | -$or = $proto.$server.$_SERVER['PHP_SELF']; | ||
| 188 | -if((isset($tema)) && ($tema != "") && ($tipo=="metadados")){ | ||
| 189 | - $or = $or."?tema=".$tema."&"; | ||
| 190 | -} | ||
| 191 | -// | ||
| 192 | -//parametros no nível maior | ||
| 193 | -// | ||
| 194 | -$oMap->setmetadata("ows_onlineresource",$or); | ||
| 195 | -$oMap->setmetadata("wms_onlineresource",$or); | ||
| 196 | -$oMap->setmetadata("wms_title",$tituloInstituicao." - i3geo"); | ||
| 197 | -$oMap->setmetadata("wfs_title",$tituloInstituicao." - i3geo"); | ||
| 198 | -$oMap->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 199 | -$oMap->setmetadata("wms_attribution_logourl_height","56"); | ||
| 200 | -$oMap->setmetadata("wms_attribution_logourl_width","85"); | ||
| 201 | -$oMap->setmetadata("wms_attribution_logourl_href",$proto.$server.dirname($_SERVER['PHP_SELF'])."/imagens/i3geo.png"); | ||
| 202 | -$oMap->setmetadata("wms_attribution_onlineresource",$proto.$server.dirname($_SERVER['PHP_SELF'])); | ||
| 203 | -$oMap->setmetadata("wms_attribution_title",$tituloInstituicao); | ||
| 204 | -$oMap->setmetadata("ows_enable_request","*"); | ||
| 205 | -$e = $oMap->extent; | ||
| 206 | -$extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | 175 | + |
| 207 | if (!isset($intervalo)){ | 176 | if (!isset($intervalo)){ |
| 208 | $intervalo = "0,5000"; | 177 | $intervalo = "0,5000"; |
| 209 | } | 178 | } |
| @@ -211,68 +180,172 @@ else{ | @@ -211,68 +180,172 @@ else{ | ||
| 211 | $tipo = "intervalo"; | 180 | $tipo = "intervalo"; |
| 212 | } | 181 | } |
| 213 | if(!isset($tema)){ | 182 | if(!isset($tema)){ |
| 214 | - if(!isset($intervalo)) | ||
| 215 | - { | ||
| 216 | - $intervalo = "0,5000"; | 183 | + if(!isset($intervalo)){ |
| 184 | + $intervalo = "0,5000"; | ||
| 217 | } | 185 | } |
| 218 | $tipo = "intervalo"; | 186 | $tipo = "intervalo"; |
| 219 | -} | ||
| 220 | -if ($tipo == "" || $tipo == "metadados"){ | ||
| 221 | - $tema = explode(" ",$tema); | ||
| 222 | - //para o caso do tema ser um arquivo mapfile existente em uma pasta qualquer | ||
| 223 | - //$temai3geo = true indica que o layer será buscado na pasta i3geo/temas | ||
| 224 | - $temai3geo = true; | ||
| 225 | - //FIXME não aceita gvp quando o caminho é completo | ||
| 226 | - if(file_exists($_GET["tema"])){ | ||
| 227 | - $nmap = ms_newMapobj($_GET["tema"]); | ||
| 228 | - $temai3geo = false; | ||
| 229 | - $nmap->setmetadata("ows_enable_request","*"); | 187 | +} |
| 188 | + | ||
| 189 | +//nome do mapfile que ficara em cache | ||
| 190 | +$nomeMapfileTmp = $dir_tmp."/ogc_".$tema.".map"; | ||
| 191 | +$nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp); | ||
| 192 | +$nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); | ||
| 193 | +if(file_exists($nomeMapfileTmp) && $tipo == ""){ | ||
| 194 | + $oMap = ms_newMapobj($nomeMapfileTmp); | ||
| 195 | +} | ||
| 196 | +else{ | ||
| 197 | + $oMap = ms_newMapobj($locaplic."/aplicmap/ogcwsv".$versao.".map"); | ||
| 198 | + $proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://"; | ||
| 199 | + $server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; | ||
| 200 | + $or = $proto.$server.$_SERVER['PHP_SELF']; | ||
| 201 | + if((isset($tema)) && ($tema != "") && ($tipo=="metadados")){ | ||
| 202 | + $or = $or."?tema=".$tema."&"; | ||
| 230 | } | 203 | } |
| 231 | - foreach ($tema as $tx){ | ||
| 232 | - $extensao = ".map"; | ||
| 233 | - if(file_exists($locaplic."/temas/".$tx.".php") && $temai3geo == true){ | ||
| 234 | - $extensao = ".php"; | ||
| 235 | - } | ||
| 236 | - if(file_exists($locaplic."/temas/".$tx.".gvp") && $temai3geo == true){ | ||
| 237 | - $extensao = ".gvp"; | 204 | + // |
| 205 | + //parametros no nível maior | ||
| 206 | + // | ||
| 207 | + $oMap->setmetadata("ows_onlineresource",$or); | ||
| 208 | + $oMap->setmetadata("wms_onlineresource",$or); | ||
| 209 | + $oMap->setmetadata("wms_title",$tituloInstituicao." - i3geo"); | ||
| 210 | + $oMap->setmetadata("wfs_title",$tituloInstituicao." - i3geo"); | ||
| 211 | + $oMap->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 212 | + $oMap->setmetadata("wms_attribution_logourl_height","56"); | ||
| 213 | + $oMap->setmetadata("wms_attribution_logourl_width","85"); | ||
| 214 | + $oMap->setmetadata("wms_attribution_logourl_href",$proto.$server.dirname($_SERVER['PHP_SELF'])."/imagens/i3geo.png"); | ||
| 215 | + $oMap->setmetadata("wms_attribution_onlineresource",$proto.$server.dirname($_SERVER['PHP_SELF'])); | ||
| 216 | + $oMap->setmetadata("wms_attribution_title",$tituloInstituicao); | ||
| 217 | + $oMap->setmetadata("ows_enable_request","*"); | ||
| 218 | + $e = $oMap->extent; | ||
| 219 | + $extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | ||
| 220 | + | ||
| 221 | + //gera o mapa | ||
| 222 | + if ($tipo == "" || $tipo == "metadados"){ | ||
| 223 | + $tema = explode(" ",$tema); | ||
| 224 | + //para o caso do tema ser um arquivo mapfile existente em uma pasta qualquer | ||
| 225 | + //$temai3geo = true indica que o layer será buscado na pasta i3geo/temas | ||
| 226 | + $temai3geo = true; | ||
| 227 | + //FIXME não aceita gvp quando o caminho é completo | ||
| 228 | + if(file_exists($_GET["tema"])){ | ||
| 229 | + $nmap = ms_newMapobj($_GET["tema"]); | ||
| 230 | + $temai3geo = false; | ||
| 231 | + $nmap->setmetadata("ows_enable_request","*"); | ||
| 238 | } | 232 | } |
| 239 | - if($extensao == ".map"){ | ||
| 240 | - if($temai3geo == true){ | ||
| 241 | - $nmap = ms_newMapobj($locaplic."/temas/".$tx.".map"); | ||
| 242 | - $nmap->setmetadata("ows_enable_request","*"); | 233 | + foreach ($tema as $tx){ |
| 234 | + $extensao = ".map"; | ||
| 235 | + if(file_exists($locaplic."/temas/".$tx.".php") && $temai3geo == true){ | ||
| 236 | + $extensao = ".php"; | ||
| 243 | } | 237 | } |
| 244 | - if($temai3geo == false || empty($layers)) | ||
| 245 | - { | ||
| 246 | - $ts = $nmap->getalllayernames(); | 238 | + if(file_exists($locaplic."/temas/".$tx.".gvp") && $temai3geo == true){ |
| 239 | + $extensao = ".gvp"; | ||
| 247 | } | 240 | } |
| 248 | - else{ | ||
| 249 | - $ts = explode(",",str_replace(" ",",",$layers)); | ||
| 250 | - } | ||
| 251 | - foreach ($ts as $t){ | ||
| 252 | - $l = $nmap->getlayerbyname($t); | ||
| 253 | - $permite = $l->getmetadata("permiteogc"); | ||
| 254 | - if(strtolower($permite) != "nao"){ | ||
| 255 | - //necessário pq o mapfile pode ter todos os layers como default | ||
| 256 | - if($temai3geo == false){ | ||
| 257 | - $l->set("status",MS_OFF); | ||
| 258 | - } | ||
| 259 | - if($cache == true && strtolower($l->getmetadata('cache')) == 'sim' && $tipo == '' && count($tema) == 1){ | ||
| 260 | - carregaCacheImagem($_GET['BBOX'],$tx,$_GET['WIDTH'],$_GET['HEIGHT'],$cachedir); | ||
| 261 | - } | ||
| 262 | - $l->setmetadata("ows_title",pegaNome($l)); | ||
| 263 | - $l->setmetadata("ows_srs",$listaepsg); | ||
| 264 | - $l->set("group",""); | ||
| 265 | - //essa linha é necessária pq as vezes no mapfile não tem nenhum layer com o nome igual ao nome do mapfile | ||
| 266 | - if(count($ts)==1 && $temai3geo == true){ | ||
| 267 | - $l->set("name",$tx); | 241 | + if($extensao == ".map"){ |
| 242 | + if($temai3geo == true){ | ||
| 243 | + $nmap = ms_newMapobj($locaplic."/temas/".$tx.".map"); | ||
| 244 | + $nmap->setmetadata("ows_enable_request","*"); | ||
| 245 | + } | ||
| 246 | + if($temai3geo == false || empty($layers)) | ||
| 247 | + { | ||
| 248 | + $ts = $nmap->getalllayernames(); | ||
| 249 | + } | ||
| 250 | + else{ | ||
| 251 | + $ts = explode(",",str_replace(" ",",",$layers)); | ||
| 252 | + } | ||
| 253 | + foreach ($ts as $t){ | ||
| 254 | + $l = $nmap->getlayerbyname($t); | ||
| 255 | + $permite = $l->getmetadata("permiteogc"); | ||
| 256 | + if(strtolower($permite) != "nao"){ | ||
| 257 | + //necessário pq o mapfile pode ter todos os layers como default | ||
| 258 | + if($temai3geo == false){ | ||
| 259 | + $l->set("status",MS_OFF); | ||
| 260 | + } | ||
| 261 | + /* | ||
| 262 | + if($cache == true && strtolower($l->getmetadata('cache')) == 'sim' && $tipo == '' && count($tema) == 1){ | ||
| 263 | + carregaCacheImagem($_GET['BBOX'],$tx,$_GET['WIDTH'],$_GET['HEIGHT'],$cachedir); | ||
| 264 | + } | ||
| 265 | + */ | ||
| 266 | + $l->setmetadata("ows_title",pegaNome($l)); | ||
| 267 | + $l->setmetadata("ows_srs",$listaepsg); | ||
| 268 | + $l->set("group",""); | ||
| 269 | + //essa linha é necessária pq as vezes no mapfile não tem nenhum layer com o nome igual ao nome do mapfile | ||
| 270 | + if(count($ts)==1 && $temai3geo == true){ | ||
| 271 | + $l->set("name",$tx); | ||
| 272 | + } | ||
| 273 | + $l->setmetadata("gml_include_items","all"); | ||
| 274 | + $l->set("template","none.htm"); | ||
| 275 | + $l->set("dump",MS_TRUE); | ||
| 276 | + $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
| 277 | + $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
| 278 | + if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){ | ||
| 279 | + $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png"; | ||
| 280 | + $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 281 | + $l->setmetadata("wms_attribution_logourl_height","50"); | ||
| 282 | + $l->setmetadata("wms_attribution_logourl_width","50"); | ||
| 283 | + $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
| 284 | + } | ||
| 285 | + if($l->type == MS_LAYER_RASTER && $l->numclasses > 0){ | ||
| 286 | + $c = $l->getclass(0); | ||
| 287 | + if($c->name == "") | ||
| 288 | + { | ||
| 289 | + $c->name = " "; | ||
| 290 | + } | ||
| 291 | + } | ||
| 292 | + //inclui extensao geografica | ||
| 293 | + $extensao = $l->getmetadata("EXTENSAO"); | ||
| 294 | + if($extensao == ""){ | ||
| 295 | + $extensao = $extensaoMap; | ||
| 296 | + } | ||
| 297 | + $l->setmetadata("wms_extent",$extensao); | ||
| 298 | + if (!empty($postgis_mapa)){ | ||
| 299 | + if ($l->connectiontype == MS_POSTGIS){ | ||
| 300 | + $lcon = $l->connection; | ||
| 301 | + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ | ||
| 302 | + // | ||
| 303 | + //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | ||
| 304 | + // | ||
| 305 | + if(($lcon == " ") || ($lcon == "")){ | ||
| 306 | + $l->set("connection",$postgis_mapa); | ||
| 307 | + $l->setmetadata("CONEXAOORIGINAL",$lcon); | ||
| 308 | + } | ||
| 309 | + else{ | ||
| 310 | + $l->set("connection",$postgis_mapa[$lcon]); | ||
| 311 | + $l->setmetadata("CONEXAOORIGINAL",$lcon); | ||
| 312 | + } | ||
| 313 | + } | ||
| 314 | + } | ||
| 315 | + } | ||
| 316 | + autoClasses($l,$oMap); | ||
| 317 | + ms_newLayerObj($oMap, $l); | ||
| 318 | + //$req->setParameter("LAYERS", "mundo"); | ||
| 268 | } | 319 | } |
| 320 | + } | ||
| 321 | + } | ||
| 322 | + if($extensao == ".php"){ | ||
| 323 | + include_once($locaplic."/temas/".$tx.".php"); | ||
| 324 | + eval($tx."(\$oMap);"); | ||
| 325 | + } | ||
| 326 | + if($extensao == ".gvp"){ | ||
| 327 | + include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); | ||
| 328 | + $gm = new gvsig2mapfile($locaplic."/temas/".$tx.".gvp"); | ||
| 329 | + $gvsigview = $gm->getViewsNames(); | ||
| 330 | + foreach($gvsigview as $gv){ | ||
| 331 | + $dataView = $gm->getViewData($gv); | ||
| 332 | + $oMap = $gm->addLayers($oMap,$gv,$dataView["layerNames"]); | ||
| 333 | + } | ||
| 334 | + $numlayers = $oMap->numlayers; | ||
| 335 | + $layers = array(); | ||
| 336 | + //$layers[] = "default"; | ||
| 337 | + for ($i=0;$i < $numlayers;$i++){ | ||
| 338 | + $l = $oMap->getlayer($i); | ||
| 269 | $l->setmetadata("gml_include_items","all"); | 339 | $l->setmetadata("gml_include_items","all"); |
| 270 | - $l->set("template","none.htm"); | ||
| 271 | $l->set("dump",MS_TRUE); | 340 | $l->set("dump",MS_TRUE); |
| 272 | $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | 341 | $l->setmetadata("WMS_INCLUDE_ITEMS","all"); |
| 273 | $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | 342 | $l->setmetadata("WFS_INCLUDE_ITEMS","all"); |
| 274 | - if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){ | ||
| 275 | - $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png"; | 343 | + $l->setmetadata("ows_srs",$listaepsg); |
| 344 | + $l->setmetadata("ows_title",$l->getmetadata("TEMA")); | ||
| 345 | + $l->set("status",MS_OFF); | ||
| 346 | + $layers[] = $l->name; | ||
| 347 | + if(file_exists($locaplic."/temas/miniaturas/".$tx.".map.mini.png")){ | ||
| 348 | + $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$tx.".map.mini.png"; | ||
| 276 | $l->setmetadata("wms_attribution_logourl_format","image/png"); | 349 | $l->setmetadata("wms_attribution_logourl_format","image/png"); |
| 277 | $l->setmetadata("wms_attribution_logourl_height","50"); | 350 | $l->setmetadata("wms_attribution_logourl_height","50"); |
| 278 | $l->setmetadata("wms_attribution_logourl_width","50"); | 351 | $l->setmetadata("wms_attribution_logourl_width","50"); |
| @@ -291,176 +364,120 @@ if ($tipo == "" || $tipo == "metadados"){ | @@ -291,176 +364,120 @@ if ($tipo == "" || $tipo == "metadados"){ | ||
| 291 | $extensao = $extensaoMap; | 364 | $extensao = $extensaoMap; |
| 292 | } | 365 | } |
| 293 | $l->setmetadata("wms_extent",$extensao); | 366 | $l->setmetadata("wms_extent",$extensao); |
| 294 | - if (!empty($postgis_mapa)){ | ||
| 295 | - if ($l->connectiontype == MS_POSTGIS){ | ||
| 296 | - $lcon = $l->connection; | ||
| 297 | - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ | ||
| 298 | - // | ||
| 299 | - //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | ||
| 300 | - // | ||
| 301 | - if(($lcon == " ") || ($lcon == "")){ | ||
| 302 | - $l->set("connection",$postgis_mapa); | ||
| 303 | - $l->setmetadata("CONEXAOORIGINAL",$lcon); | ||
| 304 | - } | ||
| 305 | - else{ | ||
| 306 | - $l->set("connection",$postgis_mapa[$lcon]); | ||
| 307 | - $l->setmetadata("CONEXAOORIGINAL",$lcon); | ||
| 308 | - } | ||
| 309 | - } | ||
| 310 | - } | ||
| 311 | - } | ||
| 312 | - autoClasses($l,$oMap); | ||
| 313 | - ms_newLayerObj($oMap, $l); | ||
| 314 | - //$req->setParameter("LAYERS", "mundo"); | ||
| 315 | } | 367 | } |
| 368 | + $req->setParameter("LAYERS", implode(",",$layers)); | ||
| 369 | + $req->setParameter("STYLES", ""); | ||
| 370 | + //r_dump($req);exit; | ||
| 316 | } | 371 | } |
| 317 | } | 372 | } |
| 318 | - if($extensao == ".php"){ | ||
| 319 | - include_once($locaplic."/temas/".$tx.".php"); | ||
| 320 | - eval($tx."(\$oMap);"); | ||
| 321 | - } | ||
| 322 | - if($extensao == ".gvp"){ | ||
| 323 | - include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); | ||
| 324 | - $gm = new gvsig2mapfile($locaplic."/temas/".$tx.".gvp"); | ||
| 325 | - $gvsigview = $gm->getViewsNames(); | ||
| 326 | - foreach($gvsigview as $gv){ | ||
| 327 | - $dataView = $gm->getViewData($gv); | ||
| 328 | - $oMap = $gm->addLayers($oMap,$gv,$dataView["layerNames"]); | ||
| 329 | - } | ||
| 330 | - $numlayers = $oMap->numlayers; | ||
| 331 | - $layers = array(); | ||
| 332 | - //$layers[] = "default"; | ||
| 333 | - for ($i=0;$i < $numlayers;$i++){ | ||
| 334 | - $l = $oMap->getlayer($i); | ||
| 335 | - $l->setmetadata("gml_include_items","all"); | ||
| 336 | - $l->set("dump",MS_TRUE); | ||
| 337 | - $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
| 338 | - $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
| 339 | - $l->setmetadata("ows_srs",$listaepsg); | ||
| 340 | - $l->setmetadata("ows_title",$l->getmetadata("TEMA")); | ||
| 341 | - $l->set("status",MS_OFF); | ||
| 342 | - $layers[] = $l->name; | ||
| 343 | - if(file_exists($locaplic."/temas/miniaturas/".$tx.".map.mini.png")){ | ||
| 344 | - $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$tx.".map.mini.png"; | ||
| 345 | - $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 346 | - $l->setmetadata("wms_attribution_logourl_height","50"); | ||
| 347 | - $l->setmetadata("wms_attribution_logourl_width","50"); | ||
| 348 | - $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
| 349 | - } | ||
| 350 | - if($l->type == MS_LAYER_RASTER && $l->numclasses > 0){ | ||
| 351 | - $c = $l->getclass(0); | ||
| 352 | - if($c->name == "") | ||
| 353 | - { | ||
| 354 | - $c->name = " "; | ||
| 355 | - } | ||
| 356 | - } | ||
| 357 | - //inclui extensao geografica | ||
| 358 | - $extensao = $l->getmetadata("EXTENSAO"); | ||
| 359 | - if($extensao == ""){ | ||
| 360 | - $extensao = $extensaoMap; | ||
| 361 | - } | ||
| 362 | - $l->setmetadata("wms_extent",$extensao); | ||
| 363 | - } | ||
| 364 | - $req->setParameter("LAYERS", implode(",",$layers)); | ||
| 365 | - $req->setParameter("STYLES", ""); | ||
| 366 | - //r_dump($req);exit; | ||
| 367 | - } | ||
| 368 | } | 373 | } |
| 369 | -} | ||
| 370 | -else{ | ||
| 371 | - $conta = 0; | ||
| 372 | - $int = explode(",",$intervalo); | ||
| 373 | - $codigosTema = array(); | ||
| 374 | - if(empty($perfil)){ | ||
| 375 | - $perfil = ""; | ||
| 376 | - } | ||
| 377 | - include("classesphp/classe_menutemas.php"); | ||
| 378 | - $m = new Menutemas("",$perfil,$locaplic,$urli3geo); | ||
| 379 | - $menus = $m->pegaListaDeMenus(); | ||
| 380 | - foreach ($menus as $menu){ | ||
| 381 | - $grupos = $m->pegaListaDeGrupos($menu["idmenu"],$listasistemas="nao",$listasgrupos="sim"); | ||
| 382 | - foreach($grupos as $grupo){ | ||
| 383 | - if(strtolower($grupo["ogc"]) == "sim"){ | ||
| 384 | - foreach($grupo["subgrupos"] as $sgrupo){ | ||
| 385 | - if(strtolower($sgrupo["ogc"]) == "sim"){ | ||
| 386 | - $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
| 387 | - foreach($temas as $tema){ | ||
| 388 | - if(strtolower($tema["ogc"]) == "sim"){ | ||
| 389 | - $codigosTema[] = array("tema"=>$tema["tid"],"fonte"=>$tema["link"]); | 374 | + else{ |
| 375 | + $conta = 0; | ||
| 376 | + $int = explode(",",$intervalo); | ||
| 377 | + $codigosTema = array(); | ||
| 378 | + if(empty($perfil)){ | ||
| 379 | + $perfil = ""; | ||
| 380 | + } | ||
| 381 | + include("classesphp/classe_menutemas.php"); | ||
| 382 | + $m = new Menutemas("",$perfil,$locaplic,$urli3geo); | ||
| 383 | + $menus = $m->pegaListaDeMenus(); | ||
| 384 | + foreach ($menus as $menu){ | ||
| 385 | + $grupos = $m->pegaListaDeGrupos($menu["idmenu"],$listasistemas="nao",$listasgrupos="sim"); | ||
| 386 | + foreach($grupos as $grupo){ | ||
| 387 | + if(strtolower($grupo["ogc"]) == "sim"){ | ||
| 388 | + foreach($grupo["subgrupos"] as $sgrupo){ | ||
| 389 | + if(strtolower($sgrupo["ogc"]) == "sim"){ | ||
| 390 | + $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
| 391 | + foreach($temas as $tema){ | ||
| 392 | + if(strtolower($tema["ogc"]) == "sim"){ | ||
| 393 | + $codigosTema[] = array("tema"=>$tema["tid"],"fonte"=>$tema["link"]); | ||
| 394 | + } | ||
| 390 | } | 395 | } |
| 391 | } | 396 | } |
| 392 | } | 397 | } |
| 393 | } | 398 | } |
| 394 | } | 399 | } |
| 395 | } | 400 | } |
| 396 | - } | ||
| 397 | - //echo "<pre>"; | ||
| 398 | - //var_dump($codigosTema); | ||
| 399 | - //exit; | ||
| 400 | - foreach($codigosTema as $c){ | ||
| 401 | - $codigoTema = $c["tema"]; | ||
| 402 | - if(file_exists($locaplic."/temas/".$codigoTema.".map")){ | ||
| 403 | - if (@ms_newMapobj($locaplic."/temas/".$codigoTema.".map")){ | ||
| 404 | - $nmap = ms_newMapobj($locaplic."/temas/".$codigoTema.".map"); | ||
| 405 | - $nmap->setmetadata("ows_enable_request","*"); | ||
| 406 | - $ts = $nmap->getalllayernames(); | ||
| 407 | - if (count($ts) == 1){ | ||
| 408 | - foreach ($ts as $t){ | ||
| 409 | - if ($oMap->getlayerbyname($t) == ""){ | ||
| 410 | - $conta++; | ||
| 411 | - if (($conta >= $int[0]) && ($conta <= $int[1])){ | ||
| 412 | - $l = $nmap->getlayerbyname($t); | ||
| 413 | - $extensao = $l->getmetadata("EXTENSAO"); | ||
| 414 | - if($extensao == "") | ||
| 415 | - { | ||
| 416 | - $extensao = $extensaoMap; | ||
| 417 | - } | ||
| 418 | - $l->setmetadata("wms_extent",$extensao); | 401 | + //echo "<pre>"; |
| 402 | + //var_dump($codigosTema); | ||
| 403 | + //exit; | ||
| 404 | + foreach($codigosTema as $c){ | ||
| 405 | + $codigoTema = $c["tema"]; | ||
| 406 | + if(file_exists($locaplic."/temas/".$codigoTema.".map")){ | ||
| 407 | + if (@ms_newMapobj($locaplic."/temas/".$codigoTema.".map")){ | ||
| 408 | + $nmap = ms_newMapobj($locaplic."/temas/".$codigoTema.".map"); | ||
| 409 | + $nmap->setmetadata("ows_enable_request","*"); | ||
| 410 | + $ts = $nmap->getalllayernames(); | ||
| 411 | + if (count($ts) == 1){ | ||
| 412 | + foreach ($ts as $t){ | ||
| 413 | + if ($oMap->getlayerbyname($t) == ""){ | ||
| 414 | + $conta++; | ||
| 415 | + if (($conta >= $int[0]) && ($conta <= $int[1])){ | ||
| 416 | + $l = $nmap->getlayerbyname($t); | ||
| 417 | + $extensao = $l->getmetadata("EXTENSAO"); | ||
| 418 | + if($extensao == "") | ||
| 419 | + { | ||
| 420 | + $extensao = $extensaoMap; | ||
| 421 | + } | ||
| 422 | + $l->setmetadata("wms_extent",$extensao); | ||
| 419 | 423 | ||
| 420 | - $l->setmetadata("ows_title",pegaNome($l)); | ||
| 421 | - $l->setmetadata("ows_srs",$listaepsg); | ||
| 422 | - $l->set("status",MS_OFF); | ||
| 423 | - $l->setmetadata("gml_include_items","all"); | ||
| 424 | - $l->set("dump",MS_TRUE); | ||
| 425 | - $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
| 426 | - $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | 424 | + $l->setmetadata("ows_title",pegaNome($l)); |
| 425 | + $l->setmetadata("ows_srs",$listaepsg); | ||
| 426 | + $l->set("status",MS_OFF); | ||
| 427 | + $l->setmetadata("gml_include_items","all"); | ||
| 428 | + $l->set("dump",MS_TRUE); | ||
| 429 | + $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
| 430 | + $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
| 427 | 431 | ||
| 428 | - $l->setmetadata("ows_metadataurl_href",$c["fonte"]); | ||
| 429 | - $l->setmetadata("ows_metadataurl_type","TC211"); | ||
| 430 | - $l->setmetadata("ows_metadataurl_format","text/html"); | ||
| 431 | - if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){ | ||
| 432 | - $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png"; | ||
| 433 | - $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 434 | - $l->setmetadata("wms_attribution_logourl_height","50"); | ||
| 435 | - $l->setmetadata("wms_attribution_logourl_width","50"); | ||
| 436 | - $l->setmetadata("wms_attribution_logourl_href",$mini); | 432 | + $l->setmetadata("ows_metadataurl_href",$c["fonte"]); |
| 433 | + $l->setmetadata("ows_metadataurl_type","TC211"); | ||
| 434 | + $l->setmetadata("ows_metadataurl_format","text/html"); | ||
| 435 | + if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){ | ||
| 436 | + $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png"; | ||
| 437 | + $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 438 | + $l->setmetadata("wms_attribution_logourl_height","50"); | ||
| 439 | + $l->setmetadata("wms_attribution_logourl_width","50"); | ||
| 440 | + $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
| 441 | + } | ||
| 442 | + ms_newLayerObj($oMap, $l); | ||
| 437 | } | 443 | } |
| 438 | - ms_newLayerObj($oMap, $l); | ||
| 439 | } | 444 | } |
| 440 | } | 445 | } |
| 441 | } | 446 | } |
| 442 | } | 447 | } |
| 443 | - } | ||
| 444 | - else{ | ||
| 445 | - echo "Erro no arquivo ".$locaplic."/temas/".$codigoTema.".map <br>"; | ||
| 446 | - $error = ms_GetErrorObj(); | ||
| 447 | - while($error && $error->code != MS_NOERR){ | ||
| 448 | - printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message); | ||
| 449 | - $error = $error->next(); | 448 | + else{ |
| 449 | + echo "Erro no arquivo ".$locaplic."/temas/".$codigoTema.".map <br>"; | ||
| 450 | + $error = ms_GetErrorObj(); | ||
| 451 | + while($error && $error->code != MS_NOERR){ | ||
| 452 | + printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message); | ||
| 453 | + $error = $error->next(); | ||
| 454 | + } | ||
| 450 | } | 455 | } |
| 451 | } | 456 | } |
| 452 | - } | 457 | + } |
| 453 | } | 458 | } |
| 459 | + $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename)); | ||
| 460 | + $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); | ||
| 461 | + $oMap->save($nomeMapfileTmp); | ||
| 454 | } | 462 | } |
| 455 | if($cache == true){ | 463 | if($cache == true){ |
| 456 | 464 | ||
| 465 | +} | ||
| 466 | + | ||
| 467 | +// | ||
| 468 | +//altera os caminhos das imagens | ||
| 469 | +// | ||
| 470 | +if((isset($legenda)) && (strtolower($legenda) == "sim")){ | ||
| 471 | + $leg = $oMap->legend; | ||
| 472 | + $leg->set("status",MS_EMBED); | ||
| 473 | + $cache = false; | ||
| 457 | } | 474 | } |
| 475 | + | ||
| 458 | ms_ioinstallstdouttobuffer(); | 476 | ms_ioinstallstdouttobuffer(); |
| 459 | 477 | ||
| 460 | $oMap->owsdispatch($req); | 478 | $oMap->owsdispatch($req); |
| 461 | $contenttype = ms_iostripstdoutbuffercontenttype(); | 479 | $contenttype = ms_iostripstdoutbuffercontenttype(); |
| 462 | -if(strtolower($request) == "getcapabilities") | ||
| 463 | -{ | 480 | +if(strtolower($request) == "getcapabilities"){ |
| 464 | header('Content-Disposition: attachment; filename=getcapabilities.xml'); | 481 | header('Content-Disposition: attachment; filename=getcapabilities.xml'); |
| 465 | } | 482 | } |
| 466 | //header("Content-type: application/xml"); | 483 | //header("Content-type: application/xml"); |