From 77ce98cee7330954dce2a059713a0a30d719f170 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Tue, 9 Mar 2010 12:56:24 +0000 Subject: [PATCH] --- ferramentas/metar/index.js.php | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ferramentas/metar/metarextensao.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ferramentas/metar/metarproxima.php | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ imagens/metar.png | Bin 0 -> 1399 bytes 4 files changed, 407 insertions(+), 0 deletions(-) create mode 100644 ferramentas/metar/index.js.php create mode 100644 ferramentas/metar/metarextensao.php create mode 100644 ferramentas/metar/metarproxima.php create mode 100644 imagens/metar.png diff --git a/ferramentas/metar/index.js.php b/ferramentas/metar/index.js.php new file mode 100644 index 0000000..9d8ce7f --- /dev/null +++ b/ferramentas/metar/index.js.php @@ -0,0 +1,200 @@ + +/*jslint plusplus:false,white:false,undef: false, rhino: true, onevar: true, evil: true */ +/* +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. +*/ +if(typeof(i3GEOF) === 'undefined'){ + i3GEOF = []; +} +/* +Class: i3GEOF.metar + +Busca as estações meteorológicas da rede METAR na extensão geográfica do mapa atual. +*/ +i3GEOF.metar = { + /* + Variavel: aguarde + + Estilo do objeto DOM com a imagem de aguarde existente no cabeçalho da janela. + */ + aguarde: "", + /* + Function: inicia + + Inicia a ferramenta. É chamado por criaJanelaFlutuante + + Parametro: + + iddiv {String} - id do div que receberá o conteudo HTML da ferramenta + */ + inicia: function(iddiv){ + try{ + $i(iddiv).innerHTML += i3GEOF.metar.html(); + i3GEOF.metar.ativaFoco(); + if(i3GEO.Interface.ATUAL === "padrao"){ + i3GEO.eventos.NAVEGAMAPA.push("i3GEOF.metar.lista()"); + } + if(i3GEO.Interface.ATUAL === "googlemaps"){ + metarDragend = GEvent.addListener(i3GeoMap, "dragend", function() {i3GEOF.metar.lista();}); + metarZoomend = GEvent.addListener(i3GeoMap, "zoomend", function() {i3GEOF.metar.lista();}); + } + if(i3GEO.Interface.ATUAL === "openlayers"){ + i3geoOL.events.register("moveend",i3geoOL,function(e){i3GEOF.metar.lista();}); + } + i3GEOF.metar.lista(); + } + catch(erro){alert(erro);} + }, + /* + Function: html + + Gera o código html para apresentação das opções da ferramenta + + Retorno: + + String com o código html + */ + html:function(){ + var ins = ''; + ins += '
'; + return ins; + }, + /* + Function: criaJanelaFlutuante + + Cria a janela flutuante para controle da ferramenta. + */ + criaJanelaFlutuante: function(){ + var minimiza,cabecalho,janela,divid,temp,titulo; + //funcao que sera executada ao ser clicado no cabeçalho da janela + cabecalho = function(){ + i3GEOF.metar.ativaFoco(); + }; + minimiza = function(){ + i3GEO.janela.minimiza("i3GEOF.metar"); + }; + //cria a janela flutuante + titulo = "Metar    "; + janela = i3GEO.janela.cria( + "250px", + "190px", + "", + "", + "", + titulo, + "i3GEOF.metar", + false, + "hd", + cabecalho, + minimiza + ); + divid = janela[2].id; + i3GEOF.metar.aguarde = $i("i3GEOF.metar_imagemCabecalho").style; + i3GEOF.metar.inicia(divid); + temp = function(){ + if(i3GEO.Interface.ATUAL === "padrao"){ + i3GEO.eventos.NAVEGAMAPA.remove("i3GEOF.metar.lista()"); + } + if(i3GEO.Interface.ATUAL === "googlemaps"){ + GEvent.removeListener(metarDragend); + GEvent.removeListener(metarZoomend); + } + }; + YAHOO.util.Event.addListener(janela[0].close, "click", temp); + }, + /* + Function: ativaFoco + + Refaz a interface da ferramenta quando a janela flutuante tem seu foco ativado + */ + ativaFoco: function(){ + g_operacao = "navega"; + var i = $i("i3GEOF.metar_c").style; + i3GEO.janela.ULTIMOZINDEX++; + i.zIndex = 10000 + i3GEO.janela.ULTIMOZINDEX; + }, + /* + Function: lista + + Lista as estações + */ + lista: function(){ + $i("i3GEOmetarLista").innerHTML = ""; + if(i3GEOF.metar.aguarde.visibility === "visible") + {return;} + i3GEOF.metar.aguarde.visibility = "visible"; + var montaResultado = { + success:function(o){ + var ins,dados,ndados,i,temp,temp1; + i3GEOF.metar.aguarde.visibility = "hidden"; + dados = YAHOO.lang.JSON.parse(o.responseText)[0].weatherObservations; + ndados = dados.length; + ins = "

Navegue no mapa para atualizar a lista de resultados (são mostradas apenas as 10 primeiras estações encontradas)

"; + ins += ""; + for(i=0;i" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + } + $i("i3GEOmetarLista").innerHTML = ins+"
long: " + dados[i].lng + ", lat: "+dados[i].lat+"
temperatura" + dados[i].temperature + " C
condição" + dados[i].weatherCondition + "
observação" + dados[i].observation + "
nuvens" + dados[i].clouds + "
direção do vento" + dados[i].windDirection + "
ponto de orvalho" + dados[i].dewPoint + " C
velocidade do vento" + dados[i].windSpeed + " mph
humidade" + dados[i].humidity + " %
data" + dados[i].datetime + "
pressão" + dados[i].hectoPascAltimeter +" hpa
ICAO" + dados[i].ICAO + "
"; + }, + failure: function(o){ + $i("i3GEOmetarLista").innerHTML = "Erro. A operação demorou muito."; + i3GEOF.metar.aguarde.visibility = "hidden"; + return; + }, + argument: { foo:"foo", bar:"bar" } + } + if(i3GEO.parametros.mapexten) + {ext = i3GEO.parametros.mapexten;} + else + {ext = "-49.1774741355 -16.379556709 -47.2737662565 -14.9806872512";} //apenas para exemplo + p = i3GEO.configura.locaplic+"/ferramentas/metar/metarextensao.php?ret="+ext; + var request = YAHOO.util.Connect.asyncRequest("GET", p, montaResultado); + }, + mostraxy: function(x,y){ + i3GEO.util.criaBox("boxpin"); + xy = i3GEO.calculo.dd2tela(x*1,y*1,$i(i3GEO.Interface.IDCORPO),i3GEO.parametros.mapexten,i3GEO.parametros.pixelsize); + var box = $i("boxpin"); + box.style.display = "block"; + box.style.width = "5px"; + box.style.height = "5px"; + box.style.top = parseInt(xy[1],10)-5+"px"; + box.style.left = parseInt(xy[0],10)-5+"px"; + box.style.position = "absolute"; + box.style.border = "solid 2px red" + box.style.zIndex = 5000 + } + +}; + \ No newline at end of file diff --git a/ferramentas/metar/metarextensao.php b/ferramentas/metar/metarextensao.php new file mode 100644 index 0000000..f7d1881 --- /dev/null +++ b/ferramentas/metar/metarextensao.php @@ -0,0 +1,52 @@ + \ No newline at end of file diff --git a/ferramentas/metar/metarproxima.php b/ferramentas/metar/metarproxima.php new file mode 100644 index 0000000..e5db9a5 --- /dev/null +++ b/ferramentas/metar/metarproxima.php @@ -0,0 +1,155 @@ +"; +require_once("../../classesphp/pega_variaveis.php"); +error_reporting(E_ALL); +$url = "http://ws.geonames.org/findNearByWeatherXML?lat=$y&lng=$x&lang=pt"; +$xml = simplexml_load_file($url); +$conta = 0; +$fim = array(); +$resultado = ""; +if($xml == true){ + $raiz = $xml->xpath('observation'); + foreach($raiz as $e){ + //var_dump($e); + $r = $e->xpath('observation'); + foreach($r as $t) + {$resultado .= "

".$t."";} + + $r = $e->xpath('observationTime'); + foreach($r as $t) + {$resultado .= "

Data: ".$t;} + + $r = $e->xpath('stationName'); + foreach($r as $t) + {$resultado .= "

Estação: ".$t;} + + $r = $e->xpath('ICAO'); + foreach($r as $t) + {$resultado .= "

ICAO: ".$t;} + + $r = $e->xpath('elevation'); + foreach($r as $t) + {$resultado .= "

Elevação: ".$t;} + + $r = $e->xpath('lat'); + $y = $r; + foreach($r as $t) + {$resultado .= "

Latitude: ".$t;} + $r = $e->xpath('lng'); + $x = $r; + foreach($r as $t) + {$resultado .= " Longitude: ".$t."";} + + $r = $e->xpath('temperature'); + foreach($r as $t) + {$resultado .= "

Temperatura: ".$t." C";} + + $r = $e->xpath('dewPoint'); + foreach($r as $t) + {$resultado .= "

Ponto de orvalho: ".$t." C";} + + $r = $e->xpath('humidity'); + foreach($r as $t) + {$resultado .= "

Humidade: ".$t." %";} + + $r = $e->xpath('clouds'); + foreach($r as $t) + {$resultado .= "

Nuvens: ".$t;} + + $r = $e->xpath('weatherCondition'); + foreach($r as $t) + {$resultado .= "

Condição: ".$t;} + + $r = $e->xpath('hectoPascAltimeter'); + foreach($r as $t) + {$resultado .= "

Pressão: ".$t." hpa";} + + $r = $e->xpath('windDirection'); + foreach($r as $t) + {$resultado .= "

Direção do vento: ".$t;} + + $r = $e->xpath('windSpeed'); + foreach($r as $t) + {$resultado .= "

Velocidade do vento: ".$t." mph
";} + + $resultado .= "

Web Service
"; + $resultado .= "
Metar
"; + } +} +if ($resultado == "") +{$resultado = "Nada encontrado


";} +else +echo $resultado; +?> + + \ No newline at end of file diff --git a/imagens/metar.png b/imagens/metar.png new file mode 100644 index 0000000..a98210e Binary files /dev/null and b/imagens/metar.png differ -- libgit2 0.21.2