Boost logo

Boost Users :

Subject: Re: [Boost-users] [geometry] Buffer (with strategy) to offset polygons
From: Olivier Tournaire (olitour_at_[hidden])
Date: 2014-08-12 15:50:41


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 <barend_at_[hidden]>:

> 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<coordinate_type>
>> point_xy_type;
>> typedef boost::geometry::model::polygon<point_xy_type> 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<coordinate_type>
>> distance_strategy(buffer_distance);
>> boost::geometry::strategy::buffer::join_miter
>> join_strategy(buffer_distance);
>>
>> polygon_type p;
>> boost::geometry::model::multi_polygon<polygon_type> 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<coordinate_type> pythagoras_distance_strategy;
>> typedef boost::geometry::strategy::
>> distance::projected_point<coordinate_type, pythagoras_distance_strategy>
>> projected_point_strategy;
>> boost::geometry::strategy::simplify::douglas_peucker<point_xy_type,
>> projected_point_strategy> dp;
>>
>> OGRPolygon poly;
>>
>> for(size_t i=0;i<result.size();++i)
>> {
>> polygon_type result_i = result[i];
>> polygon_type result_i_simplified;
>>
>> boost::geometry::simplify(result_i, result_i_simplified, 0.1, dp);
>>
>> {
>> OGRLinearRing ring;
>> for(size_t j=0;j<result_i_simplified.
>> outer().size();++j)
>> ring.addPoint(
>> result_i_simplified.outer()[j].x(), result_i_simplified.outer()[j].y() );
>> poly.addRing(&ring);
>> }
>>
>> {
>> OGRLinearRing ring;
>> for(size_t j=0;j<result_i_simplified.
>> inners().size();++j)
>> {
>> for(size_t k=0;k<result_i_simplified.
>> inners()[j].size();++k)
>> {
>> ring.addPoint(
>> result_i_simplified.inners()[j][k].x(), result_i_simplified.inners()[j][k].y()
>> );
>> }
>> poly.addRing(&ring);
>> }
>> }
>> }
>>
>> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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