Commit 2ae150a386352353c129bcc4e99414d2d77707f2
1 parent
3d54826b
Exists in
master
and in
7 other branches
--no commit message
Showing
1 changed file
with
617 additions
and
580 deletions
Show diff stats
ogc.php
| 1 | <?php | 1 | <?php |
| 2 | -/* | ||
| 3 | -Title: ogc.php | ||
| 4 | - | ||
| 5 | -Gera web services nos padrões OGC | ||
| 6 | - | ||
| 7 | -A lista de projeções mostradas na função getcapabilities é definida na variável $listaepsg. Edite essa variável | ||
| 8 | -se forem necessárias outras projeções além das existentes | ||
| 9 | - | ||
| 10 | -Licenca: | ||
| 11 | - | ||
| 12 | -i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | ||
| 13 | - | ||
| 14 | -Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | ||
| 15 | -Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | ||
| 16 | - | ||
| 17 | -Este programa é software livre; você pode redistribuí-lo | ||
| 18 | -e/ou modificá-lo sob os termos da Licença Pública Geral | ||
| 19 | -GNU conforme publicada pela Free Software Foundation; | ||
| 20 | - | ||
| 21 | -Este programa é distribuído na expectativa de que seja útil, | ||
| 22 | -porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | ||
| 23 | -de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | ||
| 24 | -Consulte a Licença Pública Geral do GNU para mais detalhes. | ||
| 25 | -Você deve ter recebido uma cópia da Licença Pública Geral do | ||
| 26 | -GNU junto com este programa; se não, escreva para a | ||
| 27 | -Free Software Foundation, Inc., no endereço | ||
| 28 | -59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
| 29 | - | ||
| 30 | -Arquivo: i3geo/ogc.php | ||
| 31 | - | ||
| 32 | -Parametros: | ||
| 33 | - | ||
| 34 | -lista - se for igual a "temas", mostra uma lista dos temas disponíveis | ||
| 35 | - se for igual a "temaswfs", mostra a lista de temas wfs | ||
| 36 | - | ||
| 37 | -ajuda - se for definida na URL, mostra uma ajuda ao usuário | ||
| 38 | - | ||
| 39 | -tema - nome do tema do serviço. Se for definido, o web service conterá apenas esse tema. O tema é o nome do mapfile existente em i3geo/temas, mas pode ser especificado um mapfile existente em outra pasta. Nesse caso, deve-se especificar o caminho completo para o arquivo. | ||
| 40 | - | ||
| 41 | -intervalo - valor inicial e final com o número de temas que serão mostrados no serviço | ||
| 42 | - | ||
| 43 | -legenda - mostra a legenda no corpo do mapa sim|nao | ||
| 44 | - | ||
| 45 | -perfil - perfil utilizado para escolher os menus | ||
| 46 | - | ||
| 47 | -format - (opcional) pode ser utilizado a opção &format=application/openlayers para abrir o mashup do OpenLayers com as camadas definida em temas, exemplo | ||
| 48 | - http://localhost/i3geo/ogc.php?temas=biomashp&format=application/openlayers&bbox=-54,-14,-50,-10 | ||
| 49 | - | ||
| 50 | -Exemplos: | ||
| 51 | - | ||
| 52 | -ogc.php?lista=temas | ||
| 53 | - | ||
| 54 | -ogc.php?tema=bioma | ||
| 55 | - | ||
| 56 | -ogc.php?tema=/var/www/i3geo/aplicmap/geral1debianv6.map&layers=mundo | ||
| 57 | - | ||
| 58 | -ogc.php?intervalo=0,50 | ||
| 59 | -*/ | 2 | +/* |
| 3 | + Title: ogc.php | ||
| 4 | + | ||
| 5 | +Gera web services nos padrões OGC | ||
| 6 | + | ||
| 7 | +A lista de projeções mostradas na função getcapabilities é definida na variável $listaepsg. Edite essa variável | ||
| 8 | +se forem necessárias outras projeções além das existentes | ||
| 9 | + | ||
| 10 | +Licenca: | ||
| 11 | + | ||
| 12 | +i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | ||
| 13 | + | ||
| 14 | +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | ||
| 15 | +Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | ||
| 16 | + | ||
| 17 | +Este programa é software livre; você pode redistribuí-lo | ||
| 18 | +e/ou modificá-lo sob os termos da Licença Pública Geral | ||
| 19 | +GNU conforme publicada pela Free Software Foundation; | ||
| 20 | + | ||
| 21 | +Este programa é distribuído na expectativa de que seja útil, | ||
| 22 | +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | ||
| 23 | +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | ||
| 24 | +Consulte a Licença Pública Geral do GNU para mais detalhes. | ||
| 25 | +Você deve ter recebido uma cópia da Licença Pública Geral do | ||
| 26 | + GNU junto com este programa; se não, escreva para a | ||
| 27 | +Free Software Foundation, Inc., no endereço | ||
| 28 | +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
| 29 | + | ||
| 30 | +Arquivo: i3geo/ogc.php | ||
| 31 | + | ||
| 32 | +Parametros: | ||
| 33 | + | ||
| 34 | +lista - se for igual a "temas", mostra uma lista dos temas disponíveis | ||
| 35 | +se for igual a "temaswfs", mostra a lista de temas wfs | ||
| 36 | + | ||
| 37 | +ajuda - se for definida na URL, mostra uma ajuda ao usuário | ||
| 38 | + | ||
| 39 | +tema - nome do tema do serviço. Se for definido, o web service conterá apenas esse tema. O tema é o nome do mapfile existente em i3geo/temas, mas pode ser especificado um mapfile existente em outra pasta. Nesse caso, deve-se especificar o caminho completo para o arquivo. | ||
| 40 | + | ||
| 41 | +intervalo - valor inicial e final com o número de temas que serão mostrados no serviço | ||
| 42 | + | ||
| 43 | +legenda - mostra a legenda no corpo do mapa sim|nao | ||
| 44 | + | ||
| 45 | +perfil - perfil utilizado para escolher os menus | ||
| 46 | + | ||
| 47 | +format - (opcional) pode ser utilizado a opção &format=application/openlayers para abrir o mashup do OpenLayers com as camadas definida em temas, exemplo | ||
| 48 | +http://localhost/i3geo/ogc.php?temas=biomashp&format=application/openlayers&bbox=-54,-14,-50,-10 | ||
| 49 | + | ||
| 50 | +Exemplos: | ||
| 51 | + | ||
| 52 | +ogc.php?lista=temas | ||
| 53 | + | ||
| 54 | +ogc.php?tema=bioma | ||
| 55 | + | ||
| 56 | +ogc.php?tema=/var/www/i3geo/aplicmap/geral1debianv6.map&layers=mundo | ||
| 57 | + | ||
| 58 | +ogc.php?intervalo=0,50 | ||
| 59 | +*/ | ||
| 60 | +// | ||
| 61 | +//validações e includes | ||
| 60 | // | 62 | // |
| 61 | -//validações e includes | ||
| 62 | -// | ||
| 63 | -$cache = true; | ||
| 64 | -require_once(__DIR__."/classesphp/carrega_ext.php"); | ||
| 65 | -include(__DIR__."/ms_configura.php"); | ||
| 66 | -include(__DIR__."/classesphp/pega_variaveis.php"); | ||
| 67 | -if(!isset($temas) && isset($tema)) | ||
| 68 | -{$temas = $tema;} | ||
| 69 | -// | ||
| 70 | -//para operar como o Geoserver | ||
| 71 | -// | ||
| 72 | -if(isset($format) && strtolower($format) == "application/openlayers"){ | ||
| 73 | - if(!isset($layers)) | ||
| 74 | - {$layers = $temas;} | ||
| 75 | - $urln = __DIR__."/mashups/openlayers.php?temas=".$layers."&layers=".$layers."&mapext=".$bbox."&botoes=pan,zoombox,zoomtot,identifica"; | ||
| 76 | - if(!headers_sent()) | ||
| 77 | - {header("Location:".$urln);} | ||
| 78 | - else | ||
| 79 | - {echo "<meta http-equiv='refresh' content='0;url=$urln'>";} | ||
| 80 | -} | ||
| 81 | -// | ||
| 82 | -//pega os endereços para compor a url de chamada do gerador de web services | ||
| 83 | -//ogc.php | ||
| 84 | -// | ||
| 85 | -$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | ||
| 86 | -$protocolo = $protocolo[0]; | ||
| 87 | -$protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME']; | ||
| 88 | -$protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; | ||
| 89 | -$urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]); | ||
| 90 | -// | ||
| 91 | -//imprime na tela a ajuda | ||
| 92 | -// | ||
| 93 | -if(isset($ajuda)){ | ||
| 94 | - ogc_imprimeAjuda(); | ||
| 95 | - exit; | ||
| 96 | -} | ||
| 97 | -// | ||
| 98 | -//imprime na tela a lista de temas disponíveis | ||
| 99 | -// | ||
| 100 | -if(isset($lista) && $lista == "temas"){ | ||
| 101 | - include_once(__DIR__."/classesphp/classe_menutemas.php"); | ||
| 102 | - ogc_imprimeListaDeTemas(); | ||
| 103 | - exit; | ||
| 104 | -} | ||
| 105 | -if(isset($lista) && $lista == "temaswfs"){ | ||
| 106 | - include_once(__DIR__."/classesphp/classe_menutemas.php"); | ||
| 107 | - ogc_imprimeListaDeTemasWfs(); | ||
| 108 | - exit; | ||
| 109 | -} | ||
| 110 | -// | ||
| 111 | -//cria o web service | ||
| 112 | -// | ||
| 113 | -include(__DIR__."/classesphp/funcoes_gerais.php"); | ||
| 114 | -error_reporting(0); | ||
| 115 | -$versao = versao(); | ||
| 116 | -$versao = $versao["principal"]; | ||
| 117 | -$req = ms_newowsrequestobj(); | ||
| 118 | -$tipo = ""; | ||
| 119 | -$_GET = array_merge($_GET,$_POST); | ||
| 120 | - | ||
| 121 | -if(isset($_GET["sld"]) || isset($_GET["filter"])){ | ||
| 122 | - $cache = false; | ||
| 123 | -} | ||
| 124 | -foreach ($_GET as $k=>$v){ | ||
| 125 | - $req->setParameter($k, $v); | ||
| 126 | - if(strtolower($v) == "getcapabilities"){ | ||
| 127 | - $tipo = "metadados"; | ||
| 128 | - $cache = false; | ||
| 129 | - } | ||
| 130 | - if(strtolower($k) == "layers" && empty($_GET["tema"])) | ||
| 131 | - {$tema = $v;} | ||
| 132 | - if(strtolower($k) == "layer" && empty($_GET["tema"])) | ||
| 133 | - {$tema = $v;} | ||
| 134 | -} | ||
| 135 | -if(empty($srs)){ | ||
| 136 | - $srs = ""; | ||
| 137 | -} | ||
| 138 | -if(!empty($SRS)){ | ||
| 139 | - $srs = $SRS; | ||
| 140 | -} | ||
| 141 | -$listaepsg = $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"; | ||
| 142 | -if(count($_GET) == 0){ | ||
| 143 | - $tipo="intervalo"; | ||
| 144 | - $req->setParameter("REQUEST", "getCapabilities"); | ||
| 145 | - $req->setParameter("SERVICE", "WMS"); | ||
| 146 | - $cache = false; | ||
| 147 | -} | ||
| 148 | -if(isset($tema) && $tipo != "metadados"){ | ||
| 149 | - $tipo = ""; | ||
| 150 | -} | ||
| 151 | -if(!isset($version)){ | ||
| 152 | - $req->setParameter("VeRsIoN","1.1.0"); | ||
| 153 | -} | ||
| 154 | -$oMap = ms_newMapobj($locaplic."/aplicmap/ogcwsv".$versao.".map"); | ||
| 155 | -// | ||
| 156 | -//altera os caminhos das imagens | ||
| 157 | -// | ||
| 158 | -if((isset($legenda)) && (strtolower($legenda) == "sim")){ | ||
| 159 | - $leg = $oMap->legend; | ||
| 160 | - $leg->set("status",MS_EMBED); | ||
| 161 | - $cache = false; | ||
| 162 | -} | ||
| 163 | -$proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://"; | ||
| 164 | -$server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; | ||
| 165 | -$or = $proto.$server.$_SERVER['PHP_SELF']; | ||
| 166 | -if((isset($tema)) && ($tema != "") && ($tipo=="metadados")){ | ||
| 167 | - $or = $or."?tema=".$tema."&"; | ||
| 168 | -} | ||
| 169 | -// | ||
| 170 | -//parametros no nível maior | ||
| 171 | -// | ||
| 172 | -$oMap->setmetadata("ows_onlineresource",$or); | ||
| 173 | -$oMap->setmetadata("wms_onlineresource",$or); | ||
| 174 | -$oMap->setmetadata("wms_title",$tituloInstituicao." - i3geo"); | ||
| 175 | -$oMap->setmetadata("wfs_title",$tituloInstituicao." - i3geo"); | ||
| 176 | -$oMap->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 177 | -$oMap->setmetadata("wms_attribution_logourl_height","56"); | ||
| 178 | -$oMap->setmetadata("wms_attribution_logourl_width","85"); | ||
| 179 | -$oMap->setmetadata("wms_attribution_logourl_href",$proto.$server.dirname($_SERVER['PHP_SELF'])."/imagens/i3geo.png"); | ||
| 180 | -$oMap->setmetadata("wms_attribution_onlineresource",$proto.$server.dirname($_SERVER['PHP_SELF'])); | ||
| 181 | -$oMap->setmetadata("wms_attribution_title",$tituloInstituicao); | ||
| 182 | -$oMap->setmetadata("ows_enable_request","*"); | ||
| 183 | -$e = $oMap->extent; | ||
| 184 | -$extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | ||
| 185 | -if (!isset($intervalo)){ | ||
| 186 | - $intervalo = "0,5000"; | ||
| 187 | -} | ||
| 188 | -else{ | ||
| 189 | - $tipo = "intervalo"; | ||
| 190 | -} | ||
| 191 | -if(!isset($tema)){ | ||
| 192 | - if(!isset($intervalo)) | ||
| 193 | - {$intervalo = "0,5000";} | ||
| 194 | - $tipo = "intervalo"; | ||
| 195 | -} | ||
| 196 | -if ($tipo == "" || $tipo == "metadados"){ | ||
| 197 | - $tema = explode(" ",$tema); | ||
| 198 | - //para o caso do tema ser um arquivo mapfile existente em uma pasta qualquer | ||
| 199 | - //$temai3geo = true indica que o layer será buscado na pasta i3geo/temas | ||
| 200 | - $temai3geo = true; | ||
| 201 | - //FIXME não aceita gvp quando o caminho é completo | ||
| 202 | - if(file_exists($_GET["tema"])){ | ||
| 203 | - $nmap = ms_newMapobj($_GET["tema"]); | ||
| 204 | - $temai3geo = false; | ||
| 205 | - $nmap->setmetadata("ows_enable_request","*"); | ||
| 206 | - } | ||
| 207 | - foreach ($tema as $tx){ | ||
| 208 | - $extensao = ".map"; | ||
| 209 | - if(file_exists($locaplic."/temas/".$tx.".php") && $temai3geo == true){ | ||
| 210 | - $extensao = ".php"; | ||
| 211 | - } | ||
| 212 | - if(file_exists($locaplic."/temas/".$tx.".gvp") && $temai3geo == true){ | ||
| 213 | - $extensao = ".gvp"; | ||
| 214 | - } | ||
| 215 | - if($extensao == ".map"){ | ||
| 216 | - if($temai3geo == true){ | ||
| 217 | - $nmap = ms_newMapobj($locaplic."/temas/".$tx.".map"); | ||
| 218 | - $nmap->setmetadata("ows_enable_request","*"); | ||
| 219 | - } | ||
| 220 | - if($temai3geo == false || empty($layers)) | ||
| 221 | - {$ts = $nmap->getalllayernames();} | ||
| 222 | - else{ | ||
| 223 | - $ts = explode(",",str_replace(" ",",",$layers)); | ||
| 224 | - } | ||
| 225 | - foreach ($ts as $t){ | ||
| 226 | - $l = $nmap->getlayerbyname($t); | ||
| 227 | - $permite = $l->getmetadata("permiteogc"); | ||
| 228 | - if(strtolower($permite) != "nao"){ | ||
| 229 | - //necessário pq o mapfile pode ter todos os layers como default | ||
| 230 | - if($temai3geo == false){ | ||
| 231 | - $l->set("status",MS_OFF); | ||
| 232 | - } | ||
| 233 | - if($cache == true && strtolower($l->getmetadata('cache')) == 'sim' && $tipo == '' && count($tema) == 1){ | ||
| 234 | - carregaCacheImagem($_GET['BBOX'],$tx,$_GET['WIDTH'],$_GET['HEIGHT'],$cachedir); | ||
| 235 | - } | ||
| 236 | - $l->setmetadata("ows_title",pegaNome($l)); | ||
| 237 | - $l->setmetadata("ows_srs",$listaepsg); | ||
| 238 | - $l->set("group",""); | ||
| 239 | - //essa linha é necessária pq as vezes no mapfile não tem nenhum layer com o nome igual ao nome do mapfile | ||
| 240 | - if(count($ts)==1){ | ||
| 241 | - $l->set("name",$tx); | ||
| 242 | - } | ||
| 243 | - $l->setmetadata("gml_include_items","all"); | ||
| 244 | - $l->set("template","none.htm"); | ||
| 245 | - $l->set("dump",MS_TRUE); | ||
| 246 | - $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
| 247 | - $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
| 248 | - if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){ | ||
| 249 | - $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png"; | ||
| 250 | - $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 251 | - $l->setmetadata("wms_attribution_logourl_height","50"); | ||
| 252 | - $l->setmetadata("wms_attribution_logourl_width","50"); | ||
| 253 | - $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
| 254 | - } | ||
| 255 | - if($l->type == MS_LAYER_RASTER && $l->numclasses > 0){ | ||
| 256 | - $c = $l->getclass(0); | ||
| 257 | - if($c->name == "") | ||
| 258 | - {$c->name = " ";} | ||
| 259 | - } | ||
| 260 | - //inclui extensao geografica | ||
| 261 | - $extensao = $l->getmetadata("EXTENSAO"); | ||
| 262 | - if($extensao == ""){ | ||
| 263 | - $extensao = $extensaoMap; | ||
| 264 | - } | ||
| 265 | - $l->setmetadata("wms_extent",$extensao); | ||
| 266 | - if (!empty($postgis_mapa)){ | ||
| 267 | - if ($l->connectiontype == MS_POSTGIS){ | ||
| 268 | - $lcon = $l->connection; | ||
| 269 | - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ | ||
| 270 | - // | ||
| 271 | - //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | ||
| 272 | - // | ||
| 273 | - if(($lcon == " ") || ($lcon == "")){ | ||
| 274 | - $l->set("connection",$postgis_mapa); | ||
| 275 | - $l->setmetadata("CONEXAOORIGINAL",$lcon); | ||
| 276 | - } | ||
| 277 | - else{ | ||
| 278 | - $l->set("connection",$postgis_mapa[$lcon]); | ||
| 279 | - $l->setmetadata("CONEXAOORIGINAL",$lcon); | ||
| 280 | - } | ||
| 281 | - } | ||
| 282 | - } | ||
| 283 | - } | ||
| 284 | - autoClasses($l,$oMap); | ||
| 285 | - ms_newLayerObj($oMap, $l); | ||
| 286 | - } | ||
| 287 | - } | ||
| 288 | - } | ||
| 289 | - if($extensao == ".php"){ | ||
| 290 | - include_once($locaplic."/temas/".$tx.".php"); | ||
| 291 | - eval($tx."(\$oMap);"); | ||
| 292 | - } | ||
| 293 | - if($extensao == ".gvp"){ | ||
| 294 | - include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); | ||
| 295 | - $gm = new gvsig2mapfile($locaplic."/temas/".$tx.".gvp"); | ||
| 296 | - $gvsigview = $gm->getViewsNames(); | ||
| 297 | - $gvsigview = $gvsigview[0]; | ||
| 298 | - $dataView = $gm->getViewData($gvsigview); | ||
| 299 | - $oMap = $gm->addLayers($oMap,$gvsigview,$dataView["layerNames"]); | ||
| 300 | - $numlayers = $oMap->numlayers; | ||
| 301 | - $layers = array(); | ||
| 302 | - //$layers[] = "default"; | ||
| 303 | - for ($i=0;$i < $numlayers;$i++){ | ||
| 304 | - $l = $oMap->getlayer($i); | ||
| 305 | - $l->setmetadata("gml_include_items","all"); | ||
| 306 | - $l->set("dump",MS_TRUE); | ||
| 307 | - $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
| 308 | - $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
| 309 | - $l->setmetadata("ows_srs",$listaepsg); | ||
| 310 | - $l->setmetadata("ows_title",$l->getmetadata("TEMA")); | ||
| 311 | - $l->set("status",MS_OFF); | ||
| 312 | - $layers[] = $l->name; | ||
| 313 | - if(file_exists($locaplic."/temas/miniaturas/".$tx.".map.mini.png")){ | ||
| 314 | - $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$tx.".map.mini.png"; | ||
| 315 | - $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 316 | - $l->setmetadata("wms_attribution_logourl_height","50"); | ||
| 317 | - $l->setmetadata("wms_attribution_logourl_width","50"); | ||
| 318 | - $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
| 319 | - } | ||
| 320 | - if($l->type == MS_LAYER_RASTER && $l->numclasses > 0){ | ||
| 321 | - $c = $l->getclass(0); | ||
| 322 | - if($c->name == "") | ||
| 323 | - {$c->name = " ";} | ||
| 324 | - } | ||
| 325 | - //inclui extensao geografica | ||
| 326 | - $extensao = $l->getmetadata("EXTENSAO"); | ||
| 327 | - if($extensao == ""){ | ||
| 328 | - $extensao = $extensaoMap; | ||
| 329 | - } | ||
| 330 | - $l->setmetadata("wms_extent",$extensao); | ||
| 331 | - } | ||
| 332 | - $req->setParameter("LAYERS", implode(",",$layers)); | ||
| 333 | - $req->setParameter("STYLES", ""); | ||
| 334 | - //r_dump($req);exit; | ||
| 335 | - } | ||
| 336 | - } | 63 | +$cache = true; |
| 64 | +require_once(__DIR__."/classesphp/carrega_ext.php"); | ||
| 65 | +include(__DIR__."/ms_configura.php"); | ||
| 66 | +include(__DIR__."/classesphp/pega_variaveis.php"); | ||
| 67 | +if(!isset($temas) && isset($tema)) | ||
| 68 | +{ | ||
| 69 | + $temas = $tema; | ||
| 70 | +} | ||
| 71 | +// | ||
| 72 | +//para operar como o Geoserver | ||
| 73 | +// | ||
| 74 | +if(isset($format) && strtolower($format) == "application/openlayers"){ | ||
| 75 | + if(!isset($layers)) | ||
| 76 | + { | ||
| 77 | + $layers = $temas; | ||
| 78 | + } | ||
| 79 | + $urln = __DIR__."/mashups/openlayers.php?temas=".$layers."&layers=".$layers."&mapext=".$bbox."&botoes=pan,zoombox,zoomtot,identifica"; | ||
| 80 | + if(!headers_sent()) | ||
| 81 | + { | ||
| 82 | + header("Location:".$urln); | ||
| 83 | + } | ||
| 84 | + else | ||
| 85 | + {echo "<meta http-equiv='refresh' content='0;url=$urln'>"; | ||
| 86 | + } | ||
| 87 | +} | ||
| 88 | +// | ||
| 89 | +//pega os endereços para compor a url de chamada do gerador de web services | ||
| 90 | +//ogc.php | ||
| 91 | +// | ||
| 92 | +$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | ||
| 93 | +$protocolo = $protocolo[0]; | ||
| 94 | +$protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME']; | ||
| 95 | +$protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; | ||
| 96 | +$urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]); | ||
| 97 | +// | ||
| 98 | +//imprime na tela a ajuda | ||
| 99 | +// | ||
| 100 | +if(isset($ajuda)){ | ||
| 101 | + ogc_imprimeAjuda(); | ||
| 102 | + exit; | ||
| 103 | +} | ||
| 104 | +// | ||
| 105 | +//imprime na tela a lista de temas disponíveis | ||
| 106 | +// | ||
| 107 | +if(isset($lista) && $lista == "temas"){ | ||
| 108 | + include_once(__DIR__."/classesphp/classe_menutemas.php"); | ||
| 109 | + ogc_imprimeListaDeTemas(); | ||
| 110 | + exit; | ||
| 111 | +} | ||
| 112 | +if(isset($lista) && $lista == "temaswfs"){ | ||
| 113 | + include_once(__DIR__."/classesphp/classe_menutemas.php"); | ||
| 114 | + ogc_imprimeListaDeTemasWfs(); | ||
| 115 | + exit; | ||
| 116 | +} | ||
| 117 | +// | ||
| 118 | +//cria o web service | ||
| 119 | +// | ||
| 120 | +include(__DIR__."/classesphp/funcoes_gerais.php"); | ||
| 121 | +error_reporting(0); | ||
| 122 | +$versao = versao(); | ||
| 123 | +$versao = $versao["principal"]; | ||
| 124 | +$req = ms_newowsrequestobj(); | ||
| 125 | +$tipo = ""; | ||
| 126 | +$_GET = array_merge($_GET,$_POST); | ||
| 127 | + | ||
| 128 | +if(isset($_GET["sld"]) || isset($_GET["filter"])){ | ||
| 129 | + $cache = false; | ||
| 130 | +} | ||
| 131 | +foreach ($_GET as $k=>$v){ | ||
| 132 | + $req->setParameter($k, $v); | ||
| 133 | + if(strtolower($v) == "getcapabilities"){ | ||
| 134 | + $tipo = "metadados"; | ||
| 135 | + $cache = false; | ||
| 136 | + } | ||
| 137 | + if(strtolower($k) == "layers" && empty($_GET["tema"])) | ||
| 138 | + { | ||
| 139 | + $tema = $v; | ||
| 140 | + } | ||
| 141 | + if(strtolower($k) == "layer" && empty($_GET["tema"])) | ||
| 142 | + { | ||
| 143 | + $tema = $v; | ||
| 144 | + } | ||
| 145 | +} | ||
| 146 | +if(empty($srs)){ | ||
| 147 | + $srs = ""; | ||
| 148 | +} | ||
| 149 | +if(!empty($SRS)){ | ||
| 150 | + $srs = $SRS; | ||
| 151 | +} | ||
| 152 | +$listaepsg = $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"; | ||
| 153 | +if(count($_GET) == 0){ | ||
| 154 | + $tipo="intervalo"; | ||
| 155 | + $req->setParameter("REQUEST", "getCapabilities"); | ||
| 156 | + $req->setParameter("SERVICE", "WMS"); | ||
| 157 | + $cache = false; | ||
| 337 | } | 158 | } |
| 338 | -else{ | ||
| 339 | - $conta = 0; | ||
| 340 | - $int = explode(",",$intervalo); | ||
| 341 | - $codigosTema = array(); | ||
| 342 | - if(empty($perfil)){$perfil = "";} | ||
| 343 | - include("classesphp/classe_menutemas.php"); | ||
| 344 | - $m = new Menutemas("",$perfil,$locaplic,$urli3geo); | ||
| 345 | - $menus = $m->pegaListaDeMenus(); | ||
| 346 | - foreach ($menus as $menu){ | ||
| 347 | - $grupos = $m->pegaListaDeGrupos($menu["idmenu"],$listasistemas="nao",$listasgrupos="sim"); | ||
| 348 | - foreach($grupos as $grupo){ | ||
| 349 | - if(strtolower($grupo["ogc"]) == "sim"){ | ||
| 350 | - foreach($grupo["subgrupos"] as $sgrupo){ | ||
| 351 | - if(strtolower($sgrupo["ogc"]) == "sim"){ | ||
| 352 | - $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
| 353 | - foreach($temas as $tema){ | ||
| 354 | - if(strtolower($tema["ogc"]) == "sim"){ | ||
| 355 | - $codigosTema[] = array("tema"=>$tema["tid"],"fonte"=>$tema["link"]); | ||
| 356 | - } | ||
| 357 | - } | ||
| 358 | - } | ||
| 359 | - } | ||
| 360 | - } | ||
| 361 | - } | ||
| 362 | - } | ||
| 363 | - //echo "<pre>"; | ||
| 364 | - //var_dump($codigosTema); | ||
| 365 | - //exit; | ||
| 366 | - foreach($codigosTema as $c){ | ||
| 367 | - $codigoTema = $c["tema"]; | ||
| 368 | - if(file_exists($locaplic."/temas/".$codigoTema.".map")){ | ||
| 369 | - if (@ms_newMapobj($locaplic."/temas/".$codigoTema.".map")){ | ||
| 370 | - $nmap = ms_newMapobj($locaplic."/temas/".$codigoTema.".map"); | ||
| 371 | - $nmap->setmetadata("ows_enable_request","*"); | 159 | + |
| 160 | +if(isset($tema) && $tipo != "metadados"){ | ||
| 161 | + $tipo = ""; | ||
| 162 | +} | ||
| 163 | +if(!isset($version)){ | ||
| 164 | + $req->setParameter("VeRsIoN","1.1.0"); | ||
| 165 | +} | ||
| 166 | +$oMap = ms_newMapobj($locaplic."/aplicmap/ogcwsv".$versao.".map"); | ||
| 167 | +// | ||
| 168 | +//altera os caminhos das imagens | ||
| 169 | +// | ||
| 170 | +if((isset($legenda)) && (strtolower($legenda) == "sim")){ | ||
| 171 | + $leg = $oMap->legend; | ||
| 172 | + $leg->set("status",MS_EMBED); | ||
| 173 | + $cache = false; | ||
| 174 | +} | ||
| 175 | +$proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://"; | ||
| 176 | +$server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; | ||
| 177 | +$or = $proto.$server.$_SERVER['PHP_SELF']; | ||
| 178 | +if((isset($tema)) && ($tema != "") && ($tipo=="metadados")){ | ||
| 179 | + $or = $or."?tema=".$tema."&"; | ||
| 180 | +} | ||
| 181 | +// | ||
| 182 | +//parametros no nível maior | ||
| 183 | +// | ||
| 184 | +$oMap->setmetadata("ows_onlineresource",$or); | ||
| 185 | +$oMap->setmetadata("wms_onlineresource",$or); | ||
| 186 | +$oMap->setmetadata("wms_title",$tituloInstituicao." - i3geo"); | ||
| 187 | +$oMap->setmetadata("wfs_title",$tituloInstituicao." - i3geo"); | ||
| 188 | +$oMap->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 189 | +$oMap->setmetadata("wms_attribution_logourl_height","56"); | ||
| 190 | +$oMap->setmetadata("wms_attribution_logourl_width","85"); | ||
| 191 | +$oMap->setmetadata("wms_attribution_logourl_href",$proto.$server.dirname($_SERVER['PHP_SELF'])."/imagens/i3geo.png"); | ||
| 192 | +$oMap->setmetadata("wms_attribution_onlineresource",$proto.$server.dirname($_SERVER['PHP_SELF'])); | ||
| 193 | +$oMap->setmetadata("wms_attribution_title",$tituloInstituicao); | ||
| 194 | +$oMap->setmetadata("ows_enable_request","*"); | ||
| 195 | +$e = $oMap->extent; | ||
| 196 | +$extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | ||
| 197 | +if (!isset($intervalo)){ | ||
| 198 | + $intervalo = "0,5000"; | ||
| 199 | +} | ||
| 200 | +else{ | ||
| 201 | + $tipo = "intervalo"; | ||
| 202 | +} | ||
| 203 | +if(!isset($tema)){ | ||
| 204 | + if(!isset($intervalo)) | ||
| 205 | + { | ||
| 206 | + $intervalo = "0,5000"; | ||
| 207 | + } | ||
| 208 | + $tipo = "intervalo"; | ||
| 209 | +} | ||
| 210 | +if ($tipo == "" || $tipo == "metadados"){ | ||
| 211 | + $tema = explode(" ",$tema); | ||
| 212 | + //para o caso do tema ser um arquivo mapfile existente em uma pasta qualquer | ||
| 213 | + //$temai3geo = true indica que o layer será buscado na pasta i3geo/temas | ||
| 214 | + $temai3geo = true; | ||
| 215 | + //FIXME não aceita gvp quando o caminho é completo | ||
| 216 | + if(file_exists($_GET["tema"])){ | ||
| 217 | + $nmap = ms_newMapobj($_GET["tema"]); | ||
| 218 | + $temai3geo = false; | ||
| 219 | + $nmap->setmetadata("ows_enable_request","*"); | ||
| 220 | + } | ||
| 221 | + foreach ($tema as $tx){ | ||
| 222 | + $extensao = ".map"; | ||
| 223 | + if(file_exists($locaplic."/temas/".$tx.".php") && $temai3geo == true){ | ||
| 224 | + $extensao = ".php"; | ||
| 225 | + } | ||
| 226 | + if(file_exists($locaplic."/temas/".$tx.".gvp") && $temai3geo == true){ | ||
| 227 | + $extensao = ".gvp"; | ||
| 228 | + } | ||
| 229 | + if($extensao == ".map"){ | ||
| 230 | + if($temai3geo == true){ | ||
| 231 | + $nmap = ms_newMapobj($locaplic."/temas/".$tx.".map"); | ||
| 232 | + $nmap->setmetadata("ows_enable_request","*"); | ||
| 233 | + } | ||
| 234 | + if($temai3geo == false || empty($layers)) | ||
| 235 | + { | ||
| 372 | $ts = $nmap->getalllayernames(); | 236 | $ts = $nmap->getalllayernames(); |
| 373 | - if (count($ts) == 1){ | ||
| 374 | - foreach ($ts as $t){ | ||
| 375 | - if ($oMap->getlayerbyname($t) == ""){ | ||
| 376 | - $conta++; | ||
| 377 | - if (($conta >= $int[0]) && ($conta <= $int[1])){ | ||
| 378 | - $l = $nmap->getlayerbyname($t); | ||
| 379 | - $extensao = $l->getmetadata("EXTENSAO"); | ||
| 380 | - if($extensao == "") | ||
| 381 | - {$extensao = $extensaoMap;} | ||
| 382 | - $l->setmetadata("wms_extent",$extensao); | ||
| 383 | - | ||
| 384 | - $l->setmetadata("ows_title",pegaNome($l)); | ||
| 385 | - $l->setmetadata("ows_srs",$listaepsg); | ||
| 386 | - $l->set("status",MS_OFF); | ||
| 387 | - $l->setmetadata("gml_include_items","all"); | ||
| 388 | - $l->set("dump",MS_TRUE); | ||
| 389 | - $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
| 390 | - $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
| 391 | - | ||
| 392 | - $l->setmetadata("ows_metadataurl_href",$c["fonte"]); | ||
| 393 | - $l->setmetadata("ows_metadataurl_type","TC211"); | ||
| 394 | - $l->setmetadata("ows_metadataurl_format","text/html"); | ||
| 395 | - if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){ | ||
| 396 | - $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png"; | ||
| 397 | - $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 398 | - $l->setmetadata("wms_attribution_logourl_height","50"); | ||
| 399 | - $l->setmetadata("wms_attribution_logourl_width","50"); | ||
| 400 | - $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
| 401 | - } | ||
| 402 | - ms_newLayerObj($oMap, $l); | ||
| 403 | - } | ||
| 404 | - } | ||
| 405 | - } | ||
| 406 | - } | ||
| 407 | - } | ||
| 408 | - } | 237 | + } |
| 238 | + else{ | ||
| 239 | + $ts = explode(",",str_replace(" ",",",$layers)); | ||
| 240 | + } | ||
| 241 | + foreach ($ts as $t){ | ||
| 242 | + $l = $nmap->getlayerbyname($t); | ||
| 243 | + $permite = $l->getmetadata("permiteogc"); | ||
| 244 | + if(strtolower($permite) != "nao"){ | ||
| 245 | + //necessário pq o mapfile pode ter todos os layers como default | ||
| 246 | + if($temai3geo == false){ | ||
| 247 | + $l->set("status",MS_OFF); | ||
| 248 | + } | ||
| 249 | + if($cache == true && strtolower($l->getmetadata('cache')) == 'sim' && $tipo == '' && count($tema) == 1){ | ||
| 250 | + carregaCacheImagem($_GET['BBOX'],$tx,$_GET['WIDTH'],$_GET['HEIGHT'],$cachedir); | ||
| 251 | + } | ||
| 252 | + $l->setmetadata("ows_title",pegaNome($l)); | ||
| 253 | + $l->setmetadata("ows_srs",$listaepsg); | ||
| 254 | + $l->set("group",""); | ||
| 255 | + //essa linha é necessária pq as vezes no mapfile não tem nenhum layer com o nome igual ao nome do mapfile | ||
| 256 | + if(count($ts)==1){ | ||
| 257 | + $l->set("name",$tx); | ||
| 258 | + } | ||
| 259 | + $l->setmetadata("gml_include_items","all"); | ||
| 260 | + $l->set("template","none.htm"); | ||
| 261 | + $l->set("dump",MS_TRUE); | ||
| 262 | + $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
| 263 | + $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
| 264 | + if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){ | ||
| 265 | + $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png"; | ||
| 266 | + $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 267 | + $l->setmetadata("wms_attribution_logourl_height","50"); | ||
| 268 | + $l->setmetadata("wms_attribution_logourl_width","50"); | ||
| 269 | + $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
| 270 | + } | ||
| 271 | + if($l->type == MS_LAYER_RASTER && $l->numclasses > 0){ | ||
| 272 | + $c = $l->getclass(0); | ||
| 273 | + if($c->name == "") | ||
| 274 | + { | ||
| 275 | + $c->name = " "; | ||
| 276 | + } | ||
| 277 | + } | ||
| 278 | + //inclui extensao geografica | ||
| 279 | + $extensao = $l->getmetadata("EXTENSAO"); | ||
| 280 | + if($extensao == ""){ | ||
| 281 | + $extensao = $extensaoMap; | ||
| 282 | + } | ||
| 283 | + $l->setmetadata("wms_extent",$extensao); | ||
| 284 | + if (!empty($postgis_mapa)){ | ||
| 285 | + if ($l->connectiontype == MS_POSTGIS){ | ||
| 286 | + $lcon = $l->connection; | ||
| 287 | + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ | ||
| 288 | + // | ||
| 289 | + //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | ||
| 290 | + // | ||
| 291 | + if(($lcon == " ") || ($lcon == "")){ | ||
| 292 | + $l->set("connection",$postgis_mapa); | ||
| 293 | + $l->setmetadata("CONEXAOORIGINAL",$lcon); | ||
| 294 | + } | ||
| 295 | + else{ | ||
| 296 | + $l->set("connection",$postgis_mapa[$lcon]); | ||
| 297 | + $l->setmetadata("CONEXAOORIGINAL",$lcon); | ||
| 298 | + } | ||
| 299 | + } | ||
| 300 | + } | ||
| 301 | + } | ||
| 302 | + autoClasses($l,$oMap); | ||
| 303 | + ms_newLayerObj($oMap, $l); | ||
| 304 | + } | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + if($extensao == ".php"){ | ||
| 308 | + include_once($locaplic."/temas/".$tx.".php"); | ||
| 309 | + eval($tx."(\$oMap);"); | ||
| 310 | + } | ||
| 311 | + if($extensao == ".gvp"){ | ||
| 312 | + include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); | ||
| 313 | + $gm = new gvsig2mapfile($locaplic."/temas/".$tx.".gvp"); | ||
| 314 | + $gvsigview = $gm->getViewsNames(); | ||
| 315 | + $gvsigview = $gvsigview[0]; | ||
| 316 | + $dataView = $gm->getViewData($gvsigview); | ||
| 317 | + $oMap = $gm->addLayers($oMap,$gvsigview,$dataView["layerNames"]); | ||
| 318 | + $numlayers = $oMap->numlayers; | ||
| 319 | + $layers = array(); | ||
| 320 | + //$layers[] = "default"; | ||
| 321 | + for ($i=0;$i < $numlayers;$i++){ | ||
| 322 | + $l = $oMap->getlayer($i); | ||
| 323 | + $l->setmetadata("gml_include_items","all"); | ||
| 324 | + $l->set("dump",MS_TRUE); | ||
| 325 | + $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
| 326 | + $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
| 327 | + $l->setmetadata("ows_srs",$listaepsg); | ||
| 328 | + $l->setmetadata("ows_title",$l->getmetadata("TEMA")); | ||
| 329 | + $l->set("status",MS_OFF); | ||
| 330 | + $layers[] = $l->name; | ||
| 331 | + if(file_exists($locaplic."/temas/miniaturas/".$tx.".map.mini.png")){ | ||
| 332 | + $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$tx.".map.mini.png"; | ||
| 333 | + $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 334 | + $l->setmetadata("wms_attribution_logourl_height","50"); | ||
| 335 | + $l->setmetadata("wms_attribution_logourl_width","50"); | ||
| 336 | + $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
| 337 | + } | ||
| 338 | + if($l->type == MS_LAYER_RASTER && $l->numclasses > 0){ | ||
| 339 | + $c = $l->getclass(0); | ||
| 340 | + if($c->name == "") | ||
| 341 | + { | ||
| 342 | + $c->name = " "; | ||
| 343 | + } | ||
| 344 | + } | ||
| 345 | + //inclui extensao geografica | ||
| 346 | + $extensao = $l->getmetadata("EXTENSAO"); | ||
| 347 | + if($extensao == ""){ | ||
| 348 | + $extensao = $extensaoMap; | ||
| 349 | + } | ||
| 350 | + $l->setmetadata("wms_extent",$extensao); | ||
| 351 | + } | ||
| 352 | + $req->setParameter("LAYERS", implode(",",$layers)); | ||
| 353 | + $req->setParameter("STYLES", ""); | ||
| 354 | + //r_dump($req);exit; | ||
| 355 | + } | ||
| 356 | + } | ||
| 357 | +} | ||
| 358 | +else{ | ||
| 359 | + $conta = 0; | ||
| 360 | + $int = explode(",",$intervalo); | ||
| 361 | + $codigosTema = array(); | ||
| 362 | + if(empty($perfil)){ | ||
| 363 | + $perfil = ""; | ||
| 364 | + } | ||
| 365 | + include("classesphp/classe_menutemas.php"); | ||
| 366 | + $m = new Menutemas("",$perfil,$locaplic,$urli3geo); | ||
| 367 | + $menus = $m->pegaListaDeMenus(); | ||
| 368 | + foreach ($menus as $menu){ | ||
| 369 | + $grupos = $m->pegaListaDeGrupos($menu["idmenu"],$listasistemas="nao",$listasgrupos="sim"); | ||
| 370 | + foreach($grupos as $grupo){ | ||
| 371 | + if(strtolower($grupo["ogc"]) == "sim"){ | ||
| 372 | + foreach($grupo["subgrupos"] as $sgrupo){ | ||
| 373 | + if(strtolower($sgrupo["ogc"]) == "sim"){ | ||
| 374 | + $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
| 375 | + foreach($temas as $tema){ | ||
| 376 | + if(strtolower($tema["ogc"]) == "sim"){ | ||
| 377 | + $codigosTema[] = array("tema"=>$tema["tid"],"fonte"=>$tema["link"]); | ||
| 378 | + } | ||
| 379 | + } | ||
| 380 | + } | ||
| 381 | + } | ||
| 382 | + } | ||
| 383 | + } | ||
| 384 | + } | ||
| 385 | + //echo "<pre>"; | ||
| 386 | + //var_dump($codigosTema); | ||
| 387 | + //exit; | ||
| 388 | + foreach($codigosTema as $c){ | ||
| 389 | + $codigoTema = $c["tema"]; | ||
| 390 | + if(file_exists($locaplic."/temas/".$codigoTema.".map")){ | ||
| 391 | + if (@ms_newMapobj($locaplic."/temas/".$codigoTema.".map")){ | ||
| 392 | + $nmap = ms_newMapobj($locaplic."/temas/".$codigoTema.".map"); | ||
| 393 | + $nmap->setmetadata("ows_enable_request","*"); | ||
| 394 | + $ts = $nmap->getalllayernames(); | ||
| 395 | + if (count($ts) == 1){ | ||
| 396 | + foreach ($ts as $t){ | ||
| 397 | + if ($oMap->getlayerbyname($t) == ""){ | ||
| 398 | + $conta++; | ||
| 399 | + if (($conta >= $int[0]) && ($conta <= $int[1])){ | ||
| 400 | + $l = $nmap->getlayerbyname($t); | ||
| 401 | + $extensao = $l->getmetadata("EXTENSAO"); | ||
| 402 | + if($extensao == "") | ||
| 403 | + { | ||
| 404 | + $extensao = $extensaoMap; | ||
| 405 | + } | ||
| 406 | + $l->setmetadata("wms_extent",$extensao); | ||
| 407 | + | ||
| 408 | + $l->setmetadata("ows_title",pegaNome($l)); | ||
| 409 | + $l->setmetadata("ows_srs",$listaepsg); | ||
| 410 | + $l->set("status",MS_OFF); | ||
| 411 | + $l->setmetadata("gml_include_items","all"); | ||
| 412 | + $l->set("dump",MS_TRUE); | ||
| 413 | + $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
| 414 | + $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
| 415 | + | ||
| 416 | + $l->setmetadata("ows_metadataurl_href",$c["fonte"]); | ||
| 417 | + $l->setmetadata("ows_metadataurl_type","TC211"); | ||
| 418 | + $l->setmetadata("ows_metadataurl_format","text/html"); | ||
| 419 | + if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){ | ||
| 420 | + $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png"; | ||
| 421 | + $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
| 422 | + $l->setmetadata("wms_attribution_logourl_height","50"); | ||
| 423 | + $l->setmetadata("wms_attribution_logourl_width","50"); | ||
| 424 | + $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
| 425 | + } | ||
| 426 | + ms_newLayerObj($oMap, $l); | ||
| 427 | + } | ||
| 428 | + } | ||
| 429 | + } | ||
| 430 | + } | ||
| 431 | + } | ||
| 432 | + else{ | ||
| 433 | + echo "Erro no arquivo ".$locaplic."/temas/".$codigoTema.".map <br>"; | ||
| 434 | + $error = ms_GetErrorObj(); | ||
| 435 | + while($error && $error->code != MS_NOERR){ | ||
| 436 | + printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message); | ||
| 437 | + $error = $error->next(); | ||
| 438 | + } | ||
| 439 | + } | ||
| 440 | + } | ||
| 409 | } | 441 | } |
| 410 | -} | ||
| 411 | -if($cache == true){ | ||
| 412 | - | ||
| 413 | -} | ||
| 414 | -ms_ioinstallstdouttobuffer(); | ||
| 415 | -$oMap->owsdispatch($req); | ||
| 416 | -$contenttype = ms_iostripstdoutbuffercontenttype(); | ||
| 417 | -if(strtolower($request) == "getcapabilities") | ||
| 418 | -{header('Content-Disposition: attachment; filename=getcapabilities.xml');} | ||
| 419 | -//header("Content-type: application/xml"); | ||
| 420 | -header("Content-type: $contenttype"); | ||
| 421 | - | ||
| 422 | -$buffer = ms_iogetStdoutBufferBytes(); | ||
| 423 | -ms_ioresethandlers(); | ||
| 424 | -// | ||
| 425 | -//funções | ||
| 426 | -// | ||
| 427 | -function ogc_pegaListaDeMenus(){ | ||
| 428 | - global $perfil,$locaplic,$urli3geo; | ||
| 429 | - if(!isset($perfil)){$perfil = "";} | ||
| 430 | - $m = new Menutemas("",$perfil,$locsistemas,$locaplic,"",$urli3geo); | ||
| 431 | - foreach($m->pegaListaDeMenus() as $menu) | ||
| 432 | - {$menus[] = $urli3geo."/admin/xmlmenutemas.php?id_menu=".$menu["idmenu"];} | ||
| 433 | - return $menus; | ||
| 434 | -} | ||
| 435 | -function ogc_imprimeAjuda(){ | ||
| 436 | - echo "<pre><b>Construtor de web services do I3Geo.</b><br><br>"; | ||
| 437 | - echo "Esse utilitário usa os arquivos mapfiles existentes em <br>"; | ||
| 438 | - echo "i3geo/temas para gerar web services no padrão OGC.<br>"; | ||
| 439 | - echo "Para escolher um tema, utilize:<br>"; | ||
| 440 | - echo "ogc.php?lista=temas - para listar os temas disponíveis<br>"; | ||
| 441 | - echo "Para usar esse web service, além dos parâmetros normais, vc deverá incluir o parâmetro &tema=,<br>"; | ||
| 442 | - echo "ou seja,http://[host]/i3geo/ogc.php?tema=[código do tema]<br>"; | ||
| 443 | - echo "no lugar do código pode ser especificado também um arquivo mapfile qualquer. Nesse caso, deve ser digitado o caminho completo no servidor<br><br>"; | ||
| 444 | - echo "Utilize o sistema de administração do i3Geo para configurar quais os temas da pasta i3geo/temas podem ser utilizados."; | ||
| 445 | - echo "Utilize o parametro &intervalo=0,20 para definir o número de temas desejado na função getcapabilities."; | ||
| 446 | -} | ||
| 447 | -function ogc_imprimeListaDeTemas(){ | ||
| 448 | - global $urli3geo,$perfil,$locaplic; | ||
| 449 | - $m = new Menutemas("",$perfil,$locaplic,$urli3geo); | ||
| 450 | - $menus = $m->pegaListaDeMenus(); | ||
| 451 | - echo '<html><head><title>WMS</title><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><meta name="description" content="OGC"><meta name="keywords" content="WMS OGC mapa sig gis webmapping geo geoprocessamento interativo meio ambiente MMA cartografia geografia"> <meta name="robots" content="index,follow">'; | ||
| 452 | - echo "<body><b>Lista de temas por grupos e subgrupos e endereços de acesso aos dados por meio de Web Services WMS (os códigos dos temas estão em vermelho)</b><br><br>"; | ||
| 453 | - $imprimir = ""; | ||
| 454 | - foreach ($menus as $menu){ | ||
| 455 | - $grupos = $m->pegaListaDeGrupos($menu["idmenu"],$listasistemas="nao",$listasgrupos="sim"); | ||
| 456 | - foreach($grupos as $grupo){ | ||
| 457 | - if(strtolower($grupo["ogc"]) == "sim"){ | ||
| 458 | - $imprimegrupo = "<i>".$grupo["nome"]."</i>"; | ||
| 459 | - foreach($grupo["subgrupos"] as $sgrupo){ | ||
| 460 | - if(strtolower($sgrupo["ogc"]) == "sim"){ | ||
| 461 | - $imprimesubgrupo = $sgrupo["nome"]; | ||
| 462 | - $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
| 463 | - foreach($temas as $tema){ | ||
| 464 | - if(strtolower($tema["ogc"]) == "sim"){ | ||
| 465 | - $imprimir .= $imprimegrupo."->".$imprimesubgrupo."<br>"; | ||
| 466 | - $imprimir .= " "; | ||
| 467 | - $imprimir .= "<span style=color:red >".$tema["tid"]."</span>"; | ||
| 468 | - $imprimir .= " - ".$tema["nome"]." "; | ||
| 469 | - $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&service=wms&request=getcapabilities' >Getcapabilities</a>"; | ||
| 470 | - $imprimir .= " <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>"; | ||
| 471 | - if($tema["link"] != " ") | ||
| 472 | - $imprimir .= " <a href='".$tema["link"]."' >fonte</a>"; | ||
| 473 | - $imprimir .= "<br>"; | ||
| 474 | - } | ||
| 475 | - } | ||
| 476 | - } | ||
| 477 | - } | ||
| 478 | - } | ||
| 479 | - } | ||
| 480 | - } | ||
| 481 | - echo $imprimir."</body></html>"; | ||
| 482 | -} | ||
| 483 | -function ogc_imprimeListaDeTemasWfs(){ | ||
| 484 | - global $urli3geo,$perfil,$locaplic; | ||
| 485 | - $m = new Menutemas("",$perfil,$locaplic,$urli3geo); | ||
| 486 | - $menus = $m->pegaListaDeMenus(); | ||
| 487 | - echo '<html><head><title>WFS</title><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><meta name="description" content="OGC"><meta name="keywords" content="WMS OGC mapa sig gis webmapping geo geoprocessamento interativo meio ambiente MMA cartografia geografia"> <meta name="robots" content="index,follow">'; | ||
| 488 | - echo "<body><b>Lista de temas por grupos e subgrupos e endereços de acesso aos dados por meio de Web Services WFS (os códigos dos temas estão em vermelho)</b><br><br>"; | ||
| 489 | - $imprimir = ""; | ||
| 490 | - foreach ($menus as $menu){ | ||
| 491 | - $grupos = $m->pegaListaDeGrupos($menu["idmenu"],$listasistemas="nao",$listasgrupos="sim"); | ||
| 492 | - foreach($grupos as $grupo){ | ||
| 493 | - if(strtolower($grupo["ogc"]) == "sim"){ | ||
| 494 | - $imprimegrupo = "<i>".$grupo["nome"]."</i>"; | ||
| 495 | - foreach($grupo["subgrupos"] as $sgrupo){ | ||
| 496 | - if(strtolower($sgrupo["ogc"]) == "sim"){ | ||
| 497 | - $imprimesubgrupo = $sgrupo["nome"]; | ||
| 498 | - $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
| 499 | - foreach($temas as $tema){ | ||
| 500 | - if(strtolower($tema["ogc"]) == "sim" && strtolower($tema["down"]) !== "nao"){ | ||
| 501 | - $imprimir .= $imprimegrupo."->".$imprimesubgrupo."<br>"; | ||
| 502 | - $imprimir .= " "; | ||
| 503 | - $imprimir .= "<span style=color:red >".$tema["tid"]."</span>"; | ||
| 504 | - $imprimir .= " - ".$tema["nome"]." "; | ||
| 505 | - $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&service=wfs&request=getcapabilities' >Getcapabilities</a>"; | ||
| 506 | - $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&SRS=EPSG:4618&service=wfs&version=1.1.0&request=getfeature&typename=".$tema["tid"]."' >Getfeature </a>"; | ||
| 507 | - if($tema["link"] != " ") | ||
| 508 | - $imprimir .= " <a href='".$tema["link"]."' >fonte</a>"; | ||
| 509 | - $imprimir .= "<br>"; | ||
| 510 | - } | ||
| 511 | - } | ||
| 512 | - } | ||
| 513 | - } | ||
| 514 | - } | ||
| 515 | - } | ||
| 516 | - } | ||
| 517 | - echo $imprimir."</body></html>"; | ||
| 518 | -} | ||
| 519 | -function carregaCacheImagem($bbox,$layer,$w,$h,$cachedir=""){ | ||
| 520 | - global $dir_tmp; | ||
| 521 | - $nome = $w.$h.$bbox.".png"; | ||
| 522 | - if($cachedir == "") | ||
| 523 | - {$nome = $dir_tmp."/cache/".$layer."/".$nome;} | ||
| 524 | - else | ||
| 525 | - {$nome = $cachedir."/".$layer."/".$nome;} | ||
| 526 | - if(file_exists($nome)){ | ||
| 527 | - ob_start(); | ||
| 528 | - // assuming you have image data in $imagedata | ||
| 529 | - $img = file_get_contents($nome); | ||
| 530 | - $length = strlen($img); | ||
| 531 | - $ft = filemtime($nome); | ||
| 532 | - if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && (strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]) == $ft)) { | ||
| 533 | - // Client's cache IS current, so we just respond '304 Not Modified'. | ||
| 534 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 304); | ||
| 535 | - } else { | ||
| 536 | - // Image not cached or cache outdated, we respond '200 OK' and output the image. | ||
| 537 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 200); | ||
| 538 | - } | ||
| 539 | - header('Accept-Ranges: bytes'); | ||
| 540 | - header('Content-Length: '.$length); | ||
| 541 | - header('Content-Type: image/png'); | ||
| 542 | - print($img); | ||
| 543 | - ob_end_flush(); | ||
| 544 | - exit; | ||
| 545 | - } | ||
| 546 | - /* | ||
| 547 | - if(file_exists($nome)) | 442 | +} |
| 443 | +if($cache == true){ | ||
| 444 | + | ||
| 445 | +} | ||
| 446 | +ms_ioinstallstdouttobuffer(); | ||
| 447 | +$oMap->owsdispatch($req); | ||
| 448 | +$contenttype = ms_iostripstdoutbuffercontenttype(); | ||
| 449 | +if(strtolower($request) == "getcapabilities") | ||
| 450 | +{ | ||
| 451 | + header('Content-Disposition: attachment; filename=getcapabilities.xml'); | ||
| 452 | +} | ||
| 453 | +//header("Content-type: application/xml"); | ||
| 454 | +header("Content-type: $contenttype"); | ||
| 455 | + | ||
| 456 | +$buffer = ms_iogetStdoutBufferBytes(); | ||
| 457 | +ms_ioresethandlers(); | ||
| 458 | +// | ||
| 459 | +//funções | ||
| 460 | +// | ||
| 461 | +function ogc_pegaListaDeMenus(){ | ||
| 462 | + global $perfil,$locaplic,$urli3geo; | ||
| 463 | + if(!isset($perfil)){ | ||
| 464 | + $perfil = ""; | ||
| 465 | + } | ||
| 466 | + $m = new Menutemas("",$perfil,$locsistemas,$locaplic,"",$urli3geo); | ||
| 467 | + foreach($m->pegaListaDeMenus() as $menu) | ||
| 548 | { | 468 | { |
| 549 | - if (!function_exists('imagepng')) | ||
| 550 | - { | ||
| 551 | - $s = PHP_SHLIB_SUFFIX; | ||
| 552 | - @dl( 'php_gd2.'.$s ); | ||
| 553 | - if (!function_exists('imagepng')) | ||
| 554 | - @dl( 'php_gd.'.$s ); | ||
| 555 | - } | ||
| 556 | - @$img = imagecreatefrompng($nome); | ||
| 557 | - if(!$img) | ||
| 558 | - { | ||
| 559 | - $img = imagecreatetruecolor($w, $h); | ||
| 560 | - imagealphablending($img, false); | ||
| 561 | - imagesavealpha($img, true); | ||
| 562 | - | ||
| 563 | - $bgc = imagecolorallocatealpha($img, 255, 255, 255,127); | ||
| 564 | - $tc = imagecolorallocate($img, 255, 0, 0); | ||
| 565 | - | ||
| 566 | - imagefilledrectangle($img, 0, 0, $w, $h, $bgc); | ||
| 567 | - imagestring($img, 3, 5, 5, 'Erro ao ler ' . $nome, $tc); | ||
| 568 | - } | ||
| 569 | - else | ||
| 570 | - { | ||
| 571 | - imagealphablending($img, false); | ||
| 572 | - imagesavealpha($img, true); | ||
| 573 | - } | ||
| 574 | - ob_clean(); | ||
| 575 | - error_reporting(0); | ||
| 576 | - echo header("Content-type: image/png \n\n"); | ||
| 577 | - imagepng($img); | ||
| 578 | - imagedestroy($img); | ||
| 579 | - exit; | ||
| 580 | - } | ||
| 581 | - */ | 469 | + $menus[] = $urli3geo."/admin/xmlmenutemas.php?id_menu=".$menu["idmenu"]; |
| 470 | + } | ||
| 471 | + return $menus; | ||
| 472 | +} | ||
| 473 | +function ogc_imprimeAjuda(){ | ||
| 474 | + echo "<pre><b>Construtor de web services do I3Geo.</b><br><br>"; | ||
| 475 | + echo "Esse utilitário usa os arquivos mapfiles existentes em <br>"; | ||
| 476 | + echo "i3geo/temas para gerar web services no padrão OGC.<br>"; | ||
| 477 | + echo "Para escolher um tema, utilize:<br>"; | ||
| 478 | + echo "ogc.php?lista=temas - para listar os temas disponíveis<br>"; | ||
| 479 | + echo "Para usar esse web service, além dos parâmetros normais, vc deverá incluir o parâmetro &tema=,<br>"; | ||
| 480 | + echo "ou seja,http://[host]/i3geo/ogc.php?tema=[código do tema]<br>"; | ||
| 481 | + echo "no lugar do código pode ser especificado também um arquivo mapfile qualquer. Nesse caso, deve ser digitado o caminho completo no servidor<br><br>"; | ||
| 482 | + echo "Utilize o sistema de administração do i3Geo para configurar quais os temas da pasta i3geo/temas podem ser utilizados."; | ||
| 483 | + echo "Utilize o parametro &intervalo=0,20 para definir o número de temas desejado na função getcapabilities."; | ||
| 484 | +} | ||
| 485 | +function ogc_imprimeListaDeTemas(){ | ||
| 486 | + global $urli3geo,$perfil,$locaplic; | ||
| 487 | + $m = new Menutemas("",$perfil,$locaplic,$urli3geo); | ||
| 488 | + $menus = $m->pegaListaDeMenus(); | ||
| 489 | + echo '<html><head><title>WMS</title><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><meta name="description" content="OGC"><meta name="keywords" content="WMS OGC mapa sig gis webmapping geo geoprocessamento interativo meio ambiente MMA cartografia geografia"> <meta name="robots" content="index,follow">'; | ||
| 490 | + echo "<body><b>Lista de temas por grupos e subgrupos e endereços de acesso aos dados por meio de Web Services WMS (os códigos dos temas estão em vermelho)</b><br><br>"; | ||
| 491 | + $imprimir = ""; | ||
| 492 | + foreach ($menus as $menu){ | ||
| 493 | + $grupos = $m->pegaListaDeGrupos($menu["idmenu"],$listasistemas="nao",$listasgrupos="sim"); | ||
| 494 | + foreach($grupos as $grupo){ | ||
| 495 | + if(strtolower($grupo["ogc"]) == "sim"){ | ||
| 496 | + $imprimegrupo = "<i>".$grupo["nome"]."</i>"; | ||
| 497 | + foreach($grupo["subgrupos"] as $sgrupo){ | ||
| 498 | + if(strtolower($sgrupo["ogc"]) == "sim"){ | ||
| 499 | + $imprimesubgrupo = $sgrupo["nome"]; | ||
| 500 | + $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
| 501 | + foreach($temas as $tema){ | ||
| 502 | + if(strtolower($tema["ogc"]) == "sim"){ | ||
| 503 | + $imprimir .= $imprimegrupo."->".$imprimesubgrupo."<br>"; | ||
| 504 | + $imprimir .= " "; | ||
| 505 | + $imprimir .= "<span style=color:red >".$tema["tid"]."</span>"; | ||
| 506 | + $imprimir .= " - ".$tema["nome"]." "; | ||
| 507 | + $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&service=wms&request=getcapabilities' >Getcapabilities</a>"; | ||
| 508 | + $imprimir .= " <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>"; | ||
| 509 | + if($tema["link"] != " ") | ||
| 510 | + $imprimir .= " <a href='".$tema["link"]."' >fonte</a>"; | ||
| 511 | + $imprimir .= "<br>"; | ||
| 512 | + } | ||
| 513 | + } | ||
| 514 | + } | ||
| 515 | + } | ||
| 516 | + } | ||
| 517 | + } | ||
| 518 | + } | ||
| 519 | + echo $imprimir."</body></html>"; | ||
| 520 | +} | ||
| 521 | +function ogc_imprimeListaDeTemasWfs(){ | ||
| 522 | + global $urli3geo,$perfil,$locaplic; | ||
| 523 | + $m = new Menutemas("",$perfil,$locaplic,$urli3geo); | ||
| 524 | + $menus = $m->pegaListaDeMenus(); | ||
| 525 | + echo '<html><head><title>WFS</title><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><meta name="description" content="OGC"><meta name="keywords" content="WMS OGC mapa sig gis webmapping geo geoprocessamento interativo meio ambiente MMA cartografia geografia"> <meta name="robots" content="index,follow">'; | ||
| 526 | + echo "<body><b>Lista de temas por grupos e subgrupos e endereços de acesso aos dados por meio de Web Services WFS (os códigos dos temas estão em vermelho)</b><br><br>"; | ||
| 527 | + $imprimir = ""; | ||
| 528 | + foreach ($menus as $menu){ | ||
| 529 | + $grupos = $m->pegaListaDeGrupos($menu["idmenu"],$listasistemas="nao",$listasgrupos="sim"); | ||
| 530 | + foreach($grupos as $grupo){ | ||
| 531 | + if(strtolower($grupo["ogc"]) == "sim"){ | ||
| 532 | + $imprimegrupo = "<i>".$grupo["nome"]."</i>"; | ||
| 533 | + foreach($grupo["subgrupos"] as $sgrupo){ | ||
| 534 | + if(strtolower($sgrupo["ogc"]) == "sim"){ | ||
| 535 | + $imprimesubgrupo = $sgrupo["nome"]; | ||
| 536 | + $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
| 537 | + foreach($temas as $tema){ | ||
| 538 | + if(strtolower($tema["ogc"]) == "sim" && strtolower($tema["down"]) !== "nao"){ | ||
| 539 | + $imprimir .= $imprimegrupo."->".$imprimesubgrupo."<br>"; | ||
| 540 | + $imprimir .= " "; | ||
| 541 | + $imprimir .= "<span style=color:red >".$tema["tid"]."</span>"; | ||
| 542 | + $imprimir .= " - ".$tema["nome"]." "; | ||
| 543 | + $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&service=wfs&request=getcapabilities' >Getcapabilities</a>"; | ||
| 544 | + $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&SRS=EPSG:4618&service=wfs&version=1.1.0&request=getfeature&typename=".$tema["tid"]."' >Getfeature </a>"; | ||
| 545 | + if($tema["link"] != " ") | ||
| 546 | + $imprimir .= " <a href='".$tema["link"]."' >fonte</a>"; | ||
| 547 | + $imprimir .= "<br>"; | ||
| 548 | + } | ||
| 549 | + } | ||
| 550 | + } | ||
| 551 | + } | ||
| 552 | + } | ||
| 553 | + } | ||
| 554 | + } | ||
| 555 | + echo $imprimir."</body></html>"; | ||
| 556 | +} | ||
| 557 | +function carregaCacheImagem($bbox,$layer,$w,$h,$cachedir=""){ | ||
| 558 | + global $dir_tmp; | ||
| 559 | + $nome = $w.$h.$bbox.".png"; | ||
| 560 | + if($cachedir == "") | ||
| 561 | + { | ||
| 562 | + $nome = $dir_tmp."/cache/".$layer."/".$nome; | ||
| 563 | + } | ||
| 564 | + else | ||
| 565 | + {$nome = $cachedir."/".$layer."/".$nome; | ||
| 566 | + } | ||
| 567 | + if(file_exists($nome)){ | ||
| 568 | + ob_start(); | ||
| 569 | + // assuming you have image data in $imagedata | ||
| 570 | + $img = file_get_contents($nome); | ||
| 571 | + $length = strlen($img); | ||
| 572 | + $ft = filemtime($nome); | ||
| 573 | + if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && (strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]) == $ft)) { | ||
| 574 | + // Client's cache IS current, so we just respond '304 Not Modified'. | ||
| 575 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 304); | ||
| 576 | + } else { | ||
| 577 | + // Image not cached or cache outdated, we respond '200 OK' and output the image. | ||
| 578 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 200); | ||
| 579 | + } | ||
| 580 | + header('Accept-Ranges: bytes'); | ||
| 581 | + header('Content-Length: '.$length); | ||
| 582 | + header('Content-Type: image/png'); | ||
| 583 | + print($img); | ||
| 584 | + ob_end_flush(); | ||
| 585 | + exit; | ||
| 586 | + } | ||
| 587 | + /* | ||
| 588 | + if(file_exists($nome)) | ||
| 589 | + { | ||
| 590 | + if (!function_exists('imagepng')) | ||
| 591 | + { | ||
| 592 | + $s = PHP_SHLIB_SUFFIX; | ||
| 593 | + @dl( 'php_gd2.'.$s ); | ||
| 594 | + if (!function_exists('imagepng')) | ||
| 595 | + @dl( 'php_gd.'.$s ); | ||
| 596 | + } | ||
| 597 | + @$img = imagecreatefrompng($nome); | ||
| 598 | + if(!$img) | ||
| 599 | + { | ||
| 600 | + $img = imagecreatetruecolor($w, $h); | ||
| 601 | + imagealphablending($img, false); | ||
| 602 | + imagesavealpha($img, true); | ||
| 603 | + | ||
| 604 | + $bgc = imagecolorallocatealpha($img, 255, 255, 255,127); | ||
| 605 | + $tc = imagecolorallocate($img, 255, 0, 0); | ||
| 606 | + | ||
| 607 | + imagefilledrectangle($img, 0, 0, $w, $h, $bgc); | ||
| 608 | + imagestring($img, 3, 5, 5, 'Erro ao ler ' . $nome, $tc); | ||
| 609 | + } | ||
| 610 | + else | ||
| 611 | + { | ||
| 612 | + imagealphablending($img, false); | ||
| 613 | + imagesavealpha($img, true); | ||
| 614 | + } | ||
| 615 | + ob_clean(); | ||
| 616 | + error_reporting(0); | ||
| 617 | + echo header("Content-type: image/png \n\n"); | ||
| 618 | + imagepng($img); | ||
| 619 | + imagedestroy($img); | ||
| 620 | + exit; | ||
| 621 | + } | ||
| 622 | + */ | ||
| 582 | } | 623 | } |
| 583 | - | ||
| 584 | -?> | ||
| 585 | - | ||
| 586 | - | ||
| 587 | - | 624 | +?> |
| 588 | \ No newline at end of file | 625 | \ No newline at end of file |