Commit 94e29cf24a608e174d899cb2c7e8e1225cf6a9be
1 parent
64bf4fed
Exists in
master
and in
7 other branches
- Opção para criar um buffer no ponto clicado na ferramenta de identificação
Showing
6 changed files
with
227 additions
and
22 deletions
Show diff stats
admin/admin.db
No preview for this file type
classesjs/dicionario_ajuda.js
| ... | ... | @@ -210,7 +210,7 @@ g_traducao_ajuda = { |
| 210 | 210 | diretorio:"i3geo/ferramentas/buffer", |
| 211 | 211 | categoria:"3", |
| 212 | 212 | pt:"O entorno, ou buffer, é um polígono que circunda um elemento geográfico em uma distância fixa. Para o cálculo de distância o i3Geo utiliza a projeção policônica. Os atributos do tema alvo são copiados para os polígonos resultantes e uma nova camada é adicionada ao mapa. Opcionalmente, os polígonos resultantes podem ser unidos como um único.", |
| 213 | - complemento:"Para gerar o entorno, você precisa selecionar alguns elementos de um tema. Utilize para isso a opção de seleção ou a tabela de atributos do tema desejado.", | |
| 213 | + complemento:"Para gerar o entorno, você precisa selecionar alguns elementos de um tema. Utilize para isso a opção de seleção ou a tabela de atributos do tema desejado. O buffer pode ser gerado também por meio da ferramenta de identificação.", | |
| 214 | 214 | tela:"ferramentas/buffer/exemplo.htm", |
| 215 | 215 | apijs:"i3GEO.analise.dialogo.buffer()" |
| 216 | 216 | }, | ... | ... |
classesphp/classe_analise.php
| ... | ... | @@ -1226,14 +1226,17 @@ $locaplic - Localização do I3geo. |
| 1226 | 1226 | |
| 1227 | 1227 | $unir - sim|nao indica se os elementos selecionados deverão ser unidos em um só antes do buffer ser criado |
| 1228 | 1228 | |
| 1229 | +$wkt - (opcional) elemento no formato wkt para o qual o buffer será gerado. Só de ve ser definido se $this->nome for vazio, ou seja | |
| 1230 | +se o parâmetro "tema" não tiver sido fornecido ao construtor da classe | |
| 1231 | + | |
| 1229 | 1232 | return: |
| 1230 | 1233 | |
| 1231 | 1234 | nome do layer criado com o buffer. |
| 1232 | 1235 | */ |
| 1233 | - function criaBuffer($distancia,$locaplic,$unir="nao") | |
| 1236 | + function criaBuffer($distancia,$locaplic,$unir="nao",$wkt="") | |
| 1234 | 1237 | { |
| 1235 | - if(!$this->layer){return "erro";} | |
| 1236 | 1238 | set_time_limit(180); |
| 1239 | + //error_reporting(E_ALL); | |
| 1237 | 1240 | //para manipular dbf |
| 1238 | 1241 | if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) |
| 1239 | 1242 | include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); |
| ... | ... | @@ -1241,20 +1244,32 @@ nome do layer criado com o buffer. |
| 1241 | 1244 | include_once "../pacotes/phpxbase/api_conversion.php"; |
| 1242 | 1245 | $nomebuffer = nomeRandomico(); |
| 1243 | 1246 | $nomeshp = $this->diretorio."/".$nomebuffer; |
| 1244 | - //pega os shapes selecionados | |
| 1245 | - carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 1246 | - $sopen = $this->layer->open(); | |
| 1247 | - if($sopen == MS_FAILURE){return "erro";} | |
| 1248 | - $items = pegaItens($this->layer); | |
| 1249 | - $this->layer->open(); | |
| 1250 | - $res_count = $this->layer->getNumresults(); | |
| 1251 | - $buffers = array(); | |
| 1252 | - //pega um shape especifico | |
| 1253 | - for ($i = 0; $i < $res_count; ++$i) | |
| 1254 | - { | |
| 1255 | - $result = $this->layer->getResult($i); | |
| 1256 | - $shp_index = $result->shapeindex; | |
| 1257 | - $shape = $this->layer->getfeature($shp_index,-1); | |
| 1247 | + $listaShapes = array(); | |
| 1248 | + if($this->nome != ""){ | |
| 1249 | + //pega os shapes selecionados | |
| 1250 | + carregaquery($this->arquivo,&$this->layer,&$this->mapa); | |
| 1251 | + $sopen = $this->layer->open(); | |
| 1252 | + if($sopen == MS_FAILURE){return "erro";} | |
| 1253 | + $items = pegaItens($this->layer); | |
| 1254 | + $this->layer->open(); | |
| 1255 | + $res_count = $this->layer->getNumresults(); | |
| 1256 | + $buffers = array(); | |
| 1257 | + //pega um shape especifico | |
| 1258 | + for ($i = 0; $i < $res_count; ++$i) | |
| 1259 | + { | |
| 1260 | + $result = $this->layer->getResult($i); | |
| 1261 | + $shp_index = $result->shapeindex; | |
| 1262 | + $listaShapes[] = $this->layer->getfeature($shp_index,-1); | |
| 1263 | + } | |
| 1264 | + $fechou = $this->layer->close(); | |
| 1265 | + } | |
| 1266 | + else{ | |
| 1267 | + $s = ms_shapeObjFromWkt($wkt); | |
| 1268 | + $s->values["ID"] = 0; | |
| 1269 | + $items[] = "ID"; | |
| 1270 | + $listaShapes[] = $s; | |
| 1271 | + } | |
| 1272 | + foreach($listaShapes as $shape){ | |
| 1258 | 1273 | //calcula a extensão geografica |
| 1259 | 1274 | $rect = $shape->bounds; |
| 1260 | 1275 | $projInObj = ms_newprojectionobj("proj=latlong"); |
| ... | ... | @@ -1283,11 +1298,9 @@ nome do layer criado com o buffer. |
| 1283 | 1298 | $buffers = array($ns); |
| 1284 | 1299 | $shapes = array($shapes[0]); |
| 1285 | 1300 | } |
| 1286 | - $fechou = $this->layer->close(); | |
| 1287 | 1301 | //gera o novo arquivo shape file |
| 1288 | 1302 | // cria o shapefile |
| 1289 | 1303 | $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON); |
| 1290 | - $items = pegaItens($this->layer); | |
| 1291 | 1304 | // cria o dbf |
| 1292 | 1305 | $def = array(); |
| 1293 | 1306 | $def[] = array("i3geo","C","254"); | ... | ... |
classesphp/mapa_controle.php
| ... | ... | @@ -464,7 +464,7 @@ Salva o mapa acrescentando um novo layer com o buffer. |
| 464 | 464 | include_once("classe_analise.php"); |
| 465 | 465 | copiaSeguranca($map_file); |
| 466 | 466 | $m = new Analise($map_file,$tema,$locaplic,$ext); |
| 467 | - $retorno = $m->criaBuffer($distancia,$locaplic,$unir); | |
| 467 | + $retorno = $m->criaBuffer($distancia,$locaplic,$unir,$wkt); | |
| 468 | 468 | $m->salva(); |
| 469 | 469 | $_SESSION["contadorsalva"]++; |
| 470 | 470 | //limpa selecao | ... | ... |
| ... | ... | @@ -0,0 +1,184 @@ |
| 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 | +Title: Buffer (entorno) em um ponto | |
| 5 | + | |
| 6 | +Arquivo: | |
| 7 | + | |
| 8 | +i3geo/ferramentas/bufferpt/index.js.php | |
| 9 | + | |
| 10 | +Licenca: | |
| 11 | + | |
| 12 | +GPL2 | |
| 13 | + | |
| 14 | +i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
| 15 | + | |
| 16 | +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
| 17 | +Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br | |
| 18 | + | |
| 19 | +Este programa é software livre; você pode redistribuí-lo | |
| 20 | +e/ou modificá-lo sob os termos da Licença Pública Geral | |
| 21 | +GNU conforme publicada pela Free Software Foundation; | |
| 22 | + | |
| 23 | +Este programa é distribuído na expectativa de que seja útil, | |
| 24 | +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
| 25 | +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
| 26 | +Consulte a Licença Pública Geral do GNU para mais detalhes. | |
| 27 | +Você deve ter recebido uma cópia da Licença Pública Geral do | |
| 28 | +GNU junto com este programa; se não, escreva para a | |
| 29 | +Free Software Foundation, Inc., no endereço | |
| 30 | +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
| 31 | +*/ | |
| 32 | +if(typeof(i3GEOF) === 'undefined'){ | |
| 33 | + i3GEOF = []; | |
| 34 | +} | |
| 35 | +/* | |
| 36 | +Classe: i3GEOF.bufferpt | |
| 37 | + | |
| 38 | +Cria um novo tema com um polígono de entorno para uma determinada coordenada enviada como parâmetro | |
| 39 | + | |
| 40 | +*/ | |
| 41 | +i3GEOF.bufferpt = { | |
| 42 | + /* | |
| 43 | + Propriedade: x | |
| 44 | + | |
| 45 | + Coordenada x (longitude) do ponto | |
| 46 | + */ | |
| 47 | + x: 0, | |
| 48 | + /* | |
| 49 | + Propriedade: y | |
| 50 | + | |
| 51 | + Coordenada y (latitude) do ponto | |
| 52 | + */ | |
| 53 | + y: 0, | |
| 54 | + /* | |
| 55 | + Variavel: aguarde | |
| 56 | + | |
| 57 | + Estilo do objeto DOM com a imagem de aguarde existente no cabeçalho da janela. | |
| 58 | + */ | |
| 59 | + aguarde: "", | |
| 60 | + /* | |
| 61 | + Function: inicia | |
| 62 | + | |
| 63 | + Inicia a ferramenta. É chamado por criaJanelaFlutuante | |
| 64 | + | |
| 65 | + Parametro: | |
| 66 | + | |
| 67 | + iddiv {String} - id do div que receberá o conteudo HTML da ferramenta | |
| 68 | + */ | |
| 69 | + inicia: function(iddiv){ | |
| 70 | + var box; | |
| 71 | + try{ | |
| 72 | + $i(iddiv).innerHTML += i3GEOF.bufferpt.html(); | |
| 73 | + new YAHOO.widget.Button( | |
| 74 | + "i3GEObufferptbotao2", | |
| 75 | + {onclick:{fn: i3GEOF.bufferpt.atualizaBox}} | |
| 76 | + ); | |
| 77 | + new YAHOO.widget.Button( | |
| 78 | + "i3GEObufferptbotao1", | |
| 79 | + {onclick:{fn: i3GEOF.bufferpt.executa}} | |
| 80 | + ); | |
| 81 | + } | |
| 82 | + catch(erro){alert(erro);} | |
| 83 | + }, | |
| 84 | + /* | |
| 85 | + Function: html | |
| 86 | + | |
| 87 | + Gera o código html para apresentação das opções da ferramenta | |
| 88 | + | |
| 89 | + Retorno: | |
| 90 | + | |
| 91 | + String com o código html | |
| 92 | + */ | |
| 93 | + html:function(){ | |
| 94 | + var ins = '' + | |
| 95 | + '<p class=paragrafo >Distância em metros ao redor do ponto</p>' + | |
| 96 | + $inputText("","","i3GEOFbufferptDistancia","",10,0) + | |
| 97 | + '<br><br><p class=paragrafo ><input id=i3GEObufferptbotao1 size=16 type=button value="Criar"/>'; | |
| 98 | + return ins; | |
| 99 | + }, | |
| 100 | + /* | |
| 101 | + Function: criaJanelaFlutuante | |
| 102 | + | |
| 103 | + Cria a janela flutuante para controle da ferramenta. | |
| 104 | + | |
| 105 | + Os parâmetros x e y são utilizados para a definição das propriedades i3GEOF.bufferpt.x e i3GEOF.bufferpt.y. Se não forem fornecidos, | |
| 106 | + seus valores permanecerão como 0. Essas propriedades podem também ser definidas pela função que ativou a ferramenta. | |
| 107 | + | |
| 108 | + Parametros: | |
| 109 | + | |
| 110 | + x {dd} - coordenada x (longitude) | |
| 111 | + | |
| 112 | + y {dd} - coordenada y (latitude) | |
| 113 | + */ | |
| 114 | + criaJanelaFlutuante: function(x,y){ | |
| 115 | + var janela,divid,temp,titulo,cabecalho,minimiza; | |
| 116 | + if(x) | |
| 117 | + {i3GEOF.bufferpt.x = x;} | |
| 118 | + if(y) | |
| 119 | + {i3GEOF.bufferpt.y = y;} | |
| 120 | + cabecalho = function(){}; | |
| 121 | + minimiza = function(){ | |
| 122 | + i3GEO.janela.minimiza("i3GEOF.bufferpt"); | |
| 123 | + }; | |
| 124 | + //cria a janela flutuante | |
| 125 | + titulo = "Entorno de um ponto <a class=ajuda_usuario target=_blank href='" + i3GEO.configura.locaplic + "/ajuda_usuario.php?idcategoria=24&idajuda=3' > </a>"; | |
| 126 | + janela = i3GEO.janela.cria( | |
| 127 | + "210px", | |
| 128 | + "110px", | |
| 129 | + "", | |
| 130 | + "", | |
| 131 | + "", | |
| 132 | + titulo, | |
| 133 | + "i3GEOF.bufferpt", | |
| 134 | + false, | |
| 135 | + "hd", | |
| 136 | + cabecalho, | |
| 137 | + "" | |
| 138 | + ); | |
| 139 | + divid = janela[2].id; | |
| 140 | + i3GEOF.bufferpt.aguarde = $i("i3GEOF.bufferpt_imagemCabecalho").style; | |
| 141 | + i3GEOF.bufferpt.inicia(divid); | |
| 142 | + }, | |
| 143 | + /* | |
| 144 | + Function: executa | |
| 145 | + | |
| 146 | + Altera o tamanho do mapa | |
| 147 | + | |
| 148 | + Veja: | |
| 149 | + | |
| 150 | + <MUDATAMANHO> | |
| 151 | + */ | |
| 152 | + executa: function(){ | |
| 153 | + try{ | |
| 154 | + if(i3GEOF.bufferpt.aguarde.visibility === "visible") | |
| 155 | + {return;} | |
| 156 | + var distancia = $i("i3GEOFbufferptDistancia").value, | |
| 157 | + p, | |
| 158 | + fim, | |
| 159 | + cp; | |
| 160 | + if (distancia*1 !== 0) | |
| 161 | + { | |
| 162 | + i3GEOF.bufferpt.aguarde.visibility = "visible"; | |
| 163 | + fim = function(retorno){ | |
| 164 | + i3GEOF.bufferpt.aguarde.visibility = "hidden"; | |
| 165 | + if (retorno.data === undefined ) | |
| 166 | + {alert("Erro. A operação demorou muito.");} | |
| 167 | + else | |
| 168 | + {i3GEO.atualiza();} | |
| 169 | + }; | |
| 170 | + p = i3GEO.configura.locaplic+"/classesphp/mapa_controle.php?g_sid="+i3GEO.configura.sid+"&funcao=criabuffer&tema=&distancia="+distancia+"&unir=nao&wkt=POINT("+i3GEOF.bufferpt.x+" "+i3GEOF.bufferpt.y+")"; | |
| 171 | + cp = new cpaint(); | |
| 172 | + cp.set_response_type("JSON"); | |
| 173 | + cp.call(p,"criaBuffer",fim); | |
| 174 | + } | |
| 175 | + else | |
| 176 | + {alert("Distancia invalida");} | |
| 177 | + } | |
| 178 | + catch(e){$i("i3GEObufferfim").innerHTML = "<p class='paragrafo' >Erro. "+e;i3GEO.janela.fechaAguarde();i3GEOF.bufferpt.aguarde.visibility = "hidden";} | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + } | |
| 183 | +}; | |
| 184 | +<?php error_reporting(0);if(extension_loaded('zlib')){ob_end_flush();}?> | |
| 0 | 185 | \ No newline at end of file | ... | ... |
ferramentas/identifica/index.js.php
| ... | ... | @@ -163,6 +163,14 @@ i3GEOF.identifica = { |
| 163 | 163 | }; |
| 164 | 164 | $i("i3GEOidentificaguia5").onclick = function(){ |
| 165 | 165 | i3GEO.guias.mostraGuiaFerramenta("i3GEOidentificaguia5","i3GEOidentificaguia"); |
| 166 | + new YAHOO.widget.Button("i3GEOidentificabotao2",{ | |
| 167 | + onclick:{ | |
| 168 | + fn: function(){ | |
| 169 | + var js = i3GEO.configura.locaplic+"/ferramentas/bufferpt/index.js.php"; | |
| 170 | + i3GEO.util.scriptTag(js,"i3GEOF.bufferpt.criaJanelaFlutuante("+i3GEOF.identifica.x+","+i3GEOF.identifica.y+")","i3GEOF.bufferpt_script"); | |
| 171 | + } | |
| 172 | + } | |
| 173 | + }); | |
| 166 | 174 | var ins = "",retorna; |
| 167 | 175 | i3GEO.coordenadas.formato = "lista"; |
| 168 | 176 | i3GEO.coordenadas.mostraCoordenadas(false,"i3GEOidentificacoordtexto",i3GEOF.identifica.x,i3GEOF.identifica.y); |
| ... | ... | @@ -303,7 +311,7 @@ i3GEOF.identifica = { |
| 303 | 311 | ins += ' <li><a href="#ancora"><em><div id="i3GEOidentificaguia1" style="text-align:center;left:0px;" >Temas visíveis</div></em></a></li>'; |
| 304 | 312 | ins += ' <li><a href="#ancora"><em><div id="i3GEOidentificaguia2" style="text-align:center;left:0px;" >Todos</div></em></a></li>'; |
| 305 | 313 | ins += ' <li><a href="#ancora"><em><div id="i3GEOidentificaguia4" style="text-align:center;left:0px;" >Etiquetas</div></em></a></li>'; |
| 306 | - ins += ' <li><a href="#ancora"><em><div id="i3GEOidentificaguia5" style="text-align:center;left:0px;" >XY</div></em></a></li>'; | |
| 314 | + ins += ' <li><a href="#ancora"><em><div id="i3GEOidentificaguia5" style="text-align:center;left:0px;" >XY/buffer</div></em></a></li>'; | |
| 307 | 315 | ins += ' <li><a href="#ancora"><em><div id="i3GEOidentificaguia3" style="text-align:center;left:0px;" >Propriedades</div></em></a></li>'; |
| 308 | 316 | ins += ' </ul>'; |
| 309 | 317 | ins += '</div>'; |
| ... | ... | @@ -328,7 +336,7 @@ i3GEOF.identifica = { |
| 328 | 336 | ins += ' <b>Valores para o ponto indicado no mapa<br></b>'; |
| 329 | 337 | ins += ' <div id=i3GEOidentificacoord ></div><br>'; |
| 330 | 338 | ins += ' <div id=i3GEOidentificacoordtexto style=text-align:left ></div>'; |
| 331 | - | |
| 339 | + ins += ' <br><br><input id=i3GEOidentificabotao2 size=20 type=button value="Criar entorno (buffer)" />'; | |
| 332 | 340 | ins += ' </div>'; |
| 333 | 341 | //ins += '</div> '; |
| 334 | 342 | return ins; | ... | ... |