catalogoOgc.js
5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
i3GEO.catalogoOgc = {
WMS: "",
MIGALHA: [],
config: {
'templateDir': 'templates/dir',
'templateTema': 'templates/tema',
'idCatalogoPrincipal': 'catalogoPrincipal',
'idCatalogoNavegacao': 'catalogoNavegacao',
'idOndeMigalha': 'catalogoMigalha'
},
carregaTemplates: function(){
var t1 = i3GEO.catalogoOgc.config.templateDir,
t2 = i3GEO.catalogoOgc.config.templateTema,
t3 = $("#" + i3GEO.catalogoOgc.config.idOndeMigalha).attr("data-template");
$.when( $.get(t1),$.get(t2),$.get(t3) ).done(function(r1,r2,r3) {
i3GEO.template.dir = r1[0];
i3GEO.template.tema = r2[0];
i3GEO.template.catalogoMigalha = r3[0];
i3GEO.caixaDeFerramentas.inicia();
}).fail(function() {
i3GEO.janela.closeMsg($trad("erroTpl"));
return;
});
},
aguarde: function(){
$("#" + i3GEO.catalogoOgc.config.idCatalogoNavegacao).html($trad("o1"));
},
atualizaMigalha: function(){
var migalha = i3GEO.catalogoOgc.MIGALHA;
var n = migalha.length;
var nome = migalha[n - 1].nome;
var onclick = migalha[n - 2].onclick;
var t = Mustache.to_html(
i3GEO.template.catalogoMigalha,
{"nome":nome,"onclick":"i3GEO.catalogoOgc.MIGALHA.pop();i3GEO.catalogoOgc.MIGALHA.pop();" + onclick}
);
$("#" + i3GEO.catalogoOgc.config.idOndeMigalha).html(t);
$("#i3GEOguiaMovelConteudo").scrollTop(0);
},
escondeCatalogoPrincipal: function(){
$("#" + i3GEO.catalogoOgc.config.idCatalogoPrincipal).hide();
},
mostraCatalogoPrincipal: function(){
$("#" + i3GEO.catalogoOgc.config.idCatalogoNavegacao).fadeOut( "fast", function(){
$("#" + i3GEO.catalogoOgc.config.idOndeMigalha).hide();
$("#" + i3GEO.catalogoOgc.config.idCatalogoPrincipal).show();
});
},
adicionaTema : function(tid) {
if (typeof (console) !== 'undefined')
console.info("i3GEO.catalogoOgc.adicionaTema");
// confirma se o tema existe no mapa
if (i3GEO.arvoreDeCamadas.pegaTema(tid) !== "") {
i3GEO.arvoreDeCamadas.ligaDesligaTemas(tid, true);
} else {
i3GEO.arvoreDeTemas.adicionaTemas([ tid ]);
}
},
inicia: function(config){
if (typeof (console) !== 'undefined')
console.info("i3GEO.catalogoOgc.inicia");
if(config){
$.each( config, function( i,v ) {
i3GEO.catalogoOgc.config[i] = v;
});
}
i3GEO.catalogoOgc.aguarde();
if(!i3GEO.template.dir || !i3GEO.template.tema || !i3GEO.template.catalogoMigalha){
i3GEO.catalogoOgc.carregaTemplates();
return;
} else {
i3GEO.catalogoOgc.MIGALHA = [
{"nome":"","onclick":"i3GEO.catalogoOgc.mostraCatalogoPrincipal()"},
{"nome":"OGC-WMS","onclick":"i3GEO.catalogoOgc.inicia()"}
];
i3GEO.catalogoOgc.atualizaMigalha();
config = i3GEO.catalogoOgc.config;
i3GEO.catalogoOgc.escondeCatalogoPrincipal();
var t = Mustache.to_html(
i3GEO.template.catalogoMigalha,
{"nome":'OGC-WMS',"onclick":"i3GEO.catalogoOgc.mostraCatalogoPrincipal()"}
);
i3GEO.catalogoOgc.config = config;
var lista = function(retorno){
var dados = retorno.data.canais,
clone = [],
t;
//ajusta o nome
//verifica se o menu esta na lista de ids definidos em i3GEO.catalogoOgc.IDSMENUS
$.each( dados, function( i,v ) {
v.nome = v.title;
v.descricao = v.description;
v.onclick = "i3GEO.catalogoOgc.listaCamadas('" + v.nome + "'," + v.id_ws + ",'" + v.nome + "','" + v.link + "',0" + ",'" + v.tipo_ws + "','" + v.layer + "')";
clone.push(v);
});
t = Mustache.to_html(
"{{#data}}" + i3GEO.template.dir + "{{/data}}",
{"data":clone}
);
$("#" + config.idCatalogoNavegacao).html(t);
$("#" + i3GEO.catalogoOgc.config.idCatalogoPrincipal).fadeOut( "fast", function(){
$("#" + i3GEO.catalogoOgc.config.idOndeMigalha).show();
$("#" + i3GEO.catalogoOgc.config.idCatalogoNavegacao).show();
});
};
i3GEO.php.listaRSSwsARRAY(lista, "WMS");
}
},
listaCamadas: function(nomeMigalha, id_ws, nome, url, nivel, tipo_ws, layer){
if (typeof (console) !== 'undefined')
console.info("i3GEO.catalogoOgc.listaCamadas");
i3GEO.catalogoOgc.MIGALHA.push({"nome": nome,"onclick":"i3GEO.catalogoOgc.listaCamadas('" + nome + "','" + id_ws + "','" + nome + "','" + url + "'," + nivel + ",'" + tipo_ws + "','" + layer + "')"});
i3GEO.catalogoOgc.atualizaMigalha();
i3GEO.catalogoOgc.aguarde();
var monta = function(dados){
var data = dados.data,
clone = [],
g = "",
temas;
//monta a lista com proximo nivel
$.each( data, function( i,v ) {
if (v.nome + " - " + v.titulo !== "undefined - undefined") {
v.descricao = v.titulo;
if (!v.estilos) {
v.onclick = "i3GEO.catalogoOgc.listaCamadas('" + nome + "'," + id_ws + ",'" + v.nome + "','" + url + "'," + (nivel*1 + 1) + ",'" + tipo_ws + "','" + v.titulo + "')";
clone.push(v);
} else {
i3GEO.catalogoOgc.temas({
"estilos": v.estilos,
"servico": url,
"layer": v.nome,
"proj": v.srs.toString(),
"formatoimg": v.formats.toString(),
"versao": v.version.toString(),
"formatoinfo": v.formatsinfo.toString()
});
}
}
});
if(clone.length > 0){
g = Mustache.to_html(
"{{#data}}" + i3GEO.template.dir + "{{/data}}",
{"data":clone}
);
$("#" + i3GEO.catalogoOgc.config.idCatalogoNavegacao).html(g);
}
};
i3GEO.php.listaLayersWMS(monta, url, (nivel * 1) + 1, id_ws, layer,
tipo_ws);
},
temas: function(config){
var clone = [],
estilos = config.estilos;
$.each( estilos, function( i,v ) {
v.onclick = "i3GEO.php.adicionaTemaWMS('','"
+ config.servico + "','"
+ config.layer + "','"
+ v.nome + "','"
+ config.proj + "','"
+ config.formatoimg + "','"
+ config.versao + "','"
+ v.titulo + "','','nao','"
+ config.formatoinfo + "','','',"
+ "true)";
v.nome = estilos[i].nome + " - " + estilos[i].titulo;
clone.push(v);
});
var t = Mustache.to_html(
"{{#data}}" + i3GEO.template.tema + "{{/data}}",
{"data":clone}
);
$("#" + i3GEO.catalogoOgc.config.idCatalogoNavegacao).html(t);
}
};