Modify

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#8365 closed Bugs (fixed)

"Overlay invalid input exception" (2)

Reported by: Volker Schöch <vschoech@…> Owned by: Barend Gehrels
Milestone: Boost 1.55.0 Component: geometry
Version: Boost 1.52.0 Severity: Problem
Keywords: spikes, polygon, multi polygon, difference, sym_difference Cc:

Description

Please find below some code that triggers "Overlay invalid input exception" (in the last statement of the example). I have a couple of different reproductions, and since I'm not sure if they all share the same root cause, I'm filing them in separate tickets.

As always, my polygon type is oriented counter-clockwise and not closed, my point type is based on int.

This is the data that triggers the exception:

_intPolygon polygon( "MULTIPOLYGON(((971 1402,5395 1402,5395 3353,971 3353)))" );
{
_intPolygon const polygonB = _intPolygon("MULTIPOLYGON(((966 2862,1704 3348,2442 3186,3180 2376,3912 1722,4650 1398,5388 1560,5388 32767,966 32767)))") ^ _intPolygon("MULTIPOLYGON(((966 2700,1704 3348,2442 3186,3180 2376,3912 1884,4650 1398,5388 1560,5388 32767,966 32767)))");
       polygon -= polygonB;
}
{
       _intPolygon const polygonB = _intPolygon("MULTIPOLYGON(((966 2700,1704 3348,2442 3186,3180 2376,3912 1884,4650 1398,5388 1560,5388 32767,966 32767)))") ^ _intPolygon("MULTIPOLYGON(((966 2700,1704 3024,2442 3186,3180 2376,3912 1884,4650 1722,5388 1560,5388 32767,966 32767)))");
       polygon -= polygonB;
}
{
       _intPolygon const polygonB = _intPolygon("MULTIPOLYGON(((966 2700,1704 3024,2442 3186,3180 2376,3912 1884,4650 1722,5388 1560,5388 32767,966 32767)))") ^ _intPolygon("MULTIPOLYGON(((966 2208,1704 3024,2442 3186,3180 2376,3912 2376,4650 1722,5388 1560,5388 32767,966 32767)))");
       polygon -= polygonB;
}

This is my code that wraps boost::geometry to implement the operators 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;
}

template<typename T>
template<typename Geometry>
_TPolygon<T>& _TPolygon< T >::operator-=(Geometry const& geometry)
{
       // boost::geometry::difference cannot operate in-place
       // http://lists.boost.org/geometry/2012/02/1796.php
       *this = *this - geometry;
       return *this;
}

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 (0)

Change History (5)

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

Note for think-cell: RT 7681

comment:2 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/05/1936.php

comment:3 Changed 4 years ago by Barend Gehrels

Keywords: spikes added
Milestone: To Be DeterminedBoost 1.55.0
Status: newassigned

comment:4 Changed 4 years ago by Barend Gehrels

Resolution: fixed
Status: assignedclosed

Fixed together with 8364, added a unit-test. Root cause were the spikes generated for integer polygons, they are now avoided on generation. (The related bug 8366 is influenced by this enhancement, but not yet fixed).

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

I can confirm that this problem is no longer reproducible with boost 1.55.0.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Barend Gehrels.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.