Turfjs / turf

A modular geospatial engine written in JavaScript and TypeScript

Home Page:https://turfjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

turf.convex does not wrap the polygons as expected

huco95 opened this issue · comments

Truf version: 7.0.0-alpha.116
GeoJson: https://gist.github.com/huco95/7d40d02a9fe3e7a0f235e6d76a02e037

I am trying to generate a single polygon from a geometry collection using convex, it wraps the polygons as expected on the left side, but it doesn't do the same in the right side. Is this the expected behavior?
image

Hi @huco95. I believe this is the correct behaviour. Not an expert in this area, so I'll have to lean on wikipedia, which says:

... is convex if, given any two points in the subset, the subset contains the whole line segment that joins them.

If the encompassing polygon "hugged" the inner curve, you could draw a line between two points in your input and it would violate the above.

Might concave do what you want instead?