Commit 4d9dab6075374b17ee947d14fcd0b4362c9cdab8

Authored by Edmar Moretti
1 parent 95c5de02

Correções no leitor de camadas WMS

Showing 2 changed files with 123 additions and 16 deletions   Show diff stats
classesphp/classe_mapa.php
@@ -939,7 +939,9 @@ Endereço do WMS @@ -939,7 +939,9 @@ Endereço do WMS
939 $this->mapa->setmetadata("wms_srs","EPSG:4291"); 939 $this->mapa->setmetadata("wms_srs","EPSG:4291");
940 foreach ($this->layers as $layer) 940 foreach ($this->layers as $layer)
941 { 941 {
942 - $layer->setmetadata("wms_title",pegaNome($layer)); 942 + $n = pegaNome($layer);
  943 + $layer->setmetadata("wms_title",$n);
  944 + $layer->setmetadata("wms_name",$n);
943 $layer->setmetadata("wms_srs","EPSG:4291 EPSG:4326"); 945 $layer->setmetadata("wms_srs","EPSG:4291 EPSG:4326");
944 $layer->setmetadata("WMS_INCLUDE_ITEMS","all"); 946 $layer->setmetadata("WMS_INCLUDE_ITEMS","all");
945 $layer->set("status","ON"); 947 $layer->set("status","ON");
classesphp/wmswfs.php
@@ -234,6 +234,7 @@ function temaswms() @@ -234,6 +234,7 @@ function temaswms()
234 # ------------------------------------------------------------- 234 # -------------------------------------------------------------
235 # Test that the capabilites file has successfully downloaded. 235 # Test that the capabilites file has successfully downloaded.
236 # 236 #
  237 + //$wms_service_request = "c://temp//teste.xml";
237 if( !($wms_capabilities = file($wms_service_request)) ) { 238 if( !($wms_capabilities = file($wms_service_request)) ) {
238 # Cannot download the capabilities file. 239 # Cannot download the capabilities file.
239 $cp->set_data("Erro de acesso"); 240 $cp->set_data("Erro de acesso");
@@ -251,15 +252,121 @@ function temaswms() @@ -251,15 +252,121 @@ function temaswms()
251 {$n = $e->getAttribute("SupportSLD");} 252 {$n = $e->getAttribute("SupportSLD");}
252 $suporta = "nao"; 253 $suporta = "nao";
253 if ($n == 1){$suporta = "sim";} 254 if ($n == 1){$suporta = "sim";}
254 -  
255 - $query = '//WMT_MS_Capabilities/Capability/Layer/Layer/Style';  
256 - $entries = $xpath->query($query);  
257 - $nums = $entries->length;  
258 - if ($entries->length > 0) 255 + $xpath = new DOMXPath($dom);
  256 + $q = '//WMT_MS_Capabilities/Capability';
  257 + $query = $q.'/Layer';
  258 + $layers = $xpath->query($query);
  259 + $retorna = array();
  260 + foreach ($layers as $layer)
  261 + {
  262 + $r = pegaTag($layer);
  263 + $retorna = imprimeTag($r,$retorna);
  264 + $query = $q.'/Layer/Layer';
  265 + $layers1 = $xpath->query($query);
  266 + foreach ($layers1 as $layer1)
  267 + {
  268 + $r1 = pegaTag($layer1);
  269 + $camada1 = $r1["nome"];
  270 + $titulocamada1 = $r1["titulo"];
  271 + $retorna = imprimeTag($r1,$retorna);
  272 + if($r1["estilos"])
  273 + {$retorna = imprimeEstilos($r1["estilos"],$suporta,$retorna,$camada1,$titulocamada1);}
  274 + else
  275 + {$retorna[] = "<input style='cursor:pointer' type=radio NAME='checks' onClick='seltema(\"tema\",\"" . $camada1 . "\",\"\",\"default\",\"".$camada1." ".$titulocamada1."\",\"".$suporta."\")' value='" . $camada1 . "'/> default<i>".$titulocamada1."</i></span><br>";}
  276 +
  277 + $query = $q.'/Layer/Layer/Layer';
  278 + $layers2 = $xpath->query($query);
  279 + foreach ($layers2 as $layer2)
  280 + {
  281 + $r2 = pegaTag($layer2);
  282 + $camada2 = $r2["nome"];
  283 + $titulocamada2 = $r2["titulo"];
  284 + $retorna = imprimeTag($r2,$retorna);
  285 + if($r2["estilos"])
  286 + {$retorna = imprimeEstilos($r2["estilos"],$suporta,$retorna,$camada2,$titulocamada2);}
  287 + else
  288 + {$retorna[] = "<input style='cursor:pointer' type=radio NAME='checks' onClick='seltema(\"tema\",\"" . $camada2 . "\",\"\",\"default\",\"".$camada2." ".$titulocamada2."\",\"".$suporta."\")' value='" . $camada2 . "'/> default <i>".$titulocamada2."</i></span><br>";}
  289 +
  290 + }
  291 + }
  292 +
  293 + }
  294 + $retorna[] = "<br>Proj.:<input size=30 id=proj type=text class=digitar value='".implode(",",wms_srs($dom))."'/><br>";
  295 + $retorna[] = "<br>Formatos imagem:<input size=30 id=formatos type=text class=digitar value='".implode(",",wms_formats($dom))."'/><br><br>";
  296 + $retorna[] = "<br>Formatos info:<input size=30 id=formatosinfo type=text class=digitar value='".implode(",",wms_formatsinfo($dom))."'/><br><br>";
  297 + $retorna[] = "<br>Versao:<input size=30 id=versao type=text class=digitar value='".(wms_version($dom))."'/><br><br>";
  298 + $retorna[] = "<br>Suporta SLD:<input size=30 id=suportasld type=text class=digitar value='".$suporta."'/><br><br><br>";
  299 + //echo "<pre>";
  300 + //var_dump($retorna);
  301 + $cp->set_data(implode($retorna));
  302 +}
  303 +function imprimeEstilos($es,$suporta,$retorna,$tval,$tituloalternativo)
  304 +{
  305 + foreach($es as $e)
259 { 306 {
260 - $query = '//WMT_MS_Capabilities/Capability/Layer';  
261 - $entries = $xpath->query($query); 307 + //$tval = $e["titulo"];
  308 + $nomeestilo = $e["nome"];
  309 + $nomecamada = $e["titulo"];
  310 + //if($nomecamada == "default" || $nomecamada == "")
  311 + //{$nomecamada = $tituloalternativo;}
  312 + $tituloestilo = $e["titulo"];
  313 + $retorna[] = "<input style='cursor:pointer' type=radio NAME='checks' onClick='seltema(\"estilo\",\"" . $tval . "\",\"\",\"" . $nomeestilo . "\",\"".$tituloalternativo." ".$nomecamada." ".$tituloestilo."\",\"".$suporta."\")' value='" . $nomeestilo . "'/><span style=color:blue >" . $nomeestilo." <i>".$tituloestilo."</i></span><br>";
262 } 314 }
  315 + return $retorna;
  316 +}
  317 +function imprimeTag($r,$retorna)
  318 +{
  319 + if(!$r["nome"])
  320 + {$retorna[] = "<br><span style='color:brown;font-size:14pt' ><b>".$r["titulo"]."</b></span><br>";}
  321 + else
  322 + {
  323 + $retorna[] = "<hr>";
  324 + $retorna[] = "<br><span style='color:brown;font-size:12pt' ><b>".$r["nome"]."</b></span><br>";
  325 + $retorna[] = "<br><span style='color:black;font-size:12pt' ><b>".$r["titulo"]."</b></span><br>";
  326 + $retorna[] = "<br><span style='color:gray;font-size:9pt' >".$r["resumo"]."</span><br>";
  327 + }
  328 + return $retorna;
  329 +}
  330 +function pegaTag($layer)
  331 +{
  332 + $noslayer = $layer->childNodes;
  333 + $resultado = array();
  334 + for ($i = 0; $i < $noslayer->length; $i++)
  335 + {
  336 + $tnome = $noslayer->item($i)->tagName;
  337 + $tvalor = $noslayer->item($i)->nodeValue;
  338 + //$tvalor = mb_convert_encoding($tvalor,"AUTO","AUTO");
  339 + if($tnome)
  340 + {
  341 + if ($tnome == "Title")
  342 + {$resultado["titulo"] = $tvalor;}
  343 + if ($tnome == "Name")
  344 + {$resultado["nome"] = $tvalor;}
  345 + if ($tnome == "Abstract")
  346 + {$resultado["resumo"] = $tvalor;}
  347 + if ($tnome == "Style")
  348 + {
  349 + $ss = $noslayer->item($i)->childNodes;
  350 + for ($s = 0; $s < $ss->length; $s++)
  351 + {
  352 + $snome = $ss->item($s)->tagName;
  353 + $svalor = $ss->item($s)->nodeValue;
  354 + if($snome)
  355 + {
  356 + if ($snome == "Title")
  357 + {$t=$svalor;}
  358 + if ($snome == "Name")
  359 + {$n=$svalor;}
  360 + }
  361 + }
  362 + $resultado["estilos"][] = array("nome"=>$n,"titulo"=>$t);
  363 + }
  364 + $resultado["tags"][] = $tnome;
  365 + }
  366 + }
  367 + return $resultado;
  368 +
  369 + /*
263 $tval = ""; 370 $tval = "";
264 foreach ($layers as $layer) 371 foreach ($layers as $layer)
265 { 372 {
@@ -268,8 +375,8 @@ function temaswms() @@ -268,8 +375,8 @@ function temaswms()
268 { 375 {
269 $tnome = $noslayer->item($i)->tagName; 376 $tnome = $noslayer->item($i)->tagName;
270 $tvalor = $noslayer->item($i)->nodeValue; 377 $tvalor = $noslayer->item($i)->nodeValue;
271 - if ($tnome == "Title")  
272 - {$retorna[] = "<b>Titulo da camada: ".$tvalor."</b><br><br>Sub-camadas:<br><br>";} 378 +
  379 +
273 if ($tnome == "Layer") 380 if ($tnome == "Layer")
274 { 381 {
275 $retorna[] = "<hr>"; 382 $retorna[] = "<hr>";
@@ -278,6 +385,7 @@ function temaswms() @@ -278,6 +385,7 @@ function temaswms()
278 { 385 {
279 $tnome = $sublayers->item($j)->tagName; 386 $tnome = $sublayers->item($j)->tagName;
280 $tvalor = $sublayers->item($j)->nodeValue; 387 $tvalor = $sublayers->item($j)->nodeValue;
  388 +
281 if ($tnome != "Style") 389 if ($tnome != "Style")
282 { 390 {
283 $ns = ""; 391 $ns = "";
@@ -322,14 +430,11 @@ function temaswms() @@ -322,14 +430,11 @@ function temaswms()
322 } 430 }
323 } 431 }
324 } 432 }
325 - $retorna[] = "<br>Proj.:<input size=30 id=proj type=text class=digitar value='".implode(",",wms_srs($dom))."'/><br>";  
326 - $retorna[] = "<br>Formatos imagem:<input size=30 id=formatos type=text class=digitar value='".implode(",",wms_formats($dom))."'/><br><br>";  
327 - $retorna[] = "<br>Formatos info:<input size=30 id=formatosinfo type=text class=digitar value='".implode(",",wms_formatsinfo($dom))."'/><br><br>";  
328 - $retorna[] = "<br>Versao:<input size=30 id=versao type=text class=digitar value='".(wms_version($dom))."'/><br><br>";  
329 - $retorna[] = "<br>Suporta SLD:<input size=30 id=suportasld type=text class=digitar value='".$suporta."'/><br><br><br>";  
330 - $cp->set_data(implode($retorna)); 433 + */
  434 +
331 } 435 }
332 436
  437 +
333 /* 438 /*
334 function: temaswfs 439 function: temaswfs
335 440