How to use the @turf/convex function in @turf/convex

To help you get started, we’ve selected a few @turf/convex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Turfjs / turf / packages / turf-center-of-mass / index.ts View on Github external
if (sArea === 0) {
            return centre;
        } else {
            // Compute the signed area, and factorize 1/6A
            var area = sArea * 0.5;
            var areaFactor = 1 / (6 * area);

            // Compute the final coordinates, adding back the values that have been neutralized
            return point([
                translation[0] + areaFactor * sx,
                translation[1] + areaFactor * sy
            ], options.properties);
        }
    default:
        // Not a polygon: Compute the convex hull and work with that
        var hull = convex(geojson);

        if (hull) return centerOfMass(hull, {properties: options.properties});
        // Hull is empty: fallback on the centroid
        else return centroid(geojson, {properties: options.properties});
    }
}
github nav-e / nav-e / src / reachability.js View on Github external
}).then((data) => {
            const vertices = data.features[0].geometry.coordinates[0];
            const pointsArray = [];
            // convert vertices to turf.js points
            vertices.forEach(vertex => pointsArray.push(point(vertex)));
            // apply convex hull computation
            const hull = convex(featureCollection(pointsArray));
            return hull.geometry.coordinates[0];
          }).catch(() => false);
};

@turf/convex

turf convex module

MIT
Latest version published 3 months ago

Package Health Score

96 / 100
Full package analysis

Popular @turf/convex functions