Commit bc40f8ea45a495518b90a1687e1b85b911338ab0

Authored by Edmar Moretti
1 parent 2a5011f3

Correção na obtenção dos nomes das classes e do outline

pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php
@@ -115,7 +115,8 @@ class gvsig2mapfile{ @@ -115,7 +115,8 @@ class gvsig2mapfile{
115 $coluna = (string) $this->getValue($path."/tag:xml-tag","fieldNames"); 115 $coluna = (string) $this->getValue($path."/tag:xml-tag","fieldNames");
116 $valores = (string) $this->getValue($path."/tag:xml-tag","values"); 116 $valores = (string) $this->getValue($path."/tag:xml-tag","values");
117 $tipocoluna = (string) $this->getValue($path."/tag:xml-tag","fieldTypes"); 117 $tipocoluna = (string) $this->getValue($path."/tag:xml-tag","fieldTypes");
118 - $classes = $this->VectorialUniqueValueLegend($result,$path1,$coluna,$tipocoluna,$valores); 118 + $nomes = (string) $this->getValue($path."/tag:xml-tag","keys");
  119 + $classes = $this->VectorialUniqueValueLegend($result,$path1,$coluna,$tipocoluna,$valores,$nomes);
119 } 120 }
120 121
121 $path1 = $path."/tag:xml-tag/tag:property[@value='".$render.".SingleSymbolLegend']/parent::*/tag:xml-tag"; 122 $path1 = $path."/tag:xml-tag/tag:property[@value='".$render.".SingleSymbolLegend']/parent::*/tag:xml-tag";
@@ -159,9 +160,11 @@ class gvsig2mapfile{ @@ -159,9 +160,11 @@ class gvsig2mapfile{
159 ) 160 )
160 ); 161 );
161 } 162 }
162 - function VectorialUniqueValueLegend($result,$path1,$coluna,$tipocoluna,$valores){ 163 + function VectorialUniqueValueLegend($result,$path1,$coluna,$tipocoluna,$valores,$nomes){
163 $valores = ",".str_replace(" ,",",",$valores); 164 $valores = ",".str_replace(" ,",",",$valores);
164 $valores = explode(",",$valores); 165 $valores = explode(",",$valores);
  166 + $nomes = ",".str_replace(" ,",",",$nomes);
  167 + $nomes = explode(",",$nomes);
165 $classes = array(); 168 $classes = array();
166 $c = 0; 169 $c = 0;
167 while(list( , $node) = each($result)) { 170 while(list( , $node) = each($result)) {
@@ -171,16 +174,22 @@ class gvsig2mapfile{ @@ -171,16 +174,22 @@ class gvsig2mapfile{
171 else 174 else
172 {$classe["exp"] = "([".$coluna."] = ".$valores[$c]." )";} 175 {$classe["exp"] = "([".$coluna."] = ".$valores[$c]." )";}
173 $classe["className"] = (string) $this->getValue($path1,"className",$c); 176 $classe["className"] = (string) $this->getValue($path1,"className",$c);
  177 + $classe["nome"] = $nomes[$c];
174 $classe["desc"] = (string) $this->getValue($path1,"desc",$c); 178 $classe["desc"] = (string) $this->getValue($path1,"desc",$c);
175 $classe["color"] = (string) $this->getValue($path1,"color",$c); 179 $classe["color"] = (string) $this->getValue($path1,"color",$c);
176 $classe["rotation"] = (string) $this->getValue($path1,"rotation",$c); 180 $classe["rotation"] = (string) $this->getValue($path1,"rotation",$c);
177 $classe["offsetX"] = (string) $this->getValue($path1,"offsetX",$c); 181 $classe["offsetX"] = (string) $this->getValue($path1,"offsetX",$c);
178 $classe["offsetY"] = (string) $this->getValue($path1,"offsetY",$c); 182 $classe["offsetY"] = (string) $this->getValue($path1,"offsetY",$c);
179 $classe["size"] = (string) $this->getValue($path1,"size",$c); 183 $classe["size"] = (string) $this->getValue($path1,"size",$c);
180 - $classe["outline"] = (string) $this->getValue($path1,"outline",$c);  
181 $classe["markerStyle"] = (string) $this->getValue($path1,"markerStyle",$c); 184 $classe["markerStyle"] = (string) $this->getValue($path1,"markerStyle",$c);
182 $classe["hasFill"] = (string) $this->getValue($path1,"hasFill",$c); 185 $classe["hasFill"] = (string) $this->getValue($path1,"hasFill",$c);
183 $classe["hasOutline"] = (string) $this->getValue($path1,"hasOutline",$c); 186 $classe["hasOutline"] = (string) $this->getValue($path1,"hasOutline",$c);
  187 + if($classe["hasOutline"] == "true"){
  188 + $classe["outline"] = (string) $this->getValue($path1."/tag:xml-tag","color",0);
  189 + }
  190 + else{
  191 + $classe["outline"] = (string) $this->getValue($path1,"color",$c);
  192 + }
184 if($classe["desc"] != "") 193 if($classe["desc"] != "")
185 {$classes[] = $classe;} 194 {$classes[] = $classe;}
186 $c = $c + 1; 195 $c = $c + 1;
@@ -200,13 +209,16 @@ class gvsig2mapfile{ @@ -200,13 +209,16 @@ class gvsig2mapfile{
200 $classe["offsetX"] = (string) $this->getValue($path,"offsetX",$c); 209 $classe["offsetX"] = (string) $this->getValue($path,"offsetX",$c);
201 $classe["offsetY"] = (string) $this->getValue($path,"offsetY",$c); 210 $classe["offsetY"] = (string) $this->getValue($path,"offsetY",$c);
202 $classe["size"] = (string) $this->getValue($path,"size",$c); 211 $classe["size"] = (string) $this->getValue($path,"size",$c);
203 - $classe["outline"] = (string) $this->getValue($path,"outline",$c);  
204 $classe["markerStyle"] = (string) $this->getValue($path,"markerStyle",$c); 212 $classe["markerStyle"] = (string) $this->getValue($path,"markerStyle",$c);
205 $classe["hasFill"] = (string) $this->getValue($path,"hasFill",$c); 213 $classe["hasFill"] = (string) $this->getValue($path,"hasFill",$c);
206 $classe["hasOutline"] = (string) $this->getValue($path,"hasOutline",$c); 214 $classe["hasOutline"] = (string) $this->getValue($path,"hasOutline",$c);
207 $classe["exp"] = false; 215 $classe["exp"] = false;
  216 + $classe["nome"] = " ";
208 if($classe["hasOutline"] == "true"){ 217 if($classe["hasOutline"] == "true"){
209 - $classe["outline"] = $this->getValue($path."/tag:xml-tag","color"); 218 + $classe["outline"] = (string) $this->getValue($path."/tag:xml-tag","color");
  219 + }
  220 + else{
  221 + $classe["outline"] = (string) $this->getValue($path,"color",$c);
210 } 222 }
211 $classes[] = $classe; 223 $classes[] = $classe;
212 $c = $c + 1; 224 $c = $c + 1;
@@ -225,12 +237,14 @@ class gvsig2mapfile{ @@ -225,12 +237,14 @@ class gvsig2mapfile{
225 $dataLayer = $this->getLayerData($gvsigview,$lname); 237 $dataLayer = $this->getLayerData($gvsigview,$lname);
226 $oLayer = ms_newLayerObj($objMap); 238 $oLayer = ms_newLayerObj($objMap);
227 $oLayer->setmetadata("TEMA",$lname); 239 $oLayer->setmetadata("TEMA",$lname);
  240 + $oLayer->set("template","none.htm");
228 $oLayer = $this->data2layer($oLayer,$dataLayer); 241 $oLayer = $this->data2layer($oLayer,$dataLayer);
229 } 242 }
230 return $objMap; 243 return $objMap;
231 } 244 }
232 function data2layer($oLayer,$dataLayer){ 245 function data2layer($oLayer,$dataLayer){
233 - $oLayer->set("name",$this->nomeRandomico()); 246 + //TODO corrigir acentuação
  247 + $oLayer->set("name",basename($this->arquivoGvp)."_".$oLayer->index); //$this->nomeRandomico());
234 $this->nomesLayersAdicionados[] = $oLayer->name; 248 $this->nomesLayersAdicionados[] = $oLayer->name;
235 $oLayer->set("data",$dataLayer["data"]); 249 $oLayer->set("data",$dataLayer["data"]);
236 if($dataLayer["connectiontype"] != "") 250 if($dataLayer["connectiontype"] != "")
@@ -254,17 +268,23 @@ class gvsig2mapfile{ @@ -254,17 +268,23 @@ class gvsig2mapfile{
254 if($tipo == "com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol") 268 if($tipo == "com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol")
255 {$oLayer->set("type",2);} 269 {$oLayer->set("type",2);}
256 foreach($dataLayer["legenda"]["classes"] as $data){ 270 foreach($dataLayer["legenda"]["classes"] as $data){
  271 + //var_dump($data);
257 $classe = ms_newClassObj($oLayer); 272 $classe = ms_newClassObj($oLayer);
  273 + $classe->set("name",$data["nome"]);
258 $estilo = ms_newStyleObj($classe); 274 $estilo = ms_newStyleObj($classe);
259 if($oLayer->type == 0){ 275 if($oLayer->type == 0){
260 $estilo->set("symbolname","ponto"); 276 $estilo->set("symbolname","ponto");
261 } 277 }
262 - $ncor = explode(",",$data["color"]);  
263 - if($data["hasFill"] == "true")  
264 - {$cor = $estilo->color;}  
265 - else  
266 - {$cor = $estilo->outlinecolor;}  
267 - $cor->setrgb($ncor[0],$ncor[1],$ncor[2]); 278 + if($data["hasFill"] == "true"){
  279 + $ncor = explode(",",$data["color"]);
  280 + $cor = $estilo->color;
  281 + $cor->setrgb($ncor[0],$ncor[1],$ncor[2]);
  282 + }
  283 + if($data["hasOutline"] == "true" && $data["outline"] != ""){
  284 + $ncor = explode(",",$data["outline"]);
  285 + $cor = $estilo->outlinecolor;
  286 + $cor->setrgb($ncor[0],$ncor[1],$ncor[2]);
  287 + }
268 if($data["size"] != false) 288 if($data["size"] != false)
269 {$estilo->set("size",$data["size"]);} 289 {$estilo->set("size",$data["size"]);}
270 if($data["exp"] != false) 290 if($data["exp"] != false)