Commit 11d0a2eff835688ac7961a20f279cd86809a5970
1 parent
d0446c17
Exists in
master
and in
7 other branches
Alteração na inicialização de um mapa com projeto gvsig, não sendo mais necessár…
…io inserir o nome de uma visat
Showing
2 changed files
with
66 additions
and
13 deletions
Show diff stats
ms_criamapa.php
| ... | ... | @@ -127,7 +127,7 @@ versao_wms - Versão do WMS (necessário quando da inclusão d |
| 127 | 127 | |
| 128 | 128 | gvsiggvp - endereço no servidor do arquivo de projeto gvSig (gvp) que será utilizado para construir o mapa (experimental) |
| 129 | 129 | |
| 130 | -gvsigview - nome da view do projeto gvSig (http://localhost/i3geo/ms_criamapa.php?gvsiggvp=c:\temp\teste.gvp&gvsigview=Untitled - 0) | |
| 130 | +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) | |
| 131 | 131 | */ |
| 132 | 132 | |
| 133 | 133 | //$_COOKIE = array(); |
| ... | ... | @@ -348,13 +348,8 @@ else |
| 348 | 348 | /* |
| 349 | 349 | Utiliza um projeto gvSig para compor o mapa |
| 350 | 350 | */ |
| 351 | -if(isset($gvsiggvp) && $gvsiggvp != ""){ | |
| 352 | - if(isset($gvsigview) && $gvsigview != ""){ | |
| 353 | - incluiMapaGvsig($gvsiggvp,$gvsigview); | |
| 354 | - } | |
| 355 | - else{ | |
| 356 | - echo "Nenhuma vista foi definida &gvsigview"; | |
| 357 | - } | |
| 351 | +if(!empty($gvsiggvp)){ | |
| 352 | + incluiMapaGvsig($gvsiggvp,$gvsigview); | |
| 358 | 353 | } |
| 359 | 354 | /* |
| 360 | 355 | Parâmetros adicionais. |
| ... | ... | @@ -505,7 +500,7 @@ function abreInterface(){ |
| 505 | 500 | { |
| 506 | 501 | if(file_exists($caminho."interface/".$interface)) |
| 507 | 502 | {include_once($caminho."interface/".$interface);} |
| 508 | - else | |
| 503 | + else | |
| 509 | 504 | {include_once($interface);} |
| 510 | 505 | exit; |
| 511 | 506 | } |
| ... | ... | @@ -513,7 +508,7 @@ function abreInterface(){ |
| 513 | 508 | { |
| 514 | 509 | if(file_exists($caminho."interface/".$interface)) |
| 515 | 510 | {$urln = $caminho."interface/".$interface."?".session_id();} |
| 516 | - else | |
| 511 | + else | |
| 517 | 512 | {$urln = $interface."?".session_id();} |
| 518 | 513 | if(!headers_sent()) |
| 519 | 514 | {header("Location:".$urln);} |
| ... | ... | @@ -1087,10 +1082,14 @@ function incluiTemaWms() |
| 1087 | 1082 | /* |
| 1088 | 1083 | Projeto gvsig |
| 1089 | 1084 | */ |
| 1090 | -function incluiMapaGvsig($gvsiggvp,$gvsigview){ | |
| 1085 | +function incluiMapaGvsig($gvsiggvp,$gvsigview=""){ | |
| 1091 | 1086 | global $mapn,$locaplic; |
| 1092 | 1087 | include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); |
| 1093 | 1088 | $gm = new gvsig2mapfile($gvsiggvp); |
| 1089 | + if(empty($gvsigview)){ | |
| 1090 | + $gvsigview = $gm->getViewsNames(); | |
| 1091 | + $gvsigview = $gvsigview[0]; | |
| 1092 | + } | |
| 1094 | 1093 | $dataView = $gm->getViewData($gvsigview); |
| 1095 | 1094 | $numlayers = $mapn->numlayers; |
| 1096 | 1095 | for ($i=0;$i < $numlayers;$i++) | ... | ... |
pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * Manipula um arquivo GVP (projeto gvSIG) para construção de layers Mapserver | |
| 4 | + * @author Edmar Moretti | |
| 5 | + * @license GPL2 | |
| 6 | + */ | |
| 2 | 7 | class gvsig2mapfile{ |
| 3 | 8 | var $arquivoGvp; |
| 4 | 9 | var $xml; |
| 10 | + /** | |
| 11 | + * Construtor da classe | |
| 12 | + * @param string $gvp arquivo de projeto gvsig | |
| 13 | + * @example $gm = new gvsig2mapfile($gvsiggvp); | |
| 14 | + * @throws Exception | |
| 15 | + */ | |
| 5 | 16 | function __construct($gvp) |
| 6 | 17 | { |
| 7 | - if(!file_exists($gvp)) | |
| 8 | - {throw new Exception("Arquivo $gvp não existe");} | |
| 18 | + if(!file_exists($gvp)) | |
| 19 | + {throw new Exception("Arquivo $gvp não existe");} | |
| 9 | 20 | else{ |
| 10 | 21 | $this->arquivoGvp = $gvp; |
| 11 | 22 | if(function_exists("dl")){ |
| ... | ... | @@ -17,6 +28,10 @@ class gvsig2mapfile{ |
| 17 | 28 | $this->xml = simplexml_load_file($gvp); |
| 18 | 29 | } |
| 19 | 30 | } |
| 31 | + /** | |
| 32 | + * Lista de vistas existentes no projeto gvsig | |
| 33 | + * @return array | |
| 34 | + **/ | |
| 20 | 35 | function getViewsNames(){ |
| 21 | 36 | $names = array(); |
| 22 | 37 | $this->xml->registerXPathNamespace("tag", "http://www.gvsig.gva.es"); |
| ... | ... | @@ -26,11 +41,27 @@ class gvsig2mapfile{ |
| 26 | 41 | } |
| 27 | 42 | return $names; |
| 28 | 43 | } |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Retorna uma vista | |
| 47 | + * @param string $nome | |
| 48 | + * @return $xml | |
| 49 | + */ | |
| 29 | 50 | function getViewByName($nome){ |
| 30 | 51 | $this->xml->registerXPathNamespace("tag", "http://www.gvsig.gva.es"); |
| 31 | 52 | $result = $this->xml->xpath("/tag:xml-tag/tag:xml-tag/tag:property[@value='ProjectView']/parent::*/tag:property[@value='".$nome."']/parent::*"); |
| 32 | 53 | return $result; |
| 33 | 54 | } |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Obtem os dados descritivos de uma visao | |
| 58 | + * @param string $nome Nome da vista | |
| 59 | + * @return array ( | |
| 60 | + "extent"=>array(xmin,ymin,xmax,ymax), | |
| 61 | + "proj"=>string projecao, | |
| 62 | + "layerNames"=>string lista de layers separados por virgula | |
| 63 | + ) | |
| 64 | + */ | |
| 34 | 65 | function getViewData($nome){ |
| 35 | 66 | $this->xml->registerXPathNamespace("tag", "http://www.gvsig.gva.es"); |
| 36 | 67 | $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{ |
| 48 | 79 | "layerNames"=>explode(",",str_replace(" ,",",",$nomes)) |
| 49 | 80 | ); |
| 50 | 81 | } |
| 82 | + /** | |
| 83 | + * Obtem os dados de um layer | |
| 84 | + * @param string $viewNome | |
| 85 | + * @param string $layerNome | |
| 86 | + * @return array( | |
| 87 | + "minScale"=> string, | |
| 88 | + "maxScale"=>string, | |
| 89 | + "visible"=>string, | |
| 90 | + "proj"=>string, | |
| 91 | + "transparency"=>string, | |
| 92 | + "type"=>string, | |
| 93 | + "data"=>string, | |
| 94 | + "connection"=>string, | |
| 95 | + "connectiontype"=>string, | |
| 96 | + "driverName"=>string, | |
| 97 | + "isLabeled"=>string, | |
| 98 | + "legenda"=>array( | |
| 99 | + "tipoLegenda"=>string, | |
| 100 | + "classes"=>string | |
| 101 | + ) | |
| 102 | + ) | |
| 103 | + * | |
| 104 | + */ | |
| 51 | 105 | function getLayerData($viewNome,$layerNome){ |
| 52 | 106 | $this->xml->registerXPathNamespace("tag", "http://www.gvsig.gva.es"); |
| 53 | 107 | $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::*"; | ... | ... |