Open cglacet opened 6 years ago
Hi @cglacet
Have you tried adjusting the maxEdge
option, perhaps try setting it to 0 and slowly adjusting upward?
Hello!
No I haven't try, I will as soon as I can. But shouldn't a larger maxEdge allow for a longer perimeter hull and thus a better concave fit to my input?
Looking at this a bit further we should probably change out our algorithm for concaveman
I updated the gist with the comparison Turf vs. Concaveman. The result from Concaveman seems way closer to what I expected in the first place.
Of course this is just one example and it doesn't prove Concaveman is good, but it's a start for me.
In case someone needs this too, here is the code I used to test both the Turf and the Concaveman versions (with input.json):
import testPoints from './input.json';
import concaveman from 'concaveman';
import turfConcave from '@turf/concave';
import { polygon as turfPolygon, featureCollection } from '@turf/helpers';
function turfConcaveman(points:FeatureCollection<Point>){
const coordinates = points.features.map(f => f.geometry.coordinates);
return turfPolygon([concaveman(coordinates)]);
}
const turf = {
polygon: turfPolygon,
featureCollection,
concaveman: turfConcaveman,
concave: turfConcave,
};
const polygonCave = turf.concaveman(testPoints);
const polygonTurf = turf.concave(testPoints);
console.log(JSON.stringify(turf.featureCollection([polygonTurf, polygonCave, ...testPoints.features])));
Same problem here (Turf 6.5.0) : a convex hull is returned instead of a concave one.
Not sure if it always happen, but here is an example of coordinates for which the hull is not concave. Just to be sure that we talk about the same concave hull, here is what I expect:
My version is
@turf/concave@6.0.5
but it seems like the same bug appears on older versions too.