3 Ekim 2017 Salı

geometry buffer metodu

Giriş
Bu metodun sanırım noktaları veya linestring'i polygon'a çeviriyor.

Örnek
Elimizde bir polygon olsun
namespace bg = boost::geometry;
typedef bg::model::d2::point_xy<float> BoostPoint;
typedef bg::model::polygon<BoostPoint> BoostPolygon;
typedef bg::model::multi_polygon<BoostPolygon> BoostMultipolygon;

BoostPolygon input;

boost::geometry::read_wkt("POLYGON((...))", input);
Şöyle yaparız.
// Declare boost strategies for buffer function.
bg::strategy::buffer::distance_symmetric<double> distance_strategy(-0.05);
bg::strategy::buffer::join_round join_strategy;
bg::strategy::buffer::end_round end_strategy;
bg::strategy::buffer::point_circle point_strategy;
bg::strategy::buffer::side_straight side_strategy;
// Perform polygon buffering.
bg::buffer(input, output, distance_strategy, side_strategy, join_strategy,
  end_strategy, point_strategy);
Örnek
Elimizde bir linestring olsun. Şöyle yaparız.
using namespace boost::geometry::model;
namespace bg = boost::geometry; 
typedef  bg::model::point <double , 2, bg::cs::cartesian > point_t;
typedef boost::geometry::model::polygon <point_t> polygon_t;
typedef bg::model::linestring<point_t> linestring_t;
linestring_t ls1;



const double buffer_distance = 1.0;
const int points_per_circle = 36;
// Declare other strategies
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(0.0002);
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
boost::geometry::strategy::buffer::end_round end_strategy(points_per_circle);
boost::geometry::strategy::buffer::point_circle circle_strategy(points_per_circle);
boost::geometry::strategy::buffer::side_straight side_strategy;
boost::geometry::model::multi_polygon<polygon_t> result; 
/* polygon_t result; */
boost::geometry::buffer(ls1, result,
                distance_strategy, side_strategy,
                join_strategy, end_strategy, circle_strategy);

Hiç yorum yok:

Yorum Gönder