Boost logo

Geometry :

Subject: Re: [geometry] difference algorithm produces invalid polygon?
From: Barend Gehrels (barend_at_[hidden])
Date: 2012-02-14 14:19:41


Hi Volker,

Nice sample. It took me a while but I can reproduce your findings.

On 14-2-2012 17:49, Volker Schöch wrote:
>
> Hi,
>
> I'm stuck with the following situation. It seems to me that the
> (asymmetric) difference algorithm produces invalid output from valid
> input:
>
> (...)
>
> Input B to Step 3 seems to be valid, at least it can be processed
> without an exception when using Input A from step 1. Thus I conclude
> that the output from step 2 is invalid. Can you confirm that this is a
> problem in GGL, possibly related to the fact that I use an integral
> numeric base type? If not, what's wrong with my input?
>
> I am using boost 1.48.0.
>

The integral numeric basetype is not the problem. I could reproduce your
scenario with int or double, if (and only if) I define a polygon-type
counter-clockwise and open. That should be possible, and it can be
processed, but it indeed produces output invalid to this combination. So
your findings are right.

If I use a clockwise/closed polygon, or a clockwise/open, or a
counterclockwise/closed, there is no exception and the output is correct
(I verified it using SQL Server).

But if I use ccw&open the output is indeed incorrect. That will be fixed.

You can work around it in the meantime by calling
boost::geometry::correct on the output. I did that and that fixes the
output (as expected).

Thanks for your report.

Attached my sample-program. If convenient for you, in case of reports,
please include the WKT... Because we can read and write WKT, but we can
only write DSV (which you apparently used). So WKT is more convenient
for me, creating the reproduction and also verifying it using SQL Server
(or PostGIS).

I attached also the SQL Server version.

Regards, Barend






Geometry list run by mateusz at loskot.net