Commit 77ce98cee7330954dce2a059713a0a30d719f170

Authored by Edmar Moretti
1 parent 242aa971

--no commit message

ferramentas/metar/index.js.php 0 → 100644
... ... @@ -0,0 +1,200 @@
  1 +<?php error_reporting(0);if(extension_loaded('zlib')){ob_start('ob_gzhandler');} header("Content-type: text/javascript"); ?>
  2 +/*jslint plusplus:false,white:false,undef: false, rhino: true, onevar: true, evil: true */
  3 +/*
  4 +About: Licença
  5 +
  6 +I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
  7 +
  8 +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil
  9 +Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br
  10 +
  11 +Este programa é software livre; você pode redistribuí-lo
  12 +e/ou modificá-lo sob os termos da Licença Pública Geral
  13 +GNU conforme publicada pela Free Software Foundation;
  14 +tanto a versão 2 da Licença.
  15 +Este programa é distribuído na expectativa de que seja útil,
  16 +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita
  17 +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA.
  18 +Consulte a Licença Pública Geral do GNU para mais detalhes.
  19 +Você deve ter recebido uma cópia da Licença Pública Geral do
  20 +GNU junto com este programa; se não, escreva para a
  21 +Free Software Foundation, Inc., no endereço
  22 +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  23 +*/
  24 +if(typeof(i3GEOF) === 'undefined'){
  25 + i3GEOF = [];
  26 +}
  27 +/*
  28 +Class: i3GEOF.metar
  29 +
  30 +Busca as estações meteorológicas da rede METAR na extensão geográfica do mapa atual.
  31 +*/
  32 +i3GEOF.metar = {
  33 + /*
  34 + Variavel: aguarde
  35 +
  36 + Estilo do objeto DOM com a imagem de aguarde existente no cabeçalho da janela.
  37 + */
  38 + aguarde: "",
  39 + /*
  40 + Function: inicia
  41 +
  42 + Inicia a ferramenta. É chamado por criaJanelaFlutuante
  43 +
  44 + Parametro:
  45 +
  46 + iddiv {String} - id do div que receberá o conteudo HTML da ferramenta
  47 + */
  48 + inicia: function(iddiv){
  49 + try{
  50 + $i(iddiv).innerHTML += i3GEOF.metar.html();
  51 + i3GEOF.metar.ativaFoco();
  52 + if(i3GEO.Interface.ATUAL === "padrao"){
  53 + i3GEO.eventos.NAVEGAMAPA.push("i3GEOF.metar.lista()");
  54 + }
  55 + if(i3GEO.Interface.ATUAL === "googlemaps"){
  56 + metarDragend = GEvent.addListener(i3GeoMap, "dragend", function() {i3GEOF.metar.lista();});
  57 + metarZoomend = GEvent.addListener(i3GeoMap, "zoomend", function() {i3GEOF.metar.lista();});
  58 + }
  59 + if(i3GEO.Interface.ATUAL === "openlayers"){
  60 + i3geoOL.events.register("moveend",i3geoOL,function(e){i3GEOF.metar.lista();});
  61 + }
  62 + i3GEOF.metar.lista();
  63 + }
  64 + catch(erro){alert(erro);}
  65 + },
  66 + /*
  67 + Function: html
  68 +
  69 + Gera o código html para apresentação das opções da ferramenta
  70 +
  71 + Retorno:
  72 +
  73 + String com o código html
  74 + */
  75 + html:function(){
  76 + var ins = '';
  77 + ins += '<div id=i3GEOmetarLista style=display:block;background-color:white;text-align:left; ></div>';
  78 + return ins;
  79 + },
  80 + /*
  81 + Function: criaJanelaFlutuante
  82 +
  83 + Cria a janela flutuante para controle da ferramenta.
  84 + */
  85 + criaJanelaFlutuante: function(){
  86 + var minimiza,cabecalho,janela,divid,temp,titulo;
  87 + //funcao que sera executada ao ser clicado no cabeçalho da janela
  88 + cabecalho = function(){
  89 + i3GEOF.metar.ativaFoco();
  90 + };
  91 + minimiza = function(){
  92 + i3GEO.janela.minimiza("i3GEOF.metar");
  93 + };
  94 + //cria a janela flutuante
  95 + titulo = "Metar <a class=ajuda_usuario target=_blank href='" + i3GEO.configura.locaplic + "/ajuda_usuario.php?idcategoria=8&idajuda=87' >&nbsp;&nbsp;&nbsp;</a>";
  96 + janela = i3GEO.janela.cria(
  97 + "250px",
  98 + "190px",
  99 + "",
  100 + "",
  101 + "",
  102 + titulo,
  103 + "i3GEOF.metar",
  104 + false,
  105 + "hd",
  106 + cabecalho,
  107 + minimiza
  108 + );
  109 + divid = janela[2].id;
  110 + i3GEOF.metar.aguarde = $i("i3GEOF.metar_imagemCabecalho").style;
  111 + i3GEOF.metar.inicia(divid);
  112 + temp = function(){
  113 + if(i3GEO.Interface.ATUAL === "padrao"){
  114 + i3GEO.eventos.NAVEGAMAPA.remove("i3GEOF.metar.lista()");
  115 + }
  116 + if(i3GEO.Interface.ATUAL === "googlemaps"){
  117 + GEvent.removeListener(metarDragend);
  118 + GEvent.removeListener(metarZoomend);
  119 + }
  120 + };
  121 + YAHOO.util.Event.addListener(janela[0].close, "click", temp);
  122 + },
  123 + /*
  124 + Function: ativaFoco
  125 +
  126 + Refaz a interface da ferramenta quando a janela flutuante tem seu foco ativado
  127 + */
  128 + ativaFoco: function(){
  129 + g_operacao = "navega";
  130 + var i = $i("i3GEOF.metar_c").style;
  131 + i3GEO.janela.ULTIMOZINDEX++;
  132 + i.zIndex = 10000 + i3GEO.janela.ULTIMOZINDEX;
  133 + },
  134 + /*
  135 + Function: lista
  136 +
  137 + Lista as estações
  138 + */
  139 + lista: function(){
  140 + $i("i3GEOmetarLista").innerHTML = "";
  141 + if(i3GEOF.metar.aguarde.visibility === "visible")
  142 + {return;}
  143 + i3GEOF.metar.aguarde.visibility = "visible";
  144 + var montaResultado = {
  145 + success:function(o){
  146 + var ins,dados,ndados,i,temp,temp1;
  147 + i3GEOF.metar.aguarde.visibility = "hidden";
  148 + dados = YAHOO.lang.JSON.parse(o.responseText)[0].weatherObservations;
  149 + ndados = dados.length;
  150 + ins = "<p class=paragrafo >Navegue no mapa para atualizar a lista de resultados (são mostradas apenas as 10 primeiras estações encontradas)</p>";
  151 + ins += "<table class=lista4 >";
  152 + for(i=0;i<ndados;i++){
  153 + temp = "i3GEOF.metar.mostraxy("+dados[i].lng+","+dados[i].lat+")";
  154 + temp1 = "i3GEO.navega.zoomponto(i3GEO.configura.locaplic,i3GEO.configura.sid,"+dados[i].lng+","+dados[i].lat+")";
  155 + ins += "<tr><td style=background:yellow ><b>Estação</b></td><td style=background:yellow ><b>" + dados[i].stationName + "</b></td></tr>" +
  156 + "<tr><td></td><td><a href='#' onclick='"+temp1+"' onmouseover='"+temp+"' onmouseout='i3GEO.util.escondeBox()' >long: " + dados[i].lng + ", lat: "+dados[i].lat+"</a></td></tr>" +
  157 + "<tr><td>temperatura</td><td>" + dados[i].temperature + " C</td></tr>" +
  158 + "<tr><td>condição</td><td>" + dados[i].weatherCondition + "</td></tr>" +
  159 + "<tr><td>observação</td><td>" + dados[i].observation + "</td></tr>" +
  160 + "<tr><td>nuvens</td><td>" + dados[i].clouds + "</td></tr>" +
  161 + "<tr><td>direção do vento</td><td>" + dados[i].windDirection + "</td></tr>" +
  162 + "<tr><td>ponto de orvalho</td><td>" + dados[i].dewPoint + " C</td></tr>" +
  163 + "<tr><td>velocidade do vento</td><td>" + dados[i].windSpeed + " mph</td></tr>" +
  164 + "<tr><td>humidade</td><td>" + dados[i].humidity + " %</td></tr>" +
  165 + "<tr><td>data</td><td>" + dados[i].datetime + "</td></tr>" +
  166 + "<tr><td>pressão</td><td>" + dados[i].hectoPascAltimeter +" hpa</td></tr>" +
  167 + "<tr><td>ICAO</td><td>" + dados[i].ICAO + "</td></tr>";
  168 + }
  169 + $i("i3GEOmetarLista").innerHTML = ins+"</table>";
  170 + },
  171 + failure: function(o){
  172 + $i("i3GEOmetarLista").innerHTML = "Erro. A operação demorou muito.";
  173 + i3GEOF.metar.aguarde.visibility = "hidden";
  174 + return;
  175 + },
  176 + argument: { foo:"foo", bar:"bar" }
  177 + }
  178 + if(i3GEO.parametros.mapexten)
  179 + {ext = i3GEO.parametros.mapexten;}
  180 + else
  181 + {ext = "-49.1774741355 -16.379556709 -47.2737662565 -14.9806872512";} //apenas para exemplo
  182 + p = i3GEO.configura.locaplic+"/ferramentas/metar/metarextensao.php?ret="+ext;
  183 + var request = YAHOO.util.Connect.asyncRequest("GET", p, montaResultado);
  184 + },
  185 + mostraxy: function(x,y){
  186 + i3GEO.util.criaBox("boxpin");
  187 + xy = i3GEO.calculo.dd2tela(x*1,y*1,$i(i3GEO.Interface.IDCORPO),i3GEO.parametros.mapexten,i3GEO.parametros.pixelsize);
  188 + var box = $i("boxpin");
  189 + box.style.display = "block";
  190 + box.style.width = "5px";
  191 + box.style.height = "5px";
  192 + box.style.top = parseInt(xy[1],10)-5+"px";
  193 + box.style.left = parseInt(xy[0],10)-5+"px";
  194 + box.style.position = "absolute";
  195 + box.style.border = "solid 2px red"
  196 + box.style.zIndex = 5000
  197 + }
  198 +
  199 +};
  200 +<?php error_reporting(0);if(extension_loaded('zlib')){ob_end_flush();}?>
0 201 \ No newline at end of file
... ...
ferramentas/metar/metarextensao.php 0 → 100644
... ... @@ -0,0 +1,52 @@
  1 +<?php
  2 +/*
  3 +Title: metarextensao
  4 +
  5 +Acessa o Web Service do Geonames que busca estações da rede Metar, retornando o resultado no formato HTML.
  6 +
  7 +Licenca:
  8 +
  9 +GPL2
  10 +
  11 +I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
  12 +
  13 +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil
  14 +Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br
  15 +
  16 +Este programa é software livre; você pode redistribuí-lo
  17 +e/ou modificá-lo sob os termos da Licença Pública Geral
  18 +GNU conforme publicada pela Free Software Foundation;
  19 +tanto a versão 2 da Licença.
  20 +Este programa é distribuído na expectativa de que seja útil,
  21 +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita
  22 +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA.
  23 +Consulte a Licença Pública Geral do GNU para mais detalhes.
  24 +Você deve ter recebido uma cópia da Licença Pública Geral do
  25 +GNU junto com este programa; se não, escreva para a
  26 +Free Software Foundation, Inc., no endereço
  27 +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  28 +
  29 +Parametros:
  30 +
  31 +ret {string} - extensão geográfica do retângulo que será utilizado na busca (xmin ymin xmax ymax)
  32 +
  33 +Return:
  34 +
  35 +{json} - lista com o resultado
  36 +*/
  37 +//set_time_limit(600);
  38 +require_once("../../pacotes/cpaint/cpaint2.inc.php");
  39 +require_once("../../classesphp/pega_variaveis.php");
  40 +require_once("../../classesphp/carrega_ext.php");
  41 +error_reporting(0);
  42 +$e = explode(" ",$ret);
  43 +$url = "http://ws.geonames.org/weatherJSON?lang=pt&north=".$e[3]."&south=".$e[1]."&east=".$e[2]."&west=".$e[0]."&maxRows=10";
  44 +$s = file($url);
  45 +header("Content-type: text/ascii; charset=UTF-8");
  46 +header('Expires: Fri, 14 Mar 1980 20:53:00 GMT');
  47 +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  48 +header('Cache-Control: no-cache, must-revalidate');
  49 +header('Pragma: no-cache');
  50 +echo "[".$s[0]."]";
  51 +
  52 +?>
0 53 \ No newline at end of file
... ...
ferramentas/metar/metarproxima.php 0 → 100644
... ... @@ -0,0 +1,155 @@
  1 +<?php
  2 +/*
  3 +Title: metarproxima
  4 +
  5 +Acessa o Web Service do Geonames que busca estações meteorológicas da rede METAR mais próximas de um ponto.
  6 +
  7 +Esse programa é utilizado na ferramenta de identificação e seu uso deve ser habilitado por meio do sistema
  8 +de administração do i3Geo. Para isso, utilize http://localhost/i3geo/admin/html/identifica.html e insira
  9 +"../ferramentas/metar/metarproxima.php" em uma nova linha na coluna "programa".
  10 +
  11 +Licenca:
  12 +
  13 +GPL2
  14 +
  15 +I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
  16 +
  17 +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil
  18 +Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br
  19 +
  20 +Este programa é software livre; você pode redistribuí-lo
  21 +e/ou modificá-lo sob os termos da Licença Pública Geral
  22 +GNU conforme publicada pela Free Software Foundation;
  23 +tanto a versão 2 da Licença.
  24 +Este programa é distribuído na expectativa de que seja útil,
  25 +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita
  26 +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA.
  27 +Consulte a Licença Pública Geral do GNU para mais detalhes.
  28 +Você deve ter recebido uma cópia da Licença Pública Geral do
  29 +GNU junto com este programa; se não, escreva para a
  30 +Free Software Foundation, Inc., no endereço
  31 +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  32 +
  33 +Parametros:
  34 +
  35 +x - coordenada x em décimos de grau
  36 +
  37 +y - coordenada y em décimos de grau
  38 +
  39 +Return:
  40 +
  41 +{html}
  42 +*/
  43 +//set_time_limit(600);
  44 +echo "<html><style>
  45 + P
  46 + {padding-top:1px;COLOR: #2F4632;text-align: justify;font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;}
  47 + </style>";
  48 +require_once("../../classesphp/pega_variaveis.php");
  49 +error_reporting(E_ALL);
  50 +$url = "http://ws.geonames.org/findNearByWeatherXML?lat=$y&lng=$x&lang=pt";
  51 +$xml = simplexml_load_file($url);
  52 +$conta = 0;
  53 +$fim = array();
  54 +$resultado = "";
  55 +if($xml == true){
  56 + $raiz = $xml->xpath('observation');
  57 + foreach($raiz as $e){
  58 + //var_dump($e);
  59 + $r = $e->xpath('observation');
  60 + foreach($r as $t)
  61 + {$resultado .= "<p><b>".$t."</b>";}
  62 +
  63 + $r = $e->xpath('observationTime');
  64 + foreach($r as $t)
  65 + {$resultado .= "<p><b> Data: </b>".$t;}
  66 +
  67 + $r = $e->xpath('stationName');
  68 + foreach($r as $t)
  69 + {$resultado .= "<p><b> Estação: </b>".$t;}
  70 +
  71 + $r = $e->xpath('ICAO');
  72 + foreach($r as $t)
  73 + {$resultado .= "<p><b> ICAO: </b>".$t;}
  74 +
  75 + $r = $e->xpath('elevation');
  76 + foreach($r as $t)
  77 + {$resultado .= "<p><b> Elevação: </b>".$t;}
  78 +
  79 + $r = $e->xpath('lat');
  80 + $y = $r;
  81 + foreach($r as $t)
  82 + {$resultado .= "<p><a title='Incluir no mapa' href='#' onmouseout='escondexy()' onmouseover='mostraxy()' onclick='insereponto()'><b> Latitude: </b>".$t;}
  83 + $r = $e->xpath('lng');
  84 + $x = $r;
  85 + foreach($r as $t)
  86 + {$resultado .= "<b> Longitude: </b>".$t."</a>";}
  87 +
  88 + $r = $e->xpath('temperature');
  89 + foreach($r as $t)
  90 + {$resultado .= "<p><b> Temperatura: </b>".$t." C";}
  91 +
  92 + $r = $e->xpath('dewPoint');
  93 + foreach($r as $t)
  94 + {$resultado .= "<p><b> Ponto de orvalho: </b>".$t." C";}
  95 +
  96 + $r = $e->xpath('humidity');
  97 + foreach($r as $t)
  98 + {$resultado .= "<p><b> Humidade: </b>".$t." %";}
  99 +
  100 + $r = $e->xpath('clouds');
  101 + foreach($r as $t)
  102 + {$resultado .= "<p><b> Nuvens: </b>".$t;}
  103 +
  104 + $r = $e->xpath('weatherCondition');
  105 + foreach($r as $t)
  106 + {$resultado .= "<p><b> Condição: </b>".$t;}
  107 +
  108 + $r = $e->xpath('hectoPascAltimeter');
  109 + foreach($r as $t)
  110 + {$resultado .= "<p><b> Pressão: </b>".$t." hpa";}
  111 +
  112 + $r = $e->xpath('windDirection');
  113 + foreach($r as $t)
  114 + {$resultado .= "<p><b> Direção do vento: </b>".$t;}
  115 +
  116 + $r = $e->xpath('windSpeed');
  117 + foreach($r as $t)
  118 + {$resultado .= "<p><b> Velocidade do vento: </b>".$t." mph<br>";}
  119 +
  120 + $resultado .= "<p><a href='$url' >Web Service</a><br>";
  121 + $resultado .= "<br><a href='http://weather.noaa.gov/' >Metar</a><br>";
  122 + }
  123 +}
  124 +if ($resultado == "")
  125 +{$resultado = "<span style=color:red >Nada encontrado</span><br><hr>";}
  126 +else
  127 +echo $resultado;
  128 +?>
  129 +<script>
  130 + var i3GEO = window.parent.i3GEO;
  131 + var x = <?php echo $x;?>;
  132 + var y = <?php echo $y;?>;
  133 +
  134 + $i = window.parent.$i
  135 + function escondexy(){
  136 + i3GEO.util.escondeBox();
  137 + }
  138 + function mostraxy(){
  139 + i3GEO.util.criaBox("boxpin");
  140 + xy = i3GEO.calculo.dd2tela(x*1,y*1,$i(i3GEO.Interface.IDCORPO),i3GEO.parametros.mapexten,i3GEO.parametros.pixelsize);
  141 + var box = $i("boxpin");
  142 + box.style.display = "block";
  143 + box.style.width = "5px";
  144 + box.style.height = "5px";
  145 + box.style.top = parseInt(xy[1],10)-2+"px";
  146 + box.style.left = parseInt(xy[0],10)-2+"px";
  147 + box.style.position = "absolute";
  148 + box.style.border = "solid 2px red"
  149 + box.style.zIndex = 5000
  150 + }
  151 + function insereponto(){
  152 + i3GEO.navega.zoomponto(i3GEO.configura.locaplic,i3GEO.configura.sid,x,y);
  153 + }
  154 +</script>
  155 +</html>
0 156 \ No newline at end of file
... ...
imagens/metar.png 0 → 100644

1.37 KB