Revision 45939 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/util/JTSUtils.java
JTSUtils.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.fmap.geom.jts.util; |
24 | 24 |
|
25 |
import java.util.ArrayList; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 | 25 |
import com.vividsolutions.jts.geom.Coordinate; |
29 | 26 |
import com.vividsolutions.jts.geom.CoordinateSequence; |
30 | 27 |
import com.vividsolutions.jts.geom.GeometryCollection; |
... | ... | |
38 | 35 |
import com.vividsolutions.jts.operation.buffer.BufferParameters; |
39 | 36 |
import com.vividsolutions.jts.operation.buffer.OffsetCurveBuilder; |
40 | 37 |
import com.vividsolutions.jts.util.GeometricShapeFactory; |
38 |
import java.util.ArrayList; |
|
39 |
import java.util.List; |
|
41 | 40 |
import org.cresques.cts.IProjection; |
42 |
|
|
43 |
import org.hibernate.spatial.jts.mgeom.MCoordinateSequence; |
|
44 |
import org.hibernate.spatial.jts.mgeom.MGeometryFactory; |
|
45 |
import org.slf4j.Logger; |
|
46 |
import org.slf4j.LoggerFactory; |
|
47 |
|
|
48 | 41 |
import org.gvsig.fmap.geom.Geometry; |
49 | 42 |
import static org.gvsig.fmap.geom.Geometry.JOIN_STYLE_BEVEL; |
50 | 43 |
import static org.gvsig.fmap.geom.Geometry.JOIN_STYLE_MITRE; |
... | ... | |
90 | 83 |
import org.gvsig.fmap.geom.primitive.Primitive; |
91 | 84 |
import org.gvsig.fmap.geom.primitive.Ring; |
92 | 85 |
import org.gvsig.fmap.geom.type.GeometryType; |
86 |
import org.hibernate.spatial.jts.mgeom.MCoordinateSequence; |
|
87 |
import org.hibernate.spatial.jts.mgeom.MGeometryFactory; |
|
88 |
import org.slf4j.Logger; |
|
89 |
import org.slf4j.LoggerFactory; |
|
93 | 90 |
|
94 | 91 |
/** |
95 | 92 |
* @author fdiaz |
... | ... | |
215 | 212 |
} |
216 | 213 |
|
217 | 214 |
public static Geometry createGeometry(IProjection proj, com.vividsolutions.jts.geom.Geometry jtsGeom) { |
215 |
return createGeometry(proj, jtsGeom, null); |
|
216 |
} |
|
217 |
|
|
218 |
public static Geometry createGeometry(IProjection proj, com.vividsolutions.jts.geom.Geometry jtsGeom, GeometryType typeWhenEmpty) { |
|
219 |
if(jtsGeom.isEmpty()){ |
|
220 |
if(typeWhenEmpty == null){ |
|
221 |
return null; |
|
222 |
} |
|
223 |
try { |
|
224 |
return typeWhenEmpty.create(); |
|
225 |
} catch (CreateGeometryException ex) { |
|
226 |
return null; |
|
227 |
} |
|
228 |
} |
|
218 | 229 |
if (jtsGeom instanceof com.vividsolutions.jts.geom.Point) { |
219 | 230 |
Coordinate coordinate = jtsGeom.getCoordinate(); |
220 | 231 |
if (jtsGeom.getFactory() instanceof MyMGeometryFactory) { |
... | ... | |
304 | 315 |
Coordinate coordinate = collection.getCoordinate(); |
305 | 316 |
MultiPrimitive multiprimitive = null; |
306 | 317 |
if (jtsGeom instanceof MultiLineString) { |
307 |
if (jtsGeom.getFactory() instanceof MyMGeometryFactory) { |
|
308 |
if (Double.isNaN(coordinate.z)) { |
|
309 |
multiprimitive = new MultiLine2DM(); |
|
318 |
if (jtsGeom.getFactory() instanceof MyMGeometryFactory) { |
|
319 |
if (Double.isNaN(coordinate.z)) { |
|
320 |
multiprimitive = new MultiLine2DM(); |
|
321 |
} else { |
|
322 |
multiprimitive = new MultiLine3DM(); |
|
323 |
} |
|
310 | 324 |
} else { |
311 |
multiprimitive = new MultiLine3DM(); |
|
325 |
if (Double.isNaN(coordinate.z)) { |
|
326 |
multiprimitive = new MultiLine2D(); |
|
327 |
} else { |
|
328 |
multiprimitive = new MultiLine3D(); |
|
329 |
} |
|
312 | 330 |
} |
313 |
} else { |
|
314 |
if (Double.isNaN(coordinate.z)) { |
|
315 |
multiprimitive = new MultiLine2D(); |
|
316 |
} else { |
|
317 |
multiprimitive = new MultiLine3D(); |
|
318 |
} |
|
319 |
} |
|
320 | 331 |
} else if (jtsGeom instanceof MultiPolygon) { |
321 | 332 |
if (jtsGeom.getFactory() instanceof MyMGeometryFactory) { |
322 | 333 |
if (Double.isNaN(coordinate.z)) { |
Also available in: Unified diff