Boost logo

Boost Users :

Subject: Re: [Boost-users] [geometry] how to set number of points / chord length in buffer() join_round strategy?
From: Barend Gehrels (barend_at_[hidden])
Date: 2013-03-02 13:30:26


Hi John,

On 28-2-2013 1:03, John Lilley wrote:
> I see in the released buffer() algorithm, there is a chord length argument:
> void buffer(Input const & geometry_in, Output & geometry_out, Distance const & distance, Distance const & chord_length = -1)
>
> But I can't seem to find an equivalent for buffer_inserter<> with a join_round strategy. How do I set the chord length or number of approximating points?

It was there but not yet exposed. I did put this in the constructor now.
You can now construct the join_round with the number of points for a
full circle. The default is 100.

Furthermore I also added support for multi_linestring types. Note that
the so-called end-cap of linestring types is not yet supported, they
currently always have square ends. That will be implemented later. What
is (was) already there is the asymmetric distance.

So this (I put all these things together in the sample below) delivers
the following picture. Original line is dotted, buffer is green.

If you decrease the number of points (e.g. 12) even more, you get less
rounded corners:

I repeat that the algorithm itself is not released yet, and (w.r.t.
buffering) not enhanced today, I just added multi_linestrings. So there
will be situations where it fails.

Regards, Barend

#include <boost/geometry.hpp>

#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/multi/geometries/multi_linestring.hpp>

#include <boost/geometry/extensions/algorithms/buffer/buffer_inserter.hpp>
#include
<boost/geometry/extensions/algorithms/buffer/multi_buffer_inserter.hpp>
#include <boost/geometry/extensions/strategies/buffer.hpp>

int main()
{
     typedef boost::geometry::model::d2::point_xy<double> point_type;
     typedef boost::geometry::model::linestring<point_type> linestring;
     typedef boost::geometry::model::polygon<point_type> polygon;

     // Multi Linestring
     {
         boost::geometry::strategy::buffer::join_round<point_type,
point_type> join(30); // 30 points per full circle

         boost::geometry::model::multi_linestring<linestring> my_input;
         boost::geometry::read_wkt("MULTILINESTRING((0 0,4 5,7 4,10
6),(1 5,5 9,8 6))", my_input);
         boost::geometry::model::multi_polygon<polygon> my_output;
         boost::geometry::buffer_inserter<polygon>
             (
                 my_input,
                 std::back_inserter(my_output),
boost::geometry::strategy::buffer::distance_assymetric<double>(1.5, 0.75),
                 join
             );

         std::cout << "Input, #points: " <<
boost::geometry::num_points(my_input) << std::endl;
         std::cout << "Output, area: " <<
boost::geometry::area(my_output) << std::endl;

     }

     return 0;
}



ecfhjehf.png
egigiabd.png

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net