S2ShapeIndex.Iterator

A random access iterator that provides low-level access to the cells of the index. Cells are sorted in increasing order of S2CellId.

Constructors

this
this()

Default constructor; must be followed by a call to Init().

this
this(S2ShapeIndex index, InitialPosition pos)

Constructs an iterator positioned as specified. By default iterators are unpositioned, since this avoids an extra seek in this situation where one of the seek methods (such as Locate) is immediately called.

Members

Functions

begin
void begin()

Positions the iterator at the first index cell (if any).

cell
inout(S2ShapeIndexCell) cell()

Returns a reference to the contents of the current index cell.

center
S2Point center()

Returns the center point of the cell.

copy
void copy(Iterator other)
Undocumented in source. Be warned that the author may not have intended to support it.
done
bool done()

Returns true if the iterator is positioned past the last index cell.

finish
void finish()

Positions the iterator past the last index cell.

id
S2CellId id()

Returns the S2CellId of the current index cell. If done() is true, returns a value larger than any valid S2CellId (S2CellId::Sentinel()).

initialize
void initialize(S2ShapeIndex index, InitialPosition pos)

Initializes an iterator for the given S2ShapeIndex. This method may also be called in order to restore an iterator to a valid state after the underlying index has been updated (although it is usually easier just to declare a new iterator whenever required, since iterator construction is cheap).

locate
bool locate(S2Point target)

Positions the iterator at the cell containing "target". If no such cell exists, returns false and leaves the iterator positioned arbitrarily. The returned index cell is guaranteed to contain all edges that might intersect the line segment between "target" and the cell center.

locate
CellRelation locate(S2CellId target)

Let T be the target S2CellId. If T is contained by some index cell I (including equality), this method positions the iterator at I and returns INDEXED. Otherwise if T contains one or more (smaller) index cells, it positions the iterator at the first such cell I and returns SUBDIVIDED. Otherwise it returns DISJOINT and leaves the iterator positioned arbitrarily.

next
void next()

Positions the iterator at the next index cell.

prev
bool prev()

If the iterator is already positioned at the beginning, returns false. Otherwise positions the iterator at the previous entry and returns true.

seek
void seek(S2CellId target)

Positions the iterator at the first cell with id() >= target, or at the end of the index if no such cell exists.

Meta