From 98f18eab59e109cdc0c13ab22cb66bdabe1b8530 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Thu, 7 Apr 2011 20:23:46 +0000 Subject: [PATCH] Obtenção de camadas POSTGIS no gvsig2mapfile --- ms_configura.php | 5 ++++- ms_criamapa.php | 2 +- pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php | 42 ++++++++++++++++++++++++++++++++++++++---- pacotes/gvsig/gvsig2mapfile/gvsig2mapfile.php | 4 ++-- pacotes/gvsig/gvsig2mapfile/projetoteste.bak | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- pacotes/gvsig/gvsig2mapfile/projetoteste.gvp | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- pacotes/gvsig/gvsig2mapfile/upload.htm | 4 +++- 7 files changed, 390 insertions(+), 87 deletions(-) diff --git a/ms_configura.php b/ms_configura.php index aaf16f9..af500ab 100644 --- a/ms_configura.php +++ b/ms_configura.php @@ -301,7 +301,10 @@ if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) Tipo: {array ou string} */ - $postgis_mapa = array("teste"=>"user=postgres password=postgres dbname=pgutf8 host=localhost port=5432 options='-c client_encoding=LATIN1'"); //"user=geodados password=geodados dbname=geodados host=10.1.1.36 port=5432"; + $postgis_mapa = array( + "teste"=>"user=postgres password=postgres dbname=pgutf8 host=localhost port=5432 options='-c client_encoding=LATIN1'", + "postgres"=>"user=postgres password=postgres dbname=postgis host=localhost port=5432'", + ); //"user=geodados password=geodados dbname=geodados host=10.1.1.36 port=5432"; /* Variable: utilizacgi diff --git a/ms_criamapa.php b/ms_criamapa.php index 749b9fe..09ef8dc 100644 --- a/ms_criamapa.php +++ b/ms_criamapa.php @@ -1019,7 +1019,7 @@ Projeto gvsig */ function incluiMapaGvsig($gvsiggvp,$gvsigview){ global $mapn,$locaplic; - include_once($locaplic."/pacotes/gvsig/class.gvsig2mapfile.php"); + include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); $gm = new gvsig2mapfile($gvsiggvp); $dataView = $gm->getViewData($gvsigview); //var_dump($dataView); diff --git a/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php b/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php index 5a3008d..574bafb 100644 --- a/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php +++ b/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php @@ -66,7 +66,25 @@ class gvsig2mapfile{ $result = $this->xml->xpath($path1); if($result != FALSE) {$classes = $this->SingleSymbolLegend($result,$path1);} - + // + //obtem a conexão + //a senha não pode ser obtida, então, é usado o mesmo nome de usuário em seu lugar. No i3Geo deve-se prever isso na variável de substituição de string. + $driverName = $this->getValue($path,"driverName"); + if($driverName == "gvSIG shp driver"){ + $data = $this->getValue($path,"file"); + $connection = ""; + $connectiontype = ""; + } + if($driverName == "PostGIS JDBC Driver"){ + $path1 = $path."/tag:xml-tag/tag:property[@value='org.postgresql.Driver']/parent::*"; + $tabela = ""; + if($this->getValue($path1,"schema") != "") + {$tabela = $this->getValue($path1,"schema").".";} + $tabela .= $this->getValue($path1,"tablename"); + $data = $this->getValue($path1,"THE_GEOM")." FROM (select ".$this->getValue($path1,"THE_GEOM").",".$this->getValue($path1,"fields")." FROM ".$tabela.") as foo USING UNIQUE ".$this->getValue($path1,"FID")." USING SRID=".$this->getValue($path1,"SRID"); + $connection = "user=".$this->getValue($path1,"username")." password=".$this->getValue($path1,"username")." dbname=".$this->getValue($path1,"dbName")." host=".$this->getValue($path1,"host")." port=".$this->getValue($path1,"port"); + $connectiontype = MS_POSTGIS; + } return array( "minScale"=>$this->getValue($path,"minScale"), "maxScale"=>$this->getValue($path,"maxScale"), @@ -74,7 +92,9 @@ class gvsig2mapfile{ "proj"=>$this->getValue($path,"proj"), "transparency"=>$this->getValue($path,"transparency"), "type"=>$this->getValue($path,"type"), - "file"=>$this->getValue($path,"file"), + "data"=>$data, + "connection"=>$connection, + "connectiontype"=>$connectiontype, "driverName"=>$this->getValue($path,"driverName"), "isLabeled"=>$this->getValue($path,"isLabeled"), "legenda"=>array( @@ -155,10 +175,21 @@ class gvsig2mapfile{ } function data2layer($oLayer,$dataLayer){ $oLayer->set("name",$this->nomeRandomico()); - $oLayer->set("data",$dataLayer["file"]); + $oLayer->set("data",$dataLayer["data"]); + if($dataLayer["connectiontype"] != "") + {$oLayer->setConnectionType($dataLayer["connectiontype"]);} + if($dataLayer["connection"] != "") + {$oLayer->set("connection",$dataLayer["connection"]);} $oLayer->set("status",MS_DEFAULT); if($dataLayer["visible"] == "false") {$oLayer->set("status",MS_OFF);} + $opacidade = ($dataLayer["transparency"] * 100) / 255; + $oLayer->set("opacity",$opacidade); + if($dataLayer["minScale"] > 0) + {$oLayer->set("minscaledenom",$dataLayer["minScale"]);} + if($dataLayer["maxScale"] > 0) + {$oLayer->set("maxscaledenom",$dataLayer["maxScale"]);} + $tipo = $dataLayer["legenda"]["classes"][0]["className"]; $oLayer->set("type",1); if($tipo == "com.iver.cit.gvsig.fmap.core.symbols.SimpleMarkerSymbol") @@ -172,7 +203,10 @@ class gvsig2mapfile{ $estilo->set("symbolname","ponto"); } $ncor = explode(",",$data["color"]); - $cor = $estilo->color; + if($data["hasFill"] == "true") + {$cor = $estilo->color;} + else + {$cor = $estilo->outlinecolor;} $cor->setrgb($ncor[0],$ncor[1],$ncor[2]); if($data["size"] != false) {$estilo->set("size",$data["size"]);} diff --git a/pacotes/gvsig/gvsig2mapfile/gvsig2mapfile.php b/pacotes/gvsig/gvsig2mapfile/gvsig2mapfile.php index bb197a3..85b27ec 100644 --- a/pacotes/gvsig/gvsig2mapfile/gvsig2mapfile.php +++ b/pacotes/gvsig/gvsig2mapfile/gvsig2mapfile.php @@ -1,7 +1,7 @@ "; $nomes = $gm->getViewsNames(); $view = $gm->getViewByName($nomes[0]); @@ -11,5 +11,5 @@ echo "Camadas: ".(implode(",",$dataView["layerNames"]))."\n"; foreach($dataView["layerNames"] as $lname) {var_dump($gm->getLayerData($nomes[0],$lname));} - //localhost/i3geo/ms_criamapa.php?gvsiggvp=C:\ms4w\Apache\htdocs\i3geo\pacotes\gvsig\projetoteste.gvp&gvsigview=teste 1&temasa= + //localhost/i3geo/ms_criamapa.php?gvsiggvp=C:\ms4w\Apache\htdocs\i3geo\pacotes\gvsig\gvsig2mapfile\projetoteste.gvp&gvsigview=teste 1&temasa= ?> \ No newline at end of file diff --git a/pacotes/gvsig/gvsig2mapfile/projetoteste.bak b/pacotes/gvsig/gvsig2mapfile/projetoteste.bak index aa0ff6b..afdedf9 100644 --- a/pacotes/gvsig/gvsig2mapfile/projetoteste.bak +++ b/pacotes/gvsig/gvsig2mapfile/projetoteste.bak @@ -6,15 +6,19 @@ - + - + + + + + @@ -28,6 +32,12 @@ + + + + + + @@ -76,14 +86,14 @@ - - + + - - + + @@ -165,6 +175,22 @@ + + + + + + + + + + + + + + + + @@ -176,13 +202,13 @@ - + - + - - + + @@ -192,7 +218,7 @@ - + @@ -232,22 +258,22 @@ - - + + - - - + + + - - - + + + @@ -258,7 +284,7 @@ - + @@ -267,9 +293,9 @@ - + - + @@ -300,14 +326,34 @@ + + + + + + + + + + + + + + + + + + - + + + - - + + @@ -322,7 +368,7 @@ - + @@ -353,7 +399,7 @@ - + @@ -703,6 +749,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1227,8 +1359,8 @@ - - + + @@ -1248,26 +1380,26 @@ - + - - - + + + - + - + - + - + - - + + diff --git a/pacotes/gvsig/gvsig2mapfile/projetoteste.gvp b/pacotes/gvsig/gvsig2mapfile/projetoteste.gvp index 3f811ef..d57ff5f 100644 --- a/pacotes/gvsig/gvsig2mapfile/projetoteste.gvp +++ b/pacotes/gvsig/gvsig2mapfile/projetoteste.gvp @@ -6,15 +6,19 @@ - + - + + + + + @@ -28,6 +32,12 @@ + + + + + + @@ -76,14 +86,14 @@ - - + + - - + + @@ -165,6 +175,22 @@ + + + + + + + + + + + + + + + + @@ -176,13 +202,13 @@ - + - + - - + + @@ -192,7 +218,7 @@ - + @@ -232,22 +258,22 @@ - - + + - - - + + + - - - + + + @@ -258,7 +284,7 @@ - + @@ -267,9 +293,9 @@ - + - + @@ -300,14 +326,34 @@ + + + + + + + + + + + + + + + + + + - + + + - - + + @@ -322,7 +368,7 @@ - + @@ -353,7 +399,7 @@ - + @@ -703,6 +749,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1227,8 +1359,8 @@ - - + + @@ -1248,26 +1380,26 @@ - + - - - + + + - + - + - + - + - - + + diff --git a/pacotes/gvsig/gvsig2mapfile/upload.htm b/pacotes/gvsig/gvsig2mapfile/upload.htm index d08468a..b79d681 100644 --- a/pacotes/gvsig/gvsig2mapfile/upload.htm +++ b/pacotes/gvsig/gvsig2mapfile/upload.htm @@ -17,7 +17,9 @@

Arquivo de projeto gvSig (.gvp). Será utilizada a primeira "view" existente no projeto.
A conversão ainda é experimental, caso ocorra algum erro, envie o seu projeto para o e-mail: edmar.moretti@gmail.com
- Não há garantias de sigilo em relação ao arquivo enviado ao servidor. Evite utilizar dados restritos, como endereços e senhas.

+ Não há garantias de sigilo em relação ao arquivo enviado ao servidor. Evite utilizar dados restritos, como endereços e senhas.
+ No caso de camadas baseadas em conexões com banco de dados, a senha colocada em CONNECTION é igual ao nome do usuário, uma vez + que não é armazenada no arquivo .gvp

-- libgit2 0.21.2