Class OffsetCurve


  • public class OffsetCurve
    extends Object
    Computes an offset curve from a geometry. An offset curve is a linear geometry which is offset a given 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. The curve(s) have the same direction as the input line(s). The result for a zero offset distance is a copy of the input linework.

    The offset curve is based on the boundary of the buffer for the geometry at the offset distance (see BufferOp. The normal mode of operation is to return the sections of the buffer boundary which lie on the raw offset curve (obtained via rawOffset(LineString, double). The offset curve will contain multiple sections if the input self-intersects or has close approaches. The computed sections are ordered along the raw offset curve. Sections are disjoint. They never self-intersect, but may be rings.

    In "joined" mode (see setJoined(boolean) the sections computed for each input line are joined into a single offset curve line. The joined curve may self-intersect. At larger offset distances the curve may contain "flat-line" artifacts in places where the input self-intersects.

    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 Detail

      • OffsetCurve

        public OffsetCurve​(Geometry geom,
                           double distance)
        Creates a new instance for computing an offset curve for a geometry at 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 for left, negative for 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. setting the quadrant segments and join style and mitre limit via BufferParameters.
        Parameters:
        geom - the geometry to offset
        distance - the offset distance (positive for left, negative for right)
        bufParams - the buffer parameters to use
    • 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 for left, negative for 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, with specified quadrant segments, join style and mitre limit.
        Parameters:
        geom - a geometry
        distance - the offset distance (positive for left, negative for 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
      • getCurveJoined

        public static Geometry getCurveJoined​(Geometry geom,
                                              double distance)
        Computes the offset curve of a geometry at a given distance, joining curve sections into a single line for each input line.
        Parameters:
        geom - a geometry
        distance - the offset distance (positive for left, negative for right)
        Returns:
        the joined offset curve
      • setJoined

        public void setJoined​(boolean isJoined)
        Computes a single curve line for each input linear component, by joining curve sections in order along the raw offset curve. The default mode is to compute separate curve sections.
        Parameters:
        isJoined - true if joined mode should be used.
      • getCurve

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

        public static Coordinate[] rawOffset​(LineString line,
                                             double distance,
                                             BufferParameters bufParams)
        Gets the raw offset curve for a line at a given distance. The quadrant segments, join style and mitre limit can be specified via BufferParameters.

        The raw offset line may contain loops and other artifacts which are not present in the true offset curve.

        Parameters:
        line - the line to offset
        distance - the offset distance (positive for left, negative for right)
        bufParams - the buffer parameters to use
        Returns:
        the raw offset curve points
      • rawOffset

        public static Coordinate[] rawOffset​(LineString line,
                                             double distance)
        Gets the raw offset curve for a line at a given distance, with default buffer parameters.
        Parameters:
        line - the line to offset
        distance - the offset distance (positive for left, negative for right)
        Returns:
        the raw offset curve points