Index: org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.fusespatially/src/main/java/org/gvsig/geoprocess/algorithm/fusespatially/FuseSpatiallyOperationFast2.java
===================================================================
--- org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.fusespatially/src/main/java/org/gvsig/geoprocess/algorithm/fusespatially/FuseSpatiallyOperationFast2.java	(revision 1131)
+++ org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.fusespatially/src/main/java/org/gvsig/geoprocess/algorithm/fusespatially/FuseSpatiallyOperationFast2.java	(revision 1132)
@@ -41,7 +41,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
  */
-
 package org.gvsig.geoprocess.algorithm.fusespatially;
 
 import java.util.ArrayList;
@@ -64,421 +63,453 @@
 
 import com.vividsolutions.jts.geom.Geometry;
 import java.util.Iterator;
+
 /**
  * Fuse spatially operation
+ *
  * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
  */
 public class FuseSpatiallyOperationFast2 extends GeometryOperation {
-	private static Logger 			         logger    		    = LoggerFactory.getLogger(FuseSpatiallyOperationFast2.class.getName());
-	private ArrayList<Element>               featureList        = null;
-	private String                           nameIdField        = null;
-	private FeatureStore                     outFeatStoreTable  = null;
-	private NodeTree                         baseTree           = null;
 
-	class Element {
-		public int                 id              = -1;
-		public Feature             feat            = null;
-		public List<Element>       overlapList     = new ArrayList<Element>();
-		public boolean             insertedToJoin  = false;
-		public Geometry            jtsGeom         = null;
-	}
+    private static Logger logger = LoggerFactory.getLogger(FuseSpatiallyOperationFast2.class.getName());
+    private ArrayList<Element> featureList = null;
+    private String nameIdField = null;
+    private FeatureStore outFeatStoreTable = null;
+    private NodeTree baseTree = null;
 
-	class NodeTree {
-		public Element       element     = null;
-		public int           pos         = 0;
-		public NodeTree       parent      = null;
+    class Element {
 
-		public NodeTree(Element node, NodeTree parent) {
-			this.element = node;
-			this.parent = parent;
-		}
+        public int id = -1;
+        public Feature feat = null;
+        public List<Element> overlapList = new ArrayList<Element>();
+        public boolean insertedToJoin = false;
+        public Geometry jtsGeom = null;
+    }
 
-		public Element getNext() {
-			if(pos < element.overlapList.size())
-				return element.overlapList.get(pos++);
-			return null;
-		}
-	}
+    class NodeTree {
 
-	public FuseSpatiallyOperationFast2(AbstractSextanteGeoProcess process) {
-		super(process);
-		featureList = new ArrayList<Element>();
-	}
+        public Element element = null;
+        public int pos = 0;
+        public NodeTree parent = null;
 
-	@Override
-	public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g,
-			Feature featureInput) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        public NodeTree(Element node, NodeTree parent) {
+            this.element = node;
+            this.parent = parent;
+        }
 
-	@Override
-	public void invoke(org.gvsig.fmap.geom.Geometry g,
-			EditableFeature featureInput) {
-		// TODO Auto-generated method stub
+        public Element getNext() {
+            if (pos < element.overlapList.size()) {
+                return element.overlapList.get(pos++);
+            }
+            return null;
+        }
+    }
 
-	}
+    public FuseSpatiallyOperationFast2(AbstractSextanteGeoProcess process) {
+        super(process);
+        featureList = new ArrayList<Element>();
+    }
 
-	/**
-	 * Computes a complete operation over the input FeatureStore. The result of this operation
-	 * is stored in the output FeatureStore. This method will call once for each geometry.
-	 * @param inFeatStore
-	 *        Input FeatureStore
-	 * @param outFeatStore
-	 *        Output FeatureStore
-	 * @param outFeatStoreTable
-	 * @param attrNames
-	 *        List of attributes to build the output feature store
-	 * @param attrNamesTable
-	 * @param selectedGeomInput
-	 * @param selectedGeomOutput
-	 * @param idField
-	 * @param selectedGeom
-	 *        If it is true only the selected geometries will be processed
-	 * @throws DataException
-	 */
-	@SuppressWarnings("deprecation")
-	public void computesGeometryOperation(FeatureStore inFeatStore,
-									FeatureStore outFeatStore,
-									FeatureStore outFeatStoreTable,
-									String[] attrNames,
-									String[] attrNamesTable,
-									boolean selectedGeomInput,
-									boolean selectedGeomOutput,
-									String idField) throws DataException {
-		this.outFeatStoreTable = outFeatStoreTable;
-		this.nameIdField = idField;
-		this.inFeatureStore = inFeatStore;
-		this.selectedGeomInput = selectedGeomInput;
-		this.selectedGeomOverlay = selectedGeomOutput;
-		FeatureSet featuresSet = null;
-		featuresSet = inFeatStore.getFeatureSet();
+    @Override
+    public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g,
+            Feature featureInput) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-		setFeatureStore(outFeatStore, attrNames);
-		Iterator it = null;
+    @Override
+    public void invoke(org.gvsig.fmap.geom.Geometry g,
+            EditableFeature featureInput) {
+        // TODO Auto-generated method stub
 
-		if(selectedGeomInput) {
+    }
+
+    /**
+     * Computes a complete operation over the input FeatureStore. The result of
+     * this operation is stored in the output FeatureStore. This method will
+     * call once for each geometry.
+     *
+     * @param inFeatStore Input FeatureStore
+     * @param outFeatStore Output FeatureStore
+     * @param outFeatStoreTable
+     * @param attrNames List of attributes to build the output feature store
+     * @param attrNamesTable
+     * @param selectedGeomInput
+     * @param selectedGeomOutput
+     * @param idField
+     * @param selectedGeom If it is true only the selected geometries will be
+     * processed
+     * @throws DataException
+     */
+    @SuppressWarnings("deprecation")
+    public void computesGeometryOperation(FeatureStore inFeatStore,
+            FeatureStore outFeatStore,
+            FeatureStore outFeatStoreTable,
+            String[] attrNames,
+            String[] attrNamesTable,
+            boolean selectedGeomInput,
+            boolean selectedGeomOutput,
+            String idField) throws DataException {
+        this.outFeatStoreTable = outFeatStoreTable;
+        this.nameIdField = idField;
+        this.inFeatureStore = inFeatStore;
+        this.selectedGeomInput = selectedGeomInput;
+        this.selectedGeomOverlay = selectedGeomOutput;
+        FeatureSet featuresSet = null;
+        featuresSet = inFeatStore.getFeatureSet();
+
+        setFeatureStore(outFeatStore, attrNames);
+        Iterator it = null;
+
+        if (selectedGeomInput) {
             FeatureSelection ds = inFeatStore.getFeatureSelection();
             it = ds.iterator();
             numberOfFeatures = (int) ds.getSelectedCount();
-		} else {
-			it = featuresSet.iterator();
-			numberOfFeatures = (int)featuresSet.getSize();
-		}
+        } else {
+            it = featuresSet.iterator();
+            numberOfFeatures = (int) featuresSet.getSize();
+        }
 
-        if (status != null)
+        if (status != null) {
             status.setRangeOfValues(0, numberOfFeatures);
-        if(process != null)
+        }
+        if (process != null) {
             process.setProgress(0, numberOfFeatures);
+        }
 
         //Crear lista de elementos
-		int iCount = 0;
-		while( it.hasNext() && !process.getTaskMonitor().isCanceled()) {
-			Feature feat = ((Feature)it.next()).getCopy();
-			Element el = new Element();
-			el.feat = feat;
-			el.id = iCount;
-			featureList.add(el);
-            if (status != null && process != null)
+        int iCount = 0;
+        while (it.hasNext() && !process.getTaskMonitor().isCanceled()) {
+            Feature feat = ((Feature) it.next()).getCopy();
+            Element el = new Element();
+            el.feat = feat;
+            el.id = iCount;
+            featureList.add(el);
+            if (status != null && process != null) {
                 status.setCurValue(iCount);
-            if(process != null)
+            }
+            if (process != null) {
                 process.setProgress(iCount, numberOfFeatures);
-			iCount ++;
-		}
+            }
+            iCount++;
+        }
 //		it.dispose();
 
-		//Crear listas de solapes para cada feature
-		iCount = 0;
-		while (iCount < featureList.size() && !process.getTaskMonitor().isCanceled()) {
-			Element elem1 = featureList.get(iCount);
-			org.gvsig.fmap.geom.Geometry geom1 = elem1.feat.getDefaultGeometry();
-			if (status != null)
+        //Crear listas de solapes para cada feature
+        iCount = 0;
+        while (iCount < featureList.size() && !process.getTaskMonitor().isCanceled()) {
+            Element elem1 = featureList.get(iCount);
+            org.gvsig.fmap.geom.Geometry geom1 = elem1.feat.getDefaultGeometry();
+            if (status != null) {
                 status.setCurValue(iCount);
-            if(process != null)
+            }
+            if (process != null) {
                 process.setProgress(iCount, numberOfFeatures);
+            }
 
-			for (int i = iCount + 1; i < featureList.size(); i++) {
-				Element elem2 = featureList.get(i);
-				org.gvsig.fmap.geom.Geometry geom2 = elem2.feat.getDefaultGeometry();
-				if(areBBoxesOverlaping(geom1, geom2)) {
-					if(elem1.jtsGeom == null) {
-						elem1.jtsGeom = GeometryUtil.geomToJTS(geom1);
-					}
-					elem2.jtsGeom = GeometryUtil.geomToJTS(geom2);
-					if(elem1.jtsGeom.intersects(elem2.jtsGeom))	{
-						elem1.overlapList.add(elem2);
-						elem2.overlapList.add(elem1);
-					}
-				}
-			}
-			iCount ++;
-		}
+            for (int i = iCount + 1; i < featureList.size(); i++) {
+                Element elem2 = featureList.get(i);
+                org.gvsig.fmap.geom.Geometry geom2 = elem2.feat.getDefaultGeometry();
+                if (areBBoxesOverlaping(geom1, geom2)) {
+                    if (elem1.jtsGeom == null) {
+                        elem1.jtsGeom = GeometryUtil.geomToJTS(geom1);
+                    }
+                    elem2.jtsGeom = GeometryUtil.geomToJTS(geom2);
+                    if (elem1.jtsGeom.intersects(elem2.jtsGeom)) {
+                        elem1.overlapList.add(elem2);
+                        elem2.overlapList.add(elem1);
+                    }
+                }
+            }
+            iCount++;
+        }
 
-		iCount = 0;
-		int iFeat = 0;
-		while (iCount < featureList.size() && !process.getTaskMonitor().isCanceled()) {
-			Element elem1 = featureList.get(iCount);
-			if (status != null)
+        iCount = 0;
+        int iFeat = 0;
+        while (iCount < featureList.size() && !process.getTaskMonitor().isCanceled()) {
+            Element elem1 = featureList.get(iCount);
+            if (status != null) {
                 status.setCurValue(iCount);
-            if(process != null)
+            }
+            if (process != null) {
                 process.setProgress(iCount, numberOfFeatures);
+            }
 
-			if(!elem1.insertedToJoin) {
-				buildListToJoin(elem1, iFeat);
-				iFeat ++;
-			}
+            if (!elem1.insertedToJoin) {
+                buildListToJoin(elem1, iFeat);
+                iFeat++;
+            }
 
-			iCount ++;
-		}
+            iCount++;
+        }
 
-		if(persister != null)
-			persister.end();
+        if (persister != null) {
+            persister.end();
+        }
 
-	}
+    }
 
-	private boolean areBBoxesOverlaping(org.gvsig.fmap.geom.Geometry g1, org.gvsig.fmap.geom.Geometry g2) {
-		if(g1.getEnvelope().getMaximum(0) < g2.getEnvelope().getMinimum(0))
-			return false;
-		if(g1.getEnvelope().getMinimum(0) > g2.getEnvelope().getMaximum(0))
-			return false;
-		if(g1.getEnvelope().getMaximum(1) < g2.getEnvelope().getMinimum(1))
-			return false;
-		if(g1.getEnvelope().getMinimum(1) > g2.getEnvelope().getMaximum(1))
-			return false;
-		return true;
-	}
+    private boolean areBBoxesOverlaping(org.gvsig.fmap.geom.Geometry g1, org.gvsig.fmap.geom.Geometry g2) {
+        if (g1.getEnvelope().getMaximum(0) < g2.getEnvelope().getMinimum(0)) {
+            return false;
+        }
+        if (g1.getEnvelope().getMinimum(0) > g2.getEnvelope().getMaximum(0)) {
+            return false;
+        }
+        if (g1.getEnvelope().getMaximum(1) < g2.getEnvelope().getMinimum(1)) {
+            return false;
+        }
+        if (g1.getEnvelope().getMinimum(1) > g2.getEnvelope().getMaximum(1)) {
+            return false;
+        }
+        return true;
+    }
 
-	/**
-	 * Computes the union of the list of geometries
-	 * @param listResult
-	 * @param elem1
-	 * @return
-	 */
-	private Geometry computesUnion(List<Geometry> listResult, Element elem1) {
-		int splitValue = 500;
-		Geometry newGeom = null;
-		if(listResult.size() > splitValue) {
-			List<List<Geometry>> list = splitList(listResult, splitValue);
-			List<Geometry> result = new ArrayList<Geometry>();
-			for (int i = 0; i < list.size(); i++) {
-				Geometry aux = GeometryUtil.geometryUnion(list.get(i), elem1.feat.getDefaultGeometry().getGeometryType().getType());
-				result.add(aux);
-			}
-			for (int i = 0; i < result.size(); i++) {
-				newGeom = GeometryUtil.geometryUnion(result, elem1.feat.getDefaultGeometry().getGeometryType().getType());
-			}
-		} else {
-			newGeom = GeometryUtil.geometryUnion(listResult, elem1.feat.getDefaultGeometry().getGeometryType().getType());
-		}
-		return newGeom;
-	}
+    /**
+     * Computes the union of the list of geometries
+     *
+     * @param listResult
+     * @param elem1
+     * @return
+     */
+    private Geometry computesUnion(List<Geometry> listResult, Element elem1) {
+        int splitValue = 500;
+        Geometry newGeom = null;
+        if (listResult.size() > splitValue) {
+            List<List<Geometry>> list = splitList(listResult, splitValue);
+            List<Geometry> result = new ArrayList<Geometry>();
+            for (int i = 0; i < list.size(); i++) {
+                Geometry aux = GeometryUtil.geometryUnion(list.get(i), elem1.feat.getDefaultGeometry().getGeometryType().getType());
+                result.add(aux);
+            }
+            for (int i = 0; i < result.size(); i++) {
+                newGeom = GeometryUtil.geometryUnion(result, elem1.feat.getDefaultGeometry().getGeometryType().getType());
+            }
+        } else {
+            newGeom = GeometryUtil.geometryUnion(listResult, elem1.feat.getDefaultGeometry().getGeometryType().getType());
+        }
+        return newGeom;
+    }
 
-	private Geometry computesUnion2(List<Geometry> listResult, Element elem1) {
-		Geometry newGeom = null;
-		for (int i = 1; i < listResult.size(); i++) {
-			if(i == 1)
-				newGeom = JTSFacade.union(listResult.get(0), listResult.get(1));
-			else
-				newGeom = JTSFacade.union(newGeom, listResult.get(i));
-		}
-		return newGeom;
-	}
+    private Geometry computesUnion2(List<Geometry> listResult, Element elem1) {
+        Geometry newGeom = null;
+        for (int i = 1; i < listResult.size(); i++) {
+            if (i == 1) {
+                newGeom = JTSFacade.union(listResult.get(0), listResult.get(1));
+            } else {
+                newGeom = JTSFacade.union(newGeom, listResult.get(i));
+            }
+        }
+        return newGeom;
+    }
 
-	private Geometry computesUnion3(List<Geometry> listResult) {
-		Geometry newGeom = null;
-		int iCount = 0;
-		int max = listResult.size();
-		if(process != null)
-			process.setName("Generating union");
-		while(listResult.size() > 1) {
-			List<Geometry> list = new ArrayList<Geometry>();
-			if (status != null)
+    private Geometry computesUnion3(List<Geometry> listResult) {
+        Geometry newGeom = null;
+        int iCount = 0;
+        int max = listResult.size();
+        if (process != null) {
+            process.setName("Generating union");
+        }
+        while (listResult.size() > 1) {
+            List<Geometry> list = new ArrayList<Geometry>();
+            if (status != null) {
                 status.setCurValue(iCount);
-            if(process != null)
+            }
+            if (process != null) {
                 process.setProgress(iCount, max);
-			for (int i = 0; i < listResult.size(); i = i + 2) {
-				if(i == (listResult.size() - 1))
-					list.add(listResult.get(i));
-				else {
-					newGeom = JTSFacade.union(listResult.get(i), listResult.get(i + 1));
-					list.add(newGeom);
-				}
-			}
-			listResult = list;
-		}
-		return newGeom;
-	}
+            }
+            for (int i = 0; i < listResult.size(); i = i + 2) {
+                if (i == (listResult.size() - 1)) {
+                    list.add(listResult.get(i));
+                } else {
+                    newGeom = JTSFacade.union(listResult.get(i), listResult.get(i + 1));
+                    list.add(newGeom);
+                }
+            }
+            listResult = list;
+        }
+        return newGeom;
+    }
 
-	/**
-	 * Splits the array of geometries to compute its union because JTS cannot support
-	 * a lot of geometries
-	 * @param list
-	 * @param n
-	 * @return
-	 */
-	private List<List<Geometry>> splitList(List<Geometry> list, int n) {
-		int elements = (int)(list.size() / n);
-		List<List<Geometry>> l = new ArrayList<List<Geometry>>();
-		for (int i = 0; i < elements; i++) {
-			l.add(list.subList((i * n), (i * n) + n));
-		}
-		if(elements * n < list.size()) {
-			l.add(list.subList((elements * n), list.size()));
-		}
-		return l;
-	}
+    /**
+     * Splits the array of geometries to compute its union because JTS cannot
+     * support a lot of geometries
+     *
+     * @param list
+     * @param n
+     * @return
+     */
+    private List<List<Geometry>> splitList(List<Geometry> list, int n) {
+        int elements = (int) (list.size() / n);
+        List<List<Geometry>> l = new ArrayList<List<Geometry>>();
+        for (int i = 0; i < elements; i++) {
+            l.add(list.subList((i * n), (i * n) + n));
+        }
+        if (elements * n < list.size()) {
+            l.add(list.subList((elements * n), list.size()));
+        }
+        return l;
+    }
 
-	/**
-	 * Builds the union of all lists
-	 * @param listResult
-	 * @param listToJoin
-	 */
-	private void buildListToJoin(Element elem, int iFeat) {
-		Geometry newGeom = null;
+    /**
+     * Builds the union of all lists
+     *
+     * @param listResult
+     * @param listToJoin
+     */
+    private void buildListToJoin(Element elem, int iFeat) {
+        Geometry newGeom = null;
 
-		if(elem.overlapList.size() == 0) {
-			if(!elem.insertedToJoin)
-				elem.insertedToJoin = true;
-			try {
-				insertInTable(outFeatStoreTable, elem.feat, iFeat);
-				addFeatureToOutput(elem.feat.getDefaultGeometry(), elem.feat, iFeat);
-			} catch (DataException e) {
-				logger.info("Imposible insertar en la tabla", e);
-			} catch (CreateGeometryException e) {
-				logger.info("Error añadiendo geometría", e);
-			}
-		} else {
-			List<Geometry> listResult = new ArrayList<Geometry>();
-			NodeTree subtree = new NodeTree(elem, null);
-			//Hacemos un recorrido en profundidad del árbol para añadir
-			//todos los elementos a la lista de geometrias a unir sin
-			//repetir ninguna.
-			while (subtree != null) {
-				if(!subtree.element.insertedToJoin) {
-					listResult.add(subtree.element.jtsGeom);
-					try {
-						insertInTable(outFeatStoreTable, subtree.element.feat, iFeat);
-					} catch (DataException e) {
-						logger.info("Imposible insertar en la tabla", e);
-					}
-					subtree.element.insertedToJoin = true;
-				}
+        if (elem.overlapList.size() == 0) {
+            if (!elem.insertedToJoin) {
+                elem.insertedToJoin = true;
+            }
+            try {
+                insertInTable(outFeatStoreTable, elem.feat, iFeat);
+                addFeatureToOutput(elem.feat.getDefaultGeometry(), elem.feat, iFeat);
+            } catch (DataException e) {
+                logger.info("Imposible insertar en la tabla", e);
+            } catch (CreateGeometryException e) {
+                logger.info("Error añadiendo geometría", e);
+            }
+        } else {
+            List<Geometry> listResult = new ArrayList<Geometry>();
+            NodeTree subtree = new NodeTree(elem, null);
+            //Hacemos un recorrido en profundidad del árbol para añadir
+            //todos los elementos a la lista de geometrias a unir sin
+            //repetir ninguna.
+            while (subtree != null) {
+                if (!subtree.element.insertedToJoin) {
+                    listResult.add(subtree.element.jtsGeom);
+                    try {
+                        insertInTable(outFeatStoreTable, subtree.element.feat, iFeat);
+                    } catch (DataException e) {
+                        logger.info("Imposible insertar en la tabla", e);
+                    }
+                    subtree.element.insertedToJoin = true;
+                }
 
-				boolean back = false;
+                boolean back = false;
 
-				Element l = subtree.getNext();
-				if(l == null)
-					back = true;
+                Element l = subtree.getNext();
+                if (l == null) {
+                    back = true;
+                }
 
-				while(!back && l.insertedToJoin) {
-					l = subtree.getNext();
-					if(l == null)
-						back = true;
-				}
+                while (!back && l.insertedToJoin) {
+                    l = subtree.getNext();
+                    if (l == null) {
+                        back = true;
+                    }
+                }
 
-				if(back) {
-					subtree = subtree.parent;
-					continue;
-				}
-				subtree = new NodeTree(l, subtree);
-			}
-			newGeom = computesUnion3(listResult);
+                if (back) {
+                    subtree = subtree.parent;
+                    continue;
+                }
+                subtree = new NodeTree(l, subtree);
+            }
+            newGeom = computesUnion3(listResult);
 
-			try {
-				addFeatureToOutput(newGeom, elem.feat, iFeat);
-			} catch (DataException e) {
-				logger.info("Imposible insertar en la tabla", e);
-			} catch (CreateGeometryException e) {
-				logger.info("Error añadiendo geometría", e);
-			}
-		}
+            try {
+                addFeatureToOutput(newGeom, elem.feat, iFeat);
+            } catch (DataException e) {
+                logger.info("Imposible insertar en la tabla", e);
+            } catch (CreateGeometryException e) {
+                logger.info("Error añadiendo geometría", e);
+            }
+        }
 
-	}
+    }
 
-	/**
-	 * Adds a feature to the output
-	 * @param newGeom
-	 * @param feat
-	 * @param newFeatID
-	 * @throws DataException
-	 * @throws CreateGeometryException
-	 */
-	private void addFeatureToOutput(org.gvsig.fmap.geom.Geometry newGeom,
-			Feature feat,
-			int newFeatID) throws DataException, CreateGeometryException {
-		//Si hay una tabla aparte esta capa solo lleva el id como referencia a la tabla de campos
-		if(outFeatStoreTable != null) {
-			lastEditFeature = persister.addFeature(newGeom, nameIdField, newFeatID);
-		} else {
-			//Si no hay tabla se ponen todos los campos de la tabla de entrada
-			String[] fieldNames = persister.getFieldNamesWithoutGeom();
-			ArrayList<String> fields = new ArrayList<String>();
-			ArrayList<Object> values = new ArrayList<Object>();
-			fields.add(nameIdField);
-			values.add(newFeatID);
-			for (int j = 0; j < fieldNames.length; j++) {
-				Object obj = feat.get(fieldNames[j]);
-				if(obj != null && fieldNames[j].compareTo(nameIdField) != 0) {
-					fields.add(fieldNames[j]);
-					values.add(obj);
-				}
-			}
-			lastEditFeature = persister.addFeature(newGeom, fields, values);
-		}
-	}
+    /**
+     * Adds a feature to the output
+     *
+     * @param newGeom
+     * @param feat
+     * @param newFeatID
+     * @throws DataException
+     * @throws CreateGeometryException
+     */
+    private void addFeatureToOutput(org.gvsig.fmap.geom.Geometry newGeom,
+            Feature feat,
+            int newFeatID) throws DataException, CreateGeometryException {
+        //Si hay una tabla aparte esta capa solo lleva el id como referencia a la tabla de campos
+        if (outFeatStoreTable != null) {
+            lastEditFeature = persister.addFeature(newGeom, nameIdField, newFeatID);
+        } else {
+            //Si no hay tabla se ponen todos los campos de la tabla de entrada
+            String[] fieldNames = persister.getFieldNamesWithoutGeom();
+            ArrayList<String> fields = new ArrayList<String>();
+            ArrayList<Object> values = new ArrayList<Object>();
+            fields.add(nameIdField);
+            values.add(newFeatID);
+            for (int j = 0; j < fieldNames.length; j++) {
+                Object obj = feat.get(fieldNames[j]);
+                if (obj != null && fieldNames[j].compareTo(nameIdField) != 0) {
+                    fields.add(fieldNames[j]);
+                    values.add(obj);
+                }
+            }
+            lastEditFeature = persister.addFeature(newGeom, fields, values);
+        }
+    }
 
-	/**
-	 * Adds a feature to the output
-	 * @param newGeom
-	 * @param feat
-	 * @param newFeatID
-	 * @throws DataException
-	 * @throws CreateGeometryException
-	 */
-	private void addFeatureToOutput(Geometry newGeom,
-			Feature feat,
-			int newFeatID) throws DataException, CreateGeometryException {
-		//Si hay una tabla aparte esta capa solo lleva el id como referencia a la tabla de campos
-		if(outFeatStoreTable != null) {
-			lastEditFeature = persister.addFeature(newGeom, nameIdField, newFeatID);
-		} else {
-			//Si no hay tabla se ponen todos los campos de la tabla de entrada
-			String[] fieldNames = persister.getFieldNamesWithoutGeom();
-			ArrayList<String> fields = new ArrayList<String>();
-			ArrayList<Object> values = new ArrayList<Object>();
-			fields.add(nameIdField);
-			values.add(newFeatID);
-			for (int j = 0; j < fieldNames.length; j++) {
-				Object obj = feat.get(fieldNames[j]);
-				if(obj != null && fieldNames[j].compareTo(nameIdField) != 0) {
-					fields.add(fieldNames[j]);
-					values.add(obj);
-				}
-			}
-			lastEditFeature = persister.addFeature(newGeom, fields, values);
-		}
-	}
+    /**
+     * Adds a feature to the output
+     *
+     * @param newGeom
+     * @param feat
+     * @param newFeatID
+     * @throws DataException
+     * @throws CreateGeometryException
+     */
+    private void addFeatureToOutput(Geometry newGeom,
+            Feature feat,
+            int newFeatID) throws DataException, CreateGeometryException {
+        //Si hay una tabla aparte esta capa solo lleva el id como referencia a la tabla de campos
+        if (outFeatStoreTable != null) {
+            lastEditFeature = persister.addFeature(newGeom, nameIdField, newFeatID);
+        } else {
+            //Si no hay tabla se ponen todos los campos de la tabla de entrada
+            String[] fieldNames = persister.getFieldNamesWithoutGeom();
+            ArrayList<String> fields = new ArrayList<String>();
+            ArrayList<Object> values = new ArrayList<Object>();
+            fields.add(nameIdField);
+            values.add(newFeatID);
+            for (int j = 0; j < fieldNames.length; j++) {
+                Object obj = feat.get(fieldNames[j]);
+                if (obj != null && fieldNames[j].compareTo(nameIdField) != 0) {
+                    fields.add(fieldNames[j]);
+                    values.add(obj);
+                }
+            }
+            lastEditFeature = persister.addFeature(newGeom, fields, values);
+        }
+    }
 
-	/**
-	 * Insert in the output table a new feature with the fields of the input feature. Moreover
-	 * exists a field that is an identifier which is a reference to the fusion layer.
-	 * @param outFeatureStoreTable
-	 * @param f
-	 * @throws DataException
-	 */
-	private void insertInTable(FeatureStore outFeatureStoreTable, Feature f, int reference) throws DataException {
-		if(outFeatureStoreTable == null)
-			return;
-		EditableFeature edFeat = outFeatureStoreTable.createNewFeature();
-		edFeat.set(nameIdField, reference);
-		FeatureAttributeDescriptor[] attrList = f.getType().getAttributeDescriptors();
-		for (int j = 0; j < attrList.length; j++) {
-			if(attrList[j].getName().compareTo("GEOMETRY") != 0) {
-				edFeat.set(attrList[j].getName(), f.get(attrList[j].getName()));
-			}
-		}
-		outFeatureStoreTable.insert(edFeat);
-	}
+    /**
+     * Insert in the output table a new feature with the fields of the input
+     * feature. Moreover exists a field that is an identifier which is a
+     * reference to the fusion layer.
+     *
+     * @param outFeatureStoreTable
+     * @param f
+     * @throws DataException
+     */
+    private void insertInTable(FeatureStore outFeatureStoreTable, Feature f, int reference) throws DataException {
+        if (outFeatureStoreTable == null) {
+            return;
+        }
+        EditableFeature edFeat = outFeatureStoreTable.createNewFeature();
+        edFeat.set(nameIdField, reference);
+        FeatureAttributeDescriptor[] attrList = f.getType().getAttributeDescriptors();
+        for (int j = 0; j < attrList.length; j++) {
+            if (attrList[j].getName().compareTo("GEOMETRY") != 0) {
+                edFeat.set(attrList[j].getName(), f.get(attrList[j].getName()));
+            }
+        }
+        outFeatureStoreTable.insert(edFeat);
+    }
 
 }
-
