turf
turf copied to clipboard
function for oriented, not-axis-aligned envelope (minimum rotated rectangle)
It would be great if Turf not only supported calculating the axis-aligned envelope (bounding box geometry) but also a not-axis-aligned envelope, for example like shapely and PostGIS do.
This can naively be implemented by rotating the convex hull of a geometry, getting the axis-aligned envelope of the rotated, stopping when the envelope has a minimum area, and then rotating the axis-aligned envelope by the angle when that area was reached. But I'm sure there is a more efficient algorithm.
Thanks for suggesting this @quassy. Are you interested in submitting a PR implementing this functionality?
Not too familiar with TS but I will try. After some research I found this https://www.npmjs.com/package/geojson-minimum-bounding-rectangle which is actually using Turf, do you think it can serve as a base for a Turf module turf-oriented-envelope (exports orientedEnvelope)?
For attribution I need to mention @matthiasfeist in the module license file, correct?
There are also other options:
- We could also use my module directly in Turf
- I'd be happy to move my source code into TurfJS and deprecate my npm module then instead.
Up to the maintainers :)
Thanks for jumping in the TS deep end to put together a PR @quassy. And for those couple of usage options @matthiasfeist. Very cool to see some new functionality coming to Turf 🤩
@matthiasfeist if you're willing to incorporate your code into Turf that would be amazing.
Option 2 would probably be cleaner, mostly so we're not creating any sort of circular import. Though I wouldn't expect you to deprecate your npm presence as well. Only if you really want to.
I'd be happy to incorporate my code into turfjs. But that would mean we would scrap @quassy's PR? Is that OK for you, @quassy ?
I'd be happy to incorporate my code into turfjs. But that would mean we would scrap @quassy's PR?
Isn't that what my PR is already doing? I basically took your code, added a test and deduplicated it into one function with an optional parameter. Happy to work further on the PR if there is anything you think is missing or could be improved :)