[Schmitzm-commits] r321 - in branches/1.0-gt2-2.6: . src/org/geotools/feature/collection

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Aug 26 15:52:55 CEST 2009


Author: mojays
Date: 2009-08-26 15:52:54 +0200 (Wed, 26 Aug 2009)
New Revision: 321

Added:
   branches/1.0-gt2-2.6/migration_to_gt2-2.6.txt
   branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.GT2-2.4.2
Removed:
   branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.java
Log:
"optimized" SubFeatureCollection removed (hoping the 2.6 version now works fine!)

Added: branches/1.0-gt2-2.6/migration_to_gt2-2.6.txt
===================================================================
--- branches/1.0-gt2-2.6/migration_to_gt2-2.6.txt	2009-08-26 13:49:19 UTC (rev 320)
+++ branches/1.0-gt2-2.6/migration_to_gt2-2.6.txt	2009-08-26 13:52:54 UTC (rev 321)
@@ -0,0 +1,21 @@
+MouseSelectionTracker
+=====================
+- not included in gt2-2.6
+- copied from 2.4.5 to temporary mirgation package
+  gtmig.org.geotools.gui.swing
+- Reference in MouseSelectionTracker_Public
+
+
+TODO: if MouseSelectionTrackerPublic is no longer part of
+      Geotools, include MouseSelectionTracker in SCHMITZM
+      - include the old Tracker in the already extended
+        schmitzm.geotools.gui.MouseSelectionTracker
+      - remove MouseSelectionTracker_Public
+      - remove MouseSelectionTracker from gtmig.org.geot...
+
+
+SubFeatureCollection
+====================
+- "optimized" overwritten SubFeatureCollection removed from
+  SCHMITZM project
+- hope that the 2.6 version works fine
\ No newline at end of file

Added: branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.GT2-2.4.2
===================================================================
--- branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.GT2-2.4.2	2009-08-26 13:49:19 UTC (rev 320)
+++ branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.GT2-2.4.2	2009-08-26 13:52:54 UTC (rev 321)
@@ -0,0 +1,280 @@
+/*
+ *    GeoTools - OpenSource mapping toolkit
+ *    http://geotools.org
+ *    (C) 2005-2006, GeoTools Project Managment Committee (PMC)
+ *
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Lesser General Public
+ *    License as published by the Free Software Foundation;
+ *    version 2.1 of the License.
+ *
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *    Lesser General Public License for more details.
+ */
+package org.geotools.feature.collection;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.batik.svggen.font.table.FeatureList;
+import org.geotools.data.FeatureReader;
+import org.geotools.data.collection.DelegateFeatureReader;
+import org.geotools.factory.CommonFactoryFinder;
+import org.geotools.feature.CollectionListener;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.FeatureIterator;
+import org.geotools.feature.IllegalAttributeException;
+import org.geotools.feature.SimpleFeature;
+import org.geotools.feature.SimpleFeatureType;
+import org.geotools.feature.visitor.FeatureVisitor;
+import org.geotools.geometry.jts.ReferencedEnvelope;
+import org.opengis.util.ProgressListener;
+import org.opengis.filter.Filter;
+import org.opengis.filter.FilterFactory;
+import org.opengis.filter.sort.SortBy;
+
+import com.vividsolutions.jts.geom.Geometry;
+
+/**
+ * <b>Xulu:<br>
+ *    Code taken from gt-2.4.2 to optimize the {@link #size()} method!
+ *    The original variant always iterates ALL features at every call!.</b><br><br>
+ *
+ * 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.
+ * </p>
+ *
+ * @author Jody Garnett, Refractions Research, Inc.
+ *
+ * @source $URL: http://svn.geotools.org/geotools/tags/2.4.2/modules/library/main/src/main/java/org/geotools/feature/collection/SubFeatureCollection.java $
+ */
+public class SubFeatureCollection extends AbstractResourceCollection implements FeatureCollection {
+// Xulu-01.sn
+  private int size = -1;
+// Xulu-01.en
+
+        /** Filter */
+    protected Filter filter;
+
+    /** Origional Collection */
+        protected FeatureCollection collection;
+    protected FeatureState state;
+    protected FilterFactory ff = CommonFactoryFinder.getFilterFactory( null );
+
+    public SubFeatureCollection(FeatureCollection collection ) {
+        this( collection, Filter.INCLUDE );
+    }
+        public SubFeatureCollection(FeatureCollection collection, Filter subfilter ){
+                if (subfilter == null ) subfilter = Filter.INCLUDE;
+                if (subfilter.equals(Filter.EXCLUDE)) {
+                        throw new IllegalArgumentException("A subcollection with Filter.EXCLUDE is a null operation");
+                }
+
+        if( collection instanceof SubFeatureCollection){
+                        SubFeatureCollection filtered = (SubFeatureCollection) collection;
+                        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 = collection;
+                        this.filter = subfilter;
+                }
+        state = new SubFeatureState( this.collection, this );
+        }
+
+        protected Filter filter(){
+            if( filter == null ){
+            filter = createFilter();
+        }
+        return filter;
+    }
+    /** Override to implement subsetting */
+    protected Filter createFilter(){
+        return Filter.INCLUDE;
+    }
+
+        public SimpleFeatureType getFeatureType() {
+                return state.getFeatureType();
+        }
+
+        public FeatureIterator features() {
+                return new DelegateFeatureIterator( this, iterator() );
+        }
+
+        public void closeIterator(Iterator iterator) {
+                if( iterator == null ) return;
+
+                if( iterator instanceof FilteredIterator){
+                        FilteredIterator filtered = (FilteredIterator) iterator;
+                        filtered.close();
+                }
+        }
+        public void close(FeatureIterator close) {
+                if( close != null ) close.close();
+        }
+
+    //
+    // SimpleFeature methods
+    //
+        public String getID() {
+                return state.getId();
+        }
+
+        public ReferencedEnvelope getBounds(){
+        return ReferencedEnvelope.reference(state.getBounds());
+        }
+
+        public Geometry getDefaultGeometry() {
+            return state.getDefaultGeometry();
+        }
+
+        public void setDefaultGeometry(Geometry g) throws IllegalAttributeException {
+            state.setDefaultGeometry( g );
+        }
+
+    public void addListener(CollectionListener listener) throws NullPointerException {
+        state.addListener( listener );
+    }
+
+    public void removeListener(CollectionListener listener) throws NullPointerException {
+        state.removeListener( listener );
+    }
+
+    public FeatureCollection getParent() {
+        return state.getParent();
+    }
+
+    public void setParent(FeatureCollection collection) {
+        state.setParent( collection );
+    }
+
+    public Object[] getAttributes(Object[] attributes) {
+        return state.getAttributes( attributes );
+    }
+
+    public Object getAttribute(String xPath) {
+        return state.getAttribute( xPath );
+    }
+
+    public Object getAttribute(int index) {
+        return state.getAttribute( index );
+    }
+
+    public void setAttribute(int position, Object val) throws IllegalAttributeException, ArrayIndexOutOfBoundsException {
+        state.setAttribute( position, val  );
+    }
+    public int getNumberOfAttributes() {
+        return state.getNumberOfAttributes();
+    }
+
+    public void setAttribute(String xPath, Object attribute) throws IllegalAttributeException {
+        state.setAttribute( xPath, attribute );
+    }
+
+    //
+    //
+    //
+        public FeatureCollection subCollection(Filter filter) {
+                if (filter.equals(Filter.INCLUDE)) {
+                        return this;
+                }
+                if (filter.equals(Filter.EXCLUDE)) {
+                        // TODO implement EmptyFeatureCollection( schema )
+                }
+                return new SubFeatureCollection(this, filter);
+        }
+
+        public int size() {
+//Xulu-01.sn
+          if ( this.size >= 0 )
+            return this.size;
+//Xulu-01.en
+                int count = 0;
+                Iterator i = null;
+                try {
+                        for( i = iterator(); i.hasNext(); count++) i.next();
+                }
+                finally {
+                        close( i );
+                }
+//Xulu-01.sn
+                this.size = count;
+//Xulu-01.en
+                return count;
+        }
+
+        public boolean isEmpty() {
+                Iterator iterator = iterator();
+                try {
+                        return !iterator.hasNext();
+                }
+                finally {
+                        close( iterator );
+                }
+        }
+
+        public Iterator openIterator() {
+                return new FilteredIterator( collection, filter() );
+        }
+
+
+        public SimpleFeatureType getSchema() {
+        return collection.getSchema();
+        }
+
+    /**
+     * Accepts a visitor, which then visits each feature in the collection.
+     * @throws IOException
+     */
+    public void accepts(FeatureVisitor visitor, ProgressListener progress ) throws IOException {
+        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 FeatureReader reader() throws IOException {
+                return new DelegateFeatureReader( getSchema(), features() );
+        }
+
+        public int getCount() throws IOException {
+                return size();
+        }
+
+        public FeatureCollection collection() throws IOException {
+                return this;
+        }
+
+        public FeatureList sort(SortBy order) {
+                return null;
+        }
+
+        public void purge() {
+                collection.purge();
+        }
+}

Deleted: 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-08-26 13:49:19 UTC (rev 320)
+++ branches/1.0-gt2-2.6/src/org/geotools/feature/collection/SubFeatureCollection.java	2009-08-26 13:52:54 UTC (rev 321)
@@ -1,280 +0,0 @@
-/*
- *    GeoTools - OpenSource mapping toolkit
- *    http://geotools.org
- *    (C) 2005-2006, GeoTools Project Managment Committee (PMC)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.feature.collection;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.apache.batik.svggen.font.table.FeatureList;
-import org.geotools.data.FeatureReader;
-import org.geotools.data.collection.DelegateFeatureReader;
-import org.geotools.factory.CommonFactoryFinder;
-import org.geotools.feature.CollectionListener;
-import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.FeatureIterator;
-import org.geotools.feature.IllegalAttributeException;
-import org.geotools.feature.SimpleFeature;
-import org.geotools.feature.SimpleFeatureType;
-import org.geotools.feature.visitor.FeatureVisitor;
-import org.geotools.geometry.jts.ReferencedEnvelope;
-import org.opengis.util.ProgressListener;
-import org.opengis.filter.Filter;
-import org.opengis.filter.FilterFactory;
-import org.opengis.filter.sort.SortBy;
-
-import com.vividsolutions.jts.geom.Geometry;
-
-/**
- * <b>Xulu:<br>
- *    Code taken from gt-2.4.2 to optimize the {@link #size()} method!
- *    The original variant always iterates ALL features at every call!.</b><br><br>
- *
- * 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.
- * </p>
- *
- * @author Jody Garnett, Refractions Research, Inc.
- *
- * @source $URL: http://svn.geotools.org/geotools/tags/2.4.2/modules/library/main/src/main/java/org/geotools/feature/collection/SubFeatureCollection.java $
- */
-public class SubFeatureCollection extends AbstractResourceCollection implements FeatureCollection {
-// Xulu-01.sn
-  private int size = -1;
-// Xulu-01.en
-
-        /** Filter */
-    protected Filter filter;
-
-    /** Origional Collection */
-        protected FeatureCollection collection;
-    protected FeatureState state;
-    protected FilterFactory ff = CommonFactoryFinder.getFilterFactory( null );
-
-    public SubFeatureCollection(FeatureCollection collection ) {
-        this( collection, Filter.INCLUDE );
-    }
-        public SubFeatureCollection(FeatureCollection collection, Filter subfilter ){
-                if (subfilter == null ) subfilter = Filter.INCLUDE;
-                if (subfilter.equals(Filter.EXCLUDE)) {
-                        throw new IllegalArgumentException("A subcollection with Filter.EXCLUDE is a null operation");
-                }
-
-        if( collection instanceof SubFeatureCollection){
-                        SubFeatureCollection filtered = (SubFeatureCollection) collection;
-                        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 = collection;
-                        this.filter = subfilter;
-                }
-        state = new SubFeatureState( this.collection, this );
-        }
-
-        protected Filter filter(){
-            if( filter == null ){
-            filter = createFilter();
-        }
-        return filter;
-    }
-    /** Override to implement subsetting */
-    protected Filter createFilter(){
-        return Filter.INCLUDE;
-    }
-
-        public SimpleFeatureType getFeatureType() {
-                return state.getFeatureType();
-        }
-
-        public FeatureIterator features() {
-                return new DelegateFeatureIterator( this, iterator() );
-        }
-
-        public void closeIterator(Iterator iterator) {
-                if( iterator == null ) return;
-
-                if( iterator instanceof FilteredIterator){
-                        FilteredIterator filtered = (FilteredIterator) iterator;
-                        filtered.close();
-                }
-        }
-        public void close(FeatureIterator close) {
-                if( close != null ) close.close();
-        }
-
-    //
-    // SimpleFeature methods
-    //
-        public String getID() {
-                return state.getId();
-        }
-
-        public ReferencedEnvelope getBounds(){
-        return ReferencedEnvelope.reference(state.getBounds());
-        }
-
-        public Geometry getDefaultGeometry() {
-            return state.getDefaultGeometry();
-        }
-
-        public void setDefaultGeometry(Geometry g) throws IllegalAttributeException {
-            state.setDefaultGeometry( g );
-        }
-
-    public void addListener(CollectionListener listener) throws NullPointerException {
-        state.addListener( listener );
-    }
-
-    public void removeListener(CollectionListener listener) throws NullPointerException {
-        state.removeListener( listener );
-    }
-
-    public FeatureCollection getParent() {
-        return state.getParent();
-    }
-
-    public void setParent(FeatureCollection collection) {
-        state.setParent( collection );
-    }
-
-    public Object[] getAttributes(Object[] attributes) {
-        return state.getAttributes( attributes );
-    }
-
-    public Object getAttribute(String xPath) {
-        return state.getAttribute( xPath );
-    }
-
-    public Object getAttribute(int index) {
-        return state.getAttribute( index );
-    }
-
-    public void setAttribute(int position, Object val) throws IllegalAttributeException, ArrayIndexOutOfBoundsException {
-        state.setAttribute( position, val  );
-    }
-    public int getNumberOfAttributes() {
-        return state.getNumberOfAttributes();
-    }
-
-    public void setAttribute(String xPath, Object attribute) throws IllegalAttributeException {
-        state.setAttribute( xPath, attribute );
-    }
-
-    //
-    //
-    //
-        public FeatureCollection subCollection(Filter filter) {
-                if (filter.equals(Filter.INCLUDE)) {
-                        return this;
-                }
-                if (filter.equals(Filter.EXCLUDE)) {
-                        // TODO implement EmptyFeatureCollection( schema )
-                }
-                return new SubFeatureCollection(this, filter);
-        }
-
-        public int size() {
-//Xulu-01.sn
-          if ( this.size >= 0 )
-            return this.size;
-//Xulu-01.en
-                int count = 0;
-                Iterator i = null;
-                try {
-                        for( i = iterator(); i.hasNext(); count++) i.next();
-                }
-                finally {
-                        close( i );
-                }
-//Xulu-01.sn
-                this.size = count;
-//Xulu-01.en
-                return count;
-        }
-
-        public boolean isEmpty() {
-                Iterator iterator = iterator();
-                try {
-                        return !iterator.hasNext();
-                }
-                finally {
-                        close( iterator );
-                }
-        }
-
-        public Iterator openIterator() {
-                return new FilteredIterator( collection, filter() );
-        }
-
-
-        public SimpleFeatureType getSchema() {
-        return collection.getSchema();
-        }
-
-    /**
-     * Accepts a visitor, which then visits each feature in the collection.
-     * @throws IOException
-     */
-    public void accepts(FeatureVisitor visitor, ProgressListener progress ) throws IOException {
-        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 FeatureReader reader() throws IOException {
-                return new DelegateFeatureReader( getSchema(), features() );
-        }
-
-        public int getCount() throws IOException {
-                return size();
-        }
-
-        public FeatureCollection collection() throws IOException {
-                return this;
-        }
-
-        public FeatureList sort(SortBy order) {
-                return null;
-        }
-
-        public void purge() {
-                collection.purge();
-        }
-}



More information about the Schmitzm-commits mailing list