[geometry] Buffer (with strategy) to offset polygons

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

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

Thanks Barend,
Do not know where to open a ticket ... Did not find the usual "issues" link
on github boost geometry repository. Please let me know where the bug
tracker is located.
In the meantime, here are the WKT's of the failing input:
POLYGON((897866.5 6272518.7,897882.5 6272519.2,897882.6 6272519,897883.3
6272508.7,897883.5 6272505.5,897855 6272503.5,897852.4 6272505.6,897850.1
6272517.6,897860.8 6272518.5,897866.5 6272518.7))
POLYGON((898882.3 6271337.3,898895.7 6271339.9,898898 6271328.3,898881.6
6271325.1,898879.3 6271336.7,898882.3 6271337.3))
POLYGON((897558.7 6272055,897552.5 6272054.2,897552.5 6272053.7,897546.1
6272052.7,897545.6 6272057.7,897560.7 6272059.6,897560.9 6272055.3,897558.7
6272055))
POLYGON((898563.3 6272366.9,898554.7 6272379.2,898559.7 6272382.3,898561.6
6272379.4,898568.7 6272369.1,898563.8 6272366.2,898563.3 6272366.9))
Best regards,
Olivier
2014-08-12 6:14 GMT+02:00 Barend Gehrels
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
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi, Olivier Tournaire wrote:
Thanks Barend,
Do not know where to open a ticket ... Did not find the usual "issues" link on github boost geometry repository. Please let me know where the bug tracker is located.
http://www.boost.org/development/bugs.html https://svn.boost.org/trac/boost/newticket Regards, Adam

Barend, Adam,
Ticket created: https://svn.boost.org/trac/boost/ticket/10398. I attached a
sample code to reproduce the problem.
Let me know if you need more inputs.
Best regards,
Olivier
2014-08-13 16:03 GMT+02:00 Adam Wulkiewicz
Hi,
Olivier Tournaire wrote:
Thanks Barend,
Do not know where to open a ticket ... Did not find the usual "issues" link on github boost geometry repository. Please let me know where the bug tracker is located.
http://www.boost.org/development/bugs.html https://svn.boost.org/trac/boost/newticket
Regards, Adam
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi Olivier, Olivier Tournaire wrote On 25-8-2014 11:13:
Ticket created: https://svn.boost.org/trac/boost/ticket/10398. I attached a sample code to reproduce the problem.
Let me know if you need more inputs.
It is fixed in branch feature/buffer, see ticket Will be released in 1.57 Thanks for the ticket/report Regards, Barend

Hi Barend,
Thank you so much for your quick fix! I can confirm the problem is solved.
I however may have found another bug (just for a single polygon this time,
over the same 4000 polygons). The bug was already here before your previous
fix.
On the attached images, you can see the result of offsetting the input
polygon with a 2.5m distance and the same strategies as above. The output
is a multipolygon and it seems to be self intersecting. Is it a bug or is
it the expected result? In the first case, I can quickly open a ticket with
a sample to reproduce the problem.
Best regards,
Olivier
2014-08-27 12:45 GMT+02:00 Barend Gehrels
Hi Olivier,
Olivier Tournaire wrote On 25-8-2014 11:13:
Ticket created: https://svn.boost.org/trac/boost/ticket/10398. I attached a sample code to reproduce the problem.
Let me know if you need more inputs.
It is fixed in branch feature/buffer, see ticket Will be released in 1.57
Thanks for the ticket/report
Regards, Barend
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Made a mistake: distance is 1.5m, not 2.5m
2014-08-27 13:36 GMT+02:00 Olivier Tournaire
Hi Barend,
Thank you so much for your quick fix! I can confirm the problem is solved.
I however may have found another bug (just for a single polygon this time, over the same 4000 polygons). The bug was already here before your previous fix.
On the attached images, you can see the result of offsetting the input polygon with a 2.5m distance and the same strategies as above. The output is a multipolygon and it seems to be self intersecting. Is it a bug or is it the expected result? In the first case, I can quickly open a ticket with a sample to reproduce the problem.
Best regards,
Olivier
2014-08-27 12:45 GMT+02:00 Barend Gehrels
: Hi Olivier,
Olivier Tournaire wrote On 25-8-2014 11:13:
Ticket created: https://svn.boost.org/trac/boost/ticket/10398. I attached a sample code to reproduce the problem.
Let me know if you need more inputs.
It is fixed in branch feature/buffer, see ticket Will be released in 1.57
Thanks for the ticket/report
Regards, Barend
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi Olivier, Olivier Tournaire wrote On 27-8-2014 13:41:
Made a mistake: distance is 1.5m, not 2.5m
2014-08-27 13:36 GMT+02:00 Olivier Tournaire
mailto:olitour@gmail.com>: Hi Barend,
Thank you so much for your quick fix! I can confirm the problem is solved.
I however may have found another bug (just for a single polygon this time, over the same 4000 polygons). The bug was already here before your previous fix.
On the attached images, you can see the result of offsetting the input polygon with a 2.5m distance and the same strategies as above. The output is a multipolygon and it seems to be self intersecting. Is it a bug or is it the expected result? In the first case, I can quickly open a ticket with a sample to reproduce the problem.
I somehow missed the first message with attachments. Can you open a new ticket and attach it there? Regards, Barend p.s. this list discourages top postings.

Barend
2014-08-27 15:37 GMT+02:00 Barend Gehrels
Hi Olivier,
Olivier Tournaire wrote On 27-8-2014 13:41:
Made a mistake: distance is 1.5m, not 2.5m
2014-08-27 13:36 GMT+02:00 Olivier Tournaire
: Hi Barend,
Thank you so much for your quick fix! I can confirm the problem is solved.
I however may have found another bug (just for a single polygon this time, over the same 4000 polygons). The bug was already here before your previous fix.
On the attached images, you can see the result of offsetting the input polygon with a 2.5m distance and the same strategies as above. The output is a multipolygon and it seems to be self intersecting. Is it a bug or is it the expected result? In the first case, I can quickly open a ticket with a sample to reproduce the problem.
I somehow missed the first message with attachments. Can you open a new ticket and attach it there?
Ticket created: https://svn.boost.org/trac/boost/ticket/10412
Regards, Barend
p.s. this list discourages top postings.
oups, sorry. Regards, Olivier
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Adam Wulkiewicz
-
Barend Gehrels
-
Olivier Tournaire