Revision 44 org.gvsig.sextante/trunk/org.gvsig.sextante.app/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.buffer/src/main/java/org/gvsig/sextante/app/algorithm/buffer/OutBufferOperation.java
OutBufferOperation.java | ||
---|---|---|
31 | 31 |
import com.vividsolutions.jts.geom.Geometry; |
32 | 32 |
import com.vividsolutions.jts.operation.buffer.BufferOp; |
33 | 33 |
import com.vividsolutions.jts.operation.buffer.BufferParameters; |
34 |
import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier; |
|
34 | 35 |
|
35 | 36 |
import es.unex.sextante.core.Sextante; |
36 | 37 |
import es.unex.sextante.dataObjects.IVectorLayer; |
... | ... | |
40 | 41 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
41 | 42 |
*/ |
42 | 43 |
public class OutBufferOperation extends BufferOperation { |
43 |
|
|
44 |
|
|
44 | 45 |
/** |
45 | 46 |
* Builds an instance of this operation. |
46 | 47 |
* @param distance |
... | ... | |
58 | 59 |
public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature feature) { |
59 | 60 |
Geometry newGeom = null; |
60 | 61 |
Geometry previousExteriorRing = null; |
61 |
Geometry inputParam = GeometryUtil.geomToJTS(g); |
|
62 |
Geometry originalGeometry = GeometryUtil.geomToJTS(g); |
|
63 |
Geometry inputParam = originalGeometry; |
|
62 | 64 |
distance.setFeature(feature); |
63 | 65 |
double bufferDistance = distance.getBufferDistance(userDistance, projection, MapTools.getDistanceUnits(), MapTools.getMapUnits()); |
64 | 66 |
|
67 |
if(originalGeometry.getDimension() != 0) |
|
68 |
inputParam = TopologyPreservingSimplifier.simplify(originalGeometry, bufferDistance / 10d); |
|
69 |
|
|
70 |
|
|
65 | 71 |
for(int i = 1; i <= numberOfRadialBuffers; i++) { |
66 | 72 |
double distRing = i * bufferDistance; |
67 | 73 |
BufferOp bufOp = new BufferOp(inputParam); |
... | ... | |
73 | 79 |
newGeom = newGeometry; |
74 | 80 |
|
75 | 81 |
try { |
76 |
lastEditFeature = persister.addFeature(feature, newGeom); |
|
82 |
if(newGeom != null) { |
|
83 |
lastEditFeature = persister.addFeature(newGeom, id, distRing); |
|
84 |
id ++; |
|
85 |
previousExteriorRing = newGeom; |
|
86 |
} |
|
77 | 87 |
} catch (CreateGeometryException e) { |
78 | 88 |
Sextante.addErrorToLog(e); |
79 | 89 |
} catch (DataException e) { |
Also available in: Unified diff