Index: branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/tojts/Surface2DToJTSLineString.java
===================================================================
--- branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/tojts/Surface2DToJTSLineString.java	(revision 0)
+++ branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/tojts/Surface2DToJTSLineString.java	(revision 38388)
@@ -0,0 +1,101 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program 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 General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+ 
+package org.gvsig.fmap.geom.operation.tojts;
+
+import java.awt.geom.PathIterator;
+import java.util.ArrayList;
+
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.operation.GeometryOperationContext;
+import org.gvsig.fmap.geom.operation.GeometryOperationException;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.CoordinateArrays;
+import com.vividsolutions.jts.geom.LinearRing;
+import com.vividsolutions.jts.geom.MultiLineString;
+
+/**
+ * Converts a Surface2D into a MultiLineString object
+ * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
+ */
+public class Surface2DToJTSLineString extends ToJTS {
+	public static final String NAME = "toJTSLineString";
+	public static final int CODE = geomManager.getGeometryOperationCode(NAME);
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.geom.operation.tojts.ToJTS#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
+	 */
+	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
+		int srid = -1;
+		if (ctx != null){
+			srid = ((JTSGeometryOperationContext)ctx).getSrid();
+		}
+		PathIterator theIterator = geom.getPathIterator(null, geomManager.getFlatness());
+		int theType;
+		double[] theData = new double[6];
+		ArrayList arrayCoords = null;
+		Coordinate[] points = null;
+		ArrayList listRings = new ArrayList();
+		theIterator = geom.getPathIterator(null, geomManager.getFlatness());
+
+		while (!theIterator.isDone()) {
+			theType = theIterator.currentSegment(theData);
+
+			switch (theType) {
+			case PathIterator.SEG_MOVETO:
+				if (arrayCoords == null) {
+					arrayCoords = new ArrayList();
+				} else
+					arrayCoords.clear();
+				arrayCoords.add(new Coordinate(theData[0], theData[1]));
+				break;
+
+			case PathIterator.SEG_LINETO:
+				arrayCoords.add(new Coordinate(theData[0],theData[1]));
+				break;
+			case PathIterator.SEG_QUADTO:
+				System.out.println("SEG_QUADTO Not supported here");
+				break;
+			case PathIterator.SEG_CUBICTO:
+				System.out.println("SEG_CUBICTO Not supported here");
+				break;
+			case PathIterator.SEG_CLOSE:
+				Coordinate firstCoord = (Coordinate) arrayCoords.get(0);
+				Coordinate lastCoord = (Coordinate) arrayCoords.get(arrayCoords.size() - 1);
+				if (!isClosed(firstCoord, lastCoord)) {
+					arrayCoords.add(firstCoord);
+				}
+				points = CoordinateArrays.toCoordinateArray(arrayCoords);
+				listRings.add(geomFactory.createLinearRing(points));
+				break;
+			}
+			theIterator.next();
+		} 
+		
+		LinearRing[] list = (LinearRing[])listRings.toArray(new LinearRing[listRings.size()]);
+		MultiLineString lineStr = new com.vividsolutions.jts.geom.GeometryFactory().createMultiLineString(list);
+		lineStr.setSRID(srid);
+		return lineStr;
+	}
+}

Property changes on: branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/tojts/Surface2DToJTSLineString.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/impl/DefaultGeometryOperationLibrary.java
===================================================================
--- branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/impl/DefaultGeometryOperationLibrary.java	(revision 38387)
+++ branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/impl/DefaultGeometryOperationLibrary.java	(revision 38388)
@@ -58,6 +58,7 @@
 import org.gvsig.fmap.geom.operation.tojts.MultiSurfaceToJTS;
 import org.gvsig.fmap.geom.operation.tojts.Point2DToJTS;
 import org.gvsig.fmap.geom.operation.tojts.Surface2DToJTS;
+import org.gvsig.fmap.geom.operation.tojts.Surface2DToJTSLineString;
 import org.gvsig.fmap.geom.operation.tojts.ToJTS;
 import org.gvsig.fmap.geom.operation.towkb.ToWKB;
 import org.gvsig.fmap.geom.operation.towkb.ToWKBNative;
@@ -117,6 +118,7 @@
         geometryManager.registerGeometryOperation(ToJTS.NAME, new MultiPointToJTS(), TYPES.MULTIPOINT);
         geometryManager.registerGeometryOperation(ToJTS.NAME, new MultiCurveToJTS(), TYPES.MULTICURVE);
         geometryManager.registerGeometryOperation(ToJTS.NAME, new MultiSurfaceToJTS(), TYPES.MULTISURFACE);
-        
+        geometryManager.registerGeometryOperation(Surface2DToJTSLineString.NAME, new Surface2DToJTSLineString(), TYPES.SURFACE);
+        geometryManager.registerGeometryOperation(Surface2DToJTSLineString.NAME, new Surface2DToJTSLineString(), TYPES.MULTISURFACE);
     }	
 }
\ No newline at end of file
Index: branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/util/Converter.java
===================================================================
--- branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/util/Converter.java	(revision 38387)
+++ branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/util/Converter.java	(revision 38388)
@@ -49,6 +49,21 @@
 import java.lang.reflect.Array;
 import java.util.ArrayList;
 
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.Geometry.TYPES;
+import org.gvsig.fmap.geom.aggregate.MultiCurve;
+import org.gvsig.fmap.geom.aggregate.MultiPoint;
+import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
+import org.gvsig.fmap.geom.aggregate.MultiSurface;
+import org.gvsig.fmap.geom.exception.CreateGeometryException;
+import org.gvsig.fmap.geom.primitive.GeneralPathX;
+import org.gvsig.fmap.geom.primitive.Surface;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import com.vividsolutions.jts.algorithm.CGAlgorithms;
 import com.vividsolutions.jts.algorithm.RobustCGAlgorithms;
 import com.vividsolutions.jts.geom.Coordinate;
@@ -62,22 +77,6 @@
 import com.vividsolutions.jts.geom.Point;
 import com.vividsolutions.jts.geom.Polygon;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.gvsig.fmap.geom.Geometry;
-import org.gvsig.fmap.geom.Geometry.SUBTYPES;
-import org.gvsig.fmap.geom.Geometry.TYPES;
-import org.gvsig.fmap.geom.GeometryLocator;
-import org.gvsig.fmap.geom.GeometryManager;
-import org.gvsig.fmap.geom.aggregate.MultiCurve;
-import org.gvsig.fmap.geom.aggregate.MultiPoint;
-import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
-import org.gvsig.fmap.geom.aggregate.MultiSurface;
-import org.gvsig.fmap.geom.exception.CreateGeometryException;
-import org.gvsig.fmap.geom.primitive.GeneralPathX;
-import org.gvsig.fmap.geom.primitive.Surface;
-
 /**
  * Clase con varios m�todos est�ticos utilizados para pasar de java2d a jts
  * y viceversa.
@@ -152,6 +151,14 @@
 				shpNew = geomManager.createPoint(((Point) geo).getX(),
 						((Point) geo).getY(), SUBTYPES.GEOM2D);
 			}
+			
+			if (geo instanceof com.vividsolutions.jts.geom.MultiPoint) {
+				shpNew = (MultiPoint)geomManager.create(TYPES.MULTIPOINT, SUBTYPES.GEOM2D);
+				Coordinate[] coord = ((com.vividsolutions.jts.geom.MultiPoint)geo).getCoordinates();
+				for (int i = 0; i < coord.length; i++) {
+					((MultiPoint)shpNew).addPoint(geomManager.createPoint(coord[i].x, coord[i].y, SUBTYPES.GEOM2D));
+				}
+			}
 
 			if (geo.isEmpty()) {
 				shpNew = null;
