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

[FEA]: Identify and fix/report issues with MultiLineString.crosses #1210

Open
thomcom opened this issue Jun 30, 2023 · 1 comment · May be fixed by #1220
Open

[FEA]: Identify and fix/report issues with MultiLineString.crosses #1210

thomcom opened this issue Jun 30, 2023 · 1 comment · May be fixed by #1220
Labels
feature request New feature or request

Comments

@thomcom
Copy link
Contributor

thomcom commented Jun 30, 2023

Is this a new feature, an improvement, or a change to existing functionality?

New Feature

How would you describe the priority of this feature request

Critical (currently preventing usage)

Please provide a clear description of problem you would like to solve.

This issue is that a MultiLineString made from two identical linestrings changes its crosses result as opposed to using the linestrings individually.

from shapely.geometry import LineString, MultiLineString
l1 = LineString([(0, 0), (1, 1)])
l2 = LineString([(0, 0), (1, 1)])
l = LineString([(0, 1), (0, 0), (1, 0)])
m = MultiLineString([l1, l2])
print(l1.crosses(l))
print(l2.crosses(l))
print(m.crosses(l))
False
False
True

Because I'm writing test generators that build a variety of tests from more basic inputs, I'm seeing this occur a few times in cases where a MultLineString a is created via duplicating another LineString b twice: a = MultiLineString([b, b]).

I'm confused because the problem doesn't occur if the LineStrings that comprise a have no intersection:

a = LineString([(0, 1), (0, 0), (1, 0)])
b = LineString([(0, 0.75), (1, 0.75)])
c = LineString([(0, 0.25), (1, 0.25)])
display(GeometryCollection([a, b, c]))
print(a.crosses(b))
print(a.crosses(c))
print(a.crosses(MultiLineString([b, c])))
print(a.crosses(MultiLineString([b, b])))
print(a.crosses(MultiLineString([c, c])))

image

However, if the LineStrings that make up a share a vertex, and that vertex intersects with l, then it seems like the LineStrings are combined into a single LineString, then crosses is computed. Anyway I'm just taking some notes here and reporting on my progress.

a = LineString([(0, 1), (0, 0), (1, 0)])
b = LineString([(0, 0), (1, 1)])
c = LineString([(0, 0), (1, 0.5)])
display(GeometryCollection([a, b, c]))
print(a.crosses(b))
print(a.crosses(c))
print(a.crosses(MultiLineString([b, c])))
print(a.crosses(MultiLineString([b, b])))
print(a.crosses(MultiLineString([c, c])))

image

False
False
True
True
True

As you can see, the crosses result of a MultiLineString is not taking the and or or result of crosses on all the individual LineStrings.

Describe any alternatives you have considered

No response

Additional context

No response

@thomcom thomcom added the feature request New feature or request label Jun 30, 2023
@harrism
Copy link
Member

harrism commented Jul 4, 2023

The title of this issue is very vague. Can you better summarize the request in the title?

@thomcom thomcom changed the title [FEA]: Wrangling MultiLineString.crosses [FEA]: Identify and fix/report issues with MultiLineString.crosses Jul 6, 2023
@thomcom thomcom linked a pull request Jul 17, 2023 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants