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

line intersect algorithm for robust line and multiline support #4

Open
morganherlocker opened this issue Dec 15, 2014 · 1 comment
Open

Comments

@morganherlocker
Copy link
Member

rough algorithm:

  1. get all line segments
  2. get all intersections between all line segments
  3. foreach intersection:
    1. add each vertex clockwise from the intersection
    2. at each intersection, take a "right turn" jump onto the intersecting segment
    3. add vertices to a new polygon ring

This could probably be done more quickly with some graph datastructures or possibly a sweepline. It will probably be O(n^2) at the fastest though. Also note that this approach throws out stray lines that do not intersect another segment. These could be wrapped as well using the method currently employed in a 2nd sweep.

Q: is this closer to the expected behavior of this tool? How does QGIS' Vector > Geometry Tools > Lines to polygons work?

@morganherlocker
Copy link
Member Author

looks like this is how the qgis polygonizer plugin works:

http://confound.me.uk/maps/ppv4.pdf

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

1 participant