How to use the jsts/org/locationtech/jts/operation/buffer/BufferParameters function in jsts

To help you get started, we’ve selected a few jsts 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 EventKit / eventkit-cloud / eventkit_cloud / ui / static / ui / app / utils / mapUtils.js View on Github external
export function bufferGeometry(jstsGeometry, bufferSize, bufferPolys) {
    // This buffers jsts points so that those features will have an actual area to be collected.
    // The buffer size is relative to the unit of measurement for the projection.
    // In order to get meters and circles, 3857 should be used.
    const bufferParams = new BufferParameters();
    bufferParams.setJoinStyle(2);

    const size = bufferSize || 1;
    if (bufferPolys) {
        const tempGeom = transformJSTSGeometry(jstsGeometry, 'EPSG:4326', 'EPSG:3857');
        const buff = new BufferOp(tempGeom, bufferParams);
        const geomBuff = buff.getResultGeometry(size);
        return transformJSTSGeometry(geomBuff, 'EPSG:3857', 'EPSG:4326');
    } if (!(jstsGeometry.getGeometryType() === 'Polygon' || jstsGeometry.getGeometryType() === 'MultiPolygon')) {
        const tempGeom = transformJSTSGeometry(jstsGeometry, 'EPSG:4326', 'EPSG:3857');
        return transformJSTSGeometry(BufferOp.bufferOp(tempGeom, size), 'EPSG:3857', 'EPSG:4326');
    }
    return jstsGeometry;
}