Esempio n. 1
0
    case "INCLUI":
        restauraCon($map_file, $postgis_mapa);
        $mapa = ms_newMapObj($map_file);
        $l = $mapa->getlayerbyname($tema);
        if ($l != "") {
            $l->setmetadata("storymap", $storymap);
            $mapa->save($map_file);
        }
        $arq = $locaplic . "/temas/" . $tema . ".map";
        if (file_exists($arq)) {
            $mapa = ms_newMapObj($arq);
            $l = $mapa->getlayerbyname($tema);
            if ($l != "") {
                $l->setmetadata("storymap", str_replace("\\", "'", $_POST["storymap"]));
                $mapa->save($arq);
                removeCabecalho($arq);
            }
        }
        $retorno = "ok";
        break;
}
cpjson($retorno);
//TODO colocar essa funcao em algum lugar que permita reaproveitamento
function removeCabecalho($arq, $symbolset = true)
{
    $handle = fopen($arq, "r");
    if ($handle) {
        $cabeca = array();
        if ($symbolset) {
            $cabeca[] = "MAP\n";
        }
Esempio n. 2
0
function alteraTemas()
{
    global $esquemaadmin, $id, $locaplic;
    //error_reporting(0);
    try {
        $retorna = "ok";
        include "conexao.php";
        $nomeo = $_GET["nome"];
        if ($convUTF) {
            $_GET["nome"] = utf8_encode($_GET["nome"]);
            $_GET["desc"] = utf8_encode($_GET["desc"]);
            $_GET["tags"] = utf8_encode($_GET["tags"]);
            $_GET["en"] = utf8_encode($_GET["en"]);
            $_GET["es"] = utf8_encode($_GET["es"]);
            $_GET["it"] = utf8_encode($_GET["it"]);
        }
        if ($id != "") {
            $dataCol = array("en" => $_GET["en"], "es" => $_GET["es"], "it" => $_GET["it"], "tags_tema" => $_GET["tags"], "link_tema" => $_GET["link"], "nome_tema" => $_GET["nome"], "desc_tema" => $_GET["desc"], "codigo_tema" => $_GET["codigo"], "tipoa_tema" => $_GET["tipoa"], "download_tema" => $_GET["download"], "ogc_tema" => $_GET["ogc"], "kml_tema" => $_GET["kml"]);
            if (isset($_GET["kmz"])) {
                $dataCol["kmz_tema"] = $_GET["kmz"];
            }
            i3GeoAdminUpdate($dbhw, "i3geoadmin_temas", $dataCol, "WHERE id_tema = {$id}");
            $retorna = $id;
            if (!isset($_GET["kmz"])) {
                $_GET["kmz"] = "nao";
            }
            $sql = "SELECT * from " . $esquemaadmin . "i3geoadmin_temas where id_tema = {$id}";
            $q = $dbh->query($sql, PDO::FETCH_ASSOC);
            $resultado = $q->fetchAll();
            $mapfile = $resultado[0]["codigo_tema"];
            if (file_exists($locaplic . "/temas/" . $mapfile . ".map")) {
                $mapfile = $locaplic . "/temas/" . $mapfile . ".map";
                if ($mapa = @ms_newMapObj($mapfile)) {
                    $mapa = ms_newMapObj($mapfile);
                    $numlayers = $mapa->numlayers;
                    for ($i = 0; $i < $numlayers; $i++) {
                        $layer = $mapa->getlayer($i);
                        $layer->setmetadata("permitedownload", strtolower($_GET["download"]));
                        $layer->setmetadata("download", strtolower($_GET["download"]));
                        $layer->setmetadata("permiteogc", strtolower($_GET["ogc"]));
                        $layer->setmetadata("permitekml", strtolower($_GET["kml"]));
                        $layer->setmetadata("permitekmz", strtolower($_GET["kmz"]));
                        //zera os metadados do sistema METAESTAT
                        if ($_GET["tipoa"] != "META") {
                            $layer->setmetadata("METAESTAT_CODIGO_TIPO_REGIAO", "");
                            $layer->setmetadata("METAESTAT_ID_MEDIDA_VARIAVEL", "");
                            $layer->setmetadata("metaestat", "");
                        }
                        if (count($_GET["nomes"]) == 1) {
                            $layer->setmetadata("tema", $nomeo);
                        }
                    }
                    $mapa->save($mapfile);
                    removeCabecalho($mapfile);
                }
            }
        } else {
            $dataCol = array("en" => "", "es" => "", "it" => "", "tags_tema" => "", "link_tema" => "", "nome_tema" => "", "desc_tema" => "", "codigo_tema" => "", "tipoa_tema" => "", "download_tema" => "", "ogc_tema" => "", "kml_tema" => "");
            if (isset($kmz)) {
                $dataCol["kmz_tema"] = "";
            }
            $retorna = i3GeoAdminInsertUnico($dbhw, "i3geoadmin_temas", $dataCol, "nome_tema", "id_tema");
        }
        //verifica se &eacute; necess&aacute;rio adicionar algum tag novo
        $_GET["tags"] = explode(" ", $_GET["tags"]);
        foreach ($_GET["tags"] as $tag) {
            if (!verificaDuplicados("select * from " . $esquemaadmin . "i3geoadmin_tags where nome = '{$tag}'", $dbh)) {
                $dataCol = array("nome" => $tag);
                i3GeoAdminInsert($dbhw, "i3geoadmin_tags", $dataCol);
            }
        }
        $dbhw = null;
        $dbh = null;
        return $retorna;
    } catch (PDOException $e) {
        return "Error!: ";
    }
}
Esempio n. 3
0
function alterarEstilo()
{
    global $codigoMap, $codigoLayer, $locaplic;
    $dados = array();
    $mapfile = $locaplic . "/temas/" . $codigoMap . ".map";
    $mapa = ms_newMapObj($mapfile);
    $layer = $mapa->getlayerbyname($codigoLayer);
    if (strtoupper($layer->getmetadata("metaestat")) === "SIM") {
        return "erro. Layer METAESTAT";
    }
    $nclasses = $layer->numclasses;
    $classe = $layer->getclass($_GET["indiceClasse"]);
    $estilo = $classe->getstyle($_GET["indiceEstilo"]);
    if (!empty($_GET["symbolname"])) {
        $estilo->set("symbolname", $_GET["symbolname"]);
    }
    if (empty($_GET["symbolname"])) {
        $estilo->set("symbolname", " ");
    }
    corE($estilo, $color, "color");
    $estilo->set("size", $_GET["size"]);
    $estilo->set("minsize", $_GET["minsize"]);
    $estilo->set("maxsize", $_GET["maxsize"]);
    $estilo->set("offsetx", $_GET["offsetx"]);
    $estilo->set("offsety", $_GET["offsety"]);
    $estilo->set("antialias", $_GET["antialias"]);
    corE($estilo, $_GET["backgroundcolor"], "backgroundcolor");
    corE($estilo, $_GET["outlinecolor"], "outlinecolor");
    $estilo->set("width", $_GET["width"]);
    $estilo->set("minwidth", $_GET["minwidth"]);
    $estilo->set("maxwidth", $_GET["maxwidth"]);
    $estilo->set("angle", $_GET["angle"]);
    //$estilo->set("opacity",$opacity);
    $mapa->save($mapfile);
    removeCabecalho($mapfile);
    return "ok";
}
Esempio n. 4
0
        $key = null;
        while ($key = $hashTable->nextkey($key)) {
            if (!in_array(strtolower($key), array("tema", "nomeoriginal"))) {
                //echo "Key: ".$key." value: ".$hashTable->get($key)."<br/>";
                $l->setmetadata($key, "");
                if ($ct != MS_WMS) {
                    $remover[] = strtoupper($key);
                }
            }
        }
    }
}
$remover = array_unique($remover);
$mapa->save($arquivo);
$mapa = null;
removeCabecalho($arquivo, $remover);
header("Content-Type:text/plain");
header('Content-Disposition: attachment; filename="' . basename($arquivo) . '"');
readfile($arquivo);
function removeCabecalho($arq, $remover)
{
    global $locaplic;
    //locaplic pode ser um endereco baseado no link simbolico. Por isso utiliza-se apenas o nome da pasta principal
    $pasta = basename($locaplic);
    $handle = fopen($arq, "r");
    if ($handle) {
        $cabeca = array();
        //$cabeca[] = "MAP\n";
        $grava = false;
        while (!feof($handle)) {
            $linha = fgets($handle);