コード例 #1
0
ファイル: exec.php プロジェクト: edmarmoretti/i3geo
verificaBlFerramentas(basename(dirname(__FILE__)), $i3geoBlFerramentas, false);
if ($statusFerramentas["melhorcaminho"] != true) {
    exit;
}
//
//faz a busca da função que deve ser executada
//
$retorno = "";
//string que será retornada ao browser via JSON
switch (strtoupper($funcao)) {
    case "SHAPE2PONTOS":
        $mapa = ms_newMapObj($map_file);
        $layer = $mapa->getlayerbyname($tema);
        $shapes = retornaShapesSelecionados($layer, $map_file, $mapa);
        if (count($shapes) == 0) {
            $shapes = retornaShapesMapext($layer, $mapa);
        }
        //quando ponto 0
        if ($layer->type == 0) {
            $objLine = $shapes[0]->line(0);
            $pontoA = $objLine->point(0);
            $objLine = $shapes[count($shapes) - 1]->line(0);
            $pontoB = $objLine->point(0);
        }
        //quando linha 1
        if ($layer->type == 1) {
            $objLine = $shapes[0]->line(0);
            $pontoA = $objLine->point(0);
            $pontoB = $objLine->point($objLine->numpoints - 1);
        }
        //quando poligono 2
コード例 #2
0
ファイル: classe_analise.php プロジェクト: edmarmoretti/i3geo
 function gravaCoordenadasPt($tema, $limitepontos = "TRUE", $extendelimite, $item = "")
 {
     $prjMapa = $this->mapa->getProjection();
     $layerPt = $this->mapa->getlayerbyname($tema);
     $prjTema = $layerPt->getProjection();
     $layerPt->set("tolerance", 0);
     $layerPt->set("template", "none.htm");
     $nomefinal = nomeRandomico();
     $nomearq = $this->diretorio . "/" . $nomefinal;
     $itemspt = pegaItens($layerPt);
     $shapes = retornaShapesSelecionados($layerPt, $this->arquivo, $this->mapa);
     if (count($shapes) == 0) {
         $shapes = retornaShapesMapext($layerPt, $this->mapa);
     }
     $pontos = array();
     $pontosz = array();
     if ($prjTema != "" && $prjMapa != $prjTema) {
         $projInObj = ms_newprojectionobj($prjTema);
         $projOutObj = ms_newprojectionobj($prjMapa);
     }
     foreach ($shapes as $shape) {
         $pt = $shape->getCentroid();
         if ($prjTema != "" && $prjMapa != $prjTema) {
             $pt->project($projInObj, $projOutObj);
         }
         $pontos[] = $pt->x . "  " . $pt->y . "\n";
         $pontosx[] = $pt->x;
         $pontosy[] = $pt->y;
         if ($item != "") {
             $pontosz[] = trim($shape->values[$item]);
         }
     }
     $layerPt->close();
     // grava o arquivo com os pontos em x
     $f = fopen($nomearq . "x", "w");
     foreach ($pontosx as $pt) {
         fwrite($f, $pt . "\n");
     }
     fclose($f);
     // grava o arquivo com os pontos em y
     $f = fopen($nomearq . "y", "w");
     foreach ($pontosy as $pt) {
         fwrite($f, $pt . "\n");
     }
     fclose($f);
     // grava o arquivo com os pontos em z
     $f = fopen($nomearq . "z", "w");
     foreach ($pontosz as $pt) {
         fwrite($f, $pt . "\n");
     }
     fclose($f);
     if ($limitepontos == "TRUE") {
         $xi = min($pontosx);
         $xf = max($pontosx);
         $yi = min($pontosy);
         $yf = max($pontosy);
     } else {
         $ext = $this->mapa->extent;
         $xi = $ext->minx;
         $xf = $ext->maxx;
         $yi = $ext->miny;
         $yf = $ext->maxy;
     }
     if ($extendelimite > 0) {
         $dx = $xf - $xi;
         $dy = $yf - $yi;
         $maisx = $dx * $extendelimite / 100;
         $maisy = $dy * $extendelimite / 100;
         $xi = $xi - $maisx;
         $xf = $xf + $maisx;
         $yi = $yi - $maisy;
         $yf = $yf + $maisy;
     }
     $dimx = "c(" . $xi . "," . $xf . ")";
     $dimy = "c(" . $yi . "," . $yf . ")";
     return array("dimx" => $dimx, "dimy" => $dimy, "arqx" => $nomearq . "x", "arqy" => $nomearq . "y", "arqz" => $nomearq . "z", "prefixoarquivo" => $nomearq);
 }
コード例 #3
0
 function estatDescritivas($item, $exclui)
 {
     if (!$this->layer) {
         return "erro";
     }
     $this->layer->set("template", "none.htm");
     $items = pegaItens($this->layer, $this->mapa);
     $valores = array();
     $filtro = $this->layer->getfilterstring();
     if ($filtro != "") {
         $this->layer->setfilter("");
     }
     //le o arquivo de query se existir e checa se existe seleção para o tema
     $shapes = retornaShapesSelecionados($this->layer, $this->arquivo, $this->mapa);
     if (count($shapes) == 0) {
         $shapes = retornaShapesMapext($this->layer, $this->mapa);
     }
     //pega os valores
     foreach ($shapes as $shape) {
         $v = $shape->values[$item];
         $valores[] = $v;
     }
     $fechou = $this->layer->close();
     $valoresn = array();
     //verifica se a lista de valores contem numeros e exclusao
     foreach ($valores as $valor) {
         if (is_numeric($valor)) {
             if ($exclui != "") {
                 if ($valor != $exclui) {
                     $valoresn[] = $valor;
                 }
             } else {
                 $valoresn[] = $valor;
             }
         }
     }
     if (count($valoresn) == 0) {
         return "erro. Nenhum valor valido";
     }
     //faz os calculos
     if (file_exists($this->locaplic . "/classe_estatistica.php")) {
         include_once $this->locaplic . "/classe_estatistica.php";
     } else {
         include_once "classe_estatistica.php";
     }
     $estat = new estatistica();
     $resultado = $estat->calcula($valoresn);
     $resultado = $estat->resultado;
     $indice = $estat->indice;
     if ($resultado['min'] == "") {
         return "erro. Nenhum valor valido";
     }
     $chaves = array_keys($indice);
     return array("indices" => $chaves, "variaveis" => $indice, "valores" => $resultado);
 }