class Cursor extends java.lang.Object implements java.util.Iterator
A Cursor is a Iterator over a Feature objects.
Most often you will get a Cursor by calling the getCursor() method of a Layer
Shapefile shp = new Shapefile('states.shp') Cursor c = shp.cursor while(c.hasNext()) { Feature f = c.next() } c.close()
Type | Name and description |
---|---|
FeatureCollection<SimpleFeatureType, SimpleFeature> |
col The GeoTools FeatureCollection |
Constructor and description |
---|
Cursor
(Map options, FeatureCollection<SimpleFeatureType, SimpleFeature> col) Create a new Cursor with a FeatureCollection |
Cursor
(Map options, FeatureCollection<SimpleFeatureType, SimpleFeature> col, Layer layer) Create a new Cursor with a FeatureCollection and a Layer |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
close() Closes the Cursor. |
|
protected void |
createIterator() Create the FeatureIterator based on the FeatureCollection and options |
|
boolean |
hasNext() Whether there are Features remaining |
|
Feature |
next() Get the next Feature |
|
java.util.List<Feature> |
read(int n) Read n features into a List |
|
void |
remove() This method is unsupported and throws an UnsupportedOperationException |
|
void |
reset() Reset and read the Features again. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
The GeoTools FeatureCollection
Create a new Cursor with a FeatureCollection
options
- A Map of options (sort - a List of Strings, start - is 0 based, max - the max number of features)col
- The GeoTools FeatureCollectionCreate a new Cursor with a FeatureCollection and a Layer
options
- A Map of options (sort - a List of Strings, start - is 0 based, max - the max number of features)col
- The GeoTools FeatureCollectionlayer
- The Geoscript LayerCloses the Cursor. This should always be called.
Create the FeatureIterator based on the FeatureCollection and options
Whether there are Features remaining
Get the next Feature
Read n features into a List
n
- The number of features to readThis method is unsupported and throws an UnsupportedOperationException
Reset and read the Features again.
Groovy Documentation