From 11d0a2eff835688ac7961a20f279cd86809a5970 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Thu, 25 Oct 2012 02:21:10 +0000 Subject: [PATCH] Alteração na inicialização de um mapa com projeto gvsig, não sendo mais necessário inserir o nome de uma visat --- ms_criamapa.php | 21 ++++++++++----------- pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/ms_criamapa.php b/ms_criamapa.php index c45dfe7..6850aa1 100644 --- a/ms_criamapa.php +++ b/ms_criamapa.php @@ -127,7 +127,7 @@ versao_wms - Versão do WMS (necessário quando da inclusão d gvsiggvp - endereço no servidor do arquivo de projeto gvSig (gvp) que será utilizado para construir o mapa (experimental) -gvsigview - nome da view do projeto gvSig (http://localhost/i3geo/ms_criamapa.php?gvsiggvp=c:\temp\teste.gvp&gvsigview=Untitled - 0) +gvsigview - nome da view do projeto gvSig. Se nao for especificado, sera considerada a primeira view existente no projeto. Exemplo (http://localhost/i3geo/ms_criamapa.php?gvsiggvp=c:\temp\teste.gvp&gvsigview=Untitled - 0) */ //$_COOKIE = array(); @@ -348,13 +348,8 @@ else /* Utiliza um projeto gvSig para compor o mapa */ -if(isset($gvsiggvp) && $gvsiggvp != ""){ - if(isset($gvsigview) && $gvsigview != ""){ - incluiMapaGvsig($gvsiggvp,$gvsigview); - } - else{ - echo "Nenhuma vista foi definida &gvsigview"; - } +if(!empty($gvsiggvp)){ + incluiMapaGvsig($gvsiggvp,$gvsigview); } /* Parâmetros adicionais. @@ -505,7 +500,7 @@ function abreInterface(){ { if(file_exists($caminho."interface/".$interface)) {include_once($caminho."interface/".$interface);} - else + else {include_once($interface);} exit; } @@ -513,7 +508,7 @@ function abreInterface(){ { if(file_exists($caminho."interface/".$interface)) {$urln = $caminho."interface/".$interface."?".session_id();} - else + else {$urln = $interface."?".session_id();} if(!headers_sent()) {header("Location:".$urln);} @@ -1087,10 +1082,14 @@ function incluiTemaWms() /* Projeto gvsig */ -function incluiMapaGvsig($gvsiggvp,$gvsigview){ +function incluiMapaGvsig($gvsiggvp,$gvsigview=""){ global $mapn,$locaplic; include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); $gm = new gvsig2mapfile($gvsiggvp); + if(empty($gvsigview)){ + $gvsigview = $gm->getViewsNames(); + $gvsigview = $gvsigview[0]; + } $dataView = $gm->getViewData($gvsigview); $numlayers = $mapn->numlayers; for ($i=0;$i < $numlayers;$i++) diff --git a/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php b/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php index 8cd63ad..9fc67ca 100644 --- a/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php +++ b/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php @@ -1,11 +1,22 @@ arquivoGvp = $gvp; if(function_exists("dl")){ @@ -17,6 +28,10 @@ class gvsig2mapfile{ $this->xml = simplexml_load_file($gvp); } } + /** + * Lista de vistas existentes no projeto gvsig + * @return array + **/ function getViewsNames(){ $names = array(); $this->xml->registerXPathNamespace("tag", "http://www.gvsig.gva.es"); @@ -26,11 +41,27 @@ class gvsig2mapfile{ } return $names; } + + /** + * Retorna uma vista + * @param string $nome + * @return $xml + */ function getViewByName($nome){ $this->xml->registerXPathNamespace("tag", "http://www.gvsig.gva.es"); $result = $this->xml->xpath("/tag:xml-tag/tag:xml-tag/tag:property[@value='ProjectView']/parent::*/tag:property[@value='".$nome."']/parent::*"); return $result; } + + /** + * Obtem os dados descritivos de uma visao + * @param string $nome Nome da vista + * @return array ( + "extent"=>array(xmin,ymin,xmax,ymax), + "proj"=>string projecao, + "layerNames"=>string lista de layers separados por virgula + ) + */ function getViewData($nome){ $this->xml->registerXPathNamespace("tag", "http://www.gvsig.gva.es"); $path = "/tag:xml-tag/tag:xml-tag/tag:property[@value='ProjectView']/parent::*/tag:property[@value='".$nome."']/parent::*/tag:xml-tag/tag:xml-tag"; @@ -48,6 +79,29 @@ class gvsig2mapfile{ "layerNames"=>explode(",",str_replace(" ,",",",$nomes)) ); } + /** + * Obtem os dados de um layer + * @param string $viewNome + * @param string $layerNome + * @return array( + "minScale"=> string, + "maxScale"=>string, + "visible"=>string, + "proj"=>string, + "transparency"=>string, + "type"=>string, + "data"=>string, + "connection"=>string, + "connectiontype"=>string, + "driverName"=>string, + "isLabeled"=>string, + "legenda"=>array( + "tipoLegenda"=>string, + "classes"=>string + ) + ) + * + */ function getLayerData($viewNome,$layerNome){ $this->xml->registerXPathNamespace("tag", "http://www.gvsig.gva.es"); $path = "/tag:xml-tag/tag:xml-tag/tag:property[@value='ProjectView']/parent::*/tag:property[@value='".$viewNome."']/parent::*/tag:xml-tag/tag:xml-tag/tag:xml-tag/tag:xml-tag/parent::*/tag:property[@value='".$layerNome."']/parent::*"; -- libgit2 0.21.2