-
Notifications
You must be signed in to change notification settings - Fork 942
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
Question about additional functionality related to lineToPolygon function #1881
Comments
Hi @alexeyvax Turf doesn't support anything like that currently and we'd probably need a new module to do so. Cheers |
@alexeyvax if I understand correctly what you want to do, I think you could do something like this, where I destructured the line into points and generated a concave polygon out of them: function toPoints (features) {
const points = [];
turf.coordEach(features, function (currentCoord) {
points.push(turf.point(turf.getCoords(currentCoord)));
}, {excludeWrapCoord: true});
return turf.featureCollection(points);
}
const hull = turf.concave(toPoints(data)); |
Brilliant solution @stebogit , so elegant! |
Many tanks guys @rowanwins and @stebogit for your replies. Yep, that's definitely what I'm looking for! And can I ask you one more question? Your function it becomes to: Is there some function which can check that the polygon has crossed lines inside? If yes - should call I have some guesses about it:
But I'm not sure that all are work fine here. Maybe you have solution for this? Please share with me. Thanks in advance. |
I can't think of anything generic enough to apply to any possible case. Alternatively you can try |
You could use shamos-hoey to check for self-intersections first before applying the concave function |
Thank you guys @stebogit and @rowanwins . Cheers! |
Hi guys,
Thank you for this awesome library!
I would like to ask you one question regarding converting line to polygon. I'm using
lineToPolygon
function and it works like a charm. But I need more functionality.For example, I have one complex line, something like this, which was converted to polygon via
lineToPolygon
function:There is a lot of lines and shapes within polygon, which are part of this polygon. And I need to reduce it to avoid drawing unnecessary lines and make a correct searching inside it.
So the question is:
Does Turf have functionality to detect crossed lines within polygon, remove these lines and make polygon like on the next screenshot?
Thanks
The text was updated successfully, but these errors were encountered: