Esempio n. 1
0
function listaRSSwsARRAY()
{
    global $cp, $rss, $locaplic, $tipo;
    if (!isset($tipo)) {
        $tipo = "GEORSS";
    }
    include_once "{$locaplic}/classesphp/funcoes_gerais.php";
    include_once "{$locaplic}/admin/php/xml.php";
    include_once "{$locaplic}/ms_configura.php";
    $rsss = explode("|", $rss);
    if (count($rsss) == 0) {
        $rsss = array(" ");
    }
    $erro = "Erro. Nao foi possivel ler o arquivo";
    $protocolo = explode("/", $_SERVER['SERVER_PROTOCOL']);
    $urli3geo = strtolower($protocolo[0]) . "://" . $_SERVER['HTTP_HOST'] . "/" . basename($locaplic);
    foreach ($rsss as $r) {
        if ($r == "" || $r == " ") {
            if ($tipo == "GEORSS") {
                $canali = simplexml_load_string(geraXmlGeorss($locaplic));
                $linkrss = $urli3geo . "/admin/xmlgeorss.php";
            }
            if ($tipo == "KML") {
                $canali = simplexml_load_string(geraXmlKmlrss($locaplic));
                $linkrss = $urli3geo . "/admin/xmlkmlrss.php";
            }
            if ($tipo == "WMS" || $tipo == "WMS-Tile") {
                $canali = simplexml_load_string(geraXmlWMS($locaplic));
                $linkrss = $urli3geo . "/admin/xmlservicoswms.php";
            }
            if ($tipo == "WMSMETAESTAT") {
                $canali = simplexml_load_string(geraXmlWMSmetaestat($locaplic));
                $linkrss = $urli3geo . "/admin/xmlservicoswms.php";
            }
            if ($tipo == "WS") {
                $canali = simplexml_load_string(geraXmlWS($locaplic));
                $linkrss = $urli3geo . "/admin/xmlservicosws.php";
            }
            if ($tipo == "DOWNLOAD") {
                $canali = simplexml_load_string(geraXmlDownload($locaplic));
                $linkrss = $urli3geo . "/admin/xmllinksdownload.php";
            }
        } else {
            $canali = simplexml_load_file($rss);
        }
        if ($r != "") {
            $linhas["rss"] = "<a href='" . $r . "' target=blank ><img style='border:0px solid white;' src='../../imagens/rss.gif' /></a>";
        } else {
            $linhas["rss"] = "<a href='" . $linkrss . "' target=blank ><img style='border:0px solid white;' src='../../imagens/rss.gif' /></a>";
        }
        //var_dump($canali);
        $canais = array();
        foreach ($canali->channel->item as $item) {
            $canais[] = array("id_ws" => ixml($item, "id"), "title" => ixml($item, "title"), "description" => ixml($item, "description"), "link" => ixml($item, "link"), "author" => ixml($item, "author"), "nacessos" => ixml($item, "nacessos"), "nacessosok" => ixml($item, "nacessosok"), "tipo_ws" => ixml($item, "tipo"));
        }
        $linhas["canais"] = $canais;
    }
    $cp->set_data($linhas);
}
Esempio n. 2
0
 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";
 }
Esempio n. 3
0
function georssCanais($servico, $map_file, $dir_tmp, $locaplic)
{
    $xml = simplexml_load_file($servico);
    //var_dump($xml);
    foreach ($xml->channel as $c) {
        $resultado[] = array("title" => ixml($c, "title"), "link" => ixml($c, "link"), "description" => ixml($c, "description"), "category" => ixml($c, "category"));
    }
    //var_dump($resultado);
    return $resultado;
}
Esempio n. 4
0
 function fonteTema($tema)
 {
     include_once $this->locaplic . "/admin/php/xml.php";
     require $this->locaplic . "/classesphp/classe_menutemas.php";
     $menutemas = new Menutemas("", "", "", $this->locaplic);
     $linkfonte = "erro";
     $tipo = "";
     $this->xml = "";
     foreach ($menutemas->pegaListaDeMenus() as $menu) {
         if (!isset($menu["url"])) {
             $menu["url"] = "";
         }
         //para efeitos de compatibilidade entre vers&otilde;es do i3geo
         $ondexml = $menu["arquivo"];
         if ($menu["url"] != "") {
             $ondexml = $menu["url"];
         }
         $verificaXml = false;
         if ($ondexml != "") {
             $verificaXml = simplexml_load_file($ondexml);
             if ($verificaXml) {
                 $this->xml[] = $verificaXml;
             }
         } else {
             $verificaXml = simplexml_load_string(geraXmlMenutemas(implode(" ", $this->perfil), $menu["idmenu"], $tipo, $this->locaplic));
             if ($verificaXml) {
                 $this->xml[] = $verificaXml;
             }
         }
         if (!$verificaXml) {
             $this->xml[] = simplexml_load_string(geraXmlMenutemas(implode(" ", $this->perfil), $menu["idmenu"], $tipo, $this->locaplic));
         }
     }
     foreach ($this->xml as $xml) {
         $subgrupo = array();
         foreach ($xml->GRUPO as $grupo) {
             foreach ($grupo->SGRUPO as $sgrupo) {
                 foreach ($sgrupo->TEMA as $t) {
                     $link = ixml($t, "TLINK");
                     $tid = ixml($t, "TID");
                     if ($tid == $tema) {
                         $linkfonte = $link;
                     }
                 }
             }
         }
     }
     return $linkfonte;
 }
Esempio n. 5
0
 function abrePrancha($atlasId, $pranchaId, $map_file, $locaplic)
 {
     $p = array();
     $temasa = array();
     $layers = array();
     $mapa = ms_newMapObj($map_file);
     $numlayers = $mapa->numlayers;
     for ($i = 0; $i < $numlayers; ++$i) {
         $l = $mapa->getlayer($i);
         if ($l->getmetadata("ATLAS") != "nao") {
             $l->set("status", MS_DELETE);
         }
     }
     $mapa->save(str_replace(".map", "", $map_file) . ".map");
     $mp = "";
     foreach ($this->xml->ATLAS as $s) {
         $ida = ixml($s, "ID");
         if ($ida == $atlasId) {
             foreach ($s->PRANCHAS as $pranchas) {
                 foreach ($pranchas->PRANCHA as $prancha) {
                     if ($pranchaId == ixml($prancha, "ID")) {
                         $link = ixml($prancha, "LINKMAISINFO");
                         $w = ixml($prancha, "WABERTURA");
                         $h = ixml($prancha, "HABERTURA");
                         $mp = ixml($prancha, "MAPEXT");
                         //pega os temas
                         foreach ($prancha->TEMAS as $temas) {
                             foreach ($temas->TEMA as $tema) {
                                 $codigo = ixml($tema, "CODIGO");
                                 $ligado = ixml($tema, "LIGADO");
                                 if ($codigo != "") {
                                     $temasa[] = $codigo;
                                     if (strtolower($ligado) == "sim") {
                                         $layers[] = $codigo;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (count($temasa) > 0) {
         include_once "classe_mapa.php";
         $mapa = "";
         $m = new Mapa($map_file);
         $m->adicionaTema(implode(",", $temasa), $locaplic, "nao");
         $m->salva();
         $mapa = ms_newMapObj($map_file);
         $numlayers = $mapa->numlayers;
         for ($i = 0; $i < $numlayers; ++$i) {
             $l = $mapa->getlayer($i);
             if ($l->getmetadata("ATLAS") != "nao") {
                 $l->set("status", MS_OFF);
             }
         }
         foreach ($layers as $t) {
             $layer = $mapa->getlayerbyname($t);
             $layer->set("status", MS_DEFAULT);
         }
         $mapa->save(str_replace(".map", "", $map_file) . ".map");
     }
     //verifica extens&atilde;o geogr&aacute;fica
     $newext = array();
     if ($mp != "") {
         $ext = $mapa->extent;
         $newext = array();
         $temp = explode(",", $mp);
         foreach ($temp as $t) {
             if ($t != "") {
                 $newext[] = $t;
             }
         }
         if (count($newext) == 4) {
             $ext->setextent($newext[0], $newext[1], $newext[2], $newext[3]);
         }
         $mapa->save(str_replace(".map", "", $map_file) . ".map");
     }
     if (!function_exists("sobeAnno")) {
         include_once "funcoes_gerais.php";
     }
     sobeAnno($map_file);
     if ($w == "") {
         $w = 300;
     }
     if ($h == "") {
         $h = 300;
     }
     return array("link" => $link, "w" => $w, "h" => $h, "mapexten" => implode(" ", $newext));
 }