Пример #1
0
 function converteInterfacePara($interface)
 {
     if ($interface == "openlayers") {
         $prefixo = "ol";
         $this->mapa->setProjection(pegaProjecaoDefault("proj4"));
     } else {
         $prefixo = "gm";
     }
     foreach ($this->layers as $l) {
         $opacidadeM = $l->getmetadata($prefixo . "opacity");
         $statusM = $l->getmetadata($prefixo . "status");
         if ($opacidadeM == "") {
             $l->setmetadata($prefixo . "opacity", 100);
         } else {
             $l->set("opacity", $prefixo . "opacity");
         }
         if ($statusM != "") {
             if ($statusM == "OFF") {
                 $l->set("status", MS_OFF);
             }
             if ($statusM == "DEFAULT") {
                 $l->set("status", MS_DEFAULT);
             }
         }
         if ($prefixo == "gm" && ($l->name == "mundo" || $l->name == "estados")) {
             $l->set("status", MS_OFF);
         }
         if ($l->opacity == 0) {
             $l->set("opacity", 100);
         }
     }
     $this->salva();
     return "ok";
 }
Пример #2
0
 function zoomSel()
 {
     if (!$this->layer) {
         return "erro";
     }
     if ($this->mapa->getmetadata("interface") == "googlemaps") {
         $projO = $this->mapa->getProjection();
         $projecao = pegaProjecaoDefault("epsg");
         $this->mapa->setProjection("init=epsg:" . $projecao);
     }
     $extatual = $this->mapa->extent;
     $prjMapa = $this->mapa->getProjection();
     $prjTema = $this->layer->getProjection();
     $shapes = retornaShapesSelecionados($this->layer, $this->arquivo, $this->mapa);
     $xmin = array();
     $xmax = array();
     $ymin = array();
     $ymax = array();
     foreach ($shapes as $shape) {
         $bound = $shape->bounds;
         $xmin[] = $bound->minx;
         $xmax[] = $bound->maxx;
         $ymin[] = $bound->miny;
         $ymax[] = $bound->maxy;
     }
     $ret = ms_newRectObj();
     $ret->set("minx", min($xmin));
     $ret->set("miny", min($ymin));
     $ret->set("maxx", max($xmax));
     $ret->set("maxy", max($ymax));
     if ($prjTema != "" && $prjMapa != $prjTema) {
         $projInObj = ms_newprojectionobj($prjTema);
         $projOutObj = ms_newprojectionobj($prjMapa);
         $ret->project($projInObj, $projOutObj);
     }
     $extatual->setextent($ret->minx, $ret->miny, $ret->maxx, $ret->maxy);
     if ($this->mapa->getmetadata("interface") == "googlemaps") {
         $this->mapa->setProjection($projO);
     }
     return "ok";
 }
Пример #3
0
include_once "../classesphp/funcoes_gerais.php";
$versao = versao();
$versao = $versao["principal"];
$exts = get_loaded_extensions();
echo "<h3>MapServer:</h3><pre>";
echo ms_GetVersion();
echo "</pre>";
echo "<h3>Array que armazena os par&acirc;metros da vers&atilde;o:</h3><pre>";
var_dump(versao());
echo "</pre>";
echo "<h3>Configura&ccedil;&atilde;o da proje&ccedil;&atilde;o default: (<a href='http://moodle.gvsig-training.com/mod/book/view.php?id=5090&chapterid=114'>saiba mais</a>)</h3>";
if (!isset($i3GeoProjDefault)) {
    echo '<div class="alert alert-warning" role="alert">A vari&aacute;vel de configura&ccedil;&atilde;o i3GeoProjDefault n&atilde;o existe no ms_configura.php. Ser&aacute; utilizada a proje&ccedil;&atilde;o 4326</div>';
}
echo "<pre>";
var_dump(pegaProjecaoDefault());
echo "</pre>";
if (!function_exists("ms_GetVersion")) {
    echo '<div class="alert alert-warning" role="alert">PARECE QUE O MAPSERVER NAO ESTA INSTALADO!!!</div>';
}
if (get_cfg_var("safe_mode") == 1) {
    echo '<div class="alert alert-warning" role="alert">Problema: safe_mode no php.ini deveria estar como Off. O i3Geo n&atilde;o ir&aacute; funcionar!!!</div>';
}
echo <<<HTML
\t\t<h3>Acentua&ccedil;&atilde;o</h3>
\t\t<pre>
As seguintes letras devem aparecer corretamente acentuadas:
<b>çÇãâáÁóÓ</b>
Caso contr&aacute;rio, verifique os par&acirc;metros de configura&ccedil;&atilde;o do Apache
<b>AddDefaultCharset (httpd.conf) e default_charset (php.ini)</b>
(default_charset='' no php.ini geralmente funciona)
Пример #4
0
    }
} else {
    //algumas aplicacoes usam essa variavel (SAIKU)
    $mapext = $ext->minx . " " . $ext->miny . " " . $ext->maxx . " " . $ext->maxy;
}
/*
Configura os endere&ccedil;os corretos no mapfile.

Altera as propriedades imagepath e imageurl corrigindo os caminhos padr&atilde;o conforme o diret&oacute;rio criado para armazenar o mapa de trabalho.
*/
$w = $mapn->web;
$atual = $w->imagepath;
$w->set("imagepath", $atual . $diretorios[2] . "/");
$atual = $w->imageurl;
$w->set("imageurl", $atual . $diretorios[2] . "/");
$projecao = pegaProjecaoDefault("proj4");
if ($projecao != "") {
    $mapn->setProjection($projecao);
}
$tmpfname = str_replace(".map", "", $tmpfname) . ".map";
$salvo = $mapn->save($tmpfname);
$_SESSION["imgurl"] = strtolower($protocolo[0]) . "://" . $_SERVER['HTTP_HOST'] . $atual . $diretorios[2] . "/";
$_SESSION["tmpurl"] = strtolower($protocolo[0]) . "://" . $_SERVER['HTTP_HOST'] . $atual;
$_SESSION["map_file"] = $tmpfname;
$_SESSION["mapext"] = $mapext;
if (isset($executa)) {
    if (file_exists($executa)) {
        //include_once ($executa);
    }
    if (function_exists($executa)) {
        //eval($executa."();");
Пример #5
0
    return;
}
include dirname(__FILE__) . "/../../classesphp/funcoes_gerais.php";
$map_file = $_SESSION["map_file"];
if (empty($map_file)) {
    exit;
}
$map_file = str_replace(".map", "", $map_file) . ".map";
restauraCon($map_file, $_SESSION["postgis_mapa"]);
$base = basename($map_file);
$dir = dirname($map_file);
$novo_mapfile = $dir . "/" . nomeRandomico(5) . $base;
copy($map_file, $novo_mapfile);
chmod($novo_mapfile, 0744);
$mapa = ms_newMapObj($novo_mapfile);
$mapa->setProjection(pegaProjecaoDefault("proj4"));
$numlayers = $mapa->numlayers;
$layers = array();
for ($i = 0; $i < $numlayers; ++$i) {
    $l = $mapa->getLayer($i);
    $l->setmetadata("permiteogc", "sim");
    if ($l->status != MS_DEFAULT) {
        $l->set("status", MS_DELETE);
    } else {
        $layers[] = $l->name;
    }
}
//$legenda = $mapa->legend;
//$legenda->set("status",MS_EMBED);
$mapa->save($novo_mapfile);
$layers = implode(",", $layers);
Пример #6
0
<?php

return;
include_once dirname(__FILE__) . "/../../classesphp/pega_variaveis.php";
include_once dirname(__FILE__) . "/../../classesphp/funcoes_gerais.php";
$projecao = pegaProjecaoDefault("epsg");
if (!isset($palavra)) {
    echo "Par&acirc;metro &palavra= n&atilde;o foi definido. 'palavra' &eacute; a palavra que ser&aacute; buscada";
}
if (!isset($locaplic)) {
    echo "<br>Par&acirc;metro &locaplic= n&atilde;o foi definido. 'locaplic' indica onde o i3geo est&aacute; instalado";
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
			<link rel="stylesheet" type="text/css" href="../../css/ferramentas.css"></link>
			<link rel="stylesheet" type="text/css" href="../../css/botoes2.css"></link>
		<title></title>
	</head>
	<body class="yui-skin-sam;" style="overflow:auto;">
<div style="top:5px;left:1px;display:block;width:90%;"  id="resultado" >Aguarde...</div>
	<script src="../../classesjs/i3geo.js" type="text/javascript"></script>
		<script type="text/javascript" src="index.js"></script>

<script type="text/javascript">
i3GEObuscaRapida.idresultado

var mapaLugar = function(wkt,layer,gid,nm)
{
	var ext = i3GEO.util.wkt2ext(wkt,"polygon");
	var url = "<?php 
Пример #7
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");
}
Пример #8
0
/**
Esse programa e uma adaptacao do codigo i3geo/ogc.php
E utilizado no mashup (i3geo/mashup) nas camadas que sao configuradas cm o plugin parametrossql
Ao adicionar uma camada ao mapa, o i3Geo identifica se a camada usa o plugin e nesse caso, ao inves de usar
o gerador de webservice i3geo/ogc.php ustiliza esse aqui.
A diferenca e que esse servico processa o parametro "plugin", aplicando os filtros definidos
no plugin parametrossql
*/
$cache = true;
include dirname(__FILE__) . "/../../classesphp/sani_request.php";
include_once dirname(__FILE__) . "/../../classesphp/carrega_ext.php";
include dirname(__FILE__) . "/../../ms_configura.php";
include dirname(__FILE__) . "/../../classesphp/funcoes_gerais.php";
$_GET = array_merge($_GET, $_POST);
$plugin = $_GET["plugin"];
$projDefault = pegaProjecaoDefault();
$tema = basename($_GET["tema"]);
if ($tema == "") {
    exit;
}
if (isset($_GET["sld"]) || isset($_GET["filter"])) {
    $cache = false;
}
if (isset($_GET["DESLIGACACHE"]) && $_GET["DESLIGACACHE"] == "sim") {
    $cache = false;
}
//
//pega os endere&ccedil;os para compor a url de chamada do gerador de web services
//ogc.php
//
$protocolo = explode("/", $_SERVER['SERVER_PROTOCOL']);
Пример #9
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"));
     }
 }
Пример #10
0
 function insereSHP($xy, $projecao, $item = "", $valor = "")
 {
     if (!$this->layer) {
         return "erro";
     }
     if ($this->dbaseExiste == false) {
         include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php";
     }
     $xy = explode(" ", $xy);
     $data = $this->layer->data;
     $data = explode(".shp", $data);
     $data = $data[0];
     $items = pegaItens($this->layer);
     $dbname = $data . ".dbf";
     if ($this->dbaseExiste == false) {
         $db = xbase_open($dbname, 2);
     } else {
         $db = dbase_open($dbname, 2);
     }
     for ($i = 0; $i < count($xy) / 2; ++$i) {
         $reg = array();
         foreach ($items as $ni) {
             //verifica se deve acrescentar o valor para um item, caso tenha sido definido
             if ($ni == $item) {
                 $reg[] = $valor;
             } else {
                 $reg[] = "-";
             }
         }
         if ($this->dbaseExiste == false) {
             xbase_add_record($db, $reg);
         } else {
             dbase_add_record($db, $reg);
         }
     }
     if ($this->dbaseExiste == false) {
         xbase_close($db);
     } else {
         dbase_close($db);
     }
     if (@($shapefileObj = ms_newShapefileObj($data, -2))) {
         for ($i = 0; $i < count($xy); $i = $i + 2) {
             $poPoint = ms_newpointobj();
             $poPoint->setXY($xy[$i], $xy[$i + 1]);
             if ($projecao != "") {
                 //$projOutObj = ms_newprojectionobj("proj=longlat,ellps=WGS84,datum=WGS84,no_defs");
                 $pmap = pegaProjecaoDefault("proj4");
                 $projOutObj = ms_newprojectionobj($pmap);
                 $projInObj = ms_newprojectionobj("init=epsg:" . $projecao);
                 $poPoint->project($projInObj, $projOutObj);
             }
             $shapefileObj->addpoint($poPoint);
         }
         return "ok";
     } else {
         return "erro";
     }
 }
Пример #11
0
        }
        if ($shp->type == MS_SHAPE_POLYGON) {
            $tipo = "POLYGON";
        }
        $m->insereFeature($_GET["marca"], $_GET["tipo"], $_GET["xy"], $_GET["texto"], $_GET["position"], $_GET["partials"], $_GET["offsetx"], $_GET["offsety"], $_GET["minfeaturesize"], $_GET["mindistance"], $_GET["force"], $_GET["shadowcolor"], $_GET["shadowsizex"], $_GET["shadowsizey"], $_GET["outlinecolor"], $_GET["cor"], $_GET["sombray"], $_GET["sombrax"], $_GET["sombra"], $_GET["fundo"], $_GET["angulo"], $_GET["tamanho"], $_GET["fonte"], $_GET["wrap"], true, $_GET["nometema"]);
        $m->salva();
        redesenhaMapa();
        break;
    case "SHAPEFILE":
        include_once "../../classesphp/classe_analise.php";
        $m = new Analise($map_file, "");
        $nomeLayer = $m->aplicaFuncaoListaWKT(array($_GET["xy"]), "converteSHP", $dir_tmp, $imgdir);
        $l = $m->mapa->getlayerbyname($nomeLayer);
        $l->setmetadata("tema", $_GET["nometema"]);
        //verifica projecao
        $shp = ms_shapeObjFromWkt($_GET["xy"]);
        $c = $shp->getCentroid();
        $c = $c->x;
        if ($c > -181 && $c < 181) {
            $l->setprojection(pegaProjecaoDefault("proj4"));
        } else {
            $l->setprojection($m->mapa->getProjection());
        }
        $m->salva();
        redesenhaMapa();
        break;
}
if (isset($map_file) && isset($postgis_mapa) && $map_file != "") {
    restauraCon($map_file, $postgis_mapa);
}
cpjson($retorno);
Пример #12
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"));
         }
     }
 }