Commit 6a57ec978b8da81228eb24b13287344b31271748
1 parent
ec18d2cd
Exists in
master
and in
7 other branches
Inclusão de cálculo de coordenadas na ferramenta identifica usando a classe_coordenadas.js
Showing
3 changed files
with
114 additions
and
46 deletions
Show diff stats
classesjs/classe_coordenadas.js
| ... | ... | @@ -32,7 +32,12 @@ if(typeof(i3GEO) === 'undefined'){ |
| 32 | 32 | /* |
| 33 | 33 | Classe: i3GEO.coordenadas |
| 34 | 34 | |
| 35 | -Inclui elementos especiais no mapa para apresentação de coordenadas | |
| 35 | +Inclui elementos especiais no mapa para apresentação de coordenadas. | |
| 36 | + | |
| 37 | +Contém funções que permitem a conversão de coordenadas, entre sistemas de projeção deiferentes, com base na biblioteca Proj4js. | |
| 38 | +Cria também o bloco de apresentação de coordenadas com base na posição do mouse sobre o mapa. | |
| 39 | +Mais informações em http://trac.osgeo.org/proj4js/ | |
| 40 | +Para adicionar novas projeções ou modificar as atuais, edit a variável i3GEO.coordenadas.config e defOrigem | |
| 36 | 41 | |
| 37 | 42 | */ |
| 38 | 43 | i3GEO.coordenadas = { |
| ... | ... | @@ -54,12 +59,15 @@ i3GEO.coordenadas = { |
| 54 | 59 | separado - mostra todos os tipos em lugares diferentes conforme o valor de idhtml |
| 55 | 60 | |
| 56 | 61 | lista - mostra cada tipo em um lugar diferente conforme o valor de idhtml |
| 62 | + | |
| 63 | + janela - cria uma janela flutuante para mostrar os dados | |
| 64 | + | |
| 57 | 65 | */ |
| 58 | 66 | formato: "bloco", //bloco,separado,lista,janela |
| 59 | 67 | /* |
| 60 | 68 | Propriedade: padrao |
| 61 | 69 | |
| 62 | - Indica qual tipo de coordenada é mostrado como padrão. Deve existir em i3GEO.coordenadas.config | |
| 70 | + Indica qual tipo de coordenada é mostrado como padrão quando formato for igual a "bloco". Deve existir em i3GEO.coordenadas.config | |
| 63 | 71 | |
| 64 | 72 | Default: |
| 65 | 73 | "geoProj" |
| ... | ... | @@ -78,9 +86,9 @@ i3GEO.coordenadas = { |
| 78 | 86 | /* |
| 79 | 87 | Propriedade: config |
| 80 | 88 | |
| 81 | - Define as configurações de cada tipo de coordenada mostrada | |
| 89 | + Define as configurações de cada tipo de coordenada que será utilizada e/ou mostrada no mapa | |
| 82 | 90 | |
| 83 | - Para alterar os parâmetros ou acrescentar novas projeções, altere esse objeto por meio de javascript | |
| 91 | + Para alterar os parâmetros ou acrescentar novas projeções, altere esse objeto | |
| 84 | 92 | |
| 85 | 93 | Para mais detalhes, veja i3geo/classesjs/classe_coordenada.js |
| 86 | 94 | |
| ... | ... | @@ -97,7 +105,7 @@ i3GEO.coordenadas = { |
| 97 | 105 | "policonicaSad69":{ |
| 98 | 106 | idhtml: "localizarxy", |
| 99 | 107 | tipo: "metrica", |
| 100 | - titulo: "Policônica SAD-69", | |
| 108 | + titulo: "Polic SAD-69", | |
| 101 | 109 | ativo: true, |
| 102 | 110 | defepsg: "+proj=poly +lat_0=0 +lon_0=-54 +x_0=5000000 +y_0=10000000 +ellps=aust_SA +units=m +no_defs" |
| 103 | 111 | }, |
| ... | ... | @@ -126,7 +134,7 @@ i3GEO.coordenadas = { |
| 126 | 134 | "utmSirgas2000Proj":{ |
| 127 | 135 | idhtml: "localizarxy", |
| 128 | 136 | tipo: "utm", |
| 129 | - titulo: "UTM Sirgas 2000", | |
| 137 | + titulo: "UTM Sirgas", | |
| 130 | 138 | ativo: true, |
| 131 | 139 | defepsg: "", |
| 132 | 140 | zona:{ |
| ... | ... | @@ -337,7 +345,7 @@ i3GEO.coordenadas = { |
| 337 | 345 | */ |
| 338 | 346 | criaMascaraDMS: function(prefixo,titulo,caixa){ |
| 339 | 347 | var ins = "<table id="+prefixo+" style=display:block;text-align:center ><tr style='border-bottom:2px solid white' >" + |
| 340 | - "<td style=width:150px;text-align:right >"+titulo+" X: </td>" + | |
| 348 | + "<td style=width:120px;text-align:right >"+titulo+" X: </td>" + | |
| 341 | 349 | "<td>"+$inputText("","315",prefixo+"xg","grau","3","-00")+" </td>" + |
| 342 | 350 | "<td>"+$inputText("","",prefixo+"xm","minuto","3","00")+" </td>" + |
| 343 | 351 | "<td>"+$inputText("","",prefixo+"xs","segundo","5","00.00")+" </td>" + |
| ... | ... | @@ -395,7 +403,7 @@ i3GEO.coordenadas = { |
| 395 | 403 | */ |
| 396 | 404 | criaMascaraMetrica: function(prefixo,titulo,caixa){ |
| 397 | 405 | var ins = "<table id="+prefixo+" style=display:block;text-align:center ><tr style='border-bottom:2px solid white' >" + |
| 398 | - "<td style=width:150px;text-align:right >"+titulo+" X: </td>" + | |
| 406 | + "<td style=width:120px;text-align:right >"+titulo+" X: </td>" + | |
| 399 | 407 | "<td>"+$inputText("","",prefixo+"X","X","12","00")+" </td>" + |
| 400 | 408 | "<td>Y:"+$inputText("","",prefixo+"Y","Y","12","00")+" </td>" + |
| 401 | 409 | "<td>Zn:"+$inputText("","",prefixo+"ZN","Zona","2","--")+" </td>" + |
| ... | ... | @@ -415,39 +423,71 @@ i3GEO.coordenadas = { |
| 415 | 423 | configProj {string} |
| 416 | 424 | |
| 417 | 425 | */ |
| 418 | - atualizaProj4: function(configProj){ | |
| 426 | + atualizaProj4: function(onde,configProj,x,y){ | |
| 427 | + try{ | |
| 428 | + if(!$i(onde+configProj+"ZN")) | |
| 429 | + {return;} | |
| 430 | + } | |
| 431 | + catch(e){return;} | |
| 419 | 432 | eval("temp = i3GEO.coordenadas.config."+configProj+";"); |
| 420 | 433 | try{ |
| 421 | - if($i(configProj).style.display == "none") | |
| 434 | + if($i(onde+configProj).style.display == "none") | |
| 422 | 435 | {return;} |
| 423 | 436 | } |
| 424 | 437 | catch(e){} |
| 425 | 438 | if(temp.tipo === "metrica"){ |
| 426 | 439 | var destino = temp.defepsg; |
| 427 | 440 | } |
| 441 | + if(x == undefined) | |
| 442 | + {x = objposicaocursor.ddx;} | |
| 443 | + if(y == undefined) | |
| 444 | + {y = objposicaocursor.ddy;} | |
| 428 | 445 | if(temp.tipo === "utm"){ |
| 429 | - var zona = i3GEO.coordenadas.geo2zonaUtm(objposicaocursor.ddx); | |
| 430 | - $i(configProj+"ZN").value = zona | |
| 446 | + var zona = i3GEO.coordenadas.geo2zonaUtm(x); | |
| 447 | + $i(onde+configProj+"ZN").value = zona | |
| 431 | 448 | if(objposicaocursor.ddy*1 > 0) |
| 432 | 449 | {var destino = temp.zona[zona+"N"];} |
| 433 | 450 | else |
| 434 | 451 | {var destino = temp.zona[zona+"S"];} |
| 435 | 452 | if(destino == undefined){ |
| 436 | - i3GEO.util.defineValor(configProj+"X","value","?"); | |
| 437 | - i3GEO.util.defineValor(configProj+"Y","value","?"); | |
| 453 | + i3GEO.util.defineValor(onde+configProj+"X","value","?"); | |
| 454 | + i3GEO.util.defineValor(onde+configProj+"Y","value","?"); | |
| 438 | 455 | return; |
| 439 | 456 | } |
| 440 | 457 | } |
| 458 | + var p = i3GEO.coordenadas.calculaProj4(i3GEO.coordenadas.defOrigem,destino,x,y); | |
| 459 | + i3GEO.util.defineValor(onde+configProj+"X","value",p.x); | |
| 460 | + i3GEO.util.defineValor(onde+configProj+"Y","value",p.y); | |
| 461 | + }, | |
| 462 | + /* | |
| 463 | + Function: calculaProj4 | |
| 464 | + | |
| 465 | + Faz a projeção de x e y da origem para o destino | |
| 466 | + | |
| 467 | + Parametros: | |
| 468 | + | |
| 469 | + origem {string} - CRS contendo o código da projeção de origem | |
| 470 | + | |
| 471 | + destino {string} - CRS contendo o código da projeção de destino | |
| 472 | + | |
| 473 | + x {numerico} - coordenada x ou longitude | |
| 474 | + | |
| 475 | + y {numerico} - coordenada y ou latitude | |
| 476 | + | |
| 477 | + Retorno: | |
| 478 | + | |
| 479 | + {Proj4js.transform} | |
| 480 | + */ | |
| 481 | + calculaProj4: function(origem,destino,x,y){ | |
| 441 | 482 | Proj4js.defs = { |
| 442 | - 'ORIGEM' : i3GEO.coordenadas.defOrigem, | |
| 483 | + 'ORIGEM' : origem, | |
| 443 | 484 | 'DESTINO': destino |
| 444 | 485 | }; |
| 445 | 486 | var source = new Proj4js.Proj("ORIGEM"), |
| 446 | 487 | dest = new Proj4js.Proj("DESTINO"), |
| 447 | - p = new Proj4js.Point(objposicaocursor.ddx,objposicaocursor.ddy); | |
| 488 | + p = new Proj4js.Point(x,y); | |
| 448 | 489 | Proj4js.transform(source, dest, p); |
| 449 | - i3GEO.util.defineValor(configProj+"X","value",p.x); | |
| 450 | - i3GEO.util.defineValor(configProj+"Y","value",p.y); | |
| 490 | + return p; | |
| 451 | 491 | }, |
| 452 | 492 | /* |
| 453 | 493 | Function: ativaBloco |
| ... | ... | @@ -456,7 +496,7 @@ i3GEO.coordenadas = { |
| 456 | 496 | |
| 457 | 497 | Mostra o que estiver definido em i3GEO.coordenadas.padrao |
| 458 | 498 | */ |
| 459 | - ativaBloco: function(){ | |
| 499 | + ativaBloco: function(prefixo){ | |
| 460 | 500 | var tipos = i3GEO.util.listaChaves(i3GEO.coordenadas.config), |
| 461 | 501 | n = tipos.length, |
| 462 | 502 | temp, |
| ... | ... | @@ -468,9 +508,9 @@ i3GEO.coordenadas = { |
| 468 | 508 | eval("temp = i3GEO.coordenadas.config."+tipos[i]+";"); |
| 469 | 509 | if(temp.ativo === true){ |
| 470 | 510 | if(tipos[i] == i3GEO.coordenadas.padrao) |
| 471 | - {$i(tipos[i]).style.display = "block";} | |
| 511 | + {$i(prefixo+tipos[i]).style.display = "block";} | |
| 472 | 512 | else |
| 473 | - {$i(tipos[i]).style.display = "none";} | |
| 513 | + {$i(prefixo+tipos[i]).style.display = "none";} | |
| 474 | 514 | } |
| 475 | 515 | } |
| 476 | 516 | }, |
| ... | ... | @@ -483,7 +523,7 @@ i3GEO.coordenadas = { |
| 483 | 523 | |
| 484 | 524 | tipo {string} - tipo de coordenada |
| 485 | 525 | */ |
| 486 | - mudaTipo: function(obj){ | |
| 526 | + mudaTipo: function(obj,onde){ | |
| 487 | 527 | if(obj.value === "janela"){ |
| 488 | 528 | i3GEO.coordenadas.formato = "janela"; |
| 489 | 529 | i3GEO.coordenadas.mostraCoordenadas(); |
| ... | ... | @@ -491,22 +531,37 @@ i3GEO.coordenadas = { |
| 491 | 531 | } |
| 492 | 532 | i3GEO.coordenadas.padrao = obj.value; |
| 493 | 533 | obj.selectedIndex = 0; |
| 494 | - i3GEO.coordenadas.ativaBloco(); | |
| 534 | + i3GEO.coordenadas.ativaBloco(onde); | |
| 495 | 535 | }, |
| 496 | 536 | /* |
| 497 | 537 | Function: mostraCoordenadas |
| 498 | 538 | |
| 499 | 539 | Constrói o conjunto de elementos HTML para mostrar as coordenadas e define as funções de atualização. |
| 540 | + | |
| 541 | + Parametro: | |
| 542 | + | |
| 543 | + ativaMovimento {boolean} - (opcional) aplica ou não as funções ligadas à movimentação do mouse | |
| 544 | + | |
| 545 | + onde {string} - (opcional) id onde o resultado será mostrado (irá ignorar os ids definidos em coordenadas.config) | |
| 500 | 546 | */ |
| 501 | - mostraCoordenadas: function(){ | |
| 547 | + mostraCoordenadas: function(ativaMovimento,onde,x,y){ | |
| 502 | 548 | try{ |
| 503 | 549 | var tipos = i3GEO.util.listaChaves(i3GEO.coordenadas.config), |
| 504 | 550 | n = tipos.length, |
| 505 | 551 | temp, |
| 506 | 552 | ins = "", |
| 507 | - onde = "", | |
| 508 | - i = 0, | |
| 509 | - caixa = "<select onchange='javascript:i3GEO.coordenadas.mudaTipo(this);' style='font-size:10px;height:15px;width:50px;' ><option>---</option><option value='janela' >janela</option>"; | |
| 553 | + i = 0; | |
| 554 | + if(arguments.length === 0){ | |
| 555 | + var ativaMovimento = true; | |
| 556 | + var onde = ""; | |
| 557 | + } | |
| 558 | + | |
| 559 | + // | |
| 560 | + //cria o HTML | |
| 561 | + // | |
| 562 | + if(onde === "") | |
| 563 | + {eval("onde = i3GEO.coordenadas.config."+tipos[0]+".idhtml;");} | |
| 564 | + var caixa = "<select onchange='javascript:i3GEO.coordenadas.mudaTipo(this,\""+onde+"\");' style='font-size:10px;height:15px;width:50px;' ><option>---</option><option value='janela' >janela</option>"; | |
| 510 | 565 | // |
| 511 | 566 | //cria a caixa de seleção |
| 512 | 567 | // |
| ... | ... | @@ -518,25 +573,20 @@ i3GEO.coordenadas = { |
| 518 | 573 | } |
| 519 | 574 | caixa += "</select>"; |
| 520 | 575 | if(i3GEO.coordenadas.formato !== "bloco") |
| 521 | - {caixa = "";} | |
| 522 | - // | |
| 523 | - //cria o HTML | |
| 524 | - // | |
| 576 | + {caixa = "";} | |
| 525 | 577 | for(i=0;i<n;i++){ |
| 526 | 578 | eval("temp = i3GEO.coordenadas.config."+tipos[i]+";"); |
| 527 | 579 | if(temp.ativo === true){ |
| 528 | 580 | if(temp.tipo === "geo"){ |
| 529 | - ins += i3GEO.coordenadas.criaMascaraDMS(tipos[i],temp.titulo,caixa); | |
| 581 | + ins += i3GEO.coordenadas.criaMascaraDMS(onde+tipos[i],temp.titulo,caixa); | |
| 530 | 582 | if(i3GEO.coordenadas.formato === "separado"){ |
| 531 | 583 | try{$i(temp.idhtml).innerHTML = ins;} |
| 532 | 584 | catch(e){} |
| 533 | 585 | ins = ""; |
| 534 | 586 | } |
| 535 | - else | |
| 536 | - {onde = temp.idhtml;} | |
| 537 | 587 | } |
| 538 | 588 | else{ |
| 539 | - ins += i3GEO.coordenadas.criaMascaraMetrica(tipos[i],temp.titulo,caixa); | |
| 589 | + ins += i3GEO.coordenadas.criaMascaraMetrica(onde+tipos[i],temp.titulo,caixa); | |
| 540 | 590 | } |
| 541 | 591 | } |
| 542 | 592 | } |
| ... | ... | @@ -564,7 +614,7 @@ i3GEO.coordenadas = { |
| 564 | 614 | {$i(onde).innerHTML = "";} |
| 565 | 615 | onde = "i3GEOJanelaCoordenadas_corpo"; |
| 566 | 616 | } |
| 567 | - if($i(onde)) | |
| 617 | + if(onde != "" && $i(onde)) | |
| 568 | 618 | {$i(onde).innerHTML = ins;} |
| 569 | 619 | // |
| 570 | 620 | //aplica as funções de movimentação do mouse |
| ... | ... | @@ -573,22 +623,36 @@ i3GEO.coordenadas = { |
| 573 | 623 | eval("temp = i3GEO.coordenadas.config."+tipos[i]+";"); |
| 574 | 624 | if(temp.ativo === true){ |
| 575 | 625 | if(temp.tipo === "geo"){ |
| 576 | - atualizaLocalizarGeo = function(id){ | |
| 626 | + atualizaLocalizarGeo = function(id,x,y){ | |
| 627 | + if(x == undefined) | |
| 628 | + {x = objposicaocursor.dmsx;} | |
| 629 | + if(y == undefined) | |
| 630 | + {y = objposicaocursor.dmsy;} | |
| 577 | 631 | temp = $i(id); |
| 578 | 632 | if(temp && temp.style.display == "block") |
| 579 | - {i3GEO.coordenadas.atualizaGeo(objposicaocursor.dmsx,objposicaocursor.dmsy,id);} | |
| 633 | + {i3GEO.coordenadas.atualizaGeo(x,y,id);} | |
| 580 | 634 | }; |
| 581 | - if(i3GEO.eventos.MOUSEMOVE.toString().search("atualizaLocalizarGeo('"+tipos[i]+"')") < 0) | |
| 582 | - {i3GEO.eventos.MOUSEMOVE.push("atualizaLocalizarGeo('"+tipos[i]+"')");} | |
| 635 | + if(ativaMovimento === true){ | |
| 636 | + if(i3GEO.eventos.MOUSEMOVE.toString().search("atualizaLocalizarGeo('"+onde+tipos[i]+"')") < 0) | |
| 637 | + {i3GEO.eventos.MOUSEMOVE.push("atualizaLocalizarGeo('"+onde+tipos[i]+"')");} | |
| 638 | + } | |
| 639 | + if(x != undefined){ | |
| 640 | + atualizaLocalizarGeo(onde+tipos[i],i3GEO.calculo.dd2dms(x)[0],i3GEO.calculo.dd2dms(y)[0]); | |
| 641 | + } | |
| 583 | 642 | } |
| 584 | 643 | else{ |
| 585 | - if(i3GEO.eventos.MOUSEMOVE.toString().search("i3GEO.coordenadas.atualizaProj4('"+tipos[i]+"')") < 0) | |
| 586 | - {i3GEO.eventos.MOUSEMOVE.push("i3GEO.coordenadas.atualizaProj4('"+tipos[i]+"')");} | |
| 644 | + if(ativaMovimento === true){ | |
| 645 | + if(i3GEO.eventos.MOUSEMOVE.toString().search("i3GEO.coordenadas.atualizaProj4('"+onde+"','"+tipos[i]+"')") < 0) | |
| 646 | + {i3GEO.eventos.MOUSEMOVE.push("i3GEO.coordenadas.atualizaProj4('"+onde+"','"+tipos[i]+"')");} | |
| 647 | + } | |
| 648 | + if(x != undefined){ | |
| 649 | + i3GEO.coordenadas.atualizaProj4(onde,tipos[i],x,y); | |
| 650 | + } | |
| 587 | 651 | } |
| 588 | 652 | } |
| 589 | 653 | } |
| 590 | 654 | if(i3GEO.coordenadas.formato === "bloco") |
| 591 | - {i3GEO.coordenadas.ativaBloco();} | |
| 655 | + {i3GEO.coordenadas.ativaBloco(onde);} | |
| 592 | 656 | } |
| 593 | 657 | catch(e){} |
| 594 | 658 | } | ... | ... |
ferramentas/identifica/index.js.php
| ... | ... | @@ -159,6 +159,9 @@ i3GEOF.identifica = { |
| 159 | 159 | $i("i3GEOidentificaguia5").onclick = function(){ |
| 160 | 160 | i3GEO.guias.mostraGuiaFerramenta("i3GEOidentificaguia5","i3GEOidentificaguia"); |
| 161 | 161 | var ins = "",retorna; |
| 162 | + i3GEO.coordenadas.formato = "lista"; | |
| 163 | + i3GEO.coordenadas.mostraCoordenadas(false,"i3GEOidentificacoord",i3GEOF.identifica.x,i3GEOF.identifica.y); | |
| 164 | + /* | |
| 162 | 165 | $i("i3GEOidentificacoord").innerHTML = "Aguarde..."; |
| 163 | 166 | retorna = function(utm){ |
| 164 | 167 | temp = i3GEO.calculo.dd2dms(i3GEOF.identifica.x,i3GEOF.identifica.y); |
| ... | ... | @@ -175,6 +178,7 @@ i3GEOF.identifica = { |
| 175 | 178 | $i("i3GEOidentificacoord").innerHTML = ins; |
| 176 | 179 | }; |
| 177 | 180 | i3GEO.php.geo2utm(retorna,i3GEOF.identifica.x,i3GEOF.identifica.y); |
| 181 | + */ | |
| 178 | 182 | }; |
| 179 | 183 | |
| 180 | 184 | i3GEOF.identifica.listaTemas("ligados"); | ... | ... |
interface/geral.htm
| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | o arquivo i3geo.js por i3geonaocompacto.js |
| 14 | 14 | No modo não compactado o código está adaptado para uso com o Firebug do Firefox. |
| 15 | 15 | --> |
| 16 | -<script type="text/javascript" src="../classesjs/i3geo.js"></script> | |
| 16 | +<script type="text/javascript" src="../classesjs/i3geonaocompacto.js"></script> | |
| 17 | 17 | <style> |
| 18 | 18 | .yui-log .i3geo {background-color:yellow;} /* customize a color */ |
| 19 | 19 | .yui-log .redesenho {background-color:yellow;} /* customize a color */ |
| ... | ... | @@ -132,8 +132,8 @@ vc pode optar por colocar mensagens de ajuda em algum lugar |
| 132 | 132 | </td> |
| 133 | 133 | <td class=tdbranca > |
| 134 | 134 | <table width=100% ><tr> |
| 135 | - <td class=tdbranca width="33%" ><div id=lugarquadros ></div></td> | |
| 136 | - <td class=tdbranca width="33%" style=text-align:center > | |
| 135 | + <td class=tdbranca width="23%" ><div id=lugarquadros ></div></td> | |
| 136 | + <td class=tdbranca width="43%" style=text-align:center > | |
| 137 | 137 | <!-- aqui será incluído o gadget que mostra a coordenada geográfica da posição do mouse --> |
| 138 | 138 | <div id=localizarxy style="text-align:left;font-size:10px;">Aguarde...</div> |
| 139 | 139 | </td> | ... | ... |