Boost logo

Geometry :

Subject: [ggl] incorrect result for an intersection
From: Barend Gehrels (barend)
Date: 2011-04-15 16:08:32

Hi Vishnu,

On 15-4-2011 20:46, Vishnu wrote:
> I'm getting incorrect results from an intersection. A multi_polygon used as
> the subject set is being intersected with a copy of itself. The output
> should be the same as the input in this case. The input set has two
> polygons:
> POLYGON((447672 5.0335e+006,447890 5.0335e+006,447891 5.0335e+006,447872
> 5.03345e+006,447841 5.0334e+006,447804 5.03337e+006,447765
> 5.03335e+006,447755 5.03336e+006,447746 5.03338e+006,447739
> 5.03338e+006,447718 5.03338e+006,447696 5.03341e+006,447689
> 5.03344e+006,447672 5.0335e+006))POLYGON((447890 5.0335e+006,448000
> 5.0335e+006,448000 5.03308e+006,447956 5.03304e+006,447900 5.033e+006,447839
> 5.03296e+006,447835 5.03295e+006,447797 5.03299e+006,447784
> 5.03304e+006,447777 5.0331e+006,447766 5.03315e+006,447767
> 5.03316e+006,447778 5.03318e+006,447779 5.03324e+006,447816
> 5.03332e+006,447816 5.03333e+006,447780 5.03334e+006,447765
> 5.03335e+006,447804 5.03337e+006,447841 5.0334e+006,447872
> 5.03345e+006,447891 5.0335e+006,447890 5.0335e+006),(447849
> 5.03319e+006,447869 5.03319e+006,447907 5.03323e+006,447923
> 5.03326e+006,447951 5.0333e+006,447951 5.03332e+006,447929
> 5.03335e+006,447907 5.03336e+006,447900 5.03337e+006,447878
> 5.03338e+006,447872 5.03337e+006,447839 5.03331e+006,447813
> 5.03326e+006,447812 5.03323e+006,447829 5.0332e+006,447849 5.03319e+006))
> and the output set has only one:
> POLYGON((447872 5.03337e+006,447878 5.03338e+006,447900 5.03337e+006,447907
> 5.03336e+006,447929 5.03335e+006,447951 5.03332e+006,447951
> 5.0333e+006,447923 5.03326e+006,447907 5.03323e+006,447869
> 5.03319e+006,447849 5.03319e+006,447829 5.0332e+006,447812
> 5.03323e+006,447813 5.03326e+006,447839 5.03331e+006,447872 5.03337e+006))

Sorry, maybe you can format your multi-polygon WKT's as a multi-polygon,
and integers as integers. That makes my life a little easier and shows
more clearly what you are trying.

Anyway, I think I reconstructed your testcase. The input is reported as
invalid by both SQL Server and PostGIS ("Self-intersection[447765
503335]"). Probably the reason why it fails, I didn't check the exact
details now.

Using Boost.Geometry you don't have this exact test, but the
"intersects" function reports it indeed as self-intersecting.

I made the polygon valid (by SQL Server), it is then indeed not
intersecting anymore, and I got correct results. My testcode is here:

Regards, Barend

Geometry list run by mateusz at