...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Let the buffer create sharp corners.
This strategy can be used as JoinStrategy for the buffer algorithm. It creates a sharp corners around each convex vertex. It can be applied for (multi)linestrings and (multi)polygons. If corners are sharp by themselves, the miters might become very long. Therefore there is a limit (miter_limit), in terms of the used distance, which limits their length. The miter is not changed to a bevel form (as done in some other software), it is just adapted to the specified miter_limit but keeps its miter form. If the buffer distance is 5.0, and the miter limit is 2.0, generated points will be located at a distance of at most 10.0 (2*5) units. This strategy is only applicable for Cartesian coordinate systems.
class strategy::buffer::join_miter { // ... };
Function |
Description |
Parameters |
---|---|---|
join_miter(double miter_limit = 5.0)
|
Constructs the strategy. |
double: miter_limit: The miter limit, to avoid excessively long miters around sharp corners |
#include <boost/geometry/strategies/cartesian/buffer_join_miter.hpp>
Shows how the join_miter strategy can be used as a JoinStrategy to create sharp corners
#include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/geometries.hpp> int main() { typedef boost::geometry::model::d2::point_xy<double> point; typedef boost::geometry::model::polygon<point> polygon; // Declare the join_miter strategy boost::geometry::strategy::buffer::join_miter join_strategy; // Declare other strategies 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; // Declare/fill a multi polygon boost::geometry::model::multi_polygon<polygon> mp; boost::geometry::read_wkt("MULTIPOLYGON(((5 5,7 8,9 5,5 5)),((8 7,8 10,11 10,11 7,8 7)))", mp); // Create the buffered geometry with sharp corners boost::geometry::model::multi_polygon<polygon> result; boost::geometry::buffer(mp, result, distance_strategy, side_strategy, join_strategy, end_strategy, point_strategy); return 0; }