Is it somehow possible to change the buffer style of the build in GeoTools buffer() function? Or is there a User Definded Function for that? I just saw a different buffer function where one could define the number of segments.
I need something similar to the options QGIS has. I want to define the "End cap style" and the "join style". At the moment GeoTools creates the buffers with round corners. But when I for example buffer a triangle I want it to remain a triangle just with a greater area.
1 Answer 1
Ok sorry I asked. Right after posting I stumbled across the answer ... Silly me .. Here is the code one can use:
int nSegments = 5;
int cap = BufferParameters.CAP_FLAT;
int join = BufferParameters.JOIN_MITRE;
BufferParameters bufferParam = new BufferParameters(nSegments, cap, join, BufferParameters.DEFAULT_MITRE_LIMIT);
BufferOp ops = new BufferOp(transformedGeometry, bufferParam);
Geometry bufferedtransformedGeometry = ops.getResultGeometry(distance);
using
import org.locationtech.jts.operation.buffer.BufferOp;
import org.locationtech.jts.operation.buffer.BufferParameters;
EDIT
For anyone interested in the differences between the above and a simple buffer, here is a picture.