Esempio n. 1
0
 function __construct($map_file = "", $perfil = "", $locaplic = "", $urli3geo = "", $editores = "", $idioma = "pt", $filtro = "")
 {
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     $perfil = str_replace(" ", ",", $perfil);
     $this->perfil = explode(",", $perfil);
     $this->locaplic = $locaplic;
     $this->urli3geo = $urli3geo;
     $this->idioma = $idioma;
     $this->filtro = $filtro;
     if ($map_file != "" && file_exists($map_file)) {
         $this->mapa = ms_newMapObj($map_file);
         substituiConObj($this->mapa, $postgis_mapa);
         $this->arquivo = $map_file;
         if ($this->mapa) {
             $c = $this->mapa->numlayers;
             for ($i = 0; $i < $c; ++$i) {
                 $this->layers[] = $this->mapa->getlayer($i);
             }
         }
     }
     //
     //verifica o usuario logado esta cadastrado como um dos publicadores
     //editores podem ver as coisas marcadas como n&atilde;o publicado
     //no sistema de administra&ccedil;&atilde;o
     //
     $this->editor = false;
     $this->editores = "";
     $this->editor = $this->verificaPapelSessao(3);
 }
Esempio n. 2
0
 function __construct($map_file, $locaplic = "")
 {
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     if (file_exists($locaplic . "/funcoes_gerais.php")) {
         include_once $locaplic . "/funcoes_gerais.php";
     } else {
         include_once "funcoes_gerais.php";
     }
     $this->mapa = ms_newMapObj($map_file);
     substituiConObj($this->mapa, $postgis_mapa);
     $this->arquivo = str_replace(".map", "", $map_file) . ".map";
 }
Esempio n. 3
0
 function __construct($map_file, $tema = "", $locaplic = "", $ext = "")
 {
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     include_once dirname(__FILE__) . "/funcoes_gerais.php";
     $this->locaplic = $locaplic;
     $this->mapa = ms_newMapObj($map_file);
     substituiConObj($this->mapa, $postgis_mapa);
     $this->arquivo = str_replace(".map", "", $map_file) . ".map";
     $this->layer = "";
     if ($tema != "" && @$this->mapa->getlayerbyname($tema)) {
         $this->layer = $this->mapa->getlayerbyname($tema);
     }
     $this->nome = $tema;
     if ($ext && $ext != "") {
         $e = explode(" ", $ext);
         $extatual = $this->mapa->extent;
         $extatual->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3]));
     }
 }
Esempio n. 4
0
 function __construct($map_file = "", $locaplic = "", $tema = "", $template = "")
 {
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     include_once dirname(__FILE__) . "/funcoes_gerais.php";
     $this->v = versao();
     $this->v = $this->v["principal"];
     $this->localaplicacao = $locaplic;
     if ($map_file == "") {
         return;
     }
     $this->mapa = ms_newMapObj($map_file);
     substituiConObj($this->mapa, $postgis_mapa);
     $this->arquivo = str_replace(".map", "", $map_file) . ".map";
     if ($tema != "" && @$this->mapa->getlayerbyname($tema)) {
         $this->layer = $this->mapa->getlayerbyname($tema);
         $this->nome = $tema;
         $vermultilayer = new vermultilayer();
         $vermultilayer->verifica($map_file, $tema);
         if ($vermultilayer->resultado == 1) {
             $ls = $vermultilayer->temas;
             $this->visiveis = $vermultilayer->temasvisiveis;
         } else {
             $ls[] = $tema;
             $this->visiveis = array($tema);
         }
         $this->grupo = $ls;
         foreach ($ls as $l) {
             $t = $this->mapa->getlayerbyname($l);
             $this->indices[] = $t->index;
         }
     }
     if ($template == "") {
         $template = "legenda.htm";
     }
     if (file_exists($template)) {
         $this->templateleg = $template;
         return;
     }
     if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
         $this->templateleg = $locaplic . "\\aplicmap\\" . $template;
     } else {
         $this->templateleg = $locaplic . "/aplicmap/" . $template;
     }
 }
Esempio n. 5
0
function downloadTema2($map_file, $tema, $locaplic, $dir_tmp, $postgis_mapa)
{
    ini_set("max_execution_time", "1800");
    ini_set('memory_limit', '5000M');
    $temas = array();
    if (file_exists($locaplic . "/ms_configura.php")) {
        include $locaplic . "/ms_configura.php";
    } else {
        include dirname(__FILE__) . "/../ms_configura.php";
    }
    //para zipar o shapefile
    include dirname(__FILE__) . "/../pacotes/kmlmapserver/classes/zip.class.php";
    $versao = versao();
    $versao = $versao["principal"];
    $dataArquivos = array();
    //
    //cria o arquivo mapfile, caso ele n&atilde;o exista, que servir&aacute; de base para obten&ccedil;&atilde;o dos dados
    //
    $nomeRand = true;
    $projecao = pegaProjecaoDefault();
    if ($map_file == "" || !@ms_newMapObj($map_file)) {
        //a funcao foi chamada do aplicativo datadownload
        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;
            }
        }
        $map_tmp = ms_newMapObj($base);
        $map_file = $dir_tmp . "/downloadTema2" . nomerandomico(20) . ".map";
        $map_tmp->setProjection($projecao["proj4"]);
        $map_tmp->save($map_file);
        $nomeRand = false;
    }
    //
    //verifica se o tema existe no mapfile
    //se n&atilde;o existir, tenta inserir com base no mapfile existente no diret&oacute;rio temas
    //o tema pode existir se a fun&ccedil;&atilde;o estiver sendo chamada da &aacute;rvore de temas de um mapa j&aacute; aberto
    //
    $temasdir = $locaplic . "/temas";
    $map = ms_newMapObj($map_file);
    $rectextent = $map->extent;
    $extensao = ".map";
    if (file_exists($locaplic . "/temas/" . $tema . ".gvp")) {
        $extensao = ".gvp";
    }
    if ($extensao == ".map") {
        //
        //problema aqui
        //$tema pode ser diferente do nome do mapfile
        //
        $teste = @$map->getlayerbyname($tema);
        //caso o usuario tenha usado caixa alta no nome do layer
        if ($teste == "") {
            $teste = @$map->getlayerbyname(strtoupper($tema));
        }
        //se o layer n&atilde;o existir no mapfile, pega da pasta i3geo/temas e adiciona em $map
        if ($teste == "") {
            //tema pode ser o nome de um arquivo mapfile
            if (file_exists($tema . ".map")) {
                $maptemp = ms_newMapObj($tema . ".map");
                $tema = basename($tema);
            } else {
                $maptemp = ms_newMapObj($temasdir . "/" . $tema . ".map");
            }
            $numlayers = $maptemp->numlayers;
            for ($i = 0; $i < $numlayers; ++$i) {
                $ll = $maptemp->getlayer($i);
                $permite = $ll->getmetadata("permitedownload");
                if ($permite != "nao") {
                    ms_newLayerObj($map, $ll);
                }
            }
            $teste = @$map->getlayerbyname($tema);
            if ($teste == "") {
                $ll = $maptemp->getlayer(0);
                $permite = $ll->getmetadata("permitedownload");
                if ($permite != "nao") {
                    ms_newLayerObj($map, $ll);
                    $tema = $ll->name;
                }
            }
        } else {
            //remove o metadata com um nome de arquivo opcional, pois a fun&ccedil;&atilde;o de download pode estar sendo executada da &aacute;rvore de camadas
            $teste = $map->getlayerbyname($tema);
            $teste->setmetadata("arquivodownload", "");
        }
    } else {
        include_once $locaplic . "/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php";
        $gm = new gvsig2mapfile($locaplic . "/temas/" . $tema . ".gvp");
        $gvsigview = $gm->getViewsNames();
        foreach ($gvsigview as $gv) {
            $dataView = $gm->getViewData($gvsigview);
            $map = $gm->addLayers($map, $gvsigview, $dataView["layerNames"]);
            $temas = array_merge($temas, $gm->nomesLayersAdicionados);
        }
    }
    //
    //salva o mapfile com um outro nome para evitar que o mapa atual, se estiver aberto, seja modificado
    //
    //verifica se tem query e copia o arquivo
    $qyfile = str_replace(".map", "_qy.map", $map_file);
    $nr = nomerandomico(5);
    $map_file = str_replace(".map", $nr . "tmp.map", $map_file);
    if (file_exists($qyfile)) {
        $nqyfile = str_replace(".map", "_qy.map", $map_file);
        $nqyfile = str_replace("_qy.map", "", $nqyfile) . "_qy.map";
        copy($qyfile, $nqyfile);
    }
    $map->save($map_file);
    //$map_file agora contem os LAYERS necess&aacute;rios
    $map = ms_newMapObj($map_file);
    substituiConObj($map, $postgis_mapa);
    $nameMapfile = $map->name;
    //
    //verifica se existe mais de um tema (grupo) montando o array com os temas
    //os grupos podem ter o nome do layer em GROUP ao inv&eacute;s de NAME
    //
    if ($extensao == ".map") {
        $multilayer = 0;
        $grupos = $map->getAllGroupNames();
        foreach ($grupos as $grupo) {
            if ($grupo == $tema) {
                $multilayer = 1;
            }
        }
        if ($multilayer == 1) {
            $temasnx = $map->getAllLayerNames();
            foreach ($temasnx as $l) {
                $gl = $map->getlayerbyname($l);
                $g = $gl->group;
                if ($g == $tema || $l == $tema) {
                    $temas[] = $l;
                }
            }
        }
        if ($multilayer == 0) {
            $temas[] = $tema;
        }
    }
    //$temas agora &eacute; um array com os NAMEs dos LAYERS que ser&atilde;o baixados
    $radtmp = dirname($dir_tmp);
    $ziper = new zipfile();
    foreach ($temas as $tema) {
        $l = $map->getlayerbyname($tema);
        $novonomelayer = $tema;
        //usa o NAME do mapfile para nao gerar arquivos com o mesmo nome em instalacoes multiplas do i3geo
        $nomeshp = $dir_tmp . "/" . $nameMapfile . "_" . $novonomelayer;
        if (file_exists($nomeshp . ".dbf")) {
            //
            //verifica se o arquivo est&aacute; vazio ou n&atilde;o
            //se estiver, apaga o arquivo
            //
            $verificaDBF = verificaDBF($nomeshp . ".dbf");
            if ($verificaDBF == false) {
                unlink($nomeshp . ".dbf");
                unlink($nomeshp . ".shp");
                unlink($nomeshp . ".shx");
                unlink($nomeshp . ".prj");
                unlink($nomeshp . ".zip");
            }
        }
        //
        //se existir um arquivo j&aacute; pronto, definido no metadata arquivodownload, ir&aacute; ser utilizado
        //
        $meta = $l->getmetadata("arquivodownload");
        if ($meta != "") {
            //
            //se o arquivo n&atilde;o tiver sido copiado
            //
            //evita que se tente copiar qualquer arquivo
            $meta = str_replace(".zip", "", $meta) . ".zip";
            $nomecopia = $dir_tmp . "/" . $nameMapfile . "_" . basename($meta);
            //para evitar que tente copiar um arquivo mapfile
            $nomecopia = str_replace(".map", "", $nomecopia);
            $nomecopia = str_replace(".zip", "zip", $nomecopia) . ".zip";
            if (file_exists($meta)) {
                if (!file_exists($nomecopia)) {
                    copy($meta, $nomecopia);
                }
            }
            $resultado[] = basename($dir_tmp) . "/" . basename($nomecopia);
        } else {
            //se n&atilde;o existir arquivo definido
            $dados = $l->data;
            //
            //se for imagem, copia o arquivo
            //
            if ($l->type == MS_LAYER_RASTER) {
                if (file_exists($dados)) {
                    $dir = dirname($dados);
                    $arq = explode(".", basename($dados));
                    $nomecopia = $dir_tmp . "/" . $nameMapfile . "_" . $arq[0];
                    $exts = array("jpg", "jpw", "tif", "tifw", "tfw", "png", "pngw", "jpgw", "wld", "img");
                    foreach ($exts as $ext) {
                        $copia = $nomecopia . "." . $ext;
                        if (!file_exists($copia) && file_exists($dir . "/" . $arq[0] . "." . $ext)) {
                            copy($dir . "/" . $arq[0] . "." . $ext, $copia);
                        }
                        if (file_exists($copia)) {
                            $resultado[] = basename($dir_tmp) . "/" . basename($copia);
                        }
                    }
                } else {
                    return "erro";
                }
            } else {
                //se for vetorial, extrai o arquivo
                //
                //verifica se existe selecao, caso contrario, faz a selecao baseada na extensao
                //do mapfile
                //
                include dirname(__FILE__) . "/../classesphp/classe_selecao.php";
                $sel = new Selecao($map_file, $tema);
                //carrega a query para ver se o layer possui selecao ou nao
                $numSel = 0;
                $nomeRand = true;
                if (file_exists($sel->qyfile)) {
                    $map->loadquery($sel->qyfile);
                    $numSel = $l->getNumresults();
                    $nomeshp = criaSHP($tema, $map_file, $locaplic, $dir_tmp, $nomeRand, $projecao["prj"]);
                }
                //
                //se nao existir selecao seleciona por box
                //o box vem do mapfile original
                //
                if (!file_exists($sel->qyfile)) {
                    $box = $rectextent->minx . " " . $rectextent->miny . " " . $rectextent->maxx . " " . $rectextent->maxy;
                    $shapesSel = $sel->selecaoBOX("novo", $box, true);
                    //reaproveita arquivo anterior
                    $nomeRand = false;
                    $nomeshp = criaSHP($tema, $map_file, $locaplic, $dir_tmp, $nomeRand, $projecao["prj"], true, $shapesSel);
                }
                //remove o arquivo de selecao se ele foi criado apenas para pegar todos os elementos
                if ($nomeRand == false) {
                    $sel->selecaoLimpa();
                }
                if ($nomeshp == false) {
                    return array("arquivos" => "<span style=color:red >Ocorreu um erro, tente novamente", "nreg" => 0);
                }
                $pre = str_replace($radtmp . "/", "", $nomeshp);
                $resultado[] = $pre . ".shp";
                $dataArquivos[] = date("F d Y H:i:s.", filemtime($nomeshp . ".shp"));
                $resultado[] = $pre . ".shx";
                $dataArquivos[] = date("F d Y H:i:s.", filemtime($nomeshp . ".shx"));
                $resultado[] = $pre . ".dbf";
                $dataArquivos[] = date("F d Y H:i:s.", filemtime($nomeshp . ".dbf"));
                $resultado[] = $pre . ".prj";
                $dataArquivos[] = date("F d Y H:i:s.", filemtime($nomeshp . ".prj"));
                //zipa o arquivo
                $zip = basename($pre);
                if (!file_exists($pre . ".zip")) {
                    $ziper->addFile(file_get_contents($nomeshp . ".shp"), $zip . ".shp");
                    $ziper->addFile(file_get_contents($nomeshp . ".shx"), $zip . ".shx");
                    $ziper->addFile(file_get_contents($nomeshp . ".dbf"), $zip . ".dbf");
                    $ziper->addFile(file_get_contents($nomeshp . ".prj"), $zip . ".prj");
                    $fp = fopen($nomeshp . ".zip", "wb");
                    fwrite($fp, $ziper->file());
                    fclose($fp);
                }
                $resultado[] = $pre . ".zip";
                $dataArquivos[] = date("F d Y H:i:s.", filemtime($nomeshp . ".zip"));
            }
        }
    }
    $nreg = "";
    if (count($resultado) == 3) {
        $arq = $radtmp . "/" . $resultado[2];
        if (function_exists("dbase_open")) {
            $db = dbase_open($arq, 0);
            if ($db) {
                $nreg = dbase_numrecords($db);
            }
        } else {
            $db = xbase_open($arq, 0);
            if ($db) {
                $nreg = xbase_numrecords($db);
            }
        }
    }
    //
    //gera um mapfile para download
    //
    $nomemapfileurl = "";
    return array("tema" => $tema, "mapfile" => "", "mapfileurl" => "", "arquivos" => implode(",", $resultado), "nreg" => $nreg, "datas" => $dataArquivos, "shape-zip" => $nomeshp . ".zip");
}
Esempio n. 6
0
 function __construct($map_file, $tema = "", $locaplic = "")
 {
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     if (file_exists($locaplic . "/funcoes_gerais.php")) {
         include_once $locaplic . "/funcoes_gerais.php";
     } else {
         include_once "funcoes_gerais.php";
     }
     $this->v = versao();
     $this->vi = $this->v["inteiro"];
     $this->v = $this->v["principal"];
     $this->mapa = ms_newMapObj($map_file);
     substituiConObj($this->mapa, $postgis_mapa);
     $this->arquivo = str_replace(".map", "", $map_file) . ".map";
     if ($tema != "" && @$this->mapa->getlayerbyname($tema)) {
         $this->layer = $this->mapa->getlayerbyname($tema);
     }
     $this->nome = $tema;
 }
Esempio n. 7
0
//
if (isset($_GET["outputFormat"]) && $_GET["outputFormat"] != "") {
    $_GET["OUTPUTFORMAT"] = $_GET["outputFormat"];
}
$agora = intval(time() / 1000);
if (isset($_GET["Z"]) && isset($_GET["X"])) {
    $agora .= "google";
}
$nomeMapfileTmp = $dir_tmp . "/ogcpsql_" . md5($tema . $plugin . $req->getValueByName("SRS")) . "_" . $agora . ".map";
$nomeMapfileTmp = str_replace(",", "", $nomeMapfileTmp);
$nomeMapfileTmp = str_replace(" ", "", $nomeMapfileTmp);
//essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao
$cortePixels = 0;
if (file_exists($nomeMapfileTmp)) {
    $oMap = ms_newMapobj($nomeMapfileTmp);
    substituiConObj($oMap, $postgis_mapa);
} else {
    if (empty($ogcwsmap)) {
        $oMap = ms_newMapobj($locaplic . "/aplicmap/ogcwsv" . $versao . ".map");
    } else {
        $oMap = ms_newMapobj($ogcwsmap);
    }
    $proto = "http" . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on" ? "s" : "") . "://";
    $server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
    $or = $proto . $server . $_SERVER['PHP_SELF'];
    $or = $or . "?tema=" . $tema . "&";
    //
    //parametros no n&iacute;vel maior
    //
    $oMap->setmetadata("ows_onlineresource", $or);
    $oMap->setmetadata("wms_onlineresource", $or);
Esempio n. 8
0
 function __construct($map_file, $tema = "", $ext = "")
 {
     include_once dirname(__FILE__) . "/funcoes_gerais.php";
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     $this->v = versao();
     $this->v = $this->v["principal"];
     $this->qyfile = str_replace(".map", "_qy.map", $map_file);
     if ($tema != "") {
         $this->qyfileTema = dirname($map_file) . "/" . $tema . "_qy.map";
     } else {
         $this->qyfileTema = "";
     }
     $this->mapa = ms_newMapObj($map_file);
     substituiConObj($this->mapa, $postgis_mapa);
     $this->arquivo = str_replace(".map", "", $map_file) . ".map";
     if ($tema != "" && @$this->mapa->getlayerbyname($tema)) {
         $this->layer = $this->mapa->getlayerbyname($tema);
     }
     $this->nome = $tema;
     $c = $this->mapa->numlayers;
     for ($i = 0; $i < $c; ++$i) {
         $l = $this->mapa->getlayer($i);
         $l->set("template", "none.htm");
     }
     if ($ext && $ext != "") {
         $e = explode(" ", $ext);
         $extatual = $this->mapa->extent;
         $extatual->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3]));
     }
     if ($this->mapa->getmetadata("interface") == "googlemaps") {
         $this->projO = $this->mapa->getProjection();
         $this->mapa->setProjection(pegaProjecaoDefault("proj4"));
     }
 }
Esempio n. 9
0
 function __construct($map_file, $tema = "", $locaplic = "", $ext = "")
 {
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     $this->qyfile = str_replace(".map", ".qy", $map_file);
     include_once dirname(__FILE__) . "/funcoes_gerais.php";
     if (empty($locaplic)) {
         $locaplic = dirname(__FILE__) . "/..";
     }
     $this->v = versao();
     $this->v = $this->v["principal"];
     $this->dbaseExiste = false;
     if (function_exists("dbase_create")) {
         $this->dbaseExiste = true;
     }
     $this->locaplic = $locaplic;
     $this->mapa = ms_newMapObj($map_file);
     substituiConObj($this->mapa, $postgis_mapa);
     $this->arquivo = str_replace(".map", "", $map_file) . ".map";
     if ($tema != "" && @$this->mapa->getlayerbyname($tema)) {
         $this->layer = $this->mapa->getlayerbyname($tema);
     }
     $this->nome = $tema;
     $this->diretorio = dirname($this->arquivo);
     if ($ext && $ext != "") {
         $e = explode(" ", $ext);
         $extatual = $this->mapa->extent;
         $extatual->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3]));
     }
 }
Esempio n. 10
0
 function __construct($map_file = "", $tema = "", $locaplic = "", $ext = "")
 {
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     if (!function_exists('ms_newMapObj')) {
         return false;
     }
     if (file_exists($locaplic . "/funcoes_gerais.php")) {
         include_once $locaplic . "/funcoes_gerais.php";
     } else {
         include_once "funcoes_gerais.php";
     }
     $this->v = versao();
     $this->v = $this->v["principal"];
     if ($map_file != "") {
         $this->locaplic = $locaplic;
         if (is_string($map_file)) {
             $this->mapa = ms_newMapObj($map_file);
             $this->arquivo = str_replace(".map", "", $map_file) . ".map";
             $this->qyfile = str_replace(".map", ".qy", $map_file);
         } else {
             $this->mapa = $map_file;
             $this->arquivo = "";
         }
         substituiConObj($this->mapa, $postgis_mapa);
         if ($tema != "" && @$this->mapa->getlayerbyname($tema)) {
             $this->layer = $this->mapa->getlayerbyname($tema);
             $this->nome = $tema;
         }
         if ($ext && $ext != "") {
             $e = explode(" ", $ext);
             $extatual = $this->mapa->extent;
             $extatual->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3]));
         }
         if ($this->mapa->getmetadata("interface") == "googlemaps") {
             $this->projO = $this->mapa->getProjection();
             $this->mapa->setProjection(pegaProjecaoDefault("proj4"));
         }
     }
 }
Esempio n. 11
0
 * Gera uma miniatura de um mapfile salvo no banco de dados
 * Verifica se a imagem existe, caso contrario cria uma no diretorio temporario
 *
 * @param restauramapa - id do mapa a ser restaurado
 * @param w
 * @param h
 */
include_once dirname(__FILE__) . "/../../ms_configura.php";
include dirname(__FILE__) . "/../blacklist.php";
verificaBlFerramentas(basename(dirname(__FILE__)), $i3geoBlFerramentas, false);
include_once dirname(__FILE__) . "/../../classesphp/funcoes_gerais.php";
if (filter_var($_GET["restauramapa"], FILTER_VALIDATE_INT) === false) {
    exit;
}
$base = restauraMapaAdmin($_GET["restauramapa"], $dir_tmp);
$nomeImagem = dirname($base) . "/" . str_replace(".map", "", "restauramapa" . $_GET["restauramapa"]) . "_miniatura.png";
//por seguranca
$nomeImagem = str_replace(".png", "", $nomeImagem);
$nomeImagem = str_replace(".", "", $nomeImagem) . ".png";
if (!file_exists($nomeImagem)) {
    $mapa = ms_newMapObj($base);
    substituiConObj($mapa, $postgis_mapa);
    $mapa->setsize($_GET["w"], $_GET["h"]);
    $sca = $mapa->scalebar;
    $sca->set("status", MS_OFF);
    $objImagemM = @$mapa->draw();
    $objImagemM->saveImage($nomeImagem);
}
ob_clean();
header('Content-Type: image/png');
readfile($nomeImagem);
Esempio n. 12
0
 function verifica($mapfile, $tema)
 {
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     $map = ms_newMapObj($mapfile);
     substituiConObj($this->mapa, $postgis_mapa);
     $map->preparequery();
     $escala = $map->scaledenom;
     $multilayer = 0;
     $temas = array();
     $layers = array();
     $nomes = array();
     $nomesvisiveis = array();
     $temasvisiveis = array();
     $numlayers = $map->numlayers;
     for ($i = 0; $i < $numlayers; ++$i) {
         $layer = $map->getlayer($i);
         $temai = $layer->name;
         $testa = 0;
         //verifica se o tema &eacute; visivel na escala
         $mins = $layer->minscaledenom;
         $maxs = $layer->maxscaledenom;
         if ($mins != $maxs) {
             $testa = 1;
             if ($mins > 0) {
                 if ($escala >= $mins) {
                     $testa = 0;
                 }
             }
             if ($maxs > 0) {
                 if ($escala <= $maxs) {
                     $testa = 0;
                 } else {
                     $testa = 1;
                 }
             }
             if ($mins > 0 && $maxs > 0) {
                 if ($escala >= $mins && $escala <= $maxs) {
                     $testa = 0;
                 } else {
                     $testa = 1;
                 }
             }
         }
         if (strtoupper($layer->getmetadata("escondido")) != "SIM") {
             if ($layer->group == $tema && $layer->type != 4) {
                 $multilayer = 1;
                 $temas[] = $temai;
                 $layers[] = $layer;
                 $pn = pegaNome($layer);
                 $nomes[] = $pn;
                 if ($testa == 0) {
                     $nomesvisiveis[] = $pn;
                     $temasvisiveis[] = $temai;
                 }
             }
         }
     }
     $this->resultado = $multilayer;
     $this->temas = $temas;
     $this->layers = $layers;
     $this->nomes = $nomes;
     $this->nomesvisiveis = $nomesvisiveis;
     $this->temasvisiveis = $temasvisiveis;
 }
Esempio n. 13
0
 function __construct($map_file = "", $tema = "", $locaplic = "", $ext = "")
 {
     if (!function_exists('ms_newMapObj')) {
         return false;
     }
     if ($locaplic == "") {
         include dirname(__FILE__) . "/../ms_configura.php";
     }
     if (!function_exists("corRGB")) {
         include_once dirname(__FILE__) . "/funcoes_gerais.php";
     }
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     $this->v = versao();
     $this->v = $this->v["principal"];
     $this->dbaseExiste = false;
     if (function_exists("dbase_create")) {
         $this->dbaseExiste = true;
     }
     $this->locaplic = $locaplic;
     if ($map_file != "") {
         $this->mapa = ms_newMapObj($map_file);
         substituiConObj($this->mapa, $postgis_mapa);
         $this->arquivo = str_replace(".map", "", $map_file) . ".map";
         $this->tema = $tema;
         if ($tema != "" && @$this->mapa->getlayerbyname($tema)) {
             $this->layer = $this->mapa->getlayerbyname($tema);
         }
         $this->nome = $tema;
         if ($ext && $ext != "") {
             $e = explode(" ", $ext);
             $extatual = $this->mapa->extent;
             $extatual->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3]));
         }
     } else {
         $this->mapa = "";
         $this->arquivo = $dir_tmp . "/" . nomeRandomico();
     }
 }
Esempio n. 14
0
    $t1 = $t1Temp;
}
if ($itemagruparel != "" && !in_array($itemagruparel, $colunas)) {
    $colunas[] = $itemagruparel;
}
$temp = explode(",", $itensrel);
$itensrel = array();
foreach ($temp as $t) {
    $t1 = explode("|", $t);
    $itensrel[] = $t1[0];
}
if ($itemagruparel != "" && !in_array($itemagruparel, $itensrel)) {
    $itensrel[] = $itemagruparel;
}
$mapa = ms_newMapObj($map_file);
substituiConObj($temp, $postgis_mapa);
if ($ext && $ext != "") {
    $e = explode(" ", $ext);
    $extatual = $mapa->extent;
    $extatual->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3]));
}
$layer = $mapa->getlayerbyname($temarel);
$layer->set("template", "none.html");
//$layer->set("data",$layer->data."options='-c client_encoding=LATIN1'");
$existesel = "nao";
/*
if (file_exists($map_file."qy"))
{$mapa->loadquery($map_file."qy");}
*/
carregaquery2($map_file, $layer, $mapa);
if ($layer->getNumresults() > 0) {
Esempio n. 15
0
 function __construct($map_file, $tema = null, $locaplic = "", $ext = "")
 {
     //error_reporting(0);
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     if ($map_file != "") {
         $map_file = str_replace(".map", "", $map_file) . ".map";
         $this->qyfile = str_replace(".map", ".qy", $map_file);
         $this->arquivo = $map_file;
     }
     if (file_exists($locaplic . "/funcoes_gerais.php")) {
         include_once $locaplic . "/funcoes_gerais.php";
     } else {
         include_once "funcoes_gerais.php";
     }
     $this->tema = $tema;
     $this->v = versao();
     $this->vi = $this->v["inteiro"];
     $this->v = $this->v["principal"];
     $this->locaplic = $locaplic;
     if ($map_file != "" && file_exists($map_file)) {
         $this->mapa = ms_newMapObj($map_file);
         substituiConObj($this->mapa, $postgis_mapa);
         $this->arquivo = $map_file;
         if ($tema != "") {
             $listaTemas = str_replace(" ", ",", $tema);
             $listaTemas = explode(",", $tema);
             foreach ($listaTemas as $tema) {
                 $this->layer = $this->mapa->getlayerbyname($tema);
                 $this->nome = $tema;
                 $vermultilayer = new vermultilayer();
                 $vermultilayer->verifica($map_file, $tema);
                 if ($vermultilayer->resultado == 1) {
                     $ls = $vermultilayer->temas;
                 } else {
                     $ls[] = $tema;
                 }
                 $this->grupo = $ls;
                 $this->visiveis = $vermultilayer->temasvisiveis;
                 foreach ($ls as $l) {
                     $t = $this->mapa->getlayerbyname($l);
                     $this->indices[] = $t->index;
                 }
             }
         }
         if ($ext && $ext != "") {
             $e = explode(" ", $ext);
             $extatual = $this->mapa->extent;
             $extatual->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3]));
         }
     }
 }
Esempio n. 16
0
 function __construct($map_file, $locaplic = "")
 {
     include dirname(__FILE__) . "/../ms_configura.php";
     $this->postgis_mapa = $postgis_mapa;
     if (!function_exists('ms_newMapObj')) {
         return false;
     }
     if (file_exists($locaplic . "/funcoes_gerais.php")) {
         include_once $locaplic . "/funcoes_gerais.php";
     } else {
         include_once "funcoes_gerais.php";
     }
     $this->v = versao();
     $this->vi = $this->v["inteiro"];
     $this->v = $this->v["principal"];
     $this->qyfile = str_replace(".map", ".qy", $map_file);
     $this->locaplic = $locaplic;
     if (!file_exists($map_file)) {
         return $this->arquivo = false;
     }
     if (!@ms_newMapObj($map_file)) {
         return $this->mapa = false;
     }
     $this->mapa = @ms_newMapObj($map_file);
     substituiConObj($this->mapa, $postgis_mapa);
     $this->arquivo = str_replace(".map", "", $map_file) . ".map";
     $c = $this->mapa->numlayers;
     for ($i = 0; $i < $c; ++$i) {
         $l = $this->mapa->getlayer($i);
         $this->layers[] = $l;
         $this->nomes[] = $l->name;
     }
 }
Esempio n. 17
0
function testaMapaImg($tema)
{
    global $locaplic, $postgis_mapa, $versao, $base, $dir_tmp, $tempo;
    $base = mapaBase($locaplic, $versao, $base);
    $mapa = ms_newMapObj($base);
    error_reporting(0);
    ms_ResetErrorList();
    try {
        ms_newMapObj($tema);
    } catch (Exception $e) {
        return array("imgMapa" => "", "imgLegenda" => "", "tempo" => microtime(true) - $tempo, "erro" => "Objeto map nao pode ser criado. Erro fatal.");
    }
    if (@ms_newMapObj($tema)) {
        $nmapa = ms_newMapObj($tema);
    } else {
        $erro = "";
        $error = ms_GetErrorObj();
        while ($error && $error->code != MS_NOERR) {
            $erro .= "<br>Error in %s: %s<br>\n";
            $erro .= "<br>" . $error->routine;
            $erro .= "<br>" . $error->message;
            $error = $error->next();
        }
        return array("imgMapa" => "", "imgLegenda" => "", "tempo" => microtime(true) - $tempo, "erro" => $erro);
    }
    substituiConObj($mapa, $postgis_mapa);
    substituiConObj($nmapa, $postgis_mapa);
    $numlayers = $nmapa->numlayers;
    $dados = "";
    $simbolos = array();
    for ($i = 0; $i < $numlayers; $i++) {
        $layern = $nmapa->getlayer($i);
        $layern->set("status", MS_DEFAULT);
        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);
        $pegarext = $layern->name;
    }
    zoomTema($pegarext, $mapa);
    $mapa->setsize(500, 500);
    $sca = $mapa->scalebar;
    $sca->set("status", MS_OFF);
    $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) {
        $error = "";
        $erro = "";
        $error = ms_GetErrorObj();
        while ($error && $error->code != MS_NOERR) {
            $erro .= "<br>Error in %s: %s<br>";
            $erro .= "<br>" . $error->routine;
            $erro .= "<br>" . $error->message;
            $error = $error->next();
        }
        return array("imgMapa" => "", "imgLegenda" => "", "tempo" => microtime(true) - $tempo, "erro" => $erro);
    }
    if ($objImagem->imagepath == "") {
        return array("imgMapa" => "", "imgLegenda" => "", "tempo" => microtime(true) - $tempo, "erro" => "Erro IMAGEPATH vazio");
    }
    $nomec = $objImagem->imagepath . nomeRandomico() . "teste.png";
    $objImagem->saveImage($nomec);
    $nomel = $objImagemLegenda->imagepath . nomeRandomico() . "testel.png";
    $objImagemLegenda->saveImage($nomel);
    $erro = "";
    $error = "";
    $error = ms_GetErrorObj();
    while ($error && $error->code != MS_NOERR) {
        $erro .= "<br>Error in %s: %s<br>";
        $erro .= "<br>" . $error->routine;
        $erro .= "<br>" . $error->message;
        $error = $error->next();
    }
    return array("imgMapa" => $objImagem->imageurl . basename($nomec), "imgLegenda" => $objImagemLegenda->imageurl . basename($nomel), "tempo" => microtime(true) - $tempo, "erro" => $erro);
}