Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contains issue for complex LineStrings #17

Closed
sgillies opened this issue Jul 10, 2012 · 7 comments
Closed

Contains issue for complex LineStrings #17

sgillies opened this issue Jul 10, 2012 · 7 comments
Assignees

Comments

@sgillies
Copy link
Contributor

Hi All,

For:
from shapely.geometry import LineString
good1 = LineString([(0,2),(0,0),(2,2)])
good2 = LineString([(2,0),(0,2),(0,0),(2,2)])
broken = LineString([(1,0),(0,2),(0,0),(2,2)])
contained = LineString([(0,0),(2,2)])
print good1.contains(contained), good2.contains(contained), broken.contains(contained)

I get:
True True False

where I would expect:
True True True

I am running: Shapely-1.2.14-py2.6.

Am I overlooking something?

Thanks for your help,
Julia

@ghost ghost assigned sgillies Jul 10, 2012
@mwtoews
Copy link
Member

mwtoews commented Jul 12, 2012

I'm seeing odd behaviour elsewhere, where the DE-9IMs are completely different between Shapely and JTS. If broken = A, and contained = B:

Shapely:
A.relate(B) : 101F001F2
B.relate(A) : 1F100F102

JTS (1.12.0):
AB : 001F001F2
BA : 0F100F102

Furthermore, Within and Contains are all false for all combinations. What's really odd with the JTS result is that the interior ∩ interior result (first position) is '0', meaning only a point interior intersection. This should be a '1' for line, like GEOS/Shapely has it.

The expected intersection matrix should be:
AB : 101F00FF2
BA : 1FF00F102

@sgillies
Copy link
Contributor Author

What's the GEOS version?

@mwtoews
Copy link
Member

mwtoews commented Jul 24, 2012

The behaviour is consistent with Shapely versions 1.2.14 to the latest, which have shapely.geos.geos_capi_version (1, 6, 2) to (1, 7, 1) (I'm not sure how to squeeze the GEOS version out of Shapely, only the C API version).

Also tested this case with POSTGIS="2.0.0 r9605" / GEOS="3.3.3-CAPI-1.7.4" with same results:

with data as (select 'LINESTRING (0 2, 0 0, 2 2)'::geometry AS good1,
    'LINESTRING (2 0, 0 2, 0 0, 2 2)'::geometry AS good2,
    'LINESTRING (1 0, 0 2, 0 0, 2 2)'::geometry AS broken,
    'LINESTRING (0 0, 2 2)'::geometry AS contained)
select ST_Contains(good1, contained),
    ST_Contains(good2, contained),
    ST_Contains(broken, contained)
from data;

returns t t f

@sgillies
Copy link
Contributor Author

Do you mean PostGIS has the same results as JTS, or same results as Shapely? If the latter, we should forward this on to the GEOS tracker (I'm subscribed to that too).

@mwtoews
Copy link
Member

mwtoews commented Jul 24, 2012

All tested versions of JTS, PostGIS and Shapely have the same results for "Contains". I recall Shapely and PostGIS have the same DE-9IM, thus this suggests issues with GEOS.

This issue has been passed to GEOS http://trac.osgeo.org/geos/ticket/572

aronbierbaum pushed a commit to aronbierbaum/shapely that referenced this issue Jan 6, 2015
@mwtoews
Copy link
Member

mwtoews commented Mar 26, 2019

FYI, this issue has been filed further upstream with JTS: locationtech/jts#396

jorisvandenbossche pushed a commit to jorisvandenbossche/shapely that referenced this issue Nov 6, 2021
Add voronoi and delaunay functions
@dr-jts
Copy link

dr-jts commented Jul 10, 2023

This is now fixed by libgeos/geos#937

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants