-
Notifications
You must be signed in to change notification settings - Fork 943
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
New module @turf/linestring-to-polygon #672
Conversation
@DenisCarriere @rowanwins Man this is definitely gonna help for |
@DenisCarriere @rowanwins check this out: https://jsfiddle.net/jStefano/5xwxxco2/ |
😄 Indeed! This will help a lot of the modules that only handle LineStrings operations and need to easily convert them back into Polygons.
There's two very different tests going on here:
Current geometry transformations
Proposed geometry transformations (@stebogit's suggestion)
I'm 👍 on this change, I prefer this proposed transformation. AutoComplete
Correct, however I've added a Sometimes a LineString will be "pretty close" but not exact, therefore it's pretty handy to have the CC: @stebogit |
Changes based on #672 (comment) - Convert FeatureCollection & GeometryCollection to MultiPolygon - Colorize test fixtures (easier to visualize) - Update Typescript defintion & tests CC: @stebogit
I've updated the repo with the proposed changes ( 👍 it's a lot better now). Key take awaysOutput type changes based on input type
The @stebogit Feel free to include more test fixtures |
Open an issue ticket to Google Maps API 🤓, that Polygon's geometry is perfectly valid. |
@DenisCarriere you know what, I did already at the time 🤓, and they told me the right geometry is a |
There's QGIS that you can open a GeoJSON, just loaded your Polygon and it works just fine. |
@DenisCarriere you are right, no need for My current approach (in Any thought? cc: @rowanwins |
👍 Agreed, I'll add that in my next commit, a solution that won't be so computational heavy would be to retrieve all the Just recently, I've improved Example:Red Lines: LineString input CC: @stebogit @rowanwins |
@DenisCarriere that is a brilliant idea! 👍 cc: @rowanwins |
@DenisCarriere what if you simply "remove" the larger polygon (that you identify calculating the area or larger cc: @rowanwins |
@stebogit Well that would mean the user is trying to make an invalid geometry (still somewhat works...). The largest linestring would be the first polygon and the smaller polygon would be the 2nd in the Array. The result would look something like this. https://gist.github.com/a7375bcb2b46c9eb35dde17346dfdc49 You would then need to use The goal of this library isn't to perform any |
- Add Test fixture with outer ring in middle position (must be placed in first position) - Update Typescript definition - Update benchmark results (2-3x peformance loss, not significant enough to complain) CC: @stebogit
@stebogit Added a new param No significant performance loss (2x-3x slower and changes only apply to MultiPolygons). Added a new test Fixture for this test case |
Going to merge this PR now, @stebogit don't hesitate to send more issues/concern afterwards. |
@DenisCarriere I added a failing test, which fails because currently the method considers all the The method should be able to detect which rings are part of a
and
It might become computationally expensive, but this is definitely a complex problem! 😕 |
New module 🎉 @turf/linestring-to-polygon
Converts (Multi)LineString(s) to Polygon(s).
To-Do
JSDocs
Dependencies
Benchmark Results
Example 1 (with holes)
Before: Feature Collection of (Multi)LineString
After: Feature Collection of Polygon (hole is preserved).
Example 2 (incomplete lines)
Before: Incomplete (Multi)LineString
After: Completed Polygons
CC: @Turfjs/ownership