Revision 42331 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.operation.jts/src/main/java/org/gvsig/fmap/geom/operation/tojts/ToJTS.java
ToJTS.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.fmap.geom.operation.tojts; |
25 | 25 |
|
26 |
import java.lang.reflect.Array; |
|
26 |
import org.slf4j.Logger; |
|
27 |
import org.slf4j.LoggerFactory; |
|
27 | 28 |
|
28 |
import com.vividsolutions.jts.geom.Coordinate; |
|
29 |
|
|
30 | 29 |
import org.gvsig.fmap.geom.Geometry; |
31 | 30 |
import org.gvsig.fmap.geom.GeometryLocator; |
32 |
import org.gvsig.fmap.geom.GeometryManager; |
|
33 |
import org.gvsig.fmap.geom.jts.GeometryJTS; |
|
34 | 31 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
35 | 32 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
36 | 33 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
37 | 34 |
|
38 |
public abstract class ToJTS extends GeometryOperation { |
|
35 |
/* |
|
36 |
* Deprecated Esta operacion ha quedado obsoleta se mantiene por motivos de compatibilidad con las constantes. |
|
37 |
*/ |
|
38 |
public class ToJTS extends GeometryOperation { |
|
39 | 39 |
public static final String NAME = "toJTS"; |
40 |
protected static GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
41 |
public static final int CODE = geomManager.getGeometryOperationCode(NAME); |
|
42 |
protected final static com.vividsolutions.jts.geom.GeometryFactory geomFactory = new com.vividsolutions.jts.geom.GeometryFactory(); |
|
40 |
public static final int CODE = GeometryLocator.getGeometryManager().getGeometryOperationCode(NAME); |
|
41 |
protected static final Logger logger = LoggerFactory.getLogger(ToJTS.class); |
|
43 | 42 |
|
44 |
public int getOperationIndex() { |
|
45 |
return CODE; |
|
46 |
} |
|
47 |
|
|
48 |
// protected boolean isClosed(Coordinate firstCoordinate, Coordinate lastCoordinate){ |
|
49 |
// double diff = Math.abs(lastCoordinate.x - firstCoordinate.x); |
|
50 |
// if (diff > 0.000001){ |
|
51 |
// return false; |
|
52 |
// } |
|
53 |
// diff = Math.abs(lastCoordinate.y - firstCoordinate.y); |
|
54 |
// if (diff > 0.000001) { |
|
55 |
// return false; |
|
56 |
// } |
|
57 |
// return true; |
|
58 |
// } |
|
59 |
// |
|
60 |
// protected boolean pointInList(Coordinate testPoint, Coordinate[] pointList) { |
|
61 |
// int t; |
|
62 |
// int numpoints; |
|
63 |
// Coordinate p; |
|
64 |
// |
|
65 |
// numpoints = Array.getLength(pointList); |
|
66 |
// |
|
67 |
// for (t = 0; t < numpoints; t++) { |
|
68 |
// p = pointList[t]; |
|
69 |
// |
|
70 |
// if ((testPoint.x == p.x) && (testPoint.y == p.y) && |
|
71 |
// ((testPoint.z == p.z) || (!(testPoint.z == testPoint.z))) //nan test; x!=x iff x is nan |
|
72 |
// ) { |
|
73 |
// return true; |
|
74 |
// } |
|
75 |
// } |
|
76 |
// |
|
77 |
// return false; |
|
78 |
// } |
|
79 |
|
|
80 |
/* |
|
81 |
* (non-Javadoc) |
|
82 |
* @see org.gvsig.fmap.geom.operation.tojts.ToJTS#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext) |
|
43 |
/* (non-Javadoc) |
|
44 |
* @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext) |
|
83 | 45 |
*/ |
84 | 46 |
public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException { |
85 |
int srid = -1; |
|
86 |
if (ctx != null){ |
|
87 |
srid = ((JTSGeometryOperationContext)ctx).getSrid(); |
|
88 |
} |
|
89 |
|
|
90 |
GeometryJTS gjts = ((GeometryJTS) geom); |
|
91 |
com.vividsolutions.jts.geom.Geometry jts = gjts.getJTS(); |
|
92 |
jts.setSRID(srid); // FIXME ?Debemos hacer esto? |
|
93 |
|
|
94 |
return jts; |
|
47 |
logger.warn("Invoked deprecated operation ToJTS"); |
|
48 |
throw new GeometryOperationException(null); |
|
95 | 49 |
} |
50 |
/* (non-Javadoc) |
|
51 |
* @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex() |
|
52 |
*/ |
|
53 |
public int getOperationIndex() { |
|
54 |
logger.warn("Called getOperationIndex method of deprecated operation ToJTS"); |
|
55 |
return CODE; |
|
56 |
} |
|
57 |
|
|
96 | 58 |
} |
Also available in: Unified diff