Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#10640 closed Bugs (fixed)

boost geometry buffer algorithm and counterclockwise polygons

Reported by: dopamine@… Owned by: Barend Gehrels
Milestone: Boost 1.58.0 Component: geometry
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc:

Description

the buffer algorithm does not seem to work (the result multipolygon is always empty) if the input model::polygons are defines as counterclockwise.

test code (adapted from the buffer documentation):

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/geometries.hpp>

int main()
{
    typedef double coordinate_type;
    typedef boost::geometry::model::d2::point_xy<coordinate_type> point;

    //counterclockwise
    typedef boost::geometry::model::polygon<point,false> polygon;

    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;

    boost::geometry::model::multi_polygon<polygon> result;
    boost::geometry::model::multi_polygon<polygon> mpol;
    
    //points reversed to get a positive area()
    boost::geometry::read_wkt("MULTIPOLYGON(((0 1,5 3,2 5,0 1)),((1 1,5 0,5 2,1 1)))", mpol);
   
    boost::geometry::buffer(mpol.front(), result,
                distance_strategy, side_strategy,
                join_strategy, end_strategy, circle_strategy);

   //always zero
   std::cerr<<"result size = "<<result.size()<<std::endl;

   return 0;
}

Change History (2)

comment:1 by awulkiew, 8 years ago

Milestone: To Be DeterminedBoost 1.58.0
Resolution: fixed
Status: newclosed

comment:2 by bruno.nascimento@…, 7 years ago

what if they are clock wise?

Note: See TracTickets for help on using tickets.