Package org.locationtech.jts.geom
Class GeometryCollectionIterator
- java.lang.Object
-
- org.locationtech.jts.geom.GeometryCollectionIterator
-
- All Implemented Interfaces:
java.util.Iterator
public class GeometryCollectionIterator extends java.lang.Object implements java.util.IteratorIterates over allGeometrys in aGeometry, (which may be either a collection or an atomic geometry). The iteration sequence follows a pre-order, depth-first traversal of the structure of theGeometryCollection(which may be nested). The originalGeometryobject is returned as well (as the first object), as are all sub-collections and atomic elements. It is simple to ignore the intermediateGeometryCollectionobjects if they are not needed.- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private booleanatStartIndicates whether or not the first element (the rootGeometryCollection) has been returned.private intindexThe index of theGeometrythat will be returned whennextis called.private intmaxThe number ofGeometrys in the theGeometryCollection.private GeometryparentTheGeometrybeing iterated over.private GeometryCollectionIteratorsubcollectionIteratorThe iterator over a nestedGeometry, ornullif thisGeometryCollectionIteratoris not currently iterating over a nestedGeometryCollection.
-
Constructor Summary
Constructors Constructor Description GeometryCollectionIterator(Geometry parent)Constructs an iterator over the givenGeometry.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasNext()Tests whether any geometry elements remain to be returned.private static booleanisAtomic(Geometry geom)java.lang.Objectnext()Gets the next geometry in the iteration sequence.voidremove()Removal is not supported.
-
-
-
Field Detail
-
parent
private Geometry parent
TheGeometrybeing iterated over.
-
atStart
private boolean atStart
Indicates whether or not the first element (the rootGeometryCollection) has been returned.
-
max
private int max
The number ofGeometrys in the theGeometryCollection.
-
index
private int index
The index of theGeometrythat will be returned whennextis called.
-
subcollectionIterator
private GeometryCollectionIterator subcollectionIterator
The iterator over a nestedGeometry, ornullif thisGeometryCollectionIteratoris not currently iterating over a nestedGeometryCollection.
-
-
Constructor Detail
-
GeometryCollectionIterator
public GeometryCollectionIterator(Geometry parent)
Constructs an iterator over the givenGeometry.- Parameters:
parent- the geometry over which to iterate; also, the first element returned by the iterator.
-
-
Method Detail
-
hasNext
public boolean hasNext()
Tests whether any geometry elements remain to be returned.- Specified by:
hasNextin interfacejava.util.Iterator- Returns:
- true if more geometry elements remain
-
next
public java.lang.Object next()
Gets the next geometry in the iteration sequence.- Specified by:
nextin interfacejava.util.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:
removein interfacejava.util.Iterator- Throws:
java.lang.UnsupportedOperationException- This method is not implemented.
-
-