Revision 30 org.gvsig.sextante/trunk/org.gvsig.sextante.app/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.clip/src/main/java/org/gvsig/sextante/app/algorithm/clip/ClipOperation.java
ClipOperation.java | ||
---|---|---|
26 | 26 |
import org.gvsig.fmap.dal.feature.Feature; |
27 | 27 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
28 | 28 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
29 |
import org.gvsig.fmap.geom.util.Converter; |
|
29 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
30 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
31 |
import org.gvsig.fmap.geom.operation.tojts.ToJTS; |
|
30 | 32 |
import org.gvsig.sextante.app.algorithm.base.core.DALFeaturePersister; |
31 | 33 |
import org.gvsig.sextante.app.algorithm.base.util.GeometryUtil; |
32 | 34 |
|
... | ... | |
51 | 53 |
* clipping layer |
52 | 54 |
*/ |
53 | 55 |
private Geometry clippingConvexHull = null; |
54 |
|
|
55 | 56 |
private DALFeaturePersister persister = null; |
56 |
|
|
57 | 57 |
private EditableFeature lastEditFeature = null; |
58 | 58 |
|
59 | 59 |
public ClipOperation(org.gvsig.fmap.geom.Geometry clip) { |
60 |
this.clippingConvexHull = Converter.geometryToJts(clip); |
|
60 |
try { |
|
61 |
this.clippingConvexHull = (Geometry)clip.invokeOperation(ToJTS.CODE, null); |
|
62 |
} catch (GeometryOperationNotSupportedException e1) { |
|
63 |
Sextante.addErrorToLog(e1); |
|
64 |
} catch (GeometryOperationException e1) { |
|
65 |
Sextante.addErrorToLog(e1); |
|
66 |
} |
|
61 | 67 |
} |
62 | 68 |
|
63 | 69 |
/** |
... | ... | |
79 | 85 |
if(g == null) |
80 | 86 |
return lastEditFeature; |
81 | 87 |
|
82 |
Geometry jtsGeom = Converter.geometryToJts(g); |
|
88 |
Geometry jtsGeom = null; |
|
89 |
try { |
|
90 |
jtsGeom = (Geometry)g.invokeOperation(ToJTS.CODE, null); |
|
91 |
} catch (GeometryOperationNotSupportedException e1) { |
|
92 |
Sextante.addErrorToLog(e1); |
|
93 |
return null; |
|
94 |
} catch (GeometryOperationException e1) { |
|
95 |
Sextante.addErrorToLog(e1); |
|
96 |
return null; |
|
97 |
} |
|
98 |
|
|
83 | 99 |
if(!jtsGeom.getEnvelope().intersects(clippingConvexHull.getEnvelope())) |
84 | 100 |
return lastEditFeature; |
85 | 101 |
|
... | ... | |
128 | 144 |
|
129 | 145 |
lastEditFeature = feature; |
130 | 146 |
|
131 |
Geometry jtsGeom = Converter.geometryToJts(g); |
|
147 |
Geometry jtsGeom = null; |
|
148 |
try { |
|
149 |
jtsGeom = (Geometry)g.invokeOperation(ToJTS.CODE, null); |
|
150 |
} catch (GeometryOperationNotSupportedException e1) { |
|
151 |
Sextante.addErrorToLog(e1); |
|
152 |
return; |
|
153 |
} catch (GeometryOperationException e1) { |
|
154 |
Sextante.addErrorToLog(e1); |
|
155 |
return; |
|
156 |
} |
|
157 |
|
|
132 | 158 |
if(!jtsGeom.getEnvelope().intersects(clippingConvexHull.getEnvelope())) |
133 | 159 |
return; |
134 | 160 |
|
Also available in: Unified diff