int main() { typedef boost::geometry::model::d2::point_xy<double> point; typedef boost::geometry::model::polygon<point> polygon; // 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; // 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 rounded corners boost::geometry::model::multi_polygon<polygon> result; boost::geometry::buffer(mp, result, distance_strategy, side_strategy, join_strategy, end_strategy, point_strategy); /*<-*/ create_svg_buffer("buffer_join_round.svg", mp, result); /*->*/ return 0; }
int main() { typedef boost::geometry::model::d2::point_xy<double> point; typedef boost::geometry::model::linestring<point> linestring; typedef boost::geometry::model::polygon<point> polygon; // 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; boost::geometry::strategy::buffer::point_circle point_strategy; // Declare/fill a multi linestring boost::geometry::model::multi_linestring<linestring> ml; boost::geometry::read_wkt("MULTILINESTRING((3 5,5 10,7 5),(7 7,11 10,15 7,19 10))", ml); // Create the buffered geometry with rounded ends boost::geometry::model::multi_polygon<polygon> result; boost::geometry::buffer(ml, result, distance_strategy, side_strategy, join_strategy, end_strategy, point_strategy); /*<-*/ create_svg_buffer("buffer_end_round.svg", ml, result); /*->*/ return 0; }
int main() { typedef boost::geometry::model::d2::point_xy<double> point; typedef boost::geometry::model::polygon<point> polygon; // Declare the point_circle strategy boost::geometry::strategy::buffer::point_circle point_strategy(360); // Declare other strategies 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/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); /*<-*/ create_svg_buffer("buffer_point_circle.svg", mp, result); /*->*/ return 0; }
inline void offset(Geometry const& geometry, GeometryOut& out, JoinStrategy const& join, Distance const& distance) { concept::check<Geometry const>(); concept::check<GeometryOut>(); typedef strategy::buffer::distance_asymmetric < typename geometry::coordinate_type<Geometry>::type > distance_strategy_type; distance_strategy_type distance_strategy(distance, distance); detail::buffer::buffered_piece_collection < model::ring<typename point_type<Geometry>::type> > collection; dispatch::offset < typename tag<Geometry>::type, typename tag<GeometryOut>::type, Geometry, GeometryOut >::apply(collection, geometry, distance_strategy, join); collection.assign_offsetted_rings(out); }
inline void offset(Geometry const& geometry, GeometryOut& out, JoinStrategy const& join, Distance const& distance) { concept::check<Geometry const>(); concept::check<GeometryOut>(); typedef strategy::buffer::distance_assymetric < typename geometry::coordinate_type<Geometry>::type > distance_strategy_type; distance_strategy_type distance_strategy(distance, distance); detail::buffer::buffered_piece_collection < //typename geometry::ring_type<GeometryOut>::type // TODO the piece collection will not require a polygonal argument model::ring<typename point_type<Geometry>::type> > collection; dispatch::offset < typename tag<Geometry>::type, typename tag<GeometryOut>::type, Geometry, GeometryOut >::apply(collection, geometry, distance_strategy, join); }
double test_growth(Geometry const& geometry, int n, int d, double distance) { typedef typename bg::coordinate_type<Geometry>::type coordinate_type; typedef typename bg::point_type<Geometry>::type point_type; // extern int point_buffer_count; std::ostringstream complete; complete << "point_growth" << "_" << "r" << "_" << n << "_" << d // << "_" << point_buffer_count ; //std::cout << complete.str() << std::endl; std::ostringstream filename; filename << "buffer_" << complete.str() << ".svg"; std::ofstream svg(filename.str().c_str()); #ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER bg::svg_mapper<point_type> mapper(svg, 500, 500); { bg::model::box<point_type> box; bg::envelope(geometry, box); bg::buffer(box, box, distance * 1.01); mapper.add(box); } #endif bg::strategy::buffer::join_round join_strategy(100); bg::strategy::buffer::end_flat end_strategy; bg::strategy::buffer::point_circle point_strategy; bg::strategy::buffer::side_straight side_strategy; typedef bg::strategy::buffer::distance_symmetric<coordinate_type> distance_strategy_type; distance_strategy_type distance_strategy(distance); std::vector<GeometryOut> buffered; bg::buffer(geometry, buffered, distance_strategy, side_strategy, join_strategy, end_strategy, point_strategy); typename bg::default_area_result<GeometryOut>::type area = 0; BOOST_FOREACH(GeometryOut const& polygon, buffered) { area += bg::area(polygon); }
int main() { typedef double coordinate_type; typedef boost::geometry::model::d2::point_xy<coordinate_type> point; typedef boost::geometry::model::polygon<point> polygon; // Declare strategies const double buffer_distance = 1.0; const int points_per_circle = 36; 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::point_circle circle_strategy(points_per_circle); boost::geometry::strategy::buffer::side_straight side_strategy; // Declare output boost::geometry::model::multi_polygon<polygon> result; // Declare/fill a linestring boost::geometry::model::linestring<point> ls; boost::geometry::read_wkt("LINESTRING(0 0,4 5,7 4,10 6)", ls); // Create the buffer of a linestring boost::geometry::buffer(ls, result, distance_strategy, side_strategy, join_strategy, end_strategy, circle_strategy); /*<-*/ create_svg_buffer("buffer_linestring.svg", ls, result); /*->*/ // Declare/fill a multi point boost::geometry::model::multi_point<point> mp; boost::geometry::read_wkt("MULTIPOINT((3 3),(4 4),(6 2))", mp); // Create the buffer of a multi point boost::geometry::buffer(mp, result, distance_strategy, side_strategy, join_strategy, end_strategy, circle_strategy); /*<-*/ create_svg_buffer("buffer_multi_point.svg", mp, result); /*->*/ // Declare/fill a multi_polygon boost::geometry::model::multi_polygon<polygon> mpol; boost::geometry::read_wkt("MULTIPOLYGON(((0 1,2 5,5 3,0 1)),((1 1,5 2,5 0,1 1)))", mpol); // Create the buffer of a multi polygon boost::geometry::buffer(mpol, result, distance_strategy, side_strategy, join_strategy, end_strategy, circle_strategy); /*<-*/ create_svg_buffer("buffer_multi_polygon.svg", mpol, result); /*->*/ return 0; }
double test_growth(Geometry const& geometry, int n, int d, double distance) { namespace bg = boost::geometry; typedef typename bg::coordinate_type<Geometry>::type coordinate_type; typedef typename bg::point_type<Geometry>::type point_type; // extern int point_buffer_count; std::ostringstream complete; complete << "point" << "_" << "growth" << "_" << string_from_type<coordinate_type>::name() << "_" << "r" << "_" << n << "_" << d // << "_" << point_buffer_count ; //std::cout << complete.str() << std::endl; std::ostringstream filename; filename << "buffer_" << complete.str() << ".svg"; std::ofstream svg(filename.str().c_str()); #ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER bg::svg_mapper<point_type> mapper(svg, 500, 500); { bg::model::box<point_type> box; bg::envelope(geometry, box); bg::buffer(box, box, distance * 1.01); mapper.add(box); } #endif JoinStrategy < point_type, typename bg::point_type<GeometryOut>::type > join_strategy; EndStrategy < point_type, typename bg::point_type<GeometryOut>::type > end_strategy; typedef bg::strategy::buffer::distance_symmetric<coordinate_type> distance_strategy_type; distance_strategy_type distance_strategy(distance); std::vector<GeometryOut> buffered; typedef typename bg::rescale_policy_type<point_type>::type rescale_policy_type; rescale_policy_type rescale_policy = bg::get_rescale_policy<rescale_policy_type>(geometry); bg::detail::buffer::buffer_inserter<GeometryOut>(geometry, std::back_inserter(buffered), distance_strategy, join_strategy, end_strategy, rescale_policy #ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER , mapper #endif ); typename bg::default_area_result<GeometryOut>::type area = 0; BOOST_FOREACH(GeometryOut const& polygon, buffered) { area += bg::area(polygon); }