From f77b5543c17874f17ba3f44aed775a451a57d724 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Thu, 3 Dec 2009 00:02:39 +0000 Subject: [PATCH] correção na acentuação dos xmls em KMZ e da árvore hiperbólica --- admin/hiperbolica.php | 15 +++++++++++++++ ferramentas/graficointerativo/exemplo.htm | 14 ++++++++++++++ ferramentas/graficointerativo/index.htm | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ferramentas/graficointerativo/index.js | 441 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ kml.php | 34 +++++++++++++++++++--------------- pacotes/kmlmapserver/classes/layerserver.class.php | 5 +++-- 6 files changed, 631 insertions(+), 17 deletions(-) create mode 100644 ferramentas/graficointerativo/exemplo.htm create mode 100644 ferramentas/graficointerativo/index.htm create mode 100644 ferramentas/graficointerativo/index.js diff --git a/admin/hiperbolica.php b/admin/hiperbolica.php index e2a5251..0d0dfa4 100644 --- a/admin/hiperbolica.php +++ b/admin/hiperbolica.php @@ -19,6 +19,7 @@ foreach ($menus as $menu) {continue;} $id = $menu["id_menu"]; $nome = html_entity_decode($menu["nome_menu"]); + $nome = h_converteTexto($nome); //menu $xml .= ' '."\n"; $grupos = pegaDados("select i3geoadmin_grupos.nome_grupo,id_n1,id_menu from i3geoadmin_n1 LEFT JOIN i3geoadmin_grupos ON i3geoadmin_n1.id_grupo = i3geoadmin_grupos.id_grupo where id_menu='$id' order by ordem",$locaplic); @@ -26,6 +27,7 @@ foreach ($menus as $menu) { $contador++; $nome = html_entity_decode($grupos[$i]["nome_grupo"]); + $nome = h_converteTexto($nome); $idgrupo = $grupos[$i]["id_n1"]; //grupo $xml .= ' '."\n"; @@ -37,6 +39,7 @@ foreach ($menus as $menu) { $contador++; $nome = html_entity_decode($subgrupos[$j]["nome_subgrupo"]); + $nome = h_converteTexto($nome); //subgrupo $xml .= ' '."\n"; $contador++; @@ -47,6 +50,7 @@ foreach ($menus as $menu) { $contador++; $nome = html_entity_decode($temas[$k]["nome_tema"]); + $nome = h_converteTexto($nome); $nid = "tema,".$temas[$k]["codigo_tema"]; if($nome != "") { @@ -62,6 +66,7 @@ foreach ($menus as $menu) { $contador++; $tag = html_entity_decode($tag); + $tag = h_converteTexto($tag); if($tag != "") $xml .= ' '."\n"; } @@ -79,6 +84,7 @@ for($i=0;$i < count($grupos);++$i) { $contador++; $nome = html_entity_decode($grupos[$i]["nome_grupo"]); + $nome = h_converteTexto($nome); $idgrupo = $grupos[$i]["id_n1"]; $xml .= ' '."\n"; $temastag = pegaDados("select d.tags_tema as tags,d.id_tema as tema from i3geoadmin_n2 as b,i3geoadmin_n1 as a,i3geoadmin_n3 as c,i3geoadmin_temas as d where a.id_grupo = '$idgrupo' and a.id_n1 = b.id_n1 and c.id_n2 = b.id_n2 and c.id_tema = d.id_tema group by tema,d.tags_tema",$locaplic); @@ -96,6 +102,7 @@ for($i=0;$i < count($grupos);++$i) foreach($arrayTag as $tag) { $tag = html_entity_decode($tag); + $tag = h_converteTexto($tag); $contador++; if($tag != "") $xml .= ' '."\n"; @@ -114,6 +121,7 @@ foreach ($tipos as $tipo) { $contador++; $nome = html_entity_decode($w["nome_ws"]); + $nome = h_converteTexto($nome); $link = str_replace("&","&",$w["link_ws"]); if($nome != "") $xml .= ' '."\n"; @@ -130,4 +138,11 @@ $xml .= ""; header("Content-type: application/xml"); echo $xml; + +function h_converteTexto($i) +{ + $encoding = mb_detect_encoding($i, 'UTF-8, UTF-7, ASCII, ISO-8859-1'); + return mb_convert_encoding($i,"UTF-8",$encoding); +} + ?> diff --git a/ferramentas/graficointerativo/exemplo.htm b/ferramentas/graficointerativo/exemplo.htm new file mode 100644 index 0000000..f5efca0 --- /dev/null +++ b/ferramentas/graficointerativo/exemplo.htm @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/ferramentas/graficointerativo/index.htm b/ferramentas/graficointerativo/index.htm new file mode 100644 index 0000000..a1c0bc4 --- /dev/null +++ b/ferramentas/graficointerativo/index.htm @@ -0,0 +1,139 @@ + + + + + + + + + + + +
+
+ selpt.png + selext.png + selbox.png + selpoli.png +
+ +
+ Escolha um ou mais temas: +
+
+
Tipo de seleção: +
+
+
+
+
+ +
+
+ Escolha o tema que receberá a seleção e o tipo de operação. + Depois, clique no mapa no elemento desejado para selecionar. +
+
+ + + +
+
+ Defina as colunas que comporão os eixos x e y do gráfico: + + + + + + + +
Eixo X (Classes)Eixo Y (Valores)
+
+
+
+ +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ferramentas/graficointerativo/index.js b/ferramentas/graficointerativo/index.js new file mode 100644 index 0000000..13a09b4 --- /dev/null +++ b/ferramentas/graficointerativo/index.js @@ -0,0 +1,441 @@ +/* +About: Licença + +I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet + +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil +Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br + +Este programa é software livre; você pode redistribuí-lo +e/ou modificá-lo sob os termos da Licença Pública Geral +GNU conforme publicada pela Free Software Foundation; +tanto a versão 2 da Licença. +Este programa é distribuído na expectativa de que seja útil, +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. +Consulte a Licença Pública Geral do GNU para mais detalhes. +Você deve ter recebido uma cópia da Licença Pública Geral do +GNU junto com este programa; se não, escreva para a +Free Software Foundation, Inc., no endereço +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. +*/ + +YAHOO.example.init = function () +{ + function onPushButtonsMarkupReady() + { + new YAHOO.widget.Button("botao1"); + new YAHOO.widget.Button("botao2"); + new YAHOO.widget.Button("botao3"); + new YAHOO.widget.Button("botao4"); + new YAHOO.widget.Button("botaoGr"); + } + YAHOO.util.Event.onContentReady("botao1", onPushButtonsMarkupReady); +}() + +//inicializa +mensagemAjuda("men1",$i("men1").innerHTML) +parametrosURL() +aguarde("block") +ativaGuias("") +mostraGuia("guia1") +comboi = "" +tema = "" +//eventos das guias +$i("guia1").onclick = function() +{mostraGuia("guia1");$i("opc1").style.display="block";$i("botoesopc").style.display="block";} +$i("guia2").onclick = function() +{ + mostraGuia("guia2"); + if ($i("comboTemas").value == "") + {alert("Escolha um tema");} + $i("opc1").style.display="block"; + $i("botoesopc").style.display="block"; +} +$i("guia3").onclick = function() +{ + mostraGuia("guia3") + comboTemasSel("comboOverlay",function(retorno) + { + $i("overlay").innerHTML = retorno.dados + },"overlay") + $i("opc1").style.display="block"; + $i("botoesopc").style.display="block"; +} +$i("guia4").onclick = function() +{ + mostraGuia("guia4") + $i("opc1").style.display="block"; + $i("botoesopc").style.display="block"; +} +$i("guia5").onclick = function() +{ + var temp = pegaTemasSel().split(",") + if(temp.length > 1) + {alert("Escolha apenas um tema!");return;} + mostraGuia("guia5") + $i("opc1").style.display="none"; + $i("botoesopc").style.display="none"; + if ($i("comboTemas").value == "") + {alert("Escolha um tema");} + else + { + if(!$i("itemX")) + { + comboitens("itemX",$i("comboTemas").value,function(retorno) + { + $i("lugarComboX").innerHTML = retorno.dados; + },"lugarComboX") + } + if(!$i("itemY")) + { + comboitens("itemY",$i("comboTemas").value,function(retorno) + { + $i("lugarComboY").innerHTML = retorno.dados; + },"lugarComboY") + } + if($i("itemX") && $i("itemY")) + {atualizaGrafico();} + } +} + +//combo com o tipo de operacao +var combot = "" +$i("operacao").innerHTML = combot + +function mudaicone() +{ + $i("selecaopt").style.border = "1px solid gray" + $i("selecaoext").style.border = "1px solid gray" + $i("selecaobox").style.border = "1px solid gray" + $i("selecaopoli").style.border = "1px solid gray" + if(window.parent.richdraw) + window.parent.richdraw.fecha() + if(window.parent.$i("img")) + window.parent.$i("img").style.cursor="pointer"; +} +//pega os temas selecionados +function pegaTemasSel() +{ + var selObj = $i("comboTemas"); + var selectedArray = new Array(); + for (i=0; i 500000) + {alert("A escala do mapa deve ser pelo menos 1:500.000");return;} + aguarde("block") + var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=selecaoext&tema="+pegaTemasSel()+"&tipo="+$i("tipoOperacao").value + var cp = new cpaint(); + //cp.set_debug(2) + cp.set_response_type("JSON"); + cp.call(p,"selecaoEXT",fim); + } + if (obj.id == "selecaobox") + { + mudaicone() + obj.style.border = "1px solid white"; + window.parent.g_tipoacao = "selecaobox"; + window.parent.i3GEO.selecao.box.criaBox(); + if(window.parent.i3GEO.eventos.MOUSEDOWN.toString().search("i3GEO.selecao.box.inicia()") < 0) + {window.parent.i3GEO.eventos.MOUSEDOWN.push("i3GEO.selecao.box.inicia()");} + } + if (obj.id == "selecaopt") + { + mudaicone() + obj.style.border = "1px solid white" + window.parent.g_tipoacao = "selecao"; + if(window.parent.i3GEO.eventos.MOUSECLIQUE.toString().search("i3GEO.selecao.clique()") < 0) + {window.parent.i3GEO.eventos.MOUSECLIQUE.push("i3GEO.selecao.clique()");} + } + if (obj.id == "selecaopoli") + { + var temp = pegaTemasSel().split(",") + if(temp.length > 1) + {alert("Escolha apenas um tema!");return;} + mudaicone() + obj.style.border = "1px solid white" + window.parent.g_tipoacao = "selecaopoli"; + window.parent.i3GEO.selecao.poligono.inicia() + } +} + +//cria combo com os temas + +comboTemasLigados("comboTemas",function(retorno) +{ + $i("temas").innerHTML = retorno.dados + aguarde("none") + $i("comboTemas").onchange = function() + { + $i("lugarComboX").innerHTML = ""; + $i("lugarComboY").innerHTML = ""; + window.parent.i3GEO.mapa.ativaTema(pegaTemasSel()); + comboitens("selItem",$i("comboTemas").value,function(retorno) + { + comboi = retorno.dados + var p = $i("parametros") + for (i = 0; i < p.childNodes.length;i++) + {p.removeChild(p.childNodes[i])} + adicionalinha() + }) + if ($i("comboTemas").value != "") + {$i("opc3").style.display="block"} + else + { + alert("Selecione um tema"); + $i("opc3").style.display="block" + } + } +},"temas","",true) + +//adiciona uma linha de parametros +function adicionalinha() +{ + var comboitens = comboi + //interrogacao abre a lista de valores + var interrogacao = document.createElement("img") + interrogacao.src = '../../imagens/interrogacao.gif' + interrogacao.title='lista' + interrogacao.style.cursor="pointer" + interrogacao.onclick = function() + { + var itemTema = (this.parentNode.parentNode.getElementsByTagName("select"))[0].value + if (itemTema == "") + { + alert("Selecione um campo") + return + } + aguarde("block") + valoresItem + ( + $i("comboTemas").value, + itemTema, + function(retorno) + { + aguarde("none") + $i("valores").innerHTML = "
Valores:
"+retorno.dados + } + ,"valores" + ) + } + var operador = "" + var valor = document.createElement("input") + valor.type = "text" + valor.value = "" + valor.size = "20" + var ntb = document.createElement("tbody") + var ntr = document.createElement("tr") + ntb.appendChild(ntr) + var ntd1 = document.createElement("td") + ntd1.innerHTML = comboi + ntr.appendChild(ntd1) + var ntd2 = document.createElement("td") + ntd2.innerHTML = operador + ntr.appendChild(ntd2) + var ntd3 = document.createElement("td") + ntd3.appendChild(valor) + ntr.appendChild(ntd3) + var ntd4 = document.createElement("td") + ntd4.appendChild(interrogacao) + ntr.appendChild(ntd4) + tabela = $i("parametros") + tabela.appendChild(ntb) +} +//executa o tipo de operacao selecionada se for o caso +function operacao(tipo) +{ + if ($i("comboTemas").value == ""){alert("Escolha um tema");return;} + if((tipo.value == "limpa") || (tipo.value == "inverte")) + { + aguarde("block") + var fim = function() + {aguarde("none");window.parent.i3GEO.atualiza("")} + var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=selecaopt&tema="+pegaTemasSel()+"&tipo="+tipo.value+"&tolerancia="+$i("toleranciapt").value + var cp = new cpaint(); + //cp.set_debug(2) + cp.set_response_type("JSON"); + window.parent.g_operacao = "selecao" + cp.call(p,"selecaoPT",fim); + } +} +//aplica a selecao por atributo +function aplicaselecao() +{ + var temp = pegaTemasSel().split(",") + if(temp.length > 1) + {alert("Escolha apenas um tema!");return;} + if ($i("comboTemas").value == ""){alert("Escolha um tema");return;} + aguarde("block") + var g = $i("parametros") + var ipt = g.getElementsByTagName("tr") + if (ipt.length > 0) + { + var filtro = "" + for (i=0;i 1) + {alert("Escolha apenas um tema!");return;} + if ($i("comboTemas").value == "") + {alert("Escolha um tema!");} + else + { + aguarde("block") + var fim = function() + {aguarde("none");window.parent.i3GEO.atualiza("")} + var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=criatemasel&tema="+$i("comboTemas").value+"&nome=Novo tema "+$i("comboTemas").value + var cp = new cpaint(); + //cp.set_debug(2) + cp.set_response_type("JSON"); + cp.call(p,"selecao2tema",fim); + } +} +function concluidof() +{ + window.parent.remapaf() + aguarde("none") +} +function concluipoligono() +{ + $i("parapoli").style.display = "none"; + tiposel($i("selecaopt")) + var pontos = window.parent.pontosdistobj; + window.parent.richdraw.fecha() + var n = pontos.xpt.length; + if (n > 2) + { + aguarde("block") + var xs = pontos.xpt.toString(",") + var ys = pontos.ypt.toString(",") + var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=selecaoPoli" + var cp = new cpaint(); + //cp.set_debug(2) + cp.set_transfer_mode('POST'); + cp.set_response_type("JSON"); + cp.call(p,"selecaoPoli",concluidof,xs,ys,pegaTemasSel(),$i("tipoOperacao").value); + } + else + {alert("Sao necessarios pelo menos tres pontos");} +} +function atualizaGrafico() +{ + $i("lugarGrafico").innerHTML = "" + var monta = function(retorno) + { + var dados = retorno.data.dados; + var values = new Array(); + var labels = new Array(); + for (i=1;iGRUPO as $grupo) { - $nome = mb_convert_encoding($grupo->GTIPO,"auto","auto"); - $desc = mb_convert_encoding($grupo->DTIPO,"auto","auto"); + $nome = kml_converteTexto($grupo->GTIPO); + $desc = kml_converteTexto($grupo->DTIPO); kml_cabecalho($nome,$desc); foreach($grupo->TEMA as $tema) {kml_tema($tema);} foreach($grupo->SGRUPO as $sgrupo) { - $nome = mb_convert_encoding($sgrupo->SDTIPO,"auto","auto"); + $nome = kml_converteTexto($sgrupo->SDTIPO); kml_folder($nome); foreach($sgrupo->TEMA as $tema) {kml_tema($tema);} @@ -193,30 +193,30 @@ function kml_tema_bd($tema) function kml_cabecalho($nome,$desc) { echo "\n"; - echo " ".str_replace("&","&",$nome)."\n"; - echo " ".str_replace("&","&",$desc)."\n"; + echo " ".str_replace("&","&",kml_converteTexto($nome))."\n"; + echo " ".str_replace("&","&",kml_converteTexto($desc))."\n"; echo " 00\n"; } function kml_folder($nome) { echo " \n"; - echo " ".str_replace("&","&",$nome)."\n"; + echo " ".str_replace("&","&",kml_converteTexto($nome))."\n"; echo " \n"; echo " 00\n"; } function kml_tema($tema) { global $urli3geo; - $nome = mb_convert_encoding($tema->TNOME,"auto","auto"); - $desc = mb_convert_encoding($tema->TDESC,"auto","auto"); - $id = mb_convert_encoding($tema->TID,"auto","auto"); - $fonte = mb_convert_encoding($tema->TLINK,"auto","auto"); + $nome = kml_converteTexto($tema->TNOME); + $desc = kml_converteTexto($tema->TDESC); + $id = kml_converteTexto($tema->TID); + $fonte = kml_converteTexto($tema->TLINK); $tipoa = ""; if($tema->TIPOA) - $tipoa = mb_convert_encoding($tema->TIPOA,"auto","auto"); + $tipoa = kml_converteTexto($tema->TIPOA); $ogc = sim; if($tema->TID) - {$kml = mb_convert_encoding($tema->KML,"auto","auto");} + {$kml = kml_converteTexto($tema->KML);} if(strtolower($kml) != "nao" && strtolower($tipoa) != "wms") { if($fonte != "") @@ -232,7 +232,7 @@ function kml_tema($tema) function kml_servico($nome,$fonte,$legenda,$desc,$href) { echo " \n"; - echo " ".str_replace("&","&",$nome)."\n"; + echo " ".str_replace("&","&",kml_converteTexto($nome))."\n"; echo " \n"; echo " 0\n"; echo " \n"; @@ -245,7 +245,7 @@ function kml_servico($nome,$fonte,$legenda,$desc,$href) function kml_networklink($nome,$fonte,$legenda,$desc,$href) { echo " \n"; - echo " ".str_replace("&","&",$nome)."\n"; + echo " ".str_replace("&","&",kml_converteTexto($nome))."\n"; echo " \n"; echo " 0\n"; echo " \n"; @@ -254,5 +254,9 @@ function kml_networklink($nome,$fonte,$legenda,$desc,$href) echo " \n"; echo " \n"; } - +function kml_converteTexto($i) +{ + $encoding = mb_detect_encoding($i, 'UTF-8, UTF-7, ASCII, ISO-8859-1'); + return mb_convert_encoding($i,"UTF-8",$encoding); +} ?> \ No newline at end of file diff --git a/pacotes/kmlmapserver/classes/layerserver.class.php b/pacotes/kmlmapserver/classes/layerserver.class.php index 6d675ed..ad6d24a 100644 --- a/pacotes/kmlmapserver/classes/layerserver.class.php +++ b/pacotes/kmlmapserver/classes/layerserver.class.php @@ -448,8 +448,9 @@ class LayerServer { */ function &add_feature(&$folder, &$wkt, $featurename, $attributes, $description_template, $style_data,$itens,$itensdesc){ $pm = $folder->addChild('Placemark'); - $pm->addChild('name',mb_convert_encoding($featurename,"UTF-8",mb_detect_encoding($featurename,"UTF-8, ISO-8859-1"))); - $pm->addChild('description', $this->get_feature_description($featurename, $attributes, $description_template,$itens,$itensdesc)); + $fname = mb_convert_encoding($featurename,"UTF-8",mb_detect_encoding($featurename,'UTF-8, UTF-7, ASCII, ISO-8859-1')); + $pm->addChild('name',$fname); + $pm->addChild('description', $this->get_feature_description($fname, $attributes, $description_template,$itens,$itensdesc)); // Now parse the wkt if(strpos($wkt, 'MULTILINESTRING') !== false){ $this->add_multilinestring($wkt, $pm, $featurename, $style_data['icon']); -- libgit2 0.21.2