Opened 12 years ago

Closed 11 years ago

#580 closed defect (invalid)

Contains(Polygon, Point) return False instead of True

Reported by: skurlat Owned by: strk
Priority: blocker Milestone: 3.3.9
Component: Core Version: 3.3.4
Severity: Significant Keywords:
Cc:

Description

Using those two geometries :

POLYGON ((-1.183864 52.951915, -1.183862 52.951903, -1.183890 
52.951900, -1.183924 52.951897, -1.183958 52.951894, -1.183954 
52.951880, -1.183954 52.951878, -1.183932 52.951841, -1.183904 
52.951844, -1.183870 52.951847, -1.183832 52.951852, -1.183824 
52.951838, -1.183820 52.951830, -1.183870 52.951819, -1.183886 
52.951815, -1.183890 52.951819, -1.183929 52.951810, -1.183909 
52.951776, -1.183861 52.951787, -1.183853 52.951788, -1.183842 
52.951770, -1.183970 52.951742, -1.183983 52.951763, -1.183963 
52.951768, -1.183975 52.951788, -1.183994 52.951785, -1.184009 
52.951807, -1.184002 52.951808, -1.184009 52.951835, -1.183990 
52.951836, -1.183990 52.951836, -1.183990 52.951838, -1.184001 
52.951880, -1.184018 52.951954, -1.184020 52.951956, -1.183998 
52.951957, -1.183998 52.951956, -1.183996 52.951948, -1.183970 
52.951906, -1.183936 52.951909, -1.183864 52.951915))

POINT (-1.183972 52.951871)

Check for point in polygon returns false while it should return true.

Attach is a .cpp file that demonstrates it.

Both 3.3.4 and 3.3.5 are having this issue.

Attachments (1)

test_geos_error.cpp (1.1 KB ) - added by skurlat 12 years ago.

Download all attachments as: .zip

Change History (9)

by skurlat, 12 years ago

Attachment: test_geos_error.cpp added

comment:1 by strk, 12 years ago

Milestone: 3.3.53.3.6

Did you check the polygon for validity ?

comment:2 by pramsey, 12 years ago

I did, ST_IsValid says it's valid. And the PostGIS ST_Contains returns true, which would be calculated in the internal liblwgeom code line (point-in-poly), not in GEOS.

comment:3 by strk, 12 years ago

Martin: is JTS affected by this ?

comment:4 by darkblueb, 12 years ago

this rev works for me:

select postgis_full_version();
"POSTGIS="2.0.1 r9979" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 2.0dev, released 2011/12/29" LIBXML="2.7.8" LIBJSON="UNKNOWN" RASTER"

select st_contains(
   'POLYGON ((-1.183864 52.951915, -1.183862 52.951903, -1.183890 
52.951900, -1.183924 52.951897, -1.183958 52.951894, -1.183954 
52.951880, -1.183954 52.951878, -1.183932 52.951841, -1.183904 
52.951844, -1.183870 52.951847, -1.183832 52.951852, -1.183824 
52.951838, -1.183820 52.951830, -1.183870 52.951819, -1.183886 
52.951815, -1.183890 52.951819, -1.183929 52.951810, -1.183909 
52.951776, -1.183861 52.951787, -1.183853 52.951788, -1.183842 
52.951770, -1.183970 52.951742, -1.183983 52.951763, -1.183963 
52.951768, -1.183975 52.951788, -1.183994 52.951785, -1.184009 
52.951807, -1.184002 52.951808, -1.184009 52.951835, -1.183990 
52.951836, -1.183990 52.951836, -1.183990 52.951838, -1.184001 
52.951880, -1.184018 52.951954, -1.184020 52.951956, -1.183998 
52.951957, -1.183998 52.951956, -1.183996 52.951948, -1.183970 
52.951906, -1.183936 52.951909, -1.183864 52.951915))'::geometry,
 'POINT (-1.183972 52.951871)'::geometry );

st_contains
boolean
---------------
t

comment:6 by strk, 11 years ago

Component: DefaultCore
Milestone: 3.3.63.3.7
Owner: changed from geos-devel@… to strk
Priority: majorblocker
Severity: UnassignedSignificant

comment:7 by strk, 11 years ago

Milestone: 3.3.73.3.x

comment:8 by strk, 11 years ago

Resolution: invalid
Status: newclosed

It turns out this bug is invalid. The testcase is testing that the _point_ contains the _polygon_. I've pushed a sane version of the test (passing) to 3.3 branch with r3838 and trunk with r3839

Note: See TracTickets for help on using tickets.