2

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.

asked Feb 13, 2019 at 13:03

1 Answer 1

2

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.

enter image description here

Ian Turton
84.1k6 gold badges93 silver badges190 bronze badges
answered Feb 13, 2019 at 13:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.