From 4d9dab6075374b17ee947d14fcd0b4362c9cdab8 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Tue, 11 Dec 2007 13:45:36 +0000 Subject: [PATCH] Correções no leitor de camadas WMS --- classesphp/classe_mapa.php | 4 +++- classesphp/wmswfs.php | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 123 insertions(+), 16 deletions(-) diff --git a/classesphp/classe_mapa.php b/classesphp/classe_mapa.php index 7ca6513..5efae98 100644 --- a/classesphp/classe_mapa.php +++ b/classesphp/classe_mapa.php @@ -939,7 +939,9 @@ Endereço do WMS $this->mapa->setmetadata("wms_srs","EPSG:4291"); foreach ($this->layers as $layer) { - $layer->setmetadata("wms_title",pegaNome($layer)); + $n = pegaNome($layer); + $layer->setmetadata("wms_title",$n); + $layer->setmetadata("wms_name",$n); $layer->setmetadata("wms_srs","EPSG:4291 EPSG:4326"); $layer->setmetadata("WMS_INCLUDE_ITEMS","all"); $layer->set("status","ON"); diff --git a/classesphp/wmswfs.php b/classesphp/wmswfs.php index 96b32f4..692942e 100644 --- a/classesphp/wmswfs.php +++ b/classesphp/wmswfs.php @@ -234,6 +234,7 @@ function temaswms() # ------------------------------------------------------------- # Test that the capabilites file has successfully downloaded. # + //$wms_service_request = "c://temp//teste.xml"; if( !($wms_capabilities = file($wms_service_request)) ) { # Cannot download the capabilities file. $cp->set_data("Erro de acesso"); @@ -251,15 +252,121 @@ function temaswms() {$n = $e->getAttribute("SupportSLD");} $suporta = "nao"; if ($n == 1){$suporta = "sim";} - - $query = '//WMT_MS_Capabilities/Capability/Layer/Layer/Style'; - $entries = $xpath->query($query); - $nums = $entries->length; - if ($entries->length > 0) + $xpath = new DOMXPath($dom); + $q = '//WMT_MS_Capabilities/Capability'; + $query = $q.'/Layer'; + $layers = $xpath->query($query); + $retorna = array(); + foreach ($layers as $layer) + { + $r = pegaTag($layer); + $retorna = imprimeTag($r,$retorna); + $query = $q.'/Layer/Layer'; + $layers1 = $xpath->query($query); + foreach ($layers1 as $layer1) + { + $r1 = pegaTag($layer1); + $camada1 = $r1["nome"]; + $titulocamada1 = $r1["titulo"]; + $retorna = imprimeTag($r1,$retorna); + if($r1["estilos"]) + {$retorna = imprimeEstilos($r1["estilos"],$suporta,$retorna,$camada1,$titulocamada1);} + else + {$retorna[] = " default".$titulocamada1."
";} + + $query = $q.'/Layer/Layer/Layer'; + $layers2 = $xpath->query($query); + foreach ($layers2 as $layer2) + { + $r2 = pegaTag($layer2); + $camada2 = $r2["nome"]; + $titulocamada2 = $r2["titulo"]; + $retorna = imprimeTag($r2,$retorna); + if($r2["estilos"]) + {$retorna = imprimeEstilos($r2["estilos"],$suporta,$retorna,$camada2,$titulocamada2);} + else + {$retorna[] = " default ".$titulocamada2."
";} + + } + } + + } + $retorna[] = "
Proj.:
"; + $retorna[] = "
Formatos imagem:

"; + $retorna[] = "
Formatos info:

"; + $retorna[] = "
Versao:

"; + $retorna[] = "
Suporta SLD:


"; + //echo "
";
+	//var_dump($retorna);
+	$cp->set_data(implode($retorna));
+}
+function imprimeEstilos($es,$suporta,$retorna,$tval,$tituloalternativo)
+{
+	foreach($es as $e)
 	{
-	 	 $query = '//WMT_MS_Capabilities/Capability/Layer';
-		 $entries = $xpath->query($query);	 	 
+		//$tval = $e["titulo"];
+		$nomeestilo = $e["nome"];
+		$nomecamada = $e["titulo"];
+		//if($nomecamada == "default" || $nomecamada == "")
+		//{$nomecamada = $tituloalternativo;}
+		$tituloestilo = $e["titulo"];
+		$retorna[] = "" . $nomeestilo." ".$tituloestilo."
"; } + return $retorna; +} +function imprimeTag($r,$retorna) +{ + if(!$r["nome"]) + {$retorna[] = "
".$r["titulo"]."
";} + else + { + $retorna[] = "
"; + $retorna[] = "
".$r["nome"]."
"; + $retorna[] = "
".$r["titulo"]."
"; + $retorna[] = "
".$r["resumo"]."
"; + } + return $retorna; +} +function pegaTag($layer) +{ + $noslayer = $layer->childNodes; + $resultado = array(); + for ($i = 0; $i < $noslayer->length; $i++) + { + $tnome = $noslayer->item($i)->tagName; + $tvalor = $noslayer->item($i)->nodeValue; + //$tvalor = mb_convert_encoding($tvalor,"AUTO","AUTO"); + if($tnome) + { + if ($tnome == "Title") + {$resultado["titulo"] = $tvalor;} + if ($tnome == "Name") + {$resultado["nome"] = $tvalor;} + if ($tnome == "Abstract") + {$resultado["resumo"] = $tvalor;} + if ($tnome == "Style") + { + $ss = $noslayer->item($i)->childNodes; + for ($s = 0; $s < $ss->length; $s++) + { + $snome = $ss->item($s)->tagName; + $svalor = $ss->item($s)->nodeValue; + if($snome) + { + if ($snome == "Title") + {$t=$svalor;} + if ($snome == "Name") + {$n=$svalor;} + } + } + $resultado["estilos"][] = array("nome"=>$n,"titulo"=>$t); + } + $resultado["tags"][] = $tnome; + } + } + return $resultado; + + /* $tval = ""; foreach ($layers as $layer) { @@ -268,8 +375,8 @@ function temaswms() { $tnome = $noslayer->item($i)->tagName; $tvalor = $noslayer->item($i)->nodeValue; - if ($tnome == "Title") - {$retorna[] = "Titulo da camada: ".$tvalor."

Sub-camadas:

";} + + if ($tnome == "Layer") { $retorna[] = "
"; @@ -278,6 +385,7 @@ function temaswms() { $tnome = $sublayers->item($j)->tagName; $tvalor = $sublayers->item($j)->nodeValue; + if ($tnome != "Style") { $ns = ""; @@ -322,14 +430,11 @@ function temaswms() } } } - $retorna[] = "
Proj.:
"; - $retorna[] = "
Formatos imagem:

"; - $retorna[] = "
Formatos info:

"; - $retorna[] = "
Versao:

"; - $retorna[] = "
Suporta SLD:


"; - $cp->set_data(implode($retorna)); + */ + } + /* function: temaswfs -- libgit2 0.21.2