Class ImmutablePart

  • All Implemented Interfaces:
    Iterable<Segment>, Collection<Segment>, List<Segment>

    public final class ImmutablePart
    extends AbstractList<Segment>
    Represents an immutable collection of Segments that define the shape of a part of an immutable Multipart geometry - Polygon or Polyline. Point-based helper methods also allow working with the part as a series of Points.

    Use Multipart.getParts() to return an ImmutablePartCollection, which can then be used to iterate through the Segments and Points in each ImmutablePart. Use java.util.AbstractList.iterator() or getPoints() to return an iterator, or use get(int) or getPoint(int) to access each specific Segment or Point.

    Because geometries themselves are immutable, the collections they are composed of are also immutable. For geometry editing or creation workflows, a mutable Part is used instead. Part has constructors that take an ImmutablePart (among other options), allowing the creation of new geometry parts from existing parts.

    For more information about using geometries, see the 'Fundamentals' > 'Geometries' topic in the Guide.

    Prior to v100.12, the only supported segment type was LineSegment. If the underlying geometry contained curve segments (Geometry.hasCurves() is true), then the curve information was lost when iterating through the segments in that part.

    From v100.12, curve segments may be returned from get(int). A part may contain a mix of linear and curve segments.

    Since:
    100.0.0
    See Also:
    Polyline, Polygon, Multipart.getParts(), Part
    • Method Detail

      • getSpatialReference

        public SpatialReference getSpatialReference()
        Gets the SpatialReference of the geometries in this ImmutablePart. The SpatialReference defines how coordinates correspond to locations in the real world. May be null.
        Returns:
        the SpatialReference of the geometries in this ImmutablePart
        Since:
        100.0.0
      • getStartPoint

        public Point getStartPoint()
        Gets a Point representing the start of the first Segment of the ImmutablePart. This is a shortcut to getting the first Segment in the ImmutablePart, then getting its start point using Segment.getStartPoint(), or getting the first Point using getPoint(int).
        Returns:
        a Point representing the start point
        Since:
        100.0.0
        See Also:
        getEndPoint()
      • getEndPoint

        public Point getEndPoint()
        Gets a Point representing the end of the last Segment of the ImmutablePart. This is a shortcut to getting the last Segment in the ImmutablePart, then getting its end point using Segment.getEndPoint(), or getting the last Point using getPoint(int).
        Returns:
        a Point representing the end point
        See Also:
        getStartPoint()
      • getPoints

        public Iterable<Point> getPoints()
        Gets an iterator of Points representing the ends of the Segments in this ImmutablePart (the vertices in the shape).

        In ImmutableParts, adjacent segments always share a start and end location (there is no gap between the segments), and this is represented by a single Point in this iterator.

        Returns:
        an iterator of Points
        Since:
        100.0.0
      • getPoint

        public Point getPoint​(int index)
        Gets the Point at the given index in the ImmutablePart. Use getPointCount() to determine the maximum possible index.

        The vertices of a Multipart geometry can be represented as a series of Points, which can be accessed using this method, or by the getPoints() iterator. If the geometry contains curves, this cannot be represented by points; segment-based methods such as get(int) and java.util.AbstractList.iterator() may be more appropriate instead.

        Parameters:
        index - the index of the Point to get
        Returns:
        the Point at the given index
        Throws:
        IndexOutOfBoundsException - if index is out of range (index < 0 || index >= getPointCount())
        Since:
        100.0.0
      • getPointCount

        public int getPointCount()
        Returns the number of Points in the ImmutablePart, representing the number of vertices in the shape. Use this to find the maximum index for calling getPoint(int).

        For Polylines, this number is one greater than the number of Segments in this ImmutablePart (size()), but for Polygons it equals the number of Segments.

        Where two adjacent segments share a start and end location (there is no gap between the segments), this is represented by a single Point. Gaps are eliminated when geometries are built using the GeometryBuilder.toGeometry() method. Completed Multipart geometries do not have gaps between the segments of a part, but separate ImmutableParts may be disjoint.

        Returns:
        the number of Points in the ImmutablePart
        Since:
        100.0.0
        See Also:
        size(), getPoints()
      • hasCurves

        public boolean hasCurves()
        Indicates if this ImmutablePart contains Segments that represent true curves.

        The ArcGIS system supports polygon and polyline geometries that contain curved segments in some types of data, for example geodatabases, feature services, and JSON. At the current release this SDK can display curved geometries, but you cannot work with curves using the API; any curved segments in a geometry will be represented as LineSegments, and the curve information will be lost. In editing workflows, use this method to determine if this ImmutablePart contains curve information which would be lost if used in an editing workflow.

        Prior to v100.12, if this property returned true, there was no way to access the curve segment information contained by the part. Retrieving the Segment instances of the part would return only LineSegment instances.

        From v100.12, when this property returns true, curve segments may be returned from get(int). A part may contain a mix of linear and curve segments.

        Returns:
        true if this ImmutablePart contains curved segments; false otherwise
        Since:
        100.0.0
      • getSegmentIndexFromStartPointIndex

        public int getSegmentIndexFromStartPointIndex​(int startPointIndex)
        Gets the index of the segment that has a given start point.
        Parameters:
        startPointIndex - the 0-based index of the start point
        Returns:
        the index of the segment, or -1 if startPointIndex does not correspond to a segment start point
        Throws:
        IndexOutOfBoundsException - if startPointIndex is out of bounds
        Since:
        100.1.0
      • getSegmentIndexFromEndPointIndex

        public int getSegmentIndexFromEndPointIndex​(int endPointIndex)
        Gets the index of the segment that has a given end point.
        Parameters:
        endPointIndex - the 0-based index of the end point
        Returns:
        the index of the segment, or -1 if endPointIndex does not correspond to a segment end point
        Throws:
        IndexOutOfBoundsException - if endPointIndex is out of bounds
        Since:
        100.1.0
      • getStartPointIndexFromSegmentIndex

        public int getStartPointIndexFromSegmentIndex​(int segmentIndex)
        Gets the index of the start point of a segment.
        Parameters:
        segmentIndex - the 0-based index of the segment
        Returns:
        the index of the start point
        Throws:
        IndexOutOfBoundsException - if segmentIndex is out of bounds
        Since:
        100.1.0
      • getEndPointIndexFromSegmentIndex

        public int getEndPointIndexFromSegmentIndex​(int segmentIndex)
        Gets the index of the end point of a segment.
        Parameters:
        segmentIndex - the 0-based index of the segment
        Returns:
        the index of the end point
        Throws:
        IndexOutOfBoundsException - if segmentIndex is out of bounds
        Since:
        100.1.0