Exemplo n.º 1
0
 function redesenhaEntorno()
 {
     $nomes = nomeRandomico();
     $this->mapa->prepareimage();
     $e = $this->mapa->extent;
     $w = $this->mapa->width;
     $h = $this->mapa->height;
     $s = $this->mapa->scaledenom;
     $this->mapa = desligamargem($this->mapa);
     $pt = ms_newPointObj();
     //desenha o leste
     $pt->setXY($w + $w / 2, $h / 2);
     $this->mapa->zoompoint(0, $pt, $w, $h, $e);
     $nomeL = gravaImagemMapa($this->mapa);
     //desenha o oeste
     $pt->setXY(0 - $w / 2, $h / 2);
     $this->mapa->zoomscale($s * 2, $pt, $w, $h, $e);
     $nomeO = gravaImagemMapa();
     //desenha o norte
     $pt->setXY($w / 2, 0 - $h);
     $this->mapa->zoomscale($s * 2, $pt, $w, $h, $e);
     $nomeN = gravaImagemMapa();
     //desenha o sul
     $pt->setXY($w / 2, $h * 2);
     $this->mapa->zoomscale($s * 2, $pt, $w, $h, $e);
     $nomeS = gravaImagemMapa();
     return "var imagens=['" . $nomeL["url"] . "','" . $nomeO["url"] . "','" . $nomeN["url"] . "','" . $nomeS["url"] . "'];";
 }
Exemplo n.º 2
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;
     }
 }
Exemplo n.º 3
0
 function capturaGeometrias($dir_tmp, $imgdir, $nome = "")
 {
     if (!$this->layer) {
         return "erro";
     }
     $this->mapa->setsize(30, 30);
     $ext = $this->mapa->extent;
     $sb = $this->mapa->scalebar;
     $sb->set("status", MS_OFF);
     $items = pegaItens($this->layer);
     $final["layer"] = pegaNome($this->layer, "UTF-8");
     $shapes = retornaShapesSelecionados($this->layer, $this->arquivo, $this->mapa);
     $registros = array();
     $i = 0;
     foreach ($shapes as $shape) {
         $valitem = array();
         foreach ($items as $item) {
             $v = trim($shape->values[$item]);
             if (function_exists("mb_convert_encoding")) {
                 $v = mb_convert_encoding($v, "UTF-8", "ISO-8859-1");
             }
             $valitem[] = array("item" => $item, "valor" => $v);
         }
         $wktgeo = $shape->toWkt();
         if ($wktgeo != "") {
             $fechou = $this->layer->close();
             $bounds = $shape->bounds;
             //gera imagem
             $d = 0.01;
             //se for do tipo ponto, faz um deslocamento do extent
             if ($shape->type == 2) {
                 $d = 0;
             }
             $ext->setextent($bounds->minx - $d, $bounds->miny - $d, $bounds->maxx + $d, $bounds->maxy + $d);
             $im = gravaImagemMapa($this->mapa);
             $registros[] = array("id" => $i, "wkt" => $wktgeo, "valores" => $valitem, "imagem" => $im["url"]);
             $abriu = $this->layer->open();
         } else {
             return "erro";
         }
         $i++;
     }
     $fechou = $this->layer->close();
     if (count($registros) > 0) {
         $final["dados"] = $registros;
         //salva arquivo
         $nome == "" ? $nome = nomerandomico(15) : ($nome = str_replace(" ", "_", $nome));
         $arq = $dir_tmp . "/" . $imgdir . "/" . $nome . "keo";
         if (file_exists($arq)) {
             unlink($arq);
         }
         $fp = fopen($arq, "w");
         $r = serialize($final);
         fwrite($fp, $r);
         fclose($fp);
     }
     return "ok";
 }
Exemplo n.º 4
0
 function funcoesGeometrias($dir_tmp, $imgdir, $lista, $operacao)
 {
     $lista = explode(",", $lista);
     $dir = $dir_tmp . "/" . $imgdir . "/";
     $geometrias = array();
     $valoresoriginais = array();
     $calculo = array();
     foreach ($lista as $l) {
         $geos = $this->unserializeGeo($dir . $l);
         foreach ($geos["dados"] as $geo) {
             $geometrias[] = $geo["wkt"];
             $valoresoriginais = array_merge($valoresoriginais, $geo["valores"]);
         }
     }
     $calculo[]["gwkt"] = $this->aplicaFuncaoListaWKT($geometrias, $operacao);
     $nomegeo = "";
     if (count($calculo) > 0) {
         $final["layer"] = $operacao . " " . implode(" ", $lista);
         $final["dados"][] = array("id" => "0", "wkt" => $calculo[0]["gwkt"], "valores" => $valoresoriginais, "imagem" => "");
         $nomegeo = $dir . nomerandomico(10) . "keo";
         $this->serializeGeo($nomegeo, $final);
         $ext = $this->mapa->extent;
         $minx = $ext->minx;
         $miny = $ext->miny;
         $maxx = $ext->maxx;
         $maxy = $ext->maxy;
         $h = $this->mapa->height;
         $w = $this->mapa->width;
         $nomelayer = $this->incmapageometrias($dir_tmp, $imgdir, basename($nomegeo));
         if ($nomelayer != "erro") {
             $nlayer = $this->mapa->getlayerbyname($nomelayer);
             $bounds = $nlayer->getExtent();
             $this->mapa->setsize(30, 30);
             $sb = $this->mapa->scalebar;
             $statusoriginal = $sb->status;
             $sb->set("status", MS_OFF);
             $ext->setextent($bounds->minx, $bounds->miny, $bounds->maxx, $bounds->maxy);
             $imagem = gravaImagemMapa($this->mapa);
             $this->mapa->setsize($w, $h);
             $ext->setextent($minx, $miny, $maxx, $maxy);
             $nlayer->set("status", MS_DELETE);
             $sb->set("status", $statusoriginal);
             $this->salva();
             $final = array();
             $final["layer"] = $operacao . " " . implode(" ", $lista);
             $final["dados"][] = array("id" => "0", "wkt" => $calculo[0]["gwkt"], "valores" => $valoresoriginais, "imagem" => $imagem["url"]);
             $this->serializeGeo($nomegeo, $final);
         }
     }
     return $nomegeo;
 }