next method

Object next()

Gets the next geometry in the iteration sequence.

@return the next geometry in the iteration

Implementation

Object next() {
  // the parent GeometryCollection is the first object returned
  if (atStart) {
    atStart = false;
    if (isAtomic(parent)) index++;
    return parent;
  }
  if (subcollectionIterator != null) {
    if (subcollectionIterator!.hasNext()) {
      return subcollectionIterator!.next();
    } else {
      subcollectionIterator = null;
    }
  }
  if (index >= max) {
    throw RangeError("index >= max");
  }
  Geometry obj = parent.getGeometryN(index++);
  if (obj is GeometryCollection) {
    subcollectionIterator = GeometryCollectionIterator(obj);
    // there will always be at least one element in the sub-collection
    return subcollectionIterator!.next();
  }
  return obj;
}