Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}