How to use the polygon-clipping.union function in polygon-clipping

To help you get started, we’ve selected a few polygon-clipping 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 / src / union / index.js View on Github external
function union(fc) {
    const args = [];
    geomEach(fc, function (geom) {
        if (geom.type === 'Polygon') args.push(geom.coordinates);
        else geom.coordinates.forEach(function (contour) {
            args.push(contour);
        });
    });
    const unioned = polygonClipping.union(args);
    if (unioned.length === 0) return null;
    else return multiPolygon(unioned);
}

polygon-clipping

Apply boolean Polygon clipping operations (intersection, union, difference, xor) to your Polygons & MultiPolygons.

MIT
Latest version published 11 months ago

Package Health Score

69 / 100
Full package analysis