function markerclusterMapfile() { global $dir, $map_file, $layer, $base, $locaplic, $dir_tmp, $postgis_mapa; if (empty($map_file) && file_exists($dir . "/../../temas/{$layer}.map")) { $versao = versao(); $versao = $versao["principal"]; if (!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"; } } } $map_file = $dir_tmp . "/" . nomeRandomico() . ".map"; $mapa = ms_newMapObj($base); $tempMapa = ms_newMapObj($dir . "/../../temas/{$layer}.map"); $layern = $tempMapa->getlayer(0); restauraConObj($mapa, $postgis_mapa); ms_newLayerObj($mapa, $layern); $mapa->save($map_file); } return $map_file; }
function gml2wkt($gml) { // Parse GML file include "funcoes_gerais.php"; $k = array_keys($_GET); session_name("i3GeoPHP"); session_id($_GET[$k[0]]); session_start(); //var_dump($_SESSION);exit; $nome = $_SESSION["dir_tmp"] . "/gml_" . nomeRandomico(); $nomegml = $nome . ".gml"; $nomemap = $_SESSION["map_file"]; $gml = str_replace("xsi:schemaLocation", "erro", $gml); gravaDados(array($gml), $nomegml); $map = new mapObj($nomemap); $layer = ms_newLayerObj($map); $layer->setConnectionType(MS_OGR); $layer->set("connection", $nomegml); $layer->set("template", "none.html"); $layer->set("type", MS_LAYER_POLYGON); $layer->set("name", $nome); $layer->set("status", MS_DEFAULT); $layer->setmetadata("tema", $nome); $classe = ms_newClassObj($layer); $novoestilo = ms_newStyleObj($classe); $ncor = $novoestilo->color; $ncor->setrgb(255, 255, 255); //$map->save($nomemap); //exit; $layer->queryByrect($map->extent); $sopen = $layer->open(); $shape = $layer->getShape($layer->getResult(0)); $wkt = $shape->towkt(); return json_encode(array($wkt)); }
function __construct($map_file, $nomeImagem = "", $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->locaplic = $locaplic; $this->mapa = ms_newMapObj($map_file); substituiConObj($this->mapa, $postgis_mapa); $this->arquivo = str_replace(".map", "", $map_file) . ".map"; if ($nomeImagem == "") { $this->nomeImagem = nomeRandomico(); } }
if ($_FILES['i3GEOuploadcsv']['name'] == "") { echo "Arquivo não definido"; exit; } if (isset($_FILES['i3GEOuploadcsv']['name'])) { echo "<p class='paragrafo' >Carregando o arquivo...</p>"; ob_flush(); flush(); sleep(1); $arqcsv = $_FILES['i3GEOuploadcsv']['tmp_name']; $nomePrefixo = str_replace(" ", "_", removeAcentos($_FILES['i3GEOuploadcsv']['name'])); $nomePrefixo = str_replace(".", "", $nomePrefixo); $nomePrefixo = strip_tags($nomePrefixo); $nomePrefixo = htmlspecialchars($nomePrefixo, ENT_QUOTES); $nomePrefixo = $nomePrefixo . md5(uniqid(rand(), true)); $nomePrefixo = $nomePrefixo . "_" . nomeRandomico(4) . ".csv"; $Arquivo = $_FILES['i3GEOuploadcsv']['tmp_name']; $status = move_uploaded_file($Arquivo, $dir_tmp . "/" . $nomePrefixo); if ($status != 1) { echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo"; exit; } if (!file_exists($dir_tmp . "/" . $nomePrefixo)) { echo "<p class='paragrafo' >Ocorreu algum problema no envio do arquivo " . $dir_tmp . "/" . $nomePrefixo; paraAguarde(); exit; } $arqcsv = $dir_tmp . "/" . $nomePrefixo; $checkphp = fileContemString($dirmap . "/" . $nomePrefixo, "<?"); if ($checkphp == true) { unlink($dirmap . "/" . $nomePrefixo);
function graficotema($lista, $tamanho = "50", $tipo = "PIE", $outlinecolor = "", $offset = 0, $mesmoTema = false) { if (!$this->layer) { return "erro"; } $nome = pegaNome($this->layer); $novolayer = ms_newLayerObj($this->mapa, $this->layer); $nomer = nomeRandomico(); $novolayer->set("name", $nomer); $novolayer->set("group", ""); $novolayer->setmetadata("cache", "nao"); $novolayer->set("type", MS_LAYER_CHART); $novolayer->setprocessing("CHART_TYPE={$tipo}"); $novolayer->setprocessing("CHART_SIZE={$tamanho}"); $nclasses = $novolayer->numclasses; for ($i = 0; $i < $nclasses; ++$i) { $c = $novolayer->getclass($i); $c->set("status", MS_DELETE); } $novolayer->set("status", MS_DEFAULT); $novolayer->setmetadata("tema", "grafico de " . $nome); $lista = explode("*", $lista); foreach ($lista as $l) { $ll = explode(",", $l); $novac = ms_newClassObj($novolayer); $novac->set("name", $ll[0]); $novoestilo = ms_newStyleObj($novac); $novoestilo->setBinding(MS_STYLE_BINDING_SIZE, $ll[0]); $cor = $novoestilo->color; $cor->setrgb($ll[1], $ll[2], $ll[3]); if ($outlinecolor != "") { $o = explode(",", $outlinecolor); $corl = $novoestilo->outlinecolor; $corl->setrgb($o[0], $o[1], $o[2]); } if ($tipo == "PIE") { $novoestilo->set("offsetx", $offset); } } if ($mesmoTema == true) { $this->layer->set("status", MS_DELETE); $novolayer->set("name", $this->layer->name); $novolayer->setmetadata("tema", $this->layer->getmetadata("tema")); } }
$fingerprint = $_SESSION["fingerprint"]; $f = explode(",", $fingerprint); if ($f[0] != md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id())) { echo "erro"; 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; } }
<?php include_once dirname(__FILE__) . "/../safe.php"; verificaBlFerramentas(basename(dirname(__FILE__)), $i3geoBlFerramentas, false); // //faz a busca da função que deve ser executada // $retorno = ""; //string que será retornada ao browser via JSON switch (strtoupper($funcao)) { /* Valor: TELAREMOTA Registra um ID para permitir o acesso ao mapa atual por outro navegador. O ID é adicionado à string $_SESSION["fingerprint"] separado por ',' <Mapa->telaRemota> */ case "TELAREMOTA": $codigo = nomeRandomico(); $_SESSION["fingerprint"] .= "," . $codigo; $retorno = $codigo; break; } if (isset($map_file) && isset($postgis_mapa) && $map_file != "") { restauraCon($map_file, $postgis_mapa); } cpjson($retorno);
function criaToponimia($item, $position, $partials, $offsetx, $offsety, $minfeaturesize, $mindistance, $force, $shadowcolor, $shadowsizex, $shadowsizey, $outlinecolor, $cor, $sombray, $sombrax, $sombra, $fundo, $angulo, $tamanho, $fonte, $tipo, $wrap, $novotema = "sim") { error_reporting(0); if (!$this->layer) { return "erro"; } $this->removeToponimia(); if (!isset($tipo)) { $tipo = ""; } if ($item != "") { if ($novotema == "sim") { $nome = pegaNome($this->layer); $novolayer = ms_newLayerObj($this->mapa, $this->layer); $nomer = nomeRandomico(); $novolayer->set("name", $nomer); $novolayer->set("group", ""); $novolayer->set("type", $this->layer->type); $nclasses = $novolayer->numclasses; for ($i = 0; $i < $nclasses; ++$i) { $c = $novolayer->getclass($i); $c->set("status", MS_DELETE); } $novac = ms_newClassObj($novolayer); $novolayer->set("status", MS_DEFAULT); $novolayer->setmetadata("tema", "texto de " . $nome); $novolayer->setmetadata("tip", ""); $novolayer->setmetadata("tiles", "nao"); $novolayer->setmetadata("identifica", "nao"); $novolayer->set("labelitem", $item); } else { $nomer = $this->layer->name; $novolayer = $this->mapa->getlayerbyname($nomer); } $novolayer->setmetadata("cache", ""); $this->layer = $novolayer; } else { //$novac = $this->layer->getclass(0); $nomer = $this->layer->name; } if (!($this->vi >= 60200)) { $this->layer->set("labelitem", $item); } $nclasses = $this->layer->numclasses; for ($i = 0; $i < $nclasses; ++$i) { $novac = $this->layer->getclass($i); if ($this->vi >= 60200) { //$indiceLabel = $novac->addLabel(new labelObj()); $s = "CLASS LABEL TEXT '[" . $item . "]' END END"; $novac->updateFromString($s); $label = $novac->getLabel($indiceLabel); } else { $label = $novac->label; } if ($wrap != "") { $label->set("maxlength", 1); $s = $novac->getTextString; $s = "CLASS LABEL WRAP '{$wrap}' END END"; $novac->updateFromString($s); } if ($this->vi >= 60200) { $label = $novac->getLabel($indiceLabel); } else { $label = $novac->label; } if ($fonte != "bitmap") { //$label->set("type",MS_TRUETYPE); $label->updatefromstring("LABEL TYPE TRUETYPE END"); $label->set("font", $fonte); $label->set("size", $tamanho); } else { //$label->set("type",MS_BITMAP); $label->updatefromstring("LABEL TYPE BITMAP END"); //$label->set("font",$fonte); $t = MS_TINY; if ($tamanho > 5) { $t = MS_TINY; } if ($tamanho >= 7) { $t = MS_SMALL; } if ($tamanho >= 10) { $t = MS_MEDIUM; } if ($tamanho >= 12) { $t = MS_LARGE; } if ($tamanho >= 14) { $t = MS_GIANT; } $label->set("size", $t); } if ($angulo > 0) { $label->set("angle", $angulo); } if ($angulo == "AUTO") { $label->updatefromstring("LABEL ANGLE AUTO END"); } if (strtoupper($angulo) == "CURVO" || strtoupper($angulo) == "FOLLOW") { $label->updatefromstring("LABEL ANGLE FOLLOW END"); } corE($label, $cor, "color"); corE($label, $fundo, "backgroundcolor"); corE($label, $sombra, "backgroundshadowcolor", $sombrax, $sombray); //$label->set("backgroundshadowsizex",$sombrax); //$label->set("backgroundshadowsizey",$sombray); corE($label, $outlinecolor, "outlinecolor"); corE($label, $shadowcolor, "shadowcolor"); $label->set("shadowsizex", $shadowsizex); $label->set("shadowsizey", $shadowsizey); $label->set("force", $force); $label->set("mindistance", $mindistance); $label->set("minfeaturesize", $minfeaturesize); $label->set("offsetx", $offsetx); $label->set("offsety", $offsety); $label->set("partials", $partials); $p = array("MS_AUTO" => MS_AUTO, "MS_UL" => MS_UL, "MS_LR" => MS_LR, "MS_UR" => MS_UR, "MS_LL" => MS_LL, "MS_CR" => MS_CR, "MS_CL" => MS_CL, "MS_UC" => MS_UC, "MS_LC" => MS_LC, "MS_CC" => MS_CC); $label->set("position", $p[$position]); } if ($tipo == "teste") { $i = gravaImagemMapa($this->mapa); return $i["url"]; } else { return $nomer; } }
$arquivo = $dirmap . "/" . $_FILES['i3GEOimportarwmc']['name']; } if ($_POST["i3GEOimportarwmcurl"]) { $s = PHP_SHLIB_SUFFIX; if (!function_exists('curl_init')) { @dl('php_curl' . '.' . $s); } if (!function_exists('curl_init')) { echo "curl não instalado"; } else { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $_POST["i3GEOimportarwmcurl"]); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($curl); curl_close($curl); $arquivo = $dirmap . "/" . nomeRandomico(); gravaDados(array($result), $arquivo); } } if ($arquivo != "") { incluiWMC(); } paraAguarde(); function incluiWMC() { global $map_file, $arquivo; $mapa = ms_newMapObj($map_file); $proj = $mapa->getprojection(); $mapa->loadMapContext($arquivo, "MS_TRUE"); $layers = $mapa->getalllayernames(); foreach ($layers as $nome) {
function criarNovoLayer() { global $locaplic, $codigoMap; include_once "{$locaplic}/classesphp/funcoes_gerais.php"; $mapfile = $locaplic . "/temas/" . $codigoMap . ".map"; $mapa = ms_newMapObj($mapfile); $nl = ms_newLayerObj($mapa); $nl->set("name", nomeRandomico()); $nl->set("type", MS_LAYER_LINE); $mapa->save($mapfile); removeCabecalho($mapfile); return array("layers" => array($nl->name)); }
if ($layer->type == 2) { $objLine = $shapes[0]->line(0); $pontoA = $objLine->point(0); $pontoB = $shapes[0]->getCentroid(); } $retorno = array("ax" => $pontoA->x, "ay" => $pontoA->y, "bx" => $pontoB->x, "by" => $pontoB->y); break; case "MELHORCAMINHO": //converte os parametros em um arquivo YAML $mapa = ms_newMapObj($map_file); $layer = $mapa->getlayerbyname($_GET["raster"]); $cost_surface_path = $layer->data; $prefixo = nomeRandomico(3); //verifica se o mapa de custo existe if (file_exists($cost_surface_path)) { $pathresult = $dir_tmp . "/melhorcaminho_" . nomeRandomico(); //cria a pasta onde os resultados serao armazenados mkdir($pathresult, 0744); $pta = $_GET["pta"]; $ptb = $_GET["ptb"]; //parametros para o calculo de melhor caminho e linha reta $best = array("p1" => array("calculation_type" => "best_path", "file_prefix" => $prefixo, "start_coord" => "[{$pta}]", "stop_coord" => "[{$ptb}]")); $cart = array("p2" => array("calculation_type" => "cartesian_straight_line_cost", "file_prefix" => $prefixo, "start_coord" => "[{$pta}]", "stop_coord" => "[{$ptb}]")); //guarda os processos que serao executados $processos = array($best, $cart); //parametros para calculo do buffer if ($buffer > 0) { $buf = array("p3" => array("calculation_type" => "best_path_within_buffer", "buffer_km" => $_GET["buffer"], "file_prefix" => $prefixo, "start_coord" => "[{$pta}]", "stop_coord" => "[{$ptb}]")); $processos[] = $buf; } //parametros para calculo com reclassificacao
/** * Altera a representacao de um layer mostrando circulos cujo tamanho corresponde a um valor * @param nome do arquivo mapfile em uso * @param nome do layer que sera processado * @param variatamanho|variacor|continuo tipo de processo */ function classes2circulos($map_file, $tema, $tipo) { $nome = basename($map_file) . $tema . $tipo; $mapa = ms_newMapObj($map_file); $teste = $mapa->getlayerbyname($nome); if ($teste != "") { return ""; } $l = $mapa->getlayerbyname($tema); if ($l->getmetadata("METAESTAT_DERIVADO") == "sim") { return ""; } $layer = ms_newLayerObj($mapa, $l); $l->set("status", MS_OFF); $layer->set("status", MS_DEFAULT); $layer->set("opacity", 50); $layer->set("name", $nome); $meta = new Metaestat(); if ($layer->type != MS_LAYER_POINT) { $layer->set("type", 0); $regiao = $meta->listaTipoRegiao($layer->getmetadata("METAESTAT_CODIGO_TIPO_REGIAO")); //repare que existe uma virgula apos o nome da coluna com a geometria, isso e necessario para substituir a string correta if ($regiao["colunacentroide"] != "") { $stringgeo = "g." . $regiao["colunageo"] . ","; $data = str_replace($stringgeo, "g." . $regiao["colunacentroide"] . ",", $layer->data); } else { $stringgeo = 'st_setsrid(g.".' . $regiao["colunageo"] . '.",".' . $regiao["srid"] . '.")'; $data = str_replace($stringgeo, "st_centroid({$stringgeo})", $layer->data); } $layer->set("data", $data); } $numclasses = $layer->numclasses; if ($tipo == "variatamanho" || $tipo == "variacor") { if ($tipo == "variatamanho") { $layer->setmetadata("tema", $layer->getmetadata("tema") . " - circ"); } if ($tipo == "variacor") { $layer->setmetadata("tema", $layer->getmetadata("tema") . " - ponto"); } if ($numclasses > 0) { for ($i = 0; $i < $numclasses; ++$i) { $classe = $layer->getClass($i); $estilo = $classe->getstyle(0); $estilo->set("symbolname", "ponto"); if ($tipo == "variatamanho") { $estilo->set("size", $i * 6); } if ($tipo == "variacor") { $estilo->set("size", 12); } } } } if ($tipo == "continuo") { $nometemp = str_replace(basename($map_file), nomeRandomico(5) . basename($map_file), $map_file); $mapa->save($nometemp); //$mapatemp = ms_newMapObj($nometemp); $medidavariavel = $meta->listaMedidaVariavel("", $layer->getmetadata("METAESTAT_ID_MEDIDA_VARIAVEL")); include_once dirname(__FILE__) . "/../../classesphp/classe_alteraclasse.php"; $m = new Alteraclasse($nometemp, $layer->name, "", ""); $valores = $m->pegaValores($m->mapa, $m->layer, $medidavariavel["colunavalor"], true, 0); $min = min($valores); $max = max($valores); $layer->setmetadata("tema", $layer->getmetadata("tema") . " - cont"); $layer->set("type", MS_LAYER_CHART); $layer->set("opacity", 60); $layer->setprocessing("CHART_TYPE=pie"); $layer->setprocessing("CHART_SIZE_RANGE=" . $medidavariavel["colunavalor"] . " 10 150 " . $min . " " . $max); if ($numclasses > 0) { for ($i = 0; $i < $numclasses; ++$i) { $classe = $layer->getClass($i); $classe->set("status", MS_DELETE); } } $classe = ms_newClassObj($layer); $novoestilo = ms_newStyleObj($classe); //$novoestilo->set("symbolname","ponto"); $novoestilo->set("size", "6"); $ncor = $novoestilo->color; $ncor->setrgb(247, 145, 29); $ncor = $novoestilo->outlinecolor; $ncor->setrgb(255, 255, 255); //$novoestilo->setbinding(MS_STYLE_BINDING_SIZE, $medidavariavel["colunavalor"]); // $classe = ms_newClassObj($layer); $novoestilo = ms_newStyleObj($classe); //$novoestilo->set("symbolname","ponto"); $novoestilo->set("size", "6"); $ncor = $novoestilo->color; $ncor->setrgb(247, 145, 29); $ncor = $novoestilo->outlinecolor; $ncor->setrgb(255, 255, 255); } $layer->setmetadata("METAESTAT_DERIVADO", "sim"); $mapa->save($map_file); return $nome; }
function shpPT2shp($locaplic, $para) { if (!$this->layer) { return "erro"; } $this->layer->set("template", "none.htm"); $diretorio = dirname($this->arquivo); $tipol = MS_SHP_ARC; $tipos = MS_SHAPE_LINE; if ($para == "poligono") { $tipol = MS_SHP_POLYGON; $tipos = MS_SHAPE_POLYGON; } $novonomelayer = nomeRandomico(); $nomeshp = $diretorio . "/" . $novonomelayer; $items = pegaItens($this->layer); // cria o dbf $def = array(); foreach ($items as $ni) { $temp = strtoupper($ni); $def[] = array($temp, "C", "254"); } //para manipular dbf if ($this->dbaseExiste == false) { include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php"; $db = xbase_create($nomeshp . ".dbf", $def); } else { $db = dbase_create($nomeshp . ".dbf", $def); } $dbname = $nomeshp . ".dbf"; $reg = array(); $novoshpf = ms_newShapefileObj($nomeshp . ".shp", $tipol); $this->layer->open(); $prjMapa = $this->mapa->getProjection(); $prjTema = $this->layer->getProjection(); $ret = $this->mapa->extent; if ($prjTema != "" && $prjMapa != $prjTema) { $projOutObj = ms_newprojectionobj($prjTema); $projInObj = ms_newprojectionobj($prjMapa); $ret->project($projInObj, $projOutObj); } $this->layer->whichShapes($ret); $linha = ms_newLineObj(); $pponto = ""; $pontos = array(); while ($shape = $this->layer->nextShape()) { $lin = $shape->line(0); $pt = $lin->point(0); if ($pponto == "") { $pponto = $pt; } if ($prjTema != "" && $prjMapa != $prjTema) { $pt->project($projInObj, $projOutObj); } $pontos[] = $pt->x; $pontos[] = $pt->y; } $pontos = implode(" ", $pontos); $pontos = xy2wkt($pontos); if ($para == "poligono") { $shape = ms_shapeObjFromWkt($pontos["poligono"]); } else { $shape = ms_shapeObjFromWkt($pontos["linha"]); } foreach ($items as $ni) { $reg[] = "-"; } $novoshpf->addShape($shape); if ($this->dbaseExiste == false) { xbase_add_record($db, $reg); xbase_close($db); } else { dbase_add_record($db, $reg); dbase_close($db); } $this->layer->close(); //cria o novo layer $layer = criaLayer($this->mapa, MS_LAYER_LINE, MS_DEFAULT, "", $metaClasse = "SIM"); $layer->set("data", $nomeshp); $layer->setmetadata("tema", $novonomelayer . " (linear)"); $layer->setmetadata("download", "sim"); $layer->setmetadata("temalocal", "sim"); $classe = $layer->getclass(0); $estilo = $classe->getstyle(0); $estilo->set("symbolname", "linha"); if ($para == "poligono") { $layer->set("type", MS_LAYER_POLYGON); $layer->set("opacity", "50"); $layer->setmetadata("tema", $novonomelayer . " (poligonal)"); } return "ok"; }
} $ArquivoDest = strip_tags($ArquivoDest); $ArquivoDest = htmlspecialchars($ArquivoDest, ENT_QUOTES); verificaNome($ArquivoDest); verificaNome($_FILES['i3GEOuploaddbffile']['name']); //sobe arquivo $Arquivo = $_FILES['i3GEOuploaddbffile']['tmp_name']; $status = move_uploaded_file($Arquivo, $dirmap . "/" . $ArquivoDest); if ($status != 1) { echo "Ocorreu um erro no envio do arquivo"; paraAguarde(); exit; } $nome = explode(".", $ArquivoDest); $nome = $nome[0]; $nome = $nome . "_" . nomeRandomico(4); $nomeshp = $dirmap . "/" . $nome . ".shp"; if ($status == 1) { if (!isset($tema)) { $nomex = strtoupper($i3GEOuploaddbfnomex); $nomey = strtoupper($i3GEOuploaddbfnomey); //converte de csv para dbf if ($i3GEOuploaddbftipoarquivo != "dbf") { if ($i3GEOuploaddbftipoarquivo == "csvpv") { $separador = ";"; } if ($i3GEOuploaddbftipoarquivo == "csvv") { $separador = ","; } include_once dirname(__FILE__) . "/../../pacotes/phpxbase/api_conversion.php"; include_once dirname(__FILE__) . "/../../pacotes/parsecsv/parsecsv.lib.php";
function gravaImagemCorpo() { $imgo = $this->mapa->draw(); $nome = $imgo->imagepath . nomeRandomico() . ".png"; $salva = $imgo->saveImage($nome); if ($salva != -1) { return $imgo->imageurl . basename($nome); } else { return "erro"; } }
} $retorno = retornaReferencia($ext); break; /* Valor: REFERENCIADINAMICA Gera a imagem do mapa de referência de forma dinâmica, variando com a escala do mapa atual. */ /* Valor: REFERENCIADINAMICA Gera a imagem do mapa de referência de forma dinâmica, variando com a escala do mapa atual. */ case "REFERENCIADINAMICA": //$objMapa = ms_newMapObj($map_file); $nomeImagem = nomeRandomico(); $ext = $_pg["ext"]; if (!isset($ext)) { $ext = ""; } $retorno = retornaReferenciaDinamica($ext, $_pg["w"], $_pg["h"]); break; /* Valor: MUDAOUTPUTFORMAT Muda o OUTPUTFORMAT. <Mapa->mudaoutputformat> */ /* Valor: MUDAOUTPUTFORMAT
function graficopizza($data, $width, $inclinacao, $shadow_height, $cores, $map_file, $temaedit) { //////////////////////////////////////////////////////////////// // PHP script made by Rasmus Petersen - http://www.peters1.dk // //////////////////////////////////////////////////////////////// include_once "funcoes_gerais.php"; //<img src="http://www.domain.dk/piechart.php?data=10*9*11*10&label=Denmark*Germany*USA*Sweden" /> $show_label = false; // true = show label, false = don't show label. $show_percent = false; // true = show percentage, false = don't show percentage. $show_text = true; // true = show text, false = don't show text. $show_parts = false; // true = show parts, false = don't show parts. $label_form = 'square'; // 'square' or 'round' label. if (!isset($width)) { $width = 50; } if (!isset($inclinacao)) { $inclinacao = 1.5; } if (!isset($shadow_height)) { $shadow_height = 10; } $background_color = 'FFFFFF'; // background-color of the chart... $text_color = '000000'; // text-color. $colors = array('003366', 'CCD6E0', '7F99B2', 'F7EFC6', 'C6BE8C', 'CC6600', '990000', '520000', 'BFBFC1', '808080'); // colors of the slices. $colorsp = explode("*", $cores); //cores das fatias //$shadow_height = 16; // Height on shadown. $shadow_dark = true; // true = darker shadow, false = lighter shadow... // DON'T CHANGE ANYTHING BELOW THIS LINE... $height = $width / $inclinacao; $data = explode('*', $data); $img = ImageCreateTrueColor($width, $height + ceil($shadow_height)); imagetruecolortopalette($img, false, 256); // convert $white = imagecolorresolve($img, 255, 255, 255); // resolve given palette entry imagecolortransparent($img, $white); ImageFill($img, 0, 0, $white); foreach ($colorsp as $colorkode) { $fill_color[] = colorRGB($img, $colorkode); $shadow_color[] = colorRGBshadow($img, $colorkode, $shadow_dark); } $centerX = round($width / 2); $centerY = round($height / 2); $diameterX = $width - 4; $diameterY = $height - 4; $data_sum = array_sum($data); $start = 270; $value_counter = 0; $value = 0; $cd = count($data); for ($i = 0; $i < $cd; ++$i) { $value += $data[$i]; $end = ceil($value / $data_sum * 360) + 270; $slice[] = array($start, $end, $shadow_color[$value_counter % count($shadow_color)], $fill_color[$value_counter % count($fill_color)]); $start = $end; $value_counter++; } for ($i = $centerY + $shadow_height; $i > $centerY; $i--) { for ($j = 0; $j < count($slice); ++$j) { ImageFilledArc($img, $centerX, $i, $diameterX, $diameterY, $slice[$j][0], $slice[$j][1], $slice[$j][2], IMG_ARC_PIE); } } for ($j = 0; $j < count($slice); ++$j) { ImageFilledArc($img, $centerX, $centerY, $diameterX, $diameterY, $slice[$j][0], $slice[$j][1], $slice[$j][3], IMG_ARC_PIE); } $nome = nomeRandomico(20) . ".png"; $nomefisico = dirname($map_file) . "/" . $nome; $nomeurl = $nome; Imagepng($img, $nomefisico); ImageDestroy($img); return $nomefisico . "," . $nomeurl; }
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); }
function restauraMapaAdmin($id_mapa, $dir_tmp) { if (filter_var($id_mapa, FILTER_VALIDATE_INT) === false) { exit; } include dirname(__FILE__) . "/../admin/php/conexao.php"; if (!empty($esquemaadmin)) { $esquemaadmin = str_replace(".", "", $esquemaadmin) . "."; } $q = $dbh->query("select * from " . $esquemaadmin . "i3geoadmin_mapas where id_mapa={$id_mapa} ", PDO::FETCH_ASSOC); $mapasalvo = $q->fetchAll(); $dbh = null; $dbhw = null; $mapasalvo = $mapasalvo[0]; $base = ""; if (strtoupper($mapasalvo["publicado"]) != "NAO") { $base = $dir_tmp . "/" . nomeRandomico() . "_restaurado.map"; $baseh = fopen($base, 'w'); $mapfile = $mapasalvo["mapfile"]; //$registro = $mapasalvo["mapfile"]; //verifica se existem parametros junto com o registro //$registro = explode(",",$registro); //$mapfile = $registro[0]; //adapta para versoes novas do mapserver //verifica se esta em base 64 (versoes antigas) if (!preg_match('/MAP/', $mapfile)) { $mapfile = base64_decode($mapfile); } else { //substitui strings especiais $mapfile = str_replace("_!!_", '"', $mapfile); $mapfile = str_replace("_!_", "'", $mapfile); } $mapfile = str_ireplace("TYPE ANNOTATION", "TYPE POINT", $mapfile); $mapfile = str_replace(array("<?", "?>"), "", $mapfile); $s = fwrite($baseh, $mapfile); fclose($baseh); if (@ms_newMapObj($base)) { return $base; } else { unlink($base); } } return false; }
include_once dirname(__FILE__) . "/../safe.php"; verificaBlFerramentas(basename(dirname(__FILE__)), $i3geoBlFerramentas, false); // //faz a busca da função que deve ser executada // $retorno = ""; //string que será retornada ao browser via JSON switch (strtoupper($funcao)) { /* Valor: CRIAMARKERCLUSTER Adiciona ao mapa uma nova camada para calculo do mapa de calor */ case "CRIAMARKERCLUSTER": $nameLayer = "markercluster" . nomeRandomico(); $map = ms_newMapObj($map_file); $layer = $map->getlayerbyname($tema); $novolayer = ms_newLayerObj($map, $layer); $novolayer->setmetadata("tema", $titulo); $parametros = '{"plugin":"markercluster","parametros":{"tipoEstilos": "default","opacity":"' . $_GET["opacidade"] . '","gridSize":"' . $_GET["gridSize"] . '"}}'; $novolayer->setmetadata("PLUGINI3GEO", $parametros); $novolayer->set("name", $nameLayer); $novolayer->set("group", ""); $map->save($map_file); $retorno = $nameLayer; break; } if (isset($map_file) && isset($postgis_mapa) && $map_file != "") { restauraCon($map_file, $postgis_mapa); }
function tabelaLegenda($totaliza = "nao") { $linhas = array(); foreach ($this->visiveis as $l) { $layer = $this->mapa->getlayerbyname($l); //verifica se é wms ou wfs $c = $layer->connectiontype; $s = $layer->getmetadata("wms_sld_url"); $im = $layer->getmetadata("legendaimg"); $nc = $layer->numclasses; // //se for wms e tiver classes define o tipo de layer para poder gerar a legenda corretamente // if ($c == 7 && $nc > 0) { $tipotemp = $layer->type; $tiporep = $layer->getmetadata("tipooriginal"); $layer->set("type", MS_LAYER_POLYGON); if ($tiporep == "linear") { $layer->set("type", MS_LAYER_LINE); } if ($tiporep == "pontual") { $layer->set("type", MS_LAYER_POINT); } } // //se for WMS e não tiver classes, tenta pegar a legenda via requisição WMS // if ($nc == 0 && ($c == 7 || $im != "")) { if ($c == 7) { $con = $layer->connection; $ver = $layer->getmetadata("wms_server_version"); $lwms = $layer->getmetadata("wms_name"); $f = $layer->getmetadata("wms_formatlist"); $f = explode(",", $f); $f = $f[0]; $imgLeg = $con . "&request=GetLegendGraphic&version=" . $ver . "&service=wms&layer=" . $lwms . "&format=" . $f . "&SLD=" . $s; if ($layer->getmetadata("legendawms") != "") { $imgLeg = $layer->getmetadata("legendawms"); } } else { $imgLeg = $im; } $linhas[] = array("tema" => $l, "idclasse" => "", "nomeclasse" => "", "expressao" => "", "expressao" => "", "imagem" => $imgLeg, "minScale" => 0, "maxScale" => 0); } else { for ($c = 0; $c < $nc; $c++) { $classe = $layer->getclass($c); $imgi = $classe->createlegendicon(30, 15); $classe->drawlegendicon(30, 15, $imgi, 0, 0); $nomes = nomeRandomico(12); $nomer = $imgi->imagepath . "icone" . $nomes . ".png"; $imgi->saveImage($nomer); $i = $imgi->imageurl . basename($nomer); $nomeclasse = $classe->name; //if (function_exists("mb_convert_encoding")) //{$nomeclasse = mb_convert_encoding($nomeclasse,"UTF-8","ISO-8859-1");} $nomeclasse = $this->converte($nomeclasse); $nomeexp = $classe->getExpressionString(); if (function_exists("mb_convert_encoding")) { $nomeexp = mb_convert_encoding($nomeexp, "UTF-8", "ISO-8859-1"); } $linhas[] = array("tema" => $l, "idclasse" => $c, "nomeclasse" => $nomeclasse, "expressao" => $nomeexp, "imagem" => $i, "proc" => "", "minScale" => $classe->minscaledenom, "maxScale" => $classe->maxscaledenom); } if ($totaliza == "sim" && $nc > 1) { $layer->set("template", "none.htm"); $sopen = $layer->open(); if ($sopen == MS_FAILURE) { return "erro"; } $itens = $layer->getitems(); $total = 0; $nreg = array(); for ($c = 0; $c < $nc; $c++) { $exp = $linhas[$c]; $exp = $exp["expressao"]; if ($exp !== "") { if ($this->layer->connectiontype == MS_POSTGIS) { $exp = str_replace("eq", " = ", $exp); $exp = str_replace("ne", " != ", $exp); $exp = str_replace("lt", " < ", $exp); $exp = str_replace("gt", " < ", $exp); $exp = str_replace("(", "", $exp); $exp = str_replace(")", "", $exp); $exp = str_replace("'[", "", $exp); $exp = str_replace("]'", "", $exp); $exp = str_replace("' [", "", $exp); $exp = str_replace("] '", "", $exp); $exp = str_replace("and", " and ", $exp); $exp = str_replace("or", " or ", $exp); $exp = str_replace("[", "", $exp); $exp = str_replace("]", "", $exp); } $teste = $layer->queryByAttributes($itens[0], $exp, 1); if ($teste != MS_SUCCESS) { $teste = $layer->queryByAttributes($itens[0], mb_convert_encoding($exp, "ISO-8859-1", "UTF-8"), 1); } if ($teste != MS_SUCCESS) { $teste = $layer->queryByAttributes($itens[0], mb_convert_encoding($exp, "UTF-8", "ISO-8859-1"), 1); } } else { $teste = 0; } if ($teste == MS_SUCCESS) { $n = $layer->getNumResults(); $nreg[] = $n; } else { $nreg[] = "erro"; } $total = $total + $n; } $layer->close(); for ($c = 0; $c < $nc; $c++) { $classe = $layer->getclass($c); $nome = $linhas[$c]["nomeclasse"]; $nome = explode(" - n=", $nome); $nome = $nome[0] . " - n=" . $nreg[$c] . "(" . round($nreg[$c] * 100 / $total) . "%)"; $classe->set("name", $nome); $linhas[$c]["nomeclasse"] = $nome; $linhas[$c]["nreg"] = $nreg[$c]; $linhas[$c]["totalreg"] = $total; } } if ($layer->type == MS_LAYER_RASTER && $nc == 1) { $proc = ""; $linhas = array(); if ($layer->num_processing > 0) { $proc = $layer->getProcessing(); } if ($layer->type == MS_LAYER_RASTER && $proc == "") { $proc = array("RESAMPLE=NEAREST"); } $linhas[] = array("tema" => $l, "idclasse" => "", "nomeclasse" => "", "expressao" => "", "imagem" => "", "proc" => $proc, "minScale" => 0, "maxScale" => 0); } } } return $linhas; }
<fusaoGrafico> */ /* Valor: FUSAOGRAFICO Faz a fusão da imagem de um gráfico com a imagem do mapa atual. <fusaoGrafico> */ case "FUSAOGRAFICO": include_once dirname(__FILE__) . "/../../classesphp/graficos.php"; restauraCon($map_file, $postgis_mapa); include_once dirname(__FILE__) . "/../../classesphp/classe_imagem.php"; if ($map_file != "") { $mapa = ms_newMapObj($map_file); $imgo = $mapa->draw(); $nome = $imgo->imagepath . nomeRandomico() . ".png"; $imgo->saveImage($nome); $imagem = $imgo->imageurl . basename($nome); } $m = new Imagem(dirname($dir_tmp) . $imagem); $i = $m->fundeIm(dirname($dir_tmp) . $grafico); imagepng($i, dirname($dir_tmp) . $imagem); $retorno = $imagem; break; } if (isset($map_file) && isset($postgis_mapa) && $map_file != "") { restauraCon($map_file, $postgis_mapa); } cpjson($retorno);
function criaDirMapa($dir_tmp, $cachedir = "") { if (empty($dir_tmp)) { return false; } if (!file_exists($dir_tmp)) { @mkdir($dir_tmp, 0744); } if (file_exists($dir_tmp)) { foreach (glob($dir_tmp . '/{,.}*.php', GLOB_BRACE) as $f) { unlink($f); } $tmpdirname = nomeRandomico(); $crdir = @mkdir($dir_tmp . "/" . $tmpdirname, 0744); chmod($dir_tmp . "/" . $tmpdirname, 0744); $crdiri = @mkdir($dir_tmp . "/img" . $tmpdirname, 0744); chmod($dir_tmp . "/img" . $tmpdirname, 0744); $mapfile = $dir_tmp . "/" . $tmpdirname . "/" . $tmpdirname . ".map"; $tmpimgname = "img" . $tmpdirname; if (!file_exists($dir_tmp . "/comum")) { @mkdir($dir_tmp . "/comum", 0744); } if (!file_exists($dir_tmp . "/saiku-datasources")) { //utilizado para armazenar os arquivos de fonte de dados do SAIKU @mkdir($dir_tmp . "/saiku-datasources", 0744); chmod($dir_tmp . "/saiku-datasources", 0744); } // if ($cachedir == "") { if (!file_exists($dir_tmp . "/cache")) { @mkdir($dir_tmp . "/cache", 0744); chmod($dir_tmp . "/cache", 0744); @mkdir($dir_tmp . "/cache/googlemaps", 0744); chmod($dir_tmp . "/cache/googlemaps", 0744); } } else { if (!file_exists($cachedir)) { @mkdir($cachedir, 0744); chmod($cachedir, 0744); @mkdir($cachedir . "/googlemaps", 0744); chmod($cachedir . "/googlemaps", 0744); } } if (file_exists($dir_tmp . "/" . $tmpdirname)) { return array($mapfile, $tmpdirname, $tmpimgname); } else { return false; } } else { return false; } }
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ã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> é um programa PHP. O teste pode nã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ço dos arquivos de símbolos estiverem <br>definidos de forma relativa ao invés de absoluta. Nesses casos, ao abrir o i3Geo, <br>o mapfile poderá 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ã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)); } } } }
function criaConexaoEsquema() { global $dir_tmp, $urlXmlEsquema; $nomeConexao = nomeRandomico(); //pega a sessao PHP aberta pelo i3Geo ou ms_criamapa.php session_name("i3GeoPHP"); session_id($_GET["g_sid"]); session_start(); $map_file = $_SESSION["map_file"]; if (empty($_GET["xmlesquema"])) { $urlXmlEsquema = $_SESSION["tmpurl"] . basename(dirname($map_file)) . "/" . $nomeConexao . ".xml"; } else { $urlXmlEsquema = $_GET["xmlesquema"]; //cria um nome de arquivo reaproveitável $nomeConexao = md5($_GET["xmlesquema"]); } //$arquivoXmlEsquema = dirname($map_file)."/".$nomeConexao.".xml"; return $nomeConexao . ".txt"; }
function retornaWms($map_fileX, $postgis_mapa) { error_reporting(0); if (isset($_GET["bbox"])) { $_GET["BBOX"] = $_GET["bbox"]; } if (isset($_GET["BBOX"])) { $_GET["mapext"] = str_replace(",", " ", $_GET["BBOX"]); $m = explode(" ", $_GET["mapext"]); $dx = $m[0] - $m[2]; if ($dx < 0) { $dx = $dx * -1; } $dy = $m[1] - $m[3]; if ($dy < 0) { $dy = $dy * -1; } $_GET["HEIGHT"] = $_GET["WIDTH"] / $dx * $dy; //$_GET["map_size"] = $_GET["WIDTH"]." ".$_GET["HEIGHT"]; } $mapa = ms_newMapObj($map_fileX); $mapa->setProjection("init=epsg:4326"); // //resolve o problema da seleção na versão nova do mapserver // $qyfile = dirname($map_fileX) . "/" . $_GET["layer"] . "_qy.map"; $qy = file_exists($qyfile); $o = $mapa->outputformat; $o->set("imagemode", MS_IMAGEMODE_RGBA); if (!isset($_GET["telaR"])) { //no caso de projecoes remotas, o mapfile nao´e alterado $numlayers = $mapa->numlayers; for ($i = 0; $i < $numlayers; ++$i) { $l = $mapa->getlayer($i); if ($l->getmetadata("classesnome") != "") { if (!function_exists("autoClasses")) { include_once "funcoes_gerais.php"; } autoClasses($l, $mapa); } $layerName = $l->name; if ($layerName != $_GET["layer"]) { $l->set("status", MS_OFF); } if ($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != "") { $l->set("status", MS_DEFAULT); if (!empty($postgis_mapa)) { if ($l->connectiontype == MS_POSTGIS) { $lcon = $l->connection; if ($lcon == " " || $lcon == "" || in_array($lcon, array_keys($postgis_mapa))) { if ($lcon == " " || $lcon == "") { $l->set("connection", $postgis_mapa); } else { $l->set("connection", $postgis_mapa[$lcon]); } } } } } $l->set("template", "none.htm"); } } else { $mapa->selectOutputFormat("jpeg"); $of = $mapa->outputformat; $of->set("imagemode", MS_IMAGEMODE_RGBA); $of->set("driver", "AGG/PNG"); $of->set("transparent", MS_ON); } $mapa->setsize($_GET["WIDTH"], $_GET["HEIGHT"]); if (isset($_GET["mapext"])) { $mapext = explode(" ", $_GET["mapext"]); $mapa->setExtent($mapext[0], $mapext[1], $mapext[2], $mapext[3]); } if (!isset($_GET["telaR"])) { $legenda = $mapa->legend; $legenda->set("status", MS_OFF); $escala = $mapa->scalebar; $escala->set("status", MS_OFF); } // //se o layer não for do tipo fundo // if (isset($_GET["tipolayer"]) && $_GET["tipolayer"] != "fundo") { $o->set("transparent", MS_TRUE); } if ($qy != true) { $img = $mapa->draw(); } else { $handle = fopen($qyfile, "r"); $conteudo = fread($handle, filesize($qyfile)); fclose($handle); $shp = unserialize($conteudo); $l = $mapa->getLayerByname($_GET["layer"]); if ($l->connectiontype != MS_POSTGIS) { $indxlayer = $l->index; foreach ($shp as $indx) { $mapa->querybyindex($indxlayer, -1, $indx, MS_TRUE); } $qm = $mapa->querymap; $qm->set("width", $map_size[0]); $qm->set("height", $map_size[1]); $img = $mapa->drawQuery(); } else { $img = $mapa->draw(); $c = $mapa->querymap->color; $numclasses = $l->numclasses; if ($numclasses > 0) { $classe0 = $l->getClass(0); $classe0->setexpression(""); $classe0->set("name", " "); for ($i = 1; $i < $numclasses; ++$i) { $classe = $l->getClass($i); $classe->set("status", MS_DELETE); } } $cor = $classe0->getstyle(0)->color; $cor->setrgb($c->red, $c->green, $c->blue); $cor = $classe0->getstyle(0)->outlinecolor; $cor->setrgb($c->red, $c->green, $c->blue); $status = $l->open(); $status = $l->whichShapes($mapa->extent); while ($shape = $l->nextShape()) { if (in_array($shape->index, $shp)) { $shape->draw($mapa, $l, $img); } } $l->close(); } } if (!function_exists('imagepng')) { $s = PHP_SHLIB_SUFFIX; @dl('php_gd.' . $s); if (!function_exists('imagepng')) { @dl('php_gd2.' . $s); } if (!function_exists('imagepng')) { $_GET["TIPOIMAGEM"] = ""; } } if (isset($_GET["TIPOIMAGEM"]) && trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") { if ($img->imagepath == "") { echo "Erro IMAGEPATH vazio"; exit; } $nomer = $img->imagepath . "filtroimgtemp" . nomeRandomico() . ".png"; $img->saveImage($nomer); filtraImagem($nomer, $_GET["TIPOIMAGEM"]); $img = imagecreatefrompng($nomer); imagealphablending($img, false); imagesavealpha($img, true); ob_clean(); echo header("Content-type: image/png \n\n"); imagepng($img); } else { ob_clean(); if ($img->imagepath == "") { echo "Erro IMAGEPATH vazio"; exit; } $nomer = $img->imagepath . "imgtemp" . nomeRandomico() . ".png"; $img->saveImage($nomer); $img = imagecreatefrompng($nomer); imagealphablending($img, false); imagesavealpha($img, true); ob_clean(); echo header("Content-type: image/png \n\n"); imagepng($img); } }
function adicionaTemaGeoRSS($servico, $dir_tmp, $locaplic, $canal) { $xml = simplexml_load_file($servico); $conta = 0; foreach ($xml->channel as $c) { if ($conta == $canal) { $canal = $c; } } $nos = $canal->item; //verifica se o canal faz referencia a elementos externos //se sim, usa todos os elementos do xml no lugar do canal foreach ($canal->items as $t) { foreach ($t->xpath('rdf:Seq') as $x) { foreach ($x->xpath('rdf:li') as $z) { $nos = $xml->item; } } } $resultado = array(); $tipog = ""; foreach ($nos as $item) { $env = array(); //define o tipo if ($item->xpath('geo:lat')) { $tipog = "geo"; } if ($item->xpath('georss:point')) { $tipog = "georsspoint"; } if ($item->xpath('georss:where')) { $tipog = "envelope"; } if ($tipog == "envelope") { foreach ($item->xpath('georss:where') as $w) { foreach ($w->xpath('gml:Envelope') as $e) { //$lc = $e->xpath('gml:lowerCorner'); $lc = (string) $e->children('gml', TRUE)->lowerCorner; //$uc = $e->xpath('gml:upperCorner'); $uc = (string) $e->children('gml', TRUE)->upperCorner; $lc = explode(" ", $lc); $uc = explode(" ", $uc); if (is_numeric($lc[0])) { $ymin = $lc[0]; $ymax = $uc[0]; $xmin = $lc[1]; $xmax = $uc[1]; if ($ymin != "") { $env = array($xmin, $ymin, $xmax, $ymax); } } } } } if ($tipog == "geo") { if ($item->xpath('geo:lon')) { $x = (string) $item->children('geo', TRUE)->lon; } else { $x = (string) $item->children('geo', TRUE)->long; } //$y = $item->xpath('geo:lat'); $y = (string) $item->children('geo', TRUE)->lat; $env = array($y, $x); } if ($tipog == "georsspoint") { //$temp = $item->xpath('georss:point'); $temp = (string) $item->children('georss', TRUE)->point; $env = explode(" ", $temp); } if (count($env) > 0) { $resultado[] = array(ixml($item, "title"), ixml($item, "link"), ixml($item, "description"), ixml($item, "category"), $env); } } //cria o shapefile com os dados if (count($resultado) > 0) { //para manipular dbf include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php"; $diretorio = dirname($this->arquivo); $tipol = MS_SHP_POLYGON; if ($tipog == "georsspoint") { $tipol = MS_SHP_POINT; } if ($tipog == "geo") { $tipol = MS_SHP_POINT; } $novonomelayer = nomeRandomico(10) . "georss"; $nomeshp = $diretorio . "/" . $novonomelayer; $novoshpf = ms_newShapefileObj($nomeshp, $tipol); $def[] = array("TITULO", "C", "254"); $def[] = array("LINK", "C", "254"); $def[] = array("DESC", "C", "254"); $def[] = array("CATEGORIA", "C", "254"); if (!function_exists(dbase_create)) { $db = xbase_create($nomeshp . ".dbf", $def); xbase_close($db); } else { $db = dbase_create($nomeshp . ".dbf", $def); dbase_close($db); } //acrescenta os pontos no novo shapefile $dbname = $nomeshp . ".dbf"; $db = xbase_open($dbname, 2); $reg = array(); $novoshpf = ms_newShapefileObj($nomeshp . ".shp", -2); //acrescenta os shapes foreach ($resultado as $r) { $pts = $r[4]; if ($tipol == MS_SHP_POLYGON) { $shp = ms_newShapeObj(MS_SHP_POLYGON); $linha = ms_newLineObj(); $linha->addXY($pts[0], $pts[3]); $linha->addXY($pts[2], $pts[3]); $linha->addXY($pts[2], $pts[1]); $linha->addXY($pts[0], $pts[1]); $linha->addXY($pts[0], $pts[3]); } else { $shp = ms_newShapeObj(MS_SHP_POINT); $linha = ms_newLineObj(); $linha->addXY($pts[1], $pts[0]); } $shp->add($linha); $novoshpf->addShape($shp); $reg = array($r[0], $r[1], $r[2], $r[3]); xbase_add_record($db, $reg); $reg = array(); } xbase_close($db); if ($tipog == "georsspoint" || $tipog == "geo") { $tipol = MS_LAYER_POINT; } else { $tipol = MS_LAYER_POLYGON; } $layer = criaLayer($this->mapa, $tipol, MS_DEFAULT, "GeoRSS", "SIM"); $layer->set("data", $nomeshp . ".shp"); $layer->set("name", basename($nomeshp)); $layer->setmetadata("DOWNLOAD", "sim"); $layer->setmetadata("TEMALOCAL", "SIM"); //evita problemas no modo tile if ($this->v > 5) { $layer->setprocessing("LABEL_NO_CLIP=True"); $layer->setprocessing("POLYLINE_NO_CLIP=True"); } if ($tipol == MS_LAYER_POLYGON) { $classe = $layer->getclass(0); $estilo = $classe->getstyle(0); $estilo->set("symbolname", "p4"); $estilo->set("size", 5); $cor = $estilo->color; $cor->setrgb(255, 0, 0); $coro = $estilo->outlinecolor; $coro->setrgb(255, 0, 0); } //$layer->set("transparency",50); $layer->setmetadata("nomeoriginal", basename($nomeshp)); //echo $tipol; return "ok"; } return "erro"; }
/** * Cria um mapfile para visualizacao de regioes * Inclui no arquivo o layer de acesso aos dados * O mapfile contem apenas o layer * O arquivo e armazenado em uma pasta temporaria * Se o arquivo para a mesma regiao ja existir, tenta usa-lo ao inves de criar um novo * @param codigo da regiao * @param cor do outline do simbolo de desenho * @param largura do simbolo * @param sim|nao inclui ou nao os labels * @param boolean remove o arquivo em cache e cria um novo * @return array("mapfile"=>,"layer"=>,"titulolayer"=>,"codigo_tipo_regiao"=>) */ function mapfileTipoRegiao($codigo_tipo_regiao, $outlinecolor = "255,0,0", $width = 1, $nomes = "nao", $forcaArquivo = false) { //para permitir a inclusao de filtros, o fim do sql e marcado com /*FW*//*FW*/ //indicando onde deve comecar e terminar uma possivel clausula where //Layers adicionados aqui sao marcados com o metadata METAESTAT "SIM" //O codigo_tipo_regiao e marcado com o metadata METAESTAT_CODIGO_TIPO_REGIAO if ($forcaArquivo == false) { $arq = $this->dir_tmp . "/" . $this->nomecache . ".map"; } else { $arq = $this->dir_tmp . "/" . $this->nomecache . nomeRandomico(3) . ".map"; } if (!file_exists($arq)) { $tipolayer = "polygon"; //define o tipo correto de layer $dg = $this->listaDadosGeometriaRegiao($codigo_tipo_regiao); if (empty($tipolayer)) { $tipolayer = "polygon"; } if ($dg["dimension"] == 0) { $tipolayer = "point"; } if ($dg["dimension"] == 1) { $tipolayer = "line"; } $meta = $this->listaTipoRegiao($codigo_tipo_regiao); $titulolayer = $meta["nome_tipo_regiao"]; $titulolayer = mb_convert_encoding($titulolayer, "ISO-8859-1", mb_detect_encoding($titulolayer)); $conexao = $this->listaConexao($meta["codigo_estat_conexao"], true); $conexao = "user="******"usuario"] . " password="******"senha"] . " dbname=" . $conexao["bancodedados"] . " host=" . $conexao["host"] . " port=" . $conexao["porta"] . ""; $colunageo = $meta["colunageo"]; $srid = $meta["srid"]; //pega as colunas menos as do tipo geometry $colunastabela = $this->colunasTabela($meta["codigo_estat_conexao"], $meta["esquemadb"], $meta["tabela"], "geometry", "!="); //define as colunas que serao mostradas no sql $vis = $meta["colunasvisiveis"]; $colunaSerial = $this->listaTipoRegiaoSerial($codigo_tipo_regiao); if ($vis != "") { $vis = str_replace(";", ",", $vis); $vis = str_replace(",,", ",", $vis); $vis = explode(",", $vis); $itens = $vis; //array $vis[] = $meta["identificador"]; if (!empty($colunaSerial)) { $vis[] = $colunaSerial; } $vis = array_unique($vis); $visiveis = array(); //verifica se as colunas existem mesmo foreach ($vis as $v) { if (in_array($v, $colunastabela)) { $visiveis[] = $v; } } $vis = implode(",", $visiveis); //apelidos $apelidos = $meta["apelidos"]; if ($apelidos == "") { $apelidos = "Nome"; } $apelidos = str_replace(";", ",", $apelidos); $apelidos = str_replace(",,", ",", $apelidos); $apelidos = mb_convert_encoding($apelidos, "ISO-8859-1", mb_detect_encoding($apelidos)); $apelidos = explode(",", $apelidos); if (!empty($colunaSerial)) { $apelidos[] = $colunaSerial . " (serial)"; } $apelidos = array_unique($apelidos); } else { $itens = array(); $apelidos = array(); if (!empty($colunaSerial)) { $colunastabela[] = $colunaSerial; $colunastabela = array_unique($colunastabela); } $vis = implode(",", $colunastabela); } $sqlf = $colunageo . " from (select st_setsrid(" . $colunageo . "," . $srid . ") as {$colunageo},{$vis} from " . $meta["esquemadb"] . "." . $meta["tabela"] . " /*FW*//*FW*/) as foo using unique " . $meta["identificador"] . " using srid=" . $srid; $sqlf = str_replace(",,", ",", $sqlf); $outlinecolor = str_replace(",", " ", $outlinecolor); $dados[] = "MAP"; $dados[] = 'SYMBOLSET "' . $this->locaplic . '/symbols/simbolosv6.sym"'; $dados[] = 'FONTSET "' . $this->locaplic . '/symbols/fontes.txt"'; $dados[] = "LAYER"; $dados[] = ' NAME "' . $this->nomecache . '"'; $dados[] = "\tTYPE {$tipolayer}"; $dados[] = ' DATA "' . $sqlf . '"'; $dados[] = ' CONNECTION "' . $conexao . '"'; $dados[] = ' CONNECTIONTYPE POSTGIS'; $dados[] = ' TEMPLATE "none.htm"'; $dados[] = ' STATUS OFF'; $dados[] = ' METADATA'; $dados[] = ' TEMA "' . $titulolayer . '"'; $dados[] = ' CLASSE "SIM"'; $dados[] = ' METAESTAT "SIM"'; $dados[] = ' METAESTAT_CODIGO_TIPO_REGIAO "' . $codigo_tipo_regiao . '"'; if (!empty($colunaSerial)) { $dados[] = ' EDITAVEL "SIM"'; $dados[] = ' COLUNAIDUNICO "' . $colunaSerial . '"'; $dados[] = ' TABELAEDITAVEL "' . $meta["tabela"] . '"'; $dados[] = ' ESQUEMATABELAEDITAVEL "' . $meta["esquemadb"] . '"'; $dados[] = ' COLUNAGEOMETRIA "' . $colunageo . '"'; } $dados[] = ' TIP "' . $meta["colunanomeregiao"] . '"'; if (count($itens) == count($apelidos)) { $dados[] = ' ITENS "' . implode(",", $itens) . '"'; $dados[] = ' ITENSDESC "' . implode(",", $apelidos) . '"'; } $dados[] = ' END'; $dados[] = ' CLASS'; $dados[] = ' NAME ""'; $dados[] = ' STYLE'; $dados[] = ' OUTLINECOLOR ' . $outlinecolor; $dados[] = ' WIDTH ' . $width; if (strtolower($tipolayer) == "point") { $dados[] = ' SYMBOL "ponto"'; $dados[] = ' SIZE 5'; $dados[] = ' COLOR 0 0 0 '; } else { $dados[] = ' COLOR -1 -1 -1'; } $dados[] = ' END'; //$dados[] = ' STYLE'; //$dados[] = ' OUTLINECOLOR -1 -1 -1'; //$dados[] = ' COLOR 255 255 255'; //$dados[] = ' OPACITY 20'; //$dados[] = ' END'; $dados[] = ' END'; $dados[] = "END"; //toponimia if ($nomes == "sim") { $dados[] = "LAYER"; $dados[] = ' NAME "' . $this->nomecache . '_anno"'; $dados[] = "\tTYPE ANNOTATION"; $dados[] = ' DATA "' . $sqlf . '"'; $dados[] = ' CONNECTION "' . $conexao . '"'; $dados[] = ' CONNECTIONTYPE POSTGIS'; $dados[] = ' TEMPLATE "none.htm"'; $dados[] = ' STATUS OFF'; $dados[] = ' LABELITEM "' . $meta["colunanomeregiao"] . '"'; $dados[] = ' METADATA'; $dados[] = ' TEMA "' . $titulolayer . ' (nomes)"'; $dados[] = ' CLASSE "SIM"'; $dados[] = ' METAESTAT "SIM"'; $dados[] = ' METAESTAT_CODIGO_TIPO_REGIAO "' . $codigo_tipo_regiao . '"'; $dados[] = ' END'; $dados[] = ' CLASS'; $dados[] = ' NAME ""'; $dados[] = ' LABEL'; $dados[] = ' FONT "arial"'; $dados[] = ' SIZE 10'; $dados[] = ' COLOR 0 0 0'; $dados[] = ' MINDISTANCE 0'; $dados[] = ' MINFEATURESIZE 0'; $dados[] = ' OFFSET 0 0'; $dados[] = ' OUTLINECOLOR 255 255 255'; $dados[] = ' PARTIALS FALSE'; $dados[] = ' POSITION AUTO'; $dados[] = ' SHADOWSIZE 1 1'; $dados[] = ' TYPE TRUETYPE'; $dados[] = ' END'; $dados[] = ' END'; $dados[] = "END"; } $dados[] = "END"; $fp = fopen($arq, "w"); foreach ($dados as $dado) { fwrite($fp, $dado . "\n"); } } return array("mapfile" => $arq, "layer" => $this->nomecache, "titulolayer" => $titulolayer, "codigo_tipo_regiao" => $codigo_tipo_regiao); }
include_once dirname(__FILE__) . "/../../classesphp/carrega_ext.php"; // //carrega o phpmapscript // $exts = get_loaded_extensions(); if (array_search("MapScript", $exts) != TRUE) { if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { if (!@dl('php_mapscript_48.dll')) { dl('php_mapscript.dll'); } } else { dl('php_mapscript.so'); } } require dirname(__FILE__) . "/../../classesphp/funcoes_gerais.php"; $nomes = nomeRandomico(); $temp = str_replace(".map", "xxx.map", $map_file); $map = ms_newMapObj($map_file); $map->save($temp); substituiCon($temp, $postgis_mapa); $map = ms_newMapObj($temp); substituiCon($temp, $postgis_mapa); $w = $map->width; $h = $map->height; $legenda = $map->legend; $legenda->set("status", MS_EMBED); //altera o nome das classes vazias $temas = $map->getalllayernames(); foreach ($temas as $tema) { $layer = $map->getlayerbyname($tema); if ($layer->data != "" && strtolower($layer->getmetadata("escondido")) != "sim" && strtolower($layer->getmetadata("tema")) != "nao") {
function executaR($rcode, $dir_tmp, $R_path, $gfile_name = "") { $R_options = "--slave --no-save"; $r_name = nomeRandomico(20); $r_input = $dir_tmp . "/" . $r_name . ".R"; $r_output = $dir_tmp . "/" . $r_name . ".Rout"; gravaDados($rcode, $r_input); $command = $R_path . " {$R_options} < {$r_input} > {$r_output}"; $result = ""; $error = ""; $exec_result = exec($command, $result, $error); // corta a imagem final // include_once("classe_imagem.php"); // $m = new Imagem($dir_tmp."/".$gfile_name.".png"); // $i = $m->cortaBorda(); // imagepng($i,$dir_tmp."/".$gfile_name.".png"); return $r_input; }