Revision 1082 org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.lateralbuffer/src/main/java/org/gvsig/geoprocess/algorithm/lateralbuffer/LateralBufferOperation.java
LateralBufferOperation.java | ||
---|---|---|
41 | 41 |
import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier; |
42 | 42 |
|
43 | 43 |
import es.unex.sextante.core.Sextante; |
44 |
import java.util.logging.Level; |
|
45 |
import java.util.logging.Logger; |
|
46 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
47 |
import org.gvsig.fmap.geom.GeometryManager; |
|
48 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
49 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
50 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
51 |
import org.gvsig.fmap.geom.primitive.Line; |
|
44 | 52 |
|
45 | 53 |
/** |
46 | 54 |
* Lateral buffer operation |
... | ... | |
50 | 58 |
public class LateralBufferOperation extends BufferOperation { |
51 | 59 |
private BufferParameters bufParams = null; |
52 | 60 |
private int lateral = LateralBufferAlgorithm.LEFT; |
61 |
private boolean ignoreInvalidLines = false; |
|
62 |
private final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
53 | 63 |
/** |
54 | 64 |
* Builds an instance of this operation. |
55 | 65 |
* |
... | ... | |
61 | 71 |
FeatureStore inputStore, |
62 | 72 |
AbstractSextanteGeoProcess p, |
63 | 73 |
byte tableFieldStructure, |
64 |
int lateral) { |
|
74 |
int lateral, |
|
75 |
boolean ignoreInvalidLines) { |
|
76 |
|
|
65 | 77 |
super(distance, inputStore, p, tableFieldStructure); |
66 | 78 |
this.lateral = lateral; |
79 |
this.ignoreInvalidLines = ignoreInvalidLines; |
|
67 | 80 |
bufParams = new BufferParameters(); |
68 | 81 |
bufParams.setSingleSided(true); |
69 | 82 |
bufParams.setEndCapStyle(capBuffer == CAP_ROUND |
... | ... | |
84 | 97 |
if(originalGeometry == null) |
85 | 98 |
return null; |
86 | 99 |
|
100 |
|
|
101 |
if(ignoreInvalidLines) { |
|
102 |
if (geomManager.isSubtype(TYPES.LINE,g.getGeometryType().getType())) { |
|
103 |
try { |
|
104 |
Line newg = null; |
|
105 |
newg = (Line) g; |
|
106 |
if ((newg.getVertex(0)==newg.getVertex(newg.getNumVertices()-1) && newg.getNumVertices()==2) || (newg.perimeter()<1)) { |
|
107 |
return null; |
|
108 |
} |
|
109 |
} catch (GeometryOperationNotSupportedException e) { |
|
110 |
Sextante.addErrorToLog(e); |
|
111 |
return null; |
|
112 |
} catch (GeometryOperationException e) { |
|
113 |
Sextante.addErrorToLog(e); |
|
114 |
return null; |
|
115 |
} |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
87 | 119 |
if (originalGeometry.getDimension() != 0) |
88 | 120 |
simplifiedGeometry = |
89 | 121 |
TopologyPreservingSimplifier.simplify(originalGeometry, |
Also available in: Unified diff