Commit aa736ba260c73a2300724dfbc347df9276a868c6

Authored by Edmar Moretti
1 parent 946a1c7a

Adaptação da rotina de cálculo de distância para OL3

Showing 1 changed file with 412 additions and 228 deletions   Show diff stats
js/analise.js
... ... @@ -21,18 +21,18 @@
21 21 */
22 22  
23 23 /**
24   - *
  24 + *
25 25 * Licença
26   - *
  26 + *
27 27 * GPL2
28   - *
  28 + *
29 29 * i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
30   - *
  30 + *
31 31 * Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com
32   - *
  32 + *
33 33 * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo sob os termos da Licença
34 34 * Pública Geral GNU conforme publicada pela Free Software Foundation;
35   - *
  35 + *
36 36 * Este programa é distribuído na expectativa de que seja útil, porém, SEM NENHUMA GARANTIA; nem mesmo a
37 37 * garantia implícita de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença
38 38 * Pública Geral do GNU para mais detalhes. Você deve ter recebido uma cópia da Licença Pública Geral do
... ... @@ -53,19 +53,19 @@ i3GEO.analise =
53 53 },
54 54 /**
55 55 * Classe: i3GEO.analise.dialogo
56   - *
  56 + *
57 57 * Abre as telas de diálogo das opções de análise
58   - *
  58 + *
59 59 * Exemplo:
60   - *
  60 + *
61 61 * Para abrir a mensagem de diálogo de geração de buffer, utilize
62   - *
  62 + *
63 63 * i3GEO.analise.dialogo.buffer()
64 64 */
65 65 dialogo : {
66 66 /**
67 67 * Function: markercluster
68   - *
  68 + *
69 69 * Ferramenta mapa agrupamento de pontos
70 70 */
71 71 markercluster : function() {
... ... @@ -78,7 +78,7 @@ i3GEO.analise =
78 78 },
79 79 /**
80 80 * Function: heatmap
81   - *
  81 + *
82 82 * Ferramenta mapa de calor
83 83 */
84 84 heatmap : function() {
... ... @@ -91,11 +91,11 @@ i3GEO.analise =
91 91 },
92 92 /**
93 93 * Function: saiku
94   - *
  94 + *
95 95 * Ferramenta SAIKU em nova aba do navegador
96 96 */
97 97 saiku : function() {
98   - if(i3GEO.parametros.statusFerramentas && i3GEO.parametros.statusFerramentas.saiku === false){
  98 + if (i3GEO.parametros.statusFerramentas && i3GEO.parametros.statusFerramentas.saiku === false) {
99 99 i3GEO.janela.tempoMsg($trad("naoInstalado"));
100 100 return;
101 101 }
... ... @@ -103,11 +103,11 @@ i3GEO.analise =
103 103 },
104 104 /**
105 105 * Function: saikuMapa
106   - *
  106 + *
107 107 * Ferramenta SAIKU em uma janela interna
108 108 */
109 109 saikuMapa : function() {
110   - if(i3GEO.parametros.statusFerramentas && i3GEO.parametros.statusFerramentas.saiku === false){
  110 + if (i3GEO.parametros.statusFerramentas && i3GEO.parametros.statusFerramentas.saiku === false) {
111 111 i3GEO.janela.tempoMsg($trad("naoInstalado"));
112 112 return;
113 113 }
... ... @@ -119,7 +119,7 @@ i3GEO.analise =
119 119 "i3GEOF.saiku.iniciaJanelaFlutuante2()");
120 120 },
121 121 /**
122   - *
  122 + *
123 123 * Ferramenta graficointerativo versao flash
124 124 */
125 125 graficoInterativo : function() {
... ... @@ -127,7 +127,7 @@ i3GEO.analise =
127 127 },
128 128 /**
129 129 * Function: graficoInterativo1
130   - *
  130 + *
131 131 * Ferramenta gráfico interativo
132 132 */
133 133 graficoInterativo1 : function() {
... ... @@ -140,7 +140,7 @@ i3GEO.analise =
140 140 },
141 141 /**
142 142 * Function: linhaDoTempo
143   - *
  143 + *
144 144 * Ferramenta linha do tempo
145 145 */
146 146 linhaDoTempo : function() {
... ... @@ -174,9 +174,15 @@ i3GEO.analise =
174 174 doc = document.frames("i3GEOF.linhaDoTempoi").document;
175 175 }
176 176 }
177   - doc.getElementById("tl") ? window.parent["i3GEOF.linhaDoTempoi"].carregaDados() : i3GEO.eventos.removeEventos("NAVEGAMAPA",["i3GEO.analise.atualizaLinhaDoTempo()"]);
  177 + doc.getElementById("tl") ? window.parent["i3GEOF.linhaDoTempoi"].carregaDados() : i3GEO.eventos.removeEventos(
  178 + "NAVEGAMAPA",
  179 + [
  180 + "i3GEO.analise.atualizaLinhaDoTempo()"
  181 + ]);
178 182 } catch (e) {
179   - i3GEO.eventos.removeEventos("NAVEGAMAPA",["i3GEO.analise.atualizaLinhaDoTempo()"]);
  183 + i3GEO.eventos.removeEventos("NAVEGAMAPA", [
  184 + "i3GEO.analise.atualizaLinhaDoTempo()"
  185 + ]);
180 186 }
181 187 };
182 188 i3GEO.eventos.adicionaEventos("NAVEGAMAPA", [
... ... @@ -190,7 +196,7 @@ i3GEO.analise =
190 196 },
191 197 /**
192 198 * Function: perfil
193   - *
  199 + *
194 200 * Ferramenta perfil
195 201 */
196 202 perfil : function() {
... ... @@ -198,11 +204,11 @@ i3GEO.analise =
198 204 },
199 205 /**
200 206 * Function: melhorcaminho
201   - *
  207 + *
202 208 * Ferramenta melhor caminho
203 209 */
204 210 melhorcaminho : function() {
205   - if(i3GEO.parametros.statusFerramentas && i3GEO.parametros.statusFerramentas.melhorcaminho === false){
  211 + if (i3GEO.parametros.statusFerramentas && i3GEO.parametros.statusFerramentas.melhorcaminho === false) {
206 212 i3GEO.janela.tempoMsg($trad("naoInstalado"));
207 213 return;
208 214 }
... ... @@ -210,7 +216,7 @@ i3GEO.analise =
210 216 },
211 217 /**
212 218 * Function: gradePontos
213   - *
  219 + *
214 220 * Ferramenta grade de pontos
215 221 */
216 222 gradePontos : function() {
... ... @@ -218,7 +224,7 @@ i3GEO.analise =
218 224 },
219 225 /**
220 226 * Function: gradePol
221   - *
  227 + *
222 228 * Ferramenta grade de polígonos
223 229 */
224 230 gradePol : function() {
... ... @@ -226,7 +232,7 @@ i3GEO.analise =
226 232 },
227 233 /**
228 234 * Function: gradeHex
229   - *
  235 + *
230 236 * Ferramenta grade de hexágonos
231 237 */
232 238 gradeHex : function() {
... ... @@ -234,7 +240,7 @@ i3GEO.analise =
234 240 },
235 241 /**
236 242 * Function: analisaGeometrias
237   - *
  243 + *
238 244 * Ferramenta de análise de geometrias
239 245 */
240 246 analisaGeometrias : function() {
... ... @@ -247,7 +253,7 @@ i3GEO.analise =
247 253 },
248 254 /**
249 255 * Function: pontosdistri
250   - *
  256 + *
251 257 * Ferramenta de cálculo de distribuição de pontos
252 258 */
253 259 pontosdistri : function() {
... ... @@ -260,7 +266,7 @@ i3GEO.analise =
260 266 },
261 267 /**
262 268 * Function: pontoempoligono
263   - *
  269 + *
264 270 * Ferramenta ponto em polígono
265 271 */
266 272 pontoempoligono : function() {
... ... @@ -273,7 +279,7 @@ i3GEO.analise =
273 279 },
274 280 /**
275 281 * Function: centromassa
276   - *
  282 + *
277 283 * Ferramenta centro médio
278 284 */
279 285 centromassa : function() {
... ... @@ -286,7 +292,7 @@ i3GEO.analise =
286 292 },
287 293 /**
288 294 * Function: nptPol
289   - *
  295 + *
290 296 * Ferramenta número de pontos em polígono
291 297 */
292 298 nptPol : function() {
... ... @@ -299,7 +305,7 @@ i3GEO.analise =
299 305 },
300 306 /**
301 307 * Function: buffer
302   - *
  308 + *
303 309 * Ferramenta buffer
304 310 */
305 311 buffer : function() {
... ... @@ -312,7 +318,7 @@ i3GEO.analise =
312 318 },
313 319 /**
314 320 * Function: distanciaptpt
315   - *
  321 + *
316 322 * Ferramenta distância entre pontos
317 323 */
318 324 distanciaptpt : function() {
... ... @@ -325,7 +331,7 @@ i3GEO.analise =
325 331 },
326 332 /**
327 333 * Function: centroide
328   - *
  334 + *
329 335 * Ferramenta centróide
330 336 */
331 337 centroide : function() {
... ... @@ -338,7 +344,7 @@ i3GEO.analise =
338 344 },
339 345 /**
340 346 * Function: dissolve
341   - *
  347 + *
342 348 * Ferramenta dissolve bordas comuns
343 349 */
344 350 dissolve : function() {
... ... @@ -351,7 +357,7 @@ i3GEO.analise =
351 357 },
352 358 /**
353 359 * Function: agrupaElementos
354   - *
  360 + *
355 361 * Ferramenta agrupa elementos
356 362 */
357 363 agrupaElementos : function() {
... ... @@ -365,7 +371,7 @@ i3GEO.analise =
365 371 },
366 372 /**
367 373 * Section: medeDistancia
368   - *
  374 + *
369 375 * Ativa e controla a opção de medição de distâncias. A medida é feita quando o
370 376 * usuário clica no mapa com esta opção ativa. Quando o botão e acionado, abre-se a janela que mostra o
371 377 * resultado da medida, o ícone que segue o mouse é alterado. Para mostrar o resultado do cálculo, é
... ... @@ -386,7 +392,7 @@ i3GEO.analise =
386 392 ultimaMedida : "",
387 393 /**
388 394 * Function: inicia
389   - *
  395 + *
390 396 * Inicia a operação de medição, abrindo a janela de resultados e criando os componentes
391 397 * necessários. São registrados os eventos de clique sobre o mapa e fechamento da janela de resultados
392 398 */
... ... @@ -408,19 +414,30 @@ i3GEO.analise =
408 414 novoel = document.createElement("div");
409 415 novoel.id = "mostradistancia";
410 416 ins =
411   - '<div class="hd" style="font-size:11px"><div class="i3GeoTituloJanela">'+$trad("distAprox")+'<a class=ajuda_usuario target=_blank href="'
412   - + i3GEO.configura.locaplic + '/ajuda_usuario.php?idcategoria=6&idajuda=50" ><b> </b></a></div></div>'
  417 + '<div class="hd" style="font-size:11px"><div class="i3GeoTituloJanela">' + $trad("distAprox")
  418 + + '<a class=ajuda_usuario target=_blank href="'
  419 + + i3GEO.configura.locaplic
  420 + + '/ajuda_usuario.php?idcategoria=6&idajuda=50" ><b> </b></a></div></div>'
413 421 + '<div class="bd" style="text-align:left;padding:3px;" >'
414 422 + '<div style="text-align:left;padding:3px;" id="mostradistancia_calculo" ></div>'
415 423 + '<div style="text-align:left;padding:3px;" id="mostradistancia_calculo_movel" ></div>'
416 424 + '<div style="text-align:left;font-size:10px" >'
417   - + '<span style="color:navy;cursor:pointer;text-align:left;" >' + '<table class="lista7" style="width:250px">' + '<tr>'
418   - + '<td><input style="cursor:pointer" type="checkbox" id="pararraios" checked /></td>' + '<td>Raios</td>'
419   - + '<td>&nbsp;</td>' + '<td><input style="cursor:pointer" type="checkbox" id="parartextos" checked /></td>'
420   - + '<td>Textos<td>' + '<td>&nbsp;Estilo:</td>' + '<td><div class=styled-select style="width:85px;">'
421   - + i3GEO.desenho.caixaEstilos() + '</div></td></tr>'
  425 + + '<span style="color:navy;cursor:pointer;text-align:left;" >'
  426 + + '<table class="lista7" style="width:250px">'
  427 + + '<tr>'
  428 + + '<td><input style="cursor:pointer" type="checkbox" id="pararraios" checked /></td>'
  429 + + '<td>Raios</td>'
  430 + + '<td>&nbsp;</td>'
  431 + + '<td><input style="cursor:pointer" type="checkbox" id="parartextos" checked /></td>'
  432 + + '<td>Textos<td>'
  433 + + '<td>&nbsp;Estilo:</td>'
  434 + + '<td><div class=styled-select style="width:85px;">'
  435 + + i3GEO.desenho.caixaEstilos()
  436 + + '</div></td></tr>'
422 437 + '<tr><td></td><td></td>'
423   - + '<td></td><td></td><td></td><td></td><td>&nbsp;<input id=i3GEObotaoPerfil size="22" type="button" value="perfil"></td><td>&nbsp;<input id=i3GEObotaoDistWkt size="22" type="button" value="incorporar"></td></tr></table></span>' + '</div>' + '</div>';
  438 + + '<td></td><td></td><td></td><td></td><td>&nbsp;<input id=i3GEObotaoPerfil size="22" type="button" value="perfil"></td><td>&nbsp;<input id=i3GEObotaoDistWkt size="22" type="button" value="incorporar"></td></tr></table></span>'
  439 + + '</div>'
  440 + + '</div>';
424 441 novoel.innerHTML = ins;
425 442 novoel.style.borderColor = "gray";
426 443 document.body.appendChild(novoel);
... ... @@ -496,146 +513,162 @@ i3GEO.analise =
496 513 * Funcoes especificas da interface openlayers
497 514 */
498 515 openlayers : {
  516 + draw : "",
  517 + featureListener : null,
  518 + //numero de pontos da geometria atual
  519 + //utilizado para saber se houve um clique ou nao
  520 + numpontos : 0,
  521 + removeControle : function() {
  522 + i3geoOL.removeInteraction(i3GEO.analise.medeDistancia.openlayers.draw);
  523 + i3GEO.analise.medeDistancia.openlayers.draw = "";
  524 + },
499 525 /**
500 526 * Inicializa o processo Cria a variavel para guardar os pontos Executa a funcao de inicializacao do desenho, que cria o
501 527 * layer para receber os graficos
502 528 */
503 529 inicia : function() {
504   - var linha, estilo = i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao], controle =
505   - i3geoOL.getControlsBy("id", "i3GeoMedeDistancia");
  530 + var m = i3GEO.analise.medeDistancia.openlayers;
506 531 i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia();
507   - i3GEO.analise.medeDistancia.pontos = {
508   - xpt : [],
509   - ypt : [],
510   - dist : []
511   - };
512   - if (controle.length === 0) {
513   - linha =
514   - new OpenLayers.Control.DrawFeature(i3GEO.desenho.layergrafico, OpenLayers.Handler.Path, {
515   - autoActivate : true,
516   - id : "i3GeoMedeDistancia",
517   - type : OpenLayers.Control.TYPE_TOOL,
518   - callbacks : {
519   - done : function(feature) {
520   - var t, f = new OpenLayers.Feature.Vector(feature, {
521   - origem : "medeDistancia"
522   - }, {
523   - graphicName : "square",
524   - pointRadius : 10,
525   - graphicOpacity : 1,
526   - strokeWidth : estilo.linewidth,
527   - strokeColor : estilo.linecolor
528   - });
529   - i3GEO.desenho.layergrafico.addFeatures([
530   - f
531   - ]);
532   - if (i3GEO.Interface) {
533   - i3GEO.Interface.openlayers.sobeLayersGraficos();
534   - }
535   - i3GEO.analise.medeDistancia.openlayers.mostraParcial(0, 0, 0);
536   - i3GEO.analise.medeDistancia.ultimoWkt = i3GEO.analise.medeDistancia.pontos2wkt();
537   - t = i3GEO.analise.medeDistancia.openlayers.somaDist();
538   - t = t.toFixed(3) + " km";
539   - i3GEO.analise.medeDistancia.ultimaMedida = t;
540   - i3GEO.analise.medeDistancia.openlayers.inicia();
541   - },
542   - modify : function(point) {
543   - var n, x1, y1, x2, y2, trecho, parcial, direcao;
544   - n = i3GEO.analise.medeDistancia.pontos.ypt.length;
545   - if (n > 0) {
546   - x1 = i3GEO.analise.medeDistancia.pontos.xpt[n - 1];
547   - y1 = i3GEO.analise.medeDistancia.pontos.ypt[n - 1];
548   - x2 = point.x;
549   - y2 = point.y;
550   - // projeta
551   - if (i3GEO.Interface.openlayers.googleLike) {
552   - temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2);
553   - temp = temp.split(" ");
554   - x1 = temp[0];
555   - y1 = temp[1];
556   - x2 = temp[2];
557   - y2 = temp[3];
558   - }
559   - trecho = i3GEO.calculo.distancia(x1, y1, x2, y2);
560   - parcial = i3GEO.analise.medeDistancia.openlayers.somaDist();
561   - direcao = i3GEO.calculo.direcao(x1, y1, x2, y2);
562   - direcao = i3GEO.calculo.dd2dms(direcao, direcao);
563   - direcao = direcao[0];
564   - i3GEO.analise.medeDistancia.openlayers.mostraParcial(trecho, parcial, direcao);
565   - }
566   - },
567   - point : function(point) {
568   - var n, x1, y1, x2, y2, trecho, temp, circ, label, raio, pontoRaio,
569   - // registra os pontos e calcula a distancia
570   - total = 0;
571   - i3GEO.analise.medeDistancia.pontos.xpt.push(point.x);
572   - i3GEO.analise.medeDistancia.pontos.ypt.push(point.y);
573   - i3GEO.analise.pontos.xpt.push(point.x);
574   - i3GEO.analise.pontos.ypt.push(point.y);
575   - n = i3GEO.analise.medeDistancia.pontos.ypt.length;
576   - if (n > 1) {
577   - x1 = i3GEO.analise.medeDistancia.pontos.xpt[n - 2];
578   - y1 = i3GEO.analise.medeDistancia.pontos.ypt[n - 2];
579   - x2 = point.x;
580   - y2 = point.y;
581   - raio = point.distanceTo(new OpenLayers.Geometry.Point(x1, y1));
582   - pontoRaio = new OpenLayers.Geometry.Point(x1, y1);
583   - // projeta
584   - if (i3GEO.Interface.openlayers.googleLike) {
585   - temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2);
586   - temp = temp.split(" ");
587   - x1 = temp[0];
588   - y1 = temp[1];
589   - x2 = temp[2];
590   - y2 = temp[3];
591   - }
592   - trecho = i3GEO.calculo.distancia(x1, y1, x2, y2);
593   - i3GEO.analise.medeDistancia.pontos.dist.push(trecho);
594   - total = i3GEO.analise.medeDistancia.openlayers.somaDist();
595   - i3GEO.analise.medeDistancia.openlayers.mostraTotal(trecho, total);
596   - // raio
597   - if ($i("pararraios") && $i("pararraios").checked === true) {
598   - circ =
599   - new OpenLayers.Feature.Vector(OpenLayers.Geometry.Polygon.createRegularPolygon(
600   - pontoRaio,
601   - raio,
602   - 30), {
603   - origem : "medeDistanciaExcluir"
604   - }, {
605   - fill : false,
606   - strokeColor : estilo.circcolor,
607   - strokeWidth : 1
608   - });
609   - i3GEO.desenho.layergrafico.addFeatures([
610   - circ
611   - ]);
612   - }
613   - // desenha ponto
614   - if ($i("parartextos") && $i("parartextos").checked === true) {
615   - label = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(point.x, point.y), {
616   - origem : "medeDistanciaExcluir"
617   - }, {
618   - graphicName : "square",
619   - pointRadius : 3,
620   - strokeColor : "black",
621   - graphicOpacity : 1,
622   - strokeWidth : 1,
623   - fillColor : "white",
624   - label : trecho.toFixed(3),
625   - labelAlign : "rb",
626   - fontColor : estilo.textcolor,
627   - fontSize : 12,
628   - fontWeight : "bold"
629   - });
630   - i3GEO.desenho.layergrafico.addFeatures([
631   - label
632   - ]);
633   - }
634   - }
635   - }
636   - }
  532 + m.removeControle();
  533 + m.draw = new ol.interaction.Draw({
  534 + type : "LineString"
  535 + });
  536 + i3GEO.Interface.openlayers.interacoes[0].setActive(false);
  537 + m.draw.on("drawend", function(evt) {
  538 + evt.feature.setProperties({
  539 + origem : "medeDistancia"
  540 + });
  541 + var m = i3GEO.analise.medeDistancia.openlayers;
  542 + i3GEO.desenho.layergrafico.getSource().addFeature(evt.feature);
  543 + m.draw.setActive(false);
  544 + m.draw.setActive(true);
  545 + });
  546 + i3GEO.analise.medeDistancia.openlayers.draw.on('drawstart', function(evt) {
  547 + i3GEO.analise.medeDistancia.pontos = {
  548 + xpt : [],
  549 + ypt : [],
  550 + dist : []
  551 + };
  552 + // set sketch
  553 + var m = i3GEO.analise.medeDistancia.openlayers,
  554 + sketch = evt.feature;
  555 +
  556 + m.numpontos = 1;
  557 +
  558 + m.featureListener = sketch.getGeometry().on('change', function(evt) {
  559 + var ponto,
  560 + geom = evt.target,
  561 + coords = geom.getCoordinates();
  562 + n = coords.length,
  563 + m = i3GEO.analise.medeDistancia.openlayers;
  564 + ponto = new ol.geom.Point(coords[n-1]);
  565 + if(m.numpontos === n-1){
  566 + //clicou
  567 + m.numpontos = n;
  568 + m.point(ponto);
  569 + }
  570 + else{
  571 + m.modify(ponto);
  572 + }
  573 + });
  574 + });
  575 + i3geoOL.addInteraction(m.draw);
  576 + },
  577 + modify : function(point) {
  578 + var n, x1, y1, x2, y2, trecho, parcial, direcao,
  579 + coord = point.getCoordinates();
  580 + n = i3GEO.analise.medeDistancia.pontos.ypt.length;
  581 + if (n > 0) {
  582 + x1 = i3GEO.analise.medeDistancia.pontos.xpt[n - 1];
  583 + y1 = i3GEO.analise.medeDistancia.pontos.ypt[n - 1];
  584 + x2 = coord[0];
  585 + y2 = coord[1];
  586 + // projeta
  587 + if (i3GEO.Interface.openlayers.googleLike) {
  588 + temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2);
  589 + temp = temp.split(" ");
  590 + x1 = temp[0];
  591 + y1 = temp[1];
  592 + x2 = temp[2];
  593 + y2 = temp[3];
  594 + }
  595 + trecho = i3GEO.calculo.distancia(x1, y1, x2, y2);
  596 + parcial = i3GEO.analise.medeDistancia.openlayers.somaDist();
  597 + direcao = i3GEO.calculo.direcao(x1, y1, x2, y2);
  598 + direcao = i3GEO.calculo.dd2dms(direcao, direcao);
  599 + direcao = direcao[0];
  600 + i3GEO.analise.medeDistancia.openlayers.mostraParcial(trecho, parcial, direcao);
  601 + }
  602 + },
  603 + point : function(point) {
  604 + var n, x1, y1, x2, y2, trecho, temp, circ, label, raio, pontoRaio,
  605 + coord = point.getCoordinates();
  606 + total = 0;
  607 + i3GEO.analise.medeDistancia.pontos.xpt.push(coord[0]);
  608 + i3GEO.analise.medeDistancia.pontos.ypt.push(coord[1]);
  609 + i3GEO.analise.pontos.xpt.push(coord[0]);
  610 + i3GEO.analise.pontos.ypt.push(coord[1]);
  611 + n = i3GEO.analise.medeDistancia.pontos.ypt.length;
  612 + if (n > 1) {
  613 + x1 = i3GEO.analise.medeDistancia.pontos.xpt[n - 2];
  614 + y1 = i3GEO.analise.medeDistancia.pontos.ypt[n - 2];
  615 + x2 = coord[0];
  616 + y2 = coord[1];
  617 + //raio = point.distanceTo(new OpenLayers.Geometry.Point(x1, y1));
  618 + //pontoRaio = new OpenLayers.Geometry.Point(x1, y1);
  619 + // projeta
  620 + if (i3GEO.Interface.openlayers.googleLike) {
  621 + temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2);
  622 + temp = temp.split(" ");
  623 + x1 = temp[0];
  624 + y1 = temp[1];
  625 + x2 = temp[2];
  626 + y2 = temp[3];
  627 + }
  628 + trecho = i3GEO.calculo.distancia(x1, y1, x2, y2);
  629 + i3GEO.analise.medeDistancia.pontos.dist.push(trecho);
  630 + total = i3GEO.analise.medeDistancia.openlayers.somaDist();
  631 + i3GEO.analise.medeDistancia.openlayers.mostraTotal(trecho, total);
  632 + /*
  633 + // raio
  634 + if ($i("pararraios") && $i("pararraios").checked === true) {
  635 + circ =
  636 + new OpenLayers.Feature.Vector(OpenLayers.Geometry.Polygon.createRegularPolygon(
  637 + pontoRaio,
  638 + raio,
  639 + 30), {
  640 + origem : "medeDistanciaExcluir"
  641 + }, {
  642 + fill : false,
  643 + strokeColor : estilo.circcolor,
  644 + strokeWidth : 1
  645 + });
  646 + i3GEO.desenho.layergrafico.addFeatures([
  647 + circ
  648 + ]);
  649 + }
  650 + // desenha ponto
  651 + if ($i("parartextos") && $i("parartextos").checked === true) {
  652 + label = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(point.x, point.y), {
  653 + origem : "medeDistanciaExcluir"
  654 + }, {
  655 + graphicName : "square",
  656 + pointRadius : 3,
  657 + strokeColor : "black",
  658 + graphicOpacity : 1,
  659 + strokeWidth : 1,
  660 + fillColor : "white",
  661 + label : trecho.toFixed(3),
  662 + labelAlign : "rb",
  663 + fontColor : estilo.textcolor,
  664 + fontSize : 12,
  665 + fontWeight : "bold"
637 666 });
638   - i3geoOL.addControl(linha);
  667 + i3GEO.desenho.layergrafico.addFeatures([
  668 + label
  669 + ]);
  670 + }
  671 + */
639 672 }
640 673 },
641 674 /**
... ... @@ -654,22 +687,30 @@ i3GEO.analise =
654 687 * atributo "origem" Os raios e pontos sao sempre removidos
655 688 */
656 689 fechaJanela : function() {
657   - var temp, controle = i3geoOL.getControlsBy("id", "i3GeoMedeDistancia"), f =
658   - i3GEO.desenho.layergrafico.getFeaturesByAttribute("origem", "medeDistancia");
659   - if (controle.length > 0) {
660   - controle[0].deactivate();
661   - i3geoOL.removeControl(controle[0]);
  690 + var m = i3GEO.analise.medeDistancia.openlayers;
  691 + ol.Observable.unByKey(m.featureListener);
  692 + m.featureListener = null;
  693 + m.removeControle();
  694 + m.numpontos = 0;
  695 + i3GEO.eventos.cliquePerm.ativa();
  696 +
  697 + var features, n, f, i, remover = [], temp;
  698 + features = i3GEO.desenho.layergrafico.getSource().getFeatures();
  699 + n = features.length;
  700 + for (i = 0; i < n; i++) {
  701 + f = features[i];
  702 + if (f.getProperties().origem === "medeDistancia" || f.getProperties().origem === "medeDistanciaExcluir") {
  703 + remover.push(f);
  704 + }
662 705 }
663   - if (f && f.length > 0) {
  706 + if (remover.length > 0) {
664 707 temp = window.confirm($trad("x94"));
665 708 if (temp) {
666   - i3GEO.desenho.layergrafico.destroyFeatures(f);
  709 + for (r in remover) {
  710 + i3GEO.desenho.layergrafico.getSource().removeFeature(remover[r]);
  711 + }
667 712 }
668 713 }
669   - f = i3GEO.desenho.layergrafico.getFeaturesByAttribute("origem", "medeDistanciaExcluir");
670   - if (f && f.length > 0) {
671   - i3GEO.desenho.layergrafico.destroyFeatures(f);
672   - }
673 714 },
674 715 /**
675 716 * Mostra a totalizacao das linhas ja digitalizadas
... ... @@ -678,8 +719,19 @@ i3GEO.analise =
678 719 var mostra = $i("mostradistancia_calculo"), texto;
679 720 if (mostra) {
680 721 texto =
681   - "<b>" + $trad("x96") + ":</b> " + total.toFixed(3) + " km" + "<br><b>" + $trad("x96") + ":</b> "
682   - + (total * 1000).toFixed(2) + " m" + "<br>" + $trad("x25") + ": " + i3GEO.calculo.metododistancia;
  722 + "<b>" + $trad("x96")
  723 + + ":</b> "
  724 + + total.toFixed(3)
  725 + + " km"
  726 + + "<br><b>"
  727 + + $trad("x96")
  728 + + ":</b> "
  729 + + (total * 1000).toFixed(2)
  730 + + " m"
  731 + + "<br>"
  732 + + $trad("x25")
  733 + + ": "
  734 + + i3GEO.calculo.metododistancia;
683 735 mostra.innerHTML = texto;
684 736 }
685 737 },
... ... @@ -690,8 +742,19 @@ i3GEO.analise =
690 742 var mostra = $i("mostradistancia_calculo_movel"), texto;
691 743 if (mostra) {
692 744 texto =
693   - "<b>" + $trad("x95") + ":</b> " + trecho.toFixed(3) + " km" + "<br><b>" + $trad("x97") + ":</b> "
694   - + (parcial + trecho).toFixed(3) + " km" + "<br><b>" + $trad("x23") + " (DMS):</b> " + direcao;
  745 + "<b>" + $trad("x95")
  746 + + ":</b> "
  747 + + trecho.toFixed(3)
  748 + + " km"
  749 + + "<br><b>"
  750 + + $trad("x97")
  751 + + ":</b> "
  752 + + (parcial + trecho).toFixed(3)
  753 + + " km"
  754 + + "<br><b>"
  755 + + $trad("x23")
  756 + + " (DMS):</b> "
  757 + + direcao;
695 758 mostra.innerHTML = texto;
696 759 }
697 760 }
... ... @@ -885,8 +948,19 @@ i3GEO.analise =
885 948 var mostra = $i("mostradistancia_calculo"), texto;
886 949 if (mostra) {
887 950 texto =
888   - "<b>" + $trad("x96") + ":</b> " + total.toFixed(3) + " km" + "<br><b>" + $trad("x96") + ":</b> "
889   - + (total * 1000).toFixed(2) + " m" + "<br>" + $trad("x25") + ": " + i3GEO.calculo.metododistancia;
  951 + "<b>" + $trad("x96")
  952 + + ":</b> "
  953 + + total.toFixed(3)
  954 + + " km"
  955 + + "<br><b>"
  956 + + $trad("x96")
  957 + + ":</b> "
  958 + + (total * 1000).toFixed(2)
  959 + + " m"
  960 + + "<br>"
  961 + + $trad("x25")
  962 + + ": "
  963 + + i3GEO.calculo.metododistancia;
890 964 mostra.innerHTML = texto;
891 965 }
892 966 },
... ... @@ -897,8 +971,19 @@ i3GEO.analise =
897 971 var mostra = $i("mostradistancia_calculo_movel"), texto;
898 972 if (mostra) {
899 973 texto =
900   - "<b>" + $trad("x95") + ":</b> " + trecho.toFixed(3) + " km" + "<br><b>" + $trad("x97") + ":</b> "
901   - + (parcial + trecho).toFixed(3) + " km" + "<br><b>" + $trad("x23") + " (DMS):</b> " + direcao;
  974 + "<b>" + $trad("x95")
  975 + + ":</b> "
  976 + + trecho.toFixed(3)
  977 + + " km"
  978 + + "<br><b>"
  979 + + $trad("x97")
  980 + + ":</b> "
  981 + + (parcial + trecho).toFixed(3)
  982 + + " km"
  983 + + "<br><b>"
  984 + + $trad("x23")
  985 + + " (DMS):</b> "
  986 + + direcao;
902 987 mostra.innerHTML = texto;
903 988 }
904 989 }
... ... @@ -998,9 +1083,15 @@ i3GEO.analise =
998 1083 if (temp) {
999 1084 i3GEO.desenho.googleearth.removePlacemark("divGeometriasTemp");
1000 1085 }
1001   - i3GEO.eventos.removeEventos("MOUSECLIQUE",["i3GEO.analise.medeDistancia.googleearth.clique()"]);
1002   - i3GEO.eventos.removeEventos("MOUSEMOVE",["i3GEO.analise.medeDistancia.movimento.googleearth()"]);
1003   - i3GEO.eventos.removeEventos("NAVEGAMAPA",["i3GEO.analise.medeDistancia.fechaJanela()"]);
  1086 + i3GEO.eventos.removeEventos("MOUSECLIQUE", [
  1087 + "i3GEO.analise.medeDistancia.googleearth.clique()"
  1088 + ]);
  1089 + i3GEO.eventos.removeEventos("MOUSEMOVE", [
  1090 + "i3GEO.analise.medeDistancia.movimento.googleearth()"
  1091 + ]);
  1092 + i3GEO.eventos.removeEventos("NAVEGAMAPA", [
  1093 + "i3GEO.analise.medeDistancia.fechaJanela()"
  1094 + ]);
1004 1095 },
1005 1096 /**
1006 1097 * Mostra a totalizacao das linhas ja digitalizadas
... ... @@ -1009,8 +1100,19 @@ i3GEO.analise =
1009 1100 var mostra = $i("mostradistancia_calculo"), texto;
1010 1101 if (mostra) {
1011 1102 texto =
1012   - "<b>" + $trad("x96") + ":</b> " + total.toFixed(3) + " km" + "<br><b>" + $trad("x96") + ":</b> "
1013   - + (total * 1000).toFixed(2) + " m" + "<br>" + $trad("x25") + ": " + i3GEO.calculo.metododistancia;
  1103 + "<b>" + $trad("x96")
  1104 + + ":</b> "
  1105 + + total.toFixed(3)
  1106 + + " km"
  1107 + + "<br><b>"
  1108 + + $trad("x96")
  1109 + + ":</b> "
  1110 + + (total * 1000).toFixed(2)
  1111 + + " m"
  1112 + + "<br>"
  1113 + + $trad("x25")
  1114 + + ": "
  1115 + + i3GEO.calculo.metododistancia;
1014 1116 mostra.innerHTML = texto;
1015 1117 }
1016 1118 },
... ... @@ -1021,8 +1123,19 @@ i3GEO.analise =
1021 1123 var mostra = $i("mostradistancia_calculo_movel"), texto;
1022 1124 if (mostra) {
1023 1125 texto =
1024   - "<b>" + $trad("x95") + ":</b> " + trecho.toFixed(3) + " km" + "<br><b>" + $trad("x97") + ":</b> "
1025   - + (parcial + trecho).toFixed(3) + " km" + "<br><b>" + $trad("x23") + " (DMS):</b> " + direcao;
  1126 + "<b>" + $trad("x95")
  1127 + + ":</b> "
  1128 + + trecho.toFixed(3)
  1129 + + " km"
  1130 + + "<br><b>"
  1131 + + $trad("x97")
  1132 + + ":</b> "
  1133 + + (parcial + trecho).toFixed(3)
  1134 + + " km"
  1135 + + "<br><b>"
  1136 + + $trad("x23")
  1137 + + " (DMS):</b> "
  1138 + + direcao;
1026 1139 mostra.innerHTML = texto;
1027 1140 }
1028 1141 }
... ... @@ -1030,14 +1143,14 @@ i3GEO.analise =
1030 1143 },
1031 1144 /**
1032 1145 * Section: medeArea
1033   - *
  1146 + *
1034 1147 * Ativa e controla a op&atilde;o de medi&ccedil;&atilde;o de &aacute;rea.
1035   - *
  1148 + *
1036 1149 * A medida &eacute; feita quando o usu&aacute;rio clica no mapa com esta op&ccedil;&atilde;o ativa
1037   - *
  1150 + *
1038 1151 * Quando o bot&atilde;o &eacute; acionado, abre-se a janela que mostra o resultado da medida, o &iacute;cone que segue o mouse
1039 1152 * &eacute; alterado.
1040   - *
  1153 + *
1041 1154 * Para mostrar o resultado do cálculo, é incluido um div específico.
1042 1155 */
1043 1156 medeArea : {
... ... @@ -1055,10 +1168,10 @@ i3GEO.analise =
1055 1168 ultimaMedida : "",
1056 1169 /**
1057 1170 * Function: inicia
1058   - *
  1171 + *
1059 1172 * Inicia a opera&ccedil;&atilde;o de medi&ccedil;&atilde;o, abrindo a janela de resultados e criando os componentes
1060 1173 * necess&aacute;rios
1061   - *
  1174 + *
1062 1175 * S&atilde;o registrados os eventos de clique sobre o mapa e fechamento da janela de resultados
1063 1176 */
1064 1177 inicia : function() {
... ... @@ -1075,14 +1188,17 @@ i3GEO.analise =
1075 1188 novoel = document.createElement("div");
1076 1189 novoel.id = "mostraarea";
1077 1190 ins =
1078   - '<div class="hd" ><div class="i3GeoTituloJanela">'+$trad("areaAprox")+'<a class=ajuda_usuario target=_blank href="' + i3GEO.configura.locaplic
  1191 + '<div class="hd" ><div class="i3GeoTituloJanela">' + $trad("areaAprox")
  1192 + + '<a class=ajuda_usuario target=_blank href="'
  1193 + + i3GEO.configura.locaplic
1079 1194 + '"/ajuda_usuario.php?idcategoria=6&idajuda=51" ><b> </b></a></div></div>'
1080 1195 + '<div class="bd" style="text-align:left;padding:3px;font-size:10px" >'
1081 1196 // + '<label class=paragrafo style="float:left;top:5px;position:relative;">Estilo:</label>'
1082 1197 // + '<div class=styled-select style="width:70px;">' + i3GEO.desenho.caixaEstilos() + '</div><br>'
1083 1198 + '<div style="text-align:left;padding:3px;font-size:10px" id="mostraarea_calculo" ></div>'
1084 1199 + '<div style="text-align:left;padding:3px;font-size:10px" id="mostraarea_calculo_parcial" ></div>'
1085   - + '<br><input id=i3GEObotaoAreaWkt size="22" type="button" value="incorporar">' + '</div>';
  1200 + + '<br><input id=i3GEObotaoAreaWkt size="22" type="button" value="incorporar">'
  1201 + + '</div>';
1086 1202 novoel.innerHTML = ins;
1087 1203 novoel.style.borderColor = "gray";
1088 1204 document.body.appendChild(novoel);
... ... @@ -1332,9 +1448,24 @@ i3GEO.analise =
1332 1448 var mostra = $i("mostraarea_calculo"), texto;
1333 1449 if (mostra) {
1334 1450 texto =
1335   - "<b>" + $trad("d21at") + ":</b> " + (area / 1000000).toFixed(3) + " km2" + "<br><b>" + $trad("d21at")
1336   - + ":</b> " + (area / 10000).toFixed(2) + " ha" + "<br><b>" + $trad("x98") + ":</b> " + (per).toFixed(2)
1337   - + " km" + "<br>" + $trad("x25") + ": " + i3GEO.calculo.metododistancia;
  1451 + "<b>" + $trad("d21at")
  1452 + + ":</b> "
  1453 + + (area / 1000000).toFixed(3)
  1454 + + " km2"
  1455 + + "<br><b>"
  1456 + + $trad("d21at")
  1457 + + ":</b> "
  1458 + + (area / 10000).toFixed(2)
  1459 + + " ha"
  1460 + + "<br><b>"
  1461 + + $trad("x98")
  1462 + + ":</b> "
  1463 + + (per).toFixed(2)
  1464 + + " km"
  1465 + + "<br>"
  1466 + + $trad("x25")
  1467 + + ": "
  1468 + + i3GEO.calculo.metododistancia;
1338 1469 mostra.innerHTML = texto;
1339 1470 i3GEO.analise.medeArea.ultimaMedida = (area / 1000000).toFixed(3) + " km2";
1340 1471 }
... ... @@ -1346,10 +1477,29 @@ i3GEO.analise =
1346 1477 var mostra = $i("mostraarea_calculo_parcial"), texto;
1347 1478 if (mostra) {
1348 1479 texto =
1349   - "<b>" + $trad("d21at") + ":</b> " + (area / 1000000).toFixed(3) + " km2" + "<br><b>" + $trad("d21at")
1350   - + ":</b> " + (area / 10000).toFixed(2) + " ha" + "<br><b>" + $trad("x95") + ":</b> " + trecho.toFixed(3)
1351   - + " km" + "<br><b>" + $trad("x98") + ":</b> " + (per).toFixed(3) + " km" + "<br><b>" + $trad("x23")
1352   - + " (DMS):</b> " + direcao;
  1480 + "<b>" + $trad("d21at")
  1481 + + ":</b> "
  1482 + + (area / 1000000).toFixed(3)
  1483 + + " km2"
  1484 + + "<br><b>"
  1485 + + $trad("d21at")
  1486 + + ":</b> "
  1487 + + (area / 10000).toFixed(2)
  1488 + + " ha"
  1489 + + "<br><b>"
  1490 + + $trad("x95")
  1491 + + ":</b> "
  1492 + + trecho.toFixed(3)
  1493 + + " km"
  1494 + + "<br><b>"
  1495 + + $trad("x98")
  1496 + + ":</b> "
  1497 + + (per).toFixed(3)
  1498 + + " km"
  1499 + + "<br><b>"
  1500 + + $trad("x23")
  1501 + + " (DMS):</b> "
  1502 + + direcao;
1353 1503 mostra.innerHTML = texto;
1354 1504 }
1355 1505 }
... ... @@ -1523,9 +1673,24 @@ i3GEO.analise =
1523 1673 var mostra = $i("mostraarea_calculo"), texto;
1524 1674 if (mostra) {
1525 1675 texto =
1526   - "<b>" + $trad("d21at") + ":</b> " + (area / 1000000).toFixed(3) + " km2" + "<br><b>" + $trad("d21at")
1527   - + ":</b> " + (area / 10000).toFixed(2) + " ha" + "<br><b>" + $trad("x98") + ":</b> " + (per).toFixed(2)
1528   - + " km" + "<br>" + $trad("x25") + ": " + i3GEO.calculo.metododistancia;
  1676 + "<b>" + $trad("d21at")
  1677 + + ":</b> "
  1678 + + (area / 1000000).toFixed(3)
  1679 + + " km2"
  1680 + + "<br><b>"
  1681 + + $trad("d21at")
  1682 + + ":</b> "
  1683 + + (area / 10000).toFixed(2)
  1684 + + " ha"
  1685 + + "<br><b>"
  1686 + + $trad("x98")
  1687 + + ":</b> "
  1688 + + (per).toFixed(2)
  1689 + + " km"
  1690 + + "<br>"
  1691 + + $trad("x25")
  1692 + + ": "
  1693 + + i3GEO.calculo.metododistancia;
1529 1694 mostra.innerHTML = texto;
1530 1695 i3GEO.analise.medeArea.ultimaMedida = (area / 1000000).toFixed(3) + " km2";
1531 1696 }
... ... @@ -1537,10 +1702,29 @@ i3GEO.analise =
1537 1702 var mostra = $i("mostraarea_calculo_parcial"), texto;
1538 1703 if (mostra) {
1539 1704 texto =
1540   - "<b>" + $trad("d21at") + ":</b> " + (area / 1000000).toFixed(3) + " km2" + "<br><b>" + $trad("d21at")
1541   - + ":</b> " + (area / 10000).toFixed(2) + " ha" + "<br><b>" + $trad("x95") + ":</b> " + trecho.toFixed(3)
1542   - + " km" + "<br><b>" + $trad("x98") + ":</b> " + (per).toFixed(3) + " km" + "<br><b>" + $trad("x23")
1543   - + " (DMS):</b> " + direcao;
  1705 + "<b>" + $trad("d21at")
  1706 + + ":</b> "
  1707 + + (area / 1000000).toFixed(3)
  1708 + + " km2"
  1709 + + "<br><b>"
  1710 + + $trad("d21at")
  1711 + + ":</b> "
  1712 + + (area / 10000).toFixed(2)
  1713 + + " ha"
  1714 + + "<br><b>"
  1715 + + $trad("x95")
  1716 + + ":</b> "
  1717 + + trecho.toFixed(3)
  1718 + + " km"
  1719 + + "<br><b>"
  1720 + + $trad("x98")
  1721 + + ":</b> "
  1722 + + (per).toFixed(3)
  1723 + + " km"
  1724 + + "<br><b>"
  1725 + + $trad("x23")
  1726 + + " (DMS):</b> "
  1727 + + direcao;
1544 1728 mostra.innerHTML = texto;
1545 1729 }
1546 1730 }
... ...