index.js
13.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
/*
Title: Grade de pontos
Cria e adiciona um novo tema ao mapa contendo uma grade de pontos com espaçamento regular.
Veja:
<i3GEO.analise.dialogo.gradePontos>
Arquivo:
i3geo/ferramentas/gradepontos/index.js.php
Licenca:
GPL2
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@gmail.com
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;
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'){
var i3GEOF = {};
}
/*
Classe: i3GEOF.gradeDePontos
*/
i3GEOF.gradeDePontos = {
/*
Variavel: aguarde
Estilo do objeto DOM com a imagem de aguarde existente no cabeçalho da janela.
*/
aguarde: "",
/*
Para efeitos de compatibilidade antes da versão 4.7 que não tinha dicionário
*/
criaJanelaFlutuante: function(){
i3GEOF.gradeDePontos.iniciaDicionario();
},
/*
Function: iniciaDicionario
Carrega o dicionário e chama a função que inicia a ferramenta
O Javascript é carregado com o id i3GEOF.nomedaferramenta.dicionario_script
*/
iniciaDicionario: function(){
if(typeof(i3GEOF.gradeDePontos.dicionario) === 'undefined'){
i3GEO.util.scriptTag(
i3GEO.configura.locaplic+"/ferramentas/gradepontos/dicionario.js",
"i3GEOF.gradeDePontos.iniciaJanelaFlutuante()",
"i3GEOF.gradeDePontos.dicionario_script"
);
}
else{
i3GEOF.gradeDePontos.iniciaJanelaFlutuante();
}
},
/*
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{
i3GEO.util.mudaCursor(i3GEO.configura.cursores,"default",i3GEO.Interface.IDMAPA,i3GEO.configura.locaplic);
$i(iddiv).innerHTML += i3GEOF.gradeDePontos.html();
i3GEOF.gradeDePontos.t0();
}
catch(erro){i3GEO.janela.tempoMsg(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 += '<div style="padding:5px;background-color:#F2F2F2;top:0px;left:0px;display:block;width:98%;" id="i3GEOgradedepontosresultado" >';
ins += '</div>';
ins += '<div style="top:10px;left:0px;display:block;width:98%;color:red" id="i3GEOgradedepontosfim" >';
ins += '</div>';
return ins;
},
/*
Function: iniciaJanelaFlutuante
Cria a janela flutuante para controle da ferramenta.
*/
iniciaJanelaFlutuante: function(){
var minimiza,cabecalho,janela,divid,titulo,temp;
if($i("i3GEOF.gradeDePontos")){
return;
}
//cria a janela flutuante
titulo = "<div class='i3GeoTituloJanela'>" + $trad("u8")+"<a class=ajuda_usuario target=_blank href='" + i3GEO.configura.locaplic + "/ajuda_usuario.php?idcategoria=3&idajuda=15' ><b> </b></a></div>";
cabecalho = function(){
i3GEO.barraDeBotoes.execBotao("pan");
};
minimiza = function(){
i3GEO.janela.minimiza("i3GEOF.gradeDePontos");
};
janela = i3GEO.janela.cria(
"400px",
"190px",
"",
"",
"",
titulo,
"i3GEOF.gradeDePontos",
false,
"hd",
cabecalho,
minimiza,
"",
false,
i3GEO.configura.locaplic+"/imagens/oxygen/16x16/accessories-calculator.png"
);
divid = janela[2].id;
janela[0].setFooter("<div id=i3GEOF.gradeDePontos_rodape class='i3GeoRodapeJanela' ></div>");
i3GEOF.gradeDePontos.aguarde = $i("i3GEOF.gradeDePontos_imagemCabecalho").style;
i3GEOF.gradeDePontos.inicia(divid);
temp = function(){
i3GEO.eventos.removeEventos("MOUSECLIQUE",["i3GEOF.gradeDePontos.capturaPonto()"]);
i3GEO.eventos.cliquePerm.ativa();
};
YAHOO.util.Event.addListener(janela[0].close, "click", temp);
},
t0: function()
{
var ins = "<img class=i3GeoExemploImg src='"+i3GEO.configura.locaplic+"/ferramentas/gradepontos/exemplo.png' />" +
"<p class='paragrafo' >"+$trad('ajuda',i3GEOF.gradeDePontos.dicionario) +
"<p class='paragrafo'>"+$trad('ajuda2',i3GEOF.gradeDePontos.dicionario) +
"<p class='paragrafo'>"+$trad('ajuda3',i3GEOF.gradeDePontos.dicionario) +
"<p class='paragrafo'><input type=checkbox id=i3GEOgradedepontosProj style='cursor:pointer;position:relative;top:2px;' /> "+$trad('projMercator',i3GEOF.gradeDePontos.dicionario);
i3GEO.util.proximoAnterior("","i3GEOF.gradeDePontos.t1()",ins,"i3GEOFgradeDePontost0","i3GEOgradedepontosresultado",true,"i3GEOF.gradeDePontos_rodape");
},
t1: function(){
var ins = "<p class='paragrafo'><b>"+$trad('espacamentoGrade',i3GEOF.gradeDePontos.dicionario)+"</b>";
if($i("i3GEOgradedepontosProj").checked){
ins += "<p class='paragrafo'>" + $trad('metros',i3GEOF.gradeDePontos.dicionario)+" X:";
ins += "<div class='i3geoForm i3geoFormIconeNumero' ><input id='i3GEOgradedepontosxg' title='metros' type=number value='100000'/></div>";
ins += "<br><p class='paragrafo'>"+$trad('metros',i3GEOF.gradeDePontos.dicionario)+" Y:";
ins += "<div class='i3geoForm i3geoFormIconeNumero' ><input id='i3GEOgradedepontosyg' title='metros' type=number value='100000'/></div>";
}
else{
ins += "<p class='paragrafo'>X: ";
ins += $trad('grau',i3GEOF.gradeDePontos.dicionario)+" - "+$trad('minuto',i3GEOF.gradeDePontos.dicionario)+" - "+$trad('segundo',i3GEOF.gradeDePontos.dicionario)+"</p>";
ins += "<div class='i3geoForm100 i3geoFormIconeLongitude' style='float:left;' ><input id='i3GEOgradedepontosxg' title='grau' type=text value='1'/></div>";
ins += "<div class='i3geoForm100 i3geoFormIconeMinuto' style='float:left;margin-left:10px;margin-right:10px;' ><input id='i3GEOgradedepontosxm' title='minuto' type=text value='00'/></div>";
ins += "<div class='i3geoForm100 i3geoFormIconeSegundo' style='margin-left:10px;' ><input id='i3GEOgradedepontosxs' title='segundo' type=text value='00.00'/></div>";
ins += "<br><p class='paragrafo'>Y: ";
ins += $trad('grau',i3GEOF.gradeDePontos.dicionario)+" - "+$trad('minuto',i3GEOF.gradeDePontos.dicionario)+" - "+$trad('segundo',i3GEOF.gradeDePontos.dicionario)+"</p>";
ins += "<div class='i3geoForm100 i3geoFormIconeLatitude' style='float:left;' ><input class=digitar id='i3GEOgradedepontosyg' title='grau' type=text value='1'/></div>";
ins += "<div class='i3geoForm100 i3geoFormIconeMinuto' style='float:left;margin-left:10px;' ><input id='i3GEOgradedepontosym' title='minuto' type=text value='00'/></div>";
ins += "<div class='i3geoForm100 i3geoFormIconeSegundo' style='float:left;margin-left:10px;' ><input id='i3GEOgradedepontosys' title='segundo' type=text value='00.00'/></div>";
}
i3GEO.util.proximoAnterior("i3GEOF.gradeDePontos.t0()","i3GEOF.gradeDePontos.t2()",ins,"i3GEOF.gradeDePontos.t1","i3GEOgradedepontosresultado",true,"i3GEOF.gradeDePontos_rodape");
},
t2: function(){
var ins = "<p class='paragrafo'><b>"+$trad('coord',i3GEOF.gradeDePontos.dicionario)+"</b>";
ins += "<p class='paragrafo'>X: ";
ins += $trad('grau',i3GEOF.gradeDePontos.dicionario)+" - "+$trad('minuto',i3GEOF.gradeDePontos.dicionario)+" - "+$trad('segundo',i3GEOF.gradeDePontos.dicionario)+"</p>";
ins += "<div class='i3geoForm100 i3geoFormIconeLongitude' style='float:left;' ><input id='i3GEOgradedepontosixg' title='grau' type=text value='1'/></div>";
ins += "<div class='i3geoForm100 i3geoFormIconeMinuto' style='float:left;margin-left:10px;margin-right:10px;' ><input id='i3GEOgradedepontosixm' title='minuto' type=text value='00'/></div>";
ins += "<div class='i3geoForm100 i3geoFormIconeSegundo' style='margin-left:10px;' ><input id='i3GEOgradedepontosixs' title='segundo' type=text value='00.00'/></div>";
ins += "<br><p class='paragrafo'>Y: ";
ins += $trad('grau',i3GEOF.gradeDePontos.dicionario)+" - "+$trad('minuto',i3GEOF.gradeDePontos.dicionario)+" - "+$trad('segundo',i3GEOF.gradeDePontos.dicionario)+"</p>";
ins += "<div class='i3geoForm100 i3geoFormIconeLatitude' style='float:left;' ><input id='i3GEOgradedepontosiyg' title='grau' type=text value='1'/></div>";
ins += "<div class='i3geoForm100 i3geoFormIconeMinuto' style='float:left;margin-left:10px;' ><input id='i3GEOgradedepontosiym' title='minuto' type=text value='00'/></div>";
ins += "<div class='i3geoForm100 i3geoFormIconeSegundo' style='float:left;margin-left:10px;' ><input id='i3GEOgradedepontosiys' title='segundo' type=text value='00.00'/></div>";
i3GEO.util.proximoAnterior("i3GEOF.gradeDePontos.t1()","i3GEOF.gradeDePontos.t3()",ins,"i3GEOF.gradeDePontos.t2","i3GEOgradedepontosresultado",true,"i3GEOF.gradeDePontos_rodape");
i3GEO.eventos.cliquePerm.desativa();
i3GEO.eventos.adicionaEventos("MOUSECLIQUE",["i3GEOF.gradeDePontos.capturaPonto()"]);
},
t3: function(){
var ins = "<p class='paragrafo'><b>"+$trad('numeroPontos',i3GEOF.gradeDePontos.dicionario)+"</b>";
ins += "<p class='paragrafo'>X</p>";
ins += "<div class='i3geoForm i3geoFormIconeNumero' ><input id='i3GEOgradedepontosnptx' title='pontos em x' type=number value='10'/></div>";
ins += "<br><p class='paragrafo'>Y";
ins += "<div class='i3geoForm i3geoFormIconeNumero' ><input id='i3GEOgradedepontosnpty' title='pontos em y' type=number value='10'/></div>";
i3GEO.util.proximoAnterior("i3GEOF.gradeDePontos.t2()","i3GEOF.gradeDePontos.t4()",ins,"i3GEOF.gradeDePontos.t3","i3GEOgradedepontosresultado",true,"i3GEOF.gradeDePontos_rodape");
},
t4: function(){
var b,ins = "<p class='paragrafo'><b>"+$trad('adicionaTema',i3GEOF.gradeDePontos.dicionario)+"</b>";
ins += "<p class='paragrafo'><input id=i3GEOgradedepontosbotao1 size=18 class=executar type='button' value='"+$trad('criaGrade',i3GEOF.gradeDePontos.dicionario)+"' />";
i3GEO.util.proximoAnterior("i3GEOF.gradeDePontos.t3()","",ins,"i3GEOF.gradeDePontos.t4","i3GEOgradedepontosresultado",true,"i3GEOF.gradeDePontos_rodape");
b = new YAHOO.widget.Button(
"i3GEOgradedepontosbotao1",
{onclick:{fn: i3GEOF.gradeDePontos.criaGrade}}
);
b.addClass("rodar");
},
/*
Function: criaGrade
Cria a grade e adiciona um novo tema ao mapa
Veja:
<GRADEDEPONTOS>
*/
criaGrade: function(){
try{
if(i3GEOF.gradeDePontos.aguarde.visibility === "visible")
{return;}
i3GEOF.gradeDePontos.aguarde.visibility = "visible";
var dx,dy,ix,iy,nptx,npty,fim,p,cp,proj="nao";
if(!$i("i3GEOgradedepontosProj").checked){
dx = i3GEO.calculo.dms2dd($i("i3GEOgradedepontosxg").value,$i("i3GEOgradedepontosxm").value,$i("i3GEOgradedepontosxs").value);
dy = i3GEO.calculo.dms2dd($i("i3GEOgradedepontosyg").value,$i("i3GEOgradedepontosym").value,$i("i3GEOgradedepontosys").value);
}
else{
proj = "sim";
dx = $i("i3GEOgradedepontosxg").value;
dy = $i("i3GEOgradedepontosyg").value;
}
ix = i3GEO.calculo.dms2dd($i("i3GEOgradedepontosixg").value,$i("i3GEOgradedepontosixm").value,$i("i3GEOgradedepontosixs").value);
iy = i3GEO.calculo.dms2dd($i("i3GEOgradedepontosiyg").value,$i("i3GEOgradedepontosiym").value,$i("i3GEOgradedepontosiys").value);
nptx = $i("i3GEOgradedepontosnptx").value;
npty = $i("i3GEOgradedepontosnpty").value;
if ((dx == 0) || (dy == 0))
{i3GEO.janela.tempoMsg($trad('msg',i3GEOF.gradeDePontos.dicionario));return;}
if ((nptx == 0) || (npty == 0))
{i3GEO.janela.tempoMsg($trad('msg',i3GEOF.gradeDePontos.dicionario));return;}
if (nptx * npty > 10000)
{i3GEO.janela.tempoMsg($trad('msg2',i3GEOF.gradeDePontos.dicionario));return;}
fim = function(retorno)
{
i3GEOF.gradeDePontos.aguarde.visibility = "hidden";
if (retorno.data == undefined )
{$i("i3GEOgradedepontosfim").innerHTML = "<p class='paragrafo'>Erro.";}
else
{i3GEO.atualiza("");}
};
p = i3GEO.configura.locaplic+"/ferramentas/gradepontos/exec.php?g_sid="+i3GEO.configura.sid+"&proj="+proj+"&funcao=gradedepontos&xdd="+dx+"&ydd="+dy+"&px="+ix+"&py="+iy+"&nptx="+nptx+"&npty="+npty;
cp = new cpaint();
cp.set_response_type("JSON");
cp.call(p,"gradeDePontos",fim);
}
catch(e){$i("i3GEOgradedepontosfim").innerHTML = "<p class='paragrafo' >Erro. "+e;i3GEO.janela.fechaAguarde();i3GEOF.gradeDePontos.aguarde.visibility = "hidden";}
},
/*
Function: capturaPonto
Captura um ponto no mapa e preenche os campos de coordenadas de início da grade
*/
capturaPonto: function(){
i3GEO.eventos.cliqueCapturaPt(
"i3GEOgradedepontosixg",
"i3GEOgradedepontosixm",
"i3GEOgradedepontosixs",
"i3GEOgradedepontosiyg",
"i3GEOgradedepontosiym",
"i3GEOgradedepontosiys"
);
}
};