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

Add support for clipping a multi-line by a polygon #91

Open
lostPixels opened this issue Jul 27, 2021 · 1 comment
Open

Add support for clipping a multi-line by a polygon #91

lostPixels opened this issue Jul 27, 2021 · 1 comment
Labels

Comments

@lostPixels
Copy link

Hello,

This is a feature request for adding new functionality to multilines. I'd like to be able to "trim" a multi-line down to only segments that exist inside of a polygon. Much like how a "difference" boolean operation between polygons work, but I would like to use a line instead of a polygon.

Hopefully this poorly drawn graphic helps visualize the ask.

image

There's not any existing library in JS that does this, and my SO question hasnt received a ton of action: https://stackoverflow.com/questions/68382197/clip-a-line-by-a-polygon-in-javascript

For single segments I can write my own version of this algorithm, but introducing multilines is a complexity that I can't seem to conquer.

@alexbol99
Copy link
Owner

Hello, James,

The idea of algorithm is:

  1. Find intersection point between multiline and polygon
  2. Insert intersection points into multiline
  3. Return edges of split multiline that lay inside polygon

All these tools implemented in the library.
If you send me a real data I will show you how to do that.

Do you need that parts of multiline inside polygon will be ordered in a specific order?

Best regards,
Alex

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

No branches or pull requests

2 participants