turf.convex doesn't support single or colinear points
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.5k
- Forks
- 1k
- Avg merge
- 1h 11m
- Merged PRs (30d)
- 4
Description
This might be more of a feature request instead of a bug report, but I found the behaviour of turf.convex non-intuitive. I would expect something like this behaviour:
var singlePoint = turf.convex(turf.point([10, 45])); // == turf.point([10, 45])
var twoPoints = turf.featureCollection([
turf.point([10, 45]),
turf.point([11, 45]),
]);
var twoHull = turf.convex(twoPoints) // == turf.lineString([[10, 45], [11, 45]]) (or the other direction)
var colinearPoints = turf.featureCollection([
turf.point([12, 45]),
turf.point([10, 45]),
turf.point([11, 45]),
]);
var colinearHull = turf.convex(colinearPoints) // == turf.lineString([[10, 45], [12, 45]]) (or the other direction)
My exact use-case is to use turf.convex followed by turf.buffer on a set of points, so I don't mind that the intermediate result isn't a polygon, since the final result will be. The two first cases are easy to handle (just check the number of input points), but the third one isn't as easy.
This would also potentially break code that assumes turf.convex will always return a Polygon or throw.
I'm currently at v6.5.0.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the turf.convex entry point and locate its existing tests or implementation. Check how single points, two points, and colinear point collections are handled, then clarify the intended return geometry and compatibility expectations. Done means the requested degenerate-input behavior is covered for the examples in the issue without breaking existing Polygon behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100