Opened 10 years ago

Closed 8 years ago

#8375 closed Bugs (fixed)

sym_difference of non-closed polygons returns closed polygon

Reported by: Volker Schöch <vschoech@…> Owned by: Barend Gehrels
Milestone: Boost 1.56.0 Component: geometry
Version: Boost 1.55.0 Severity: Problem
Keywords: sym_difference, multi-polygon, polygon, closed, open, correct Cc:

Description

The output multi-polygon from boost::geometry::sym_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.

This is the data used as input to sym_difference:

_TPolygon<int> const polygonB =
	_TPolygon<int>("MULTIPOLYGON(((813 277,1341 319,1863 361,2391 571,2913 361,3441 319,3963 277,3963 32767,813 32767)))")
	^ _TPolygon<int>("MULTIPOLYGON(((813 277,1341 319,1863 571,2391 571,2913 571,3441 319,3963 277,3963 32767,813 32767)))");

This is the resulting multi-polygon, consisting of two closed polygons:

polygonB: MULTIPOLYGON(((2391 571,1863 571,1341 319,1863 361,2391 571)),((2391 571,2913 361,3441 319,2913 571,2391 571)))

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
{
       _TPolygon< T > polygonOut;
       boost::geometry::sym_difference(*this, geometry, polygonOut);

       // should not be necessary
       //boost::geometry::correct( polygonOut );

       return polygonOut;
}

Attachments (2)

ticket_8375.cpp (1.5 KB ) - added by mkaravel 8 years ago.
stand-along program for reproducing ticket #8375
ticket_8375.out (290 bytes ) - added by mkaravel 8 years ago.
output of test program for ticket #8375 (corrected)

Download all attachments as: .zip

Change History (11)

comment:1 by Volker Schöch <vschoech@…>, 10 years ago

Our conversation on the geometry mailing list regarding this issue in 1.48.0: http://lists.boost.org/geometry/2012/02/1857.php

comment:2 by Volker Schöch <vschoech@…>, 10 years ago

The difference algorithm has the same problem which I filed as a separate ticket #8376.

comment:3 by Barend Gehrels, 9 years ago

Status: newassigned

comment:4 by anonymous, 9 years ago

Version: Boost 1.52.0Boost 1.55.0

Still reproducible with boost 1.55.0.

comment:5 by vschoech@…, 9 years ago

Sorry for "anonymous" in the previous comment. That was me.

comment:6 by mkaravel, 8 years ago

See attached test program and output, as well as comments in ticket #9828

by mkaravel, 8 years ago

Attachment: ticket_8375.cpp added

stand-along program for reproducing ticket #8375

comment:7 by mkaravel, 8 years ago

Resolution: worksforme
Status: assignedclosed

by mkaravel, 8 years ago

Attachment: ticket_8375.out added

output of test program for ticket #8375 (corrected)

comment:8 by mkaravel, 8 years ago

Resolution: worksforme
Status: closedreopened

comment:9 by mkaravel, 8 years ago

Milestone: To Be DeterminedBoost 1.56.0
Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.