public class BufferOp extends Object
In GIS, the positive (or negative) buffer of a geometry is defined as the Minkowski sum (or difference) of the geometry with a circle of radius equal to the absolute value of the buffer distance. In the CAD/CAM world buffers are known as offset curves. In morphological analysis the operation of positive and negative buffering is referred to as erosion and dilation
The buffer operation always returns a polygonal result.
The negative or zero-distance buffer of lines and points is always an empty Polygon
.
Since true buffer curves may contain circular arcs,
computed buffer polygons are only approximations to the true geometry.
The user can control the accuracy of the approximation by specifying
the number of linear segments used to approximate arcs.
This is specified via BufferParameters.setQuadrantSegments(int)
or setQuadrantSegments(int)
.
The end cap style of a linear buffer may be specified
. The
following end cap styles are supported:
BufferParameters.CAP_ROUND
- the usual round end caps
BufferParameters.CAP_FLAT
- end caps are truncated flat at the line ends
BufferParameters.CAP_SQUARE
- end caps are squared off at the buffer distance beyond the line ends
The join style of the corners in a buffer may be specified
. The
following join styles are supported:
BufferParameters.JOIN_ROUND
- the usual round join
BufferParameters.JOIN_MITRE
- corners are "sharp" (up to a distance limit
)
BufferParameters.JOIN_BEVEL
- corners are beveled (clipped off).
The buffer algorithm may perform simplification on the input to increase performance.
The simplification is performed a way that always increases the buffer area
(so that the simplified input covers the original input).
The degree of simplification can be specified
,
with a default
used otherwise.
Note that if the buffer distance is zero then so is the computed simplify tolerance,
no matter what the simplify factor.
Buffer results are always valid geometry. Given this, computing a zero-width buffer of an invalid polygonal geometry is an effective way to "validify" the geometry. Note however that in the case of self-intersecting "bow-tie" geometries, only the largest enclosed area will be retained.
Modifier and Type | Field and Description |
---|---|
static int |
CAP_BUTT
Deprecated.
use BufferParameters
|
static int |
CAP_FLAT
Deprecated.
use BufferParameters
|
static int |
CAP_ROUND
Deprecated.
use BufferParameters
|
static int |
CAP_SQUARE
Deprecated.
use BufferParameters
|
Constructor and Description |
---|
BufferOp(Geometry g)
Initializes a buffer computation for the given geometry
|
BufferOp(Geometry g,
BufferParameters bufParams)
Initializes a buffer computation for the given geometry
with the given set of parameters
|
Modifier and Type | Method and Description |
---|---|
static Geometry |
bufferByZero(Geometry geom,
boolean isBothOrientations)
Buffers a geometry with distance zero.
|
static Geometry |
bufferOp(Geometry g,
double distance)
Computes the buffer of a geometry for a given buffer distance.
|
static Geometry |
bufferOp(Geometry g,
double distance,
BufferParameters params)
Computes the buffer for a geometry for a given buffer distance
and accuracy of approximation.
|
static Geometry |
bufferOp(Geometry g,
double distance,
int quadrantSegments)
Computes the buffer for a geometry for a given buffer distance
and accuracy of approximation.
|
static Geometry |
bufferOp(Geometry g,
double distance,
int quadrantSegments,
int endCapStyle)
Computes the buffer for a geometry for a given buffer distance
and accuracy of approximation.
|
Geometry |
getResultGeometry(double distance)
Returns the buffer computed for a geometry for a given buffer distance.
|
void |
setEndCapStyle(int endCapStyle)
Specifies the end cap style of the generated buffer.
|
void |
setQuadrantSegments(int quadrantSegments)
Sets the number of line segments in a quarter-circle
used to approximate angle fillets for round end caps and joins.
|
public static final int CAP_ROUND
public static final int CAP_BUTT
public static final int CAP_FLAT
public static final int CAP_SQUARE
public BufferOp(Geometry g)
g
- the geometry to bufferpublic BufferOp(Geometry g, BufferParameters bufParams)
g
- the geometry to bufferbufParams
- the buffer parameters to usepublic static Geometry bufferOp(Geometry g, double distance)
g
- the geometry to bufferdistance
- the buffer distancepublic static Geometry bufferOp(Geometry g, double distance, BufferParameters params)
g
- the geometry to bufferdistance
- the buffer distanceparams
- the buffer parameters to usepublic static Geometry bufferOp(Geometry g, double distance, int quadrantSegments)
g
- the geometry to bufferdistance
- the buffer distancequadrantSegments
- the number of segments used to approximate a quarter circlepublic static Geometry bufferOp(Geometry g, double distance, int quadrantSegments, int endCapStyle)
g
- the geometry to bufferdistance
- the buffer distancequadrantSegments
- the number of segments used to approximate a quarter circleendCapStyle
- the end cap style to usepublic static Geometry bufferByZero(Geometry geom, boolean isBothOrientations)
This can be used to fix an invalid polygonal geometry to be valid (i.e. with no self-intersections). For some uses (e.g. fixing the result of a simplification) a better result is produced by using only the max-area orientation. Other uses (e.g. fixing geometry) require both orientations to be used.
This function is for INTERNAL use only.
geom
- the polygonal geometry to buffer by zeroisBothOrientations
- true if both orientations of input rings should be usedpublic void setEndCapStyle(int endCapStyle)
BufferParameters.CAP_ROUND
, BufferParameters.CAP_FLAT
, and BufferParameters.CAP_SQUARE
.
The default is CAP_ROUND.endCapStyle
- the end cap style to specifypublic void setQuadrantSegments(int quadrantSegments)
quadrantSegments
- the number of segments in a fillet for a quadrantpublic Geometry getResultGeometry(double distance)
distance
- the buffer distanceCopyright © 2024. All rights reserved.