Opened 15 years ago
Closed 15 years ago
#250 closed defect (worksforme)
geos_contains(multipolygon, polygon) returns false when it should return true
| Reported by: | cdestigter | Owned by: | mloskot |
|---|---|---|---|
| Priority: | major | Milestone: | 3.1.1 |
| Component: | Default | Version: | 3.0.0 |
| Severity: | Unassigned | Keywords: | |
| Cc: |
Description
In geodjango:
from django.contrib.gis import geos
g1 = geos.GEOSGeometry('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))')
g2 = geos.GEOSGeometry('POLYGON((1 1,1 2,2 2,2 1,1 1))')
g1.contains(g2)
=> False
g2.within(g1)
=> False
Both of the above should return True. The following combinations work fine though: polygon.contains(polygon) multipolygon.contains(multipolygon) polygon.contains(multipolygon)
It's possible this has been fixed in a more recent version, though I couldn't find any existing tickets on it. Feel free to close if that's the case, stating when it was fixed.
Change History (3)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
Any chance for some feedback or I can just close as worksforme?
I've run the GEOSContainsTest and GEOSWithinTest with current branch 3.0 and both pass:
make[3]: Entering directory `/home/mloskot/dev/geos/_svn/branches/3.0/tests/unit' =============================== GEOS Test Suite Application =============================== capi::GEOSContains: ... 3 capi::GEOSCoordSeq: ..... 5 capi::GEOSSimplify: . 1 capi::GEOSWithin: ... 3 ... geos::util::UniqueCoordinateArrayFilter: . 1 Tests summary: - passed: 409 PASS: geos_unit ============= 1 test passed =============
I've attached patch test-contains-within-branch-3_0.patch which adds the two new tests to the branch 3.0, so others can run these tests on their own.
comment:3 by , 15 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | assigned → closed |
Due to lack of feedback from the ticket reporter, I'm closing it.

I've added new unit tests for C API calls GEOSContains and GEOSWithin (see r2422). The tests include cases you've reported above as test case number 3 (see function void test<3>, in both files).
I've run the tests on Linux 64-bit, certainly, using GEOS from trunk and I couldn't reproduce your problem. IOW, all the tests cases pass as expected.