Class GreatArcPath

java.lang.Object
org.apache.commons.geometry.spherical.twod.GreatArcPath
All Implemented Interfaces:
BoundarySource<GreatArc>, BoundarySource2S

public final class GreatArcPath extends Object implements BoundarySource2S
Class representing a connected sequence of GreatArc instances.
  • Field Details

    • EMPTY

      private static final GreatArcPath EMPTY
      Instance containing no arcs.
    • arcs

      private final List<GreatArc> arcs
      Arcs comprising the instance.
  • Constructor Details

    • GreatArcPath

      private GreatArcPath(List<GreatArc> arcs)
      Simple constructor. No validation is performed on the input arc.
      Parameters:
      arcs - arcs for the path, in connection order
  • Method Details

    • boundaryStream

      public Stream<GreatArc> boundaryStream()
      Return a stream containing the boundaries for this instance.
      Specified by:
      boundaryStream in interface BoundarySource<GreatArc>
      Returns:
      a stream containing the boundaries for this instance
    • getArcs

      public List<GreatArc> getArcs()
      Get the arcs in path.
      Returns:
      the arcs in the path
    • getStartArc

      public GreatArc getStartArc()
      Get the start arc for the path or null if the path is empty.
      Returns:
      the start arc for the path or null if the path is empty
    • getEndArc

      public GreatArc getEndArc()
      Get the end arc for the path or null if the path is empty.
      Returns:
      the end arc for the path or null if the path is empty
    • getStartVertex

      public Point2S getStartVertex()
      Get the start vertex for the path or null if the path is empty or consists of a single, full arc.
      Returns:
      the start vertex for the path
    • getEndVertex

      public Point2S getEndVertex()
      Get the end vertex for the path or null if the path is empty or consists of a single, full arc.
      Returns:
      the end vertex for the path
    • getVertices

      public List<Point2S> getVertices()
      Get the vertices contained in the path in the order they appear. Closed paths contain the start vertex at the beginning of the list as well as the end.
      Returns:
      the vertices contained in the path in order they appear
    • isEmpty

      public boolean isEmpty()
      Return true if the path does not contain any arcs.
      Returns:
      true if the path does not contain any arcs
    • isClosed

      public boolean isClosed()
      Return true if the path is closed, meaning that the end point for the last arc is equal to the start point for the path.
      Returns:
      true if the end point for the last arc is equal to the start point for the path
    • toString

      public String toString()
      Return a string representation of this arc path instance.

      In order to keep the string representation short but useful, the exact format of the return value depends on the properties of the path. See below for examples.

      • Empty path
        • GreatArcPath[empty= true]
      • Single, full arc
        • GreatArcPath[full= true, circle= GreatCircle[pole= (0.0, 0.0, 1.0), x= (0.0, 1.0, -0.0), y= (-1.0, 0.0, 0.0)]]
      • One or more non-full arcs
        • GreatArcPath[vertices= [(0.0, 1.5707963267948966), (1.5707963267948966, 1.5707963267948966)]]
      Overrides:
      toString in class Object
    • fromArcs

      public static GreatArcPath fromArcs(GreatArc... arcs)
      Construct a new path from the given arcs.
      Parameters:
      arcs - arc instance to use to construct the path
      Returns:
      a new instance constructed from the given arc instances
    • fromArcs

      public static GreatArcPath fromArcs(Collection<GreatArc> arcs)
      Construct a new path from the given arcs.
      Parameters:
      arcs - arc instance to use to construct the path
      Returns:
      a new instance constructed from the given arc instances
    • fromVertexLoop

      public static GreatArcPath fromVertexLoop(Collection<Point2S> vertices, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Return a new path formed by connecting the given vertices. An additional arc is added from the last point to the first point to construct a loop, if the two points are not already considered equal by the given precision context. This method is equivalent to calling fromPoints(points, true, precision).
      Parameters:
      vertices - the points to construct the path from
      precision - precision precision context used to construct the arc instances for the path
      Returns:
      a new path formed by connecting the given vertices
      See Also:
    • fromVertices

      public static GreatArcPath fromVertices(Collection<Point2S> vertices, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Return a new path formed by connecting the given vertices. No additional arc is inserted to connect the last point to the first. This method is equivalent to calling fromPoint(points, false, precision).
      Parameters:
      vertices - the points to construct the path from
      precision - precision context used to construct the arc instances for the path
      Returns:
      a new path formed by connecting the given vertices
      See Also:
    • fromVertices

      public static GreatArcPath fromVertices(Collection<Point2S> vertices, boolean close, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Return a new path formed by connecting the given vertices.
      Parameters:
      vertices - the points to construct the path from
      close - if true, then an additional arc will be added from the last point to the first, if the points are not already considered equal by the given precision context
      precision - precision context used to construct the arc instances for the path
      Returns:
      a new path formed by connecting the given points
    • builder

      public static GreatArcPath.Builder builder(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Return a GreatArcPath.Builder instance configured with the given precision context. The precision context is used when building arcs from points and may be omitted if raw points are not used.
      Parameters:
      precision - precision context to use when building arcs from raw points; may be null if raw points are not used.
      Returns:
      a new GreatArcPath.Builder instance
    • empty

      public static GreatArcPath empty()
      Get an instance containing no arcs.
      Returns:
      an instance containing no arcs