Commit 24de638f479565c33677ee6d05031a9b64dc4cbc
1 parent
d6e4bb78
Exists in
master
and in
7 other branches
Alteração na ferramenta de cálculo de área para utilizar a API do OpenLayers nessa interface
Showing
2 changed files
with
423 additions
and
125 deletions
Show diff stats
classesjs/classe_analise.js
| ... | ... | @@ -259,8 +259,8 @@ i3GEO.analise = { |
| 259 | 259 | i3GEO.analise.medeDistancia.criaJanela(); |
| 260 | 260 | i3GEO.analise.medeDistancia[i3GEO.Interface["ATUAL"]].inicia(); |
| 261 | 261 | }, |
| 262 | - /* | |
| 263 | - Cria a janela para mostrar os resultados da medicao | |
| 262 | + /** | |
| 263 | + * Cria a janela para mostrar os resultados da medicao | |
| 264 | 264 | */ |
| 265 | 265 | criaJanela: function(){ |
| 266 | 266 | var novoel,ins,imagemxy,janela; |
| ... | ... | @@ -367,14 +367,14 @@ i3GEO.analise = { |
| 367 | 367 | var f = new OpenLayers.Feature.Vector( |
| 368 | 368 | feature, |
| 369 | 369 | { |
| 370 | - strokeWidth: estilo.linewidth, | |
| 371 | - strokeColor: estilo.linecolor, | |
| 372 | 370 | origem: "medeDistancia" |
| 373 | 371 | }, |
| 374 | 372 | { |
| 375 | 373 | graphicName: "square", |
| 376 | 374 | pointRadius: 10, |
| 377 | - graphicOpacity: 1 | |
| 375 | + graphicOpacity: 1, | |
| 376 | + strokeWidth: estilo.linewidth, | |
| 377 | + strokeColor: estilo.linecolor | |
| 378 | 378 | } |
| 379 | 379 | ); |
| 380 | 380 | i3GEO.desenho.layergrafico.addFeatures([f]); |
| ... | ... | @@ -442,12 +442,12 @@ i3GEO.analise = { |
| 442 | 442 | 30 |
| 443 | 443 | ), |
| 444 | 444 | { |
| 445 | - strokeWidth: 1, | |
| 446 | 445 | origem: "medeDistanciaExcluir" |
| 447 | 446 | }, |
| 448 | 447 | { |
| 449 | 448 | fill: false, |
| 450 | - strokeColor: "#FFFFFF" | |
| 449 | + strokeColor: estilo.circcolor, | |
| 450 | + strokeWidth: 1 | |
| 451 | 451 | } |
| 452 | 452 | ); |
| 453 | 453 | i3GEO.desenho.layergrafico.addFeatures([circ]); |
| ... | ... | @@ -468,7 +468,7 @@ i3GEO.analise = { |
| 468 | 468 | fillColor: "white", |
| 469 | 469 | label: trecho.toFixed(3), |
| 470 | 470 | labelAlign: "rb", |
| 471 | - fontColor: "gray", | |
| 471 | + fontColor: estilo.textcolor, | |
| 472 | 472 | fontSize: 12, |
| 473 | 473 | fontWeight: "bold" |
| 474 | 474 | } |
| ... | ... | @@ -715,7 +715,7 @@ i3GEO.analise = { |
| 715 | 715 | } |
| 716 | 716 | }, |
| 717 | 717 | /* |
| 718 | - Classe: i3GEO.analise.medeArea | |
| 718 | + i3GEO.analise.medeArea | |
| 719 | 719 | |
| 720 | 720 | Ativa e controla a opcao de medicao de area. |
| 721 | 721 | |
| ... | ... | @@ -726,6 +726,10 @@ i3GEO.analise = { |
| 726 | 726 | Para mostrar o resultado do calculo, e incluido um div especifico. |
| 727 | 727 | */ |
| 728 | 728 | medeArea:{ |
| 729 | + /** | |
| 730 | + * Armazena os pontos clicados para realizar os calculos | |
| 731 | + */ | |
| 732 | + pontos: {}, | |
| 729 | 733 | /* |
| 730 | 734 | Function: inicia |
| 731 | 735 | |
| ... | ... | @@ -734,8 +738,9 @@ i3GEO.analise = { |
| 734 | 738 | Sao registrados os eventos de clique sobre o mapa e fechamento da janela de resultados |
| 735 | 739 | */ |
| 736 | 740 | inicia: function(){ |
| 737 | - if(typeof(console) !== 'undefined'){console.info("i3GEO.analise.medeArea.inicia()");} | |
| 741 | + if(typeof(console) !== 'undefined'){console.info("i3GEO.analise.medeDistancia.inicia()");} | |
| 738 | 742 | i3GEO.eventos.cliquePerm.desativa(); |
| 743 | + //@TODO remover apos concluir a refatoracao do codigo | |
| 739 | 744 | i3GEO.analise.pontosdistobj = { |
| 740 | 745 | xpt: [], |
| 741 | 746 | ypt: [], |
| ... | ... | @@ -748,42 +753,8 @@ i3GEO.analise = { |
| 748 | 753 | linhas: [], |
| 749 | 754 | linhastemp: [] |
| 750 | 755 | }; |
| 751 | - var x,y,ll1,ll2,d, | |
| 752 | - calculo = i3GEO.calculo, | |
| 753 | - montacontainer = function(){ | |
| 754 | - var desenho = i3GEO.desenho; | |
| 755 | - $i("mostraarea_calculo").innerHTML = "Clique no mapa para desenhar o poligono. Clique duas vezes para concluir"; | |
| 756 | - i3GEO.barraDeBotoes.ativaIcone("area"); | |
| 757 | - g_tipoacao = "area"; | |
| 758 | - desenho.criaContainerRichdraw(); | |
| 759 | - desenho.richdraw.lineColor = "green"; | |
| 760 | - desenho.richdraw.lineWidth = "2px"; | |
| 761 | - }; | |
| 762 | 756 | i3GEO.analise.medeArea.criaJanela(); |
| 763 | - if (g_tipoacao !== "area"){ | |
| 764 | - $i("mostraarea_calculo").innerHTML = ""; | |
| 765 | - if(i3GEO.eventos.MOUSECLIQUE.toString().search("i3GEO.analise.medeArea.clique()") < 0) | |
| 766 | - {i3GEO.eventos.MOUSECLIQUE.push("i3GEO.analise.medeArea.clique()");} | |
| 767 | - if(i3GEO.eventos.MOUSEMOVE.toString().search("i3GEO.analise.medeArea.movimento()") < 0) | |
| 768 | - {i3GEO.eventos.MOUSEMOVE.push("i3GEO.analise.medeArea.movimento()");} | |
| 769 | - if(i3GEO.eventos.NAVEGAMAPA.toString().search("i3GEO.analise.medeArea.fechaJanela()") < 0) | |
| 770 | - {i3GEO.eventos.NAVEGAMAPA.push("i3GEO.analise.medeArea.fechaJanela()");} | |
| 771 | - // | |
| 772 | - //a API do Openlayers e GoogleMaps tem uma funcao propria de obtencao da resolucao de cada pixel | |
| 773 | - //essa funcao e embutida em i3GEO.calculo.tela2dd | |
| 774 | - // | |
| 775 | - if(i3GEO.util.in_array(i3GEO.Interface.ATUAL,["openlayers","googlemaps"])){ | |
| 776 | - x = parseInt(i3GEO.parametros.w / 2,10); | |
| 777 | - y = parseInt(i3GEO.parametros.h / 2,10); | |
| 778 | - ll1 = calculo.tela2dd(x,y,"",""); | |
| 779 | - ll2 = calculo.tela2dd(x + 1,y,"",""); | |
| 780 | - d = calculo.distancia(ll1[0],ll1[1],ll2[0],ll2[1]); | |
| 781 | - d = d * 1000; | |
| 782 | - g_areapixel = d * d; | |
| 783 | - g_areapixel < 0 ? i3GEO.janela.tempoMsg("Nao e possivel calcular a area. Entre em contato com o administrador do sistema.") : montacontainer(); | |
| 784 | - } | |
| 785 | - } | |
| 786 | - else{i3GEO.desenho.richdraw.fecha();} | |
| 757 | + i3GEO.analise.medeArea[i3GEO.Interface["ATUAL"]].inicia(); | |
| 787 | 758 | }, |
| 788 | 759 | /* |
| 789 | 760 | Cria a janela para mostrar os resultados da medicao |
| ... | ... | @@ -797,6 +768,7 @@ i3GEO.analise = { |
| 797 | 768 | '<div class="bd" style="text-align:left;padding:3px;font-size:10px" >' + |
| 798 | 769 | 'Estilo: '+i3GEO.desenho.caixaEstilos()+'<br>' + |
| 799 | 770 | '<div style="text-align:left;padding:3px;font-size:10px" id="mostraarea_calculo" ></div>' + |
| 771 | + '<div style="text-align:left;padding:3px;font-size:10px" id="mostraarea_calculo_parcial" ></div>' + | |
| 800 | 772 | '</div>'; |
| 801 | 773 | novoel.innerHTML = ins; |
| 802 | 774 | novoel.style.borderColor="gray"; |
| ... | ... | @@ -821,87 +793,413 @@ i3GEO.analise = { |
| 821 | 793 | fechaJanela: function(){ |
| 822 | 794 | var janela; |
| 823 | 795 | i3GEO.eventos.cliquePerm.ativa(); |
| 824 | - i3GEO.desenho.richdraw.fecha(); | |
| 825 | - i3GEO.util.removeChild("pontosArea",document.body); | |
| 826 | - i3GEO.eventos.MOUSECLIQUE.remove("i3GEO.analise.medeArea.clique()"); | |
| 827 | - i3GEO.eventos.MOUSEMOVE.remove("i3GEO.analise.medeArea.movimento()"); | |
| 828 | - i3GEO.eventos.NAVEGAMAPA.remove("i3GEO.analise.medeArea.fechaJanela()"); | |
| 829 | - i3GEO.barraDeBotoes.ativaBotoes(); | |
| 796 | + //@TODO remover | |
| 797 | + if(i3GEO.Interface.ATUAL !== "openlayers"){ | |
| 798 | + i3GEO.desenho.richdraw.fecha(); | |
| 799 | + i3GEO.util.removeChild("pontosArea",document.body); | |
| 800 | + i3GEO.eventos.MOUSECLIQUE.remove("i3GEO.analise.medeArea.clique()"); | |
| 801 | + i3GEO.eventos.MOUSEMOVE.remove("i3GEO.analise.medeArea.movimento()"); | |
| 802 | + i3GEO.eventos.NAVEGAMAPA.remove("i3GEO.analise.medeArea.fechaJanela()"); | |
| 803 | + i3GEO.barraDeBotoes.ativaBotoes(); | |
| 804 | + } | |
| 830 | 805 | janela = YAHOO.i3GEO.janela.manager.find("mostraarea"); |
| 831 | 806 | if(janela){ |
| 832 | 807 | YAHOO.i3GEO.janela.manager.remove(janela); |
| 833 | 808 | janela.destroy(); |
| 834 | 809 | } |
| 835 | 810 | i3GEO.barraDeBotoes.ativaIcone("pointer"); |
| 811 | + i3GEO.analise.medeArea[i3GEO.Interface["ATUAL"]].fechaJanela(); | |
| 836 | 812 | }, |
| 837 | - /* | |
| 838 | - Adiciona uma marca na tela e realiza o calculo de distancia dos pontos inseridos | |
| 813 | + /** | |
| 814 | + * Funcoes especificas da interface openlayers | |
| 839 | 815 | */ |
| 840 | - clique: function(){ | |
| 841 | - var n,m; | |
| 842 | - pontosdistobj = i3GEO.analise.pontosdistobj; | |
| 843 | - if (g_tipoacao === "area"){ | |
| 844 | - n = pontosdistobj.xpt.length; | |
| 845 | - pontosdistobj.xpt[n] = objposicaocursor.ddx; | |
| 846 | - pontosdistobj.ypt[n] = objposicaocursor.ddy; | |
| 847 | - pontosdistobj.xtela[n] = objposicaocursor.telax; | |
| 848 | - pontosdistobj.ytela[n] = objposicaocursor.telay; | |
| 849 | - pontosdistobj.ximg[n] = objposicaocursor.imgx; | |
| 850 | - pontosdistobj.yimg[n] = objposicaocursor.imgy; | |
| 851 | - pontosdistobj.dist[n] = 0; | |
| 852 | - //inclui a linha para ligar com o ponto inicial | |
| 853 | - if (n === 0){ | |
| 854 | - try { | |
| 855 | - pontosdistobj.linhastemp = i3GEO.desenho.richdraw.renderer.create(i3GEO.desenho.richdraw.mode, i3GEO.desenho.richdraw.fillColor, i3GEO.desenho.richdraw.lineColor, i3GEO.desenho.richdraw.lineWidth, pontosdistobj.ximg[n]-1,pontosdistobj.yimg[n]-1,pontosdistobj.ximg[0]-1,pontosdistobj.yimg[0]-1); | |
| 856 | - } | |
| 857 | - catch(e){ | |
| 858 | - if(typeof(console) !== 'undefined'){console.error(e);} | |
| 859 | - } | |
| 860 | - } | |
| 861 | - else{ | |
| 862 | - if(navm) | |
| 863 | - {i3GEO.desenho.richdraw.renderer.create(i3GEO.desenho.richdraw.mode, i3GEO.desenho.richdraw.fillColor, i3GEO.desenho.richdraw.lineColor, i3GEO.desenho.richdraw.lineWidth, (pontosdistobj.ximg[n-1]),pontosdistobj.yimg[n-1],(pontosdistobj.ximg[n]),pontosdistobj.yimg[n]);} | |
| 864 | - //parece qe tem um problema de versao do ie aqui | |
| 865 | - //if(navm) | |
| 866 | - //{i3GEO.desenho.richdraw.renderer.create(i3GEO.desenho.richdraw.mode, i3GEO.desenho.richdraw.fillColor, i3GEO.desenho.richdraw.lineColor, i3GEO.desenho.richdraw.lineWidth, (pontosdistobj.ximg[n-1])-(i3GEO.parametros.w/2),pontosdistobj.yimg[n-1],(pontosdistobj.ximg[n])-(i3GEO.parametros.w/2),pontosdistobj.yimg[n]);} | |
| 867 | - } | |
| 868 | - try{ | |
| 869 | - pontosdistobj.linhas[n] = i3GEO.desenho.richdraw.renderer.create(i3GEO.desenho.richdraw.mode, i3GEO.desenho.richdraw.fillColor, i3GEO.desenho.richdraw.lineColor, i3GEO.desenho.richdraw.lineWidth, pontosdistobj.ximg[n]-1,pontosdistobj.yimg[n]-1,pontosdistobj.ximg[n]-1,pontosdistobj.yimg[n]-1); | |
| 816 | + openlayers:{ | |
| 817 | + /** | |
| 818 | + * Inicializa o processo | |
| 819 | + * Cria a variavel para guardar os pontos | |
| 820 | + * Executa a funcao de inicializacao do desenho, que cria o layer para receber os graficos | |
| 821 | + */ | |
| 822 | + inicia: function(){ | |
| 823 | + var poligono, | |
| 824 | + estilo = i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao], | |
| 825 | + controle = i3geoOL.getControlsBy("id","i3GeoMedeArea"); | |
| 826 | + i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); | |
| 827 | + i3GEO.analise.medeArea.pontos = { | |
| 828 | + xpt: [], | |
| 829 | + ypt: [], | |
| 830 | + dist: [] | |
| 831 | + }; | |
| 832 | + if(controle.length === 0){ | |
| 833 | + poligono = new OpenLayers.Control.DrawFeature( | |
| 834 | + i3GEO.desenho.layergrafico, | |
| 835 | + OpenLayers.Handler.Polygon, | |
| 836 | + { | |
| 837 | + autoActivate: true, | |
| 838 | + id: "i3GeoMedeArea", | |
| 839 | + type: OpenLayers.Control.TYPE_TOOL, | |
| 840 | + callbacks:{ | |
| 841 | + done: function(feature){ | |
| 842 | + var f = new OpenLayers.Feature.Vector( | |
| 843 | + feature, | |
| 844 | + { | |
| 845 | + origem: "medeArea" | |
| 846 | + }, | |
| 847 | + { | |
| 848 | + graphicName: "square", | |
| 849 | + pointRadius: 10, | |
| 850 | + graphicOpacity: 1, | |
| 851 | + strokeWidth: estilo.linewidth, | |
| 852 | + strokeColor: estilo.linecolor, | |
| 853 | + fillColor: estilo.fillcolor, | |
| 854 | + fillOpacity: 0.3 | |
| 855 | + } | |
| 856 | + ); | |
| 857 | + i3GEO.desenho.layergrafico.addFeatures([f]); | |
| 858 | + if(i3GEO.Interface){ | |
| 859 | + i3GEO.Interface.openlayers.sobeLayersGraficos(); | |
| 860 | + } | |
| 861 | + i3GEO.analise.medeArea.openlayers.mostraParcial(0,0,0,0); | |
| 862 | + i3GEO.analise.medeArea.openlayers.inicia(); | |
| 863 | + }, | |
| 864 | + modify: function(point,poligono){ | |
| 865 | + var n,x1,y1,x2,y2, | |
| 866 | + trecho = 0, | |
| 867 | + per = 0, | |
| 868 | + direcao = 0, | |
| 869 | + area = 0; | |
| 870 | + n = i3GEO.analise.medeArea.pontos.ypt.length; | |
| 871 | + if(n > 1){ | |
| 872 | + x1 = i3GEO.analise.medeArea.pontos.xpt[n-1]; | |
| 873 | + y1 = i3GEO.analise.medeArea.pontos.ypt[n-1]; | |
| 874 | + x2 = point.x; | |
| 875 | + y2 = point.y; | |
| 876 | + //projeta | |
| 877 | + if(i3GEO.Interface.openlayers.googleLike){ | |
| 878 | + temp = i3GEO.util.extOSM2Geo(x1+" "+y1+" "+x2+" "+y2); | |
| 879 | + temp = temp.split(" "); | |
| 880 | + x1 = temp[0]; | |
| 881 | + y1 = temp[1]; | |
| 882 | + x2 = temp[2]; | |
| 883 | + y2 = temp[3]; | |
| 884 | + } | |
| 885 | + trecho = i3GEO.calculo.distancia(x1,y1,x2,y2); | |
| 886 | + direcao = i3GEO.calculo.direcao(x1,y1,x2,y2); | |
| 887 | + per = i3GEO.analise.medeArea.openlayers.somaDist(); | |
| 888 | + //soma ate o primeiro ponto | |
| 889 | + x1 = i3GEO.analise.medeArea.pontos.xpt[0]; | |
| 890 | + y1 = i3GEO.analise.medeArea.pontos.ypt[0]; | |
| 891 | + //projeta | |
| 892 | + if(i3GEO.Interface.openlayers.googleLike){ | |
| 893 | + temp = i3GEO.util.extOSM2Geo(x1+" "+y1+" "+x2+" "+y2); | |
| 894 | + temp = temp.split(" "); | |
| 895 | + x1 = temp[0]; | |
| 896 | + y1 = temp[1]; | |
| 897 | + x2 = temp[2]; | |
| 898 | + y2 = temp[3]; | |
| 899 | + } | |
| 900 | + per += i3GEO.calculo.distancia(x1,y1,x2,y2); | |
| 901 | + if(n > 2){ | |
| 902 | + area = poligono.geometry.getGeodesicArea(); | |
| 903 | + } | |
| 904 | + i3GEO.analise.medeArea.openlayers.mostraParcial(trecho,per,area,direcao); | |
| 905 | + } | |
| 906 | + }, | |
| 907 | + point: function(point,poligono){ | |
| 908 | + var n,x1,y1,x2,y2,temp,label, | |
| 909 | + //registra os pontos e calcula a distancia | |
| 910 | + per = 0, | |
| 911 | + trecho = 0, | |
| 912 | + area = 0; | |
| 913 | + i3GEO.analise.medeArea.pontos.xpt.push(point.x); | |
| 914 | + i3GEO.analise.medeArea.pontos.ypt.push(point.y); | |
| 915 | + n = i3GEO.analise.medeArea.pontos.ypt.length; | |
| 916 | + if(n > 1){ | |
| 917 | + x1 = i3GEO.analise.medeArea.pontos.xpt[n-2]; | |
| 918 | + y1 = i3GEO.analise.medeArea.pontos.ypt[n-2]; | |
| 919 | + x2 = point.x; | |
| 920 | + y2 = point.y; | |
| 921 | + //projeta | |
| 922 | + if(i3GEO.Interface.openlayers.googleLike){ | |
| 923 | + temp = i3GEO.util.extOSM2Geo(x1+" "+y1+" "+x2+" "+y2); | |
| 924 | + temp = temp.split(" "); | |
| 925 | + x1 = temp[0]; | |
| 926 | + y1 = temp[1]; | |
| 927 | + x2 = temp[2]; | |
| 928 | + y2 = temp[3]; | |
| 929 | + } | |
| 930 | + trecho = i3GEO.calculo.distancia(x1,y1,x2,y2); | |
| 931 | + i3GEO.analise.medeArea.pontos.dist.push(trecho); | |
| 932 | + per = i3GEO.analise.medeArea.openlayers.somaDist(); | |
| 933 | + //soma ate o primeiro ponto | |
| 934 | + x1 = i3GEO.analise.medeArea.pontos.xpt[0]; | |
| 935 | + y1 = i3GEO.analise.medeArea.pontos.ypt[0]; | |
| 936 | + //projeta | |
| 937 | + if(i3GEO.Interface.openlayers.googleLike){ | |
| 938 | + temp = i3GEO.util.extOSM2Geo(x1+" "+y1+" "+x2+" "+y2); | |
| 939 | + temp = temp.split(" "); | |
| 940 | + x1 = temp[0]; | |
| 941 | + y1 = temp[1]; | |
| 942 | + x2 = temp[2]; | |
| 943 | + y2 = temp[3]; | |
| 944 | + } | |
| 945 | + per += i3GEO.calculo.distancia(x1,y1,x2,y2); | |
| 946 | + //desenha ponto | |
| 947 | + //if($i("parartextos") && $i("parartextos").checked === true ){ | |
| 948 | + label = new OpenLayers.Feature.Vector( | |
| 949 | + new OpenLayers.Geometry.Point(point.x,point.y), | |
| 950 | + { | |
| 951 | + origem: "medeAreaExcluir" | |
| 952 | + }, | |
| 953 | + { | |
| 954 | + graphicName: "square", | |
| 955 | + pointRadius: 3, | |
| 956 | + strokeColor: "black", | |
| 957 | + graphicOpacity: 1, | |
| 958 | + strokeWidth: 1, | |
| 959 | + fillColor: "white", | |
| 960 | + label: trecho.toFixed(3), | |
| 961 | + labelAlign: "rb", | |
| 962 | + fontColor: estilo.textcolor, | |
| 963 | + fontSize: 12, | |
| 964 | + fontWeight: "bold" | |
| 965 | + } | |
| 966 | + ); | |
| 967 | + i3GEO.desenho.layergrafico.addFeatures([label]); | |
| 968 | + if(n > 2){ | |
| 969 | + area = poligono.getGeodesicArea(); | |
| 970 | + } | |
| 971 | + } | |
| 972 | + i3GEO.analise.medeArea.openlayers.mostraTotal(per,area); | |
| 973 | + } | |
| 974 | + } | |
| 975 | + } | |
| 976 | + ); | |
| 977 | + i3geoOL.addControl(poligono); | |
| 978 | + } | |
| 979 | + }, | |
| 980 | + /** | |
| 981 | + * Soma os valores de distancia guardados em pontos.dist | |
| 982 | + */ | |
| 983 | + somaDist: function(){ | |
| 984 | + var n,i, | |
| 985 | + total = 0; | |
| 986 | + n = i3GEO.analise.medeArea.pontos.dist.length; | |
| 987 | + for(i=0;i<n;i++){ | |
| 988 | + total += i3GEO.analise.medeArea.pontos.dist[i]; | |
| 989 | + } | |
| 990 | + return total; | |
| 991 | + }, | |
| 992 | + /** | |
| 993 | + * Fecha a janela que mostra os dados | |
| 994 | + * Pergunta ao usuario se os graficos devem ser removidos | |
| 995 | + * Os graficos sao marcados com o atributo "origem" | |
| 996 | + * Os raios e pontos sao sempre removidos | |
| 997 | + */ | |
| 998 | + fechaJanela: function(){ | |
| 999 | + var temp, | |
| 1000 | + controle = i3geoOL.getControlsBy("id","i3GeoMedeArea"), | |
| 1001 | + f = i3GEO.desenho.layergrafico.getFeaturesByAttribute("origem","medeArea"); | |
| 1002 | + if(controle.length > 0){ | |
| 1003 | + controle[0].deactivate(); | |
| 1004 | + i3geoOL.removeControl(controle[0]); | |
| 1005 | + } | |
| 1006 | + if(f && f.length > 0){ | |
| 1007 | + temp = window.confirm($trad("x94")); | |
| 1008 | + if(temp){ | |
| 1009 | + i3GEO.desenho.layergrafico.destroyFeatures(f); | |
| 870 | 1010 | } |
| 871 | - catch(men){ | |
| 872 | - if(typeof(console) !== 'undefined'){console.error(men);} | |
| 1011 | + } | |
| 1012 | + f = i3GEO.desenho.layergrafico.getFeaturesByAttribute("origem","medeAreaExcluir"); | |
| 1013 | + if(f && f.length > 0){ | |
| 1014 | + i3GEO.desenho.layergrafico.destroyFeatures(f); | |
| 1015 | + } | |
| 1016 | + }, | |
| 1017 | + /** | |
| 1018 | + * Mostra a totalizacao das linhas ja digitalizadas | |
| 1019 | + */ | |
| 1020 | + mostraTotal: function(per,area){ | |
| 1021 | + var mostra = $i("mostraarea_calculo"), | |
| 1022 | + texto; | |
| 1023 | + if (mostra){ | |
| 1024 | + texto = "<b>Área:</b> "+(area/1000000).toFixed(3)+" km2"+ | |
| 1025 | + "<br><b>Área:</b> "+(area/10000).toFixed(2)+" ha"+ | |
| 1026 | + "<br><b>perímetro:</b> "+(per).toFixed(2)+" km"+ | |
| 1027 | + "<br>"+$trad("x25")+": "+i3GEO.calculo.metododistancia; | |
| 1028 | + mostra.innerHTML = texto; | |
| 1029 | + } | |
| 1030 | + }, | |
| 1031 | + /** | |
| 1032 | + * Mostra o valor do trecho entre o ultimo ponto clicado e a posicao do mouse | |
| 1033 | + */ | |
| 1034 | + mostraParcial: function(trecho,per,area,direcao){ | |
| 1035 | + var mostra = $i("mostraarea_calculo_parcial"), | |
| 1036 | + texto; | |
| 1037 | + if (mostra){ | |
| 1038 | + texto = "<b>Área:</b> "+(area/1000000).toFixed(3)+" km2"+ | |
| 1039 | + "<br><b>Área:</b> "+(area/10000).toFixed(2)+" ha"+ | |
| 1040 | + "<br><b>trecho:</b> "+trecho.toFixed(3)+" km"+ | |
| 1041 | + "<br><b>perímetro:</b> "+(per).toFixed(3)+" km" + | |
| 1042 | + "<br><b>"+$trad("x23")+" (DMS):</b> "+direcao.toFixed(4); | |
| 1043 | + mostra.innerHTML = texto; | |
| 1044 | + } | |
| 1045 | + } | |
| 1046 | + }, | |
| 1047 | + googlemaps: { | |
| 1048 | + inicia: function(){ | |
| 1049 | + var x,y,ll1,ll2,d, | |
| 1050 | + calculo = i3GEO.calculo, | |
| 1051 | + montacontainer = function(){ | |
| 1052 | + var desenho = i3GEO.desenho; | |
| 1053 | + $i("mostraarea_calculo").innerHTML = "Clique no mapa para desenhar o poligono. Clique duas vezes para concluir"; | |
| 1054 | + i3GEO.barraDeBotoes.ativaIcone("area"); | |
| 1055 | + g_tipoacao = "area"; | |
| 1056 | + desenho.criaContainerRichdraw(); | |
| 1057 | + desenho.richdraw.lineColor = "green"; | |
| 1058 | + desenho.richdraw.lineWidth = "2px"; | |
| 1059 | + }; | |
| 1060 | + i3GEO.analise.medeArea.criaJanela(); | |
| 1061 | + if (g_tipoacao !== "area"){ | |
| 1062 | + $i("mostraarea_calculo").innerHTML = ""; | |
| 1063 | + if(i3GEO.eventos.MOUSECLIQUE.toString().search("i3GEO.analise.medeArea.clique()") < 0) | |
| 1064 | + {i3GEO.eventos.MOUSECLIQUE.push("i3GEO.analise.medeArea.clique()");} | |
| 1065 | + if(i3GEO.eventos.MOUSEMOVE.toString().search("i3GEO.analise.medeArea.movimento()") < 0) | |
| 1066 | + {i3GEO.eventos.MOUSEMOVE.push("i3GEO.analise.medeArea.movimento()");} | |
| 1067 | + if(i3GEO.eventos.NAVEGAMAPA.toString().search("i3GEO.analise.medeArea.fechaJanela()") < 0) | |
| 1068 | + {i3GEO.eventos.NAVEGAMAPA.push("i3GEO.analise.medeArea.fechaJanela()");} | |
| 1069 | + // | |
| 1070 | + //a API do Openlayers e GoogleMaps tem uma funcao propria de obtencao da resolucao de cada pixel | |
| 1071 | + //essa funcao e embutida em i3GEO.calculo.tela2dd | |
| 1072 | + // | |
| 1073 | + if(i3GEO.util.in_array(i3GEO.Interface.ATUAL,["openlayers","googlemaps"])){ | |
| 1074 | + x = parseInt(i3GEO.parametros.w / 2,10); | |
| 1075 | + y = parseInt(i3GEO.parametros.h / 2,10); | |
| 1076 | + ll1 = calculo.tela2dd(x,y,"",""); | |
| 1077 | + ll2 = calculo.tela2dd(x + 1,y,"",""); | |
| 1078 | + d = calculo.distancia(ll1[0],ll1[1],ll2[0],ll2[1]); | |
| 1079 | + d = d * 1000; | |
| 1080 | + g_areapixel = d * d; | |
| 1081 | + g_areapixel < 0 ? i3GEO.janela.tempoMsg("Nao e possivel calcular a area. Entre em contato com o administrador do sistema.") : montacontainer(); | |
| 873 | 1082 | } |
| 874 | - m = i3GEO.calculo.area(pontosdistobj.xtela,pontosdistobj.ytela,g_areapixel); | |
| 875 | - i3GEO.util.defineValor("mostraarea_calculo","innerHTML","<br>m2</b>= "+m.toFixed(2)+"<br><b>km2</b>= "+(m/1000000).toFixed(2)+"<br><b>ha</b>= "+(m/10000).toFixed(2)); | |
| 1083 | + } | |
| 1084 | + else{i3GEO.desenho.richdraw.fecha();} | |
| 1085 | + }, | |
| 1086 | + fechaJanela: function(){ | |
| 1087 | + } | |
| 1088 | + }, | |
| 1089 | + googleearth: { | |
| 1090 | + inicia: function(){ | |
| 1091 | + var x,y,ll1,ll2,d, | |
| 1092 | + calculo = i3GEO.calculo, | |
| 1093 | + montacontainer = function(){ | |
| 1094 | + var desenho = i3GEO.desenho; | |
| 1095 | + $i("mostraarea_calculo").innerHTML = "Clique no mapa para desenhar o poligono. Clique duas vezes para concluir"; | |
| 1096 | + i3GEO.barraDeBotoes.ativaIcone("area"); | |
| 1097 | + g_tipoacao = "area"; | |
| 1098 | + desenho.criaContainerRichdraw(); | |
| 1099 | + desenho.richdraw.lineColor = "green"; | |
| 1100 | + desenho.richdraw.lineWidth = "2px"; | |
| 1101 | + }; | |
| 1102 | + i3GEO.analise.medeArea.criaJanela(); | |
| 1103 | + if (g_tipoacao !== "area"){ | |
| 1104 | + $i("mostraarea_calculo").innerHTML = ""; | |
| 1105 | + if(i3GEO.eventos.MOUSECLIQUE.toString().search("i3GEO.analise.medeArea.clique()") < 0) | |
| 1106 | + {i3GEO.eventos.MOUSECLIQUE.push("i3GEO.analise.medeArea.clique()");} | |
| 1107 | + if(i3GEO.eventos.MOUSEMOVE.toString().search("i3GEO.analise.medeArea.movimento()") < 0) | |
| 1108 | + {i3GEO.eventos.MOUSEMOVE.push("i3GEO.analise.medeArea.movimento()");} | |
| 1109 | + if(i3GEO.eventos.NAVEGAMAPA.toString().search("i3GEO.analise.medeArea.fechaJanela()") < 0) | |
| 1110 | + {i3GEO.eventos.NAVEGAMAPA.push("i3GEO.analise.medeArea.fechaJanela()");} | |
| 1111 | + // | |
| 1112 | + //a API do Openlayers e GoogleMaps tem uma funcao propria de obtencao da resolucao de cada pixel | |
| 1113 | + //essa funcao e embutida em i3GEO.calculo.tela2dd | |
| 1114 | + // | |
| 876 | 1115 | if(i3GEO.util.in_array(i3GEO.Interface.ATUAL,["openlayers","googlemaps"])){ |
| 877 | - i3GEO.util.insereMarca.cria(objposicaocursor.imgx,objposicaocursor.imgy,i3GEO.analise.medeArea.paraCalculo,"divGeometriasTemp","",i3GEO.configura.locaplic+"/imagens/estasel.png",6,6); | |
| 878 | - i3GEO.desenho.insereCirculo(objposicaocursor.imgx,objposicaocursor.imgy,3,"white"); | |
| 1116 | + x = parseInt(i3GEO.parametros.w / 2,10); | |
| 1117 | + y = parseInt(i3GEO.parametros.h / 2,10); | |
| 1118 | + ll1 = calculo.tela2dd(x,y,"",""); | |
| 1119 | + ll2 = calculo.tela2dd(x + 1,y,"",""); | |
| 1120 | + d = calculo.distancia(ll1[0],ll1[1],ll2[0],ll2[1]); | |
| 1121 | + d = d * 1000; | |
| 1122 | + g_areapixel = d * d; | |
| 1123 | + g_areapixel < 0 ? i3GEO.janela.tempoMsg("Nao e possivel calcular a area. Entre em contato com o administrador do sistema.") : montacontainer(); | |
| 879 | 1124 | } |
| 880 | - if(i3GEO.Interface.ATUAL === "googleearth") | |
| 881 | - {i3GEO.util.insereMarca.cria(objposicaocursor.ddx,objposicaocursor.ddy,i3GEO.analise.medeArea.paraCalculo,"divGeometriasTemp","");} | |
| 882 | 1125 | } |
| 1126 | + else{i3GEO.desenho.richdraw.fecha();} | |
| 883 | 1127 | }, |
| 884 | - /* | |
| 1128 | + fechaJanela: function(){ | |
| 1129 | + } | |
| 1130 | + }, | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + //////////////////////////////////////////// | |
| 1135 | + /* | |
| 1136 | + Adiciona uma marca na tela e realiza o calculo de distancia dos pontos inseridos | |
| 1137 | + */ | |
| 1138 | + clique: function(){ | |
| 1139 | + var n,m; | |
| 1140 | + pontosdistobj = i3GEO.analise.pontosdistobj; | |
| 1141 | + if (g_tipoacao === "area"){ | |
| 1142 | + n = pontosdistobj.xpt.length; | |
| 1143 | + pontosdistobj.xpt[n] = objposicaocursor.ddx; | |
| 1144 | + pontosdistobj.ypt[n] = objposicaocursor.ddy; | |
| 1145 | + pontosdistobj.xtela[n] = objposicaocursor.telax; | |
| 1146 | + pontosdistobj.ytela[n] = objposicaocursor.telay; | |
| 1147 | + pontosdistobj.ximg[n] = objposicaocursor.imgx; | |
| 1148 | + pontosdistobj.yimg[n] = objposicaocursor.imgy; | |
| 1149 | + pontosdistobj.dist[n] = 0; | |
| 1150 | + //inclui a linha para ligar com o ponto inicial | |
| 1151 | + if (n === 0){ | |
| 1152 | + try { | |
| 1153 | + pontosdistobj.linhastemp = i3GEO.desenho.richdraw.renderer.create(i3GEO.desenho.richdraw.mode, i3GEO.desenho.richdraw.fillColor, i3GEO.desenho.richdraw.lineColor, i3GEO.desenho.richdraw.lineWidth, pontosdistobj.ximg[n]-1,pontosdistobj.yimg[n]-1,pontosdistobj.ximg[0]-1,pontosdistobj.yimg[0]-1); | |
| 1154 | + } | |
| 1155 | + catch(e){ | |
| 1156 | + if(typeof(console) !== 'undefined'){console.error(e);} | |
| 1157 | + } | |
| 1158 | + } | |
| 1159 | + else{ | |
| 1160 | + if(navm) | |
| 1161 | + {i3GEO.desenho.richdraw.renderer.create(i3GEO.desenho.richdraw.mode, i3GEO.desenho.richdraw.fillColor, i3GEO.desenho.richdraw.lineColor, i3GEO.desenho.richdraw.lineWidth, (pontosdistobj.ximg[n-1]),pontosdistobj.yimg[n-1],(pontosdistobj.ximg[n]),pontosdistobj.yimg[n]);} | |
| 1162 | + //parece qe tem um problema de versao do ie aqui | |
| 1163 | + //if(navm) | |
| 1164 | + //{i3GEO.desenho.richdraw.renderer.create(i3GEO.desenho.richdraw.mode, i3GEO.desenho.richdraw.fillColor, i3GEO.desenho.richdraw.lineColor, i3GEO.desenho.richdraw.lineWidth, (pontosdistobj.ximg[n-1])-(i3GEO.parametros.w/2),pontosdistobj.yimg[n-1],(pontosdistobj.ximg[n])-(i3GEO.parametros.w/2),pontosdistobj.yimg[n]);} | |
| 1165 | + } | |
| 1166 | + try{ | |
| 1167 | + pontosdistobj.linhas[n] = i3GEO.desenho.richdraw.renderer.create(i3GEO.desenho.richdraw.mode, i3GEO.desenho.richdraw.fillColor, i3GEO.desenho.richdraw.lineColor, i3GEO.desenho.richdraw.lineWidth, pontosdistobj.ximg[n]-1,pontosdistobj.yimg[n]-1,pontosdistobj.ximg[n]-1,pontosdistobj.yimg[n]-1); | |
| 1168 | + } | |
| 1169 | + catch(men){ | |
| 1170 | + if(typeof(console) !== 'undefined'){console.error(men);} | |
| 1171 | + } | |
| 1172 | + m = i3GEO.calculo.area(pontosdistobj.xtela,pontosdistobj.ytela,g_areapixel); | |
| 1173 | + i3GEO.util.defineValor("mostraarea_calculo","innerHTML","<br>m2</b>= "+m.toFixed(2)+"<br><b>km2</b>= "+(m/1000000).toFixed(2)+"<br><b>ha</b>= "+(m/10000).toFixed(2)); | |
| 1174 | + if(i3GEO.util.in_array(i3GEO.Interface.ATUAL,["openlayers","googlemaps"])){ | |
| 1175 | + i3GEO.util.insereMarca.cria(objposicaocursor.imgx,objposicaocursor.imgy,i3GEO.analise.medeArea.paraCalculo,"divGeometriasTemp","",i3GEO.configura.locaplic+"/imagens/estasel.png",6,6); | |
| 1176 | + i3GEO.desenho.insereCirculo(objposicaocursor.imgx,objposicaocursor.imgy,3,"white"); | |
| 1177 | + } | |
| 1178 | + if(i3GEO.Interface.ATUAL === "googleearth") | |
| 1179 | + {i3GEO.util.insereMarca.cria(objposicaocursor.ddx,objposicaocursor.ddy,i3GEO.analise.medeArea.paraCalculo,"divGeometriasTemp","");} | |
| 1180 | + } | |
| 1181 | + }, | |
| 1182 | + /* | |
| 885 | 1183 | Para o calculo de area e ativa o botao "pan" |
| 886 | - */ | |
| 887 | - paraCalculo: function(){ | |
| 888 | - var botaoPan = $i("pan"); | |
| 889 | - g_tipoacao = ""; | |
| 890 | - botaoPan ? botaoPan.onclick.call() : i3GEO.barraDeBotoes.ativaBotoes(); | |
| 891 | - }, | |
| 892 | - /* | |
| 1184 | + */ | |
| 1185 | + paraCalculo: function(){ | |
| 1186 | + var botaoPan = $i("pan"); | |
| 1187 | + g_tipoacao = ""; | |
| 1188 | + botaoPan ? botaoPan.onclick.call() : i3GEO.barraDeBotoes.ativaBotoes(); | |
| 1189 | + }, | |
| 1190 | + /* | |
| 893 | 1191 | Realiza o desenho do poligono conforme o usuario movimenta o mouse |
| 894 | - */ | |
| 895 | - movimento: function(){ | |
| 896 | - var n, | |
| 897 | - pontosdistobj = i3GEO.analise.pontosdistobj; | |
| 898 | - if (g_tipoacao === "area"){ | |
| 899 | - n = pontosdistobj.xpt.length; | |
| 900 | - if (n > 0){ | |
| 901 | - i3GEO.desenho.aplica("resizePoligono",pontosdistobj.linhastemp,1); | |
| 902 | - i3GEO.desenho.aplica("resizeLinha",pontosdistobj.linhas[n-1],n); | |
| 903 | - } | |
| 1192 | + */ | |
| 1193 | + movimento: function(){ | |
| 1194 | + var n, | |
| 1195 | + pontosdistobj = i3GEO.analise.pontosdistobj; | |
| 1196 | + if (g_tipoacao === "area"){ | |
| 1197 | + n = pontosdistobj.xpt.length; | |
| 1198 | + if (n > 0){ | |
| 1199 | + i3GEO.desenho.aplica("resizePoligono",pontosdistobj.linhastemp,1); | |
| 1200 | + i3GEO.desenho.aplica("resizeLinha",pontosdistobj.linhas[n-1],n); | |
| 904 | 1201 | } |
| 905 | 1202 | } |
| 906 | 1203 | } |
| 1204 | +} | |
| 907 | 1205 | }; | ... | ... |
classesjs/classe_desenho.js
| ... | ... | @@ -62,32 +62,32 @@ i3GEO.desenho = { |
| 62 | 62 | */ |
| 63 | 63 | estilos: { |
| 64 | 64 | "normal":{ |
| 65 | - fillcolor: '255,0,0', | |
| 66 | - linecolor: '0,0,0', | |
| 65 | + fillcolor: '#ffffff', | |
| 66 | + linecolor: '#000000', | |
| 67 | 67 | linewidth: '2', |
| 68 | - circcolor: '255,255,255', | |
| 69 | - textcolor: '100,100,100' | |
| 68 | + circcolor: '#ffffff', | |
| 69 | + textcolor: '#787A78' | |
| 70 | 70 | }, |
| 71 | 71 | "palido":{ |
| 72 | - fillcolor: '100,100,100', | |
| 73 | - linecolor: '100,100,100', | |
| 72 | + fillcolor: '#B5A8A8', | |
| 73 | + linecolor: '#BAA4AE', | |
| 74 | 74 | linewidth: '1', |
| 75 | - circcolor: '100,100,100', | |
| 76 | - textcolor: '100,100,100' | |
| 75 | + circcolor: '#E0D7DC', | |
| 76 | + textcolor: '#787A78' | |
| 77 | 77 | }, |
| 78 | 78 | "vermelho":{ |
| 79 | - fillcolor: '100,100,100', | |
| 80 | - linecolor: '255,0,0', | |
| 79 | + fillcolor: '#E8ACAC', | |
| 80 | + linecolor: '#F50707', | |
| 81 | 81 | linewidth: '1', |
| 82 | - circcolor: '255,50,0', | |
| 83 | - textcolor: '200,200,200' | |
| 82 | + circcolor: '#F09EA6', | |
| 83 | + textcolor: '#787A78' | |
| 84 | 84 | }, |
| 85 | 85 | "verde":{ |
| 86 | - fillcolor: '100,100,100', | |
| 87 | - linecolor: '100,255,100', | |
| 86 | + fillcolor: '#3CCC2F', | |
| 87 | + linecolor: '#0C6642', | |
| 88 | 88 | linewidth: '1', |
| 89 | - circcolor: '0,255,0', | |
| 90 | - textcolor: '0,0,0' | |
| 89 | + circcolor: '#C7D9D2', | |
| 90 | + textcolor: '#787A78' | |
| 91 | 91 | } |
| 92 | 92 | }, |
| 93 | 93 | //@TODO remover apos refatorar codigo | ... | ... |