Commit 2de66c6cf57c73cd3ab5cd02461aa4eb09467a29

Authored by Edmar Moretti
1 parent b7bde244

-

Showing 2 changed files with 0 additions and 4363 deletions   Show diff stats
js/editorgm.js
... ... @@ -1,2056 +0,0 @@
1   -//TODO documentar
2   -//TODO incluir balao de informacoes como um elemento grafico de desenho
3   -//TODO incluir caixas de texto
4   -//TODO incluir undo na edicao
5   -
6   -/*
7   - Editor vetorial de limites para a interface google maps
8   -
9   - Utilizado em i3geo/metaestat/editorlimites.php
10   -
11   - Utiliza a API do Google Maps e pacotes/wicket/wicket.js (que cria o objeto Wkt com funcoes para processamento de Wkt)
12   -
13   - Licenca:
14   -
15   - GPL2
16   -
17   - i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
18   -
19   - Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil
20   - Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com
21   -
22   - Esse programa utiliza parcialmente os codigos da aplicacao calculadora de carbono desenvolvido pelo
23   - IPAM - Instituto de Pesquisa Ambiental da Amazonia
24   -
25   - Este programa e software livre; voce pode redistribui-lo
26   - e/ou modifica-lo sob os termos da Licenca Publica Geral
27   - GNU conforme publicada pela Free Software Foundation;
28   -
29   - Este programa e distribuido na expectativa de que seja util,
30   - porem, SEM NENHUMA GARANTIA; nem mesmo a garantia implicita
31   - de COMERCIABILIDADE OU ADEQUACAO A UMA FINALIDADE ESPECIFICA.
32   - Consulte a Licenca Publica Geral do GNU para mais detalhes.
33   - Voce deve ter recebido uma copia da Licenca Publica Geral do
34   - GNU junto com este programa; se nao, escreva para a
35   - Free Software Foundation, Inc., no endereco
36   - 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
37   - */
38   -//
39   -if (typeof (i3GEO) === 'undefined') {
40   - var i3GEO = {};
41   -}
42   -/*
43   - * Classe i3GEO.editorGM
44   - *
45   - * Funções de edição vetorial utilizadas pelo editor de regiões do sistema METAESTAT
46   - */
47   -i3GEO.editorGM =
48   - {
49   - iconePonto : function(sel) {
50   - if (sel) {
51   - return i3GEO.configura.locaplic + "/imagens/google/symbol_middot_y.png";
52   - } else {
53   - return i3GEO.configura.locaplic + "/imagens/google/symbol_middot.png";
54   - }
55   - },
56   - /**
57   - * Objeto DOM com a imagem de aguarde existente no cabecalho da janela
58   - *
59   - */
60   - aguarde : "",
61   - /**
62   - * Guarda o Id do DIV que recebera o conteudo HTML do editor
63   - */
64   - iddiv : "",
65   - /**
66   - * Objeto criado com new google.maps.drawing.DrawingManager
67   - */
68   - drawingManager : "",
69   - selectedShape : null,
70   - /**
71   - * guarda o mapeamento entre o codigo da regiao e o codigo do layer adicionado ao mapa
72   - */
73   - regioestemas : {},
74   - /**
75   - * Guarda o mapeamento entre o codigo da regiao e o codigo do layer adicionado ao mapa
76   - */
77   - temasregioes : {},
78   - /**
79   - * Guarda os dados descritivos sobre cada regiao obtidos na formacao no combo de escolha de regioes
80   - */
81   - descregioes : [],
82   - /**
83   - * Inicia o editor
84   - *
85   - * Cria o objeto da API do Google Maps com new google.maps.drawing.DrawingManager A janela flutuante que recebera os componentes do
86   - * editor ja deve estar aberta (veja editorlimites.php) Executa i3GEO.editorGM.html
87   - *
88   - * @param Id
89   - * do DIV que recebera o conteudo HTML do editor
90   - */
91   - inicia : function(iddiv) {
92   - var i, n, ics;
93   - // mensagem
94   - // i3GEO.janela.tempoMsg("Atenção: apenas tabelas no esquema i3geo_metaestat podem ser editadas.");
95   - i3GEO.editorGM.iddiv = iddiv;
96   - $i(iddiv).innerHTML = i3GEO.editorGM.html();
97   - ics = $i(iddiv).getElementsByTagName("button");
98   - n = ics.length;
99   - i3GEO.barraDeBotoes.ativaBotoes();
100   - i3GEO.editorGM.comboRegiaoEditavel();
101   - for (i = 0; i < n; i++) {
102   - ics[i].style.backgroundColor = "white";
103   - ics[i].className = "iconeGuiaMovel";
104   - ics[i].onmouseout = function() {
105   - this.className = "iconeGuiaMovel iconeGuiaMovelMouseOut";
106   - };
107   - ics[i].onmouseover = function() {
108   - this.className = "iconeGuiaMovel iconeGuiaMovelMouseOver";
109   - };
110   - ics[i].style.backgroundImage = "none";
111   - ics[i].style.height = "32px";
112   - ics[i].style.width = "32px";
113   - ics[i].style.border = "1px solid gray";
114   - ics[i].style.margin = "0px";
115   - }
116   - i3GEO.editorGM.drawingManager =
117   - new google.maps.drawing.DrawingManager({
118   - drawingMode : google.maps.drawing.OverlayType.POLYGON,
119   - drawingControl : false,
120   - drawingControlOptions : {
121   - position : google.maps.ControlPosition.TOP_CENTER,
122   - drawingModes : [
123   - google.maps.drawing.OverlayType.POLYGON,
124   - google.maps.drawing.OverlayType.MARKER,
125   - google.maps.drawing.OverlayType.POLYLINE
126   - ]
127   - },
128   - markerOptions : {
129   - icon : i3GEO.editorGM.iconePonto(),
130   - clickable : true,
131   - zIndex : 1,
132   - draggable : true,
133   - tema : "",
134   - colunaid : "",
135   - valorid : "",
136   - colunanome : "",
137   - valornome : "",
138   - editable : false
139   - },
140   - polygonOptions : {
141   - fillColor : '#ffff00',
142   - fillOpacity : .5,
143   - strokeWeight : 2,
144   - clickable : true,
145   - zIndex : 1,
146   - editable : true,
147   - tema : "",
148   - colunaid : "",
149   - valorid : "",
150   - colunanome : "",
151   - valornome : ""
152   - }
153   - });
154   - i3GEO.editorGM.drawingManager.setMap(i3GeoMap);
155   - i3GEO.editorGM.drawingManager.setDrawingMode(null);
156   - google.maps.event.addListener(i3GEO.editorGM.drawingManager, 'overlaycomplete', function(e) {
157   - // if (e.type != google.maps.drawing.OverlayType.MARKER) {
158   - i3GEO.editorGM.drawingManager.setDrawingMode(null);
159   - i3GEO.editorGM.mudaicone();
160   - var newShape = e.overlay;
161   - newShape.type = e.type;
162   - newShape.tema = $i("i3geoCartoRegioesEditaveis").value;
163   - newShape.colunaid = "";
164   - newShape.valorid = "";
165   - newShape.colunanome = "";
166   - newShape.valornome = "";
167   - google.maps.event.addListener(newShape, 'click', function() {
168   - i3GEO.editorGM.setSelection(newShape);
169   - });
170   - i3GEO.editorGM.setSelection(newShape);
171   - i3GEO.desenho.googlemaps.shapes.push(newShape);
172   - // }
173   - });
174   - google.maps.event.addListener(i3GEO.editorGM.drawingManager, 'drawingmode_changed', i3GEO.editorGM.clearSelection);
175   - google.maps.event.addListener(i3GeoMap, 'click', i3GEO.editorGM.clearSelection);
176   - },
177   - /**
178   - * Atualiza as camadas do mapa que sao oriundas do sistema METAESTAT Busca a lista de camadas com
179   - * ferramentas/metaestat/analise.php?funcao=LISTACAMADASMETAESTAT Faz um loop para atualizar cada camada
180   - */
181   - atualizaCamadasMetaestat : function() {
182   - var p =
183   - i3GEO.configura.locaplic + "/ferramentas/metaestat/analise.php?funcao=LISTACAMADASMETAESTAT&g_sid=" + i3GEO.configura.sid, temp =
184   - function(retorno) {
185   - var n = retorno.data.length, i;
186   - for (i = 0; i < n; i++) {
187   - i3GEO.Interface.atualizaTema("", retorno.data[i]);
188   - }
189   - };
190   - cpJSON.call(p, "foo", temp);
191   - },
192   - /**
193   - * Monta o codigo HTML com o conteudo da ferramenta Define os botoes e demais elementos que serao preenchidos via codigo
194   - *
195   - * @return html
196   - */
197   - html : function() {
198   - var ins =
199   - '<div style=margin-left:5px >' + ' <button title="' + $trad("dpol")
200   - + '" onclick="i3GEO.editorGM.digitalizaPol(this)"><img src="'
201   - + i3GEO.configura.locaplic
202   - + '/imagens/gisicons/polygon-create.png" /></button>'
203   - + ' <button title="'
204   - + $trad("dponto")
205   - + '" onclick="i3GEO.editorGM.digitalizaPt(this)"><img src="'
206   - + i3GEO.configura.locaplic
207   - + '/imagens/gisicons/point-create.png" /></button>'
208   - + ' <button title="'
209   - + $trad("capturar")
210   - + '" onclick="i3GEO.editorGM.capturaPoligonoTema.ativa(this)"><img src="'
211   - + i3GEO.configura.locaplic
212   - + '/imagens/gisicons/layer-import.png" /></button>'
213   - + ' <button title="'
214   - + $trad("d24t")
215   - + '" onclick="i3GEO.editorGM.seleciona(this)"><img src="'
216   - + i3GEO.configura.locaplic
217   - + '/imagens/gisicons/select.png" /></button>'
218   - + ' <button title="'
219   - + $trad("studo")
220   - + '" onclick="i3GEO.editorGM.selectAll(this)"><img src="'
221   - + i3GEO.configura.locaplic
222   - + '/imagens/gisicons/selectall.png" /></button>'
223   - + ' <button title="'
224   - + $trad("excsel")
225   - + '" onclick="i3GEO.editorGM.deleteSelectedShape()"><img src="'
226   - + i3GEO.configura.locaplic
227   - + '/imagens/gisicons/selected-delete.png" /></button>'
228   - + ' <button title="'
229   - + $trad("salvexc")
230   - + '" onclick="i3GEO.editorGM.salvaLimite.inicia()"><img src="'
231   - + i3GEO.configura.locaplic
232   - + '/imagens/gisicons/vector-save.png" /></button>'
233   - + ' <button title="'
234   - + $trad("edatrib")
235   - + '" onclick="i3GEO.editorGM.editarAtributos.ativa(this)"><img src="'
236   - + i3GEO.configura.locaplic
237   - + '/imagens/gisicons/annotation-form.png" /></button>'
238   - + ' <button title="'
239   - + $trad("s1")
240   - + '" onmousedown="i3GEO.editorGM.mudaicone()" onclick="i3GEO.editorGM.ajuda()" ><img src="'
241   - + i3GEO.configura.locaplic
242   - + '/imagens/gisicons/help-contents.png" /></button>'
243   - + ' <br><div id="i3geoCartoRegioesEditaveisDiv" ><img style="display:block;z-index:2" src="'
244   - + i3GEO.configura.locaplic
245   - + '/imagens/aguarde.gif" /></div></div>'; // combo para escolher a regiao
246   - return ins;
247   - },
248   - /**
249   - * Atualiza a ferramenta quando a janela flutuante tem seu foco ativado
250   - */
251   - ativaFoco : function() {
252   - i3GEO.util.mudaCursor(i3GEO.configura.cursores, "crosshair", i3GEO.Interface.IDMAPA, i3GEO.configura.locaplic);
253   - i3GEO.barraDeBotoes.ativaIcone("pan");
254   - i3GEO.editorGM.mudaicone();
255   - i3GEO.Interface.googlemaps.recalcPar();
256   - },
257   - /**
258   - * Marca uma figura como selecionada
259   - *
260   - * @param objeto
261   - * shape que sera marcado
262   - */
263   - setSelection : function(shape) {
264   - if (shape.setEditable) {
265   - shape.setEditable(!shape.editable);
266   - } else {
267   - shape.editable = true;
268   - shape.setIcon({
269   - url : i3GEO.editorGM.iconePonto(true)
270   - });
271   - }
272   - },
273   - /**
274   - * Marca todas as figuras como nao selecionadas As figuras existentes no mapa sao mantidas na variavel
275   - * i3GEO.desenho.googlemaps.shapes
276   - */
277   - clearSelection : function() {
278   - var i, n = i3GEO.desenho.googlemaps.shapes.length;
279   - for (i = 0; i < n; i++) {
280   - if (i3GEO.desenho.googlemaps.shapes[i] != "" && i3GEO.desenho.googlemaps.shapes[i].setEditable) {
281   - i3GEO.desenho.googlemaps.shapes[i].setEditable(false);
282   - } else if (i3GEO.desenho.googlemaps.shapes[i] != "") {// caso for ponto
283   - i3GEO.desenho.googlemaps.shapes[i].editable = false;
284   - if (i3GEO.desenho.googlemaps.shapes[i].setIcon) {
285   - i3GEO.desenho.googlemaps.shapes[i].setIcon({
286   - url : i3GEO.editorGM.iconePonto(false)
287   - });
288   - }
289   - }
290   - }
291   - },
292   - /**
293   - * Marca todas as figuras como selecionadas As figuras existentes no mapa sao mantidas na variavel i3GEO.desenho.googlemaps.shapes
294   - */
295   - selectAll : function() {
296   - var i, n = i3GEO.desenho.googlemaps.shapes.length;
297   - for (i = 0; i < n; i++) {
298   - if (i3GEO.desenho.googlemaps.shapes[i] != "" && i3GEO.desenho.googlemaps.shapes[i].setEditable) {
299   - i3GEO.desenho.googlemaps.shapes[i].setEditable(true);
300   - } else if (i3GEO.desenho.googlemaps.shapes[i] != "") {// caso for ponto
301   - i3GEO.desenho.googlemaps.shapes[i].editable = true;
302   - i3GEO.desenho.googlemaps.shapes[i].setIcon({
303   - url : i3GEO.editorGM.iconePonto(true)
304   - });
305   - }
306   - }
307   - },
308   - /**
309   - * Remove do mapa as figuras que estiverem selecionadas
310   - *
311   - * @param boolean
312   - * indica se deve ser feita uma confirmacao ou nao antes de apagar
313   - */
314   - deleteSelectedShape : function(naoconfirma) {
315   - i3GEO.janela.tempoMsg($trad("meneditor1"));
316   - if (!naoconfirma) {
317   - naoconfirma = false;
318   - }
319   - var i, n = i3GEO.desenho.googlemaps.shapes.length;
320   - if (n > 0) {
321   - if (naoconfirma === false) {
322   - var x = window.confirm($trad("excsel") + "?");
323   - } else {
324   - x = true;
325   - }
326   - if (x) {
327   - for (i = 0; i < n; i++) {
328   - if (i3GEO.desenho.googlemaps.shapes[i] != "" && i3GEO.desenho.googlemaps.shapes[i].editable
329   - && i3GEO.desenho.googlemaps.shapes[i].editable === true) {
330   - i3GEO.desenho.googlemaps.shapes[i].setMap(null);
331   - i3GEO.desenho.googlemaps.shapes[i] = "";
332   - }
333   - }
334   - }
335   - } else {
336   - i3GEO.janela.tempoMsg($trad("selum"));
337   - }
338   - },
339   - /**
340   - * Lista as figuras que estao marcadas como selecionadas
341   - *
342   - * @return array de shapes
343   - */
344   - selectedShapes : function() {
345   - var i, s = [], n = i3GEO.desenho.googlemaps.shapes.length;
346   - for (i = 0; i < n; i++) {
347   - if (i3GEO.desenho.googlemaps.shapes[i] != "" && i3GEO.desenho.googlemaps.shapes[i].editable === true) {
348   - s.push(i3GEO.desenho.googlemaps.shapes[i]);
349   - }
350   - }
351   - return s;
352   - },
353   - /**
354   - * Lista as coordenadas de todas as figuras existentes
355   - *
356   - * @return objeto contendo a indicacao do tipo de figura e o array com a lista de coordenadas
357   - */
358   - getCoordenadas : function() {
359   - var coordenadas = [], lista = [], n = i3GEO.desenho.googlemaps.shapes.length, tipo = "", ps, nps, j, p, i, r;
360   -
361   - for (i = 0; i < n; i++) {
362   - coordenadas = [];
363   - if (i3GEO.desenho.googlemaps.shapes[i] != "" && i3GEO.desenho.googlemaps.shapes[i].editable === true) {
364   - if (tipo == "") {
365   - tipo = i3GEO.desenho.googlemaps.shapes[i].type;
366   - }
367   - ps = i3GEO.desenho.googlemaps.shapes[i].getPath();
368   - nps = ps.getLength();
369   - for (j = 0; j < nps; j++) {
370   - p = ps.getAt(j);
371   - coordenadas.push([
372   - p.lng() + " " + p.lat()
373   - ]);
374   - }
375   - lista.push(coordenadas);
376   - }
377   - }
378   - r = {
379   - "tipo" : tipo,
380   - "coordenadas" : lista
381   - };
382   - return r;
383   - },
384   - /**
385   - * Converte um objeto shape em uma string WKT
386   - *
387   - * @param shape
388   - */
389   - toWKT : function(obj) {
390   - var wkt = new Wkt.Wkt();
391   - wkt.fromObject(obj);
392   - return wkt.write();
393   - },
394   - merge : function(geoms) {
395   - var n = geoms.length, w = new Wkt.Wkt(), g, m, i;
396   - w.read(geoms[0].toString());
397   - if (n > 1) {
398   - for (i = 1; i < n; i++) {
399   - g = geoms[i].toString();
400   - m = new Wkt.Wkt();
401   - m.read(g);
402   - w.merge(m);
403   - }
404   - }
405   - return w.write();
406   - },
407   - /**
408   - * Funcoes que controlam o processo de obtencao das coordenadas de um componente de uma camada existente no mapa
409   - */
410   - capturaPoligonoTema : {
411   - /**
412   - * Ativa a operaco de captura definindo o evento que sera executado no onclick do mouse sobre o mapa O evento executa
413   - * i3GEO.editorGM.capturaPoligonoTema.captura
414   - *
415   - * @param botao
416   - * da interface que foi pressionado
417   - */
418   - ativa : function(botao) {
419   - i3GEO.editorGM.mudaicone(botao);
420   - i3GEO.eventos.cliquePerm.desativa();
421   - i3GEO.eventos.adicionaEventos("MOUSECLIQUE", [
422   - "i3GEO.editorGM.capturaPoligonoTema.captura()"
423   - ]);
424   - i3GEO.util.mudaCursor(i3GEO.configura.cursores, "crosshair", i3GEO.Interface.IDMAPA, i3GEO.configura.locaplic);
425   - },
426   - desativa : function() {
427   - },
428   - /**
429   - * Realiza a captura de um componente do mapa quando o usuario faz o clique A captura e feita com
430   - * classesphp/mapa_controle.php&funcao=identifica3 O resultado e adicionado ao mapa como um novo objeto shape
431   - */
432   - captura : function() {
433   - var temp, tema = "", regiao = "", p, par, aguarde = $i("i3GEOjanelaEditor_imagemCabecalho");
434   - if (!$i("i3geoCartoRegioesEditaveis")) {
435   - i3GEO.eventos.removeEventos("MOUSECLIQUE", [
436   - "i3GEO.editorGM.capturaPoligonoTema.captura()"
437   - ]);
438   - } else {
439   - temp =
440   - function(retorno) {
441   - var temp, n, i, WicketWkt, wkt = "", colunaid = "", valorid = "", colunanome = "", valornome = "", aguarde =
442   - $i("i3GEOjanelaEditor_imagemCabecalho");
443   - if (i3GEO.editorGM.descregioes["a_" + regiao]["identificador"]) {
444   - colunaid = i3GEO.editorGM.descregioes["a_" + regiao]["identificador"];
445   - }
446   - if (i3GEO.editorGM.descregioes["a_" + regiao]["colunanomeregiao"]) {
447   - colunanome = i3GEO.editorGM.descregioes["a_" + regiao]["colunanomeregiao"];
448   - }
449   - if (aguarde) {
450   - aguarde.style.visibility = "hidden";
451   - }
452   - // obtem os dados buscando nos itens que vem da requisicao ao wms
453   - temp = retorno.data[0].resultado[0];
454   - if (temp === " ") {
455   - i3GEO.janela.tempoMsg($trad("meneditor2"));
456   - return;
457   - }
458   - i3GEO.editorGM.mudaicone();
459   - n = temp.length;
460   - for (i = 0; i < n; i++) {
461   - if (temp[i].alias == "wkt") {
462   - wkt = temp[i].valor;
463   - }
464   - if (temp[i].alias == colunaid || temp[i].item == colunaid) {
465   - valorid = temp[i].valor;
466   - }
467   - if (temp[i].alias == colunanome || temp[i].item == colunanome) {
468   - valornome = temp[i].valor;
469   - }
470   - }
471   - // objeto do wicket ver pacotes/wicket
472   - WicketWkt = new Wkt.Wkt();
473   - // wkt = "MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), ((20 35, 45 20, 30 5, 10 10, 10 30, 20 35), (30 20, 20
474   - // 25, 20 15, 30 20)))";
475   - try { // Catch any malformed WKT strings
476   - WicketWkt.read(wkt);
477   - } catch (e1) {
478   - try {
479   - wkt.read(wkt.replace('\n', '').replace('\r', '').replace('\t', ''));
480   - } catch (e2) {
481   - if (e2.name === 'WKTError') {
482   - alert('Wicket could not understand the WKT string you entered. Check that you have parentheses balanced, and try removing tabs and newline characters.');
483   - return;
484   - }
485   - }
486   - }
487   - obj = WicketWkt.toObject(i3GeoMap.defaults);
488   - // obj.setMap(i3GeoMap); // Add it to the map
489   - // i3GEO.desenho.googlemaps.shapes.push(obj);
490   - i3GEO.editorGM.adicionaPoligonos(obj, tema, colunaid, valorid, colunanome, valornome);
491   - i3GEO.eventos.MOUSECLIQUE = [];
492   - };
493   - regiao = $i("i3geoCartoRegioesEditaveis").value;
494   - if (regiao != "") {
495   - tema = i3GEO.editorGM.regioestemas["a" + regiao];
496   - if (aguarde && aguarde.style.visibility == "hidden") {
497   - aguarde.style.visibility = "visible";
498   - p = i3GEO.configura.locaplic + "/classesphp/mapa_controle.php";
499   - par =
500   - "funcao=identifica3&opcao=tema&xy=" + objposicaocursor.ddx
501   - + ","
502   - + objposicaocursor.ddy
503   - + "&resolucao=5&g_sid="
504   - + i3GEO.configura.sid
505   - + "&ext="
506   - + i3GEO.parametros.mapexten
507   - + "&listaDeTemas=&wkt=sim&tema="
508   - + tema;
509   - cpJSON.call(p, "identifica", temp, par);
510   - }
511   - }
512   - }
513   - }
514   - },
515   - /**
516   - * Monta um combo com a lista de regioes cadastradas e que podem ser editadas pelo editor A regiao em edicao sera a escolhida nesse
517   - * combo Ao ser escolhida, e adicionada uma camada no mapa
518   - *
519   - * @param opcional
520   - * codigo da regiao no cadastro. Se nao for definido, busca todas
521   - */
522   - comboRegiaoEditavel : function(codigo_tipo_regiao) {
523   - if (!codigo_tipo_regiao) {
524   - codigo_tipo_regiao = "";
525   - }
526   - var onde = $i("i3geoCartoRegioesEditaveisDiv"), temp =
527   - function(dados) {
528   - var n = dados.length, ins = '<br><p class="paragrafo" >' + $trad("camedit") + ':</p>', i;
529   - ins +=
530   - "<select onchange='i3GEO.editorGM.comboRegiaoEditavelOnchange(this)' id='i3geoCartoRegioesEditaveis' style='width:175px' ><option value=''>---</option>";
531   - for (i = 0; i < n; i++) {
532   - ins += "<option value='" + dados[i].codigo_tipo_regiao + "'>" + dados[i].nome_tipo_regiao + "</option>";
533   - i3GEO.editorGM.descregioes["a_" + dados[i].codigo_tipo_regiao] = dados[i];
534   - }
535   - // inclui as camadas que sao editaveis e estao no mapa
536   - dados = i3GEO.arvoreDeCamadas.filtraCamadas("editavel", "SIM", "igual");
537   - n = dados.length;
538   - for (i = 0; i < n; i++) {
539   - // layer e usado aqui para identificar que a camada veio do mapa e nao do cadastro de regioes
540   - if (!dados[i].codigo_tipo_regiao || dados[i].codigo_tipo_regiao === "") {
541   - ins += "<option value='" + dados[i].name + "'>" + dados[i].tema + "</option>";
542   - dados[i]["identificador"] = dados[i].colunaidunico;
543   - dados[i]["colunanomeregiao"] = "";
544   - i3GEO.editorGM.descregioes["a_" + dados[i].name] = dados[i];
545   - }
546   - }
547   - ins += "</select>";
548   - if (onde) {
549   - onde.innerHTML = ins;
550   - }
551   - return ins;
552   - };
553   - i3GEO.php.listaTipoRegiao(temp, codigo_tipo_regiao);
554   - },
555   - /**
556   - * Funcao ativada no evento onchange do combo criado com comboRegiaoEditavel Executa i3GEO.php.mapfileTipoRegiao
557   - */
558   - comboRegiaoEditavelOnchange : function(combo) {
559   - if (combo.value === "") {
560   - return;
561   - }
562   - i3GEO.editorGM.editarAtributos.desativa();
563   - // caso a camada escolhida seja uma camada normal, vinda de um mapfile
564   - if (i3GEO.arvoreDeCamadas.pegaTema(combo.value) != "") {
565   - i3GEO.editorGM.regioestemas["a" + combo.value] = combo.value;
566   - i3GEO.editorGM.temasregioes[combo.value] = combo.value;
567   - } else {
568   - var temp = function(retorno) {
569   - if (i3GEO.arvoreDeCamadas.pegaTema(retorno.layer) == "") {
570   - i3GEO.php.adtema(i3GEO.atualiza, retorno.mapfile);
571   - // guarda o codigo e relaciona com a regiao
572   - i3GEO.editorGM.regioestemas["a" + combo.value] = retorno.layer;
573   - i3GEO.editorGM.temasregioes[retorno.layer] = combo.value;
574   - }
575   - };
576   - i3GEO.php.mapfileTipoRegiao(temp, combo.value);
577   - }
578   - },
579   - /**
580   - * Altera as bordas dos icones e desativa eventos Desativa todos os botoes e ativa o indicado
581   - *
582   - * @param objeto
583   - * DOM que representa o botao que sera focado
584   - */
585   - mudaicone : function(botao) {
586   - var c = $i(i3GEO.editorGM.iddiv), ci = c.getElementsByTagName("img"), n = ci.length, i;
587   - for (i = 0; i < n; i++) {
588   - ci[i].parentNode.style.backgroundColor = "#F5F5F5";
589   - }
590   - i3GEO.eventos.MOUSECLIQUE = [];
591   - i3GEO.editorGM.capturaPoligonoTema.desativa();
592   - i3GEO.editorGM.editarAtributos.desativa();
593   - if (botao && botao.style) {
594   - botao.style.backgroundColor = "#cedff2";
595   - }
596   - },
597   - /**
598   - * Ativa a digitalizacao de poligono
599   - *
600   - * @param objeto
601   - * DOM que representa o botao que sera focado
602   - */
603   - digitalizaPol : function(botao) {
604   - i3GEO.editorGM.mudaicone(botao);
605   - i3GEO.util.mudaCursor(i3GEO.configura.cursores, "pointer", i3GEO.Interface.IDMAPA, i3GEO.configura.locaplic);
606   - i3GEO.editorGM.drawingManager.setOptions({
607   - drawingMode : google.maps.drawing.OverlayType.POLYGON
608   - });
609   - },
610   - /**
611   - * Ativa a digitalizacao de ponto
612   - *
613   - * @param objeto
614   - * DOM que representa o botao que sera focado
615   - */
616   - digitalizaPt : function(botao) {
617   - i3GEO.editorGM.mudaicone(botao);
618   - i3GEO.util.mudaCursor(i3GEO.configura.cursores, "pointer", i3GEO.Interface.IDMAPA, i3GEO.configura.locaplic);
619   - i3GEO.editorGM.drawingManager.setOptions({
620   - drawingMode : google.maps.drawing.OverlayType.MARKER
621   - });
622   - },
623   - /**
624   - * Ativa a selecao de figuras
625   - *
626   - * @param objeto
627   - * DOM que representa o botao que sera focado
628   - */
629   - seleciona : function(botao) {
630   - i3GEO.editorGM.mudaicone(botao);
631   - i3GEO.util.mudaCursor(i3GEO.configura.cursores, "pointer", i3GEO.Interface.IDMAPA, i3GEO.configura.locaplic);
632   - i3GEO.editorGM.drawingManager.setOptions({
633   - drawingMode : null
634   - });
635   - },
636   - /**
637   - * Adiciona uma nova figura ao mapa (shape) Pode ser poligono ou ponto
638   - *
639   - * @param objeto
640   - * shape (API do Google)
641   - * @param codigo
642   - * do layer que sera vinculado ao shape
643   - * @param coluna
644   - * do tema que contem os identificadores de cada um de seus elementos (registros)
645   - * @param valor
646   - * do identificador
647   - * @param coluna
648   - * que cntem os nomes das regioes
649   - * @param nome
650   - * da regiao a ser adicionada
651   - */
652   - adicionaPoligonos : function(obj, tema, colunaid, valorid, colunanome, valornome) {
653   - if (!tema) {
654   - tema = $i("i3geoCartoRegioesEditaveis").value;
655   - }
656   - if (!colunaid) {
657   - colunaid = "";
658   - }
659   - if (!valorid) {
660   - valorid = "";
661   - }
662   - if (!colunanome) {
663   - colunanome = "";
664   - }
665   - if (!valornome) {
666   - valornome = "";
667   - }
668   - var pol;
669   - if (Wkt.isArray(obj)) { // Distinguish multigeometries (Arrays) from objects
670   - for (i in obj) {
671   - if (obj.hasOwnProperty(i) && !Wkt.isArray(obj[i])) {
672   - pol = new google.maps.Polygon({
673   - path : obj[i].getPath(),
674   - map : i3GeoMap,
675   - fillColor : '#ffff00',
676   - fillOpacity : .5,
677   - strokeWeight : 2,
678   - clickable : true,
679   - zIndex : 1,
680   - editable : true,
681   - tema : tema,
682   - colunaid : colunaid,
683   - valorid : valorid,
684   - colunanome : colunanome,
685   - valornome : valornome
686   - });
687   - google.maps.event.addListener(pol, 'click', function() {
688   - i3GEO.editorGM.setSelection(pol);
689   - });
690   - i3GEO.desenho.googlemaps.shapes.push(pol);
691   - }
692   - }
693   - return;
694   - }
695   - if (obj.type === 'polygon' || obj.type === 'linestring') {
696   - pol = new google.maps.Polygon({
697   - paths : obj.getPaths(),
698   - map : i3GeoMap,
699   - fillColor : '#ffff00',
700   - fillOpacity : .5,
701   - strokeWeight : 2,
702   - clickable : true,
703   - zIndex : 1,
704   - editable : true,
705   - tema : tema,
706   - colunaid : colunaid,
707   - valorid : valorid,
708   - colunanome : colunanome,
709   - valornome : valornome
710   - });
711   - google.maps.event.addListener(pol, 'click', function() {
712   - i3GEO.editorGM.setSelection(pol);
713   - });
714   - i3GEO.desenho.googlemaps.shapes.push(pol);
715   - return;
716   - }
717   - if (obj.type === 'marker') {
718   - i3GEO.editorGM.selectAll();
719   - if (i3GEO.desenho.googlemaps.shapes.length > 0) {
720   - i3GEO.editorGM.deleteSelectedShape(true);
721   - }
722   - pol = new google.maps.Marker({
723   - position : new google.maps.LatLng(obj.getPosition().ob, obj.getPosition().pb),
724   - map : i3GeoMap,
725   - icon : {
726   - url : i3GEO.editorGM.iconePonto(false)
727   - },
728   - clickable : true,
729   - zIndex : 1,
730   - draggable : true,
731   - tema : tema,
732   - colunaid : colunaid,
733   - valorid : valorid,
734   - colunanome : colunanome,
735   - valornome : valornome,
736   - editable : false
737   - });
738   - google.maps.event.addListener(pol, 'click', function() {
739   - i3GEO.editorGM.setSelection(pol);
740   - });
741   - i3GEO.desenho.googlemaps.shapes.push(pol);
742   - return;
743   - }
744   - },
745   - /**
746   - * Salva um poligono no banco de dados
747   - */
748   - salvaLimite : {
749   - /**
750   - * Inicia a ferramenta definindo as funcoes dos botoes Executa i3GEO.editorGM.salvaLimite.criaJanelaFlutuante
751   - */
752   - inicia : function() {
753   - if (i3GEO.login.verificaCookieLogin() === false) {
754   - i3GEO.janela.tempoMsg($trad("meneditor3"));
755   - if (i3GEO.editorGM.selectedShapes().length > 0) {
756   - var temp = i3GEO.editorGM.toWKT(i3GEO.editorGM.selectedShapes()[0]);
757   - i3GEO.mapa.dialogo.wkt2layer(temp);
758   - }
759   - return;
760   - }
761   - var wkt, temp, s = i3GEO.editorGM.selectedShapes(), n = s.length, janela = YAHOO.i3GEO.janela.manager.find("salvaLimite");
762   - if (janela) {
763   - janela.destroy();
764   - }
765   - if (n == 1) {
766   - s = s[0];
767   - temp = function(retorno) {
768   - i3GEO.editorGM.deleteSelectedShape(true);
769   - i3GEO.Interface.redesenha();
770   - };
771   - // verifica se e uma regiao cadastrada ou um tema comum editavel
772   - if (i3GEO.editorGM.descregioes["a_" + $i("i3geoCartoRegioesEditaveis").value].tema != undefined) {
773   - wkt = i3GEO.editorGM.toWKT(i3GEO.editorGM.selectedShapes()[0]);
774   - if (wkt && wkt != "") {
775   - // cria um novo registro
776   - if (s.valorid == "") {
777   - p =
778   - i3GEO.configura.locaplic + "/ferramentas/editortema/exec.php?funcao=adicionaGeometria&g_sid="
779   - + i3GEO.configura.sid;
780   - cpJSON.call(p, "foo", temp, "&tema=" + $i("i3geoCartoRegioesEditaveis").value + "&wkt=" + wkt);
781   - } else {
782   - // atualiza a geometria
783   - p =
784   - i3GEO.configura.locaplic + "/ferramentas/editortema/exec.php?funcao=atualizaGeometria&g_sid="
785   - + i3GEO.configura.sid;
786   - cpJSON.call(p, "foo", temp, "&idunico=" + s.valorid
787   - + "&tema="
788   - + $i("i3geoCartoRegioesEditaveis").value
789   - + "&wkt="
790   - + wkt);
791   - }
792   - }
793   - } else {
794   - // formulario para o caso de ser um tema cadastrado como regiao no sistema metaestat
795   - i3GEO.editorGM.salvaLimite.criaJanelaFlutuante(i3GEO.editorGM.salvaLimite.html(
796   - s.colunaid,
797   - s.valorid,
798   - s.colunanome,
799   - s.valornome));
800   - new YAHOO.widget.Button("i3GEOFmetaestati3GEO.editorGMBotao1", {
801   - onclick : {
802   - fn : function() {
803   - i3GEO.editorGM.salvaLimite.gravaDados(true);
804   - }
805   - }
806   - });
807   - new YAHOO.widget.Button("i3GEOFmetaestati3GEO.editorGMBotao2", {
808   - onclick : {
809   - fn : function() {
810   - i3GEO.editorGM.salvaLimite.gravaDados(false);
811   - }
812   - }
813   - });
814   - new YAHOO.widget.Button("i3GEOFmetaestati3GEO.editorGMBotao3", {
815   - onclick : {
816   - fn : function() {
817   - i3GEO.editorGM.salvaLimite.excluiPoligono();
818   - }
819   - }
820   - });
821   - }
822   - } else {
823   - i3GEO.janela.tempoMsg("Selecione uma figura");
824   - }
825   - },
826   - /**
827   - * Monta o HTML para o formulario que permite salvar os dados
828   - */
829   - html : function(colunaIdElemento, valorIdElemento, colunaNomeElemento, valorNomeElemento) {
830   - var ins =
831   - '' + '<p class=paragrafo >Se o valor do c&oacute;digo for vazio, ser&aacute; criado um novo elemento. Caso contr&aacute;rio, os valores atualmente registrados ser&atilde;o atualizados.</p>'
832   - + '<p class=paragrafo >Edite os atributos:</p>'
833   - + '<input type=hidden id="inputColunaIdElemento" value="' + colunaIdElemento
834   - + '" />'
835   - + '<input type=hidden id="inputColunaNomeElemento" value="'
836   - + colunaNomeElemento
837   - + '" />'
838   - + '<input type=hidden id="inputIdentificadorElemento" value="'
839   - + valorIdElemento
840   - + '" />'
841   - + '<input type=hidden id="inputNomeElemento" value="'
842   - + valorNomeElemento
843   - + '" />'
844   - + '<p class=paragrafo >C&oacute;digo:</p>'
845   - + '<p class=paragrafo ><input class=digitar type=text id="inputIdentificadorNovoElemento" value="'
846   - + valorIdElemento
847   - + '" style="width:180;cursor:text" /></p>'
848   - + '<p class=paragrafo >Nome:</p>'
849   - + '<p class=paragrafo ><input class=digitar type=text id="inputNomeNovoElemento" value="'
850   - + valorNomeElemento
851   - + '" style="width:180;cursor:text" /></p>'
852   - + '<p class=paragrafo >Escolha a opera&ccedil;&atilde;o desejada:</p>'
853   - + '<input id=i3GEOFmetaestati3GEO.editorGMBotao1 type="button" value="Salvar tudo" />'
854   - + '&nbsp;<input id=i3GEOFmetaestati3GEO.editorGMBotao2 type="button" value="Salvar apenas os atributos" />'
855   - + '<br><br><input id=i3GEOFmetaestati3GEO.editorGMBotao3 type="button" value="Excluir" />';
856   - return ins;
857   - },
858   - /**
859   - * Cria a janela flutuante para receber os componentes da ferramenta
860   - *
861   - * @param html
862   - * com o conteudo da ferramenta
863   - */
864   - criaJanelaFlutuante : function(html) {
865   - var titulo, cabecalho, minimiza, janela;
866   - cabecalho = function() {
867   - };
868   - minimiza = function() {
869   - i3GEO.janela.minimiza("salvaLimite");
870   - };
871   - titulo = "<div class='i3GeoTituloJanela'>" + $trad("sdados") + "</div>";
872   - janela = i3GEO.janela.cria("300px", "265px", "", "", "", titulo, "salvaLimite", true, "hd", cabecalho, minimiza);
873   - $i("salvaLimite_corpo").style.backgroundColor = "white";
874   - $i("salvaLimite_corpo").innerHTML = html;
875   - YAHOO.util.Event.addListener(janela[0].close, "click", i3GEO.editorGM.mudaicone);
876   - },
877   - /**
878   - * Aplica a operacao de salvar os dados no banco para o shape selecionado Executa
879   - * admin/php/metaestat.php?funcao=mantemDadosRegiao
880   - *
881   - * @param boolean
882   - * indica se as coordenadas serao salvas tambem
883   - */
884   - gravaDados : function(comwkt) {
885   - if (i3GEO.login.verificaCookieLogin() === false) {
886   - i3GEO.janela.tempoMsg($trad("meneditor3"));
887   - return;
888   - }
889   - if (!window.confirm($trad("sdados") + "?")) {
890   - return;
891   - }
892   - var p, codigo_tipo_regiao = $i("i3geoCartoRegioesEditaveis").value, identificadornovo =
893   - $i("inputIdentificadorNovoElemento").value, identificador = $i("inputIdentificadorElemento").value, nome =
894   - $i("inputNomeNovoElemento").value, wkt = "", temp = function(retorno) {
895   - i3GEO.editorGM.deleteSelectedShape(true);
896   - var janela = YAHOO.i3GEO.janela.manager.find("salvaLimite");
897   - if (janela) {
898   - janela.destroy();
899   - }
900   - i3GEO.Interface.redesenha();
901   - };
902   - if (comwkt === true) {
903   - wkt = i3GEO.editorGM.toWKT(i3GEO.editorGM.selectedShapes()[0]);
904   - } else {
905   - if (identificadornovo === identificador && $i("inputNomeElemento").value === nome) {
906   - i3GEO.janela.tempoMsg($trad("meneditor4"));
907   - return;
908   - }
909   - }
910   - p = i3GEO.configura.locaplic + "/admin/php/metaestat.php?funcao=mantemDadosRegiao&tipo=";
911   - cpJSON.call(p, "foo", temp, "&codigo_tipo_regiao=" + codigo_tipo_regiao
912   - + "&identificadornovo="
913   - + identificadornovo
914   - + "&identificador="
915   - + identificador
916   - + "&nome="
917   - + nome
918   - + "&wkt="
919   - + wkt);
920   - },
921   - /**
922   - * Exclui um registro do banco de dados Executa admin/php/metaestat.php?funcao=mantemDadosRegiao&tipo=excluir
923   - */
924   - excluiPoligono : function() {
925   - if (i3GEO.login.verificaCookieLogin() === false) {
926   - i3GEO.janela.tempoMsg($trad("meneditor3"));
927   - return;
928   - }
929   - if (!window.confirm($trad("excsel") + "?")) {
930   - return;
931   - }
932   - var codigo_tipo_regiao = $i("i3geoCartoRegioesEditaveis").value, identificador = $i("inputIdentificadorElemento").value, temp =
933   - function(retorno) {
934   - i3GEO.editorGM.deleteSelectedShape(true);
935   - var janela = YAHOO.i3GEO.janela.manager.find("salvaLimite");
936   - if (janela) {
937   - janela.destroy();
938   - }
939   - i3GEO.Interface.redesenha();
940   - }, p = i3GEO.configura.locaplic + "/admin/php/metaestat.php?funcao=mantemDadosRegiao&tipo=excluir";
941   - if (identificador === "") {
942   - i3GEO.janela.tempoMsg($trad("meneditor5"));
943   - } else {
944   - cpJSON.call(p, "foo", temp, "&codigo_tipo_regiao=" + codigo_tipo_regiao + "&identificador=" + identificador);
945   - }
946   - }
947   - },
948   - /**
949   - * Funcoes que controlam o processo de edicao de atributos de um shape
950   - */
951   - editarAtributos : {
952   - aliascolunas : "", // guarda os nomes das colunas e seus aliases para permitir a criacao de novos registros
953   - x : "",
954   - y : "",
955   - /**
956   - * Ativa a ferramenta Define os eventos de onclick para abrir formulario quando o usuario clica no mapa Para cada regiao sao
957   - * obtidas todas as variaveis cadastradas Executa i3GEO.editorGM.editarAtributos.criaJanelaFlutuante Executa
958   - * i3GEO.editorGM.editarAtributos.comboVariaveis();
959   - */
960   - ativa : function(botao) {
961   - if ($i("i3geoCartoRegioesEditaveis").value == "") {
962   - i3GEO.janela.tempoMsg("Escolha uma regiao");
963   - return;
964   - }
965   - i3GEO.editorGM.mudaicone(botao);
966   - i3GEO.eventos.adicionaEventos("MOUSECLIQUE", [
967   - "i3GEO.editorGM.editarAtributos.captura()"
968   - ]);
969   - var janela = YAHOO.i3GEO.janela.manager.find("editaAtributos");
970   - if (janela) {
971   - $i("editarAtributosForm").innerHTML = "";
972   - } else {
973   - i3GEO.editorGM.editarAtributos.criaJanelaFlutuante(i3GEO.editorGM.editarAtributos.html());
974   - i3GEO.editorGM.editarAtributos.comboVariaveis();
975   - }
976   - },
977   - /**
978   - * Fecha a janela de edicao
979   - */
980   - desativa : function() {
981   - var janela = YAHOO.i3GEO.janela.manager.find("editaAtributos");
982   - if (janela) {
983   - janela.destroy();
984   - }
985   - },
986   - criaJanelaFlutuante : function(html) {
987   - var janela, titulo, cabecalho, minimiza;
988   - cabecalho = function() {
989   - };
990   - minimiza = function() {
991   - i3GEO.janela.minimiza("editaAtributos");
992   - };
993   - titulo = "<div class='i3GeoTituloJanela'>" + $trad("atrib") + "</div>";
994   - janela = i3GEO.janela.cria("250px", "265px", "", "", "", titulo, "editaAtributos", false, "hd", cabecalho, minimiza);
995   - $i("editaAtributos_corpo").style.backgroundColor = "white";
996   - $i("editaAtributos_corpo").innerHTML = html;
997   - i3GEO.janela.tempoMsg($trad("meneditor6"));
998   - YAHOO.util.Event.addListener(janela[0].close, "click", i3GEO.editorGM.mudaicone);
999   - },
1000   - /**
1001   - * Fornece o HTML com os objetos que receberao os componentes da ferramenta
1002   - *
1003   - * @return html
1004   - */
1005   - html : function() {
1006   - var ins =
1007   - '' + '<p class="paragrafo" ><div id="editarAtributosVariaveis" ></div></p>'
1008   - + '<p class="paragrafo" ><div id="editarAtributosMedidasVariavel" ></div></p>'
1009   - + '<p class="paragrafo" ><div id="editarAtributosRegiao" ></div></p>'
1010   - + '<p class="paragrafo" ><div id="editarAtributosForm" ></div></p>'
1011   - + '';
1012   - return ins;
1013   - },
1014   - /**
1015   - * Monta um combo para escolha de uma variavel que sera editada Executa i3GEO.php.listaVariavel
1016   - */
1017   - comboVariaveis : function() {
1018   - var temp =
1019   - function(dados) {
1020   - var i, n = dados.length, ins = '';
1021   - ins += '<p class="paragrafo" >Escolha uma vari&aacute;vel para editar</p>';
1022   - ins +=
1023   - "<select style='box-shadow:0 1px 5px gray;width:200px' onchange='i3GEO.editorGM.editarAtributos.comboMedidasVariavel(this)'><option value=''>---</option>";
1024   - for (i = 0; i < n; i++) {
1025   - ins +=
1026   - "<option title='" + dados[i].descricao
1027   - + "' value='"
1028   - + dados[i].codigo_variavel
1029   - + "'>"
1030   - + dados[i].nome
1031   - + "</option>";
1032   - }
1033   - ins += "</select>";
1034   - $i("editarAtributosVariaveis").innerHTML = ins;
1035   - };
1036   - i3GEO.php.listaVariavel(temp, "i3geo_metaestat");
1037   - },
1038   - /**
1039   - * Monta um combo com as medidas de uma variavel Executa i3GEO.php.listaMedidaVariavel
1040   - *
1041   - * @param objeto
1042   - * DOM do tipo select que contem a lista de variaveis
1043   - */
1044   - comboMedidasVariavel : function(comboMedidas) {
1045   - var temp =
1046   - function(dados) {
1047   - var i, n = dados.length, ins = '';
1048   - ins += '<p class="paragrafo" >Escolha uma medida da vari&aacute;vel para editar</p>';
1049   - ins +=
1050   - "<select id='editarAtributosComboMedidas' style='box-shadow:0 1px 5px gray;width:200px' onchange=''><option value=''>---</option>";
1051   - for (i = 0; i < n; i++) {
1052   - if (dados[i].esquemadb == "i3geo_metaestat" && dados[i].codigo_tipo_regiao == $i("i3geoCartoRegioesEditaveis").value) {
1053   - ins += "<option value='" + dados[i].id_medida_variavel + "'>" + dados[i].nomemedida + "</option>";
1054   - }
1055   - }
1056   -
1057   - ins += "</select>";
1058   - $i("editarAtributosMedidasVariavel").innerHTML = ins;
1059   - };
1060   - if (comboMedidas.value !== "") {
1061   - i3GEO.php.listaMedidaVariavel(comboMedidas.value, temp);
1062   - }
1063   - },
1064   - /**
1065   - * Captura os atributos de um elemento do mapa Executa i3GEO.editorGM.editarAtributos.pegaDados();
1066   - */
1067   - captura : function() {
1068   - if (!YAHOO.i3GEO.janela.manager.find("editaAtributos")) {
1069   - i3GEO.editorGM.mudaicone(botao);
1070   - return;
1071   - }
1072   - i3GEO.editorGM.editarAtributos.x = objposicaocursor.ddx;
1073   - i3GEO.editorGM.editarAtributos.y = objposicaocursor.ddy;
1074   - i3GEO.editorGM.editarAtributos.pegaDados();
1075   - },
1076   - /**
1077   - * Obtem os dados de um elemento de uma regiao Monta o formulario para edicao Executa
1078   - * admin/php/metaestat.php?funcao=listaAtributosMedidaVariavelXY
1079   - */
1080   - pegaDados : function() {
1081   - var p = i3GEO.configura.locaplic + "/admin/php/metaestat.php?funcao=listaAtributosMedidaVariavelXY", codigo_tipo_regiao =
1082   - $i("i3geoCartoRegioesEditaveis").value, id_medida_variavel = $i("editarAtributosComboMedidas").value, temp =
1083   - function(retorno) {
1084   - var atr = retorno.atributos, i = 0, n = atr.dados.length, j = 0, idunico = "", nj = atr.aliascolunas.length, ins =
1085   - "" + '<p class=paragrafo >Limite geogr&aacute;fico escolhido:</p>'
1086   - + '<p class=paragrafo ><b>Nome: </b>'
1087   - + retorno.regiao.nomeregiao
1088   - + '</p>'
1089   - + '<p class=paragrafo ><b>C&oacute;digo: </b>'
1090   - + retorno.regiao.identificador_regiao
1091   - + '</p>'
1092   - + '<input type=hidden id="editarAtributosidentificador_regiao" value="'
1093   - + retorno.regiao.identificador_regiao
1094   - + '" />'
1095   - + '<p class=paragrafo >Atributos:</p>'
1096   - + '<input id=editarAtributosAdicionar value="Adicionar um novo" />'
1097   - + '&nbsp;<input id=editarAtributosSalvar value="Salvar" />';
1098   - $i("editarAtributosRegiao").innerHTML = ins;
1099   - ins = "";
1100   - // registros
1101   - for (i = 0; i < n; i++) {
1102   - // descobre qual o indice que corresponde ao idunico do registro
1103   - for (j = 0; j < nj; j++) {
1104   - if (atr.aliascolunas[j] == "idunico") {
1105   - idunico = atr.dados[i][atr.colunas[j]];
1106   - }
1107   - }
1108   - ins +=
1109   - "<hr><div><p class=paragrafo style='color:blue;cursor:pointer' onclick='i3GEO.editorGM.editarAtributos.excluir(" + idunico
1110   - + ")' >excluir</p>";
1111   - // colunas
1112   - for (j = 0; j < nj; j++) {
1113   - if (atr.aliascolunas[j] !== "idunico") {
1114   - ins +=
1115   - '<p class=paragrafo >' + atr.aliascolunas[j]
1116   - + ':<br>'
1117   - + '<input class=digitar id="idunico_'
1118   - + idunico
1119   - + '" value="'
1120   - + atr.dados[i][atr.colunas[j]]
1121   - + '" name="'
1122   - + atr.colunas[j]
1123   - + '" /></p>';
1124   - }
1125   - }
1126   - }
1127   - $i("editarAtributosForm").innerHTML = ins;
1128   - new YAHOO.widget.Button("editarAtributosAdicionar", {
1129   - onclick : {
1130   - fn : function() {
1131   - var novoel = document.createElement("div"), ins = "<hr><br>";
1132   - for (j = 0; j < nj; j++) {
1133   - if (atr.aliascolunas[j] !== "idunico") {
1134   - ins +=
1135   - '<p class=paragrafo >' + atr.aliascolunas[j]
1136   - + ' - '
1137   - + atr.descricao[j]
1138   - + ':<br>'
1139   - + '<input class=digitar id="" value="" name="'
1140   - + atr.colunas[j]
1141   - + '" /></p>';
1142   - }
1143   - }
1144   - ins += "<br></div>";
1145   - novoel.innerHTML = ins;
1146   - $i("editarAtributosForm").appendChild(novoel);
1147   - }
1148   - }
1149   - });
1150   - new YAHOO.widget.Button("editarAtributosSalvar", {
1151   - onclick : {
1152   - fn : function() {
1153   - i3GEO.editorGM.editarAtributos.salva();
1154   - }
1155   - }
1156   - });
1157   - };
1158   - cpJSON.call(p, "foo", temp, "&codigo_tipo_regiao=" + codigo_tipo_regiao
1159   - + "&id_medida_variavel="
1160   - + id_medida_variavel
1161   - + "&x="
1162   - + i3GEO.editorGM.editarAtributos.x
1163   - + "&y="
1164   - + i3GEO.editorGM.editarAtributos.y);
1165   - },
1166   - // FIXME redesenhar as camadas que sofrerem alteracoes em funcao do salvar ou excluir
1167   - /**
1168   - * Exclui o valor de uma medida de variavel para o componente de uma regiao
1169   - */
1170   - excluir : function(id) {
1171   - if (i3GEO.login.verificaCookieLogin() === false) {
1172   - i3GEO.janela.tempoMsg("Voc&ecirc; precisa fazer login para usar essa op&ccedil;&atilde;o");
1173   - return;
1174   - }
1175   - var p = i3GEO.configura.locaplic + "/admin/php/metaestat.php?funcao=excluiAtributosMedidaVariavel", codigo_tipo_regiao =
1176   - $i("i3geoCartoRegioesEditaveis").value, id_medida_variavel = $i("editarAtributosComboMedidas").value, identificador_regiao =
1177   - $i("editarAtributosidentificador_regiao").value, temp = function(retorno) {
1178   - i3GEO.editorGM.editarAtributos.pegaDados();
1179   - i3GEO.janela.fechaAguarde("aguardeSalvaAtributos");
1180   - };
1181   - i3GEO.janela.AGUARDEMODAL = true;
1182   - i3GEO.janela.abreAguarde("aguardeSalvaAtributos", "Salvando...");
1183   - i3GEO.janela.AGUARDEMODAL = false;
1184   - cpJSON.call(p, "foo", temp, "&codigo_tipo_regiao=" + codigo_tipo_regiao
1185   - + "&identificador_regiao="
1186   - + identificador_regiao
1187   - + "&id_medida_variavel="
1188   - + id_medida_variavel
1189   - + "&id="
1190   - + id);
1191   -
1192   - },
1193   - /**
1194   - * Salva os valores digitados
1195   - */
1196   - salva : function() {
1197   - if (i3GEO.login.verificaCookieLogin() === false) {
1198   - i3GEO.janela.tempoMsg("Voc&ecirc; precisa fazer login para usar essa op&ccedil;&atilde;o");
1199   - return;
1200   - }
1201   - var container = $i("editarAtributosForm"), divsT = container.getElementsByTagName("div"), n = divsT.length, i = 0, dv = "", inputs =
1202   - "", codigo_tipo_regiao = $i("i3geoCartoRegioesEditaveis").value, id_medida_variavel =
1203   - $i("editarAtributosComboMedidas").value, identificador_regiao = $i("editarAtributosidentificador_regiao").value, nj, j, colunas =
1204   - [], colunasT = [], valores = [], valoresT = [], idsunicosT = [], p =
1205   - i3GEO.configura.locaplic + "/admin/php/metaestat.php?funcao=salvaAtributosMedidaVariavel", re =
1206   - new RegExp("idunico_", "g"), // prefixo usado para marcar o id dos elementos input que contem os valores que se quer
1207   - // obter
1208   - temp = function(retorno) {
1209   - i3GEO.editorGM.editarAtributos.pegaDados();
1210   - i3GEO.editorGM.atualizaCamadasMetaestat();
1211   - i3GEO.janela.fechaAguarde("aguardeSalvaAtributos");
1212   - };
1213   - if (codigo_tipo_regiao == "") {
1214   - i3GEO.janela.tempoMsg("Problemas com o codigo da regiao");
1215   - return;
1216   - }
1217   - if (id_medida_variavel == "") {
1218   - i3GEO.janela.tempoMsg("Escolha uma medida");
1219   - return;
1220   - }
1221   - if (identificador_regiao == "") {
1222   - i3GEO.janela.tempoMsg("Problemas com o identificador da regiao");
1223   - return;
1224   - }
1225   - for (i = 0; i < n; i++) {
1226   - dv = divsT[i];
1227   - inputs = dv.getElementsByTagName("input");
1228   - nj = inputs.length;
1229   - colunas = [];
1230   - valores = [];
1231   - for (j = 0; j < nj; j++) {
1232   - colunas.push(inputs[j].name);
1233   - valores.push(inputs[j].value);
1234   - }
1235   - idsunicosT.push(inputs[0].id.replace(re, ''));
1236   - colunasT.push(colunas.join("|"));
1237   - valoresT.push(valores.join("|"));
1238   - }
1239   - i3GEO.janela.AGUARDEMODAL = true;
1240   - i3GEO.janela.abreAguarde("aguardeSalvaAtributos", "Salvando...");
1241   - i3GEO.janela.AGUARDEMODAL = false;
1242   - cpJSON.call(p, "foo", temp, "&codigo_tipo_regiao=" + codigo_tipo_regiao
1243   - + "&identificador_regiao="
1244   - + identificador_regiao
1245   - + "&id_medida_variavel="
1246   - + id_medida_variavel
1247   - + "&colunas="
1248   - + colunasT[0]
1249   - + "&valores="
1250   - + valoresT.join("#")
1251   - + "&idsunicos="
1252   - + idsunicosT.join("|"));
1253   - }
1254   - },
1255   - /**
1256   - * Abre a janela de ajuda sobre a operacao dos botoes do editor
1257   - */
1258   - ajuda : function() {
1259   - var titulo, cabecalho, minimiza, html = "";
1260   - cabecalho = function() {
1261   - };
1262   - minimiza = function() {
1263   - i3GEO.janela.minimiza("editaAtributosAjuda");
1264   - };
1265   - titulo = "<div class='i3GeoTituloJanela'>Ajuda&nbsp;</div>";
1266   - i3GEO.janela.cria("400px", "350px", "", "", "", titulo, "editaAtributosAjuda", false, "hd", cabecalho, minimiza);
1267   - $i("editaAtributosAjuda_corpo").style.backgroundColor = "white";
1268   - html +=
1269   - "<table class=lista8 >" + "<tr><td><img src='" + i3GEO.configura.locaplic
1270   - + "/imagens/gisicons/polygon-create.png' /></td>"
1271   - + "<td>Clique no mapa para tra&ccedil;ar um pol&iacute;gono novo. Cada clique corresponde a um v&eacute;rtice do pol&iacute;gono. Para encerrar o tra&ccedil;ado utilize um duplo clique. Ap&oacute;s tra&ccedil;ar um novo pol&iacute;gono pode-se selecion&aacute;-lo novamente e editar os v&eacute;rtices, se for necess&aacute;rio, ou mesmo apagar o pol&iacute;gono por completo. O novo pol&iacute;gono s&oacute; ser&aacute; salvo por meio da op&ccedil;&atilde;o espec&iacute;fica para isso.</td></tr>"
1272   - + "<tr><td><img src='"
1273   - + i3GEO.configura.locaplic
1274   - + "/imagens/gisicons/layer-import.png' /></td>"
1275   - + "<td>Utilize essa op&ccedil;&atilde;o para capturar os v&eacute;rtices de um pol&iacute;gono existente. O resultado da captura &eacute; uma figura que pode ser editada, ou seja, os v&eacute;rtices podem ser modificados de posi&ccedil;&atilde;o ou mesmo removidos. Ap&oacute;s editar, salve o novo pol&iacute;gono.</td></tr>"
1276   - + "<tr><td><img src='"
1277   - + i3GEO.configura.locaplic
1278   - + "/imagens/gisicons/select.png' /></td>"
1279   - + "<td>Ap&oacute;s ativar essa op&ccedil;&atilde;o clique no mapa sobre uma figura existente (que tenha sido capturada ou digtalizada). A figura passar&aacute; ent&atilde;o para o estado de 'selecionada' podendo ser utilizada por outras ferramentas de edi&ccedil;&atilde;o.</td></tr>"
1280   - + "<tr><td><img src='"
1281   - + i3GEO.configura.locaplic
1282   - + "/imagens/gisicons/selected-delete.png' /></td>"
1283   - + "<td>Remove da tela a figura que estiver selecionada. Essa opera&ccedil;&atilde;o n&atilde;o apaga o pol&iacute;gono do banco de dados, apenas remove do modo de edi&ccedil;&atilde;o.</td></tr>"
1284   - + "<tr><td><img src='"
1285   - + i3GEO.configura.locaplic
1286   - + "/imagens/gisicons/vector-save.png' /></td>"
1287   - + "<td>Salva no banco de dados a figura que estiver selecionada. Essa op&ccedil;&atilde;o altera apenas os atributos do limite geogr&aacute;fico, n&atilde;o afetando os valores armazenados em cada medida de vari&aacute;vel.</td></tr>"
1288   - + "<tr><td><img src='"
1289   - + i3GEO.configura.locaplic
1290   - + "/imagens/gisicons/annotation-form.png' /></td>"
1291   - + "<td>Abre um formul&aacute;rio que permite alterar os valores de uma medida de vari&aacute;vel relacionada a uma determinada regi&atilde;o. Ap&oacute;s abrir o formul&aacute;rio, clique no mapa sobre a regi&atilde;o desejada, mas escolha a medida da vari&aacute;vel primeiro. Os valores j&aacute; existentes poder&atilde;o ent&atilde;o ser alterados ou podem ser adicionados novos.</td></tr>"
1292   - + "</table>";
1293   - $i("editaAtributosAjuda_corpo").innerHTML = html;
1294   - }
1295   - };
1296   -
1297   -// copia do original de pacotes/wicket
1298   -
1299   -/* global Wkt, google, document, window, console */
1300   -google.maps.Marker.prototype.type = 'marker';
1301   -google.maps.Polyline.prototype.type = 'polyline';
1302   -google.maps.Polygon.prototype.type = 'polygon';
1303   -google.maps.Rectangle.prototype.type = 'rectangle';
1304   -google.maps.Circle.prototype.type = 'circle';
1305   -
1306   -/**
1307   - * @license
1308   - *
1309   - * Copyright (C) 2012 K. Arthur Endsley (kaendsle@mtu.edu) Michigan Tech Research Institute (MTRI) 3600 Green Court, Suite 100, Ann Arbor,
1310   - * MI, 48105
1311   - *
1312   - * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
1313   - * the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
1314   - *
1315   - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
1316   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1317   - *
1318   - * You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
1319   - *
1320   - */
1321   -(function(Wkt) {
1322   -
1323   - /**
1324   - * @augments Wkt.Wkt A framework-dependent flag, set for each Wkt.Wkt() instance, that indicates whether or not a closed polygon
1325   - * geometry should be interpreted as a rectangle.
1326   - */
1327   - Wkt.Wkt.prototype.isRectangle = false;
1328   -
1329   - /**
1330   - * @augments Wkt.Wkt An object of framework-dependent construction methods used to generate objects belonging to the various geometry
1331   - * classes of the framework.
1332   - */
1333   - Wkt.Wkt.prototype.construct = {
1334   - /**
1335   - * Creates the framework's equivalent point geometry object.
1336   - *
1337   - * @param config
1338   - * {Object} An optional properties hash the object should use
1339   - * @param component
1340   - * {Object} An optional component to build from
1341   - * @return {google.maps.Marker}
1342   - */
1343   - point : function(config, component) {
1344   - var c = component || this.components;
1345   -
1346   - config = config || {};
1347   -
1348   - config.position = new google.maps.LatLng(c[0].y, c[0].x);
1349   -
1350   - return new google.maps.Marker(config);
1351   - },
1352   -
1353   - /**
1354   - * Creates the framework's equivalent multipoint geometry object.
1355   - *
1356   - * @param config
1357   - * {Object} An optional properties hash the object should use
1358   - * @return {Array} Array containing multiple google.maps.Marker
1359   - */
1360   - multipoint : function(config) {
1361   - var i, c, arr;
1362   -
1363   - c = this.components;
1364   -
1365   - config = config || {};
1366   -
1367   - arr = [];
1368   -
1369   - for (i = 0; i < c.length; i += 1) {
1370   - arr.push(this.construct.point(config, c[i]));
1371   - }
1372   -
1373   - return arr;
1374   - },
1375   -
1376   - /**
1377   - * Creates the framework's equivalent linestring geometry object.
1378   - *
1379   - * @param config
1380   - * {Object} An optional properties hash the object should use
1381   - * @param component
1382   - * {Object} An optional component to build from
1383   - * @return {google.maps.Polyline}
1384   - */
1385   - linestring : function(config, component) {
1386   - var i, c;
1387   -
1388   - c = component || this.components;
1389   -
1390   - config = config || {
1391   - editable : false
1392   - };
1393   -
1394   - config.path = [];
1395   -
1396   - for (i = 0; i < c.length; i += 1) {
1397   - config.path.push(new google.maps.LatLng(c[i].y, c[i].x));
1398   - }
1399   -
1400   - return new google.maps.Polyline(config);
1401   - },
1402   -
1403   - /**
1404   - * Creates the framework's equivalent multilinestring geometry object.
1405   - *
1406   - * @param config
1407   - * {Object} An optional properties hash the object should use
1408   - * @return {Array} Array containing multiple google.maps.Polyline instances
1409   - */
1410   - multilinestring : function(config) {
1411   - var i, c, arr;
1412   -
1413   - c = this.components;
1414   -
1415   - config = config || {
1416   - editable : false
1417   - };
1418   -
1419   - config.path = [];
1420   -
1421   - arr = [];
1422   -
1423   - for (i = 0; i < c.length; i += 1) {
1424   - arr.push(this.construct.linestring(config, c[i]));
1425   - }
1426   -
1427   - return arr;
1428   - },
1429   -
1430   - /**
1431   - * Creates the framework's equivalent Box or Rectangle geometry object.
1432   - *
1433   - * @param config
1434   - * {Object} An optional properties hash the object should use
1435   - * @param component
1436   - * {Object} An optional component to build from
1437   - * @return {google.maps.Rectangle}
1438   - */
1439   - box : function(config, component) {
1440   - var c = component || this.components;
1441   -
1442   - config = config || {};
1443   -
1444   - config.bounds = new google.maps.LatLngBounds(new google.maps.LatLng(c[0].y, c[0].x), new google.maps.LatLng(c[1].y, c[1].x));
1445   -
1446   - return new google.maps.Rectangle(config);
1447   - },
1448   -
1449   - /**
1450   - * Creates the framework's equivalent polygon geometry object.
1451   - *
1452   - * @param config
1453   - * {Object} An optional properties hash the object should use
1454   - * @param component
1455   - * {Object} An optional component to build from
1456   - * @return {google.maps.Polygon}
1457   - */
1458   - polygon : function(config, component) {
1459   - var j, k, c, rings, verts;
1460   -
1461   - c = component || this.components;
1462   -
1463   - config = config || {
1464   - editable : false
1465   - // Editable geometry off by default
1466   - };
1467   -
1468   - config.paths = [];
1469   -
1470   - rings = [];
1471   - for (j = 0; j < c.length; j += 1) { // For each ring...
1472   -
1473   - verts = [];
1474   - // NOTE: We iterate to one (1) less than the Array length to skip the last vertex
1475   - for (k = 0; k < c[j].length - 1; k += 1) { // For each vertex...
1476   - verts.push(new google.maps.LatLng(c[j][k].y, c[j][k].x));
1477   -
1478   - } // eo for each vertex
1479   -
1480   - if (j !== 0) { // Reverse the order of coordinates in inner rings
1481   - if (config.reverseInnerPolygons == null || config.reverseInnerPolygons) {
1482   - verts.reverse();
1483   - }
1484   - }
1485   -
1486   - rings.push(verts);
1487   - } // eo for each ring
1488   -
1489   - config.paths = config.paths.concat(rings);
1490   -
1491   - if (this.isRectangle) {
1492   - return (function() {
1493   - var bounds, v = 0;
1494   -
1495   - bounds = new google.maps.LatLngBounds();
1496   -
1497   - for (v in rings[0]) { // Ought to be only 1 ring in a Rectangle
1498   - if (rings[0].hasOwnProperty(v)) {
1499   - bounds.extend(rings[0][v]);
1500   - }
1501   - }
1502   -
1503   - return new google.maps.Rectangle({
1504   - bounds : bounds
1505   - });
1506   - }());
1507   - } else {
1508   - return new google.maps.Polygon(config);
1509   - }
1510   - },
1511   -
1512   - /**
1513   - * Creates the framework's equivalent multipolygon geometry object.
1514   - *
1515   - * @param config
1516   - * {Object} An optional properties hash the object should use
1517   - * @return {Array} Array containing multiple google.maps.Polygon
1518   - */
1519   - multipolygon : function(config) {
1520   - var i, c, arr;
1521   -
1522   - c = this.components;
1523   -
1524   - config = config || {
1525   - editable : false
1526   - };
1527   -
1528   - config.path = [];
1529   -
1530   - arr = [];
1531   -
1532   - for (i = 0; i < c.length; i += 1) {
1533   - arr.push(this.construct.polygon(config, c[i]));
1534   - }
1535   -
1536   - return arr;
1537   - }
1538   -
1539   - };
1540   -
1541   - /**
1542   - * @augments Wkt.Wkt A framework-dependent deconstruction method used to generate internal geometric representations from instances of
1543   - * framework geometry. This method uses object detection to attempt to classify members of framework geometry classes into the
1544   - * standard WKT types.
1545   - * @param obj
1546   - * {Object} An instance of one of the framework's geometry classes
1547   - * @param multiFlag
1548   - * {Boolean} If true, then the deconstructor will be forced to return a MultiGeometry (multipoint, multilinestring or
1549   - * multipolygon)
1550   - * @return {Object} A hash of the 'type' and 'components' thus derived, plus the WKT string of the feature.
1551   - */
1552   - Wkt.Wkt.prototype.deconstruct =
1553   - function(obj, multiFlag) {
1554   - var features, i, j, verts, rings, sign, tmp, response, lat, lng;
1555   -
1556   - // Shortcut to signed area function (determines clockwise vs counter-clock)
1557   - if (google.maps.geometry) {
1558   - sign = google.maps.geometry.spherical.computeSignedArea;
1559   - }
1560   - ;
1561   -
1562   - // google.maps.LatLng //////////////////////////////////////////////////////
1563   - if (obj.constructor === google.maps.LatLng) {
1564   -
1565   - response = {
1566   - type : 'point',
1567   - components : [
1568   - {
1569   - x : obj.lng(),
1570   - y : obj.lat()
1571   - }
1572   - ]
1573   - };
1574   - return response;
1575   - }
1576   -
1577   - // google.maps.Point //////////////////////////////////////////////////////
1578   - if (obj.constructor === google.maps.Point) {
1579   - response = {
1580   - type : 'point',
1581   - components : [
1582   - {
1583   - x : obj.x,
1584   - y : obj.y
1585   - }
1586   - ]
1587   - };
1588   - return response;
1589   - }
1590   -
1591   - // google.maps.Marker //////////////////////////////////////////////////////
1592   - if (obj.constructor === google.maps.Marker) {
1593   - response = {
1594   - type : 'point',
1595   - components : [
1596   - {
1597   - x : obj.getPosition().lng(),
1598   - y : obj.getPosition().lat()
1599   - }
1600   - ]
1601   - };
1602   - return response;
1603   - }
1604   -
1605   - // google.maps.Polyline ////////////////////////////////////////////////////
1606   - if (obj.constructor === google.maps.Polyline) {
1607   -
1608   - verts = [];
1609   - for (i = 0; i < obj.getPath().length; i += 1) {
1610   - tmp = obj.getPath().getAt(i);
1611   - verts.push({
1612   - x : tmp.lng(),
1613   - y : tmp.lat()
1614   - });
1615   - }
1616   - response = {
1617   - type : 'linestring',
1618   - components : verts
1619   - };
1620   - return response;
1621   -
1622   - }
1623   -
1624   - // google.maps.Polygon /////////////////////////////////////////////////////
1625   - if (obj.constructor === google.maps.Polygon) {
1626   -
1627   - rings = [];
1628   -
1629   - if (multiFlag === undefined) {
1630   - multiFlag = (function() {
1631   - var areas, l;
1632   -
1633   - l = obj.getPaths().length;
1634   - if (l <= 1) { // Trivial; this is a single polygon
1635   - return false;
1636   - }
1637   -
1638   - if (l === 2) {
1639   - // If clockwise*clockwise or counter*counter, i.e.
1640   - // (-1)*(-1) or (1)*(1), then result would be positive
1641   - if (sign(obj.getPaths().getAt(0)) * sign(obj.getPaths().getAt(1)) < 0) {
1642   - return false; // Most likely single polygon with 1 hole
1643   - }
1644   -
1645   - return true;
1646   - }
1647   -
1648   - // Must be longer than 3 polygons at this point...
1649   - areas = obj.getPaths().getArray().map(function(k) {
1650   - return sign(k) / Math.abs(sign(k)); // Unit normalization (outputs 1 or -1)
1651   - });
1652   -
1653   - // If two clockwise or two counter-clockwise rings are found
1654   - // (at different indices)...
1655   - if (areas.indexOf(areas[0]) !== areas.lastIndexOf(areas[0])) {
1656   - multiFlag = true; // Flag for holes in one or more polygons
1657   - return true;
1658   - }
1659   -
1660   - return false;
1661   -
1662   - }());
1663   - }
1664   -
1665   - for (i = 0; i < obj.getPaths().length; i += 1) { // For each polygon (ring)...
1666   - tmp = obj.getPaths().getAt(i);
1667   - verts = [];
1668   - for (j = 0; j < obj.getPaths().getAt(i).length; j += 1) { // For each vertex...
1669   - verts.push({
1670   - x : tmp.getAt(j).lng(),
1671   - y : tmp.getAt(j).lat()
1672   - });
1673   -
1674   - }
1675   -
1676   - if (!tmp.getAt(tmp.length - 1).equals(tmp.getAt(0))) {
1677   - if (i % 2 !== 0) { // In inner rings, coordinates are reversed...
1678   - verts.unshift({ // Add the first coordinate again for closure
1679   - x : tmp.getAt(tmp.length - 1).lng(),
1680   - y : tmp.getAt(tmp.length - 1).lat()
1681   - });
1682   -
1683   - } else {
1684   - verts.push({ // Add the first coordinate again for closure
1685   - x : tmp.getAt(0).lng(),
1686   - y : tmp.getAt(0).lat()
1687   - });
1688   -
1689   - }
1690   -
1691   - }
1692   -
1693   - if (obj.getPaths().length > 1 && i > 0) {
1694   - // If this and the last ring have the same signs...
1695   - if (sign(obj.getPaths().getAt(i)) > 0 && sign(obj.getPaths().getAt(i - 1)) > 0
1696   - || sign(obj.getPaths().getAt(i)) < 0
1697   - && sign(obj.getPaths().getAt(i - 1)) < 0
1698   - && !multiFlag) {
1699   - // ...They must both be inner rings (or both be outer rings, in a multipolygon)
1700   - verts = [
1701   - verts
1702   - ]; // Wrap multipolygons once more (collection)
1703   - }
1704   -
1705   - }
1706   -
1707   - if (i % 2 !== 0) { // In inner rings, coordinates are reversed...
1708   - verts.reverse();
1709   - }
1710   - rings.push(verts);
1711   - }
1712   -
1713   - response = {
1714   - type : (multiFlag) ? 'multipolygon' : 'polygon',
1715   - components : rings
1716   - };
1717   - return response;
1718   -
1719   - }
1720   -
1721   - // google.maps.Circle //////////////////////////////////////////////////////
1722   - if (obj.constructor === google.maps.Circle) {
1723   - var point = obj.getCenter();
1724   - var radius = obj.getRadius();
1725   - verts = [];
1726   - var d2r = Math.PI / 180; // degrees to radians
1727   - var r2d = 180 / Math.PI; // radians to degrees
1728   - radius = radius / 1609; // meters to miles
1729   - var earthsradius = 3963; // 3963 is the radius of the earth in miles
1730   - var num_seg = 32; // number of segments used to approximate a circle
1731   - var rlat = (radius / earthsradius) * r2d;
1732   - var rlng = rlat / Math.cos(point.lat() * d2r);
1733   -
1734   - for (var n = 0; n <= num_seg; n++) {
1735   - var theta = Math.PI * (n / (num_seg / 2));
1736   - lng = point.lng() + (rlng * Math.cos(theta)); // center a + radius x * cos(theta)
1737   - lat = point.lat() + (rlat * Math.sin(theta)); // center b + radius y * sin(theta)
1738   - verts.push({
1739   - x : lng,
1740   - y : lat
1741   - });
1742   - }
1743   -
1744   - response = {
1745   - type : 'polygon',
1746   - components : [
1747   - verts
1748   - ]
1749   - };
1750   -
1751   - return response;
1752   -
1753   - }
1754   -
1755   - // google.maps.LatLngBounds ///////////////////////////////////////////////////
1756   - if (obj.constructor === google.maps.LatLngBounds) {
1757   -
1758   - tmp = obj;
1759   - verts = [];
1760   - verts.push({ // NW corner
1761   - x : tmp.getSouthWest().lng(),
1762   - y : tmp.getNorthEast().lat()
1763   - });
1764   -
1765   - verts.push({ // NE corner
1766   - x : tmp.getNorthEast().lng(),
1767   - y : tmp.getNorthEast().lat()
1768   - });
1769   -
1770   - verts.push({ // SE corner
1771   - x : tmp.getNorthEast().lng(),
1772   - y : tmp.getSouthWest().lat()
1773   - });
1774   -
1775   - verts.push({ // SW corner
1776   - x : tmp.getSouthWest().lng(),
1777   - y : tmp.getSouthWest().lat()
1778   - });
1779   -
1780   - verts.push({ // NW corner (again, for closure)
1781   - x : tmp.getSouthWest().lng(),
1782   - y : tmp.getNorthEast().lat()
1783   - });
1784   -
1785   - response = {
1786   - type : 'polygon',
1787   - isRectangle : true,
1788   - components : [
1789   - verts
1790   - ]
1791   - };
1792   -
1793   - return response;
1794   -
1795   - }
1796   -
1797   - // google.maps.Rectangle ///////////////////////////////////////////////////
1798   - if (obj.constructor === google.maps.Rectangle) {
1799   -
1800   - tmp = obj.getBounds();
1801   - verts = [];
1802   - verts.push({ // NW corner
1803   - x : tmp.getSouthWest().lng(),
1804   - y : tmp.getNorthEast().lat()
1805   - });
1806   -
1807   - verts.push({ // NE corner
1808   - x : tmp.getNorthEast().lng(),
1809   - y : tmp.getNorthEast().lat()
1810   - });
1811   -
1812   - verts.push({ // SE corner
1813   - x : tmp.getNorthEast().lng(),
1814   - y : tmp.getSouthWest().lat()
1815   - });
1816   -
1817   - verts.push({ // SW corner
1818   - x : tmp.getSouthWest().lng(),
1819   - y : tmp.getSouthWest().lat()
1820   - });
1821   -
1822   - verts.push({ // NW corner (again, for closure)
1823   - x : tmp.getSouthWest().lng(),
1824   - y : tmp.getNorthEast().lat()
1825   - });
1826   -
1827   - response = {
1828   - type : 'polygon',
1829   - isRectangle : true,
1830   - components : [
1831   - verts
1832   - ]
1833   - };
1834   -
1835   - return response;
1836   -
1837   - }
1838   -
1839   - // google.maps.Data Geometry Types /////////////////////////////////////////////////////
1840   -
1841   - // google.maps.Data.Feature /////////////////////////////////////////////////////
1842   - if (obj.constructor === google.maps.Data.Feature) {
1843   - return this.deconstruct.call(this, obj.getGeometry());
1844   - }
1845   -
1846   - // google.maps.Data.Point /////////////////////////////////////////////////////
1847   - if (obj.constructor === google.maps.Data.Point) {
1848   - // console.log('It is a google.maps.Data.Point');
1849   - response = {
1850   - type : 'point',
1851   - components : [
1852   - {
1853   - x : obj.get().lng(),
1854   - y : obj.get().lat()
1855   - }
1856   - ]
1857   - };
1858   - return response;
1859   - }
1860   -
1861   - // google.maps.Data.LineString /////////////////////////////////////////////////////
1862   - if (obj.constructor === google.maps.Data.LineString) {
1863   - verts = [];
1864   - // console.log('It is a google.maps.Data.LineString');
1865   - for (i = 0; i < obj.getLength(); i += 1) {
1866   - vertex = obj.getAt(i);
1867   - verts.push({
1868   - x : vertex.lng(),
1869   - y : vertex.lat()
1870   - });
1871   - }
1872   - response = {
1873   - type : 'linestring',
1874   - components : verts
1875   - };
1876   - return response;
1877   - }
1878   -
1879   - // google.maps.Data.Polygon /////////////////////////////////////////////////////
1880   - if (obj.constructor === google.maps.Data.Polygon) {
1881   - var rings = [];
1882   - // console.log('It is a google.maps.Data.Polygon');
1883   - for (i = 0; i < obj.getLength(); i += 1) { // For each ring...
1884   - ring = obj.getAt(i);
1885   - var verts = [];
1886   - for (j = 0; j < ring.getLength(); j += 1) { // For each vertex...
1887   - vertex = ring.getAt(j);
1888   - verts.push({
1889   - x : vertex.lng(),
1890   - y : vertex.lat()
1891   - });
1892   - }
1893   - verts.push({
1894   - x : ring.getAt(0).lng(),
1895   - y : ring.getAt(0).lat()
1896   - });
1897   -
1898   - rings.push(verts);
1899   - }
1900   - response = {
1901   - type : 'polygon',
1902   - components : rings
1903   - };
1904   -
1905   - return response;
1906   - }
1907   -
1908   - // google.maps.Data.MultiPoint /////////////////////////////////////////////////////
1909   - if (obj.constructor === google.maps.Data.MultiPoint) {
1910   - verts = [];
1911   - for (i = 0; i < obj.getLength(); i += 1) {
1912   - vertex = obj.getAt(i);
1913   - verts.push([
1914   - {
1915   - x : vertex.lng(),
1916   - y : vertex.lat()
1917   - }
1918   - ]);
1919   - }
1920   - response = {
1921   - type : 'multipoint',
1922   - components : verts
1923   - };
1924   - return response;
1925   - }
1926   -
1927   - // google.maps.Data.MultiLineString /////////////////////////////////////////////////////
1928   - if (obj.constructor === google.maps.Data.MultiLineString) {
1929   - linestrings = [];
1930   - for (i = 0; i < obj.getLength(); i += 1) {
1931   - verts = [];
1932   - var linestring = obj.getAt(i);
1933   - for (j = 0; j < linestring.getLength(); j += 1) {
1934   - vertex = linestring.getAt(j);
1935   - verts.push({
1936   - x : vertex.lng(),
1937   - y : vertex.lat()
1938   - });
1939   - }
1940   - linestrings.push(verts);
1941   - }
1942   - response = {
1943   - type : 'multilinestring',
1944   - components : linestrings
1945   - };
1946   - return response;
1947   - }
1948   -
1949   - // google.maps.Data.MultiPolygon /////////////////////////////////////////////////////
1950   - if (obj.constructor === google.maps.Data.MultiPolygon) {
1951   -
1952   - var k = 0, polygons = [];
1953   -
1954   - // console.log('It is a google.maps.Data.MultiPolygon');
1955   - for (k = 0; k < obj.getLength(); k += 1) { // For each multipolygon
1956   - var polygon = obj.getAt(k);
1957   - var rings = [];
1958   - for (i = 0; i < polygon.getLength(); i += 1) { // For each ring...
1959   - ring = polygon.getAt(i);
1960   - var verts = [];
1961   - for (j = 0; j < ring.getLength(); j += 1) { // For each vertex...
1962   - vertex = ring.getAt(j);
1963   - verts.push({
1964   - x : vertex.lng(),
1965   - y : vertex.lat()
1966   - });
1967   - }
1968   - verts.push({
1969   - x : ring.getAt(0).lng(),
1970   - y : ring.getAt(0).lat()
1971   - });
1972   -
1973   - rings.push(verts);
1974   - }
1975   - polygons.push(rings);
1976   - }
1977   -
1978   - response = {
1979   - type : 'multipolygon',
1980   - components : polygons
1981   - };
1982   - return response;
1983   - }
1984   -
1985   - // google.maps.Data.GeometryCollection /////////////////////////////////////////////////////
1986   - if (obj.constructor === google.maps.Data.GeometryCollection) {
1987   -
1988   - var objects = [];
1989   - for (k = 0; k < obj.getLength(); k += 1) { // For each multipolygon
1990   - var object = obj.getAt(k);
1991   - objects.push(this.deconstruct.call(this, object));
1992   - }
1993   - // console.log('It is a google.maps.Data.GeometryCollection', objects);
1994   - response = {
1995   - type : 'geometrycollection',
1996   - components : objects
1997   - };
1998   - return response;
1999   - }
2000   -
2001   - // Array ///////////////////////////////////////////////////////////////////
2002   - if (Wkt.isArray(obj)) {
2003   - features = [];
2004   -
2005   - for (i = 0; i < obj.length; i += 1) {
2006   - features.push(this.deconstruct.call(this, obj[i], true));
2007   - }
2008   -
2009   - response = {
2010   -
2011   - type : (function() {
2012   - var k, type = obj[0].constructor;
2013   -
2014   - for (k = 0; k < obj.length; k += 1) {
2015   - // Check that all items have the same constructor as the first item
2016   - if (obj[k].constructor !== type) {
2017   - // If they don't, type is heterogeneous geometry collection
2018   - return 'geometrycollection';
2019   - }
2020   - }
2021   -
2022   - switch (type) {
2023   - case google.maps.Marker:
2024   - return 'multipoint';
2025   - case google.maps.Polyline:
2026   - return 'multilinestring';
2027   - case google.maps.Polygon:
2028   - return 'multipolygon';
2029   - default:
2030   - return 'geometrycollection';
2031   - }
2032   -
2033   - }()),
2034   - components : (function() {
2035   - // Pluck the components from each Wkt
2036   - var i, comps;
2037   -
2038   - comps = [];
2039   - for (i = 0; i < features.length; i += 1) {
2040   - if (features[i].components) {
2041   - comps.push(features[i].components);
2042   - }
2043   - }
2044   -
2045   - return {
2046   - "comps" : comps
2047   - };
2048   - }())
2049   -
2050   - };
2051   - response.components = response.components.comps;
2052   - return response;
2053   -
2054   - }
2055   - };
2056   -}(Wkt || require('./wicket')));
js/editorol.js
... ... @@ -1,2307 +0,0 @@
1   -//TODO incluir balao de informacoes como um elemento grafico de desenho
2   -//TODO incluir caixas de texto
3   -//TODO incluir undo na edicao
4   -
5   -/*
6   - Title: Editor vetorial para OpenLayers
7   -
8   - i3GEO.editorOL
9   -
10   - Fun&ccedil;&otilde;es utilizadas pelo OpenLayers nas op&ccedil;&otilde;es de edi&ccedil;&atilde;o de dados vetoriais.
11   - &Eacute; utilizado tamb&eacute;m pelo mashup com navega&ccedil;&atilde;o via OpenLayers e com OSM.
12   -
13   - Para adicionar novos botoes, modifique tamb&eacute;m i3GEO.editorOL.botoes existente em i3GEO.barraDeBotoes.openlayers.ativaPainel
14   -
15   - Mesmo em interfaces de debug, esse javascript s&oacute; &eacute; carregado depois de cmpactado
16   -
17   - Arquivo: i3geo/classesjs/classe_editorol.js
18   -
19   - Licen&ccedil;a:
20   -
21   - GPL2
22   -
23   - i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
24   -
25   - Direitos Autorais Reservados (c) 2006 Minist&eacute;rio do Meio Ambiente Brasil
26   - Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com
27   -
28   - Este programa &eacute; software livre; voc&ecirc; pode redistribu&iacute;-lo
29   - e/ou modific&aacute;-lo sob os termos da Licen&ccedil;a P&uacute;blica Geral
30   - GNU conforme publicada pela Free Software Foundation;
31   -
32   - Este programa &eacute; distribu&iacute;do na expectativa de que seja &uacute;til,
33   - por&eacute;m, SEM NENHUMA GARANTIA; nem mesmo a garantia impl&iacute;cita
34   - de COMERCIABILIDADE OU ADEQUACAtilde;O A UMA FINALIDADE ESPEC&Iacute;FICA.
35   - Consulte a Licen&ccedil;a P&uacute;blica Geral do GNU para mais detalhes.
36   - Voc&ecirc; deve ter recebido uma c&oacute;pia da Licen&ccedil;a P&uacute;blica Geral do
37   - GNU junto com este programa; se n&atilde;o, escreva para a
38   - Free Software Foundation, Inc., no endere&ccedil;o
39   - 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
40   - */
41   -
42   -if (!i3GEO || typeof (i3GEO) === 'undefined') {
43   - var i3GEO = {};
44   - i3GEO.Interface = {};
45   - navn = false;
46   - navm = false;
47   - $i = function(id) {
48   - return document.getElementById(id);
49   - };
50   - app = navigator.appName.substring(0, 1);
51   - if (app === 'N') {
52   - navn = true;
53   - } else {
54   - navm = true;
55   - }
56   -}
57   -i3GEO.editorOL =
58   - {
59   - simbologia : {
60   - opacidade : 0.8,
61   - texto : "",
62   - fillColor : "250,180,15",
63   - strokeWidth : 2,
64   - strokeColor : "250,150,0",
65   - pointRadius : 4,
66   - graphicName : "square",
67   - fontSize : "12px",
68   - fontColor : "0,0,0",
69   - externalGraphic : "",
70   - graphicHeight : 25,
71   - graphicWidth : 25
72   - },
73   - backup : new ol.layer.Vector({
74   - source : new ol.source.Vector({
75   - features : new ol.Collection(),
76   - useSpatialIndex : false,
77   - name : "Backup"
78   - }),
79   - visible : false,
80   - map : i3geoOL
81   - }),
82   - nomeFuncaoSalvar : "i3GEO.editorOL.salvaGeo()",
83   - e_oce : new ol.layer.Tile(
84   - {
85   - title : "ESRI Ocean Basemap",
86   - visible : false,
87   - isBaseLayer : true,
88   - name : "oce",
89   - source : new ol.source.TileArcGISRest(
90   - {
91   - url : "http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer",
92   - attributions : [
93   - new ol.Attribution(
94   - {
95   - html : 'Tiles &copy; <a href="http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer">ArcGIS</a>'
96   - })
97   - ]
98   - })
99   - }),
100   - e_ims : new ol.layer.Tile(
101   - {
102   - title : "ESRI Imagery World 2D",
103   - visible : false,
104   - isBaseLayer : true,
105   - name : "ims",
106   - source : new ol.source.TileArcGISRest(
107   - {
108   - url : "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer",
109   - attributions : [
110   - new ol.Attribution(
111   - {
112   - html : 'Tiles &copy; <a href="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer">ArcGIS</a>'
113   - })
114   - ]
115   - })
116   - }),
117   - e_wsm : new ol.layer.Tile(
118   - {
119   - title : "ESRI World Street Map",
120   - visible : false,
121   - isBaseLayer : true,
122   - name : "wsm",
123   - source : new ol.source.TileArcGISRest(
124   - {
125   - url : "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer",
126   - attributions : [
127   - new ol.Attribution(
128   - {
129   - html : 'Tiles &copy; <a href="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer">ArcGIS</a>'
130   - })
131   - ]
132   - })
133   - }),
134   - ol_mma : new ol.layer.Tile({
135   - title : "Base carto MMA",
136   - visible : false,
137   - isBaseLayer : true,
138   - name : "bra",
139   - source : new ol.source.TileWMS({
140   - url : "http://mapas.mma.gov.br/cgi-bin/mapserv?map=/opt/www/html/webservices/baseraster.map&",
141   - params : {
142   - 'layers' : "baseraster",
143   - 'srs' : "EPSG:4326",
144   - 'format' : "image/png"
145   - }
146   - })
147   - }),
148   - ol_wms : new ol.layer.Tile(
149   - {
150   - title : "ESRI World Street Map",
151   - visible : false,
152   - isBaseLayer : true,
153   - name : "wsm",
154   - source : new ol.source.TileArcGISRest(
155   - {
156   - url : "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer",
157   - attributions : [
158   - new ol.Attribution(
159   - {
160   - html : 'Tiles &copy; <a href="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer">ArcGIS</a>'
161   - })
162   - ]
163   - })
164   - }),
165   - fundo : "e_ims,e_wsm,ol_mma,ol_wms,top_wms",
166   - kml : [],
167   - layersIniciais : [],
168   - botoes : {
169   - 'pan' : true,
170   - 'zoombox' : true,
171   - 'zoomtot' : true,
172   - 'zoomin' : true,
173   - 'zoomout' : true,
174   - 'distancia' : true,
175   - 'area' : true,
176   - 'identifica' : true,
177   - 'linha' : true,
178   - 'ponto' : true,
179   - 'poligono' : true,
180   - 'texto' : true,
181   - 'edita' : true,
182   - 'listag' : true,
183   - 'corta' : true,
184   - 'apaga' : true,
185   - 'procura' : true,
186   - 'selecao' : true,
187   - 'selecaotudo' : true,
188   - 'salva' : true,
189   - 'ajuda' : true,
190   - 'propriedades' : true,
191   - 'fecha' : false,
192   - 'tools' : true,
193   - 'undo' : false,
194   - 'frente' : false,
195   - 'legenda' : true,
196   - 'rodadomouse' : true
197   - },
198   - pontos : [],
199   - marca : "../pacotes/openlayers/img/marker-gold.png",
200   - controles : [
201   - new ol.interaction.DoubleClickZoom(),
202   - new ol.interaction.KeyboardPan(),
203   - new ol.interaction.KeyboardZoom(),
204   - new ol.interaction.MouseWheelZoom(),
205   - new ol.interaction.PinchRotate(),
206   - new ol.interaction.PinchZoom(),
207   - new ol.interaction.DragZoom(),
208   - new ol.interaction.DragPan(),
209   - new ol.control.Zoom(),
210   - new ol.control.ZoomSlider(),
211   - new ol.control.ScaleLine()
212   - ],
213   - tiles : true,
214   - incluilayergrafico : true,
215   - ativalayerswitcher : false,
216   - ativarodadomouse : true,
217   - legendahtml : false,
218   - numzoom : 12,
219   - minresolution : 0.703125,
220   - maxext : "",
221   - mapext : [-76.5125927, -39.3925675209, -29.5851853, 9.49014852081],
222   - mapa : "",
223   - inicia : function() {
224   - // ativabotoes e boolean
225   - var alayers = [], fundo = (i3GEO.editorOL.fundo).split(","), nfundo = fundo.length, ncontroles =
226   - i3GEO.editorOL.controles.length, i, n, temp;
227   -
228   - //TODO layerswitcher no OL3
229   - /*
230   - if (i3GEO.editorOL.ativalayerswitcher === "false") {
231   - i3GEO.editorOL.ativalayerswitcher = false;
232   - }
233   - if (i3GEO.editorOL.ativalayerswitcher === "true") {
234   - i3GEO.editorOL.ativalayerswitcher = true;
235   - }
236   - */
237   - if (i3GEO.editorOL.ativarodadomouse === "false") {
238   - i3GEO.editorOL.ativarodadomouse = false;
239   - }
240   - if (i3GEO.editorOL.ativarodadomouse === "true") {
241   - i3GEO.editorOL.ativarodadomouse = true;
242   - }
243   - if (i3GEO.editorOL.legendahtml === "false") {
244   - i3GEO.editorOL.legendahtml = false;
245   - }
246   - if (i3GEO.editorOL.legendahtml === "true") {
247   - i3GEO.editorOL.legendahtml = true;
248   - }
249   -
250   - if (i3GEO.editorOL.incluilayergrafico === "false") {
251   - i3GEO.editorOL.incluilayergrafico = false;
252   - }
253   - if (i3GEO.editorOL.incluilayergrafico === "true") {
254   - i3GEO.editorOL.incluilayergrafico = true;
255   - }
256   - if (i3GEO.editorOL.incluilayergrafico === true) {
257   - if (!i3GEO.desenho.layergrafico) {
258   - i3GEO.editorOL.criaLayerGrafico();
259   - }
260   - } else {
261   - i3GEO.desenho.layergrafico = "";
262   - i3GEO.editorOL.botoes.linha = false;
263   - i3GEO.editorOL.botoes.ponto = false;
264   - i3GEO.editorOL.botoes.poligono = false;
265   - i3GEO.editorOL.botoes.texto = false;
266   - i3GEO.editorOL.botoes.edita = false;
267   - i3GEO.editorOL.botoes.listag = false;
268   - i3GEO.editorOL.botoes.corta = false;
269   - i3GEO.editorOL.botoes.apaga = false;
270   - i3GEO.editorOL.botoes.selecao = false;
271   - i3GEO.editorOL.botoes.selecaotudo = false;
272   - i3GEO.editorOL.botoes.salva = false;
273   - i3GEO.editorOL.botoes.propriedades = false;
274   - i3GEO.editorOL.botoes.fecha = false;
275   - i3GEO.editorOL.botoes.tools = false;
276   - i3GEO.editorOL.botoes.undo = false;
277   - i3GEO.editorOL.botoes.frente = false;
278   - }
279   - if (i3GEO.editorOL.mapa === "") {
280   - alert("O objeto i3GEO.editorOL.mapa nao existe. Precisa ser criado com new OpenLayers.Map()");
281   - return;
282   - }
283   - for (i = 0; i < ncontroles; i++) {
284   - i3GEO.editorOL.mapa.addControl(i3GEO.editorOL.controles[i]);
285   - }
286   - if (i3GEO.editorOL.fundo != "") {
287   - for (i = nfundo - 1; i >= 0; i--) {
288   - if (fundo[i] != "") {
289   - try {
290   - i3GEO.editorOL[fundo[i]].transitionEffect = 'resize';
291   - i3GEO.editorOL[fundo[i]].setVisibility(false);
292   - i3GEO.editorOL[fundo[i]].singleTile = false;
293   - alayers.push(i3GEO.editorOL[fundo[i]]);
294   - } catch (e) {
295   - if (alayers[0]) {
296   - alayers[0].setVisibility(true);
297   - }
298   - }
299   - }
300   - }
301   - }
302   - i3GEO.editorOL.mapa.addLayers(alayers);
303   - if (i3GEO.editorOL.layersIniciais !== "") {
304   - n = i3GEO.editorOL.layersIniciais.length;
305   - for (i = 0; i < n; i++) {
306   - // singleTile deve ser definido em cada layer
307   - // i3GEO.editorOL.layersIniciais[i].singleTile = single;
308   - i3GEO.editorOL.mapa.addLayer(i3GEO.editorOL.layersIniciais[i]);
309   - }
310   - }
311   - if (!i3GEO.desenho.layergrafico && i3GEO.editorOL.incluilayergrafico === true) {
312   - i3GEO.editorOL.mapa.addLayers([
313   - i3GEO.desenho.layergrafico
314   - ]);
315   - }
316   - i3GEO.editorOL.adicionaKml();
317   - i3GEO.editorOL.adicionaMarcas();
318   -
319   - i3GEO.editorOL.coordenadas();
320   - i3GEO.editorOL.criaJanelaBusca();
321   - i3GEO.editorOL.criaBotoes(i3GEO.editorOL.botoes);
322   - if (i3GEO.editorOL.ativalayerswitcher === true) {
323   - i3GEO.editorOL.ativaLayerSwitcher();
324   - }
325   - if (i3GEO.editorOL.ativarodadomouse === false) {
326   - i3GEO.editorOL.desativaRodaDoMouse();
327   - }
328   -
329   - if (i3GEO.editorOL.numzoom !== "") {
330   - i3GEO.editorOL.mapa.setOptions({
331   - numZoomLevels : i3GEO.editorOL.numzoom
332   - });
333   - }
334   - if (i3GEO.editorOL.maxext !== "") {
335   - i3GEO.editorOL.mapa.setOptions({
336   - maxExtent : i3GEO.editorOL.maxext
337   - });
338   - }
339   - if (i3GEO.editorOL.mapext != "") {
340   - var m = i3GEO.util.extGeo2OSM(i3GEO.editorOL.mapext);
341   - i3GEO.editorOL.mapa.zoomToExtent(m);
342   - } else {
343   - i3GEO.editorOL.mapa.zoomToMaxExtent();
344   - }
345   - i3GEO.editorOL.sobeLayersGraficos();
346   - // evita que botoes de opcoes propaguem
347   - // o mashup utiliza esse tipo de botal junto ao nome do layer
348   - temp = i3GEO.editorOL.pegaControle("OpenLayers.Control.LayerSwitcher");
349   - if (temp) {
350   - temp = temp.dataLayersDiv.getElementsByTagName("label");
351   - n = temp.length;
352   - for (i = 0; i < n; i++) {
353   - // YAHOO.util.Event.addListener(temp[i], "click", YAHOO.util.Event.stopEvent);
354   - temp[i].onclick = "";
355   - }
356   - }
357   - },
358   - criaLayerGrafico : function() {
359   - i3GEO.desenho.openlayers.criaLayerGrafico();
360   - },
361   - layersLigados : function() {
362   - var layers = i3GEO.editorOL.mapa.layers, nlayers = layers.length, ins = [], i;
363   - for (i = 0; i < nlayers; i++) {
364   - if (layers[i].visibility === true) {
365   - ins.push(layers[i]);
366   - }
367   - }
368   - return ins;
369   - },
370   - layerPorParametro : function(parametro, valor) {
371   - var layers = i3GEO.editorOL.mapa.layers, nlayers = layers.length, ins = [], i;
372   - for (i = 0; i < nlayers; i++) {
373   - if (layers[i][parametro] || layers[i][parametro.toLowerCase()]) {
374   - if (layers[i][parametro] === valor || layers[i][parametro.toLowerCase()] === valor) {
375   - ins.push(layers[i]);
376   - }
377   - } else {
378   - if (layers[i].params && layers[i].params[parametro] && layers[i].params[parametro] === valor) {
379   - ins.push(layers[i]);
380   - }
381   - }
382   - }
383   - return ins;
384   - },
385   - // layers clonados sao copias WMS de layers TMS necessarios para realizar o getfeature
386   - // sao criados quando o layer e adicionado
387   - layersClonados : function(paramsLayers) {
388   - var layers = i3GEO.editorOL.mapa.layers, nlayers = layers.length, i;
389   - for (i = 0; i < nlayers; i++) {
390   - if (layers[i].params && layers[i].params.CLONETMS === paramsLayers) {
391   - return (layers[i]);
392   - }
393   - }
394   - return false;
395   - },
396   - layertms2wms : function(tms) {
397   - var layer, url;
398   - url = tms.url.replace("&cache=sim", "&DESLIGACACHE=sim");
399   - url = url.replace("&Z=${z}&X=${x}&Y=${y}", "");
400   - url = url.replace("Z=${z}&X=${x}&Y=${y}", "");
401   - layer = new OpenLayers.Layer.WMS(tms.layername + "_clone", url, {
402   - layers : tms.name,
403   - transparent : true
404   - }, {
405   - gutter : 0,
406   - isBaseLayer : false,
407   - displayInLayerSwitcher : false,
408   - opacity : 1,
409   - visibility : true,
410   - singleTile : true
411   - });
412   - // i3GEO.editorOL.mapa.addLayer(layer);
413   - return layer;
414   - },
415   - // remove o layer clonado com layertms2wms
416   - removeClone : function() {
417   - var nome = i3GEO.editorOL.layerAtivo().layername + "_clone", busca = i3GEO.editorOL.mapa.getLayersByName(nome);
418   - if (busca.length > 0) {
419   - i3GEO.editorOL.mapa.removeLayer(i3GEO.editorOL.mapa.getLayersByName(camada.name)[0], false);
420   - }
421   - },
422   - coordenadas : function() {
423   - //
424   - // substitui o controle que mostra as coordenadas
425   - //
426   - var idcoord = i3GEO.editorOL.mapa.getControlsBy("separator", " ");
427   - if (idcoord[0]) {
428   - i3GEO.editorOL.mapa.events.register("mousemove", i3GEO.editorOL.mapa, function(e) {
429   - var p, lonlat, d;
430   - if (navm) {
431   - p = new OpenLayers.Pixel(e.x, e.y);
432   - } else {
433   - p = e.xy;
434   - }
435   - // altera o indicador de localizacao
436   - lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(p);
437   - lonlat = i3GEO.util.projOSM2Geo(lonlat);
438   - d = i3GEO.calculo.dd2dms(lonlat.lon, lonlat.lat);
439   - try {
440   - $i(idcoord[0].id).innerHTML = "Long: " + d[0] + "<br>Lat: " + d[1];
441   - } catch (e) {
442   - if (typeof (console) !== 'undefined') {
443   - console.error(e);
444   - }
445   - }
446   - });
447   - }
448   - },
449   - criaJanelaBusca : function() {
450   - var layers = i3GEO.editorOL.layersLigados(), nlayers = layers.length, i, ins, combo =
451   - "<select id=i3GEOOLlistaTemasBusca ><option value=''>----</option>";
452   - for (i = 0; i < nlayers; i++) {
453   - combo += "<option value='" + i + "' >" + layers[i].name + "</option>";
454   - }
455   - combo += "</select>";
456   - ins = "<div class=paragrafo >" + $trad("a7") + ":<br>" + combo;
457   - ins += "<br>" + $trad("x64") + ":<br><span id=i3GEOOLcomboitens ></span>";
458   - ins += "<br>" + $trad("t23") + ":<br><input type=text size=20 id=i3GEOOLpalavraBusca >";
459   - ins += "<br><br><input type=button value='" + $trad("t23") + "' id='i3GEOOLbotaoBusca' ></div>";
460   - ins += "<br>'" + $trad("result") + "':<br><span id=i3GEOOLcomboresultado ></span>";
461   - try {
462   - YAHOO.namespace("procura.container");
463   - YAHOO.procura.container.panel = new YAHOO.widget.Panel("panelprocura", {
464   - zIndex : 2000,
465   - iframe : false,
466   - width : "250px",
467   - visible : false,
468   - draggable : true,
469   - close : true
470   - });
471   - YAHOO.procura.container.panel.setHeader("Encontre no mapa");
472   - YAHOO.procura.container.panel.setBody(ins);
473   - YAHOO.procura.container.panel.setFooter("");
474   - YAHOO.procura.container.panel.render(document.body);
475   - YAHOO.procura.container.panel.center();
476   -
477   - document.getElementById("i3GEOOLbotaoBusca").onclick =
478   - function() {
479   - var layer = i3GEO.editorOL.layerAtivo(), item = document.getElementById("i3GEOOLbuscaItem").value, palavra =
480   - document.getElementById("i3GEOOLpalavraBusca").value;
481   - if (item === "" || palavra === "") {
482   - alert("Escolha o item e o texto de busca");
483   - return;
484   - }
485   - i3GEO.editorOL.busca(layer, item, palavra, "i3GEOOLcomboresultado");
486   - };
487   - document.getElementById("i3GEOOLlistaTemasBusca").onchange = function() {
488   - i3GEO.editorOL.ativaTema(this.value);
489   - document.getElementById("i3GEOOLcomboitens").innerHTML = "...";
490   - i3GEO.editorOL.listaItens(i3GEO.editorOL.layerAtivo(), "i3GEOOLcomboitens", "i3GEOOLbuscaItem");
491   - };
492   - } catch (e) {
493   - }
494   - },
495   - criaComboTemas : function() {
496   - var layers = i3GEO.editorOL.layersLigados(), nlayers = layers.length, i, nometema = "", temp, combo =
497   - "<select id=i3GEOOLlistaTemasAtivos style=width:235px; >";
498   - // i3GEO.desenho.layergrafico.setLayerIndex(i3GEO.editorOL.getNumLayers() + 1);
499   - for (i = 0; i < nlayers; i++) {
500   - // pega o nome do tema
501   - nometema = "";
502   - if (i3GEO.arvoreDeCamadas && i3GEO.arvoreDeCamadas.CAMADAS) {
503   - temp = i3GEO.arvoreDeCamadas.pegaTema(layers[i].name, "", "name");
504   - if (temp != "") {
505   - nometema = temp.tema + " - ";
506   - }
507   - }
508   - combo += "<option value='" + i + "' >" + nometema + layers[i].name + "</option>";
509   - }
510   - combo += "</select>";
511   - return combo;
512   - },
513   - atualizaJanelaAtivaTema : function() {
514   - var combo = i3GEO.editorOL.criaComboTemas();
515   - YAHOO.temaativo.container.panel.setBody(combo);
516   - document.getElementById("i3GEOOLlistaTemasAtivos").onchange = function() {
517   - if (botaoIdentifica) {
518   - botaoIdentifica.layers = [
519   - i3GEO.editorOL.layersLigados()[this.value]
520   - ];
521   - }
522   - };
523   - },
524   - criaJanelaAtivaTema : function() {
525   - var temp;
526   - if (!document.getElementById("paneltemaativo")) {
527   - YAHOO.namespace("temaativo.container");
528   - YAHOO.temaativo.container.panel = new YAHOO.widget.Panel("paneltemaativo", {
529   - zIndex : 20000,
530   - iframe : true,
531   - width : "250px",
532   - visible : false,
533   - draggable : true,
534   - close : true
535   - });
536   - YAHOO.temaativo.container.panel.setBody("");
537   - if (i3GEO && typeof i3GEO != undefined && i3GEO != "") {
538   - YAHOO.temaativo.container.panel
539   - .setHeader("Tema ativo<div id='paneltemaativo_minimizaCabecalho' class='container-minimiza'></div>");
540   - } else {
541   - YAHOO.temaativo.container.panel.setHeader($trad("tativo"));
542   - }
543   - YAHOO.temaativo.container.panel.setFooter("");
544   - YAHOO.temaativo.container.panel.render(document.body);
545   - YAHOO.temaativo.container.panel.show();
546   - YAHOO.temaativo.container.panel.center();
547   - i3GEO.editorOL.atualizaJanelaAtivaTema();
548   - YAHOO.util.Event.addListener(YAHOO.temaativo.container.panel.close, "click", function() {
549   - i3GEOpanelEditor.deactivate();
550   - i3GEOpanelEditor.activate();
551   - if (i3GEO.eventos) {
552   - i3GEO.eventos.adicionaEventos("ATUALIZAARVORECAMADAS", [
553   - "i3GEO.editorOL.atualizaJanelaAtivaTema()"
554   - ]);
555   - }
556   - });
557   - if (i3GEO && typeof i3GEO != undefined && i3GEO != "") {
558   - if (i3GEO.eventos) {
559   - i3GEO.eventos.adicionaEventos("ATUALIZAARVORECAMADAS", [
560   - "i3GEO.editorOL.atualizaJanelaAtivaTema()"
561   - ]);
562   - }
563   - }
564   - temp = $i("paneltemaativo_minimizaCabecalho");
565   - if (temp) {
566   - temp.onclick = function() {
567   - i3GEO.janela.minimiza("paneltemaativo");
568   - };
569   - }
570   - } else {
571   - YAHOO.temaativo.container.panel.show();
572   - i3GEO.editorOL.atualizaJanelaAtivaTema();
573   - }
574   - },
575   - ativaTema : function(id) {
576   - document.getElementById("i3GEOOLlistaTemasAtivos").value = id;
577   - },
578   - layerAtivo : function() {
579   - var id = document.getElementById("i3GEOOLlistaTemasAtivos");
580   - if (id) {
581   - id = id.value;
582   - } else {
583   - id = i3GEO.temaAtivo;
584   - }
585   - if (id == "") {
586   - return [];
587   - } else {
588   - return i3GEO.editorOL.layersLigados()[id];
589   - }
590   - },
591   - listaItens : function(layer, idonde, idobj) {
592   - if (!layer) {
593   - return;
594   - }
595   - if (!layer.params) {
596   - return;
597   - }
598   - var u = layer.url + "&request=describefeaturetype&service=wfs&version=1.0.0";
599   - u += "&typename=" + layer.params.LAYERS;
600   - document.body.style.cursor = "wait";
601   - document.getElementById("i3geoMapa").style.cursor = "wait";
602   - OpenLayers.Request.issue({
603   - method : "GET",
604   - url : u,
605   - callback : function(retorno) {
606   - document.body.style.cursor = "default";
607   - document.getElementById("i3geoMapa").style.cursor = "default";
608   - var fromgml = new OpenLayers.Format.WFSDescribeFeatureType({
609   - geometryName : "msGeometry"
610   - }), gml = fromgml.read(retorno.responseText), prop = gml.featureTypes[0].properties, nprop = prop.length, i, combo =
611   - "<select id=" + idobj + " ><option value=''>----</option>";
612   - for (i = 0; i < nprop; i++) {
613   - combo += "<option value=" + prop[i].name + " >" + prop[i].name + "</option>";
614   - }
615   - combo += "</select>";
616   - document.getElementById(idonde).innerHTML = combo;
617   - },
618   - failure : function() {
619   - document.body.style.cursor = "default";
620   - document.getElementById("i3geoMapa").style.cursor = "default";
621   - alert("Erro");
622   - }
623   - });
624   - },
625   - busca : function(layer, item, palavra, onde) {
626   - document.body.style.cursor = "wait";
627   - document.getElementById("i3geoMapa").style.cursor = "wait";
628   - var u = layer.url + "&request=getfeature&service=wfs&version=1.0.0";
629   - u = u.replace("Z=${z}&X=${x}&Y=${y}", "");
630   - u += "&OUTPUTFORMAT=gml2&typename=" + layer.params.LAYERS;
631   - u +=
632   - "&filter=<Filter><PropertyIsLike wildcard=* singleChar=. escape=! ><PropertyName>" + item
633   - + "</PropertyName><Literal>*"
634   - + palavra
635   - + "*</Literal></PropertyIsLike></Filter>";
636   - document.body.style.cursor = "wait";
637   - document.getElementById("i3geoMapa").style.cursor = "wait";
638   - document.getElementById(onde).innerHTML = "...";
639   - OpenLayers.Request.issue({
640   - method : "GET",
641   - url : u,
642   - callback : function(retorno) {
643   - document.body.style.cursor = "default";
644   - document.getElementById("i3geoMapa").style.cursor = "default";
645   - var fromgml = new OpenLayers.Format.GML({
646   - geometryName : "msGeometry"
647   - }), gml = fromgml.read(retorno.responseText), ngml = gml.length, i, ins =
648   - "<select onchange='i3GEO.editorOL.zoomPara(this.value)'>";
649   - ins += "<option value=''>---</option>";
650   - for (i = 0; i < ngml; i++) {
651   - eval("var valor = gml[i].data." + item);
652   - var bounds = gml[i].geometry.getBounds();
653   - bounds = bounds.toBBOX();
654   - ins += "<option value='" + bounds + "'>" + valor + "</option>";
655   - }
656   - ins += "</select>";
657   - document.getElementById(onde).innerHTML = ins;
658   - },
659   - failure : function() {
660   - document.body.style.cursor = "default";
661   - document.getElementById("i3geoMapa").style.cursor = "default";
662   - alert("Erro");
663   - }
664   - });
665   - },
666   - zoomPara : function(bbox) {
667   - var b = new OpenLayers.Bounds.fromString(bbox);
668   - i3GEO.editorOL.mapa.zoomToExtent(b);
669   - },
670   - mostraLegenda : function() {
671   - var layers = i3GEO.editorOL.layersLigados(), nlayers = layers.length, ins = "", i, icone = "", url, fers, f = "", fer = "";
672   - for (i = 0; i < nlayers; i++) {
673   - try {
674   - if (layers[i].isBaseLayer === false) {
675   - url = layers[i].getFullRequestString({
676   - "request" : "getlegendgraphic"
677   - });
678   - icone = "";
679   - if (i3GEO.editorOL.legendahtml === true) {
680   - // os parametros FORMAT e SERVICE sao inseridos de forma redundante para grantir
681   - // caso seja um TMS
682   - url = url.replace("image%2Fpng", "text/html") + "&FORMAT=text/html&SERVICE=WMS";
683   - // verifica se a camada veio de um plugin de classe_plugini3geo
684   - // e insere o icone se for necessario
685   - if (layers[i].options.plugini3geo) {
686   - if (layers[i].params.LAYERS) {
687   - // wms
688   - icone = i3GEO.pluginI3geo[layers[i].options.plugini3geo].iconeArvoreDeCamadas(layers[i].params.LAYERS);
689   - } else {
690   - // tms
691   - icone = i3GEO.pluginI3geo[layers[i].options.plugini3geo].iconeArvoreDeCamadas(layers[i].layers);
692   - }
693   - }
694   - //
695   - // verifica se a camada tem ferramentas parametrizadas
696   - // insere o icone
697   - //
698   - fers = layers[i].options.ferramentas;
699   - for (fer in fers) {
700   - if (i3GEO.configura.ferramentasLayers[fer]) {
701   - icone = i3GEO.configura.ferramentasLayers[fer].icone(layers[i]);
702   - }
703   - }
704   - ins += icone + layers[i].name + "<br><div id=legendaL_" + i + " ></div><br>";
705   - // necessario pq nao e sincrono
706   - eval("var f = function(retorno){document.getElementById('legendaL_" + i
707   - + "').innerHTML = retorno.responseText;};");
708   - var config = {
709   - method : "GET",
710   - url : url,
711   - callback : f
712   - };
713   - OpenLayers.Request.issue(config);
714   - } else {
715   - url = url.replace("LAYERS", "LAYER");
716   - url = url.replace("&Z=${z}&X=${x}&Y=${y}", "");
717   - url = url.replace("Z=${z}&X=${x}&Y=${y}", "");
718   - ins += layers[i].name + "<br><img src='" + url + "&SERVICE=wms' /><br>";
719   - }
720   - }
721   - } catch (e) {
722   - }
723   - }
724   - // var w = window.open();
725   - // w.document.write(ins);
726   - // w.document.close();
727   - if (!document.getElementById("panellegendaeditorOL")) {
728   - YAHOO.namespace("legendaeditorOL.container");
729   - YAHOO.legendaeditorOL.container.panel = new YAHOO.widget.Panel("panellegendaeditorOL", {
730   - zIndex : 20000,
731   - iframe : true,
732   - width : "auto",
733   - visible : false,
734   - draggable : true,
735   - close : true
736   - });
737   - YAHOO.legendaeditorOL.container.panel.setBody(ins);
738   - YAHOO.legendaeditorOL.container.panel.setHeader($trad("p3"));
739   - YAHOO.legendaeditorOL.container.panel.setFooter("");
740   - YAHOO.legendaeditorOL.container.panel.render(document.body);
741   - YAHOO.legendaeditorOL.container.panel.show();
742   - YAHOO.legendaeditorOL.container.panel.center();
743   -
744   - YAHOO.util.Event.addListener(YAHOO.legendaeditorOL.container.panel.close, "click", function() {
745   - YAHOO.legendaeditorOL.container.panel.destroy();
746   - });
747   - } else {
748   - YAHOO.legendaeditorOL.container.panel.setBody(ins);
749   - YAHOO.legendaeditorOL.container.panel.show();
750   - }
751   - },
752   - captura : function(lonlat) {
753   - // if(i3GEO.desenho.layergrafico !== ""){return;}
754   -
755   - var d = 0.1, layers = [
756   - i3GEO.editorOL.layerAtivo()
757   - ], xy = lonlat.split(","), u = layers[0].url + "&REQUEST=getfeature&service=wfs&version=1.0.0";
758   - u += "&OUTPUTFORMAT=gml2&typename=" + layers[0].params.LAYERS;
759   - // remove parametros nao desejados
760   - if (i3GEO.Interface.openlayers.googleLike === true) {
761   - u += "&SRS=EPSG:3857";
762   - }
763   - u = u.replace("&cache=sim", "&DESLIGACACHE=sim");
764   - u = u.replace("&Z=${z}&X=${x}&Y=${y}", "");
765   - u = u.replace("Z=${z}&X=${x}&Y=${y}", "");
766   - // u +=
767   - // "&filter=<Filter><Intersects><PropertyName>Geometry</PropertyName><gml:Point><gml:coordinates>"+lonlat+"</gml:coordinates></gml:Point></Intersects></Filter>";
768   -
769   - xy[0] = xy[0] * 1;
770   - xy[1] = xy[1] * 1;
771   - var poligono =
772   - (xy[0] - d) + ","
773   - + (xy[1] + d)
774   - + " "
775   - + (xy[0] + d)
776   - + ","
777   - + (xy[1] + d)
778   - + " "
779   - + (xy[0] + d)
780   - + ","
781   - + (xy[1] - d)
782   - + " "
783   - + (xy[0] - d)
784   - + ","
785   - + (xy[1] - d)
786   - + " "
787   - + (xy[0] - d)
788   - + ","
789   - + (xy[1] + d);
790   - u +=
791   - "&filter=<Filter><Intersects><PropertyName>Geometry</PropertyName><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:posList>" + poligono
792   - + "</gml:posList></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></Filter>";
793   -
794   - document.body.style.cursor = "wait";
795   - if (document.getElementById("i3geoMapa")) {
796   - document.getElementById("i3geoMapa").style.cursor = "wait";
797   - }
798   - OpenLayers.Request.issue({
799   - method : "GET",
800   - url : u,
801   - callback : function(retorno) {
802   - document.body.style.cursor = "default";
803   - if (document.getElementById("i3geoMapa")) {
804   - document.getElementById("i3geoMapa").style.cursor = "default";
805   - }
806   - var i, n, f, fromgml = new OpenLayers.Format.GML({
807   - geometryName : "msGeometry"
808   - }), gml = fromgml.read(retorno.responseText);
809   - n = gml.length;
810   - for (i = 0; i < n; i++) {
811   - f = gml[i];
812   - f["attributes"] = {
813   - opacidade : i3GEO.editorOL.simbologia.opacidade,
814   - texto : i3GEO.editorOL.simbologia.texto,
815   - fillColor : i3GEO.editorOL.simbologia.fillColor,
816   - strokeWidth : i3GEO.editorOL.simbologia.strokeWidth,
817   - strokeColor : i3GEO.editorOL.simbologia.strokeColor,
818   - pointRadius : i3GEO.editorOL.simbologia.pointRadius,
819   - graphicName : i3GEO.editorOL.simbologia.graphicName,
820   - registros : f["attributes"]
821   - };
822   - }
823   - i3GEO.desenho.layergrafico.addFeatures(gml);
824   - },
825   - failure : function() {
826   - document.body.style.cursor = "default";
827   - if (document.getElementById("i3geoMapa")) {
828   - document.getElementById("i3geoMapa").style.cursor = "default";
829   - }
830   - alert("Erro");
831   - }
832   - });
833   - },
834   - salvaGeometrias : function() {
835   - var geos = i3GEO.desenho.layergrafico.selectedFeatures, n = geos.length, ins = "";
836   - if (n > 0) {
837   - if ($i("panelsalvageometrias")) {
838   - if (YAHOO.i3GEO) {
839   - YAHOO.salvaGeometrias.container.panel = YAHOO.i3GEO.janela.manager.find("panelsalvageometrias");
840   - }
841   - YAHOO.salvaGeometrias.container.panel.show();
842   - YAHOO.salvaGeometrias.container.panel.bringToTop();
843   - } else {
844   - try {
845   - YAHOO.namespace("salvaGeometrias.container");
846   - YAHOO.salvaGeometrias.container.panel = new YAHOO.widget.Panel("panelsalvageometrias", {
847   - zIndex : 2000,
848   - iframe : false,
849   - width : "250px",
850   - visible : false,
851   - draggable : true,
852   - close : true
853   - });
854   - YAHOO.salvaGeometrias.container.panel.setHeader($trad("u6"));
855   - YAHOO.salvaGeometrias.container.panel.setBody("");
856   - YAHOO.salvaGeometrias.container.panel.setFooter("");
857   - YAHOO.salvaGeometrias.container.panel.render(document.body);
858   - YAHOO.salvaGeometrias.container.panel.center();
859   - if (YAHOO.i3GEO && YAHOO.i3GEO.janela) {
860   - YAHOO.i3GEO.janela.manager.register(YAHOO.salvaGeometrias.container.panel);
861   - }
862   - YAHOO.salvaGeometrias.container.panel.show();
863   - } catch (e) {
864   - }
865   - }
866   - ins += "<p class=paragrafo >" + n + " " + $trad("geosel") + "</p>";
867   - ins +=
868   - "<p class=paragrafo ><a href='#' onclick='i3GEO.editorOL.listaGeometriasSel()' >" + $trad("listar")
869   - + "</a>&nbsp;&nbsp;";
870   - if (i3GEO.editorOL.nomeFuncaoSalvar && i3GEO.editorOL.nomeFuncaoSalvar != "") {
871   - ins += "<a href='#' onclick='" + i3GEO.editorOL.nomeFuncaoSalvar + "' >" + $trad("sdados") + "</a>&nbsp;&nbsp;";
872   - }
873   - if (typeof i3geoOL !== "undefined") {
874   - ins += "<a href='#' onclick='i3GEO.editorOL.incorporar()' >" + $trad("incorpo") + "</a></p>";
875   - ins += "<p class=paragrafo>" + $trad("ajudaEditorOlSalva") + "</p>";
876   - }
877   - YAHOO.salvaGeometrias.container.panel.setBody(ins);
878   - } else {
879   - i3GEO.janela.tempoMsg($trad("selum"));
880   - }
881   - },
882   - exportarSHP : function() {
883   - i3GEO.editorOL.processageo("converteSHP");
884   - },
885   - incorporar : function() {
886   - i3GEO.editorOL.processageo("incorporar");
887   - },
888   - listaGeometriasSel : function() {
889   - var geos = i3GEO.desenho.layergrafico.selectedFeatures, n = geos.length, ins = "", i, a, w, g;
890   - for (i = 0; i < n; i++) {
891   - g = geos[i];
892   - ins += "<b>" + $trad("u6") + ": " + i + "</b><br>" + i3GEO.editorOL.google2wgs(g.geometry) + "<br><br>";
893   - ins += "<b>" + $trad("atrib") + ": " + i + "</b><br>";
894   - a = g.attributes;
895   - for (key in a) {
896   - if (a[key]) {
897   - ins += key + " = " + a[key] + "<br>";
898   - }
899   - }
900   - // lista os registros se for fruto de uma captura
901   - if (g.attributes.registros) {
902   - ins += "<b>" + $trad("reg") + ": " + i + "</b><br>";
903   - a = g.attributes.registros;
904   - for (key in a) {
905   - if (a[key]) {
906   - ins += key + " = " + a[key] + "<br>";
907   - }
908   - }
909   - }
910   - ins += "<br>";
911   - }
912   - w = window.open();
913   - w.document.write(ins);
914   - w.document.close();
915   - },
916   - testeSalvar : function() {
917   - alert("Funcao nao disponivel. Defina o nome da funcao em i3GEO.editorOL.nomeFuncaoSalvar ");
918   - },
919   - salvaGeo : function() {
920   - // i3GEO.editorOL.testeSalvar();
921   - // return;
922   - var geos = i3GEO.desenho.layergrafico.selectedFeatures, n = geos.length, funcaoOK =
923   - function() {
924   - // verifica se a geometria contem o atributo que indica a coluna ou codigo unico
925   - if (geos[0].geometry) {
926   - var registros = "", valorunico = "", nometema = $i("editorOLcomboTemaEditavel").value, key = "", tema, redesenha, p, g =
927   - i3GEO.editorOL.google2wgs(geos[0].geometry);
928   - if (nometema == "") {
929   - return;
930   - }
931   - tema = i3GEO.arvoreDeCamadas.pegaTema(nometema, "", "name");
932   - // o tema contem o indicador de qual e a coluna que contem o identificador unico
933   - if (geos[0].attributes.registros) {
934   - registros = geos[0].attributes.registros;
935   - for (key in registros) {
936   - if (registros[key] && key == tema.colunaidunico) {
937   - valorunico = registros[key];
938   - }
939   - }
940   - }
941   - redesenha = function(retorno) {
942   - i3GEO.janela.fechaAguarde("aguardeSalvaPonto");
943   - i3GEO.desenho.layergrafico.removeFeatures(i3GEO.desenho.layergrafico.selectedFeatures);
944   - i3GEO.Interface.atualizaTema("", nometema);
945   - };
946   - i3GEO.janela.AGUARDEMODAL = true;
947   - i3GEO.janela.abreAguarde("aguardeSalvaPonto", $trad("adic") + "...");
948   - i3GEO.janela.AGUARDEMODAL = false;
949   -
950   - // cria um novo registro
951   - if (valorunico == "") {
952   - p =
953   - i3GEO.configura.locaplic + "/ferramentas/editortema/exec.php?funcao=adicionaGeometria&g_sid="
954   - + i3GEO.configura.sid;
955   - cpJSON.call(p, "foo", redesenha, "&tema=" + nometema + "&wkt=" + g);
956   - } else {
957   - // atualiza a geometria
958   - p =
959   - i3GEO.configura.locaplic + "/ferramentas/editortema/exec.php?funcao=atualizaGeometria&g_sid="
960   - + i3GEO.configura.sid;
961   - cpJSON.call(p, "foo", redesenha, "&idunico=" + valorunico + "&tema=" + nometema + "&wkt=" + g);
962   - }
963   - }
964   - }, funcaoCombo = function(obj) {
965   - $i("editorOLondeComboTemaEditavel").innerHTML = obj.dados;
966   - }, texto = $trad("stema") + ":<br><div id=editorOLondeComboTemaEditavel ></div><br><br>";
967   - if (n != 1) {
968   - i3GEO.janela.tempoMsg($trad("seluma"));
969   - } else {
970   - i3GEO.janela.confirma(texto, 300, $trad("salva"), $trad("canc"), funcaoOK);
971   - i3GEO.util.comboTemas("editorOLcomboTemaEditavel", funcaoCombo, "editorOLondeComboTemaEditavel", "", false, "editavel");
972   - }
973   - },
974   - criaBotoes : function(botoes) {
975   - var sketchSymbolizers = {
976   - "Point" : {
977   - pointRadius : 4,
978   - graphicName : "square",
979   - fillColor : "white",
980   - fillOpacity : 1,
981   - strokeWidth : 1,
982   - strokeOpacity : 1,
983   - strokeColor : "#333333"
984   - },
985   - "Line" : {
986   - strokeWidth : 3,
987   - strokeOpacity : 1,
988   - strokeColor : "#666666",
989   - strokeDashstyle : "dash"
990   - },
991   - "Polygon" : {
992   - strokeWidth : 2,
993   - strokeOpacity : 1,
994   - strokeColor : "#666666",
995   - fillColor : "white",
996   - fillOpacity : 0.3
997   - }
998   - };
999   -
1000   - i3GEOpanelEditor = new OpenLayers.Control.Panel({
1001   - displayClass : "olControlEditingToolbar1 noprint",
1002   - saveState : false,
1003   - activateControl : function(c) {
1004   - this.deactivate();
1005   - this.activate();
1006   - try {
1007   - i3GEO.editorOL.ModifyFeature.deactivate();
1008   - if (i3GEO && i3GEO.barraDeBotoes) {
1009   - i3GEO.barraDeBotoes.ativaPadrao();
1010   - }
1011   - } catch (e) {
1012   - }
1013   - if (!c.trigger) {
1014   - c.activate();
1015   - } else {
1016   - c.trigger.call();
1017   - }
1018   - }
1019   - });
1020   - if (botoes.procura === true) {
1021   - button = new OpenLayers.Control.Button({
1022   - displayClass : "editorOLprocura",
1023   - trigger : function() {
1024   - YAHOO.procura.container.panel.show();
1025   - },
1026   - title : $trad("t23"),
1027   - type : OpenLayers.Control.TYPE_BUTTON
1028   - });
1029   - controles.push(button);
1030   - adiciona = true;
1031   - }
1032   - if (botoes.pan === true) {
1033   - controles.push(new OpenLayers.Control.Navigation({
1034   - title : "pan",
1035   - displayClass : "editorOLpan",
1036   - type : OpenLayers.Control.TYPE_TOOL
1037   - }));
1038   - adiciona = true;
1039   - }
1040   - if (botoes.zoombox === true) {
1041   - controles.push(new OpenLayers.Control.ZoomBox({
1042   - title : "zoombox",
1043   - displayClass : "editorOLzoombox",
1044   - type : OpenLayers.Control.TYPE_TOOL
1045   - }));
1046   - adiciona = true;
1047   - }
1048   - if (botoes.zoomtot === true) {
1049   - button = new OpenLayers.Control.Button({
1050   - displayClass : "editorOLzoomtot",
1051   - trigger : function() {
1052   - if (i3GEO.editorOL.mapext && i3GEO.editorOL.mapext != "") {
1053   - i3GEO.editorOL.mapa.zoomToExtent(i3GEO.editorOL.mapext);
1054   - } else {
1055   - i3GEO.editorOL.mapa.zoomToMaxExtent();
1056   - }
1057   - },
1058   - title : $trad("d2t"),
1059   - type : OpenLayers.Control.TYPE_BUTTON
1060   - });
1061   - controles.push(button);
1062   - adiciona = true;
1063   - }
1064   - if (botoes.zoomin === true) {
1065   - button = new OpenLayers.Control.Button({
1066   - displayClass : "editorOLzoomin",
1067   - trigger : function() {
1068   - i3GEO.editorOL.mapa.zoomIn();
1069   - },
1070   - title : $trad("d5t"),
1071   - type : OpenLayers.Control.TYPE_BUTTON
1072   - });
1073   - controles.push(button);
1074   - adiciona = true;
1075   - }
1076   - if (botoes.zoomout === true) {
1077   - button = new OpenLayers.Control.Button({
1078   - displayClass : "editorOLzoomout",
1079   - trigger : function() {
1080   - i3GEO.editorOL.mapa.zoomOut();
1081   - },
1082   - title : $trad("d6t"),
1083   - type : OpenLayers.Control.TYPE_BUTTON
1084   - });
1085   - controles.push(button);
1086   - adiciona = true;
1087   - }
1088   - if (botoes.legenda === true) {
1089   - button = new OpenLayers.Control.Button({
1090   - displayClass : "editorOLlegenda",
1091   - trigger : function() {
1092   - i3GEO.editorOL.mostraLegenda();
1093   - },
1094   - title : $trad("p3"),
1095   - type : OpenLayers.Control.TYPE_BUTTON
1096   - });
1097   - controles.push(button);
1098   - adiciona = true;
1099   - }
1100   - if (botoes.distancia === true) {
1101   - button = new OpenLayers.Control.Measure(OpenLayers.Handler.Path, {
1102   - handlerOptions : {
1103   - layerOptions : {
1104   - styleMap : styleMap
1105   - }
1106   - },
1107   - persist : true,
1108   - displayClass : "editorOLdistancia",
1109   - title : $trad("d21t"),
1110   - type : OpenLayers.Control.TYPE_TOOL
1111   - });
1112   - button.events.on({
1113   - "measure" : function(event) {
1114   - var units = event.units, measure = event.measure;
1115   - alert($trad("d21t") + ": " + measure.toFixed(3) + " " + units);
1116   - }
1117   - });
1118   - controles.push(button);
1119   - adiciona = true;
1120   - }
1121   - if (botoes.area === true) {
1122   - button = new OpenLayers.Control.Measure(OpenLayers.Handler.Polygon, {
1123   - handlerOptions : {
1124   - layerOptions : {
1125   - styleMap : styleMap
1126   - }
1127   - },
1128   - persist : true,
1129   - displayClass : "editorOLarea",
1130   - title : $trad("d21at"),
1131   - type : OpenLayers.Control.TYPE_TOOL
1132   - });
1133   - button.events.on({
1134   - "measure" : function(event) {
1135   - var units = event.units;
1136   - var measure = event.measure;
1137   - alert($trad("d21at") + ": " + measure.toFixed(3) + " " + units + "2");
1138   - }
1139   - });
1140   - controles.push(button);
1141   - adiciona = true;
1142   - }
1143   - if (botoes.identifica === true) {
1144   - botaoIdentifica =
1145   - new OpenLayers.Control.WMSGetFeatureInfo(
1146   - {
1147   - maxFeatures : 1,
1148   - infoFormat : 'text/plain', // 'application/vnd.ogc.gml',
1149   - layers : [
1150   - i3GEO.editorOL.layerAtivo()
1151   - ],
1152   - queryVisible : true,
1153   - title : $trad("d7t"),
1154   - type : OpenLayers.Control.TYPE_TOOL,
1155   - displayClass : "editorOLidentifica",
1156   - eventListeners : {
1157   - getfeatureinfo : function(event) {
1158   - var lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(event.xy), lonlattexto = "<hr>", formata;
1159   - if (botoes.linha === true || botoes.ponto === true || botoes.poligono === true || botoes.edita === true) {
1160   - lonlattexto +=
1161   - "<pre><span style=font-size:12px;color:blue;cursor:pointer onclick='i3GEO.editorOL.captura(\"" + lonlat.lon
1162   - + ","
1163   - + lonlat.lat
1164   - + "\")'>edita geometria</span></pre><br>";
1165   - }
1166   - formata = function(texto) {
1167   - var temp, temp1, n, i, f = [], textoN = texto.split(":");
1168   - try {
1169   - if (textoN.length > 1) {
1170   - temp = textoN[2].replace(/\n\r/g, "");
1171   - temp = temp.replace(/'/g, "");
1172   - temp = temp.replace(/\n/g, "|");
1173   - temp = temp.replace(/_/g, " ");
1174   - temp = temp.replace(/=/g, ":");
1175   - temp = temp.split("|");
1176   - n = temp.length;
1177   - for (i = 0; i < n; i++) {
1178   - temp1 = temp[i].replace(/^\s+/, "");
1179   - temp1 = temp1.replace(/\s+$/, "");
1180   - if (temp1 != "")
1181   - f.push(temp1);
1182   - }
1183   - texto = f.join("<br><br>");
1184   - }
1185   - } catch (e) {
1186   - }
1187   - return texto;
1188   - };
1189   - i3GEO.editorOL.mapa.addPopup(new OpenLayers.Popup.FramedCloud("chicken", i3GEO.editorOL.mapa
1190   - .getLonLatFromPixel(event.xy), null, "<div style=text-align:left >" + lonlattexto
1191   - + "<pre>"
1192   - + formata(event.text)
1193   - + "</pre></div>", null, true));
1194   - i3GEO.editorOL.removeClone();
1195   - },
1196   - beforegetfeatureinfo : function(event) {
1197   - var ativo = [
1198   - i3GEO.editorOL.layerAtivo()
1199   - ];
1200   - // se for TMS tem de pegar o clone wms
1201   - if (ativo[0].serviceVersion === "&tms=" || ativo[0].CLASS_NAME == "OpenLayers.Layer.TMS"
1202   - || ativo[0].CLASS_NAME == "OpenLayers.Layer.OSM") {
1203   - ativo = [
1204   - i3GEO.editorOL.layertms2wms(ativo[0])
1205   - ];
1206   - }
1207   - ativo[0].projection = new OpenLayers.Projection("EPSG:4326");
1208   - event.object.layers = ativo;
1209   - botaoIdentifica.layers = ativo;
1210   - botaoIdentifica.url = ativo[0].url;
1211   - },
1212   - activate : function() {
1213   - i3GEO.editorOL.criaJanelaAtivaTema();
1214   - }
1215   - }
1216   - });
1217   - // button.events.register("getfeatureinfo", this, showInfo);
1218   - controles.push(botaoIdentifica);
1219   - adiciona = true;
1220   - }
1221   - if (botoes.linha === true) {
1222   - button = new OpenLayers.Control.DrawFeature(i3GEO.desenho.layergrafico, OpenLayers.Handler.Path, {
1223   - displayClass : "editorOLlinha",
1224   - title : $trad("dlinha"),
1225   - type : OpenLayers.Control.TYPE_TOOL,
1226   - callbacks : {
1227   - done : function(feature) {
1228   - var f = new OpenLayers.Feature.Vector(feature);
1229   - f["attributes"] = {
1230   - opacidade : i3GEO.editorOL.simbologia.opacidade,
1231   - texto : i3GEO.editorOL.simbologia.texto,
1232   - fillColor : i3GEO.editorOL.simbologia.fillColor,
1233   - strokeWidth : i3GEO.editorOL.simbologia.strokeWidth,
1234   - strokeColor : i3GEO.editorOL.simbologia.strokeColor,
1235   - pointRadius : i3GEO.editorOL.simbologia.pointRadius,
1236   - graphicName : i3GEO.editorOL.simbologia.graphicName
1237   - };
1238   - i3GEO.desenho.layergrafico.addFeatures([
1239   - f
1240   - ]);
1241   - if (document.getElementById("panellistagEditor")) {
1242   - i3GEO.editorOL.listaGeometrias();
1243   - }
1244   - i3GEO.editorOL.sobeLayersGraficos();
1245   - }
1246   - }
1247   - });
1248   - controles.push(button);
1249   - adiciona = true;
1250   - }
1251   - if (botoes.ponto === true) {
1252   - button = new OpenLayers.Control.DrawFeature(i3GEO.desenho.layergrafico, OpenLayers.Handler.Point, {
1253   - displayClass : "editorOLponto",
1254   - title : $trad("dponto"),
1255   - type : OpenLayers.Control.TYPE_TOOL,
1256   - callbacks : {
1257   - done : function(feature) {
1258   - var f, style_mark;
1259   - if (i3GEO.editorOL.simbologia.externalGraphic != "") {
1260   - style_mark = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
1261   - style_mark.externalGraphic = i3GEO.editorOL.simbologia.externalGraphic;
1262   - style_mark.graphicWidth = i3GEO.editorOL.simbologia.graphicWidth;
1263   - style_mark.graphicHeight = i3GEO.editorOL.simbologia.graphicHeight;
1264   - style_mark.fillOpacity = i3GEO.editorOL.simbologia.opacidade;
1265   - f = new OpenLayers.Feature.Vector(feature, null, style_mark);
1266   - } else {
1267   - f = new OpenLayers.Feature.Vector(feature);
1268   - }
1269   - f["attributes"] = {
1270   - opacidade : i3GEO.editorOL.simbologia.opacidade,
1271   - texto : i3GEO.editorOL.simbologia.texto,
1272   - fillColor : i3GEO.editorOL.simbologia.fillColor,
1273   - strokeWidth : i3GEO.editorOL.simbologia.strokeWidth,
1274   - strokeColor : i3GEO.editorOL.simbologia.strokeColor,
1275   - pointRadius : i3GEO.editorOL.simbologia.pointRadius,
1276   - graphicName : i3GEO.editorOL.simbologia.graphicName,
1277   - externalGraphic : i3GEO.editorOL.simbologia.externalGraphic,
1278   - graphicHeight : i3GEO.editorOL.simbologia.graphicHeight,
1279   - graphicWidth : i3GEO.editorOL.simbologia.graphicWidth
1280   - };
1281   - i3GEO.desenho.layergrafico.addFeatures([
1282   - f
1283   - ]);
1284   - if (document.getElementById("panellistagEditor")) {
1285   - i3GEO.editorOL.listaGeometrias();
1286   - }
1287   - i3GEO.editorOL.sobeLayersGraficos();
1288   - }
1289   - }
1290   - });
1291   - controles.push(button);
1292   - adiciona = true;
1293   - }
1294   - if (botoes.poligono === true) {
1295   - button = new OpenLayers.Control.DrawFeature(i3GEO.desenho.layergrafico, OpenLayers.Handler.Polygon, {
1296   - displayClass : "editorOLpoligono",
1297   - title : $trad("dpol"),
1298   - type : OpenLayers.Control.TYPE_TOOL,
1299   - // handlerOptions: {holeModifier: "altKey"},
1300   - callbacks : {
1301   - done : function(feature) {
1302   - var f = new OpenLayers.Feature.Vector(feature);
1303   - f["attributes"] = {
1304   - opacidade : i3GEO.editorOL.simbologia.opacidade,
1305   - texto : i3GEO.editorOL.simbologia.texto,
1306   - fillColor : i3GEO.editorOL.simbologia.fillColor,
1307   - strokeWidth : i3GEO.editorOL.simbologia.strokeWidth,
1308   - strokeColor : i3GEO.editorOL.simbologia.strokeColor,
1309   - pointRadius : i3GEO.editorOL.simbologia.pointRadius,
1310   - graphicName : i3GEO.editorOL.simbologia.graphicName
1311   - };
1312   - i3GEO.desenho.layergrafico.addFeatures([
1313   - f
1314   - ]);
1315   - if (document.getElementById("panellistagEditor")) {
1316   - i3GEO.editorOL.listaGeometrias();
1317   - }
1318   - i3GEO.editorOL.sobeLayersGraficos();
1319   - }
1320   - }
1321   - });
1322   - controles.push(button);
1323   - adiciona = true;
1324   - }
1325   - if (botoes.texto === true) {
1326   - button = new OpenLayers.Control.DrawFeature(i3GEO.desenho.layergrafico, OpenLayers.Handler.Point, {
1327   - displayClass : "editorOLtexto",
1328   - title : $trad("dtexto"),
1329   - type : OpenLayers.Control.TYPE_TOOL,
1330   - persist : true,
1331   - callbacks : {
1332   - done : function(feature) {
1333   - var texto = window.prompt("Texto", ""), label = new OpenLayers.Feature.Vector(feature);
1334   - label["attributes"] = {
1335   - opacidade : 0.1,
1336   - fillColor : "white",
1337   - strokeWidth : i3GEO.editorOL.simbologia.strokeWidth,
1338   - texto : texto,
1339   - pointRadius : 2,
1340   - graphicName : "square",
1341   - strokeColor : "black",
1342   - fontColor : i3GEO.editorOL.simbologia.fontColor,
1343   - fontSize : i3GEO.editorOL.simbologia.fontSize,
1344   - fontFamily : "Arial",
1345   - fontWeight : "bold",
1346   - labelAlign : "rt"
1347   - };
1348   - if (texto && texto !== "") {
1349   - i3GEO.desenho.layergrafico.addFeatures([
1350   - label
1351   - ]);
1352   - }
1353   - i3GEO.editorOL.sobeLayersGraficos();
1354   - }
1355   - }
1356   - });
1357   - controles.push(button);
1358   - adiciona = true;
1359   - }
1360   - if (botoes.edita === true && botoes.corta === true && i3GEO.php) {
1361   - i3GEO.editorOL.CortaFeature = new OpenLayers.Control.DrawFeature(i3GEO.desenho.layergrafico, OpenLayers.Handler.Polygon, {
1362   - displayClass : "editorOLcorta",
1363   - title : $trad("cortaf"),
1364   - type : OpenLayers.Control.TYPE_TOOL,
1365   - clickout : true,
1366   - toggle : true,
1367   - trigger : function() {
1368   - if (i3GEO.desenho.layergrafico.selectedFeatures.length != 1) {
1369   - alert("Selecione primeiro um elemento para ser cortado");
1370   - i3GEO.editorOL.CortaFeature.deactivate();
1371   - } else {
1372   - i3GEO.editorOL.CortaFeature.activate();
1373   - }
1374   - },
1375   - callbacks : {
1376   - done : function(feature) {
1377   - var temp, sel = i3GEO.desenho.layergrafico.selectedFeatures[0].geometry, corta = feature;
1378   - temp = function(retorno) {
1379   - i3GEO.janela.fechaAguarde("i3GEO.cortador");
1380   - if (retorno != "" && retorno.data && retorno.data != "") {
1381   - i3GEO.editorOL.substituiFeaturesSel(retorno.data);
1382   - }
1383   - };
1384   - i3GEO.janela.abreAguarde("i3GEO.cortador", "Cortando");
1385   - i3GEO.php.funcoesGeometriasWkt(temp, sel + "|" + corta, "difference");
1386   - }
1387   - }
1388   - });
1389   - controles.push(i3GEO.editorOL.CortaFeature);
1390   - adiciona = true;
1391   - }
1392   - if (botoes.edita === true) {
1393   - i3GEO.editorOL.ModifyFeature = new OpenLayers.Control.ModifyFeature(i3GEO.desenho.layergrafico, {
1394   - displayClass : "editorOLedita",
1395   - title : $trad("modf"),
1396   - type : OpenLayers.Control.TYPE_TOOL,
1397   - clickout : true,
1398   - toggle : true,
1399   - mode : OpenLayers.Control.ModifyFeature.RESHAPE,
1400   - standalone : false,
1401   - createVertices : true,
1402   - styleMap : "default",
1403   - vertexRenderIntent : "vertex"
1404   - });
1405   - controles.push(i3GEO.editorOL.ModifyFeature);
1406   - adiciona = true;
1407   - }
1408   - if (botoes.edita === true && botoes.listag === true) {
1409   - button = new OpenLayers.Control.Button({
1410   - displayClass : "editorOLlistag",
1411   - trigger : function() {
1412   - i3GEO.editorOL.listaGeometrias();
1413   - },
1414   - title : $trad("listag"),
1415   - type : OpenLayers.Control.TYPE_BUTTON
1416   - });
1417   - controles.push(button);
1418   - adiciona = true;
1419   - }
1420   - if (botoes.frente === true) {
1421   - button = new OpenLayers.Control.Button({
1422   - displayClass : "editorOLfrente",
1423   - trigger : function() {
1424   - i3GEO.editorOL.trazParaFrente();
1425   - if (document.getElementById("panellistagEditor")) {
1426   - i3GEO.editorOL.listaGeometrias();
1427   - }
1428   - },
1429   - title : $trad("frente"),
1430   - type : OpenLayers.Control.TYPE_BUTTON
1431   - });
1432   - controles.push(button);
1433   - adiciona = true;
1434   - }
1435   - if (botoes.tools === true && i3GEO.php) {
1436   - button = new OpenLayers.Control.Button({
1437   - displayClass : "editorOLtools",
1438   - trigger : function() {
1439   - // fora do i3geo, usa o jsts
1440   - if (i3GEO.php) {
1441   - i3GEO.editorOL.ferramentas();
1442   - } else {
1443   - i3GEO.editorOL.carregajts("i3GEO.editorOL.ferramentas()");
1444   - }
1445   -
1446   - },
1447   - title : $trad("u15a"),
1448   - type : OpenLayers.Control.TYPE_BUTTON
1449   - });
1450   - controles.push(button);
1451   - adiciona = true;
1452   - }
1453   - // botao de sele&ccedil;&atilde;o
1454   - if (botoes.selecao === true) {
1455   - i3GEO.editorOL.selbutton = new OpenLayers.Control.SelectFeature(i3GEO.desenho.layergrafico, {
1456   - displayClass : "editorOLselecao",
1457   - title : $trad("d24t"),
1458   - type : OpenLayers.Control.TYPE_TOOL,
1459   - clickout : true,
1460   - toggle : true,
1461   - multiple : false,
1462   - hover : false,
1463   - toggleKey : "ctrlKey", // ctrl key removes from selection
1464   - multipleKey : "shiftKey", // shift key adds to selection
1465   - box : false
1466   - });
1467   - controles.push(i3GEO.editorOL.selbutton);
1468   - adiciona = true;
1469   - }
1470   - // botao de selecionar tudo
1471   - if (botoes.selecaotudo === true) {
1472   - button = new OpenLayers.Control.Button({
1473   - displayClass : "editorOLselecaoTudo",
1474   - trigger : function() {
1475   - var fs = i3GEO.desenho.layergrafico.features, n = fs.length, i;
1476   - for (i = 0; i < n; i++) {
1477   - i3GEO.editorOL.selbutton.select(fs[i]);
1478   - }
1479   - },
1480   - title : $trad("studo"),
1481   - type : OpenLayers.Control.TYPE_BUTTON
1482   - });
1483   - controles.push(button);
1484   - adiciona = true;
1485   - }
1486   - if (botoes.apaga === true) {
1487   - button = new OpenLayers.Control.Button({
1488   - displayClass : "editorOLapaga",
1489   - trigger : function() {
1490   - if (i3GEO.desenho.layergrafico.selectedFeatures.length > 0) {
1491   - var x = window.confirm($trad("excsel") + "?");
1492   - if (x) {
1493   - i3GEO.editorOL.guardaBackup();
1494   - i3GEO.desenho.layergrafico.removeFeatures(i3GEO.desenho.layergrafico.selectedFeatures);
1495   - if (document.getElementById("panellistagEditor")) {
1496   - i3GEO.editorOL.listaGeometrias();
1497   - }
1498   - if (typeof i3geoOL !== "undefined") {
1499   - i3GEO.janela.tempoMsg($trad("meneditor1"));
1500   - }
1501   - }
1502   - } else {
1503   - i3GEO.janela.tempoMsg($trad("seluma"));
1504   - }
1505   - },
1506   - title : $trad("excsel"),
1507   - type : OpenLayers.Control.TYPE_BUTTON
1508   - });
1509   - controles.push(button);
1510   - adiciona = true;
1511   - }
1512   - // n&atilde;o dispon&iacute;vel ainda
1513   - /*
1514   - * if(botoes.undo===true){ button = new OpenLayers.Control.Button({ displayClass: "editorOLundo", trigger:
1515   - * function(){i3GEO.editorOL.restauraBackup();}, title: "recupera" }); controles.push(button); adiciona = true; }
1516   - */
1517   - if (botoes.propriedades === true) {
1518   - button = new OpenLayers.Control.Button({
1519   - displayClass : "editorOLpropriedades",
1520   - trigger : function() {
1521   - i3GEO.editorOL.propriedades();
1522   - },
1523   - title : $trad("p13"),
1524   - type : OpenLayers.Control.TYPE_BUTTON
1525   - });
1526   - controles.push(button);
1527   - adiciona = true;
1528   - }
1529   - if (botoes.salva === true) {
1530   - button = new OpenLayers.Control.Button({
1531   - displayClass : "editorOLsalva",
1532   - trigger : function() {
1533   - i3GEO.editorOL.salvaGeometrias();
1534   - },
1535   - title : $trad("salva"),
1536   - type : OpenLayers.Control.TYPE_BUTTON
1537   - });
1538   - controles.push(button);
1539   - adiciona = true;
1540   - }
1541   - if (botoes.ajuda === true) {
1542   - button = new OpenLayers.Control.Button({
1543   - displayClass : "editorOLajuda",
1544   - trigger : function() {
1545   - try {
1546   - window.open(i3GEO.configura.locaplic + "/mashups/openlayers_ajuda.php");
1547   - } catch (e) {
1548   - window.open("openlayers_ajuda.php");
1549   - }
1550   - },
1551   - title : $trad("s1"),
1552   - type : OpenLayers.Control.TYPE_BUTTON
1553   - });
1554   - controles.push(button);
1555   - adiciona = true;
1556   - }
1557   - if (botoes.fecha === true) {
1558   - button = new OpenLayers.Control.Button({
1559   - displayClass : "editorOLfecha",
1560   - trigger : function() {
1561   - var temp = window.confirm($trad("x94"));
1562   - if (i3GEO.eventos) {
1563   - i3GEO.eventos.cliquePerm.ativa();
1564   - }
1565   - i3GEOpanelEditor.destroy();
1566   - try {
1567   - YAHOO.temaativo.container.panel.destroy();
1568   - } catch (e) {
1569   - }
1570   - try {
1571   - YAHOO.procura.container.panel.destroy();
1572   - } catch (e) {
1573   - }
1574   - try {
1575   - YAHOO.editorOL.container.panel.destroy();
1576   - } catch (e) {
1577   - }
1578   - try {
1579   - YAHOO.editorOL.listaGeometrias.panel.destroy();
1580   - } catch (e) {
1581   - }
1582   - // try{YAHOO.panelpropriedadesEditor.panel.destroy();}catch(e){}
1583   - // try{YAHOO.editorOL.panellistagEditor.panel.destroy();}catch(e){}
1584   - try {
1585   - YAHOO.editorOL.ferramentas.panel.destroy();
1586   - } catch (e) {
1587   - }
1588   - // try{YAHOO.panelprocura.panel.destroy();}catch(e){}
1589   - try {
1590   - YAHOO.legendaeditorOL.container.panel.destroy();
1591   - } catch (e) {
1592   - }
1593   - try {
1594   - YAHOO.salvaGeometrias.container.panel.destroy();
1595   - } catch (e) {
1596   - }
1597   - if (temp === true) {
1598   - try {
1599   - if (i3GEO.desenho.layergrafico) {
1600   - i3GEO.editorOL.mapa.removeLayer(i3GEO.desenho.layergrafico);
1601   - delete (i3GEO.desenho.layergrafico);
1602   - }
1603   - if (i3GEO.editorOL.backup) {
1604   - i3GEO.editorOL.mapa.removeLayer(i3GEO.editorOL.backup);
1605   - delete (i3GEO.editorOL.backup);
1606   - }
1607   - } catch (e) {
1608   - }
1609   - }
1610   - },
1611   - title : $trad("x74"),
1612   - type : OpenLayers.Control.TYPE_BUTTON
1613   - });
1614   - controles.push(button);
1615   - adiciona = true;
1616   - }
1617   - //
1618   - // controle que permite o snap
1619   - //
1620   - i3GEOOLsnap = new OpenLayers.Control.Snapping({
1621   - layer : i3GEO.desenho.layergrafico
1622   - });
1623   - i3GEOOLsplit = new OpenLayers.Control.Split({
1624   - layer : i3GEO.desenho.layergrafico,
1625   - source : i3GEO.desenho.layergrafico,
1626   - tolerance : 0.0001,
1627   - eventListeners : {
1628   - beforesplit : function(event) {
1629   - i3GEO.editorOL.guardaBackup();
1630   - },
1631   - aftersplit : function(event) {
1632   - i3GEO.editorOL.flashFeatures(event.features);
1633   - if (document.getElementById("panellistagEditor")) {
1634   - i3GEO.editorOL.listaGeometrias();
1635   - }
1636   - }
1637   - }
1638   - });
1639   - //
1640   - // adiciona o painel ao mapa se alguma opcao foi inserida
1641   - //
1642   - if (adiciona === true) {
1643   - i3GEOpanelEditor.addControls(controles);
1644   - i3GEO.editorOL.mapa.addControl(i3GEOpanelEditor);
1645   - }
1646   - },
1647   - mudaSimbolo : function(estilo, id) {
1648   - var valor = $i(id).value, geos = i3GEO.desenho.layergrafico.selectedFeatures, n = geos.length, i;
1649   - i3GEO.editorOL.simbologia[estilo] = valor;
1650   - for (i = 0; i < n; i++) {
1651   - geos[i].attributes[estilo] = valor;
1652   - geos[i].style[estilo] = valor;
1653   - }
1654   - },
1655   - adicionaMarcas : function() {
1656   - if (i3GEO.editorOL.pontos.length === 0) {
1657   - return;
1658   - }
1659   - var f, SHADOW_Z_INDEX = 10, MARKER_Z_INDEX = 11, layer = new OpenLayers.Layer.Vector("pontos", {
1660   - styleMap : new OpenLayers.StyleMap({
1661   - externalGraphic : i3GEO.editorOL.marca,
1662   - backgroundGraphic : "../pacotes/openlayers/img/marker_shadow.png",
1663   - backgroundXOffset : 0,
1664   - backgroundYOffset : -7,
1665   - graphicZIndex : MARKER_Z_INDEX,
1666   - backgroundGraphicZIndex : SHADOW_Z_INDEX,
1667   - pointRadius : 10
1668   - }),
1669   - isBaseLayer : false,
1670   - rendererOptions : {
1671   - yOrdering : true
1672   - },
1673   - displayInLayerSwitcher : true,
1674   - visibility : true
1675   - }), index, x = [], y = [], features = [];
1676   - for (index = 0; index < i3GEO.editorOL.pontos.length; index = index + 2) {
1677   - x.push(i3GEO.editorOL.pontos[index]);
1678   - y.push(i3GEO.editorOL.pontos[index + 1]);
1679   - }
1680   - for (index = 0; index < x.length; index++) {
1681   - f = new OpenLayers.Geometry.Point(x[index], y[index]);
1682   - f = i3GEO.util.projGeo2OSM(f);
1683   - f = new OpenLayers.Feature.Vector(f);
1684   - features.push(f);
1685   - }
1686   - layer.addFeatures(features);
1687   - i3GEO.editorOL.mapa.addLayer(layer);
1688   - },
1689   - adicionaKml : function() {
1690   - var temp, n, i, id, url;
1691   - n = i3GEO.editorOL.kml.length;
1692   - for (i = 0; i < n; i++) {
1693   - id = "kml" + i;
1694   - url = i3GEO.editorOL.kml[i];
1695   - eval(id + " = new OpenLayers.Layer.Vector('"
1696   - + id
1697   - + "', {displayOutsideMaxExtent:true,displayInLayerSwitcher:false,visibility:true, strategies: [new OpenLayers.Strategy.Fixed()],protocol: new OpenLayers.Protocol.HTTP({url: '"
1698   - + url
1699   - + "',format: new OpenLayers.Format.KML({extractStyles: true,extractAttributes: true,maxDepth: 5})})})");
1700   - eval("i3GEO.editorOL.mapa.addLayer(" + id + ");");
1701   - eval("temp = " + id + ".div;");
1702   - temp.onclick =
1703   - function(e) {
1704   - var targ = "", id, temp, features, n, i, g, html = "";
1705   - if (!e) {
1706   - e = window.event;
1707   - }
1708   - if (e.target) {
1709   - targ = e.target;
1710   - } else {
1711   - if (e.srcElement) {
1712   - targ = e.srcElement;
1713   - }
1714   - }
1715   - if (targ.id) {
1716   - temp = targ.id.split("_");
1717   - if (temp[0] === "OpenLayers.Geometry.Point") {
1718   - id = targ.id;
1719   - temp = i3GEO.editorOL.mapa.getLayer(this.id);
1720   - features = temp.features;
1721   - n = features.length;
1722   - for (i = 0; i < n; i++) {
1723   - if (features[i].geometry.id === id) {
1724   - for ( var j in features[i].attributes) {
1725   - html += j + ": " + features[i].attributes[j];
1726   - }
1727   - g = features[i].geometry;
1728   - i3GEO.editorOL.mapa.addPopup(new OpenLayers.Popup.FramedCloud(
1729   - "kml",
1730   - new OpenLayers.LonLat(g.x, g.y),
1731   - null,
1732   - html,
1733   - null,
1734   - true));
1735   - }
1736   - }
1737   - }
1738   - }
1739   - };
1740   - }
1741   - },
1742   - // obtido de openlayers.org
1743   - propriedades : function() {
1744   - if (!document.getElementById("panelpropriedadesEditor")) {
1745   - YAHOO.namespace("editorOL.container");
1746   - YAHOO.editorOL.container.panel = new YAHOO.widget.Panel("panelpropriedadesEditor", {
1747   - zIndex : 20000,
1748   - iframe : true,
1749   - width : "350px",
1750   - height : "250px",
1751   - visible : false,
1752   - draggable : true,
1753   - close : true
1754   - });
1755   - var ins =
1756   - "" + '<p class=paragrafo ><b>Estilos (utilize a cor no formato r,g,b):</b></p>'
1757   - + '<table class=lista7 >'
1758   - + ' <tr>'
1759   - + ' <td>Cor do contorno</td><td><input onchange="i3GEO.editorOL.mudaSimbolo(\'strokeColor\',\'i3GEOEditorOLcorContorno\')" type="text" style="cursor:text" id="i3GEOEditorOLcorContorno" size="12" value="'
1760   - + i3GEO.editorOL.simbologia.strokeColor
1761   - + '" /></td><td>';
1762   - if (i3GEO.configura) {
1763   - ins +=
1764   - '<img alt="aquarela.gif" style=cursor:pointer src="' + i3GEO.configura.locaplic
1765   - + '/imagens/aquarela.gif" onclick="i3GEO.util.abreCor(\'\',\'i3GEOEditorOLcorContorno\');" />';
1766   - }
1767   - ins +=
1768   - "" + ' </td>'
1769   - + ' </tr>'
1770   - + ' <tr>'
1771   - + ' <td>Cor do preenchimento</td><td><input onchange="i3GEO.editorOL.mudaSimbolo(\'fillColor\',\'i3GEOEditorOLcorPre\')" type="text" style="cursor:text" id="i3GEOEditorOLcorPre" size="12" value="'
1772   - + i3GEO.editorOL.simbologia.fillColor
1773   - + '" /></td><td>';
1774   - if (i3GEO.configura) {
1775   - ins +=
1776   - '<img alt="aquarela.gif" style=cursor:pointer src="' + i3GEO.configura.locaplic
1777   - + '/imagens/aquarela.gif" onclick="i3GEO.util.abreCor(\'\',\'i3GEOEditorOLcorPre\');" />';
1778   - }
1779   - ins +=
1780   - "" + ' </td>'
1781   - + ' </tr>'
1782   - + ' <tr>'
1783   - + ' <td>Cor da fonte</td><td><input onchange="i3GEO.editorOL.mudaSimbolo(\'fontColor\',\'i3GEOEditorOLcorFonte\')" type="text" style="cursor:text" id="i3GEOEditorOLcorFonte" size="12" value="'
1784   - + i3GEO.editorOL.simbologia.fontColor
1785   - + '" /></td><td>';
1786   - if (i3GEO.configura) {
1787   - ins +=
1788   - '<img alt="aquarela.gif" style=cursor:pointer src="' + i3GEO.configura.locaplic
1789   - + '/imagens/aquarela.gif" onclick="i3GEO.util.abreCor(\'\',\'i3GEOEditorOLcorFonte\');" />';
1790   - }
1791   - ins +=
1792   - "" + ' </td>'
1793   - + ' </tr>'
1794   - + ' <tr>'
1795   - + ' <td>Tamanho da fonte</td><td><input onchange="i3GEO.editorOL.mudaSimbolo(\'fontSize\',\'i3GEOEditorOLfontsize\')" type="text" style="cursor:text" id="i3GEOEditorOLfontsize" size="3" value="' + i3GEO.editorOL.simbologia.fontSize
1796   - + '" /></td><td></td>'
1797   - + ' </tr>'
1798   - + ' <tr>'
1799   - + ' <td>Opacidade (de 0 a 1)</td><td><input onchange="i3GEO.editorOL.mudaSimbolo(\'opacidade\',\'i3GEOEditorOLopacidade\')" type="text" style="cursor:text" id="i3GEOEditorOLopacidade" size="3" value="'
1800   - + i3GEO.editorOL.simbologia.opacidade
1801   - + '" /></td><td></td>'
1802   - + ' </tr>'
1803   - + ' <tr>'
1804   - + ' <td>Largura da linha/contorno</td><td><input onchange="i3GEO.editorOL.mudaSimbolo(\'strokeWidth\',\'i3GEOEditorOLlarguraLinha\')" type="text" style="cursor:text" id="i3GEOEditorOLlarguraLinha" size="2" value="'
1805   - + i3GEO.editorOL.simbologia.strokeWidth
1806   - + '" /></td><td></td>'
1807   - + ' </tr>'
1808   - + ' <tr>'
1809   - + ' <td>Url de uma figura</td><td><input onchange="i3GEO.editorOL.mudaSimbolo(\'externalGraphic\',\'i3GEOEditorOLexternalGraphic\')" type="text" style="cursor:text" id="i3GEOEditorOLexternalGraphic" size="22" value="'
1810   - + i3GEO.editorOL.simbologia.externalGraphic
1811   - + '" /></td><td></td>'
1812   - + ' </tr>'
1813   - + ' <tr>'
1814   - + ' <td>Largura e altura</td><td><input onchange="i3GEO.editorOL.mudaSimbolo(\'graphicWidth\',\'i3GEOEditorOLgraphicWidth\')" type="text" style="cursor:text" id="i3GEOEditorOLgraphicWidth" size="4" value="'
1815   - + i3GEO.editorOL.simbologia.graphicWidth
1816   - + '" />&nbsp;<input onchange="i3GEO.editorOL.mudaSimbolo(\'graphicHeight\',\'i3GEOEditorOLgraphicHeight\')" type="text" style="cursor:text" id="i3GEOEditorOLgraphicHeight" size="4" value="'
1817   - + i3GEO.editorOL.simbologia.graphicHeight
1818   - + '" /></td><td></td>'
1819   - + ' </tr>'
1820   - + '</table>'
1821   - + '<br />'
1822   - + '<p class=paragrafo ><b>Ajusta n&oacute; em edi&ccedil;&atilde;o para o(a):</b></p>'
1823   - + '<table class=lista7 >'
1824   - + ' <tr>'
1825   - + ' <td></td><td>n&oacute</td><td></td><td>v&eacute;rtice</td><td></td><td>borda</td>'
1826   - + ' </tr>'
1827   - + ' <tr>'
1828   - + ' <td><input style=cursor:pointer onclick="i3GEO.editorOL.snap()" type="checkbox" id="target_node" /></td><td><input onchange="i3GEO.editorOL.snap()" id="target_nodeTolerance" type="text" size="3" value=15 /></td>'
1829   - + ' <td><input style=cursor:pointer onclick="i3GEO.editorOL.snap()" type="checkbox" id="target_vertex" /></td><td><input onchange="i3GEO.editorOL.snap()" id="target_vertexTolerance" type="text" size="3" value=15 /></td>'
1830   - + ' <td><input style=cursor:pointer onclick="i3GEO.editorOL.snap()" type="checkbox" id="target_edge" /></td><td><input onchange="i3GEO.editorOL.snap()" id="target_edgeTolerance" type="text" size="3" value=15 /></td>'
1831   - + ' </tr>'
1832   - + '</table>'
1833   - + '<br />'
1834   - + '<p class=paragrafo ><b>Divide intersec&ccedil;&atilde;o ao digitalizar</b></p>'
1835   - + '<table class=lista7 >'
1836   - + ' <tr>'
1837   - + ' <td><input style=cursor:pointer onclick="i3GEO.editorOL.split()" type="checkbox" id="edge_split_toggle" /></td><td>borda</td>'
1838   - + ' </tr>'
1839   - + '</table>'
1840   - + '<br />'
1841   - + '<p class=paragrafo ><b>Opera&ccedil;&atilde;o ativada pelo bot&atilde;o de modifica&ccedil;&atilde;o da figura</b></p>'
1842   - + '<table class=lista7 >'
1843   - + ' <tr>'
1844   - + ' <td><input checked style=cursor:pointer onclick="i3GEO.editorOL.ModifyFeature.mode = OpenLayers.Control.ModifyFeature.RESHAPE;" type="radio" name=i3geoOLtipoEdita /></td><td>altera figura</td>'
1845   - + ' <td><input style=cursor:pointer onclick="i3GEO.editorOL.ModifyFeature.mode = OpenLayers.Control.ModifyFeature.RESIZE;" type="radio" name=i3geoOLtipoEdita /></td><td>altera tamanho</td>'
1846   - + ' </tr>'
1847   - + ' <tr>'
1848   - + ' <td><input style=cursor:pointer onclick="i3GEO.editorOL.ModifyFeature.mode = OpenLayers.Control.ModifyFeature.ROTATE;" type="radio" name=i3geoOLtipoEdita /></td><td>rotaciona</td>'
1849   - + ' <td><input style=cursor:pointer onclick="i3GEO.editorOL.ModifyFeature.mode = OpenLayers.Control.ModifyFeature.DRAG;" type="radio" name=i3geoOLtipoEdita /></td><td>desloca</td>'
1850   - + ' </tr>'
1851   - + '</table>';
1852   - YAHOO.editorOL.container.panel.setBody(ins);
1853   - if (i3GEO && typeof i3GEO != undefined && i3GEO != "") {
1854   - YAHOO.editorOL.container.panel
1855   - .setHeader("Propriedades<div id='panelpropriedadesEditor_minimizaCabecalho' class='container-minimiza'></div>");
1856   - } else {
1857   - YAHOO.editorOL.container.panel.setHeader("Propriedades");
1858   - }
1859   -
1860   - YAHOO.editorOL.container.panel.setFooter("");
1861   - YAHOO.editorOL.container.panel.render(document.body);
1862   -
1863   - YAHOO.editorOL.container.panel.center();
1864   - YAHOO.util.Event.addListener(YAHOO.editorOL.container.panel.close, "click", function() {
1865   - });
1866   - temp = $i("panelpropriedadesEditor_minimizaCabecalho");
1867   - if (temp) {
1868   - temp.onclick = function() {
1869   - i3GEO.janela.minimiza("panelpropriedadesEditor");
1870   - };
1871   - }
1872   - }
1873   - YAHOO.editorOL.container.panel.show();
1874   - temp = $i("panelpropriedadesEditor").getElementsByTagName("div");
1875   - if (temp && temp[2]) {
1876   - temp[2].style.overflow = "auto";
1877   - }
1878   - },
1879   - listaGeometrias : function() {
1880   - if (!document.getElementById("panellistagEditor")) {
1881   - YAHOO.namespace("editorOL.listaGeometrias");
1882   - YAHOO.editorOL.listaGeometrias.panel = new YAHOO.widget.Panel("panellistagEditor", {
1883   - zIndex : 20000,
1884   - iframe : true,
1885   - width : "320px",
1886   - visible : false,
1887   - draggable : true,
1888   - close : true
1889   - });
1890   - if (i3GEO && typeof i3GEO != undefined && i3GEO != "") {
1891   - YAHOO.editorOL.listaGeometrias.panel
1892   - .setHeader($trad("u6") + " <div id='panellistagEditor_minimizaCabecalho' class='container-minimiza'></div>");
1893   - } else {
1894   - YAHOO.editorOL.listaGeometrias.panel.setHeader($trad("u6"));
1895   - }
1896   - YAHOO.editorOL.listaGeometrias.panel.setFooter("");
1897   - YAHOO.editorOL.listaGeometrias.panel.render(document.body);
1898   - YAHOO.editorOL.listaGeometrias.panel.center();
1899   - YAHOO.util.Event.addListener(YAHOO.editorOL.listaGeometrias.panel.close, "click", function() {
1900   - YAHOO.editorOL.listaGeometrias.panel.destroy();
1901   - });
1902   - temp = $i("panellistagEditor_minimizaCabecalho");
1903   - if (temp) {
1904   - temp.onclick = function() {
1905   - i3GEO.janela.minimiza("panellistagEditor");
1906   - };
1907   - }
1908   - } else {
1909   - YAHOO.editorOL.listaGeometrias.panel.render(document.body);
1910   - }
1911   - var g, temp, geos = i3GEO.desenho.layergrafico.features, n = geos.length, ins = "<table class=lista4 >";
1912   - ins += "<tr><td><i>" + $trad("u6") + "</i></td><td><i>" + $trad("opcoes") + "</i></td><td></td><td></td></tr>";
1913   -
1914   - while (n > 0) {
1915   - n -= 1;
1916   - g = geos[n].geometry;
1917   - ins +=
1918   - "<tr><td>" + g.CLASS_NAME
1919   - + "</td><td style='cursor:pointer;color:blue' onclick='javascript:i3GEO.editorOL.selFeature("
1920   - + n
1921   - + ")'>seleciona</td><td style='cursor:pointer;color:blue' onclick='javascript:i3GEO.editorOL.unselFeature("
1922   - + n
1923   - + ")'>limpa</td><td style='cursor:pointer;color:blue' onclick='javascript:i3GEO.editorOL.flashFeaturesI("
1924   - + n
1925   - + ")'>brilha</td></tr>";
1926   - }
1927   - ins += "</table>";
1928   - if (geos.length === 0) {
1929   - ins = $trad("meneditor2");
1930   - }
1931   - YAHOO.editorOL.listaGeometrias.panel.show();
1932   - if (i3GEO.configura) {
1933   - temp = $i("panellistagEditor").getElementsByTagName("div")[2];
1934   - } else {
1935   - temp = $i("panellistagEditor").getElementsByTagName("div")[1];
1936   - }
1937   - temp.style.overflow = "auto";
1938   - temp.style.height = "100px";
1939   - temp.innerHTML = ins;
1940   - },
1941   - ferramentas : function() {
1942   - if (!document.getElementById("panelferramentasEditor")) {
1943   - YAHOO.namespace("editorOL.ferramentas");
1944   - YAHOO.editorOL.ferramentas.panel = new YAHOO.widget.Panel("panelferramentasEditor", {
1945   - zIndex : 20000,
1946   - iframe : true,
1947   - width : "300px",
1948   - visible : false,
1949   - draggable : true,
1950   - close : true
1951   - });
1952   - var ins =
1953   - "" + '<p class=paragrafo >'
1954   - + $trad("opsel")
1955   - + ':</p>'
1956   - + '<select onchange="i3GEO.editorOL.processageo(this.value);this.value = \'\'" >'
1957   - + ' <option value="">---</option>'
1958   - + ' <option value=union >Uni&atilde;o</option>';
1959   - if (i3GEO.php) {
1960   - ins +=
1961   - ' <option value=intersection >Intersec&ccedil;&atilde;o</option>' + ' <option value=convexhull >Convex hull</option>'
1962   - + ' <option value=boundary >Bordas</option>'
1963   - + ' <option value=difference >Diferen&ccedil;a</option>'
1964   - + ' <option value=symdifference >Diferen&ccedil;a sim&eacute;trica</option>';
1965   - }
1966   - ins +=
1967   - '</select>' + '<br><br><a class=paragrafo href=# onclick="i3GEO.desenho.layergrafico.destroyFeatures()" >Apaga tudo</a>';
1968   -
1969   - YAHOO.editorOL.ferramentas.panel.setBody(ins);
1970   - if (i3GEO && typeof i3GEO != undefined && i3GEO != "") {
1971   - YAHOO.editorOL.ferramentas.panel
1972   - .setHeader("Ferramentas <div id='panelferramentasEditor_minimizaCabecalho' class='container-minimiza'></div>");
1973   - } else {
1974   - YAHOO.editorOL.ferramentas.panel.setHeader("Ferramentas");
1975   - }
1976   -
1977   - YAHOO.editorOL.ferramentas.panel.setFooter("");
1978   - YAHOO.editorOL.ferramentas.panel.render(document.body);
1979   - YAHOO.editorOL.ferramentas.panel.center();
1980   - YAHOO.util.Event.addListener(YAHOO.editorOL.ferramentas.panel.close, "click", function() {
1981   - });
1982   - temp = $i("panelferramentasEditor_minimizaCabecalho");
1983   - if (temp) {
1984   - temp.onclick = function() {
1985   - i3GEO.janela.minimiza("panelferramentasEditor");
1986   - };
1987   - }
1988   - } else {
1989   - YAHOO.editorOL.ferramentas.panel.render(document.body);
1990   - }
1991   - YAHOO.editorOL.ferramentas.panel.show();
1992   - },
1993   - snap : function() {
1994   - var target = i3GEOOLsnap.targets[0], tipos = [
1995   - "node", "vertex", "edge"
1996   - ], ntipos = tipos.length, i, temp, ativa = false;
1997   - i3GEOOLsnap.deactivate();
1998   - for (i = 0; i < ntipos; i++) {
1999   - temp = $i("target_" + tipos[i]);
2000   - target[tipos[i]] = temp.checked;
2001   - if (temp.checked === true) {
2002   - ativa = true;
2003   - }
2004   - temp = $i("target_" + tipos[i] + "Tolerance");
2005   - target[tipos[i] + "Tolerance"] = temp.value;
2006   - }
2007   - if (ativa === true) {
2008   - i3GEOOLsnap.activate();
2009   - }
2010   - },
2011   - split : function() {
2012   - i3GEOOLsplit.deactivate();
2013   - var temp = $i("edge_split_toggle");
2014   - if (temp.checked === true) {
2015   - i3GEOOLsplit.activate();
2016   - }
2017   - },
2018   - processageo : function(operacao) {
2019   - if (operacao === "") {
2020   - return;
2021   - }
2022   - var geosel = i3GEO.desenho.layergrafico.selectedFeatures, polis, linhas, pontos, temp;
2023   - if (geosel.length > 0) {
2024   - polis = i3GEO.editorOL.retornaGeometriasTipo(geosel, "OpenLayers.Geometry.Polygon");
2025   - linhas = i3GEO.editorOL.retornaGeometriasTipo(geosel, "OpenLayers.Geometry.LineString");
2026   - pontos = i3GEO.editorOL.retornaGeometriasTipo(geosel, "OpenLayers.Geometry.Point");
2027   - temp = function(retorno) {
2028   - if (i3GEO.janela) {
2029   - i3GEO.janela.fechaAguarde("i3GEO.editorPoli");
2030   - i3GEO.janela.fechaAguarde("i3GEO.editorLinhas");
2031   - i3GEO.janela.fechaAguarde("i3GEO.editorPontos");
2032   - }
2033   - if (retorno != "" && retorno.data && retorno.data != "" && operacao != "converteSHP") {
2034   - i3GEO.editorOL.substituiFeaturesSel(retorno.data);
2035   - }
2036   - if (operacao === "converteSHP") {
2037   - i3GEO.atualiza();
2038   - i3GEO.janela.minimiza("paneltemaativo");
2039   - }
2040   - };
2041   - if (operacao === "incorporar") {
2042   - if (polis.length > 0) {
2043   - temp = i3GEO.editorOL.merge(polis);
2044   - }
2045   - if (linhas.length > 0) {
2046   - temp = i3GEO.editorOL.merge(linhas);
2047   - }
2048   - if (pontos.length > 0) {
2049   - temp = i3GEO.editorOL.merge(pontos);
2050   - }
2051   - if (i3GEO.mapa) {
2052   - i3GEO.mapa.dialogo.wkt2layer(temp);
2053   - }
2054   - return;
2055   - }
2056   - if (operacao === "union" && !i3GEO.php) {
2057   - if (polis.length > 0) {
2058   - temp = i3GEO.editorOL.uniaojts(polis);
2059   - i3GEO.editorOL.substituiFeaturesSel(temp);
2060   - }
2061   - if (linhas.length > 0) {
2062   - temp = i3GEO.editorOL.uniaojts(linhas);
2063   - i3GEO.editorOL.substituiFeaturesSel(temp);
2064   - }
2065   - if (pontos.length > 0) {
2066   - temp = i3GEO.editorOL.uniaojts(pontos);
2067   - i3GEO.editorOL.substituiFeaturesSel(temp);
2068   - }
2069   - } else {
2070   - if (polis.length > 0) {
2071   - i3GEO.janela.abreAguarde("i3GEO.editorPoli", "Poligonos");
2072   - i3GEO.php.funcoesGeometriasWkt(temp, polis.join("|"), operacao);
2073   - }
2074   - if (linhas.length > 0) {
2075   - i3GEO.janela.abreAguarde("i3GEO.editorLinhas", "Linhas");
2076   - i3GEO.php.funcoesGeometriasWkt(temp, linhas.join("|"), operacao);
2077   - }
2078   - if (pontos.length > 0) {
2079   - i3GEO.janela.abreAguarde("i3GEO.editorPontos", "Pontos");
2080   - i3GEO.php.funcoesGeometriasWkt(temp, pontos.join("|"), operacao);
2081   - }
2082   - }
2083   - return;
2084   - } else {
2085   - i3GEO.janela.tempoMsg("Selecione pelo menos dois elementos");
2086   - }
2087   - },
2088   - merge : function(geoms) {
2089   - var n = geoms.length, w = new Wkt.Wkt(), g, m, i;
2090   - w.read(geoms[0].toString());
2091   - if (n > 1) {
2092   - for (i = 1; i < n; i++) {
2093   - g = geoms[i].toString();
2094   - m = new Wkt.Wkt();
2095   - m.read(g);
2096   - w.merge(m);
2097   - }
2098   - }
2099   - return w.write();
2100   - },
2101   - uniaojts : function(geoms) {
2102   - var n = geoms.length, rwkt = new jsts.io.WKTReader(), wwkt = new jsts.io.WKTWriter(), fwkt = new OpenLayers.Format.WKT(), g, i, uniao;
2103   - if (n > 1) {
2104   - uniao = (fwkt.read(geoms[0]).geometry).toString();
2105   - uniao = rwkt.read(uniao);
2106   - for (i = 1; i <= n; i++) {
2107   - g = (fwkt.read(geoms[i]).geometry).toString();
2108   - uniao = uniao.union(rwkt.read(g));
2109   - }
2110   - uniao = wwkt.write(uniao);
2111   - return [
2112   - fwkt.read(uniao)
2113   - ];
2114   - } else {
2115   - return false;
2116   - }
2117   - },
2118   - retornaGeometriasTipo : function(features, tipo) {
2119   - var n = features.length, lista = [], i, temp;
2120   - for (i = 0; i < n; i++) {
2121   - temp = features[i].geometry;
2122   - if (temp.CLASS_NAME == tipo) {
2123   - lista.push(temp);
2124   - }
2125   - }
2126   - return lista;
2127   - },
2128   - guardaBackup : function() {
2129   - return;
2130   - // if(!i3GEO.editorOL.backup)
2131   - // {i3GEO.editorOL.backup = new OpenLayers.Layer.Vector("Backup",{displayInLayerSwitcher:false,visibility:false});}
2132   - // else
2133   - // {i3GEO.editorOL.backup.removeFeatures(i3GEO.editorOL.backup.features);}
2134   - // i3GEO.editorOL.backup.addFeatures(i3GEO.desenho.layergrafico.features);
2135   - },
2136   - unselTodos : function() {
2137   - var n, i;
2138   - n = i3GEO.desenho.layergrafico.features.length;
2139   - for (i = 0; i < n; i++) {
2140   - i3GEO.desenho.layergrafico.features[i].renderIntent = "default";
2141   - i3GEO.editorOL.selbutton.unselect(i3GEO.desenho.layergrafico.features[i]);
2142   - }
2143   - },
2144   - unselTodosBackup : function() {
2145   - var n, i;
2146   - n = i3GEO.editorOL.backup.features.length;
2147   - for (i = 0; i < n; i++) {
2148   - i3GEO.editorOL.backup.features[i].renderIntent = "default";
2149   - i3GEO.editorOL.selbutton.unselect(i3GEO.editorOL.backup.features[i]);
2150   - }
2151   - },
2152   - restauraBackup : function() {
2153   - if (i3GEO.editorOL.backup.features.length > 0) {
2154   - i3GEO.desenho.layergrafico.removeFeatures(i3GEO.desenho.layergrafico.features);
2155   - i3GEO.desenho.layergrafico.addFeatures(i3GEO.editorOL.backup.features);
2156   - }
2157   - if (document.getElementById("panellistagEditor")) {
2158   - i3GEO.editorOL.listaGeometrias();
2159   - }
2160   - // i3GEO.editorOL.backup.removeFeatures(i3GEO.editorOL.backup.features);
2161   - },
2162   - substituiFeaturesSel : function(wkt) {
2163   - i3GEO.editorOL.guardaBackup();
2164   - try {
2165   - var f, fwkt = new OpenLayers.Format.WKT();
2166   - i3GEO.desenho.layergrafico.removeFeatures(i3GEO.desenho.layergrafico.selectedFeatures);
2167   - f = fwkt.read(wkt);
2168   - f["attributes"] = {
2169   - opacidade : i3GEO.editorOL.simbologia.opacidade,
2170   - texto : i3GEO.editorOL.simbologia.texto,
2171   - fillColor : i3GEO.editorOL.simbologia.fillColor,
2172   - strokeWidth : i3GEO.editorOL.simbologia.strokeWidth,
2173   - strokeColor : i3GEO.editorOL.simbologia.strokeColor,
2174   - pointRadius : i3GEO.editorOL.simbologia.pointRadius,
2175   - graphicName : i3GEO.editorOL.simbologia.graphicName
2176   - };
2177   - i3GEO.desenho.layergrafico.addFeatures([
2178   - f
2179   - ]);
2180   - if (document.getElementById("panellistagEditor")) {
2181   - i3GEO.editorOL.listaGeometrias();
2182   - }
2183   - } catch (e) {
2184   - i3GEO.editorOL.restauraBackup();
2185   - }
2186   - },
2187   - adicionaFeatureWkt : function(wkt, atributos) {
2188   - var f, fwkt = new OpenLayers.Format.WKT();
2189   -
2190   - if (atributos.externalGraphic && atributos.externalGraphic != "") {
2191   - var style_mark = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
2192   - style_mark.externalGraphic = atributos.externalGraphic;
2193   - style_mark.graphicWidth = atributos.graphicWidth;
2194   - style_mark.graphicHeight = atributos.graphicHeight;
2195   - style_mark.fillOpacity = atributos.opacidade;
2196   - f = fwkt.read(wkt);
2197   - f["attributes"] = atributos;
2198   - f["style"] = style_mark;
2199   - } else {
2200   - f = fwkt.read(wkt);
2201   - f["attributes"] = atributos;
2202   - }
2203   - i3GEO.desenho.layergrafico.addFeatures([
2204   - f
2205   - ]);
2206   - if (document.getElementById("panellistagEditor")) {
2207   - i3GEO.editorOL.listaGeometrias();
2208   - }
2209   - },
2210   - flashFeaturesI : function(index) {
2211   - i3GEO.editorOL.flashFeatures([
2212   - i3GEO.desenho.layergrafico.features[index]
2213   - ], 0);
2214   - },
2215   - flashFeatures : function(features, index) {
2216   - if (!index) {
2217   - index = 0;
2218   - }
2219   - var current = features[index];
2220   - if (current && current.layer === i3GEO.desenho.layergrafico) {
2221   - i3GEO.desenho.layergrafico.drawFeature(features[index], "select");
2222   - }
2223   - var prev = features[index - 1];
2224   - if (prev && prev.layer === i3GEO.desenho.layergrafico) {
2225   - i3GEO.desenho.layergrafico.drawFeature(prev, "default");
2226   - }
2227   - ++index;
2228   - if (index <= features.length) {
2229   - window.setTimeout(function() {
2230   - i3GEO.editorOL.flashFeatures(features, index);
2231   - }, 75);
2232   - }
2233   - },
2234   - selFeature : function(index) {
2235   - i3GEO.editorOL.selbutton.select(i3GEO.desenho.layergrafico.features[index]);
2236   - },
2237   - unselFeature : function(index) {
2238   - i3GEO.editorOL.selbutton.unselect(i3GEO.desenho.layergrafico.features[index]);
2239   - },
2240   - carregajts : function(funcao) {
2241   - if (i3GEO.configura) {
2242   - i3GEO.util.scriptTag(i3GEO.configura.locaplic + "/pacotes/jsts/lib/jsts.js", funcao, "i3GEOjts", true);
2243   - } else {
2244   - i3GEO.util.scriptTag("../pacotes/jsts/lib/jsts.js", funcao, "i3GEOjts", true);
2245   - }
2246   - },
2247   - trazParaFrente : function() {
2248   - var features = i3GEO.desenho.layergrafico.selectedFeatures;
2249   - if (features.length > 0) {
2250   - i3GEO.editorOL.backup = new OpenLayers.Layer.Vector("Backup", {
2251   - displayInLayerSwitcher : false,
2252   - visibility : false
2253   - });
2254   - i3GEO.editorOL.backup.addFeatures(features);
2255   - i3GEO.editorOL.unselTodosBackup();
2256   - i3GEO.desenho.layergrafico.removeFeatures(features);
2257   - i3GEO.desenho.layergrafico.addFeatures(i3GEO.editorOL.backup.features);
2258   - if (document.getElementById("panellistagEditor")) {
2259   - i3GEO.editorOL.listaGeometrias();
2260   - }
2261   - } else {
2262   - i3GEO.janela.tempoMsg("Selecione pelo menos um elemento");
2263   - }
2264   - },
2265   - pegaControle : function(classe) {
2266   - var n = i3GEO.editorOL.controles.length, i;
2267   - for (i = 0; i < n; i++) {
2268   - if (i3GEO.editorOL.controles[i].CLASS_NAME === classe) {
2269   - return i3GEO.editorOL.controles[i];
2270   - }
2271   - }
2272   - return false;
2273   - },
2274   - ativaLayerSwitcher : function() {
2275   - var ls = i3GEO.editorOL.pegaControle("OpenLayers.Control.LayerSwitcher");
2276   - if (ls) {
2277   - ls.maximizeDiv.click();
2278   - }
2279   - },
2280   - desativaRodaDoMouse : function() {
2281   - var controls = i3GEO.editorOL.mapa.getControlsByClass('OpenLayers.Control.Navigation');
2282   - for ( var i = 0; i < controls.length; ++i) {
2283   - controls[i].disableZoomWheel();
2284   - }
2285   - },
2286   - google2wgs : function(obj) {
2287   - if (i3GEO.Interface.openlayers.googleLike === true) {
2288   - var projWGS84 = new OpenLayers.Projection("EPSG:4326"), proj900913 = new OpenLayers.Projection("EPSG:900913");
2289   - return obj.transform(proj900913, projWGS84);
2290   - } else {
2291   - return obj;
2292   - }
2293   - },
2294   - sobeLayersGraficos : function() {
2295   - var nlayers = i3GEO.editorOL.mapa.getNumLayers(), layers = i3GEO.editorOL.mapa.layers, i;
2296   - for (i = 0; i < nlayers; i++) {
2297   - if (layers[i].CLASS_NAME == "OpenLayers.Layer.Vector" && layers[i].name != "Nenhum") {
2298   - i3GEO.editorOL.mapa.raiseLayer(i3GEO.editorOL.mapa.layers[i], nlayers);
2299   - }
2300   - }
2301   - }
2302   - };
2303   -
2304   -// para compatibilidade com OpenLayers 2x
2305   -i3GEO.editorOL.backup.getFeatures = function() {
2306   - return i3GEO.editorOL.backup.getSource().getFeatures();
2307   -};
2308 0 \ No newline at end of file