From 824c374e13c37e2b556bce5ca31baa98a308a0bb Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Mon, 4 Jul 2011 15:38:42 +0000 Subject: [PATCH] Complementação da função de obtenção das colunas de atributos de um tema permitindo o uso de WMS --- admin/admin.db | Bin 71680 -> 0 bytes classesphp/classe_atributos.php | 2 +- classesphp/classe_legenda.php | 44 +++++++++++++++++++++++++++++++++++++++++--- classesphp/funcoes_gerais.php | 48 +++++++++++++++++++++++++++++++++++++----------- ferramentas/legenda/index.js.php | 2 +- 5 files changed, 80 insertions(+), 16 deletions(-) diff --git a/admin/admin.db b/admin/admin.db index 076f268..5edc9fd 100644 Binary files a/admin/admin.db and b/admin/admin.db differ diff --git a/classesphp/classe_atributos.php b/classesphp/classe_atributos.php index 8eac52f..66ce83e 100644 --- a/classesphp/classe_atributos.php +++ b/classesphp/classe_atributos.php @@ -218,7 +218,7 @@ Lista os itens de um tema. //pega o nome correto do tema $nometmp = pegaNome($layer,"UTF-8"); $nomestemas[] = $nometmp; - if ($layer->data != "") + if($layer->data != "" || $layer->connectiontype == 7) { $items = pegaItens($layer,$this->mapa); foreach ($items as $item) diff --git a/classesphp/classe_legenda.php b/classesphp/classe_legenda.php index 5fa6521..78ceff9 100644 --- a/classesphp/classe_legenda.php +++ b/classesphp/classe_legenda.php @@ -164,7 +164,30 @@ Salva o mapfile atual function salva() { if (connection_aborted()){exit();} - $this->mapa->save($this->arquivo); + $this->recalculaSLD(); + $this->mapa->save($this->arquivo); + } +/* +function: recalculaSLD + +Constrói o SLD que é aplicado ao metadata wms_sld_body. O SLD resultante é baseado nas definições das classes existentes no layer +*/ + function recalculaSLD(){ + if($this->layer->classitem != "" && $this->layer->connectiontype == 7 && $this->layer->numclasses > 0){ + $tipotemp = $this->layer->type; + $tiporep = $this->layer->getmetadata("tipooriginal"); + $this->layer->set("type",MS_LAYER_POLYGON); + if ($tiporep == "linear") + {$this->layer->set("type",MS_LAYER_LINE);} + if ($tiporep == "pontual") + {$this->layer->set("type",MS_LAYER_POINT);} + $this->layer->set("status",MS_DEFAULT); + $this->layer->setmetadata("wms_sld_body",""); + $sld = $this->layer->generateSLD(); + if($sld != "") + {$this->layer->setmetadata("wms_sld_body",str_replace('"',"'",$sld));} + $this->layer->set("type",$tipotemp); + } } /* @@ -284,7 +307,23 @@ array $c = $layer->connectiontype; $s = $layer->getmetadata("wms_sld_url"); $im = $layer->getmetadata("legendaimg"); - if ($c == 7 || $im != "") + $nc = $layer->numclasses; + // + //se for wms e tiver classes define o tipo de layer para poder gerar a legenda corretamente + // + if($c == 7 && $nc > 0){ + $tipotemp = $layer->type; + $tiporep = $layer->getmetadata("tipooriginal"); + $layer->set("type",MS_LAYER_POLYGON); + if($tiporep == "linear") + {$layer->set("type",MS_LAYER_LINE);} + if ($tiporep == "pontual") + {$layer->set("type",MS_LAYER_POINT);} + } + // + //se for WMS e não tiver classes, tenta pegar a legenda via requisição WMS + // + if ($nc == 0 && ($c == 7 || $im != "")) { if($c == 7){ $con = $layer->connection; @@ -303,7 +342,6 @@ array } else { - $nc = $layer->numclasses; for ($c = 0;$c < $nc;$c++) { $classe = $layer->getclass($c); diff --git a/classesphp/funcoes_gerais.php b/classesphp/funcoes_gerais.php index 9d1e3bb..ebbd649 100644 --- a/classesphp/funcoes_gerais.php +++ b/classesphp/funcoes_gerais.php @@ -1345,17 +1345,43 @@ Retorno: */ function pegaItens($layer,$mapa="") { - if($layer->type == MS_LAYER_RASTER && $mapa != ""){ - $pt = ms_newPointObj(); - $pt->setXY($mapa->extent->minx,$mapa->extent->miny); - $layer->queryByPoint($pt,0,0); - } - $sopen = $layer->open(); - if($sopen != MS_FAILURE) - {$items = $layer->getItems();} - else - {$items = array();} - $layer->close(); + // + //no caso de WMS ou WFS + // + + if($layer->connectiontype == 7){ + $url = $layer->connection; + $temp = explode("?",$url); + if(count($temp) == 1) + {$url .= "?";} + $url = $url."&SERVICE=wfs&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=".$layer->getmetadata("wms_name"); + //$url = "http://ogi.state.ok.us/geoserver/wfs?VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=okcounties"; + $xml = simplexml_load_file($url); + $dom = new DOMDocument(); + $dom->loadXML($xml->asxml()); + $items = array(); + $sequences = $dom->getElementsByTagName("sequence"); + + foreach ($sequences as $sq){ + $services = $sq->getElementsByTagName("element"); + foreach ($services as $s){ + $items[] = $s->getAttribute("name"); + } + } + } + else{ + if($layer->type == MS_LAYER_RASTER && $mapa != ""){ + $pt = ms_newPointObj(); + $pt->setXY($mapa->extent->minx,$mapa->extent->miny); + $layer->queryByPoint($pt,0,0); + } + $sopen = $layer->open(); + if($sopen != MS_FAILURE) + {$items = $layer->getItems();} + else + {$items = array();} + $layer->close(); + } return $items; } /* diff --git a/ferramentas/legenda/index.js.php b/ferramentas/legenda/index.js.php index 5940fbf..116fe58 100644 --- a/ferramentas/legenda/index.js.php +++ b/ferramentas/legenda/index.js.php @@ -447,7 +447,7 @@ i3GEOF.legenda = { {$i("i3GEOlegendaresultado").innerHTML = "

Ocorreu um erro
";} i3GEOF.legenda.aguarde.visibility = "hidden"; } - catch(e){alert("Erro: "+ e);i3GEOF.legenda.aguarde.visibility = "hidden";} + catch(e){alert("Não é possível editar a legenda desse tema");i3GEOF.legenda.aguarde.visibility = "hidden";} }, aplicaColourRamp: function(){ if($i("listaColourRamp").value != ""){ -- libgit2 0.21.2