function converteWMC($locmapserv, $h) { $protocolo = explode("/", $_SERVER['SERVER_PROTOCOL']); $protocolo = $protocolo[0]; $protocolo1 = strtolower($protocolo) . '://' . $_SERVER['SERVER_NAME']; $protocolo = strtolower($protocolo) . '://' . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT']; $urli3geo = str_replace("/classesphp/mapa_controle.php", "", $protocolo . $_SERVER["PHP_SELF"]); $nomews = str_replace(".map", "wmc.map", $this->arquivo); $nomeurl = $locmapserv . "?map=" . $nomews; $nomeogc = $urli3geo . "/ogc.php?tema=" . $nomews; $w = $this->mapa->web; $w->set("template", ""); // adiciona os parametros no nivel do mapa $this->mapa->setmetadata("wms_title", "i3Geo"); $this->mapa->setmetadata("wms_onlineresource", "http://" . $h . $nomeurl); $projecao = pegaProjecaoDefault("epsg"); $this->mapa->setmetadata("wms_srs", "EPSG:" . $projecao); $this->mapa->setmetadata("wms_getcontext_enabled", "1"); foreach ($this->layers as $layer) { if ($layer->connectiontype != 7 && $layer->connectiontype != 9) { $n = pegaNome($layer); $layer->setmetadata("wms_title", $n); $codigo = $layer->getmetadata("nomeoriginal"); if ($codigo == "") { $codigo = $layer->name; } $layer->setmetadata("wms_server_version", "1.0.0"); $layer->setmetadata("wms_name", $codigo); //$layer->setmetadata("wms_srs","EPSG:4291 EPSG:4326"); $layer->setmetadata("WMS_INCLUDE_ITEMS", "all"); $layer->setmetadata("wms_onlineresource", $nomeogc . "&layer=" . $layer->name); $layer->setmetadata("gml_include_items", "all"); $layer->setmetadata("wms_format", "image/png"); $layer->setmetadata("wms_formatlist", "image/gif,image/png,image/png; mode=24bit,image/jpeg,image/wbmp,image/tiff"); $layer->set("dump", MS_TRUE); $layer->set("status", "ON"); $layer->set("template", "none.htm"); $c = $layer->getclass(0); if ($c->name == "") { $c->name = " "; } if ($layer->connectiontype != "WS_WMS" && $layer->getmetadata("permiteogc") == "" && $layer->getmetadata("TEMALOCAL") == "") { if (ms_GetVersionInt() > 50201) { $layer->setconnectiontype(MS_WMS); } else { $layer->set("connectiontype", MS_WMS); } $data = $urli3geo . "/ogc.php?tema=" . $codigo; $layer->set("connection", $data); $layer->set("data", ""); if (file_exists("../temas/" . $codigo . ".map")) { $layer->setmetadata("wms_onlineresource", $data); } } } else { $layer->setmetadata("wms_onlineresource", $layer->connection); } } $eb = $this->mapa->scalebar; $eb->set("status", MS_OFF); $this->mapa->save($nomews); return $nomeurl . "&service=WMS&request=GetContext&version=1.1.0"; }
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; } }
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")); } }
function selecao2tema($locaplic, $dir_tmp) { if (!$this->layer) { return "erro"; } $this->layer->setfilter(""); $nomeshp = criaSHP($this->nome, $this->arquivo, $locaplic, $dir_tmp, true, "", false); $novolayer = criaLayer($this->mapa, $this->layer->type, MS_DEFAULT, "Seleção de " . pegaNome($this->layer) . " (" . $this->nome . ")", $metaClasse = "SIM"); if ($this->layer->getprojection() != "") { $novolayer->setprojection($this->layer->getprojection()); } $novolayer->set("data", $nomeshp . ".shp"); $novolayer->set("name", basename($nomeshp)); $down = "nao"; $down = $this->layer->getmetadata("download"); if ($down == "") { $down = "sim"; } $novolayer->setmetadata("DOWNLOAD", $down); $tipo = $this->layer->type; if ($this->layer->getmetadata("TABELA") != '') { $novolayer->setmetadata("TABELA", "NAO"); } $novolayer->setmetadata("TEMALOCAL", "SIM"); $novolayer->setfilter(""); return "ok"; }
function dissolvePoligono($item, $locaplic) { if (!$this->layer) { return "erro"; } set_time_limit(180); // para manipular dbf if (!isset($item)) { $item = ""; } if ($this->dbaseExiste == false) { include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php"; } $shapes = retornaShapesSelecionados($this->layer, $this->arquivo, $this->mapa); $indices = array(); foreach ($shapes as $shape) { if ($item != "") { $valor = $shape->values[$item]; } else { $valor = "nenhum"; } if (!isset($indices[$valor])) { $indices[$valor] = array($shape); } else { $indices[$valor] = array_merge($indices[$valor], array($shape)); } } $dissolve = array(); foreach ($indices as $shapes) { foreach ($shapes as $shape) { if ($item != "") { $valor = $shape->values[$item]; } else { $valor = "nenhum"; } if (!isset($dissolve[$valor])) { $dissolve[$valor] = $shape; } else { if ($shape->type != MS_SHAPE_POLYGON) { for ($l = 0; $l < $shape->numlines; $l++) { $shape1 = $dissolve[$valor]; $linha = $shape->line($l); $shape1->add($linha); } $dissolve[$valor] = $shape1; } else { $dissolve[$valor] = $shape->union($dissolve[$valor]); } } } } // // cria o novo shapefile // $nomefinal = nomeRandomico(); $nomeshp = $this->diretorio . "/" . $nomefinal; $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON); // cria o dbf $def = array(); if ($item == "") { $item = "nenhum"; } $def[] = array($item, "C", "254"); if ($this->dbaseExiste == false) { $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"; if ($this->dbaseExiste == false) { $db = xbase_open($dbname, 2); } else { $db = dbase_open($dbname, 2); } $classes = array_keys($dissolve); foreach ($classes as $classe) { $novoshpf->addShape($dissolve[$classe]); if ($this->dbaseExiste == false) { xbase_add_record($db, array($classe)); } else { dbase_add_record($db, array($classe)); } } if ($this->dbaseExiste == false) { xbase_close($db); } else { dbase_close($db); } // // adiciona o novo layer no mapa // $n = pegaNome($this->layer); $novolayer = criaLayer($this->mapa, MS_LAYER_POLYGON, MS_DEFAULT, "Dissolve de " . $n, $metaClasse = "SIM"); $novolayer->set("data", $nomeshp . ".shp"); $novolayer->setmetadata("DOWNLOAD", "SIM"); $novolayer->setmetadata("TEMALOCAL", "SIM"); if (file_exists($this->qyfile)) { unlink($this->qyfile); } return "ok"; }
foreach ($codigosTema as $c) { $codigoTema = $c["tema"]; if (file_exists($locaplic . "/temas/" . $codigoTema . ".map")) { if (@ms_newMapobj($locaplic . "/temas/" . $codigoTema . ".map")) { $nmap = ms_newMapobj($locaplic . "/temas/" . $codigoTema . ".map"); $nmap->setmetadata("ows_enable_request", "*"); $ts = $nmap->getalllayernames(); foreach ($ts as $t) { if ($oMap->getlayerbyname($t) == "") { $l = $nmap->getlayerbyname($t); $extensao = $l->getmetadata("EXTENSAO"); if ($extensao == "") { $extensao = $extensaoMap; } $l->setmetadata("wms_extent", $extensao); $l->setmetadata("ows_title", pegaNome($l)); $l->setmetadata("ows_srs", $listaepsg); $l->set("status", MS_OFF); $l->setmetadata("gml_include_items", "all"); $l->set("dump", MS_TRUE); $l->setmetadata("WMS_INCLUDE_ITEMS", "all"); $l->setmetadata("WFS_INCLUDE_ITEMS", "all"); if ($l->getmetadata("ows_metadataurl_href") == "") { $l->setmetadata("ows_metadataurl_href", $c["fonte"]); $l->setmetadata("ows_metadataurl_type", "TC211"); $l->setmetadata("ows_metadataurl_format", "text/html"); } if (file_exists($locaplic . "/temas/miniaturas/" . $t . ".map.mini.png")) { $mini = $proto . $server . dirname($_SERVER['PHP_SELF']) . "/temas/miniaturas/" . $t . ".map.mini.png"; $l->setmetadata("wms_attribution_logourl_format", "image/png"); $l->setmetadata("wms_attribution_logourl_height", "50");
function verifica($mapfile, $tema) { include dirname(__FILE__) . "/../ms_configura.php"; $this->postgis_mapa = $postgis_mapa; $map = ms_newMapObj($mapfile); substituiConObj($this->mapa, $postgis_mapa); $map->preparequery(); $escala = $map->scaledenom; $multilayer = 0; $temas = array(); $layers = array(); $nomes = array(); $nomesvisiveis = array(); $temasvisiveis = array(); $numlayers = $map->numlayers; for ($i = 0; $i < $numlayers; ++$i) { $layer = $map->getlayer($i); $temai = $layer->name; $testa = 0; //verifica se o tema é visivel na escala $mins = $layer->minscaledenom; $maxs = $layer->maxscaledenom; if ($mins != $maxs) { $testa = 1; if ($mins > 0) { if ($escala >= $mins) { $testa = 0; } } if ($maxs > 0) { if ($escala <= $maxs) { $testa = 0; } else { $testa = 1; } } if ($mins > 0 && $maxs > 0) { if ($escala >= $mins && $escala <= $maxs) { $testa = 0; } else { $testa = 1; } } } if (strtoupper($layer->getmetadata("escondido")) != "SIM") { if ($layer->group == $tema && $layer->type != 4) { $multilayer = 1; $temas[] = $temai; $layers[] = $layer; $pn = pegaNome($layer); $nomes[] = $pn; if ($testa == 0) { $nomesvisiveis[] = $pn; $temasvisiveis[] = $temai; } } } } $this->resultado = $multilayer; $this->temas = $temas; $this->layers = $layers; $this->nomes = $nomes; $this->nomesvisiveis = $nomesvisiveis; $this->temasvisiveis = $temasvisiveis; }
function listaItens() { //verifica se o tema é um grupo e cria um array com a lista de temas $vermultilayer = new vermultilayer(); $vermultilayer->verifica($this->arquivo, $this->nome); if ($vermultilayer->resultado == 1) { // o tema e multi layer $l = $vermultilayer->temasvisiveis; } else { $l[] = $this->nome; } //pega os itens de cada layer $lista = array(); foreach ($l as $tema) { $layer = $this->mapa->getlayerbyname($tema); $layer->set("template", "none.htm"); //pega o nome correto do tema $nometmp = pegaNome($layer, "UTF-8"); $nomestemas[] = $nometmp; if ($layer->data != "" || $layer->connectiontype == 7) { $items = pegaItens($layer, $this->mapa); //pega os alias if ($this->layer->getmetadata("itensdesc") != "") { $alias = array(); $aliasdesc = explode(",", $this->layer->getmetadata("itensdesc")); $aliasitens = explode(",", $this->layer->getmetadata("itens")); $aliasc = array_combine($aliasitens, $aliasdesc); if (strtoupper($this->layer->getmetadata("convcaracter")) == "NAO") { $convC = false; } else { $convC = true; } foreach ($items as $i) { if ($aliasc[$i]) { if ($convC) { $alias[$i] = $this->converte($aliasc[$i]); } else { $alias[$i] = $aliasc[$i]; } } else { $alias[$i] = $i; } } } foreach ($items as $item) { if ($alias[$item]) { $a = $alias[$item]; } else { $a = ""; } $lista[] = array("item" => $item, "nome" => $nometmp, "tema" => $tema, "alias" => $a); } } } return array("valores" => $lista, "temas" => $l, "nomes" => $nomestemas); }