Opened 5 years ago
Closed 4 years ago
#8376 closed Bugs (fixed)
difference of non-closed polygons returns closed polygon
Reported by: | Owned by: | Barend Gehrels | |
---|---|---|---|
Milestone: | Boost 1.56.0 | Component: | geometry |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | difference, multi-polygon, polygon, closed, open, correct | Cc: | mkaravel |
Description
The output multi-polygon from boost::geometry::difference should have the same orientation, closed-ness and underlying scalar data type, as the input (multi-)polygons. My polygon type is oriented counter-clockwise and not closed, my point type is based on int. Please find below some code that results in a closed polygon.
Note: The sym_difference algorithm has the same problem which I filed as a separate ticket #8375.
This is the data used as input to difference:
_TPolygon<int> const polygon = _TPolygon<int>("MULTIPOLYGON(((1920 1462,3720 1462,3720 3262,1920 3262)))") - _TPolygon<int>("MULTIPOLYGON(((1918 1957,1918 1657,2218 2189)),((3718 1957,3360 2233,3718 1561)),((3360 2233,2818 3253,2218 2189,2818 2653)))");
This is the resulting multi-polygon, with the first contained polygon being closed:
MULTIPOLYGON(((1920 1660,1920 1462,3720 1462,3720 3262,1920 3262,1920 1958,2218 2189,1920 1660),(3718 1561,3360 2233,3718 1957),(2818 2653,2218 2189,2818 3253,3360 2233)))
This is my code that wraps boost::geometry to implement the operator used above:
template<typename T> template<typename Geometry> _TPolygon< T > _TPolygon< T >::operator-(Geometry const& geometry) const { // should not be necessary //if( boost::geometry::area(geometry)==0 ) return *this; _TPolygon< T > polygonOut; boost::geometry::difference(*this, geometry, polygonOut); // should not be necessary //boost::geometry::correct( polygonOut ); return polygonOut; }
Attachments (3)
Change History (10)
comment:1 Changed 5 years ago by
comment:2 Changed 5 years ago by
Status: | new → assigned |
---|
comment:4 Changed 4 years ago by
Cc: | mkaravel added |
---|---|
Resolution: | → worksforme |
Status: | assigned → closed |
Please see attached test program and output. See also comments for ticket #9828.
Changed 4 years ago by
Attachment: | ticket_8375.cpp added |
---|
Replace irrelevant attachment by an empty file
comment:5 Changed 4 years ago by
The attachment with file name ticket_8375.cpp was uploaded by error, and to avoid any confusion is has been replaced by an empty file.
comment:6 Changed 4 years ago by
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
comment:7 Changed 4 years ago by
Milestone: | To Be Determined → Boost 1.56.0 |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
Our conversation on the geometry mailing list regarding this issue in 1.48.0: http://lists.boost.org/geometry/2012/02/1829.php