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 __construct($map_file, $tema = "", $locaplic = "") { include dirname(__FILE__) . "/../ms_configura.php"; $this->postgis_mapa = $postgis_mapa; if (file_exists($locaplic . "/funcoes_gerais.php")) { include_once $locaplic . "/funcoes_gerais.php"; } else { include_once "funcoes_gerais.php"; } $this->v = versao(); $this->vi = $this->v["inteiro"]; $this->v = $this->v["principal"]; $this->mapa = ms_newMapObj($map_file); substituiConObj($this->mapa, $postgis_mapa); $this->arquivo = str_replace(".map", "", $map_file) . ".map"; if ($tema != "" && @$this->mapa->getlayerbyname($tema)) { $this->layer = $this->mapa->getlayerbyname($tema); } $this->nome = $tema; }
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")); } }
function calculaGeometrias($dir_tmp, $imgdir, $lista, $operacao) { // error_reporting(0); $lista = explode(",", $lista); $dir = $dir_tmp . "/" . $imgdir . "/"; foreach ($lista as $l) { $geos = $this->unserializeGeo($dir . $l); // // verifica a versão do mapserver // se for anterior a 5, utiliza a conexão com o postgis para fazer o processamento dos daods // $v = versao(); if ($v["principal"] < 5) { return "erro. E necessario uma versão maior que 5.0 do Mapserver."; } foreach ($geos["dados"] as &$geo) { $g = $geo["wkt"]; switch ($operacao) { case "perimetro": $shape = ms_shapeObjFromWkt($g); $rect = $shape->bounds; $projInObj = ms_newprojectionobj("proj=longlat,ellps=WGS84,datum=WGS84,no_defs"); $projOutObj = ms_newprojectionobj("proj=poly,ellps=GRS67,lat_0=" . $rect->miny . ",lon_0=" . $rect->minx . ",x_0=5000000,y_0=10000000,units=m"); $shape->project($projInObj, $projOutObj); $s = $shape->towkt(); $shape = ms_shapeObjFromWkt($s); $area = $shape->getLength(); $geo["valores"][] = array("item" => "P_perim_metros", "valor" => $area); break; case "area": $shape = ms_shapeObjFromWkt($g); $rect = $shape->bounds; $projInObj = ms_newprojectionobj("proj=longlat,ellps=WGS84,datum=WGS84,no_defs"); $projOutObj = ms_newprojectionobj("proj=laea,lat_0=" . $rect->miny . ",lon_0=" . $rect->minx . ",x_0=500000,y_0=10000000,ellps=GRS67,units=m,no_defs"); $shape->project($projInObj, $projOutObj); $s = $shape->towkt(); $shape = ms_shapeObjFromWkt($s); $area = $shape->getArea(); $geo["valores"][] = array("item" => "P_area_metros", "valor" => $area); break; case "comprimento": break; } } $this->serializeGeo($dir . $l, $geos); } return "ok"; }
/** * Complementa um mapfile resumido inserindo seus layers em um mapfile completo, contendo todos os elementos necessarios para uso * Usado na geracao de WMS e outros servicos * @param mapfile resumido * @return nome do arquivo com o mapfile completo */ function mapfileCompleto($mapfile) { $f = $this->base; if ($f == "") { include_once $this->locaplic . "/classesphp/funcoes_gerais.php"; $versao = versao(); $versao = $versao["principal"]; $f = ""; if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { $f = $this->locaplic . "/aplicmap/geral1windowsv" . $versao . ".map"; } else { if ($f == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv' . $versao . '.map')) { $f = "/var/www/i3geo/aplicmap/geral1debianv" . $versao . ".map"; } if ($f == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) { $f = "/var/www/html/i3geo/aplicmap/geral1fedorav" . $versao . ".map"; } if ($f == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) { $f = "/opt/www/html/i3geo/aplicmap/geral1v" . $versao . ".map"; } if ($f == "") { $f = $this->locaplic . "/aplicmap/geral1v" . $versao . ".map"; } } } $mapa = ms_newMapObj($f); $n = $mapa->numlayers; for ($i = 0; $i < $n; $i++) { $l = $mapa->getlayer($i); $l->set("status", MS_DELETE); } $mapatemp = ms_newMapObj($mapfile); $l = $mapatemp->getlayer(0); $l->set("status", MS_DEFAULT); $novonome = str_replace(".map", "completo.map", $mapfile); //necessario para o kml $mapa->setmetadata("ows_enable_request", "*"); $listaepsg = "EPSG:4618 EPSG:4291 EPSG:4326 EPSG:22521 EPSG:22522 EPSG:22523 EPSG:22524 EPSG:22525 EPSG:29101 EPSG:29119 EPSG:29120 EPSG:29121 EPSG:29122 EPSG:29177 EPSG:29178 EPSG:29179 EPSG:29180 EPSG:29181 EPSG:29182 EPSG:29183 EPSG:29184 EPSG:29185"; $l->setmetadata("ows_srs", $listaepsg); $temp = ms_newLayerObj($mapa, $l); $mapa->save($novonome); return $novonome; }
function iniciaMapa() { global $googleApiKey, $i3geoPermiteLogin, $dir_tmp, $logExec, $postgis_mapa, $statusFerramentas, $saikuUrl, $emailInstituicao, $openid, $interfacePadrao, $mensagemInicia, $kmlurl, $tituloInstituicao, $tempo, $navegadoresLocais, $locaplic, $embedLegenda, $map_file, $mapext, $w, $h, $R_path, $locmapserv, $utilizacgi, $expoeMapfile, $interface; // //verifica se algum tema e restrito a determinado usuario //as funcoes de validacao encontram-se em funcoes_gerais.php // if (!function_exists("validaAcessoTemas")) { include_once "funcoes_gerais.php"; } validaAcessoTemas($map_file); if ($dir_tmp != "" && isset($logExec) && $logExec["init"] == true) { i3GeoLog("prog: iniciaMapa interface: {$interface}", $dir_tmp); } if (!isset($kmlurl)) { $kmlurl = ""; } error_reporting(0); if (!isset($interface)) { $interface = ""; } if ($interface == "openlayers") { $m = ms_newMapObj($map_file); $e = $m->extent; $ext = $e->minx . " " . $e->miny . " " . $e->maxx . " " . $e->maxy; $c = $m->numlayers; for ($i = 0; $i < $c; ++$i) { $layer = $m->getlayer($i); if ($layer->status == 2) { $layer->setmetadata("olstatus", "DEFAULT"); } else { $layer->setmetadata("olstatus", "OFF"); } $layer->setmetadata("olopacity", $layer->opacity); } $m->save($map_file); } if ($interface == "googlemaps" || $interface == "googleearth") { $m = ms_newMapObj($map_file); $e = $m->extent; $ext = $e->minx . " " . $e->miny . " " . $e->maxx . " " . $e->maxy; if ($interface == "googlemaps") { $m->setProjection("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m"); } $c = $m->numlayers; for ($i = 0; $i < $c; ++$i) { $layer = $m->getlayer($i); if ($layer->status == 2) { $layer->setmetadata("gmstatus", "DEFAULT"); } else { $layer->setmetadata("gmstatus", "OFF"); } $layer->setmetadata("gmopacity", $layer->opacity); if ($layer->name == "mundo" || $layer->name == "estados") { $layer->set("status", MS_OFF); } if ($layer->type == MS_LAYER_POLYGON || $layer->type == MS_LAYER_RASTER) { if ($layer->opacity == "" || $layer->opacity == 100) { $layer->set("opacity", 50); } } if ($layer->name == "rosadosventos" || $layer->name == "copyright") { $layer->set("status", MS_DELETE); } } $temp = $m->scalebar; $temp->set("status", MS_OFF); $c = $m->imagecolor; $c->setrgb(255, 255, 255); if ($interface == "googleearth") { $m->selectOutputFormat("jpeg"); $of = $m->outputformat; $of->set("driver", "AGG/PNG"); } else { $of = $m->outputformat; } $of->set("imagemode", MS_IMAGEMODE_RGBA); $of->set("transparent", MS_ON); $m->save($map_file); } $protocolo = explode("/", $_SERVER['SERVER_PROTOCOL']); $protocolo = $protocolo[0]; $protocolo = strtolower($protocolo) . '://' . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT']; $urli3geo = str_replace("/classesphp/mapa_controle.php", "", $protocolo . $_SERVER["PHP_SELF"]); //altera o tamanho do query map para ficar igual ao do mapa include_once "classe_mapa.php"; error_reporting(0); if (!function_exists("sobeAnno")) { include_once "funcoes_gerais.php"; } sobeAnno($map_file); $m = new Mapa($map_file); if (isset($w)) { $m->mudaQS($w, $h); $m = new Mapa($map_file); $m->mapa->setsize($w, $h); } error_reporting(0); // //verifica se a legenda deve ser embebida no mapa // $legenda = $m->mapa->legend; $embedLegenda == "sim" ? $legenda->set("status", MS_EMBED) : $legenda->set("status", MS_OFF); // //salva as alterações feitas // $m->mapa->setmetadata("ows_enable_request", "*"); $m->salva(); //prepara a legenda para incluir no mapa, preenchendo os nomes das classes em branco if (strtolower($embedLegenda) == "sim") { foreach ($m->layers as $l) { if ($l->data != "" && strtoupper($l->getmetadata("escondido")) != "SIM" && strtolower($l->getmetadata("tema")) != "nao") { if ($l->numclasses > 0) { $classe = $l->getclass(0); if ($classe->name == "" || $classe->name == " ") { $classe->set("name", $l->getmetadata("tema")); } } } } } // //cuidado ao mexer aqui //o mapa precisa ser salvo para registrar a extensão geográfica // //$imgo = $m->mapa->draw(); $imgo = $m->mapa->prepareImage(); $m->salva($map_file); //$e = $m->mapa->extent; //$ext = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); $escalaMapa = $m->mapa->scaledenom; $celula = $m->mapa->cellsize; // //pega os parametros de cada tema // $qyfile = str_replace(".map", ".qy", $map_file); $arqsel = file_exists($qyfile) ? true : false; $m = new Mapa($map_file, $locaplic); $temas = $m->parametrosTemas(); //$m->ligaDesligaTemas("",implode(",",$m->nomes),"nao"); // //é necessário um mapa para compor o fundo apenas com o imagecolor e sem nenhuma outra camada //utilizado em algumas interfaces // /* $nomefundo = str_replace(".map","fundo.map",$map_file); $m->mapa->save($nomefundo); $mf = ms_newMapObj($nomefundo); $numlayers = $mf->numlayers; for($i = 0;$i < $numlayers;++$i) { $l = $mf->getLayer($i); $l->set("status",MS_DELETE); } $of = $mf->outputformat; $of->set("driver","GD/PNG"); $versao = versao(); $temp = $mf->scalebar; $temp->set("status",MS_OFF); $mf->save($nomefundo); */ $versao = versao(); $temp = $m->mapa->scalebar; $temp->set("status", MS_OFF); $of = $m->mapa->outputformat; $of->set("imagemode", MS_IMAGEMODE_RGBA); $of->setOption("QUANTIZE_FORCE", "OFF"); $of->set("driver", "AGG/PNG"); $m->mapa->setmetadata("interface", $interface); $m->salva(); $nomes = nomeRandomico(12); if ($imgo->imagepath == "") { echo "Erro IMAGEPATH vazio"; exit; } $nomer = $imgo->imagepath . "mapa" . $nomes . ".png"; //$imgo->saveImage($nomer); if (isset($utilizacgi) && strtolower($utilizacgi) == "sim") { $nomer = $locmapserv . "?map=" . $map_file . "&mode=map"; } else { $nomer = $imgo->imageurl . basename($nomer); } //pega a cor de fundo do mapa $c = $m->mapa->imagecolor; $cordefundo = $c->red . "," . $c->green . "," . $c->blue; //pega o texto de copyright $copyright = ""; $lc = $m->mapa->getlayerbyname("copyright"); if ($lc != "" && $lc->status == MS_DEFAULT) { if ($versao["principal"] >= 6) { $shape = $lc->getShape(new resultObj(0)); $copyright = $shape->text; } else { $shape = $lc->getfeature(0, -1); $copyright = $shape->text; } } $res["editor"] = "nao"; // //papeis do usuario se estiver logado // $res["papeis"] = array(); $logado = "nao"; $res["i3geoPermiteLogin"] = "******"; if (isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false) { $_COOKIE = array(); $res["i3geoPermiteLogin"] = "******"; } if (!empty($_COOKIE["i3geocodigologin"])) { session_write_close(); session_name("i3GeoLogin"); session_id($_COOKIE["i3geocodigologin"]); session_start(); //var_dump($_SESSION);exit; $logado = "sim"; if (!empty($_SESSION["usuario"]) && $_SESSION["usuario"] == $_COOKIE["i3geousuariologin"]) { $res["papeis"] = $_SESSION["papeis"]; } else { $logado = "nao"; } //verifica se o usuario logado pode ver as opcoes de edicao do sistema de admin dentro do mapa foreach ($res["papeis"] as $p) { if ($p < 3) { $res["editor"] = "sim"; } } } // $res["mapexten"] = $ext; $res["mapscale"] = $escalaMapa; $res["mapres"] = $m->mapa->resolution; $res["pixelsize"] = $celula; //TODO depreciar na documentacao e ms_configura /* if ((isset($expoeMapfile)) && ($expoeMapfile == "nao")) {$res["mapfile"] = "";} else {$res["mapfile"] = $map_file;} */ $res["mapfile"] = ""; $res["cgi"] = ""; //$locmapserv; $res["extentTotal"] = $ext; $res["mapimagem"] = ""; //$nomer; $geoip = "nao"; if (file_exists($locaplic . "/pacotes/geoip") && file_exists($locaplic . "/pacotes/geoip/GeoLiteCity.dat")) { $geoip = "sim"; } $res["geoip"] = $geoip; $res["listavisual"] = file_exists($locaplic . "/imagens/visual") ? implode(",", listaDiretorios($locaplic . "/imagens/visual")) : ""; //TODO depreciar na documentacao $res["utilizacgi"] = "nao"; //$utilizacgi; $res["versaoms"] = $versao["principal"]; $res["versaomscompleta"] = $versao["completa"]; $res["mensagens"] = $m->pegaMensagens(); $res["r"] = isset($R_path) ? "sim" : "nao"; $res["extentref"] = ""; $res["kmlurl"] = $kmlurl; $res["mensageminicia"] = $mensagemInicia; $res["interfacePadrao"] = $interfacePadrao; $res["embedLegenda"] = $embedLegenda; $res["w"] = $w; $res["h"] = $h; $res["titulo"] = $tituloInstituicao; $res["tempo"] = microtime(1) - $tempo; $res["embedLegenda"] = $embedLegenda; $res["erro"] = ''; $res["mappath"] = ""; //$imgo->imagepath; $res["mapurl"] = ""; //$imgo->imageurl; $res["navegacaoDir"] = $navegadoresLocais; if ($openid == true) { $res["autenticadoopenid"] = "sim"; } else { $res["autenticadoopenid"] = "nao"; } $res["emailInstituicao"] = $emailInstituicao; $res["cordefundo"] = $cordefundo; $res["copyright"] = $copyright; $res["logado"] = $logado; $res["saikuUrl"] = $saikuUrl; $res["statusFerramentas"] = $statusFerramentas; $res["googleApiKey"] = $googleApiKey; //parametros de inicializacao armazenados com o mapa quando o usuario utiliza a opcao de salvar mapa no nbanco de dados $customizacoesinit = $m->mapa->getmetadata("CUSTOMIZACOESINIT"); $res["editavel"] = $m->mapa->getmetadata("EDITAVEL"); $m->mapa->setmetadata("CUSTOMIZACOESINIT", ""); $m->salva(); restauraCon($map_file, $postgis_mapa); copy($map_file, str_replace(".map", "reinc.map", $map_file)); copy($map_file, str_replace(".map", "seguranca.map", $map_file)); ob_clean(); cpjson(array("variaveis" => $res, "temas" => $temas, "customizacoesinit" => $customizacoesinit)); }
function __construct($map_file, $locaplic = "") { include dirname(__FILE__) . "/../ms_configura.php"; $this->postgis_mapa = $postgis_mapa; if (!function_exists('ms_newMapObj')) { return false; } if (file_exists($locaplic . "/funcoes_gerais.php")) { include_once $locaplic . "/funcoes_gerais.php"; } else { include_once "funcoes_gerais.php"; } $this->v = versao(); $this->vi = $this->v["inteiro"]; $this->v = $this->v["principal"]; $this->qyfile = str_replace(".map", ".qy", $map_file); $this->locaplic = $locaplic; if (!file_exists($map_file)) { return $this->arquivo = false; } if (!@ms_newMapObj($map_file)) { return $this->mapa = false; } $this->mapa = @ms_newMapObj($map_file); substituiConObj($this->mapa, $postgis_mapa); $this->arquivo = str_replace(".map", "", $map_file) . ".map"; $c = $this->mapa->numlayers; for ($i = 0; $i < $c; ++$i) { $l = $this->mapa->getlayer($i); $this->layers[] = $l; $this->nomes[] = $l->name; } }
function listaSimbolos($tipo, $dir_tmp, $imgdir, $onclick, $tamanho = 8, $width = 1, $forca = false) { $versao = versao(); $versao = $versao["principal"]; error_reporting(0); if ($tipo == 3) { $tipo = 2; } //tipo raster if ($imgdir == "") { $dir = $dir_tmp; } else { $dir = $dir_tmp . "/" . $imgdir; } if ($forca == true) { unlink($dir . "/simbolos" . $tipo . ".inc"); } $ins = ""; //pega imagens que podem ser usadas como simbolos if ($tipo == 0) { if (!isset($locaplic)) { include dirname(__FILE__) . "/../ms_configura.php"; } //veja esse codigo tambem em ferramentas/uploadsimbolo/exec.php $pasta = $locaplic . "/temas"; $url = "../temas"; if ($customDir != "interface") { $teste = $locaplic . "/" . $customDir; if (file_exists($teste)) { $pasta = $teste; $url = "../" . $customDir; } $teste = $locaplic . "/" . $customDir . "/images"; if (file_exists($teste)) { $pasta = $teste; $url = "../" . $customDir . "/images"; } $teste = $locaplic . "/" . $customDir . "/imagens"; if (file_exists($teste)) { $pasta = $teste; $url = "../" . $customDir . "/imagens"; } } if (file_exists($pasta)) { $lista = listaArquivos($pasta, true, array("png", "PNG")); //var_dump($lista);exit; $n = count($lista["nomes"]); for ($i = 0; $i < $n; $i++) { $ins .= "<img src='" . $url . "/" . $lista["nomes"][$i] . "' style='max-width: 80px;cursor:pointer;border: 5px solid #FFFFFF' title=" . $pasta . "/" . $lista["nomes"][$i] . " onclick='" . $onclick . "'>"; } } } if (!file_exists($dir . "/simbolos" . $tipo . ".inc")) { $f = fopen($dir . "/simbolos" . $tipo . ".inc", "w"); if ($tipo == 2) { $t = "simpolv" . $versao . ".map"; } if ($tipo == 0) { $t = "simptv" . $versao . ".map"; } if ($tipo == 1) { $t = "simlinv" . $versao . ".map"; $tamanho = $tamanho / 4; } if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { $mapatemp = ms_newMapObj($this->localaplicacao . "\\aplicmap\\" . $t); } else { $mapatemp = ms_newMapObj($this->localaplicacao . "/aplicmap/" . $t); } $l = $mapatemp->getlayer(0); if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { $novoss = dirname($this->mapa->symbolsetfilename) . "\\" . basename($mapatemp->symbolsetfilename); } else { $novoss = dirname($this->mapa->symbolsetfilename) . "/" . basename($mapatemp->symbolsetfilename); } $this->mapa->setsymbolset($novoss); $ns = $this->mapa->getnumsymbols(); $inis = 0; //na versao 7 nao tem o simbolo 0 if ($this->v >= 7) { $inis = 1; //se for versao 7 inclui um primeiro simbolo com valor 0 e imagem $oSymbol = $this->mapa->getSymbolObjectById(1); $adiciona = ms_newLayerObj($this->mapa, $l); $nomel = $l->name; $tematemp = $this->mapa->getlayerbyname($nomel); $c = $tematemp->getClass(0); $e = $c->getstyle(0); $e->set("size", 1); $e->set("width", 1); $ico = $c->createLegendIcon(40, 40); $nimg = $ico->saveWebImage(); $pat = $this->mapa->web->imageurl; $ins .= "<img src='" . $nimg . "' style='cursor:pointer;border: 5px solid #FFFFFF' title='0' onclick='" . $onclick . "'>"; } for ($i = $inis; $i < $ns; ++$i) { $oSymbol = $this->mapa->getSymbolObjectById($i); $nomes = $oSymbol->name; if ($nomes == "") { $nomes = $i; } $adiciona = ms_newLayerObj($this->mapa, $l); $nomel = $l->name; $tematemp = $this->mapa->getlayerbyname($nomel); $c = $tematemp->getClass(0); $e = $c->getstyle(0); $e->set("symbolname", $nomes); $e->set("size", $tamanho); $e->set("width", $width); $ico = $c->createLegendIcon(40, 40); $nimg = $ico->saveWebImage(); $pat = $this->mapa->web->imageurl; $ins .= "<img src='" . $nimg . "' style='cursor:pointer;border: 5px solid #FFFFFF' title=" . $nomes . " onclick='" . $onclick . "'>"; } fwrite($f, "<?php \$res = \"" . $ins . "\";?>"); fclose($f); //copy ($dir."/simbolos".$tipo.".inc",$dir_tmp."/comum/simbolos".$tipo.".inc"); return $ins; } else { $res = ""; include_once $dir . "/simbolos" . $tipo . ".inc"; return $res; } }
function getDataStore($nomelayer, $colunasvalor, $colunanomeregiao, $titulo, $descricao, $ext = "", $mapType = "") { //$indicatorID, $year, $region){ if (!function_exists("versao")) { include dirname(__FILE__) . "/../../classesphp/funcoes_gerais.php"; } $versao = versao(); $versao = $versao["principal"]; $mapa = ms_newMapObj($this->map_file); if ($ext == "") { $mapa = extPadrao($mapa); } else { $e = str_replace(",", " ", $ext); $e = explode(" ", $ext); $extatual = $mapa->extent; $extatual->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3])); } $layer = $mapa->getlayerbyname($nomelayer); $layer->set("template", "none.html"); $existesel = "nao"; if ($this->postgis_mapa != "" && $this->postgis_mapa != " ") { if ($layer->connectiontype == MS_POSTGIS) { $lcon = $layer->connection; if ($lcon == " " || $lcon == "" || in_array($lcon, array_keys($this->postgis_mapa))) { if ($lcon == " " || $lcon == "") { $layer->set("connection", $this->postgis_mapa); } else { $layer->set("connection", $this->postgis_mapa[$lcon]); } } } } $itens = pegaItens($layer, $mapa); carregaquery2($this->map_file, $layer, $mapa); if ($layer->getNumresults() > 0) { $existesel = "sim"; } if ($existesel == "nao") { $layer->querybyrect($mapa->extent); } $layer->open(); $res_count = $layer->getNumresults(); $dataStore = array(); $dataStore['indicators']['valores'] = array("name" => $titulo, "description" => $descricao, "source" => "", "decimals" => 2, "max" => 0, "min" => 0); for ($i = 0; $i < $res_count; $i++) { $valitem = array(); if ($versao >= 6) { $shape = $layer->getShape($layer->getResult($i)); } else { $shape = $layer->getFeature($layer->getResult($i)->shapeindex); } $pt = $shape->getCentroid(); $texto = $shape->values[$colunanomeregiao]; /* if(!mb_detect_encoding($texto,"ISO-8859-1",true)){ $texto = mb_convert_encoding($texto,"ISO-8859-1","UTF-8"); } */ if ($mapType == "bar") { $wkt = ""; } else { $wkt = $shape->toWkt(); } $dataStore['features'][$i] = array("featureID" => $i, "name" => $texto, "lon" => round($pt->x, 6), "lat" => round($pt->y, 6), "wkt" => $wkt); //[0] � o ano foreach ($colunasvalor as $colunavalor) { $valor = $shape->values[$colunavalor]; settype($valor, "float"); //echo $valor; if (is_numeric($valor)) { $valor = number_format($valor, 2, '.', ''); $dataStore['indicators']['valores']['values'][$colunavalor][$i] = $valor; $indicatorYears[$colunavalor] = $colunavalor; $todosV[] = $valor; } } } $fechou = $layer->close(); $dataStore['indicators']['valores']['years'] = $indicatorYears; $dataStore['indicators']['valores']['max'] = max($todosV); $dataStore['indicators']['valores']['min'] = min($todosV); //echo "<pre>"; //var_dump($dataStore); return $dataStore; /* $sqlregion = ''; if ($region) $sqlregion = "region = $region AND"; $sqlyear = ''; if ($year) $sqlyear = "AND year = $year"; // Add features - exclude Antarctica $sql = "SELECT un AS featureID, name, lon, lat, AsText(geom) AS wkt FROM $this->featureTable WHERE $sqlregion un != 10 ORDER BY featureID"; $features = $this->dbc->query($sql); while($row = $features->fetch_array(MYSQLI_ASSOC)) { // First field should be feature id $featureID = array_shift($row); // Add feature to dataStore $dataStore['features'][$featureID] = $row; } $indicatorYears = array(); // Select indicator metadata $sql = "SELECT name, description, source, decimals, (SELECT ROUND(MAX(value),decimals) FROM indicator_values, $this->featureTable WHERE variable=$indicatorID AND indicator_values.area=un $sqlyear) AS max, (SELECT ROUND(MIN(value),decimals) FROM indicator_values, $this->featureTable WHERE variable=$indicatorID AND indicator_values.area=un $sqlyear) AS min FROM $this->indicatorTable WHERE id=$indicatorID"; $result = $this->dbc->query($sql); $indicator = $result->fetch_assoc(); $precision = $indicator['decimals']; // Add indicator to dataStore $dataStore['indicators'][$indicatorID] = $indicator; // Select indicator values (only values that have features) $sql = "SELECT indvalues.area AS featureID, indvalues.year, indvalues.value FROM $this->valuesTable AS indvalues, $this->featureTable WHERE indvalues.variable=$indicatorID AND indvalues.area=un $sqlyear ORDER BY indvalues.value"; // Needed for qunatiles calculation $result = $this->dbc->query($sql); // Add indicator values to dataStore while($row = $result->fetch_row()) { $dataStore['indicators'][$indicatorID]['values'][$row[1]][$row[0]] = number_format($row[2], $precision, '.', ''); // Find all years with values (could also be a separate sql for better performance) $indicatorYears[$row[1]] = $row[1]; } sort($indicatorYears); $dataStore['indicators'][$indicatorID]['years'] = $indicatorYears; return $dataStore; */ }
function __construct($map_file = "", $tema = "", $locaplic = "", $ext = "") { if (!function_exists('ms_newMapObj')) { return false; } if ($locaplic == "") { include dirname(__FILE__) . "/../ms_configura.php"; } if (!function_exists("corRGB")) { include_once dirname(__FILE__) . "/funcoes_gerais.php"; } include dirname(__FILE__) . "/../ms_configura.php"; $this->postgis_mapa = $postgis_mapa; $this->v = versao(); $this->v = $this->v["principal"]; $this->dbaseExiste = false; if (function_exists("dbase_create")) { $this->dbaseExiste = true; } $this->locaplic = $locaplic; if ($map_file != "") { $this->mapa = ms_newMapObj($map_file); substituiConObj($this->mapa, $postgis_mapa); $this->arquivo = str_replace(".map", "", $map_file) . ".map"; $this->tema = $tema; if ($tema != "" && @$this->mapa->getlayerbyname($tema)) { $this->layer = $this->mapa->getlayerbyname($tema); } $this->nome = $tema; if ($ext && $ext != "") { $e = explode(" ", $ext); $extatual = $this->mapa->extent; $extatual->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3])); } } else { $this->mapa = ""; $this->arquivo = $dir_tmp . "/" . nomeRandomico(); } }
function calculaarea($geo) { global $postgis_con; $v = versao(); if ($v["principal"] < 5 && $postgis_con == "") { return "erro. É necessária uma versão maior que 5.0 do Mapserver."; } $g = $geo->towkt(); $shape = ms_shapeObjFromWkt($g); $rect = $shape->bounds; $projInObj = ms_newprojectionobj("proj=longlat,ellps=WGS84,datum=WGS84,no_defs"); $projOutObj = ms_newprojectionobj("proj=laea,lat_0=" . $rect->miny . ",lon_0=" . $rect->minx . ",x_0=500000,y_0=10000000,ellps=GRS67,units=m,no_defs"); $shape->project($projInObj, $projOutObj); $s = $shape->towkt(); $shape = ms_shapeObjFromWkt($s); $area = $shape->getArea(); return $area / 10000; }
function pegaValoresM($mapa, $layer, $itens, $exclui = "nulo", $selecionados = "nao", $chaves = false, $centroide = false) { $versao = versao(); $versao = $versao["principal"]; $prjMapa = $mapa->getProjection(); $prjTema = $layer->getProjection(); $layer->set("template", "none.htm"); $layer->setfilter(""); $indicesel = array(); //pega os valores dos indices dos elementos selecionados para comparacao posterior if ($selecionados == "sim") { $sopen = $layer->open(); if ($sopen == MS_FAILURE) { return "erro"; } $res_count = $layer->getNumresults(); for ($i = 0; $i < $res_count; ++$i) { $result = $layer->getResult($i); $indicesel[] = $result->shapeindex; } $layer->close(); } $valores = array(); $nclasses = $layer->numclasses; if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS) { //$layer->draw(); $sopen = $layer->open(); if ($sopen == MS_FAILURE) { return "erro"; } $res_count = $layer->getNumresults(); //echo $res_count;echo "\n"; for ($i = 0; $i < $res_count; ++$i) { if ($versao >= 6) { $shape = $layer->getShape($layer->getResult($i)); $shp_index = $shape->index; } else { $result = $layer->getResult($i); $shp_index = $result->shapeindex; $shape = $layer->getfeature($shp_index, -1); } if ($selecionados == "sim" && array_search($shp_index, $indicesel) === FALSE) { continue; } $considera = "sim"; //verifica se no registro deve ser considerado if ($exclui != "nulo") { foreach ($itens as $item) { if ($shape->values[$item] == $exclui) { $considera = "nao"; } } } //pega os valores $v = array(); if ($considera == "sim") { //pega os valores dos itens do registro foreach ($itens as $item) { $vitem = $shape->values[$item]; if (!mb_detect_encoding($vitem, "UTF-8", true)) { $vitem = mb_convert_encoding($vitem, "UTF-8", "ISO-8859-1"); } if ($chaves == false) { $v[] = $vitem; } else { $v[$item] = $vitem; } } //pega o centroide //echo $i;echo "\n"; if ($centroide == true) { $c = $shape->getCentroid(); if ($prjTema != "" && $prjMapa != $prjTema) { $projOutObj = ms_newprojectionobj($prjTema); $projInObj = ms_newprojectionobj($prjMapa); $c->project($projInObj, $projOutObj); } $v["centroide"] = "POINT(" . $c->x . " " . $c->y . ")"; } //echo $i;echo "---\n"; //pega a cor da classe onde cai o registro if ($nclasses > 0 && $versao >= 6) { $cx = $layer->getClassIndex($shape); if ($cx > -1) { $classe = $layer->getclass($cx); $cor = $classe->getstyle(0)->color; $v["cores"] = $cor->red . " " . $cor->green . " " . $cor->blue; } } if (count($v) == 1) { $valores[] = $v[0]; } else { $valores[] = $v; } } } $layer->close(); } return $valores; }
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")); } } }
require dirname(__FILE__) . "/../../classesphp/funcoes_gerais.php"; error_reporting(0); $nomes = nomeRandomico(); $map = ms_newMapObj($map_file); $temp = str_replace(".map", "xxx.map", $map_file); $map->save($temp); substituiCon($temp, $postgis_mapa); $map = ms_newMapObj($temp); if ($map->getmetadata("interface") == "googlemaps") { $proj4 = pegaProjecaoDefault("proj4"); $map->setProjection($proj4); $map->set("units", MS_METERS); $map->preparequery(); $map->set("scaledenom", $map->scaledenom * 100000); } $v = versao(); $leb = $eb->label; if ($leb->type == "MS_BITMAP") { $leb->set("type", MS_TRUETYPE); $leb->set("font", "Arial"); } //altera o nome das classes vazias $numlayers = $map->numlayers; for ($i = 0; $i < $numlayers; $i++) { $layer = $map->getlayer($i); if ($layer->data != "" && strtolower($layer->getmetadata("escondido")) != "sim" && strtolower($layer->getmetadata("tema")) != "sim") { if ($layer->numclasses > 0) { $classe = $layer->getclass(0); if ($classe->name == "" || $classe->name == " ") { $classe->set("name", $layer->getmetadata("tema")); }
function mapfilebase($base, $locaplic) { $versao = versao(); $versao = $versao["principal"]; if (isset($base) && $base != "") { if (file_exists($base)) { $f = $base; } else { $f = $locaplic . "/aplicmap/" . $base . ".map"; } } else { $f = ""; if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { $f = $locaplic . "/aplicmap/geral1windowsv" . $versao . ".map"; } else { if ($f == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv' . $versao . '.map')) { $f = "/var/www/i3geo/aplicmap/geral1debianv" . $versao . ".map"; } if ($f == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) { $f = "/var/www/html/i3geo/aplicmap/geral1fedorav" . $versao . ".map"; } if ($f == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) { $f = "/opt/www/html/i3geo/aplicmap/geral1v" . $versao . ".map"; } if ($f == "") { $f = $locaplic . "/aplicmap/geral1v" . $versao . ".map"; } } } return $f; }
function cloneInlineSymbol($layern, $nmapa, $mapa) { $versao = versao(); if ($versao["principal"] > 5) { $numclasses = $layern->numclasses; for ($ci = 0; $ci < $numclasses; $ci++) { $classe = $layern->getclass($ci); $numestilos = $classe->numstyles; for ($ei = 0; $ei < $numestilos; $ei++) { $estilo = $classe->getstyle($ei); if ($estilo->symbolname != "") { $nomesimbolo = $estilo->symbolname; $simbolo = $nmapa->getSymbolObjectById($nmapa->getSymbolByName($nomesimbolo)); if ($simbolo->inmapfile == MS_TRUE || file_exists($nomesimbolo)) { $simbolon = new symbolObj($mapa, $nomesimbolo); $simbolon->set("inmapfile", MS_TRUE); $simbolon->setImagePath($simbolo->imagepath); $simbolon->setPoints($simbolo->getPointsArray()); //$simbolon->setPattern($simbolo->getPatternArray()); $simbolon->set("type", $simbolo->type); //$simbolon->set("antialias",$simbolo->antialias); $simbolon->set("character", $simbolo->character); $simbolon->set("filled", $simbolo->filled); //$simbolon->set("font",$simbolo->font); //$simbolon->set("position",$simbolo->position); $simbolon->set("sizex", $simbolo->sizex); $simbolon->set("sizey", $simbolo->sizey); $simbolon->set("transparent", $simbolo->transparent); $simbolon->set("transparentcolor", $simbolo->transparentcolor); //$simbolon->set("anchorpoint",$simbolo->anchorpoint); } } } } } }
function alterarClasseLabel() { global $codigoMap, $codigoLayer, $locaplic; if (!isset($_GET["text"])) { $_GET["text"] = ""; } else { $_GET["text"] = "[" . $_GET["text"] . "]"; } $dados = array(); $mapfile = $locaplic . "/temas/" . $codigoMap . ".map"; $mapa = ms_newMapObj($mapfile); $layer = $mapa->getlayerbyname($codigoLayer); if (strtoupper($layer->getmetadata("metaestat")) === "SIM") { return "erro. Layer METAESTAT"; } $classe = $layer->getclass($_GET["indiceClasse"]); $v = versao(); $vi = $v["inteiro"]; if ($vi >= 60300) { while ($classe->numlabels > 0) { $classe->removeLabel(0); } } if ($text == "") { if ($vi >= 60300) { $indiceLabel = $classe->addLabel(new labelObj()); $label = $classe->getLabel($indiceLabel); } else { $label = $classe->label; } } elseif ($vi >= 60300 && $classe->numlabels == 0) { if ($wrap != "") { $s = "CLASS LABEL WRAP '{$wrap}' TEXT '" . $_GET["text"] . "' END END"; $classe->updateFromString($s); } else { $s = "CLASS LABEL TEXT '" . $_GET["text"] . "' END END"; $classe->updateFromString($s); } } if ($vi >= 60300) { $label = $classe->getLabel(0); } else { $label = $classe->label; } if ($wrap != "") { $label->set("maxlength", 1); } if ($_GET["fonte"] != "bitmap") { //para funcionar na versao 7 do mapserver $label->updateFromString("LABEL type truetype END"); $label->set("font", $_GET["fonte"]); $label->set("size", $_GET["tamanho"]); } else { //para funcionar na versao 7 do mapserver $label->updateFromString("LABEL type bitmap END"); $t = MS_TINY; if ($_GET["tamanho"] > 5) { $t = MS_TINY; } if ($_GET["tamanho"] >= 7) { $t = MS_SMALL; } if ($_GET["tamanho"] >= 10) { $t = MS_MEDIUM; } if ($_GET["tamanho"] >= 12) { $t = MS_LARGE; } if ($_GET["tamanho"] >= 14) { $t = MS_GIANT; } $label->set("size", $t); } if ($label != "") { //$label->set("type",$type); corE($label, $_GET["backgroundcolor"], "backgroundcolor"); corE($label, $_GET["backgroundshadowcolor"], "backgroundshadowcolor"); corE($label, $_GET["color"], "color"); corE($label, $_GET["outlinecolor"], "outlinecolor"); if (!empty($_GET["sombra"]) && !empty($_GET["backgroundshadowsizex"])) { corE($label, $_GET["sombra"], "backgroundshadowcolor", $_GET["backgroundshadowsizex"], $_GET["backgroundshadowsizey"]); } $label->set("shadowsizex", $_GET["shadowsizex"]); $label->set("shadowsizey", $_GET["shadowsizey"]); //$label->set("backgroundshadowsizex",$backgroundshadowsizex); //$label->set("backgroundshadowsizey",$backgroundshadowsizey); $label->set("minsize", $_GET["minsize"]); $label->set("maxsize", $_GET["maxsize"]); //$label->set("position",$position); $label->set("offsetx", $_GET["offsetx"]); $label->set("offsety", $_GET["offsety"]); $label->set("angle", $_GET["angle"]); //$label->set("autoangle",$autoangle); //$label->set("buffer",$buffer); //$label->set("antialias",$antialias); $label->set("wrap", $_GET["wrap"]); $label->set("minfeaturesize", $_GET["minfeaturesize"]); $label->set("mindistance", $_GET["mindistance"]); $label->set("partials", $_GET["partials"]); $label->set("force", $_GET["force"]); $label->set("encoding", $_GET["encoding"]); $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[$_GET["position"]]); } $mapa->save($mapfile); removeCabecalho($mapfile); return "ok"; }
function mudaTransparencia($valor) { $v = versao(); foreach ($this->grupo as $lg) { $ll = $this->mapa->getlayerbyname($lg); $ll->setmetaData("cache", ""); if ($this->v == 4) { $ll->set("transparency", $valor); return "ok"; } if ($this->v < 7) { $ll->set("opacity", $valor); return "ok"; } if ($this->v >= 7) { //$ll->composite->opacity = $valor; //$ll->set("opacity",$valor); //$ll->updateFromString('LAYER COMPOSITE OPACITY '.$valor.'END END'); $numclasses = $ll->numclasses; for ($i = 0; $i < $numclasses; ++$i) { $classe = $this->layer->getclass($i); $numestilos = $classe->numstyles; for ($j = 0; $j < $numestilos; ++$j) { $estilo = $classe->getstyle($j); $estilo->set("opacity", $valor); } } return "ok"; } } }
function verificaMiniatura($map, $tipo, $admin = false) { global $locaplic, $versao, $base, $postgis_mapa; if ($versao == "") { $versao = versao(); $versao = $versao["principal"]; } ms_ResetErrorList(); $tema = ""; $map = str_replace("\\", "/", $map); $map = basename($map); $extensao = ".map"; if (file_exists($locaplic . '/temas/' . $map)) { $tema = $locaplic . '/temas/' . $map; } else { if (file_exists($locaplic . '/temas/' . $map . '.gvp')) { $extensao = ".gvp"; } $tema = $locaplic . '/temas/' . $map . $extensao; } if ($tema != "") { if (isset($base) && $base != "") { if (file_exists($base)) { $f = $base; } else { $f = $locaplic . "/aplicmap/" . $base . ".map"; } if (!file_exists($base)) { echo "<div class='alert alert-danger'>ARQUIVO {$base} NÂO FOI ENCONTRADO. CORRIJA ISSO EM ms_configura.php"; exit; } } else { $f = ""; if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { $f = $locaplic . "/aplicmap/geral1windowsv" . $versao . ".map"; } else { if ($f == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv' . $versao . '.map')) { $f = "/var/www/i3geo/aplicmap/geral1debianv" . $versao . ".map"; } if ($f == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) { $f = "/var/www/html/i3geo/aplicmap/geral1fedorav" . $versao . ".map"; } if ($f == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) { $f = "/opt/www/html/i3geo/aplicmap/geral1v" . $versao . ".map"; } if ($f == "") { $f = $locaplic . "/aplicmap/geral1v" . $versao . ".map"; } } } $mapa = ms_newMapObj($f); if ($extensao == ".map") { if (@ms_newMapObj($tema)) { $nmapa = ms_newMapObj($tema); } else { echo "<div class='alert alert-danger'>erro no arquivo {$tema} </div>"; return; } $dados = ""; $numlayers = $nmapa->numlayers; for ($i = 0; $i < $numlayers; $i++) { $layern = $nmapa->getlayer($i); $layern->set("status", MS_DEFAULT); cloneInlineSymbol($layern, $nmapa, $mapa); ms_newLayerObj($mapa, $layern); autoClasses($layern, $mapa, $locaplic); if ($layern->data == "") { $dados = $layern->connection; } else { $dados = $layern->data; } $pegarext = $teman->name; } if (isset($postgis_mapa)) { if ($postgis_mapa != "") { $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]); } } } } } } } zoomTemaMiniatura($pegarext, $mapa); } if ($extensao == ".gvp") { include_once $locaplic . "/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"; $gm = new gvsig2mapfile($tema); $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" || $tipo == "todos") { $mapa->setsize(50, 50); $sca = $mapa->scalebar; $sca->set("status", MS_OFF); $objImagemM = @$mapa->draw(); //if ($objImagemM == "" || $objImagemM == MS_FAILURE) //{echo "Problemas ao gerar o mapa<br>";return;} $weboM = $mapa->web; $urlM = $weboM->imageurl . "/" . $map; } if ($tipo == "grande" || $tipo == "todos") { $mapa->setsize(300, 300); $sca = $mapa->scalebar; $sca->set("status", MS_OFF); $objImagemG = @$mapa->draw(); //if ($objImagemG == "" || $objImagemG == MS_FAILURE) //{echo "Problemas ao gerar o mapa<br>";return;} $weboG = $mapa->web; $urlG = $weboG->imageurl . "/" . $map; } if ($tipo == "mini" || $tipo == "todos") { if (!$objImagemM) { echo "Problemas ao gerar o mapa<br>"; $error = ""; $error = ms_GetErrorObj(); while ($error && $error->code != MS_NOERR) { echo "<div class='alert alert-danger'>Error in %s: %s</div>", $error->routine, $error->message; $error = $error->next(); } return; } if ($objImagemM->imagepath == "") { echo "<div class='alert alert-danger'>Erro IMAGEPATH vazio</div>"; return; } $nomecM = $objImagemM->imagepath . $map . ".mini.png"; $objImagemM->saveImage($nomecM); } if ($tipo == "grande" || $tipo == "todos") { if (!$objImagemG) { echo "<div class='alert alert-danger'>Problemas ao gerar o mapa</div>"; $error = ""; $error = ms_GetErrorObj(); while ($error && $error->code != MS_NOERR) { echo "<div class='alert alert-danger'>Error in %s: %s</div>", $error->routine, $error->message; $error = $error->next(); } return; } if ($objImagemG->imagepath == "") { echo "<div class='alert alert-danger'>Erro IMAGEPATH vazio</div>"; return; } $nomecG = $objImagemG->imagepath . $map . ".grande.png"; $objImagemG->saveImage($nomecG); } if ($admin === false) { if ($tipo == "mini" || $tipo == "todos") { echo "<img class='img-thumbnail' src='" . $urlM . ".mini.png' />"; } if ($tipo == "grande" || $tipo == "todos") { echo "<img class='img-thumbnail' src='" . $urlG . ".grande.png' />"; } } // //copia a imagem // if ($admin === true) { $dir = $locaplic . "/temas/miniaturas"; $mini = $dir . "/" . $map . ".map.mini.png"; $grande = $dir . "/" . $map . ".map.grande.png"; if (file_exists($mini)) { unlink($mini); } if (file_exists($grande)) { unlink($grande); } copy($objImagemG->imagepath . $map . ".grande.png", $grande); copy($objImagemM->imagepath . $map . ".mini.png", $mini); } } }
<?php include_once dirname(__FILE__) . "/../../../../admin/php/login.php"; include_once dirname(__FILE__) . "/../../../../admin/php/conexao.php"; error_reporting(0); if (isset($_POST["texto"])) { $gravarTexto = $_POST["texto"]; $_POST["texto"] = ""; } $versao = versao(); $versao = $versao["principal"]; if (verificaOperacaoSessao("admin/html/editortexto") === false) { header("HTTP/1.1 403 Vc nao pode realizar essa operacao"); exit; } error_reporting(0); function textoMapfile($codigo) { global $locaplic, $dbhw; $mapfile = $locaplic . "/temas/" . $codigo . ".map"; if (!file_exists($mapfile)) { return "Arquivo {$codigo} não existe."; } // testa try { ms_newMapObj($mapfile); } catch (Exception $e) { $texto = file_get_contents($mapfile); if (mb_detect_encoding($texto, 'UTF-8, ISO-8859-1') == "ISO-8859-1") { return utf8_encode($texto); } else {
function pegaValores($mapa, $layer, $item, $numerico = false, $ignorar = "") { $layer->set("template", "none.htm"); $layer->setfilter(""); $versao = versao(); $versao = $versao["principal"]; $ignorararray = explode(",", $ignorar); if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS) { if ($layer->type == MS_LAYER_RASTER) { if ($item == "pixel") { $item = "value_0"; } } $sopen = $layer->open(); if ($sopen == MS_FAILURE) { return "erro"; } $res_count = $layer->getNumresults(); $valitem = array(); for ($i = 0; $i < $res_count; ++$i) { if ($versao >= 6) { $shape = $layer->getShape($layer->getResult($i)); } else { $result = $layer->getResult($i); $shp_index = $result->shapeindex; $shape = $layer->getfeature($shp_index, -1); } $v = trim($shape->values[$item]); if ($numerico) { if (is_numeric($v)) { if ($ignorar == "") { $valitem[] = $v; } else { //if ($v != $ignorar) if (!in_array($v, $ignorararray)) { $valitem[] = $v; } } } } else { if ($ignorar == "") { $valitem[] = $v; } else { if (!in_array($v, $ignorararray)) { $valitem[] = $v; } } } } $fechou = $layer->close(); } $layer->close(); return $valitem; }