Example #1
0
function markerclusterDados($map_file)
{
    global $dir, $layer, $coluna;
    //pega os dados e formata como uma string no formato
    // [{"lat":"-21.7079984","lng":"-47.4913629","count":"1"}]
    //os dados sao devolvidos como uma variavel javascript
    //obtem os registros
    include_once $dir . "/../../classesphp/classe_atributos.php";
    $m = new Atributos($map_file, $layer);
    $registros = $m->listaRegistrosXY($coluna, "brasil", "tudo");
    $n = count($registros);
    $resultado = array();
    if (empty($coluna)) {
        foreach ($registros as $r) {
            $resultado[] = '{"lat":"' . $r["y"] . '","lng":"' . $r["x"] . '","count":"1"}';
        }
    } else {
        foreach ($registros as $r) {
            $resultado[] = '{"lat":"' . $r["y"] . '","lng":"' . $r["x"] . '","count":"' . $r["valores"][0]["valor"] . '"}';
        }
    }
    if (isset($map_file) && isset($postgis_mapa) && $map_file != "") {
        restauraCon($map_file, $postgis_mapa);
    }
    return $resultado;
}
Example #2
0
     Pega a extensão geográfica de um registro na tabela de atributos de um tema.
     
     <Atributos->extensaoRegistro>
     */
 /*
  Valor: EXTREGISTROS
 
 Pega a extens&atilde;o geogr&aacute;fica de um registro na tabela de atributos de um tema.
 
 <Atributos->extensaoRegistro>
 */
 case "EXTREGISTROS":
     include_once "classe_atributos.php";
     $tema = $_pg["tema"];
     $registro = $_pg["registro"];
     $m = new Atributos($map_file, $tema);
     $retorno = $m->extensaoRegistro($registro);
     $m->salva();
     break;
     /*
      Section: Navega&ccedil;&atilde;o
     
     Altera a extens&atilde;o geogr&aacute;fica do mapa.
     
     <classe_navegacao.php>
     */
     /*
      Valor: MARCADORES2SHP
     
     Converte marcadores em shapefile
     */
Example #3
0
function verifica($map, $solegenda, $tabela, $cache = "sim")
{
    global $tipo, $locaplic, $postgis_mapa, $versao, $base, $dir_tmp, $tempo;
    $mapUrl = $map;
    if ($tipo == "mini" && file_exists('temas/miniaturas/' . $map . ".mini.png") && $cache == "sim") {
        Header("Content-type: image/png");
        ImagePng(ImageCreateFromPNG('temas/miniaturas/' . $map . ".mini.png"));
        exit;
    }
    if ($tipo == "grande" && file_exists('temas/miniaturas/' . $map . ".grande.png") && $cache == "sim") {
        Header("Content-type: image/png");
        ImagePng(ImageCreateFromPNG('temas/miniaturas/' . $map . ".grande.png"));
        exit;
    }
    ms_ResetErrorList();
    $tema = "";
    if (file_exists($map)) {
        $tema = $map;
    } else {
        $map = str_replace("\\", "/", $map);
        $map = basename($map);
        if (file_exists('temas/' . $map)) {
            $tema = 'temas/' . $map;
        }
        if (file_exists('temas/' . $map . '.map')) {
            $tema = 'temas/' . $map . ".map";
        }
        if (file_exists('temas/' . $map . '.gvp')) {
            $tema = 'temas/' . $map . ".gvp";
        }
    }
    if (!file_exists($tema)) {
        $tema = $locaplic . "/" . $tema;
    }
    if ($tipo == "" || $tipo == "todos") {
        echo "<hr><br><br><span style='color:red' ><b>Testando: {$tema} </span><pre></b>";
    }
    if (!file_exists($tema)) {
        echo "Arquivo " . $map . " n&atilde;o encontrado.";
        exit;
    }
    if ($tema != "") {
        if ($base == "" or !isset($base)) {
            $base = "";
            if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
                $base = $locaplic . "/aplicmap/geral1windowsv" . $versao . ".map";
            } else {
                if ($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv' . $versao . '.map')) {
                    $base = "/var/www/i3geo/aplicmap/geral1debianv" . $versao . ".map";
                }
                if ($base == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) {
                    $base = "/var/www/html/i3geo/aplicmap/geral1fedorav" . $versao . ".map";
                }
                if ($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) {
                    $base = "/opt/www/html/i3geo/aplicmap/geral1v" . $versao . ".map";
                }
                if ($base == "") {
                    $base = $locaplic . "/aplicmap/geral1v" . $versao . ".map";
                }
            }
        } else {
            if (!file_exists($base)) {
                $base = $locaplic . "/aplicmap/" . $base;
            }
        }
        //echo $base;exit;
        $mapa = ms_newMapObj($base);
        error_reporting(0);
        $numlayers = $mapa->numlayers;
        for ($i = 0; $i < $numlayers; $i++) {
            $layern = $mapa->getlayer($i);
            if (!empty($postgis_mapa)) {
                if ($layern->connectiontype == MS_POSTGIS) {
                    $lcon = $layern->connection;
                    if ($lcon == " " || $lcon == "" || in_array($lcon, array_keys($postgis_mapa))) {
                        if ($lcon == " " || $lcon == "") {
                            $layern->set("connection", $postgis_mapa);
                        } else {
                            $layern->set("connection", $postgis_mapa[$lcon]);
                        }
                    }
                }
            }
        }
        if (!stristr($tema, '.php') === FALSE) {
            /*
            echo "<br>Arquivo <i>$tema</i> &eacute; um programa PHP. O teste pode n&atilde;o funcionar.<br>";
            include_once($locaplic."/".$tema);
            $pegarext = str_replace(".php","",$tema);
            $pegarext = str_replace("temas/","",$pegarext);
            eval($pegarext."(\$mapa);");
            */
        }
        if (!stristr($tema, '.map') === FALSE) {
            if (file_exists($mapUrl)) {
                ms_ResetErrorList();
                if (@ms_newMapObj($mapUrl)) {
                    $nmapa = ms_newMapObj($mapUrl);
                } else {
                    echo "Erro no arquivo {$mapUrl} <br>";
                    $error = ms_GetErrorObj();
                    while ($error && $error->code != MS_NOERR) {
                        printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message);
                        $error = $error->next();
                    }
                    return;
                }
            } else {
                if (@ms_newMapObj($locaplic . "/" . $tema)) {
                    if (!function_exists("validaAcessoTemas")) {
                        include $locaplic . "/classesphp/funcoes_gerais.php";
                    }
                    if (validaAcessoTemas($locaplic . "/" . $tema, false) == false) {
                        $nmapa = ms_newMapObj($locaplic . "/" . $tema);
                    } else {
                        echo "tema restrito <br>";
                        exit;
                    }
                } else {
                    echo "erro no arquivo {$map} <br>";
                    echo "Obs.: em alguns testes o mapfile pode falhar se o endere&ccedil;o dos arquivos de s&iacute;mbolos estiverem <br>definidos de forma relativa ao inv&eacute;s de absoluta. Nesses casos, ao abrir o i3Geo, <br>o mapfile poder&aacute; funcionar. <br>";
                    $error = ms_GetErrorObj();
                    while ($error && $error->code != MS_NOERR) {
                        printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message);
                        $error = $error->next();
                    }
                    return;
                }
            }
            $numlayers = $nmapa->numlayers;
            $dados = "";
            $simbolos = array();
            for ($i = 0; $i < $numlayers; $i++) {
                $layern = $nmapa->getlayer($i);
                $layern->set("status", MS_DEFAULT);
                if (!empty($postgis_mapa)) {
                    if ($layern->connectiontype == MS_POSTGIS) {
                        $lcon = $layern->connection;
                        error_reporting(0);
                        if ($lcon == " " || $lcon == "" || in_array($lcon, array_keys($postgis_mapa))) {
                            if ($lcon == " " || $lcon == "") {
                                $layern->set("connection", $postgis_mapa);
                            } else {
                                $layern->set("connection", $postgis_mapa[$lcon]);
                            }
                        }
                    }
                }
                autoClasses($layern, $nmapa);
                error_reporting(0);
                if ($layern->classitem != "" && $layern->connectiontype == 7 && $layern->numclasses > 0 && $layern->getmetadata("wms_sld_body") == "") {
                    $tipotemp = $layern->type;
                    $tiporep = $layern->getmetadata("tipooriginal");
                    $layern->set("type", MS_LAYER_POLYGON);
                    if ($tiporep == "linear") {
                        $layern->set("type", MS_LAYER_LINE);
                    }
                    if ($tiporep == "pontual") {
                        $layern->set("type", MS_LAYER_POINT);
                    }
                    $sld = $layern->generateSLD();
                    if ($sld != "") {
                        $layern->setmetadata("wms_sld_body", str_replace('"', "'", $sld));
                    }
                    $layern->set("type", $tipotemp);
                }
                //pega simbolos locais e aplica no novo mapa
                cloneInlineSymbol($layern, $nmapa, $mapa);
                $layerAdicionado = ms_newLayerObj($mapa, $layern);
                corrigeLayerGrid($layern, $layerAdicionado);
                /*
                if ($layern->data == ""){
                	$dados = $layern->connection;
                }
                else{
                	$dados = $layern->data;
                }
                */
                $pegarext = $layern->name;
            }
            zoomTema($pegarext, $mapa);
        }
        if (!stristr($tema, '.gvp') === FALSE) {
            if (file_exists($mapUrl)) {
                $gvsiggvp = $mapUrl;
            } else {
                $gvsiggvp = $locaplic . "/" . $tema;
            }
            include_once $locaplic . "/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php";
            $gm = new gvsig2mapfile($gvsiggvp);
            $gvsigview = $gm->getViewsNames();
            foreach ($gvsigview as $v) {
                $dataView = $gm->getViewData($v);
                $mapa = $gm->addLayers($mapa, $v, $dataView["layerNames"]);
            }
            $next = $dataView["extent"];
            $ext = $mapa->extent;
            $ext->setextent($next[0], $next[1], $next[2], $next[3]);
        }
        if ($tipo == "mini") {
            $mapa->setsize(50, 50);
            $sca = $mapa->scalebar;
            $sca->set("status", MS_OFF);
        }
        if ($tipo == "grande") {
            $mapa->setsize(300, 300);
            $sca = $mapa->scalebar;
            $sca->set("status", MS_OFF);
        }
        if ($tipo == "todos") {
            $mapa->setsize(150, 150);
            $sca = $mapa->scalebar;
            $sca->set("status", MS_OFF);
        }
        $destino = $dir_tmp . "/" . nomeRandomico() . ".map";
        $mapa->save($destino);
        validaAcessoTemas($destino, true);
        //testa a tabela de atributos
        if (isset($_GET["tabela"])) {
            include "classesphp/classe_atributos.php";
            $t = new Atributos($destino, $map);
            restauraCon($destino, $postgis_mapa);
            $r = $t->itensTexto();
            $colunas = explode(";", $r["itens"]);
            $ncolunas = count($colunas);
            $registros = $r["valores"];
            $nregistros = count($registros);
            $error = "";
            $error = ms_GetErrorObj();
            echo "</div><div style='text-align:left;margin: auto;width:900px;overflow: auto;'>";
            while ($error && $error->code != MS_NOERR) {
                echo "<br>Error in %s: %s<br>", $error->routine, $error->message;
                $error = $error->next();
            }
            echo "Registros em UTF8 s&atilde;o convertidos para ISO-8859-1<br>";
            echo "Registros: " . $nregistros;
            "<br>";
            echo "<br><b>Tempo leitura (s): ";
            echo microtime(true) - $tempo;
            echo "</b>";
            echo "<table>";
            echo "<tr>";
            foreach ($colunas as $co) {
                echo "<td><b>" . $co . "</b></td>";
            }
            echo "</tr>";
            foreach ($registros as $reg) {
                echo "<tr>";
                $cc = explode(";", $reg);
                foreach ($cc as $c) {
                    if (mb_detect_encoding($c, "UTF-8", true)) {
                        $c = mb_convert_encoding($c, "ISO-8859-1", "UTF-8");
                    }
                    echo "<td>" . $c . "</td>";
                }
                echo "</tr>";
            }
            echo "</table>";
            echo "<br><b>Tempo total (montagem da tabela) (s): ";
            echo microtime(true) - $tempo;
            echo "</b>";
        } else {
            $mapa = ms_newMapObj($destino);
            restauraConObj($mapa, $postgis_mapa);
            $objImagem = @$mapa->draw();
            //corrige o titulo da legenda
            $numlayers = $mapa->numlayers;
            for ($j = 0; $j < $numlayers; $j++) {
                $l = $mapa->getlayer($j);
                if ($l->type != 3 && $l->type != 4) {
                    $nclass = $l->numclasses;
                    for ($i = 0; $i < $nclass; $i++) {
                        $classe = $l->getclass($i);
                        if ($classe->title === "") {
                            $classe->title = $classe->name;
                        }
                    }
                }
            }
            $objImagemLegenda = @$mapa->drawLegend();
            if (!$objImagem) {
                echo "Problemas ao gerar o mapa<br>";
                $error = "";
                $error = ms_GetErrorObj();
                while ($error && $error->code != MS_NOERR) {
                    echo "<br>Error in %s: %s<br>", $error->routine, $error->message;
                    $error = $error->next();
                }
                return;
            }
            if ($objImagem->imagepath == "") {
                echo "Erro IMAGEPATH vazio";
            }
            $nomec = $objImagem->imagepath . nomeRandomico() . "teste.png";
            $objImagem->saveImage($nomec);
            $nomer = $objImagem->imageurl . basename($nomec);
            $nomel = $objImagemLegenda->imagepath . nomeRandomico() . "testel.png";
            $objImagemLegenda->saveImage($nomel);
            $nomerl = $objImagemLegenda->imageurl . basename($nomel);
            if ($tipo == "" || $tipo == "todos") {
                if ($solegenda == "nao") {
                    echo "<img src=" . $nomer . " /><br>";
                }
                echo "<img src=" . $nomerl . " />";
                if ($tipo == "todos") {
                    //echo "<br>".$dados."<br>";
                }
                if ($map != "todos") {
                    echo "<br><b>Tempo (s): ";
                    echo microtime(true) - $tempo;
                    echo "</b>";
                    echo "<br>Erros ocorridos:<br>";
                    $error = "";
                    $error = ms_GetErrorObj();
                    while ($error && $error->code != MS_NOERR) {
                        echo "<br>Error in %s: %s<br>", $error->routine, $error->message;
                        $error = $error->next();
                    }
                }
            } else {
                Header("Content-type: image/png");
                ImagePng(ImageCreateFromPNG($nomec));
            }
        }
    }
}
Example #4
0
     Valor: ESTATISTICA
     
     Calcula estat&iacute;sticas b&aacute;sicas de uma tabela de um tema.
     
     <Atributos->estatDescritivas>
     */
 /*
 Valor: ESTATISTICA
 
 Calcula estat&iacute;sticas b&aacute;sicas de uma tabela de um tema.
 
 <Atributos->estatDescritivas>
 */
 case "ESTATISTICA":
     include_once dirname(__FILE__) . "/../../classesphp/classe_atributos.php";
     $m = new Atributos($map_file, $tema, $locaplic, $ext);
     $retorno = $m->estatDescritivas($_GET["item"], $_GET["exclui"]);
     break;
     /*
     Valor: GRAFICOPIZZA
     
     Cria um gr&aacute;fico de pizza.
     
     <graficoPizza>
     */
 /*
 Valor: GRAFICOPIZZA
 
 Cria um gr&aacute;fico de pizza.
 
 <graficoPizza>
Example #5
0
function testaTabela($tema)
{
    global $locaplic, $postgis_mapa, $versao, $base, $dir_tmp, $tempo;
    $base = mapaBase($locaplic, $versao, $base);
    $mapa = ms_newMapObj($base);
    $nmapa = ms_newMapObj($tema);
    error_reporting(0);
    ms_ResetErrorList();
    $numlayers = $nmapa->numlayers;
    $dados = "";
    for ($i = 0; $i < $numlayers; $i++) {
        $layern = $nmapa->getlayer($i);
        $layern->set("status", MS_DEFAULT);
        error_reporting(0);
        if ($layern->classitem != "" && $layern->connectiontype == 7 && $layern->numclasses > 0 && $layern->getmetadata("wms_sld_body") == "") {
            $tipotemp = $layern->type;
            $tiporep = $layern->getmetadata("tipooriginal");
            $layern->set("type", MS_LAYER_POLYGON);
            if ($tiporep == "linear") {
                $layern->set("type", MS_LAYER_LINE);
            }
            if ($tiporep == "pontual") {
                $layern->set("type", MS_LAYER_POINT);
            }
            $sld = $layern->generateSLD();
            if ($sld != "") {
                $layern->setmetadata("wms_sld_body", str_replace('"', "'", $sld));
            }
            $layern->set("type", $tipotemp);
        }
        $layerAdicionado = ms_newLayerObj($mapa, $layern);
        $pegarext = $layern->name;
    }
    zoomTema($pegarext, $mapa);
    include_once $locaplic . "/classesphp/classe_atributos.php";
    $t = new Atributos($mapa, $layern->name);
    $r = $t->itensTexto();
    $colunas = explode(";", $r["itens"]);
    $ncolunas = count($colunas);
    $registros = $r["valores"];
    $nregistros = count($registros);
    $error = "";
    $error = ms_GetErrorObj();
    $tab = "";
    while ($error && $error->code != MS_NOERR) {
        $tab .= "<br>Error in %s: %s<br>";
        $tab .= $error->routine;
        $tab .= $error->message;
        $error = $error->next();
    }
    $tab .= "Registros em ISO-8859-1 s&atilde;o convertidos para UTF8<br>";
    $tab .= "Registros: " . $nregistros;
    "<br>";
    $tab .= "<br><b>Tempo leitura (s): ";
    $tab .= microtime(true) - $tempo;
    $tab .= "</b>";
    $tab .= "<table>";
    $tab .= "<tr>";
    foreach ($colunas as $co) {
        $tab .= "<td><b>" . $co . "</b></td>";
    }
    $tab .= "</tr>";
    foreach ($registros as $reg) {
        $tab .= "<tr>";
        $cc = explode(";", $reg);
        foreach ($cc as $c) {
            if (mb_detect_encoding($c, 'UTF-8, ISO-8859-1') == "ISO-8859-1") {
                $c = utf8_encode($c);
            }
            $tab .= "<td>" . $c . "</td>";
        }
        $tab .= "</tr>";
    }
    $tab .= "</table>";
    $tab .= "<br><b>Tempo total (montagem da tabela) (s): ";
    $tab .= microtime(true) - $tempo;
    $tab .= "</b>";
    return $tab;
}
Example #6
0
 function insereSHPgrafico($x, $y, $itens, $width, $inclinacao, $shadow_height, $ext = "")
 {
     if (!isset($tipo)) {
         $tipo = "pizza";
     }
     //nome do novo tema
     $temaedit = nomeRandomico();
     //pega os valores
     include_once $this->locaplic . "/classesphp/classe_atributos.php";
     $m = new Atributos($this->arquivo, $this->tema);
     $shape = $m->identificaQBP2($this->nome, $x, $y, $this->arquivo, 0, "", "shape", false, $ext);
     if (is_array($shape) && $shape[0] == " ") {
         return "erro.Nenhum valor encontrado";
     } else {
         $shape = $shape[0];
         $itens = explode("*", $itens);
         foreach ($itens as $i) {
             $ii = explode(",", $i);
             $v = $shape->values[$ii[0]];
             if (!is_numeric($v)) {
                 return "erro. Dados nao numericos.";
             }
             $valor[] = $v;
             $cor[] = $ii[1] . "," . $ii[2] . "," . $ii[3];
         }
         $data = implode("*", $valor);
         $cores = implode("*", $cor);
         if ($tipo == "pizza") {
             //gera a figura
             include_once $this->locaplic . "/classesphp/graficopizza.php";
             $res = graficopizza($data, $width, $inclinacao, $shadow_height, $cores, $this->arquivo, $temaedit);
             $img = explode(",", $res);
         }
         //insere simbolo
         $nomes = nomeRandomico();
         $nId = ms_newsymbolobj($this->mapa, $img[0]);
         $oSymbol = $this->mapa->getsymbolobjectbyid($nId);
         $oSymbol->set("inmapfile", MS_TRUE);
         $oSymbol->set("type", MS_SYMBOL_PIXMAP);
         $oSymbol->setimagepath($img[0]);
         $oSymbol->set("name", $nomes);
         $pinlayer = criaLayer($this->mapa, MS_LAYER_POINT, MS_DEFAULT, "Gr&aacute;fico (" . $temaedit . ")", "SIM");
         $c = $pinlayer->getclass(0);
         $e = $c->getstyle(0);
         $pinlayer->set("name", $temaedit);
         $c->set("name", "");
         if (!isset($tamanho)) {
             $tamanho = 50;
         }
         $e->set("size", $tamanho);
         $e->set("symbolname", $nomes);
         $pinlayer->set("opacity", MS_GD_ALPHA);
         $shp = ms_newshapeobj(MS_SHAPE_POINT);
         $lin = ms_newlineobj();
         $lin->addxy($x, $y);
         $shp->add($lin);
         $pinlayer->addfeature($shp);
         $this->salva();
         return "ok";
     }
 }
Example #7
0
function dadosPerfilRelevo($pontos, $opcao, $amostragem, $item = "", $map_file = "")
{
    $urlGoogle = "http://maps.google.com/maps/api/elevation/json?sensor=false&path=";
    $pontos = str_replace(",", "|", $pontos);
    $pontos = str_replace(" ", ",", $pontos);
    $urlGoogle .= $pontos . "&samples=" . $amostragem;
    $curl = curl_init();
    if (!isset($i3geo_proxy_server)) {
        include dirname(__FILE__) . "/../ms_configura.php";
    }
    curl_setopt($curl, CURLOPT_URL, $urlGoogle);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    if (isset($i3geo_proxy_server) && $i3geo_proxy_server != "") {
        curl_setopt($curl, CURLOPT_PROXY, $i3geo_proxy_server);
    }
    $result = curl_exec($curl);
    curl_close($curl);
    $result = json_decode($result, true);
    if ($opcao != "google") {
        include_once "classe_atributos.php";
        $m = new Atributos($map_file, $opcao);
        $rs = array();
        foreach ($result["results"] as $r) {
            $l = $r["location"];
            $rs[] = $m->identificaQBP2("", $l["lng"], $l["lat"], "", 5, $item, "googlerelevo", $etip = false, $ext = "");
        }
        $result = array("results" => $rs, "status" => "OK");
    }
    return $result;
}
Example #8
0
$c->setrgb(-1, -1, -1);
$o = $mapa->outputformat;
$o->set("imagemode", MS_IMAGEMODE_RGBA);
if ($transparente == "sim") {
    $o->set("transparent", MS_TRUE);
}
restauraConObj($mapa, $postgis_mapa);
$mapa->save($arqtemp . ".map");
/*
if(validaAcessoTemas($arqtemp.".map",false) == true){
	echo "Existem temas restritos";exit;
}
*/
//pega a lista de valores unicos da $colunat
include_once "../../classesphp/classe_atributos.php";
$m = new Atributos($arqtemp . ".map", $tema);
$lista = $m->listaUnicoRapida($colunat);
$listaunica = array();
foreach ($lista as $l) {
    $l = str_replace($nulos, "", $l);
    if ($l != "") {
        $listaunica[] = $l;
    }
}
$mapa = ms_newMapObj($arqtemp . ".map");
//cria as imagens para cada periodo
$layer = $mapa->getlayerbyname($tema);
$copyright = $mapa->getlayerbyname("copyright");
if ($copyright != "") {
    $classe = ms_newClassObj($copyright);
    $classet = ms_newClassObj($copyright);