Opened 4 years ago

Closed 4 years ago

#9828 closed Bugs (fixed)

boost::geometry::union_(...) creates redundant closing point

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: union, multi-polygon, polygon, correct Cc: mkaravel

Description

Polygons created by boost::geometry algorithms should conform to the same rules as the input. In the following example, boost::geometry::union_ takes two simple, non-empty rectangular polygons and creates a polygon with a redundant closing point. My polygon type is oriented counter-clockwise and not closed, my point type is based on int.

This is the data used as input to union:

_TPolygon<int> const polygon =
	_TPolygon<int>("MULTIPOLYGON(((3398 1759,3592 1759,3592 1893,3398 1893)))")
	| _TPolygon<int>( "MULTIPOLYGON(((3592 1893,3592 1759,3910 1759,3910 1893)))" );

This is the resulting multi-polygon with the redundant closing point:

MULTIPOLYGON(((3592 1893,3398 1893,3398 1759,3592 1759,3910 1759,3910 1893,3592 1893)))

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::union_(*this, geometry, polygonOut);

	// the following line fixes the problem but should not be necessary
	//boost::geometry::correct( polygonOut );

	return polygonOut;
}

Attachments (2)

ticket_9828.cpp (1.4 KB) - added by mkaravel 4 years ago.
stand-along program for reproducing the ticket
ticket_9828.out (242 bytes) - added by mkaravel 4 years ago.
output of the ticket_9828.cpp program (corrected)

Download all attachments as: .zip

Change History (9)

comment:1 Changed 4 years ago by mkaravel

Resolution: invalid
Status: newclosed

See attached file ticket_9828.cpp and its output in file ticket_9828.out.

The output polygon is indeed open as you can see from the dsv output of the result, as well as from the number of points that I also print out. The WKT output/description (in develop branch or in the upcoming boost 1.56) "closes" the polygon by default, so it is not a safe way for determining whether polygons are closed or not.

comment:2 Changed 4 years ago by mkaravel

Cc: mkaravel added

comment:3 Changed 4 years ago by mkaravel

Resolution: invalid
Status: closedreopened

comment:4 Changed 4 years ago by mkaravel

Resolution: worksforme
Status: reopenedclosed

Changed 4 years ago by mkaravel

Attachment: ticket_9828.cpp added

stand-along program for reproducing the ticket

Changed 4 years ago by mkaravel

Attachment: ticket_9828.out added

output of the ticket_9828.cpp program (corrected)

comment:5 Changed 4 years ago by mkaravel

Milestone: To Be DeterminedBoost 1.56.0

comment:6 Changed 4 years ago by mkaravel

Resolution: worksforme
Status: closedreopened

comment:7 Changed 4 years ago by mkaravel

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.