function xy2wkt($xy) { $apt = explode(" ", $xy); $shppt = ms_newshapeobj(MS_SHAPE_POINT); $shplin = ms_newshapeobj(MS_SHAPE_LINE); $shppol = ms_newshapeobj(MS_SHAPE_POLYGON); $lin = ms_newlineobj(); $capt = count($apt); for ($i = 0; $i < $capt; $i = $i + 2) { $lin->addxy($apt[$i], $apt[$i + 1]); } $shppt->add($lin); if (count($apt) < 4) { $lin->addxy($apt[0], $apt[1]); $apt[] = $apt[0]; $apt[] = $apt[1]; } $shplin->add($lin); if (count($apt) < 6) { $lin->addxy($apt[0], $apt[1]); $apt[] = $apt[0]; $apt[] = $apt[1]; } if ($apt[0] . " " . $apt[1] != $apt[count($apt) - 2] . " " . $apt[count($apt) - 1]) { $lin->addxy($apt[0], $apt[1]); } $shppol->add($lin); return array("ponto" => $shppt->toWkt(), "linha" => $shplin->toWkt(), "poligono" => $shppol->toWkt()); }
function insereFeature($marca, $tipo, $xy, $texto, $position, $partials, $offsetx, $offsety, $minfeaturesize, $mindistance, $force, $shadowcolor, $shadowsizex, $shadowsizey, $outlinecolor, $cor, $sombray, $sombrax, $sombra, $fundo, $angulo, $tamanho, $fonte, $wrap, $wkt = false, $nomeTema = "") { //verifica se ja existe um layer criado anteriormente com o mesmo nome e apaga se existir if ($tipo == "limpaponto") { if ($this->layer) { $this->layer->set("status", MS_DELETE); $this->layer->set("name", "pindelete"); $tipo = "POINT"; } } if (!$this->layer) { $pinlayer = criaLayer($this->mapa, MS_LAYER_LINE, MS_DEFAULT, "Ins", $metaClasse = "SIM"); $c = $pinlayer->getclass(0); $c->set("name", ""); $e = $c->getstyle(0); $e->set("size", 1); $e->set("symbol", "ponto"); $core = $e->color; $core->setrgb(255, 0, 0); if (!isset($cor)) { $cor = "255 0 0"; } switch ($tipo) { case "GRAFICOPIZZA": if (!isset($tamanho)) { $tamanho = 5; } $e->set("size", $tamanho); $pinlayer->setmetadata("tema", "Pontos inseridos"); $pinlayer->set("type", MS_LAYER_POINT); break; case "POINT": if (!isset($marca) || $marca == "") { $marca = "marca"; } if (!isset($tamanho)) { $tamanho = 5; } $e->set("size", $tamanho); $e->set("symbolname", $marca); corE($e, $cor, "color"); $pinlayer->setmetadata("tema", "Pontos inseridos"); $pinlayer->set("type", MS_LAYER_POINT); break; case "LINE": if (!isset($marca) || $marca == "") { $marca = "linha"; } if (!isset($tamanho)) { $tamanho = 2; } $e->set("size", $tamanho); $e->set("symbol", $marca); if (isset($cor) && $cor != "") { corE($e, $cor, "color"); } if (isset($texto) && $texto != "") { $pinlayer->setmetadata("TEMA", $texto); } else { $pinlayer->setmetadata("tema", "Linhas inseridas"); } $pinlayer->set("type", MS_LAYER_LINE); break; case "POLYGON": if (!isset($marca)) { $marca = "p9"; } if (!isset($tamanho)) { $tamanho = 5; } $e->set("size", $tamanho); $e->set("symbol", $marca); $pinlayer->setmetadata("tema", "Poligonos inseridos"); $pinlayer->set("type", MS_LAYER_POLYGON); $pinlayer->set("opacity", "50"); break; case "ANNOTATION": //$c->set("status",MS_DELETE); $pinlayer->setmetadata("TEMA", $texto); $pinlayer->setmetadata("tiles", "nao"); $pinlayer->set("type", MS_LAYER_POINT); $pinlayer->set("opacity", "100"); break; } } switch ($tipo) { case "ANNOTATION": $shp = ms_newshapeobj(MS_SHAPE_POINT); break; case "POINT": $shp = ms_newshapeobj(MS_SHAPE_POINT); break; case "LINE": $shp = ms_newshapeobj(MS_SHAPE_LINE); break; case "POLYGON": $shp = ms_newshapeobj(MS_SHAPE_POLYGON); break; } if ($wkt == false) { $apt = explode(" ", $xy); $lin = ms_newlineobj(); for ($i = 0; $i < count($apt); $i = $i + 2) { $lin->addxy($apt[$i], $apt[$i + 1]); } $shp->add($lin); } else { $shp = ms_shapeObjFromWkt($xy); } if ($texto != "") { $texto = str_replace("*", "&", $texto); $texto = str_replace("|", ";", $texto); $shp->set("text", $texto); //caso nao seja do tipo annotation if ($pinlayer->numclasses == 1) { $novac = $pinlayer->getclass(0); } else { $novac = ms_newclassobj($pinlayer); } $this->adicionaLabel($novac, $wrap, $fonte, $tamanho, $angulo, $fundo, $sombra, $cor, $outlinecolor, $shadowcolor, $shadowsizex, $shadowsizey, $force, $mindistance, $minfeaturesize, $offsetx, $offsety, $partials, $position, ""); } $pinlayer->addfeature($shp); if ($nomeTema != "") { $pinlayer->setmetadata("tema", $nomeTema); } //verifica a projecao $c = $shp->getCentroid(); $c = $c->x; if ($c > -181 && $c < 181) { $pinlayer->setprojection(pegaProjecaoDefault("proj4")); } else { $pinlayer->setprojection($this->mapa->getProjection()); } return "ok"; }
function insereSHPgrafico($x, $y, $itens, $width, $inclinacao, $shadow_height, $ext = "") { if (!isset($tipo)) { $tipo = "pizza"; } //nome do novo tema $temaedit = nomeRandomico(); //pega os valores include_once $this->locaplic . "/classesphp/classe_atributos.php"; $m = new Atributos($this->arquivo, $this->tema); $shape = $m->identificaQBP2($this->nome, $x, $y, $this->arquivo, 0, "", "shape", false, $ext); if (is_array($shape) && $shape[0] == " ") { return "erro.Nenhum valor encontrado"; } else { $shape = $shape[0]; $itens = explode("*", $itens); foreach ($itens as $i) { $ii = explode(",", $i); $v = $shape->values[$ii[0]]; if (!is_numeric($v)) { return "erro. Dados nao numericos."; } $valor[] = $v; $cor[] = $ii[1] . "," . $ii[2] . "," . $ii[3]; } $data = implode("*", $valor); $cores = implode("*", $cor); if ($tipo == "pizza") { //gera a figura include_once $this->locaplic . "/classesphp/graficopizza.php"; $res = graficopizza($data, $width, $inclinacao, $shadow_height, $cores, $this->arquivo, $temaedit); $img = explode(",", $res); } //insere simbolo $nomes = nomeRandomico(); $nId = ms_newsymbolobj($this->mapa, $img[0]); $oSymbol = $this->mapa->getsymbolobjectbyid($nId); $oSymbol->set("inmapfile", MS_TRUE); $oSymbol->set("type", MS_SYMBOL_PIXMAP); $oSymbol->setimagepath($img[0]); $oSymbol->set("name", $nomes); $pinlayer = criaLayer($this->mapa, MS_LAYER_POINT, MS_DEFAULT, "Gráfico (" . $temaedit . ")", "SIM"); $c = $pinlayer->getclass(0); $e = $c->getstyle(0); $pinlayer->set("name", $temaedit); $c->set("name", ""); if (!isset($tamanho)) { $tamanho = 50; } $e->set("size", $tamanho); $e->set("symbolname", $nomes); $pinlayer->set("opacity", MS_GD_ALPHA); $shp = ms_newshapeobj(MS_SHAPE_POINT); $lin = ms_newlineobj(); $lin->addxy($x, $y); $shp->add($lin); $pinlayer->addfeature($shp); $this->salva(); return "ok"; } }