Class GeometryCollectionIterator

java.lang.Object
org.locationtech.jts.geom.GeometryCollectionIterator
All Implemented Interfaces:
Iterator

public class GeometryCollectionIterator extends Object implements Iterator
Iterates over all Geometrys in a Geometry, (which may be either a collection or an atomic geometry). The iteration sequence follows a pre-order, depth-first traversal of the structure of the GeometryCollection (which may be nested). The original Geometry object is returned as well (as the first object), as are all sub-collections and atomic elements. It is simple to ignore the intermediate GeometryCollection objects if they are not needed.
Version:
1.7
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    Indicates whether or not the first element (the root GeometryCollection) has been returned.
    private int
    The index of the Geometry that will be returned when next is called.
    private int
    The number of Geometrys in the the GeometryCollection.
    private Geometry
    The Geometry being iterated over.
    The iterator over a nested Geometry, or null if this GeometryCollectionIterator is not currently iterating over a nested GeometryCollection.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an iterator over the given Geometry.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Tests whether any geometry elements remain to be returned.
    private static boolean
     
    Gets the next geometry in the iteration sequence.
    void
    Removal is not supported.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining
  • Field Details

    • parent

      private Geometry parent
      The Geometry being iterated over.
    • atStart

      private boolean atStart
      Indicates whether or not the first element (the root GeometryCollection) has been returned.
    • max

      private int max
      The number of Geometrys in the the GeometryCollection.
    • index

      private int index
      The index of the Geometry that will be returned when next is called.
    • subcollectionIterator

      private GeometryCollectionIterator subcollectionIterator
      The iterator over a nested Geometry, or null if this GeometryCollectionIterator is not currently iterating over a nested GeometryCollection.
  • Constructor Details

    • GeometryCollectionIterator

      public GeometryCollectionIterator(Geometry parent)
      Constructs an iterator over the given Geometry.
      Parameters:
      parent - the geometry over which to iterate; also, the first element returned by the iterator.
  • Method Details

    • hasNext

      public boolean hasNext()
      Tests whether any geometry elements remain to be returned.
      Specified by:
      hasNext in interface Iterator
      Returns:
      true if more geometry elements remain
    • next

      public Object next()
      Gets the next geometry in the iteration sequence.
      Specified by:
      next in interface Iterator
      Returns:
      the next geometry in the iteration
    • isAtomic

      private static boolean isAtomic(Geometry geom)
    • remove

      public void remove()
      Removal is not supported.
      Specified by:
      remove in interface Iterator
      Throws:
      UnsupportedOperationException - This method is not implemented.