Class OffsetCurveSetBuilder
- java.lang.Object
-
- org.locationtech.jts.operation.buffer.OffsetCurveSetBuilder
-
public class OffsetCurveSetBuilder extends java.lang.Object
Creates all the raw offset curves for a buffer of aGeometry
. Raw curves need to be noded together and polygonized to form the final buffer area.- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private OffsetCurveBuilder
curveBuilder
private java.util.List
curveList
private double
distance
private Geometry
inputGeom
-
Constructor Summary
Constructors Constructor Description OffsetCurveSetBuilder(Geometry inputGeom, double distance, OffsetCurveBuilder curveBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
add(Geometry g)
private void
addCollection(GeometryCollection gc)
private void
addCurve(Coordinate[] coord, int leftLoc, int rightLoc)
Creates aSegmentString
for a coordinate list which is a raw offset curve, and adds it to the list of buffer curves.private void
addLineString(LineString line)
private void
addPoint(Point p)
Add a Point to the graph.private void
addPolygon(Polygon p)
private void
addPolygonRing(Coordinate[] coord, double offsetDistance, int side, int cwLeftLoc, int cwRightLoc)
Adds an offset curve for a polygon ring.java.util.List
getCurves()
Computes the set of raw offset curves for the buffer.private boolean
isErodedCompletely(LinearRing ring, double bufferDistance)
The ringCoord is assumed to contain no repeated points.private boolean
isTriangleErodedCompletely(Coordinate[] triangleCoord, double bufferDistance)
Tests whether a triangular ring would be eroded completely by the given buffer distance.
-
-
-
Field Detail
-
inputGeom
private Geometry inputGeom
-
distance
private double distance
-
curveBuilder
private OffsetCurveBuilder curveBuilder
-
curveList
private java.util.List curveList
-
-
Constructor Detail
-
OffsetCurveSetBuilder
public OffsetCurveSetBuilder(Geometry inputGeom, double distance, OffsetCurveBuilder curveBuilder)
-
-
Method Detail
-
getCurves
public java.util.List getCurves()
Computes the set of raw offset curves for the buffer. Each offset curve has an attachedLabel
indicating its left and right location.- Returns:
- a Collection of SegmentStrings representing the raw buffer curves
-
addCurve
private void addCurve(Coordinate[] coord, int leftLoc, int rightLoc)
Creates aSegmentString
for a coordinate list which is a raw offset curve, and adds it to the list of buffer curves. The SegmentString is tagged with a Label giving the topology of the curve. The curve may be oriented in either direction. If the curve is oriented CW, the locations will be:
Left: Location.EXTERIOR
Right: Location.INTERIOR
-
add
private void add(Geometry g)
-
addCollection
private void addCollection(GeometryCollection gc)
-
addPoint
private void addPoint(Point p)
Add a Point to the graph.
-
addLineString
private void addLineString(LineString line)
-
addPolygon
private void addPolygon(Polygon p)
-
addPolygonRing
private void addPolygonRing(Coordinate[] coord, double offsetDistance, int side, int cwLeftLoc, int cwRightLoc)
Adds an offset curve for a polygon ring. The side and left and right topological location arguments assume that the ring is oriented CW. If the ring is in the opposite orientation, the left and right locations must be interchanged and the side flipped.- Parameters:
coord
- the coordinates of the ring (must not contain repeated points)offsetDistance
- the distance at which to create the bufferside
- the side of the ring on which to construct the buffer linecwLeftLoc
- the location on the L side of the ring (if it is CW)cwRightLoc
- the location on the R side of the ring (if it is CW)
-
isErodedCompletely
private boolean isErodedCompletely(LinearRing ring, double bufferDistance)
The ringCoord is assumed to contain no repeated points. It may be degenerate (i.e. contain only 1, 2, or 3 points). In this case it has no area, and hence has a minimum diameter of 0.- Parameters:
ringCoord
-offsetDistance
-- Returns:
-
isTriangleErodedCompletely
private boolean isTriangleErodedCompletely(Coordinate[] triangleCoord, double bufferDistance)
Tests whether a triangular ring would be eroded completely by the given buffer distance. This is a precise test. It uses the fact that the inner buffer of a triangle converges on the inCentre of the triangle (the point equidistant from all sides). If the buffer distance is greater than the distance of the inCentre from a side, the triangle will be eroded completely. This test is important, since it removes a problematic case where the buffer distance is slightly larger than the inCentre distance. In this case the triangle buffer curve "inverts" with incorrect topology, producing an incorrect hole in the buffer.- Parameters:
triangleCoord
-bufferDistance
-- Returns:
-
-