svn-gvsig-desktop / tags / v2_0_0_Build_2049 / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / operation / tojts / ToJTS.java @ 38487
History | View | Annotate | Download (1.71 KB)
1 |
package org.gvsig.fmap.geom.operation.tojts; |
---|---|
2 |
|
3 |
import java.lang.reflect.Array; |
4 |
|
5 |
import org.gvsig.fmap.geom.Geometry; |
6 |
import org.gvsig.fmap.geom.GeometryLocator; |
7 |
import org.gvsig.fmap.geom.GeometryManager; |
8 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
9 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
10 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
11 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
12 |
import org.gvsig.fmap.geom.util.Converter; |
13 |
|
14 |
import com.vividsolutions.jts.geom.Coordinate; |
15 |
|
16 |
public abstract class ToJTS extends GeometryOperation { |
17 |
public static final String NAME = "toJTS"; |
18 |
protected static GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
19 |
public static final int CODE = geomManager.getGeometryOperationCode(NAME); |
20 |
protected final static com.vividsolutions.jts.geom.GeometryFactory geomFactory = new com.vividsolutions.jts.geom.GeometryFactory(); |
21 |
|
22 |
public int getOperationIndex() { |
23 |
return CODE;
|
24 |
} |
25 |
|
26 |
protected boolean isClosed(Coordinate firstCoordinate, Coordinate lastCoordinate){ |
27 |
double diff = Math.abs(lastCoordinate.x - firstCoordinate.x); |
28 |
if (diff > 0.000001){ |
29 |
return false; |
30 |
} |
31 |
diff = Math.abs(lastCoordinate.y - firstCoordinate.y);
|
32 |
if (diff > 0.000001) { |
33 |
return false; |
34 |
} |
35 |
return true; |
36 |
} |
37 |
|
38 |
protected boolean pointInList(Coordinate testPoint, Coordinate[] pointList) { |
39 |
int t;
|
40 |
int numpoints;
|
41 |
Coordinate p; |
42 |
|
43 |
numpoints = Array.getLength(pointList);
|
44 |
|
45 |
for (t = 0; t < numpoints; t++) { |
46 |
p = pointList[t]; |
47 |
|
48 |
if ((testPoint.x == p.x) && (testPoint.y == p.y) &&
|
49 |
((testPoint.z == p.z) || (!(testPoint.z == testPoint.z))) //nan test; x!=x iff x is nan
|
50 |
) { |
51 |
return true; |
52 |
} |
53 |
} |
54 |
|
55 |
return false; |
56 |
} |
57 |
} |