Class OffsetCurve


  • public class OffsetCurve
    extends java.lang.Object
    Computes an offset curve from a geometry. The offset curve is a linear geometry which is offset a specified distance from the input. If the offset distance is positive the curve lies on the left side of the input; if it is negative the curve is on the right side.
    • For a LineString the offset curve is a line.
    • For a Point the offset curve is an empty LineString.
    • For a Polygon the offset curve is the boundary of the polygon buffer (which may be a MultiLineString.
    • For a collection the output is a MultiLineString containing the element offset curves.
    The offset curve is computed as a single contiguous section of the geometry buffer boundary. In some geometric situations this definition is ill-defined. This algorithm provides a "best-effort" interpretation. In particular:
    • For self-intersecting lines, the buffer boundary includes offset lines for both left and right sides of the input line. Only a single contiguous portion on the specified side is returned.
    • If the offset corresponds to buffer holes, only the largest hole is used.
    Offset curves support setting the number of quadrant segments, the join style, and the mitre limit (if applicable) via the BufferParameters.
    Author:
    Martin Davis
    • Constructor Summary

      Constructors 
      Constructor Description
      OffsetCurve​(Geometry geom, double distance)
      Creates a new instance for computing an offset curve for a geometryat a given distance.
      OffsetCurve​(Geometry geom, double distance, BufferParameters bufParams)
      Creates a new instance for computing an offset curve for a geometry at a given distance.
    • Constructor Detail

      • OffsetCurve

        public OffsetCurve​(Geometry geom,
                           double distance)
        Creates a new instance for computing an offset curve for a geometryat a given distance. with default quadrant segments (BufferParameters.DEFAULT_QUADRANT_SEGMENTS) and join style (BufferParameters#JOIN_STYLE).
        Parameters:
        geom - the geometry to offset
        distance - the offset distance (positive = left, negative = right)
        See Also:
        BufferParameters
      • OffsetCurve

        public OffsetCurve​(Geometry geom,
                           double distance,
                           BufferParameters bufParams)
        Creates a new instance for computing an offset curve for a geometry at a given distance. allowing the quadrant segments and join style and mitre limit to be set via BufferParameters.
        Parameters:
        geom -
        distance -
        bufParams -
    • Method Detail

      • getCurve

        public static Geometry getCurve​(Geometry geom,
                                        double distance)
        Computes the offset curve of a geometry at a given distance.
        Parameters:
        geom - a geometry
        distance - the offset distance (positive = left, negative = right)
        Returns:
        the offset curve
      • getCurve

        public static Geometry getCurve​(Geometry geom,
                                        double distance,
                                        int quadSegs,
                                        int joinStyle,
                                        double mitreLimit)
        Computes the offset curve of a geometry at a given distance, and for a specified quadrant segments, join style and mitre limit.
        Parameters:
        geom - a geometry
        distance - the offset distance (positive = left, negative = right)
        quadSegs - the quadrant segments (-1 for default)
        joinStyle - the join style (-1 for default)
        mitreLimit - the mitre limit (-1 for default)
        Returns:
        the offset curve
      • getCurve

        public Geometry getCurve()
        Gets the computed offset curve.
        Returns:
        the offset curve geometry
      • rawOffset

        public static Coordinate[] rawOffset​(LineString geom,
                                             double distance,
                                             BufferParameters bufParams)
        Gets the raw offset line. The quadrant segments and join style and mitre limit to be set via BufferParameters.

        The raw offset line may contain loops and other artifacts which are not present in the true offset curve. The raw offset line is matched to the buffer ring (which is clean) to extract the offset curve.

        Parameters:
        geom - the linestring to offset
        distance - the offset distance
        bufParams - the buffer parameters to use
        Returns:
        the raw offset line
      • rawOffset

        public static Coordinate[] rawOffset​(LineString geom,
                                             double distance)
        Gets the raw offset line, with default buffer parameters.
        Parameters:
        geom - the linestring to offset
        distance - the offset distance
        Returns:
        the raw offset line