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

Create nodes at lines intersections #51

Conversation

jmon12
Copy link
Contributor

@jmon12 jmon12 commented Jul 1, 2022

A node is created at the edges intersections and the corresponding edges are split accordingly.

This is an attempt to fix #15

A node is created at the intersection and the corresponding edges
are split accordingly.

Issue: tomalrussel/snkit#15

NB: the file `pyproject.toml` has beend added for testing with local
dev files.
src/snkit/network.py Outdated Show resolved Hide resolved
src/snkit/network.py Outdated Show resolved Hide resolved
Tests for:
 - multiple intersections
 - partially overlapping lines
 - end-node intersection
 - already split network

NOTE: overlapping lines test doesn't pass!

Issue: tomalrussel/snkit#15
There is now a recursive function extracting the points from
intersections, in an exhaustive way (excluding polygons).

The crossing restriction has been removed because it is wrong
for overlapping segments: the corresponding test now passes.
A notable consequence is the change in handling endpoints:
intersections with endpoints are now accepted.

Issue: tomalrussel/snkit#15
Copy link
Owner

@tomalrussell tomalrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good ☺️ building up a good set of test cases. Splitting out the intersection_endpoints logic helps make things clearer. I'll reply about self-intersection separately.

tests/test_init.py Outdated Show resolved Hide resolved
src/snkit/network.py Outdated Show resolved Hide resolved
src/snkit/network.py Outdated Show resolved Hide resolved
Special treatment of complex lines:
 - self-intersection points need to be found, no built-in way to do so
 - splitting a complex line at a self-intersecting point doesn't do
   what would be expected: a work around when splitting as well.

NB: small fixes from @tomalrussel have been implemented
@jmon12
Copy link
Contributor Author

jmon12 commented Jul 13, 2022

How do you usually handle the conflicts: should I rebase or merge my branch? Or you don't really care?

@tomalrussell
Copy link
Owner

Either is fine, thanks @jmon12!

intersection = [
Point(p) for p, c in Counter(segments_coordinates).items() if c > 1
]
intersection = MultiPoint(intersection)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might have sense to have a dedicated helper function here...

tomalrussell added a commit that referenced this pull request Aug 10, 2022
@tomalrussell tomalrussell merged commit 846ddc1 into tomalrussell:main Aug 10, 2022
@tomalrussell
Copy link
Owner

Hi @jmon12 - apologies for leaving this hanging for a while - I've just fixed the conflicts and merged this in. I think it's in really useful shape, thanks for your work ☺️ let me know if you have any further thoughts on this or other improvements!

@jmon12
Copy link
Contributor Author

jmon12 commented Aug 16, 2022

Hi @tomalrussell, I'm the one to be sorry! I was supposed to resolve the conflicts but was working on something else. Thank you!
While using snkit, I'll maybe implement ticket #58.

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

Successfully merging this pull request may close these issues.

Create nodes at edge intersections
2 participants