Hi Olivier, Olivier Tournaire wrote On 11-8-2014 23:41:
Dear all,
I have used successfully the buffering algorithm to offset a shapefile of 2D polygons. However, there are 4 polygons (amongst nearly 4000) in my SHP does are not successfully processed. They do not have topology or orientation errors.
I use GDAL 1.9 to read the SHP, boost 1.56 precompiled binaries from sourceforge on a 64bit windows 7. If someone is willing to have a look at the problem, I can share the files and the code I use. Here is a quick overview:
typedef double coordinate_type; typedef boost::geometry::model::d2::point_xy
point_xy_type; typedef boost::geometry::model::polygon polygon_type; boost::geometry::strategy::buffer::end_flat end_strategy; boost::geometry::strategy::buffer::point_square point_strategy; boost::geometry::strategy::buffer::side_straight side_strategy; boost::geometry::strategy::buffer::distance_symmetric
distance_strategy(buffer_distance); boost::geometry::strategy::buffer::join_miter join_strategy(buffer_distance); polygon_type p; boost::geometry::model::multi_polygon
result; // Build a polygon_type from OGRPolygon OGRLinearRing* exteriorRing = polygon->getExteriorRing(); for(int i=0;i<exteriorRing->getNumPoints();++i) { OGRPoint pt; exteriorRing->getPoint(i,&pt);
p.outer().push_back( point_xy_type(pt.getX(), pt.getY()) ); } for(int i=0;i<polygon->getNumInteriorRings();++i) { OGRLinearRing* interiorRing = polygon->getInteriorRing(i); polygon_type::ring_type ring;
for(int j=0;j<interiorRing->getNumPoints();++j) { OGRPoint pt; interiorRing->getPoint(j,&pt);
ring.push_back( point_xy_type(pt.getX(), pt.getY()) ); } p.inners().push_back(ring); }
boost::geometry::buffer(p, result, distance_strategy, side_strategy, join_strategy, end_strategy, point_strategy);
if(result.size() == 0) { int indexID = feature->GetFieldIndex("ID"); cout << "No result build for polygon with ID " << feature->GetFieldAsString(indexID) << endl; } else { typedef boost::geometry::strategy::distance::pythagoras
pythagoras_distance_strategy; typedef boost::geometry::strategy::distance::projected_point projected_point_strategy; boost::geometry::strategy::simplify::douglas_peucker dp; OGRPolygon poly;
for(size_t i=0;i
boost::geometry::simplify(result_i, result_i_simplified, 0.1, dp);
{ OGRLinearRing ring; for(size_t j=0;j
{ OGRLinearRing ring; for(size_t j=0;j
Note that I use a simplification algorithm after buffering to remove colinear points.
Hope you could help.
Thanks for the report. If you can, can you please make WKT's of the 4 failing input (with enough precision)? And send them to me or create a ticket for them? Will look then (might take a while). Regards, Barend