Opened 5 years ago

Closed 4 years ago

#8376 closed Bugs (fixed)

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: 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)

ticket_8376.cpp (1.5 KB) - added by mkaravel 4 years ago.
stand-alone test program for ticket #8376
ticket_8376.out (461 bytes) - added by mkaravel 4 years ago.
output of test program for ticket #8376
ticket_8375.cpp (2 bytes) - added by mkaravel 4 years ago.
Replace irrelevant attachment by an empty file

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 years ago by Volker Schöch <vschoech@…>

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

comment:2 Changed 5 years ago by Barend Gehrels

Status: newassigned

comment:3 Changed 5 years ago by vschoech@…

Version: Boost 1.52.0Boost 1.55.0

Still reproducible in 1.55.

Changed 4 years ago by mkaravel

Attachment: ticket_8376.cpp added

stand-alone test program for ticket #8376

Changed 4 years ago by mkaravel

Attachment: ticket_8376.out added

output of test program for ticket #8376

comment:4 Changed 4 years ago by mkaravel

Cc: mkaravel added
Resolution: worksforme
Status: assignedclosed

Please see attached test program and output. See also comments for ticket #9828.

Changed 4 years ago by mkaravel

Attachment: ticket_8375.cpp added

Replace irrelevant attachment by an empty file

comment:5 Changed 4 years ago by mkaravel

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 mkaravel

Resolution: worksforme
Status: closedreopened

comment:7 Changed 4 years ago by mkaravel

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