Commit a1981934c473d43bb6c977472c858c30a40def19

Authored by Edmar Moretti
1 parent 9e152d6f
Exists in master

Classificador pela média

classesphp/classe_alteraclasse.php
@@ -321,15 +321,15 @@ class Alteraclasse @@ -321,15 +321,15 @@ class Alteraclasse
321 } 321 }
322 /* 322 /*
323 function: metade 323 function: metade
324 - 324 +
325 Classifica os dados em duas classes, a primeira concentra os registros que somados correspondem à primeira metade do total e a segunda classe corresponde à segunda metade 325 Classifica os dados em duas classes, a primeira concentra os registros que somados correspondem à primeira metade do total e a segunda classe corresponde à segunda metade
326 - 326 +
327 Parametros: 327 Parametros:
328 - 328 +
329 $item - item da tabela de atributos 329 $item - item da tabela de atributos
330 - 330 +
331 $itemid - item que identifica unicamente cada registro 331 $itemid - item que identifica unicamente cada registro
332 - 332 +
333 $ignorar - valor que será ignorado na listagem final 333 $ignorar - valor que será ignorado na listagem final
334 */ 334 */
335 function metade($item,$itemid,$ignorar) 335 function metade($item,$itemid,$ignorar)
@@ -423,6 +423,75 @@ class Alteraclasse @@ -423,6 +423,75 @@ class Alteraclasse
423 } 423 }
424 } 424 }
425 /* 425 /*
  426 + function: classemedia
  427 +
  428 + Classifica os dados em duas classes, a primeira concentra os registros que estão abaixo da média e a segunda aqueles que são iguais ou superiores a média
  429 +
  430 + Parametros:
  431 +
  432 + $item - item da tabela de atributos
  433 +
  434 + $ignorar - valor que será ignorado na listagem final
  435 + */
  436 + function classemedia($item,$ignorar)
  437 + {
  438 + if(!$this->layer){
  439 + return "erro";
  440 + }
  441 + $valores = $this->pegaValores($this->mapa,$this->layer,$item,false,$ignorar);
  442 +
  443 + if (count($valores) > 0){
  444 + $media = array_sum($valores) / count($valores);
  445 +
  446 + $numclassesatual = $this->layer->numclasses;
  447 + //apaga todas as classes existentes
  448 + $classetemp = $this->layer->getClass(0);
  449 + $estilotemp = $classetemp->getStyle(0);
  450 + for ($i=0; $i < $numclassesatual; ++$i){
  451 + $classe = $this->layer->getClass($i);
  452 + $classe->set("status",MS_DELETE);
  453 + }
  454 + //adiciona as classes novas
  455 + $expressao = "([".$item."]<".$media.")";
  456 + $nomeclasse = "< media ".$media;
  457 + $classe = ms_newClassObj($this->layer);
  458 +
  459 + $novoestilo = ms_newStyleObj($classe);
  460 + if ($this->layer->type == 0){
  461 + $novoestilo->set("symbolname","ponto");
  462 + $novoestilo->set("size","6");
  463 + }
  464 + $ncor = $novoestilo->color;
  465 + $ncor->setrgb(200,183,134);
  466 + $ncor = $novoestilo->outlinecolor;
  467 + $ncor->setrgb(255,255,255);
  468 + $classe->setexpression($expressao);
  469 + $classe->set("name",$nomeclasse);
  470 +
  471 + $expressao = "([".$item."]>=".$media.")";
  472 + $nomeclasse = ">= media ".$media;
  473 + $classe = ms_newClassObj($this->layer);
  474 +
  475 + $novoestilo = ms_newStyleObj($classe);
  476 + if ($this->layer->type == 0){
  477 + $novoestilo->set("symbolname","ponto");
  478 + $novoestilo->set("size","6");
  479 + }
  480 + $ncor = $novoestilo->color;
  481 + $ncor->setrgb(210,100,100);
  482 + $ncor = $novoestilo->outlinecolor;
  483 + $ncor->setrgb(255,255,255);
  484 + $classe->setexpression($expressao);
  485 + $classe->set("name",$nomeclasse);
  486 +
  487 + $this->layer->setMetaData("cache","");
  488 + return ("ok");
  489 + }
  490 + else{
  491 + return ("erro. Nenhum valor numerico no item");
  492 + }
  493 + }
  494 + /*
426 function: quantil 495 function: quantil
427 496
428 Cria classes em um objeto layer com intervalos baseados no calculo de quantil 497 Cria classes em um objeto layer com intervalos baseados no calculo de quantil
classesphp/mapa_controle.php
@@ -1218,6 +1218,9 @@ switch (strtoupper($funcao)) @@ -1218,6 +1218,9 @@ switch (strtoupper($funcao))
1218 if ($opcao == "metade"){ 1218 if ($opcao == "metade"){
1219 $retorno = $m->metade($item,$itemid,$ignorar); 1219 $retorno = $m->metade($item,$itemid,$ignorar);
1220 } 1220 }
  1221 + if ($opcao == "media"){
  1222 + $retorno = $m->classemedia($item,$ignorar);
  1223 + }
1221 if ($opcao == "quartis"){ 1224 if ($opcao == "quartis"){
1222 if(!isset($tipoLegenda)) 1225 if(!isset($tipoLegenda))
1223 { 1226 {
@@ -2346,7 +2349,7 @@ switch (strtoupper($funcao)) @@ -2346,7 +2349,7 @@ switch (strtoupper($funcao))
2346 Valor: LISTAINTERFACES 2349 Valor: LISTAINTERFACES
2347 2350
2348 Lista as interfaces de abertura de mapas 2351 Lista as interfaces de abertura de mapas
2349 - 2352 +
2350 Pesquisa na pasta interfaces e na pasta definida em $customDir 2353 Pesquisa na pasta interfaces e na pasta definida em $customDir
2351 */ 2354 */
2352 case "LISTAINTERFACES": 2355 case "LISTAINTERFACES":
ferramentas/editorol/editorol.js
@@ -1531,6 +1531,9 @@ i3GEO.editorOL = @@ -1531,6 +1531,9 @@ i3GEO.editorOL =
1531 i3GEOpanelEditor.id = "i3GEObarraEdicao"; 1531 i3GEOpanelEditor.id = "i3GEObarraEdicao";
1532 i3GEOpanelEditor.className = "olControlEditingToolbar1 noprint"; 1532 i3GEOpanelEditor.className = "olControlEditingToolbar1 noprint";
1533 //cria os icones 1533 //cria os icones
  1534 + if (botoes.novaaba === true) {
  1535 + i3GEOpanelEditor.appendChild(i3GEO.editorOL.botaoNovaaba());
  1536 + }
1534 if (botoes.procura === true) { 1537 if (botoes.procura === true) {
1535 i3GEOpanelEditor.appendChild(i3GEO.editorOL.botaoProcura()); 1538 i3GEOpanelEditor.appendChild(i3GEO.editorOL.botaoProcura());
1536 } 1539 }
@@ -1603,11 +1606,8 @@ i3GEO.editorOL = @@ -1603,11 +1606,8 @@ i3GEO.editorOL =
1603 if (botoes.salva === true) { 1606 if (botoes.salva === true) {
1604 i3GEOpanelEditor.appendChild(i3GEO.editorOL.botaoSalva()); 1607 i3GEOpanelEditor.appendChild(i3GEO.editorOL.botaoSalva());
1605 } 1608 }
1606 - if (botoes.novaaba === true) {  
1607 - i3GEOpanelEditor.appendChild(i3GEO.editorOL.botaoAjuda());  
1608 - }  
1609 if (botoes.ajuda === true) { 1609 if (botoes.ajuda === true) {
1610 - i3GEOpanelEditor.appendChild(i3GEO.editorOL.botaoNovaaba()); 1610 + i3GEOpanelEditor.appendChild(i3GEO.editorOL.botaoAjuda());
1611 } 1611 }
1612 if (botoes.fecha === true) { 1612 if (botoes.fecha === true) {
1613 i3GEOpanelEditor.appendChild(i3GEO.editorOL.botaoFecha()); 1613 i3GEOpanelEditor.appendChild(i3GEO.editorOL.botaoFecha());
ferramentas/legenda/dicionario.js
@@ -779,5 +779,19 @@ i3GEOF.legenda.dicionario = @@ -779,5 +779,19 @@ i3GEOF.legenda.dicionario =
779 en : "", 779 en : "",
780 es : "" 780 es : ""
781 } 781 }
782 - ] 782 + ],
  783 + "media" : [
  784 + {
  785 + pt : "M&eacute;dia",
  786 + en : "",
  787 + es : ""
  788 + }
  789 + ],
  790 + "duasmedias" : [
  791 + {
  792 + pt : "Classifica os dados em duas classes, a primeira concentra os registros que est&atilde;o abaixo da m&eacute;dia e a segunda aqueles que s&atilde;o iguais ou superiores a m&eacute;dia",
  793 + en : "",
  794 + es : ""
  795 + }
  796 + ]
783 }; 797 };
ferramentas/legenda/index.js
@@ -222,6 +222,12 @@ i3GEOF.legenda = @@ -222,6 +222,12 @@ i3GEOF.legenda =
222 } 222 }
223 }); 223 });
224 b.addClass("rodar"); 224 b.addClass("rodar");
  225 + b = new YAHOO.widget.Button("i3GEOlegendabotaoMedia", {
  226 + onclick : {
  227 + fn : i3GEOF.legenda.media
  228 + }
  229 + });
  230 + b.addClass("rodar");
225 b = new YAHOO.widget.Button("i3GEOlegendabotao7", { 231 b = new YAHOO.widget.Button("i3GEOlegendabotao7", {
226 onclick : { 232 onclick : {
227 fn : i3GEOF.legenda.representacao 233 fn : i3GEOF.legenda.representacao
@@ -366,6 +372,9 @@ i3GEOF.legenda = @@ -366,6 +372,9 @@ i3GEOF.legenda =
366 if ($i("i3GEOlegendaitensMetadeId")) { 372 if ($i("i3GEOlegendaitensMetadeId")) {
367 $i("i3GEOlegendaitensMetadeId").innerHTML = retorno.dados; 373 $i("i3GEOlegendaitensMetadeId").innerHTML = retorno.dados;
368 } 374 }
  375 + if ($i("i3GEOlegendaitensMedia")) {
  376 + $i("i3GEOlegendaitensMedia").innerHTML = retorno.dados;
  377 + }
369 if ($i("i3GEOlegendaitensValorClass")) { 378 if ($i("i3GEOlegendaitensValorClass")) {
370 $i("i3GEOlegendaitensValorClass").innerHTML = retorno.dados; 379 $i("i3GEOlegendaitensValorClass").innerHTML = retorno.dados;
371 } 380 }
@@ -1348,7 +1357,6 @@ i3GEOF.legenda = @@ -1348,7 +1357,6 @@ i3GEOF.legenda =
1348 } 1357 }
1349 var item = $i("i3GEOlegendaitensMetade").getElementsByTagName("select")[0].value, 1358 var item = $i("i3GEOlegendaitensMetade").getElementsByTagName("select")[0].value,
1350 itemid = $i("i3GEOlegendaitensMetadeId").getElementsByTagName("select")[0].value, 1359 itemid = $i("i3GEOlegendaitensMetadeId").getElementsByTagName("select")[0].value,
1351 - ext = i3GEO.util.extOSM2Geo(i3GEO.parametros.mapexten),  
1352 p = i3GEO.configura.locaplic + "/classesphp/mapa_controle.php?g_sid=" 1360 p = i3GEO.configura.locaplic + "/classesphp/mapa_controle.php?g_sid="
1353 + i3GEO.configura.sid 1361 + i3GEO.configura.sid
1354 + "&funcao=alteraclasse" 1362 + "&funcao=alteraclasse"
@@ -1359,9 +1367,7 @@ i3GEOF.legenda = @@ -1359,9 +1367,7 @@ i3GEOF.legenda =
1359 + "&itemid=" 1367 + "&itemid="
1360 + itemid 1368 + itemid
1361 + "&opcao=metade&ignorar=" 1369 + "&opcao=metade&ignorar="
1362 - + $i("i3GEOlegendaignorar").value  
1363 - + "&ext="  
1364 - + ext, 1370 + + $i("i3GEOlegendaignorar").value,
1365 cp = new cpaint(), 1371 cp = new cpaint(),
1366 fim = function() { 1372 fim = function() {
1367 i3GEOF.legenda.aposAlterarLegenda(); 1373 i3GEOF.legenda.aposAlterarLegenda();
@@ -1389,6 +1395,52 @@ i3GEOF.legenda = @@ -1389,6 +1395,52 @@ i3GEOF.legenda =
1389 } 1395 }
1390 }, 1396 },
1391 /* 1397 /*
  1398 + * Function: media
  1399 + *
  1400 + * Duas classes considerando a media
  1401 + *
  1402 + * Veja:
  1403 + *
  1404 + * <ALTERACLASSE>
  1405 + */
  1406 + media : function() {
  1407 + try {
  1408 + if (i3GEOF.legenda.aguarde.visibility === "visible") {
  1409 + return;
  1410 + }
  1411 + var item = $i("i3GEOlegendaitensMedia").getElementsByTagName("select")[0].value,
  1412 + p = i3GEO.configura.locaplic + "/classesphp/mapa_controle.php?g_sid="
  1413 + + i3GEO.configura.sid
  1414 + + "&funcao=alteraclasse"
  1415 + + "&tema="
  1416 + + i3GEOF.legenda.tema
  1417 + + "&item="
  1418 + + item
  1419 + + "&opcao=media&ignorar="
  1420 + + $i("i3GEOlegendaignorar").value,
  1421 + cp = new cpaint(),
  1422 + fim = function() {
  1423 + i3GEOF.legenda.aposAlterarLegenda();
  1424 + i3GEOF.legenda.aguarde.visibility = "hidden";
  1425 + };
  1426 + if (item == "") {
  1427 + i3GEO.janela.tempoMsg("Selecione um item!");
  1428 + return;
  1429 + }
  1430 + if ($i("i3GEOFlegendaaplicaextent").checked === true) {
  1431 + p += "&ext=" + i3GEO.util.extOSM2Geo(i3GEO.parametros.mapexten);
  1432 + } else {
  1433 + p += "&ext=" + i3GEO.util.extOSM2Geo(i3GEO.parametros.extentTotal);
  1434 + }
  1435 + i3GEOF.legenda.aguarde.visibility = "visible";
  1436 + cp.set_response_type("JSON");
  1437 + cp.call(p, "alteraclasse", fim);
  1438 + } catch (e) {
  1439 + i3GEO.janela.tempoMsg("Erro: " + e);
  1440 + i3GEOF.legenda.aguarde.visibility = "hidden";
  1441 + }
  1442 + },
  1443 + /*
1392 * Function: valorQ 1444 * Function: valorQ
1393 * 1445 *
1394 * Altera a leganda do tema claculando as classes pelo m&eacute;todo quartil 1446 * Altera a leganda do tema claculando as classes pelo m&eacute;todo quartil
ferramentas/legenda/template_mst.html
@@ -200,6 +200,16 @@ @@ -200,6 +200,16 @@
200 </fieldset> 200 </fieldset>
201 <br> 201 <br>
202 <fieldset style='padding: 5px; margin: 2px;'> 202 <fieldset style='padding: 5px; margin: 2px;'>
  203 + <legend>{{{media}}}</legend>
  204 + <p class='paragrafo'>{{{duasmedias}}}</p>
  205 + <div id='i3GEOlegendaitensMedia' class='styled-select'></div>
  206 + <br>
  207 + <p class='paragrafo'>
  208 + <input id='i3GEOlegendabotaoMedia' size='25' type='button' value='{{{aplicar}}}' />
  209 + </p>
  210 + </fieldset>
  211 + <br>
  212 + <fieldset style='padding: 5px; margin: 2px;'>
203 <legend>{{{calcularQuartil}}}</legend> 213 <legend>{{{calcularQuartil}}}</legend>
204 <p class='paragrafo'>{{{criaQuartis}}}</p> 214 <p class='paragrafo'>{{{criaQuartis}}}</p>
205 <div id='i3GEOlegendaitensValorQuartil' class='styled-select'></div> 215 <div id='i3GEOlegendaitensValorQuartil' class='styled-select'></div>
ferramentas/saiku/saiku-server/tomcat/webapps/ROOT/js/saiku/models/Session.js
1 -/* 1 +/*
2 * Copyright 2012 OSBI Ltd 2 * Copyright 2012 OSBI Ltd
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 - 16 +
17 /** 17 /**
18 * Object which handles authentication and stores connections and cubes 18 * Object which handles authentication and stores connections and cubes
19 * @param username 19 * @param username
@@ -24,7 +24,7 @@ var Session = Backbone.Model.extend({ @@ -24,7 +24,7 @@ var Session = Backbone.Model.extend({
24 username: null, 24 username: null,
25 password: null, 25 password: null,
26 sessionid: null, 26 sessionid: null,
27 - 27 +
28 initialize: function(args, options) { 28 initialize: function(args, options) {
29 // Attach a custom event bus to this model 29 // Attach a custom event bus to this model
30 _.extend(this, Backbone.Events); 30 _.extend(this, Backbone.Events);
@@ -43,7 +43,7 @@ var Session = Backbone.Model.extend({ @@ -43,7 +43,7 @@ var Session = Backbone.Model.extend({
43 check_session: function() { 43 check_session: function() {
44 if (this.sessionid === null || this.username === null || this.password === null) { 44 if (this.sessionid === null || this.username === null || this.password === null) {
45 this.clear(); 45 this.clear();
46 - this.fetch({ success: this.process_session }) 46 + this.fetch({ success: this.process_session });
47 } else { 47 } else {
48 this.username = encodeURIComponent(options.username); 48 this.username = encodeURIComponent(options.username);
49 this.load_session(); 49 this.load_session();
@@ -71,24 +71,24 @@ var Session = Backbone.Model.extend({ @@ -71,24 +71,24 @@ var Session = Backbone.Model.extend({
71 } 71 }
72 this.load_session(); 72 this.load_session();
73 } 73 }
74 - 74 +
75 return this; 75 return this;
76 }, 76 },
77 - 77 +
78 error: function() { 78 error: function() {
79 $(this.form.el).dialog('open'); 79 $(this.form.el).dialog('open');
80 }, 80 },
81 - 81 +
82 login: function(username, password) { 82 login: function(username, password) {
83 // Set expiration on localStorage to one day in the future 83 // Set expiration on localStorage to one day in the future
84 - var expires = (new Date()).getTime() + 84 + var expires = (new Date()).getTime() +
85 Settings.LOCALSTORAGE_EXPIRATION; 85 Settings.LOCALSTORAGE_EXPIRATION;
86 typeof localStorage !== "undefined" && localStorage && localStorage.setItem('expiration', expires); 86 typeof localStorage !== "undefined" && localStorage && localStorage.setItem('expiration', expires);
87 87
88 this.save({username:username, password:password},{success: this.check_session, error: this.check_session}); 88 this.save({username:username, password:password},{success: this.check_session, error: this.check_session});
89 - 89 +
90 }, 90 },
91 - 91 +
92 logout: function() { 92 logout: function() {
93 //This is a hack (inherited from old UI) 93 //This is a hack (inherited from old UI)
94 Saiku.ui.unblock(); 94 Saiku.ui.unblock();
@@ -105,7 +105,7 @@ var Session = Backbone.Model.extend({ @@ -105,7 +105,7 @@ var Session = Backbone.Model.extend({
105 this.password = null; 105 this.password = null;
106 this.destroy({async: false }); 106 this.destroy({async: false });
107 //console.log("REFRESH!"); 107 //console.log("REFRESH!");
108 - document.location.reload(false) 108 + document.location.reload(false);
109 delete this.id; 109 delete this.id;
110 110
111 }, 111 },