Index: DefaultTopologyDataSet.java
===================================================================
--- DefaultTopologyDataSet.java	(revision 2066)
+++ DefaultTopologyDataSet.java	(revision 2067)
@@ -29,6 +29,9 @@
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.mutable.MutableObject;
 import org.gvsig.expressionevaluator.Expression;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
+import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
 import org.gvsig.expressionevaluator.ExpressionUtils;
 import org.gvsig.expressionevaluator.GeometryExpressionBuilder;
 import org.gvsig.expressionevaluator.GeometryExpressionUtils;
@@ -372,11 +375,14 @@
                     );
                     final SpatialIndex dataIndex = theStore.wrapSpatialIndex(geomIndex);
                     try {
-                        store.accept((Object o) -> {
-                            Feature f = (Feature) o;
-                            Geometry geom = f.getDefaultGeometry();
-                            if (geom != null) {
-                                dataIndex.insert(geom, f);
+                        store.accept(new Visitor() {
+                            @Override
+                            public void visit(Object o) throws VisitCanceledException, BaseException {
+                                Feature f = (Feature) o;
+                                Geometry geom = f.getDefaultGeometry();
+                                if (geom != null) {
+                                    dataIndex.insert(geom, f);
+                                }
                             }
                         });
                     } catch (VisitCanceledException ex) {
@@ -390,128 +396,7 @@
         return this.spatialIndex.getValue();
     }
 
-    
     @Override
-    public Iterable<FeatureReference>  getFeatureReferencesThatEnvelopeIntersectsWith(Geometry geom) {
-        SpatialIndex index = this.getSpatialIndex();
-        if( index == null ) {
-            try {
-                FeatureStore theStore = (FeatureStore) this.getStore();
-                Expression expression = ExpressionUtils.createExpression();
-                GeometryExpressionBuilder expressionBuilder = GeometryExpressionUtils.createExpressionBuilder();
-                String geomName = theStore.getDefaultFeatureType().getDefaultGeometryAttributeName();
-                if( GeometryUtils.isSubtype(Geometry.TYPES.POINT, geom.getType()) )  {
-                    expression.setPhrase(
-                        expressionBuilder.ifnull(
-                            expressionBuilder.column(geomName),
-                            expressionBuilder.constant(false),
-                            expressionBuilder.ST_Intersects(
-                                    expressionBuilder.column(geomName),
-                                    expressionBuilder.geometry(geom)
-                            )
-                        ).toString()
-                    );
-                } else {
-                    expression.setPhrase(
-                        expressionBuilder.ifnull(
-                            expressionBuilder.column(geomName),
-                            expressionBuilder.constant(false),
-                            expressionBuilder.ST_Intersects(
-                                    expressionBuilder.column(geomName),
-                                    expressionBuilder.envelope(geom.getEnvelope())
-                            )
-                        ).toString()
-                    );
-                }
-                FeatureSet set = theStore.getFeatureSet(expression);
-                final DisposableIterator it = set.fastIterator();
-                return () -> new Iterator<FeatureReference>() {
-                    @Override
-                    public boolean hasNext() {
-                        return it.hasNext();
-                    }
-                    
-                    @Override
-                    public FeatureReference next() {
-                        Feature f = (Feature) it.next();
-                        return f.getReference();
-                    }
-                };
-                
-            } catch(Exception ex) {
-                return (Iterable<FeatureReference>) IteratorUtils.EMPTY_ITERATOR;
-            }
-        }
-        final Iterator it = index.query(geom);
-        if( it == null ) {
-            return (Iterable<FeatureReference>) IteratorUtils.EMPTY_ITERATOR;
-        }
-        return () -> it;
-    }
-    
-    @Override
-    public Iterable<Feature>  getFeaturesThatEnvelopeIntersectsWith(Geometry geom) {
-        SpatialIndex index = this.getSpatialIndex();
-        if( index == null ) {
-            try {
-                FeatureStore theStore = (FeatureStore) this.getStore();
-                Expression expression = ExpressionUtils.createExpression();
-                GeometryExpressionBuilder expressionBuilder = GeometryExpressionUtils.createExpressionBuilder();
-                String geomName = theStore.getDefaultFeatureType().getDefaultGeometryAttributeName();
-                if( GeometryUtils.isSubtype(Geometry.TYPES.POINT, geom.getType()) )  {
-                    expression.setPhrase(
-                        expressionBuilder.ifnull(
-                            expressionBuilder.column(geomName),
-                            expressionBuilder.constant(false),
-                            expressionBuilder.ST_Intersects(
-                                    expressionBuilder.column(geomName),
-                                    expressionBuilder.geometry(geom)
-                            )
-                        ).toString()
-                    );
-                } else {
-                    expression.setPhrase(
-                        expressionBuilder.ifnull(
-                            expressionBuilder.column(geomName),
-                            expressionBuilder.constant(false),
-                            expressionBuilder.ST_Intersects(
-                                    expressionBuilder.column(geomName),
-                                    expressionBuilder.envelope(geom.getEnvelope())
-                            )
-                        ).toString()
-                    );
-                }
-                FeatureSet set = theStore.getFeatureSet(expression);
-                final DisposableIterator it = set.fastIterator();
-                return () -> it;
-                
-            } catch(Exception ex) {
-                return (Iterable<Feature>) IteratorUtils.EMPTY_ITERATOR;
-            }
-        }
-        final Iterator it = index.query(geom);
-        if( it == null ) {
-            return (Iterable<Feature>) IteratorUtils.EMPTY_ITERATOR;
-        }
-        return () -> new Iterator<Feature>() {
-            @Override
-            public boolean hasNext() {
-                return it.hasNext();
-            }
-            
-            @Override
-            public Feature next() {
-                FeatureReference ref = (FeatureReference) it.next();
-                try {
-                    return ref.getFeature();
-                } catch (DataException ex) {
-                    return null;
-                }
-            }
-        };
-    }
-
-    @Override
     public Iterable<FeatureReference> query(Geometry geom) {
         return this.queryReferences(geom);
     }
@@ -550,17 +435,22 @@
                 }
                 FeatureSet set = theStore.getFeatureSet(expression);
                 final DisposableIterator it = set.fastIterator();
-                return () -> new Iterator<FeatureReference>() {
+                return new Iterable<FeatureReference>() {
                     @Override
-                    public boolean hasNext() {
-                        return it.hasNext();
+                    public Iterator<FeatureReference> iterator() {
+                        return new Iterator<FeatureReference>() {
+                            @Override
+                            public boolean hasNext() {
+                                return it.hasNext();
+                            }
+
+                            @Override
+                            public FeatureReference next() {
+                                Feature f = (Feature) it.next();
+                                return f.getReference();
+                            }
+                        };
                     }
-                    
-                    @Override
-                    public FeatureReference next() {
-                        Feature f = (Feature) it.next();
-                        return f.getReference();
-                    }
                 };
                 
             } catch(Exception ex) {
@@ -571,7 +461,12 @@
         if( it == null ) {
             return (Iterable<FeatureReference>) IteratorUtils.EMPTY_ITERATOR;
         }
-        return () -> it;
+        return new Iterable<FeatureReference>() {
+            @Override
+            public Iterator<FeatureReference> iterator() {
+                return it;
+            }
+        };
     }
 
     @Override
@@ -608,7 +503,12 @@
                 }
                 FeatureSet set = theStore.getFeatureSet(expression);
                 final DisposableIterator it = set.fastIterator();
-                return () -> it;
+                return new Iterable<Feature>() {
+                    @Override
+                    public Iterator<Feature> iterator() {
+                        return it;
+                    }
+                };
                 
             } catch(Exception ex) {
                 return (Iterable<Feature>) IteratorUtils.EMPTY_ITERATOR;
@@ -618,21 +518,26 @@
         if( it == null ) {
             return (Iterable<Feature>) IteratorUtils.EMPTY_ITERATOR;
         }
-        return () -> new Iterator<Feature>() {
+        return new Iterable<Feature>() {
             @Override
-            public boolean hasNext() {
-                return it.hasNext();
+            public Iterator<Feature> iterator() {
+                return new Iterator<Feature>() {
+                    @Override
+                    public boolean hasNext() {
+                        return it.hasNext();
+                    }
+
+                    @Override
+                    public Feature next() {
+                        FeatureReference ref = (FeatureReference) it.next();
+                        try {
+                            return ref.getFeature();
+                        } catch (DataException ex) {
+                            return null;
+                        }
+                    }
+                };
             }
-            
-            @Override
-            public Feature next() {
-                FeatureReference ref = (FeatureReference) it.next();
-                try {
-                    return ref.getFeature();
-                } catch (DataException ex) {
-                    return null;
-                }
-            }
         };
     }
 
