Commit 54863b29bc1428868fa942559c4cb5362c5c5ec6

Authored by Edmar Moretti
1 parent a2547eab

Incluida opção Kernel na função de análise de distribuição de pontos

classesphp/classe_analise.php
... ... @@ -179,6 +179,8 @@ Include:
179 179  
180 180 $dimx = "c(".$xi.",".$xf.")";
181 181 $dimy = "c(".$yi.",".$yf.")";
  182 + if ($tipo == "kernel")
  183 + {$this->mapaKernel($nomearq,$dimx,$dimy,$dir_tmp,$R_path,$locaplic);}
182 184 if ($tipo == "densidade")
183 185 {$this->mapaDensidade($nomearq,$dimx,$dimy,$dir_tmp,$R_path,$locaplic);}
184 186 if ($tipo == "distancia")
... ... @@ -348,6 +350,47 @@ $locaplic - Onde fica o I3Geo.
348 350 $r = executaR($rcode,$dir_tmp,$R_path);
349 351 }
350 352 /*
  353 +function: mapaKernel
  354 +
  355 +Gera um mapa de kernel.
  356 +
  357 +Executa script R para gerar a imagem.
  358 +
  359 +parameters:
  360 +$arqpt - Prefixo dos arquivos em disco com os pontos.
  361 +
  362 +$dimx - Range em x no formato R c(-54,-53).
  363 +
  364 +$dimy - Range em y no formato R c(-25,-23).
  365 +
  366 +$dir_tmp - Diretório temporário do mapserver.
  367 +
  368 +$R_path - Onde fica o R.
  369 +
  370 +$locaplic - Onde fica o I3Geo.
  371 +*/
  372 + function mapaKernel($arqpt,$dimx,$dimy,$dir_tmp,$R_path,$locaplic)
  373 + {
  374 + $gfile_name = nomeRandomico(20);
  375 + $graf = "png";
  376 + $rcode[] = 'dadosx<-scan("'.$arqpt.'x")';
  377 + $rcode[] = 'dadosy<-scan("'.$arqpt.'y")';
  378 + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
  379 + {$lib = '.libPaths("'.$locaplic.'/pacotes/r/win/library")';}
  380 + $rcode[] = $lib;
  381 + $rcode[] = 'library(spatstat)';
  382 + $rcode[] = 'pt <- ppp(dadosx, dadosy, '.$dimx.','.$dimy.')';
  383 + $rcode[] = 'img <- ksmooth.ppp(pt)';
  384 + $rcode[] = 'cat(img$v,file="'.$arqpt.'img",fill=FALSE)';
  385 + $rcode[] = 'cat(img$xstep,file="'.$arqpt.'h",fill=TRUE)';
  386 + $rcode[] = 'cat(img$ystep,file="'.$arqpt.'h",append=TRUE,fill=TRUE)';
  387 + $rcode[] = 'cat(img$xrange,file="'.$arqpt.'h",append=TRUE,fill=TRUE)';
  388 + $rcode[] = 'cat(img$yrange,file="'.$arqpt.'h",append=TRUE,fill=TRUE)';
  389 + $rcode[] = 'cat(img$dim,file="'.$arqpt.'h",append=TRUE,fill=TRUE)';
  390 + $r = executaR($rcode,$dir_tmp,$R_path,$gfile_name);
  391 + return "ok";
  392 + }
  393 +/*
351 394 function: mapaDensidade
352 395  
353 396 Gera um mapa de densidade de pontos.
... ...
ferramentas/pontosdistri/index.js
... ... @@ -35,6 +35,7 @@ comboTemasPt(&quot;temasPt&quot;,function(retorno)
35 35 ins += retorno
36 36 ins += "<br><br><div style=top:0px;left:0px;text-align:left; onclick='analiseDensidade()' ><input id=botao1 size=35 type=button value='densidade de pontos' /></div><br>"
37 37 ins += "<div style=top:0px;left:0px;text-align:left; onclick='analiseDistancia()' ><input id=botao2 size=35 type=button value='dist&acirc;ncia entre pontos' /></div><br>"
  38 + ins += "<div style=top:0px;left:0px;text-align:left; onclick='analiseKernel()' ><input id=botaokernel size=35 type=button value='Kernel' /></div><br>"
38 39 ins += "<div style=top:0px;left:0px;text-align:left; onclick='analiseRelatorio()' ><input id=botao3 size=35 type=button value='relat&oacute;rio' /></div><br>"
39 40 mensagemOpcao("guia1obj",ins)
40 41 YAHOO.example.init = function ()
... ... @@ -45,6 +46,7 @@ comboTemasPt(&quot;temasPt&quot;,function(retorno)
45 46 new YAHOO.widget.Button("botao2");
46 47 new YAHOO.widget.Button("botao3");
47 48 new YAHOO.widget.Button("botao4");
  49 + new YAHOO.widget.Button("botaokernel");
48 50 }
49 51 YAHOO.util.Event.onContentReady("botao1", onPushButtonsMarkupReady);
50 52 }()
... ... @@ -78,6 +80,21 @@ function mostracores(retorno)
78 80 function corj(obj)
79 81 {window.parent.abreCor("wdocai",obj)}
80 82  
  83 +function analiseKernel()
  84 +{
  85 + //window.parent.borra("sim")
  86 + var n = $i("numclasses").value
  87 + var ci = $i("cori").value
  88 + var cf = $i("corf").value
  89 + aguarde("block")
  90 + var tema = $i("temasPt").value
  91 + var cp = new cpaint();
  92 + var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=analiseDistriPt&tema="+tema+"&numclasses="+n+"&cori="+ci+"&corf="+cf+"&tipo=kernel"
  93 + //cp.set_debug(2)
  94 + cp.set_response_type("JSON");
  95 + cp.call(p,"analiseDistriPt",window.parent.ajaxredesenha);
  96 +}
  97 +
81 98 function analiseDensidade()
82 99 {
83 100 //window.parent.borra("sim")
... ...