Class BufferParameters
- java.lang.Object
-
- org.locationtech.jts.operation.buffer.BufferParameters
-
public class BufferParameters extends java.lang.Object
A value class containing the parameters which specify how a buffer should be constructed.The parameters allow control over:
- Quadrant segments (accuracy of approximation for circular arcs)
- End Cap style
- Join style
- Mitre limit
- whether the buffer is single-sided
- Author:
- Martin Davis
-
-
Field Summary
Fields Modifier and Type Field Description static int
CAP_FLAT
Specifies a flat line buffer end cap style.static int
CAP_ROUND
Specifies a round line buffer end cap style.static int
CAP_SQUARE
Specifies a square line buffer end cap style.static double
DEFAULT_MITRE_LIMIT
The default mitre limit Allows fairly pointy mitres.static int
DEFAULT_QUADRANT_SEGMENTS
The default number of facets into which to divide a fillet of 90 degrees.static double
DEFAULT_SIMPLIFY_FACTOR
The default simplify factor Provides an accuracy of about 1%, which matches the accuracy of the default Quadrant Segments parameter.static int
JOIN_BEVEL
Specifies a bevel join style.static int
JOIN_MITRE
Specifies a mitre join style.static int
JOIN_ROUND
Specifies a round join style.
-
Constructor Summary
Constructors Constructor Description BufferParameters()
Creates a default set of parametersBufferParameters(int quadrantSegments)
Creates a set of parameters with the given quadrantSegments value.BufferParameters(int quadrantSegments, int endCapStyle)
Creates a set of parameters with the given quadrantSegments and endCapStyle values.BufferParameters(int quadrantSegments, int endCapStyle, int joinStyle, double mitreLimit)
Creates a set of parameters with the given parameter values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static double
bufferDistanceError(int quadSegs)
Computes the maximum distance error due to a given level of approximation to a true arc.BufferParameters
copy()
int
getEndCapStyle()
Gets the end cap style.int
getJoinStyle()
Gets the join style.double
getMitreLimit()
Gets the mitre ratio limit.int
getQuadrantSegments()
Gets the number of quadrant segments which will be used to approximate angle fillets in round endcaps and joins.double
getSimplifyFactor()
Gets the simplify factor.boolean
isSingleSided()
Tests whether the buffer is to be generated on a single side only.void
setEndCapStyle(int endCapStyle)
Specifies the end cap style of the generated buffer.void
setJoinStyle(int joinStyle)
Sets the join style for outside (reflex) corners between line segments.void
setMitreLimit(double mitreLimit)
Sets the limit on the mitre ratio used for very sharp corners.void
setQuadrantSegments(int quadSegs)
Sets the number of line segments in a quarter-circle used to approximate angle fillets in round endcaps and joins.void
setSimplifyFactor(double simplifyFactor)
Sets the factor used to determine the simplify distance tolerance for input simplification.void
setSingleSided(boolean isSingleSided)
Sets whether the computed buffer should be single-sided.
-
-
-
Field Detail
-
CAP_ROUND
public static final int CAP_ROUND
Specifies a round line buffer end cap style.- See Also:
- Constant Field Values
-
CAP_FLAT
public static final int CAP_FLAT
Specifies a flat line buffer end cap style.- See Also:
- Constant Field Values
-
CAP_SQUARE
public static final int CAP_SQUARE
Specifies a square line buffer end cap style.- See Also:
- Constant Field Values
-
JOIN_ROUND
public static final int JOIN_ROUND
Specifies a round join style.- See Also:
- Constant Field Values
-
JOIN_MITRE
public static final int JOIN_MITRE
Specifies a mitre join style.- See Also:
- Constant Field Values
-
JOIN_BEVEL
public static final int JOIN_BEVEL
Specifies a bevel join style.- See Also:
- Constant Field Values
-
DEFAULT_QUADRANT_SEGMENTS
public static final int DEFAULT_QUADRANT_SEGMENTS
The default number of facets into which to divide a fillet of 90 degrees. A value of 8 gives less than 2% max error in the buffer distance. For a max error of < 1%, use QS = 12. For a max error of < 0.1%, use QS = 18.- See Also:
- Constant Field Values
-
DEFAULT_MITRE_LIMIT
public static final double DEFAULT_MITRE_LIMIT
The default mitre limit Allows fairly pointy mitres.- See Also:
- Constant Field Values
-
DEFAULT_SIMPLIFY_FACTOR
public static final double DEFAULT_SIMPLIFY_FACTOR
The default simplify factor Provides an accuracy of about 1%, which matches the accuracy of the default Quadrant Segments parameter.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BufferParameters
public BufferParameters()
Creates a default set of parameters
-
BufferParameters
public BufferParameters(int quadrantSegments)
Creates a set of parameters with the given quadrantSegments value.- Parameters:
quadrantSegments
- the number of quadrant segments to use
-
BufferParameters
public BufferParameters(int quadrantSegments, int endCapStyle)
Creates a set of parameters with the given quadrantSegments and endCapStyle values.- Parameters:
quadrantSegments
- the number of quadrant segments to useendCapStyle
- the end cap style to use
-
BufferParameters
public BufferParameters(int quadrantSegments, int endCapStyle, int joinStyle, double mitreLimit)
Creates a set of parameters with the given parameter values.- Parameters:
quadrantSegments
- the number of quadrant segments to useendCapStyle
- the end cap style to usejoinStyle
- the join style to usemitreLimit
- the mitre limit to use
-
-
Method Detail
-
getQuadrantSegments
public int getQuadrantSegments()
Gets the number of quadrant segments which will be used to approximate angle fillets in round endcaps and joins.- Returns:
- the number of quadrant segments
-
setQuadrantSegments
public void setQuadrantSegments(int quadSegs)
Sets the number of line segments in a quarter-circle used to approximate angle fillets in round endcaps and joins. The value should be at least 1.This determines the error in the approximation to the true buffer curve. The default value of 8 gives less than 2% error in the buffer distance. For a error of < 1%, use QS = 12. For a error of < 0.1%, use QS = 18. The error is always less than the buffer distance (in other words, the computed buffer curve is always inside the true curve).
- Parameters:
quadSegs
- the number of segments in a fillet for a circle quadrant
-
bufferDistanceError
public static double bufferDistanceError(int quadSegs)
Computes the maximum distance error due to a given level of approximation to a true arc.- Parameters:
quadSegs
- the number of segments used to approximate a quarter-circle- Returns:
- the error of approximation
-
getEndCapStyle
public int getEndCapStyle()
Gets the end cap style.- Returns:
- the end cap style code
-
setEndCapStyle
public void setEndCapStyle(int endCapStyle)
Specifies the end cap style of the generated buffer. The styles supported areCAP_ROUND
,CAP_FLAT
, andCAP_SQUARE
. The default isCAP_ROUND
.- Parameters:
endCapStyle
- the code for the end cap style
-
getJoinStyle
public int getJoinStyle()
Gets the join style.- Returns:
- the join style code
-
setJoinStyle
public void setJoinStyle(int joinStyle)
Sets the join style for outside (reflex) corners between line segments. The styles supported areJOIN_ROUND
,JOIN_MITRE
and {link JOIN_BEVEL}. The default isJOIN_ROUND
.- Parameters:
joinStyle
- the code for the join style
-
getMitreLimit
public double getMitreLimit()
Gets the mitre ratio limit.- Returns:
- the limit value
-
setMitreLimit
public void setMitreLimit(double mitreLimit)
Sets the limit on the mitre ratio used for very sharp corners. The mitre ratio is the ratio of the distance from the corner to the end of the mitred offset corner. When two line segments meet at a sharp angle, a miter join will extend far beyond the original geometry. (and in the extreme case will be infinitely far.) To prevent unreasonable geometry, the mitre limit allows controlling the maximum length of the join corner. Corners with a ratio which exceed the limit will be beveled.- Parameters:
mitreLimit
- the mitre ratio limit
-
setSingleSided
public void setSingleSided(boolean isSingleSided)
Sets whether the computed buffer should be single-sided. A single-sided buffer is constructed on only one side of each input line.The side used is determined by the sign of the buffer distance:
- a positive distance indicates the left-hand side
- a negative distance indicates the right-hand side
The End Cap Style for single-sided buffers is always ignored, and forced to the equivalent of CAP_FLAT.
- Parameters:
isSingleSided
- true if a single-sided buffer should be constructed
-
isSingleSided
public boolean isSingleSided()
Tests whether the buffer is to be generated on a single side only.- Returns:
- true if the generated buffer is to be single-sided
-
getSimplifyFactor
public double getSimplifyFactor()
Gets the simplify factor.- Returns:
- the simplify factor
-
setSimplifyFactor
public void setSimplifyFactor(double simplifyFactor)
Sets the factor used to determine the simplify distance tolerance for input simplification. Simplifying can increase the performance of computing buffers. Generally the simplify factor should be greater than 0. Values between 0.01 and .1 produce relatively good accuracy for the generate buffer. Larger values sacrifice accuracy in return for performance.- Parameters:
simplifyFactor
- a value greater than or equal to zero.
-
copy
public BufferParameters copy()
-
-