Commit 4cf55296b444d91d8494847bc191c35a72f2573a
1 parent
7d66716d
Exists in
master
and in
7 other branches
Correção na conversão de um projeto gvsig em mapfile que ocorrem em função de di…
…ferentes versões do PHP e gvSIG
Showing
4 changed files
with
63 additions
and
59 deletions
Show diff stats
ms_criamapa.php
... | ... | @@ -365,8 +365,9 @@ if(isset($gvsiggvp) && $gvsiggvp != ""){ |
365 | 365 | if(isset($gvsigview) && $gvsigview != ""){ |
366 | 366 | incluiMapaGvsig($gvsiggvp,$gvsigview); |
367 | 367 | } |
368 | - else | |
369 | - {echo "Nenhuma vista foi definida &gvsigview";} | |
368 | + else{ | |
369 | + echo "Nenhuma vista foi definida &gvsigview"; | |
370 | + } | |
370 | 371 | } |
371 | 372 | /* |
372 | 373 | Parâmetros adicionais. |
... | ... | @@ -1104,7 +1105,6 @@ function incluiMapaGvsig($gvsiggvp,$gvsigview){ |
1104 | 1105 | include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); |
1105 | 1106 | $gm = new gvsig2mapfile($gvsiggvp); |
1106 | 1107 | $dataView = $gm->getViewData($gvsigview); |
1107 | - //var_dump($dataView);exit; | |
1108 | 1108 | $numlayers = $mapn->numlayers; |
1109 | 1109 | for ($i=0;$i < $numlayers;$i++) |
1110 | 1110 | { | ... | ... |
pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php
... | ... | @@ -14,9 +14,9 @@ class gvsig2mapfile{ |
14 | 14 | } |
15 | 15 | if (!function_exists('simplexml_load_file')) |
16 | 16 | {throw new Exception("Função PHP simplexml_load_file não existe");} |
17 | - $this->xml = simplexml_load_file($gvp); | |
17 | + $this->xml = simplexml_load_file($gvp); | |
18 | 18 | } |
19 | - } | |
19 | + } | |
20 | 20 | function getViewsNames(){ |
21 | 21 | $names = array(); |
22 | 22 | $this->xml->registerXPathNamespace("tag", "http://www.gvsig.gva.es"); |
... | ... | @@ -34,16 +34,17 @@ class gvsig2mapfile{ |
34 | 34 | function getViewData($nome){ |
35 | 35 | $this->xml->registerXPathNamespace("tag", "http://www.gvsig.gva.es"); |
36 | 36 | $path = "/tag:xml-tag/tag:xml-tag/tag:property[@value='ProjectView']/parent::*/tag:property[@value='".$nome."']/parent::*/tag:xml-tag/tag:xml-tag"; |
37 | - | |
38 | - $xmin = $this->getValue($path,"adjustedExtentX"); | |
39 | - $ymin = $this->getValue($path,"adjustedExtentY"); | |
40 | - $xmax = $xmin + $this->getValue($path,"adjustedExtentW"); | |
41 | - $ymax = $ymin + $this->getValue($path,"adjustedExtentH"); | |
37 | + | |
38 | + $xmin = (float) $this->getValue($path,"adjustedExtentX"); | |
39 | + $ymin = (float) $this->getValue($path,"adjustedExtentY"); | |
40 | + $xmax = $xmin + (float) $this->getValue($path,"adjustedExtentW"); | |
41 | + $ymax = $ymin + (float) $this->getValue($path,"adjustedExtentH"); | |
42 | + | |
42 | 43 | $proj = $this->getValue($path,"proj"); |
43 | 44 | $nomes = $this->getValue($path,"LayerNames"); |
44 | 45 | return array( |
45 | 46 | "extent"=>array($xmin,$ymin,$xmax,$ymax), |
46 | - "proj"=>$proj, | |
47 | + "proj"=>(string) $proj, | |
47 | 48 | "layerNames"=>explode(",",str_replace(" ,",",",$nomes)) |
48 | 49 | ); |
49 | 50 | } |
... | ... | @@ -52,16 +53,16 @@ class gvsig2mapfile{ |
52 | 53 | $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::*"; |
53 | 54 | $classes = array(); |
54 | 55 | $render = 'com.iver.cit.gvsig.fmap.rendering'; |
55 | - | |
56 | + | |
56 | 57 | $path1 = $path."/tag:xml-tag/tag:property[@value='".$render.".VectorialUniqueValueLegend']/parent::*/tag:xml-tag"; |
57 | 58 | $result = $this->xml->xpath($path1); |
58 | 59 | if($result != FALSE){ |
59 | - $coluna = $this->getValue($path."/tag:xml-tag","fieldNames"); | |
60 | - $valores = $this->getValue($path."/tag:xml-tag","values"); | |
61 | - $tipocoluna = $this->getValue($path."/tag:xml-tag","fieldTypes"); | |
60 | + $coluna = (string) $this->getValue($path."/tag:xml-tag","fieldNames"); | |
61 | + $valores = (string) $this->getValue($path."/tag:xml-tag","values"); | |
62 | + $tipocoluna = (string) $this->getValue($path."/tag:xml-tag","fieldTypes"); | |
62 | 63 | $classes = $this->VectorialUniqueValueLegend($result,$path1,$coluna,$tipocoluna,$valores); |
63 | 64 | } |
64 | - | |
65 | + | |
65 | 66 | $path1 = $path."/tag:xml-tag/tag:property[@value='".$render.".SingleSymbolLegend']/parent::*/tag:xml-tag"; |
66 | 67 | $result = $this->xml->xpath($path1); |
67 | 68 | if($result != FALSE) |
... | ... | @@ -71,7 +72,7 @@ class gvsig2mapfile{ |
71 | 72 | //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. |
72 | 73 | $driverName = $this->getValue($path,"driverName"); |
73 | 74 | if($driverName == "gvSIG shp driver"){ |
74 | - $data = $this->getValue($path,"file"); | |
75 | + $data = (string) $this->getValue($path,"file"); | |
75 | 76 | $connection = ""; |
76 | 77 | $connectiontype = ""; |
77 | 78 | } |
... | ... | @@ -79,26 +80,26 @@ class gvsig2mapfile{ |
79 | 80 | $path1 = $path."/tag:xml-tag/tag:property[@value='org.postgresql.Driver']/parent::*"; |
80 | 81 | $tabela = ""; |
81 | 82 | if($this->getValue($path1,"schema") != "") |
82 | - {$tabela = $this->getValue($path1,"schema").".";} | |
83 | - $tabela .= $this->getValue($path1,"tablename"); | |
84 | - $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"); | |
85 | - $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"); | |
83 | + {$tabela = (string) $this->getValue($path1,"schema").".";} | |
84 | + $tabela .= (string) $this->getValue($path1,"tablename"); | |
85 | + $data = (string) $this->getValue($path1,"THE_GEOM")." FROM (select ".(string) $this->getValue($path1,"THE_GEOM").",".(string) $this->getValue($path1,"fields")." FROM ".$tabela.") as foo USING UNIQUE ".(string) $this->getValue($path1,"FID")." USING SRID=".(string) $this->getValue($path1,"SRID"); | |
86 | + $connection = "user=".(string) $this->getValue($path1,"username")." password=".(string) $this->getValue($path1,"username")." dbname=".(string) $this->getValue($path1,"dbName")." host=".(string) $this->getValue($path1,"host")." port=".(string) $this->getValue($path1,"port"); | |
86 | 87 | $connectiontype = MS_POSTGIS; |
87 | 88 | } |
88 | 89 | return array( |
89 | - "minScale"=>$this->getValue($path,"minScale"), | |
90 | - "maxScale"=>$this->getValue($path,"maxScale"), | |
91 | - "visible"=>$this->getValue($path,"visible"), | |
92 | - "proj"=>$this->getValue($path,"proj"), | |
93 | - "transparency"=>$this->getValue($path,"transparency"), | |
94 | - "type"=>$this->getValue($path,"type"), | |
90 | + "minScale"=>(string) $this->getValue($path,"minScale"), | |
91 | + "maxScale"=>(string) $this->getValue($path,"maxScale"), | |
92 | + "visible"=>(string) $this->getValue($path,"visible"), | |
93 | + "proj"=>(string) $this->getValue($path,"proj"), | |
94 | + "transparency"=>(string) $this->getValue($path,"transparency"), | |
95 | + "type"=>(string) $this->getValue($path,"type"), | |
95 | 96 | "data"=>$data, |
96 | 97 | "connection"=>$connection, |
97 | 98 | "connectiontype"=>$connectiontype, |
98 | - "driverName"=>$this->getValue($path,"driverName"), | |
99 | - "isLabeled"=>$this->getValue($path,"isLabeled"), | |
99 | + "driverName"=>(string) $this->getValue($path,"driverName"), | |
100 | + "isLabeled"=>(string) $this->getValue($path,"isLabeled"), | |
100 | 101 | "legenda"=>array( |
101 | - "tipoLegenda"=>$this->getValue($path."/tag:xml-tag","className"), | |
102 | + "tipoLegenda"=>(string) $this->getValue($path."/tag:xml-tag","className"), | |
102 | 103 | "classes"=>$classes |
103 | 104 | ) |
104 | 105 | ); |
... | ... | @@ -114,17 +115,17 @@ class gvsig2mapfile{ |
114 | 115 | {$classe["exp"] = "('[".$coluna."]'eq'".$valores[$c]."')";} |
115 | 116 | else |
116 | 117 | {$classe["exp"] = "([".$coluna."] = ".$valores[$c]." )";} |
117 | - $classe["className"] = $this->getValue($path1,"className",$c); | |
118 | - $classe["desc"] = $this->getValue($path1,"desc",$c); | |
119 | - $classe["color"] = $this->getValue($path1,"color",$c); | |
120 | - $classe["rotation"] = $this->getValue($path1,"rotation",$c); | |
121 | - $classe["offsetX"] = $this->getValue($path1,"offsetX",$c); | |
122 | - $classe["offsetY"] = $this->getValue($path1,"offsetY",$c); | |
123 | - $classe["size"] = $this->getValue($path1,"size",$c); | |
124 | - $classe["outline"] = $this->getValue($path1,"outline",$c); | |
125 | - $classe["markerStyle"] = $this->getValue($path1,"markerStyle",$c); | |
126 | - $classe["hasFill"] = $this->getValue($path1,"hasFill",$c); | |
127 | - $classe["hasOutline"] = $this->getValue($path1,"hasOutline",$c); | |
118 | + $classe["className"] = (string) $this->getValue($path1,"className",$c); | |
119 | + $classe["desc"] = (string) $this->getValue($path1,"desc",$c); | |
120 | + $classe["color"] = (string) $this->getValue($path1,"color",$c); | |
121 | + $classe["rotation"] = (string) $this->getValue($path1,"rotation",$c); | |
122 | + $classe["offsetX"] = (string) $this->getValue($path1,"offsetX",$c); | |
123 | + $classe["offsetY"] = (string) $this->getValue($path1,"offsetY",$c); | |
124 | + $classe["size"] = (string) $this->getValue($path1,"size",$c); | |
125 | + $classe["outline"] = (string) $this->getValue($path1,"outline",$c); | |
126 | + $classe["markerStyle"] = (string) $this->getValue($path1,"markerStyle",$c); | |
127 | + $classe["hasFill"] = (string) $this->getValue($path1,"hasFill",$c); | |
128 | + $classe["hasOutline"] = (string) $this->getValue($path1,"hasOutline",$c); | |
128 | 129 | if($classe["desc"] != "") |
129 | 130 | {$classes[] = $classe;} |
130 | 131 | $c = $c + 1; |
... | ... | @@ -137,17 +138,17 @@ class gvsig2mapfile{ |
137 | 138 | //var_dump($result);exit; |
138 | 139 | while(list( , $node) = each($result)) { |
139 | 140 | $classe = array(); |
140 | - $classe["className"] = $this->getValue($path,"className",$c); | |
141 | - $classe["desc"] = $this->getValue($path,"desc",$c); | |
142 | - $classe["color"] = $this->getValue($path,"color",$c); | |
143 | - $classe["rotation"] = $this->getValue($path,"rotation",$c); | |
144 | - $classe["offsetX"] = $this->getValue($path,"offsetX",$c); | |
145 | - $classe["offsetY"] = $this->getValue($path,"offsetY",$c); | |
146 | - $classe["size"] = $this->getValue($path,"size",$c); | |
147 | - $classe["outline"] = $this->getValue($path,"outline",$c); | |
148 | - $classe["markerStyle"] = $this->getValue($path,"markerStyle",$c); | |
149 | - $classe["hasFill"] = $this->getValue($path,"hasFill",$c); | |
150 | - $classe["hasOutline"] = $this->getValue($path,"hasOutline",$c); | |
141 | + $classe["className"] = (string) $this->getValue($path,"className",$c); | |
142 | + $classe["desc"] = (string) $this->getValue($path,"desc",$c); | |
143 | + $classe["color"] = (string) $this->getValue($path,"color",$c); | |
144 | + $classe["rotation"] = (string) $this->getValue($path,"rotation",$c); | |
145 | + $classe["offsetX"] = (string) $this->getValue($path,"offsetX",$c); | |
146 | + $classe["offsetY"] = (string) $this->getValue($path,"offsetY",$c); | |
147 | + $classe["size"] = (string) $this->getValue($path,"size",$c); | |
148 | + $classe["outline"] = (string) $this->getValue($path,"outline",$c); | |
149 | + $classe["markerStyle"] = (string) $this->getValue($path,"markerStyle",$c); | |
150 | + $classe["hasFill"] = (string) $this->getValue($path,"hasFill",$c); | |
151 | + $classe["hasOutline"] = (string) $this->getValue($path,"hasOutline",$c); | |
151 | 152 | $classe["exp"] = false; |
152 | 153 | if($classe["hasOutline"] == "true"){ |
153 | 154 | $classe["outline"] = $this->getValue($path."/tag:xml-tag","color"); |
... | ... | @@ -179,7 +180,7 @@ class gvsig2mapfile{ |
179 | 180 | if($dataLayer["connectiontype"] != "") |
180 | 181 | {$oLayer->setConnectionType($dataLayer["connectiontype"]);} |
181 | 182 | if($dataLayer["connection"] != "") |
182 | - {$oLayer->set("connection",$dataLayer["connection"]);} | |
183 | + {$oLayer->set("connection",$dataLayer["connection"]);} | |
183 | 184 | $oLayer->set("status",MS_DEFAULT); |
184 | 185 | if($dataLayer["visible"] == "false") |
185 | 186 | {$oLayer->set("status",MS_OFF);} |
... | ... | @@ -189,7 +190,7 @@ class gvsig2mapfile{ |
189 | 190 | {$oLayer->set("minscaledenom",$dataLayer["minScale"]);} |
190 | 191 | if($dataLayer["maxScale"] > 0) |
191 | 192 | {$oLayer->set("maxscaledenom",$dataLayer["maxScale"]);} |
192 | - | |
193 | + | |
193 | 194 | $tipo = $dataLayer["legenda"]["classes"][0]["className"]; |
194 | 195 | $oLayer->set("type",1); |
195 | 196 | if($tipo == "com.iver.cit.gvsig.fmap.core.symbols.SimpleMarkerSymbol") |
... | ... | @@ -234,6 +235,6 @@ class gvsig2mapfile{ |
234 | 235 | for($i=0; $i < $n; ++$i) |
235 | 236 | {$nomes .= $a{mt_rand(0, $max)};} |
236 | 237 | return $nomes; |
237 | - } | |
238 | + } | |
238 | 239 | } |
239 | 240 | ?> |
240 | 241 | \ No newline at end of file | ... | ... |
pacotes/gvsig/gvsig2mapfile/gvsig2mapfile.php
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | include_once("class.gvsig2mapfile.php"); |
3 | 3 | error_reporting(E_ALL); |
4 | 4 | $gm = new gvsig2mapfile("C:\ms4w\Apache\htdocs\i3geo\pacotes\gvsig\gvsig2mapfile\projetoteste.gvp"); |
5 | - echo "<pre>"; | |
5 | + echo "<pre>Teste<br>"; | |
6 | 6 | $nomes = $gm->getViewsNames(); |
7 | 7 | $view = $gm->getViewByName($nomes[0]); |
8 | 8 | $dataView = $gm->getViewData($nomes[0]); | ... | ... |
pacotes/gvsig/gvsig2mapfile/upload.php
... | ... | @@ -17,13 +17,13 @@ if (isset($_FILES['i3GEOuploadfile']['name'])) |
17 | 17 | if($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv'.$versao.'.map')){ |
18 | 18 | $base = "/var/www/i3geo/aplicmap/geral1debianv".$versao.".map"; |
19 | 19 | } |
20 | - if($f == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){ | |
20 | + if($base == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){ | |
21 | 21 | $base = "/var/www/html/i3geo/aplicmap/geral1fedorav".$versao.".map"; |
22 | 22 | } |
23 | - if($f == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){ | |
23 | + if($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){ | |
24 | 24 | $base = "/opt/www/html/i3geo/aplicmap/geral1v".$versao.".map"; |
25 | 25 | } |
26 | - if($f == "") | |
26 | + if($base == "") | |
27 | 27 | {$base = $locaplic."/aplicmap/geral1v".$versao.".map";} |
28 | 28 | } |
29 | 29 | } |
... | ... | @@ -32,6 +32,7 @@ if (isset($_FILES['i3GEOuploadfile']['name'])) |
32 | 32 | {$base = $locaplic."/aplicmap/".$base;} |
33 | 33 | } |
34 | 34 | $mapn = ms_newMapObj($base); |
35 | + | |
35 | 36 | //echo "<p>Carregando o arquivo...</p>"; |
36 | 37 | //verifica nomes |
37 | 38 | verificaNome($_FILES['i3GEOuploadfile']['name']); |
... | ... | @@ -41,6 +42,7 @@ if (isset($_FILES['i3GEOuploadfile']['name'])) |
41 | 42 | $status = move_uploaded_file($Arquivo,$Arquivon); |
42 | 43 | if($status != 1) |
43 | 44 | {ob_clean();echo "Ocorreu um erro no envio do arquivo";exit;} |
45 | + | |
44 | 46 | if($status == 1) |
45 | 47 | { |
46 | 48 | //echo $Arquivon; |
... | ... | @@ -56,6 +58,7 @@ if (isset($_FILES['i3GEOuploadfile']['name'])) |
56 | 58 | $next = $dataView["extent"]; |
57 | 59 | $ext = $mapn->extent; |
58 | 60 | $ext->setextent($next[0],$next[1],$next[2],$next[3]); |
61 | + | |
59 | 62 | $mapn = $gm->addLayers($mapn,$views[0],$dataView["layerNames"]); |
60 | 63 | $mapn->save(str_replace(".gvp",".map",$Arquivon)); |
61 | 64 | $handle = fopen(str_replace(".gvp",".map",$Arquivon), "r"); | ... | ... |