[buffer] change default constructors for round strategies and

changed corresponding samples (often omitting the number for non relevant
strategies)
This commit is contained in:
Barend Gehrels 2014-07-20 15:51:49 +02:00
parent 03b6571555
commit 384632c572
12 changed files with 45 additions and 74 deletions

View File

@ -25,11 +25,10 @@ int main()
boost::geometry::strategy::buffer::distance_asymmetric<double> distance_strategy(1.0, 0.5);
// Declare other strategies
const int points_per_circle = 36;
boost::geometry::strategy::buffer::side_straight side_strategy;
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 point_strategy(points_per_circle);
boost::geometry::strategy::buffer::join_round join_strategy;
boost::geometry::strategy::buffer::end_round end_strategy;
boost::geometry::strategy::buffer::point_circle point_strategy;
// Declare/fill a multi linestring
boost::geometry::model::multi_linestring<linestring> ml;

View File

@ -25,11 +25,10 @@ int main()
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(0.5);
// Declare other strategies
const int points_per_circle = 36;
boost::geometry::strategy::buffer::side_straight side_strategy;
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 point_strategy(points_per_circle);
boost::geometry::strategy::buffer::join_round join_strategy;
boost::geometry::strategy::buffer::end_round end_strategy;
boost::geometry::strategy::buffer::point_circle point_strategy;
// Declare/fill a multi linestring
boost::geometry::model::multi_linestring<linestring> ml;

View File

@ -25,11 +25,10 @@ int main()
boost::geometry::strategy::buffer::end_flat end_strategy;
// Declare other strategies
const int points_per_circle = 36;
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(1.0);
boost::geometry::strategy::buffer::side_straight side_strategy;
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
boost::geometry::strategy::buffer::point_circle point_strategy(points_per_circle);
boost::geometry::strategy::buffer::join_round join_strategy;
boost::geometry::strategy::buffer::point_circle point_strategy;
// Declare/fill a multi linestring
boost::geometry::model::multi_linestring<linestring> ml;

View File

@ -21,15 +21,14 @@ int main()
typedef boost::geometry::model::linestring<point> linestring;
typedef boost::geometry::model::polygon<point> polygon;
// Declare the round-end strategy
const int points_per_circle = 36;
boost::geometry::strategy::buffer::end_round end_strategy(points_per_circle);
// Declare the round-end strategy with 36 points for a full circle
boost::geometry::strategy::buffer::end_round end_strategy(36);
// Declare other strategies
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(1.0);
boost::geometry::strategy::buffer::side_straight side_strategy;
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
boost::geometry::strategy::buffer::point_circle point_strategy(points_per_circle);
boost::geometry::strategy::buffer::join_round join_strategy;
boost::geometry::strategy::buffer::point_circle point_strategy;
// Declare/fill a multi linestring
boost::geometry::model::multi_linestring<linestring> ml;

View File

@ -28,7 +28,7 @@ int main()
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(0.5);
boost::geometry::strategy::buffer::end_flat end_strategy;
boost::geometry::strategy::buffer::side_straight side_strategy;
boost::geometry::strategy::buffer::point_circle point_strategy(36);
boost::geometry::strategy::buffer::point_circle point_strategy;
// Declare/fill a multi polygon
boost::geometry::model::multi_polygon<polygon> mp;

View File

@ -21,15 +21,14 @@ int main()
typedef boost::geometry::model::linestring<point> linestring;
typedef boost::geometry::model::polygon<point> polygon;
// Declare the join_round strategy
const int points_per_circle = 36;
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
// Declare the join_round strategy with 72 points for a full circle
boost::geometry::strategy::buffer::join_round join_strategy(72);
// Declare other strategies
boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(1.0);
boost::geometry::strategy::buffer::end_flat end_strategy;
boost::geometry::strategy::buffer::side_straight side_strategy;
boost::geometry::strategy::buffer::point_circle point_strategy(points_per_circle);
boost::geometry::strategy::buffer::point_circle point_strategy;
// Declare/fill a multi polygon
boost::geometry::model::multi_polygon<polygon> mp;

View File

@ -17,30 +17,24 @@
int main()
{
typedef double coordinate_type;
typedef boost::geometry::model::d2::point_xy<coordinate_type> point;
typedef boost::geometry::model::d2::point_xy<double> point;
typedef boost::geometry::model::polygon<point> polygon;
// Declare the point_circle strategy
const int points_per_circle = 360;
boost::geometry::strategy::buffer::point_circle point_strategy(points_per_circle);
boost::geometry::strategy::buffer::point_circle point_strategy(360);
// Declare other strategies
const double buffer_distance = 0.7;
boost::geometry::strategy::buffer::distance_symmetric<coordinate_type> distance_strategy(buffer_distance);
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::distance_symmetric<double> distance_strategy(0.7);
boost::geometry::strategy::buffer::join_round join_strategy;
boost::geometry::strategy::buffer::end_round end_strategy;
boost::geometry::strategy::buffer::side_straight side_strategy;
// Declare output
boost::geometry::model::multi_polygon<polygon> result;
// Declare/fill of a multi point
boost::geometry::model::multi_point<point> mp;
boost::geometry::read_wkt("MULTIPOINT((3 3),(3 4),(4 4),(7 3))", mp);
// Create the buffer of a multi point
boost::geometry::model::multi_polygon<polygon> result;
boost::geometry::buffer(mp, result,
distance_strategy, side_strategy,
join_strategy, end_strategy, point_strategy);

View File

@ -18,29 +18,24 @@
int main()
{
typedef double coordinate_type;
typedef boost::geometry::model::d2::point_xy<coordinate_type> point;
typedef boost::geometry::model::d2::point_xy<double> point;
typedef boost::geometry::model::polygon<point> polygon;
// Declare the point_square strategy
boost::geometry::strategy::buffer::point_square point_strategy;
// Declare other strategies
const int points_per_circle = 36;
const double buffer_distance = 0.5;
boost::geometry::strategy::buffer::distance_symmetric<coordinate_type> distance_strategy(buffer_distance);
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::distance_symmetric<double> distance_strategy(0.5);
boost::geometry::strategy::buffer::join_round join_strategy;
boost::geometry::strategy::buffer::end_round end_strategy;
boost::geometry::strategy::buffer::side_straight side_strategy;
// Declare output
boost::geometry::model::multi_polygon<polygon> result;
// Declare/fill of a multi point
boost::geometry::model::multi_point<point> mp;
boost::geometry::read_wkt("MULTIPOINT((3 3),(3 4),(4 4),(7 3))", mp);
// Create the buffer of a multi point
boost::geometry::model::multi_polygon<polygon> result;
boost::geometry::buffer(mp, result,
distance_strategy, side_strategy,
join_strategy, end_strategy, point_strategy);

View File

@ -48,7 +48,7 @@ namespace strategy { namespace buffer
class end_round
{
private :
int m_steps_per_circle;
std::size_t m_points_per_circle;
template
<
@ -65,7 +65,7 @@ private :
PromotedType const two = 2.0;
PromotedType const two_pi = two * geometry::math::pi<PromotedType>();
int point_buffer_count = m_steps_per_circle;
std::size_t point_buffer_count = m_points_per_circle;
PromotedType const diff = two_pi / PromotedType(point_buffer_count);
@ -92,14 +92,11 @@ private :
}
public :
//! Constructs the strategy with default number of points (100)
inline end_round()
: m_steps_per_circle(100)
{}
//! Constructs the strategy specifying the nuber of points
explicit inline end_round(int steps_per_circle)
: m_steps_per_circle(steps_per_circle)
//! \brief Constructs the strategy
//! \param points_per_circle points which would be used for a full circle
explicit inline end_round(std::size_t points_per_circle = 90)
: m_points_per_circle(points_per_circle)
{}
#ifndef DOXYGEN_SHOULD_SKIP_THIS

View File

@ -35,8 +35,6 @@ namespace strategy { namespace buffer
It creates a rounded corners around each convex vertex. It can be applied
for (multi)linestrings and (multi)polygons.
This strategy is only applicable for Cartesian coordinate systems.
The specified number of points is for a full circle, which will in practice
never be the case
\qbk{
[heading Example]
@ -52,14 +50,10 @@ class join_round
{
public :
//! Constructs the strategy with default number of points (100)
inline join_round()
: m_steps_per_circle(100)
{}
//! Constructs the strategy specifying the nuber of points
explicit inline join_round(int steps_per_circle)
: m_steps_per_circle(steps_per_circle)
//! \brief Constructs the strategy
//! \param points_per_circle points which would be used for a full circle
explicit inline join_round(std::size_t points_per_circle = 90)
: m_points_per_circle(points_per_circle)
{}
private :
@ -92,7 +86,7 @@ private :
promoted_type angle_diff = acos(dx1 * dx2 + dy1 * dy2);
promoted_type two = 2.0;
promoted_type steps = m_steps_per_circle;
promoted_type steps = m_points_per_circle;
int n = boost::numeric_cast<int>(steps * angle_diff
/ (two * geometry::math::pi<promoted_type>()));
@ -166,7 +160,7 @@ public :
#endif // DOXYGEN_SHOULD_SKIP_THIS
private :
int m_steps_per_circle;
std::size_t m_points_per_circle;
};

View File

@ -32,7 +32,7 @@ class join_round_by_divide
{
public :
inline join_round_by_divide(int max_level = 4)
inline join_round_by_divide(std::size_t max_level = 4)
: m_max_level(max_level)
{}
@ -47,7 +47,7 @@ public :
Point const& p1, Point const& p2,
DistanceType const& buffer_distance,
RangeOut& range_out,
int level = 1) const
std::size_t level = 1) const
{
typedef typename coordinate_type<Point>::type coordinate_type;
@ -137,7 +137,7 @@ public :
}
private :
int m_max_level;
std::size_t m_max_level;
};

View File

@ -44,13 +44,9 @@ namespace strategy { namespace buffer
class point_circle
{
public :
//! Constructs the strategy with default number of points (90)
point_circle()
: m_count(90)
{}
//! Constructs the strategy specifying the nuber of points
explicit point_circle(std::size_t count)
//! \brief Constructs the strategy
//! \param count number of points for the created circle
explicit point_circle(std::size_t count = 90)
: m_count(count)
{}