Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates for GeoTools FeatureCollection api changes
- Loading branch information
jdeolive
committed
Nov 3, 2012
1 parent
06bc9c7
commit bd8840d
Showing
28 changed files
with
166 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import org.geotools.data.DataUtilities; | ||
import org.geotools.data.store.DataFeatureCollection; | ||
import org.geotools.feature.FeatureCollection; | ||
import org.geotools.feature.FeatureIterator; | ||
import org.geotools.geometry.jts.ReferencedEnvelope; | ||
import org.opengis.feature.simple.SimpleFeatureType; | ||
import org.opengis.filter.identity.FeatureId; | ||
|
@@ -64,7 +65,7 @@ public int getCount() throws IOException { | |
|
||
class CompositeIterator implements Iterator { | ||
int index; | ||
Iterator iterator; | ||
FeatureIterator iterator; | ||
|
||
public CompositeIterator() { | ||
index = 0; | ||
|
@@ -83,11 +84,11 @@ public boolean hasNext() { | |
while (index < collections.size()) { | ||
//close current before we move to next | ||
if (iterator != null) { | ||
((FeatureCollection) collections.get(index - 1)).close(iterator); | ||
iterator.close(); | ||
} | ||
|
||
//grap next | ||
iterator = ((FeatureCollection) collections.get(index++)).iterator(); | ||
iterator = ((FeatureCollection) collections.get(index++)).features(); | ||
|
||
if (iterator.hasNext()) { | ||
return true; | ||
|
@@ -97,7 +98,7 @@ public boolean hasNext() { | |
//no more | ||
if (iterator != null) { | ||
//close the last iterator | ||
((FeatureCollection) collections.get(collections.size() - 1)).close(iterator); | ||
iterator.close(); | ||
} | ||
|
||
return false; | ||
|
@@ -108,43 +109,17 @@ public Object next() { | |
} | ||
} | ||
|
||
public boolean addAll(Collection arg0) { | ||
throw new RuntimeException("Can't add to a composite featurecollection; you need to add to one of the constituent collections direclty."); | ||
} | ||
|
||
public boolean removeAll(Collection arg0) { | ||
Iterator it = collections.iterator(); | ||
boolean result = false; | ||
while (it.hasNext()){ | ||
FeatureCollection col = (FeatureCollection)it.next(); | ||
result |= col.removeAll(arg0); | ||
} | ||
return result; | ||
} | ||
|
||
public boolean retainAll(Collection arg0) { | ||
boolean result = false; | ||
|
||
Iterator it = collections.iterator(); | ||
while (it.hasNext()){ | ||
FeatureCollection col = (FeatureCollection)it.next(); | ||
result |= col.removeAll(arg0); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public Object[] toArray(Object[] arg0) { | ||
List list = new ArrayList(); | ||
|
||
Iterator it = collections.iterator(); | ||
while(it.hasNext()){ | ||
FeatureCollection col = (FeatureCollection)it.next(); | ||
Iterator it2 = col.iterator(); | ||
FeatureIterator it2 = col.features(); | ||
while (it2.hasNext()){ | ||
This comment has been minimized.
Sorry, something went wrong.
jodygarnett
Member
|
||
list.add(it.next()); | ||
} | ||
col.close(it2); | ||
it2.close(); | ||
} | ||
|
||
return list.toArray(arg0); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
There is a DataUtilities.close( iterator ) that aaime requested, it does allow you to avoid null checks