Webservice com todas as camadas: " + servico + ""; ins += "
Webservice dessa camada: " + servico + "tema=" + tema + "&"; ins += "
Link para essa página: "+ window.location.href.split("?")[0] + "?temaOgc=" + tema + ""; - ins += "
Bookmark: "; ins += "
testar getmap"; ins += + "
testar getLegendGraphic"; + ins += "
visualizar com openLayers"; ins += "
download shapefile via WFS"; @@ -210,6 +214,8 @@ A:hover { ins += "
Explore a tabela de atributos"; diff --git a/ogc.php b/ogc.php index a2a9bf1..f7a27c8 100755 --- a/ogc.php +++ b/ogc.php @@ -181,9 +181,10 @@ if(!empty($OUTPUTFORMAT)){ carregaCacheArquivo(); } // -//para o caso da requisicao kml +//para o caso da requisicao kmz +//kmz nao funciona diretamente com mapserver // -if(strtolower($OUTPUTFORMAT) == "kml" || strtolower($OUTPUTFORMAT) == "kmz"){ +if(strtolower($OUTPUTFORMAT) == "xkml" || strtolower($OUTPUTFORMAT) == "kmz"){ $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema; header("Location:".$urln); exit; @@ -290,8 +291,7 @@ $arrayget["Z"] = ""; $arrayget["X"] = ""; $arrayget["Y"] = ""; $arrayget["tms"] = ""; -$nomeMapfileTmp = $dir_tmp."/ogc_".md5(implode("",$arrayget))."_".$agora.".map"; - +$nomeMapfileTmp = $dir_tmp."/ogc_".md5(implode("",$arrayget))."_".$agora.".map"; //essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao $cortePixels = 0; if(file_exists($nomeMapfileTmp) && $tipo == ""){ @@ -558,7 +558,7 @@ else{ } } $req->setParameter("LAYERS", implode(",",$lys)); - $req->setParameter("STYLES", ""); + $req->setParameter("STYLES", ""); } } } @@ -677,9 +677,10 @@ else{ //caso seja download ou json ou csv // processaOutputformatMapfile(); - $oMap->save($nomeMapfileTmp); + validaAcessoTemas($nomeMapfileTmp,true); + $oMap = ms_newMapobj($nomeMapfileTmp); } @@ -945,6 +946,35 @@ if(strtolower($OUTPUTFORMAT) == "geojson" || strtolower($OUTPUTFORMAT) == "json" exit; } +if(strtolower($OUTPUTFORMAT) == "kml"){ + $oMap->owsdispatch($req); + $contenttype = ms_iostripstdoutbuffercontenttype(); + ms_iostripstdoutbuffercontentheaders(); + //grava em disco + $arq = $dir_tmp."/".$tema.".kml"; + $contents = ms_iogetstdoutbufferstring(); + file_put_contents($arq,$contents); + //envia para download + header('Content-Disposition: attachment; filename='.$tema.'.kml'); + ms_iogetStdoutBufferBytes(); + ms_ioresethandlers(); + exit; +} +//kmz nao funciona quando fornecido diretamente pelo mapserver +if(strtolower($OUTPUTFORMAT) == "kmz"){ + $oMap->owsdispatch($req); + $contenttype = ms_iostripstdoutbuffercontenttype(); + ms_iostripstdoutbuffercontentheaders(); + //grava em disco + $arq = $dir_tmp."/".$tema.".kmz"; + $contents = ms_iogetstdoutbufferstring(); + file_put_contents($arq,$contents); + //envia para download + header('Content-Disposition: attachment; filename='.$tema.'.kmz'); + ms_iogetStdoutBufferBytes(); + ms_ioresethandlers(); + exit; +} if(strtolower($OUTPUTFORMAT) == "shape-zip"){ $oMap->owsdispatch($req); $contenttype = ms_iostripstdoutbuffercontenttype(); @@ -1245,6 +1275,14 @@ function getfeatureinfoJson(){ } function processaOutputformatMapfile(){ global $OUTPUTFORMAT, $oMap, $tema, $ows_geomtype; + if(strtolower($OUTPUTFORMAT) == "kml"){ + $l = $oMap->getlayer(0); + $n = $l->name; + $oMap->selectOutputFormat("kml"); + $oMap->outputformat->setOption("STORAGE", "filesystem"); + $oMap->outputformat->setOption("FILENAME", $tema.".kml"); + $l->setmetadata("wfs_getfeature_formatlist","kml"); + } if(strtolower($OUTPUTFORMAT) == "shape-zip"){ $l = $oMap->getlayer(0); $n = $l->name; @@ -1290,6 +1328,24 @@ function carregaCacheArquivo(){ readfile($arq); exit; } + } + if(strtolower($OUTPUTFORMAT) == "kml"){ + $arq = $dir_tmp."/".$tema.".kml"; + if(file_exists($arq)){ + header('Content-Disposition: attachment; filename='.$tema.'.kml'); + header("Content-type: application/vnd.google-earth.kml+xml"); + readfile($arq); + exit; + } + } + if(strtolower($OUTPUTFORMAT) == "kmz"){ + $arq = $dir_tmp."/".$tema.".kmz"; + if(file_exists($arq)){ + header('Content-Disposition: attachment; filename='.$tema.'.kmz'); + header("Content-type: application/vnd.google-earth.kmz"); + readfile($arq); + exit; + } } if(strtolower($OUTPUTFORMAT) == "geojson" || strtolower($OUTPUTFORMAT) == "json"){ $arq = $dir_tmp."/".$tema.".json"; diff --git a/pacotes/kmlmapserver/classes/layerserver.class.php b/pacotes/kmlmapserver/classes/layerserver.class.php index a13e160..f93d6f4 100755 --- a/pacotes/kmlmapserver/classes/layerserver.class.php +++ b/pacotes/kmlmapserver/classes/layerserver.class.php @@ -157,7 +157,29 @@ class LayerServer { } else { $this->_networklink = false; } - + //ajusta a legenda + $numlayers = $this->map_object->numlayers; + for ($i=0;$i < $numlayers;++$i){ + $layer = $this->map_object->getlayer($i); + if (($layer->data != "") && (strtoupper($layer->getmetadata("escondido")) != "SIM") && (strtoupper($layer->getmetadata("tema")) != "NAO")){ + if ($layer->numclasses > 0){ + $classe = $layer->getclass(0); + if (($classe->name == "") || ($classe->name == " ")){ + $classe->set("name",$layer->getmetadata("tema")); + } + //corrige o titulo da legenda + if($layer->type != 3 && $layer->type != 4){ + $nclass = $layer->numclasses; + for($j=0;$j<$nclass;$j++){ + $classe = $layer->getclass($j); + if($classe->title === ""){ + $classe->title = $classe->name; + } + } + } + } + } + } $imageObj = $this->map_object->drawlegend(); $url = $imageObj->saveWebImage(); $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); -- libgit2 0.21.2