[Schmitzm-commits] r373 - in branches/1.0-gt2-2.6/src/org/geotools: . feature/collection
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Sep 4 10:48:50 CEST 2009
Author: alfonx
Date: 2009-09-04 10:48:50 +0200 (Fri, 04 Sep 2009)
New Revision: 373
Removed:
branches/1.0-gt2-2.6/src/org/geotools/styling/
Modified:
branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.java
Log:
* Comments in SubFeatureCollection
* Removed the patched StyleFactorImpl we needed in GT2.4.5
Modified: branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.java
===================================================================
--- branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.java 2009-09-03 18:41:50 UTC (rev 372)
+++ branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.java 2009-09-04 08:48:50 UTC (rev 373)
@@ -43,99 +43,109 @@
/**
* Used as a reasonable default implementation for subCollection.
* <p>
- * Note: to implementors, this is not optimal, please do your own
- * thing - your users will thank you.
+ * Note: to implementors, this is not optimal, please do your own thing - your
+ * users will thank you.
* </p>
*
* @author Jody Garnett, Refractions Research, Inc.
- *
- * @source $URL: http://svn.osgeo.org/geotools/tags/2.6-M2/modules/library/main/src/main/java/org/geotools/feature/collection/SubFeatureCollection.java $
+ *
+ * @source $URL:
+ * http://svn.osgeo.org/geotools/tags/2.6-M2/modules/library/main/src
+ * /main/java/org/geotools/feature/collection/SubFeatureCollection.java
+ * $
*/
public class SubFeatureCollection extends AbstractFeatureCollection {
-
- /** Filter */
- protected Filter filter;
-
- /** Original Collection */
+
+ /** Filter */
+ protected Filter filter;
+
+ /** Original Collection */
protected FeatureCollection<SimpleFeatureType, SimpleFeature> collection;
-
- protected FilterFactory ff = CommonFactoryFinder.getFilterFactory( null );
-
- public SubFeatureCollection(FeatureCollection<SimpleFeatureType, SimpleFeature> collection ) {
- this( collection, Filter.INCLUDE );
- }
- public SubFeatureCollection(FeatureCollection<SimpleFeatureType, SimpleFeature> collection, Filter subfilter ){
- super( collection.getSchema() );
- if (subfilter == null ) subfilter = Filter.INCLUDE;
+
+ protected FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
+
+ public SubFeatureCollection(
+ FeatureCollection<SimpleFeatureType, SimpleFeature> collection) {
+ this(collection, Filter.INCLUDE);
+ }
+
+ public SubFeatureCollection(
+ FeatureCollection<SimpleFeatureType, SimpleFeature> collection,
+ Filter subfilter) {
+ super(collection.getSchema());
+ if (subfilter == null)
+ subfilter = Filter.INCLUDE;
if (subfilter.equals(Filter.EXCLUDE)) {
- throw new IllegalArgumentException("A subcollection with Filter.EXCLUDE would be empty");
- }
- if( collection instanceof SubFeatureCollection){
+ throw new IllegalArgumentException(
+ "A subcollection with Filter.EXCLUDE would be empty");
+ }
+ if (collection instanceof SubFeatureCollection) {
SubFeatureCollection filtered = (SubFeatureCollection) collection;
- if( subfilter.equals(Filter.INCLUDE)){
- this.collection = filtered.collection;
- this.filter = filtered.filter();
+ if (subfilter.equals(Filter.INCLUDE)) {
+ this.collection = filtered.collection;
+ this.filter = filtered.filter();
+ } else {
+ this.collection = filtered.collection;
+ this.filter = ff.and(filtered.filter(), subfilter);
}
- else {
- this.collection = filtered.collection;
- this.filter = ff.and( filtered.filter(), subfilter );
- }
} else {
this.collection = collection;
this.filter = subfilter;
}
- }
-
+ }
+
public Iterator openIterator() {
- return new FilteredIterator<SimpleFeature>( collection, filter() );
+ return new FilteredIterator<SimpleFeature>(collection, filter());
}
public void closeIterator(Iterator iterator) {
- if( iterator == null ) return;
-
- if( iterator instanceof FilteredIterator){
- FilteredIterator filtered = (FilteredIterator) iterator;
+ if (iterator == null)
+ return;
+
+ if (iterator instanceof FilteredIterator) {
+ FilteredIterator filtered = (FilteredIterator) iterator;
filtered.close();
}
}
-
+
public int size() {
int count = 0;
- Iterator i = null;
+ Iterator i = null;
try {
- for( i = iterator(); i.hasNext(); count++) i.next();
+ for (i = iterator(); i.hasNext(); count++)
+ i.next();
+ } finally {
+ close(i);
}
- finally {
- close( i );
- }
return count;
}
-
- protected Filter filter(){
- if( filter == null ){
- filter = createFilter();
- }
- return filter;
- }
-
- /** Override to implement subsetting */
- protected Filter createFilter(){
- return Filter.INCLUDE;
- }
-
+
+ protected Filter filter() {
+ if (filter == null) {
+ filter = createFilter();
+ }
+ return filter;
+ }
+
+ /** Override to implement subsetting */
+ protected Filter createFilter() {
+ return Filter.INCLUDE;
+ }
+
public FeatureIterator<SimpleFeature> features() {
- return new DelegateFeatureIterator<SimpleFeature>( this, iterator() );
+ return new DelegateFeatureIterator<SimpleFeature>(this, iterator());
}
-
-
+
public void close(FeatureIterator<SimpleFeature> close) {
- if( close != null ) close.close();
+ if (close != null)
+ close.close();
}
- //
- //
- //
- public FeatureCollection<SimpleFeatureType, SimpleFeature> subCollection(Filter filter) {
+ //
+ //
+ //
+ public FeatureCollection<SimpleFeatureType, SimpleFeature> subCollection(
+ Filter filter) {
if (filter.equals(Filter.INCLUDE)) {
return this;
}
@@ -145,77 +155,82 @@
return new SubFeatureCollection(this, filter);
}
-
public boolean isEmpty() {
Iterator iterator = iterator();
try {
return !iterator.hasNext();
+ } finally {
+ close(iterator);
}
- finally {
- close( iterator );
+ }
+
+ public void accepts(org.opengis.feature.FeatureVisitor visitor,
+ org.opengis.util.ProgressListener progress) {
+ Iterator iterator = null;
+ // if( progress == null ) progress = new NullProgressListener();
+ try {
+ float size = size();
+ float position = 0;
+ progress.started();
+ for (iterator = iterator(); !progress.isCanceled()
+ && iterator.hasNext(); progress.progress(position++ / size)) {
+ try {
+ SimpleFeature feature = (SimpleFeature) iterator.next();
+ visitor.visit(feature);
+ } catch (Exception erp) {
+ progress.exceptionOccurred(erp);
+ }
+ }
+ } finally {
+ progress.complete();
+ close(iterator);
}
}
-
- public void accepts(org.opengis.feature.FeatureVisitor visitor, org.opengis.util.ProgressListener progress) {
- Iterator iterator = null;
- // if( progress == null ) progress = new NullProgressListener();
- try{
- float size = size();
- float position = 0;
- progress.started();
- for( iterator = iterator(); !progress.isCanceled() && iterator.hasNext(); progress.progress( position++/size )){
- try {
- SimpleFeature feature = (SimpleFeature) iterator.next();
- visitor.visit(feature);
- }
- catch( Exception erp ){
- progress.exceptionOccurred( erp );
- }
- }
- }
- finally {
- progress.complete();
- close( iterator );
- }
- }
public FeatureCollection<SimpleFeatureType, SimpleFeature> sort(SortBy order) {
- return new SubFeatureList( collection, filter, order );
+ return new SubFeatureList(collection, filter, order);
}
-
+
public boolean add(SimpleFeature o) {
- return collection.add(o);
+ return collection.add(o);
}
-
+
public void clear() {
- List toDelete = DataUtilities.list( this );
- removeAll( toDelete );
+ List toDelete = DataUtilities.list(this);
+ removeAll(toDelete);
}
-
+
public boolean remove(Object o) {
- return collection.remove( o );
+ return collection.remove(o);
}
-
- public String getID() {
- return collection.getID();
- }
- // extra methods
- public FeatureReader<SimpleFeatureType, SimpleFeature> reader() throws IOException {
- return new DelegateFeatureReader<SimpleFeatureType, SimpleFeature>( getSchema(), features() );
- }
+ public String getID() {
+ return collection.getID();
+ }
- public int getCount() throws IOException {
- return size();
- }
+ // extra methods
+ public FeatureReader<SimpleFeatureType, SimpleFeature> reader()
+ throws IOException {
+ return new DelegateFeatureReader<SimpleFeatureType, SimpleFeature>(
+ getSchema(), features());
+ }
- public FeatureCollection<SimpleFeatureType, SimpleFeature> collection() throws IOException {
- return this;
- }
-
- @Override
- public ReferencedEnvelope getBounds() {
- return collection.getBounds();
- }
+ public int getCount() throws IOException {
+ return size();
+ }
+ public FeatureCollection<SimpleFeatureType, SimpleFeature> collection()
+ throws IOException {
+ return this;
+ }
+
+ /**
+ * TODO THIS IS NOT VErY SMART.. THE Bounds of the sub-collection might be
+ * different from the original collection.
+ */
+ @Override
+ public ReferencedEnvelope getBounds() {
+ return collection.getBounds();
+ }
+
}
More information about the Schmitzm-commits
mailing list