Class BufferInputLineSimplifier
- java.lang.Object
-
- org.locationtech.jts.operation.buffer.BufferInputLineSimplifier
-
public class BufferInputLineSimplifier extends java.lang.Object
Simplifies a buffer input line to remove concavities with shallow depth.The most important benefit of doing this is to reduce the number of points and the complexity of shape which will be buffered. It also reduces the risk of gores created by the quantized fillet arcs (although this issue should be eliminated in any case by the offset curve generation logic).
A key aspect of the simplification is that it affects inside (concave or inward) corners only. Convex (outward) corners are preserved, since they are required to ensure that the generated buffer curve lies at the correct distance from the input geometry.
Another important heuristic used is that the end segments of the input are never simplified. This ensures that the client buffer code is able to generate end caps faithfully.
No attempt is made to avoid self-intersections in the output. This is acceptable for use for generating a buffer offset curve, since the buffer algorithm is insensitive to invalid polygonal geometry. However, this means that this algorithm cannot be used as a general-purpose polygon simplification technique.
-
-
Field Summary
Fields Modifier and Type Field Description private int
angleOrientation
private static int
DELETE
private double
distanceTol
private static int
INIT
private Coordinate[]
inputLine
private byte[]
isDeleted
private static int
KEEP
private static int
NUM_PTS_TO_CHECK
-
Constructor Summary
Constructors Constructor Description BufferInputLineSimplifier(Coordinate[] inputLine)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private Coordinate[]
collapseLine()
private boolean
deleteShallowConcavities()
Uses a sliding window containing 3 vertices to detect shallow angles in which the middle vertex can be deleted, since it does not affect the shape of the resulting buffer in a significant way.private int
findNextNonDeletedIndex(int index)
Finds the next non-deleted index, or the end of the point array if noneprivate boolean
isConcave(Coordinate p0, Coordinate p1, Coordinate p2)
private boolean
isDeletable(int i0, int i1, int i2, double distanceTol)
private boolean
isShallow(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol)
private boolean
isShallowConcavity(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol)
private boolean
isShallowSampled(Coordinate p0, Coordinate p2, int i0, int i2, double distanceTol)
Checks for shallowness over a sample of points in the given section.Coordinate[]
simplify(double distanceTol)
Simplify the input coordinate list.static Coordinate[]
simplify(Coordinate[] inputLine, double distanceTol)
Simplify the input coordinate list.
-
-
-
Field Detail
-
INIT
private static final int INIT
- See Also:
- Constant Field Values
-
DELETE
private static final int DELETE
- See Also:
- Constant Field Values
-
KEEP
private static final int KEEP
- See Also:
- Constant Field Values
-
inputLine
private Coordinate[] inputLine
-
distanceTol
private double distanceTol
-
isDeleted
private byte[] isDeleted
-
angleOrientation
private int angleOrientation
-
NUM_PTS_TO_CHECK
private static final int NUM_PTS_TO_CHECK
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BufferInputLineSimplifier
public BufferInputLineSimplifier(Coordinate[] inputLine)
-
-
Method Detail
-
simplify
public static Coordinate[] simplify(Coordinate[] inputLine, double distanceTol)
Simplify the input coordinate list. If the distance tolerance is positive, concavities on the LEFT side of the line are simplified. If the supplied distance tolerance is negative, concavities on the RIGHT side of the line are simplified.- Parameters:
inputLine
- the coordinate list to simplifydistanceTol
- simplification distance tolerance to use- Returns:
- the simplified coordinate list
-
simplify
public Coordinate[] simplify(double distanceTol)
Simplify the input coordinate list. If the distance tolerance is positive, concavities on the LEFT side of the line are simplified. If the supplied distance tolerance is negative, concavities on the RIGHT side of the line are simplified.- Parameters:
distanceTol
- simplification distance tolerance to use- Returns:
- the simplified coordinate list
-
deleteShallowConcavities
private boolean deleteShallowConcavities()
Uses a sliding window containing 3 vertices to detect shallow angles in which the middle vertex can be deleted, since it does not affect the shape of the resulting buffer in a significant way.- Returns:
-
findNextNonDeletedIndex
private int findNextNonDeletedIndex(int index)
Finds the next non-deleted index, or the end of the point array if none- Parameters:
index
-- Returns:
- the next non-deleted index, if any or inputLine.length if there are no more non-deleted indices
-
collapseLine
private Coordinate[] collapseLine()
-
isDeletable
private boolean isDeletable(int i0, int i1, int i2, double distanceTol)
-
isShallowConcavity
private boolean isShallowConcavity(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol)
-
isShallowSampled
private boolean isShallowSampled(Coordinate p0, Coordinate p2, int i0, int i2, double distanceTol)
Checks for shallowness over a sample of points in the given section. This helps prevents the simplification from incrementally "skipping" over points which are in fact non-shallow.- Parameters:
p0
- start coordinate of sectionp2
- end coordinate of sectioni0
- start index of sectioni2
- end index of sectiondistanceTol
- distance tolerance- Returns:
-
isShallow
private boolean isShallow(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol)
-
isConcave
private boolean isConcave(Coordinate p0, Coordinate p1, Coordinate p2)
-
-