Class BufferOp
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 capsBufferParameters.CAP_FLAT
- end caps are truncated flat at the line endsBufferParameters.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 joinBufferParameters.JOIN_MITRE
- corners are "sharp" (up to adistance limit
)BufferParameters.JOIN_BEVEL
- corners are beveled (clipped off).
The buffer algorithm can 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.
- Version:
- 1.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Geometry
private BufferParameters
static final int
Deprecated.use BufferParametersstatic final int
Deprecated.use BufferParametersstatic final int
Deprecated.use BufferParametersstatic final int
Deprecated.use BufferParametersprivate double
private static int
A number of digits of precision which leaves some computational "headroom" for floating point operations.private Geometry
private RuntimeException
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes a buffer computation for the given geometryBufferOp
(Geometry g, BufferParameters bufParams) Initializes a buffer computation for the given geometry with the given set of parameters -
Method Summary
Modifier and TypeMethodDescriptionprivate void
bufferFixedPrecision
(PrecisionModel fixedPM) static Geometry
Computes the buffer of a geometry for a given buffer distance.static Geometry
Computes the buffer for a geometry for a given buffer distance and accuracy of approximation.static Geometry
Computes the buffer for a geometry for a given buffer distance and accuracy of approximation.static Geometry
bufferOp
(Geometry g, double distance, BufferParameters params) Computes the buffer for a geometry for a given buffer distance and accuracy of approximation.private void
private void
private void
bufferReducedPrecision
(int precisionDigits) private void
getResultGeometry
(double distance) Returns the buffer computed for a geometry for a given buffer distance.private static double
precisionScaleFactor
(Geometry g, double distance, int maxPrecisionDigits) Compute a scale factor to limit the precision of a given combination of Geometry and buffer distance.void
setEndCapStyle
(int endCapStyle) Specifies the end cap style of the generated buffer.void
setQuadrantSegments
(int quadrantSegments) Sets the number of segments used to approximate a angle fillet
-
Field Details
-
CAP_ROUND
public static final int CAP_ROUNDDeprecated.use BufferParametersSpecifies a round line buffer end cap style.- See Also:
-
CAP_BUTT
public static final int CAP_BUTTDeprecated.use BufferParametersSpecifies a butt (or flat) line buffer end cap style.- See Also:
-
CAP_FLAT
public static final int CAP_FLATDeprecated.use BufferParametersSpecifies a butt (or flat) line buffer end cap style.- See Also:
-
CAP_SQUARE
public static final int CAP_SQUAREDeprecated.use BufferParametersSpecifies a square line buffer end cap style.- See Also:
-
MAX_PRECISION_DIGITS
private static int MAX_PRECISION_DIGITSA number of digits of precision which leaves some computational "headroom" for floating point operations. This value should be less than the decimal precision of double-precision values (16). -
argGeom
-
distance
private double distance -
bufParams
-
resultGeometry
-
saveException
-
-
Constructor Details
-
BufferOp
Initializes a buffer computation for the given geometry- Parameters:
g
- the geometry to buffer
-
BufferOp
Initializes a buffer computation for the given geometry with the given set of parameters- Parameters:
g
- the geometry to bufferbufParams
- the buffer parameters to use
-
-
Method Details
-
precisionScaleFactor
Compute a scale factor to limit the precision of a given combination of Geometry and buffer distance. The scale factor is determined by the number of digits of precision in the (geometry + buffer distance), limited by the suppliedmaxPrecisionDigits
value.The scale factor is based on the absolute magnitude of the (geometry + buffer distance). since this determines the number of digits of precision which must be handled.
- Parameters:
g
- the Geometry being buffereddistance
- the buffer distancemaxPrecisionDigits
- the max # of digits that should be allowed by the precision determined by the computed scale factor- Returns:
- a scale factor for the buffer computation
-
bufferOp
Computes the buffer of a geometry for a given buffer distance.- Parameters:
g
- the geometry to bufferdistance
- the buffer distance- Returns:
- the buffer of the input geometry
-
bufferOp
Computes the buffer for a geometry for a given buffer distance and accuracy of approximation.- Parameters:
g
- the geometry to bufferdistance
- the buffer distanceparams
- the buffer parameters to use- Returns:
- the buffer of the input geometry
-
bufferOp
Computes the buffer for a geometry for a given buffer distance and accuracy of approximation.- Parameters:
g
- the geometry to bufferdistance
- the buffer distancequadrantSegments
- the number of segments used to approximate a quarter circle- Returns:
- the buffer of the input geometry
-
bufferOp
Computes the buffer for a geometry for a given buffer distance and accuracy of approximation.- Parameters:
g
- the geometry to bufferdistance
- the buffer distancequadrantSegments
- the number of segments used to approximate a quarter circleendCapStyle
- the end cap style to use- Returns:
- the buffer of the input geometry
-
setEndCapStyle
public void setEndCapStyle(int endCapStyle) Specifies the end cap style of the generated buffer. The styles supported areBufferParameters.CAP_ROUND
,BufferParameters.CAP_FLAT
, andBufferParameters.CAP_SQUARE
. The default is CAP_ROUND.- Parameters:
endCapStyle
- the end cap style to specify
-
setQuadrantSegments
public void setQuadrantSegments(int quadrantSegments) Sets the number of segments used to approximate a angle fillet- Parameters:
quadrantSegments
- the number of segments in a fillet for a quadrant
-
getResultGeometry
Returns the buffer computed for a geometry for a given buffer distance.- Parameters:
distance
- the buffer distance- Returns:
- the buffer of the input geometry
-
computeGeometry
private void computeGeometry() -
bufferReducedPrecision
private void bufferReducedPrecision() -
bufferOriginalPrecision
private void bufferOriginalPrecision() -
bufferReducedPrecision
private void bufferReducedPrecision(int precisionDigits) -
bufferFixedPrecision
-