Revision 43 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/BufferOperation.java
BufferOperation.java | ||
---|---|---|
20 | 20 |
*/ |
21 | 21 |
package org.gvsig.sextante.app.algorithm.buffer; |
22 | 22 |
|
23 |
import org.cresques.cts.IProjection; |
|
23 | 24 |
import org.gvsig.fmap.dal.exception.DataException; |
24 | 25 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
25 | 26 |
import org.gvsig.fmap.dal.feature.Feature; |
26 | 27 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
28 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
27 | 29 |
import org.gvsig.sextante.app.algorithm.base.core.DALFeaturePersister; |
28 | 30 |
import org.gvsig.sextante.app.algorithm.base.core.GeometryOperation; |
31 |
import org.gvsig.sextante.app.algorithm.base.util.GeometryUtil; |
|
29 | 32 |
|
33 |
import com.vividsolutions.jts.geom.Geometry; |
|
34 |
import com.vividsolutions.jts.geom.GeometryCollection; |
|
35 |
|
|
36 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
37 |
|
|
30 | 38 |
/** |
31 | 39 |
* Buffer operation |
32 | 40 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
33 | 41 |
*/ |
34 |
public class BufferOperation extends GeometryOperation { |
|
35 |
|
|
36 |
public BufferOperation() { |
|
37 |
|
|
42 |
public abstract class BufferOperation extends GeometryOperation { |
|
43 |
public static final byte CAP_SQUARE = 0; |
|
44 |
public static final byte CAP_ROUND = 1; |
|
45 |
|
|
46 |
protected byte capBuffer = CAP_ROUND; |
|
47 |
protected int numberOfRadialBuffers = 1; |
|
48 |
protected IDistance distance = null; |
|
49 |
|
|
50 |
protected IVectorLayer layer = null; |
|
51 |
protected IProjection projection = null; |
|
52 |
protected double userDistance = 0D; |
|
53 |
|
|
54 |
public BufferOperation(IDistance distance, IVectorLayer layer, double userDistance) { |
|
55 |
this.distance = distance; |
|
56 |
this.layer = layer; |
|
57 |
this.projection = (IProjection)layer.getCRS(); |
|
58 |
this.userDistance = userDistance; |
|
38 | 59 |
} |
39 | 60 |
|
40 | 61 |
/** |
... | ... | |
47 | 68 |
} |
48 | 69 |
|
49 | 70 |
|
50 |
public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature feature) { |
|
51 |
|
|
52 |
return lastEditFeature; |
|
71 |
/** |
|
72 |
* Verifys if a geometry buffer is null. |
|
73 |
* It is useful when you're working with internal buffers. If the internal |
|
74 |
* buffer distance is greater than the geometry radius, the buffer result |
|
75 |
* will be null. |
|
76 |
* |
|
77 |
* @param newGeometry |
|
78 |
* @return |
|
79 |
*/ |
|
80 |
protected boolean verifyNilGeometry(Geometry newGeometry){ |
|
81 |
if(newGeometry instanceof GeometryCollection){ |
|
82 |
if(((GeometryCollection)newGeometry).getNumGeometries() == 0){ |
|
83 |
//we have collapsed initial geometry |
|
84 |
return true; |
|
85 |
} |
|
86 |
} |
|
87 |
return false; |
|
53 | 88 |
} |
54 | 89 |
|
90 |
/** |
|
91 |
* Adds a new feature |
|
92 |
* @param feature |
|
93 |
* @param newGeom |
|
94 |
* @throws CreateGeometryException |
|
95 |
* @throws DataException |
|
96 |
* @deprecated No es necesario porque no hay diferencia entre las llamadas entre ambos invoke |
|
97 |
*/ |
|
98 |
protected void addFeature(Feature feature, Geometry newGeom) throws CreateGeometryException, DataException { |
|
99 |
if(!(feature instanceof EditableFeature)) |
|
100 |
lastEditFeature = persister.addFeature(feature, newGeom); |
|
101 |
else { |
|
102 |
org.gvsig.fmap.geom.Geometry g = GeometryUtil.jtsToGeom(newGeom); |
|
103 |
persister.addGeometryToExistingFeature((EditableFeature)feature, g); |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* Sets type of cap flag |
|
109 |
* @param typeOfCap |
|
110 |
*/ |
|
111 |
public void setTypeOfCap(byte typeOfCap) { |
|
112 |
capBuffer = typeOfCap; |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Sets number of radial rings buffers |
|
117 |
* @param number |
|
118 |
*/ |
|
119 |
public void setNumberOfRadialBuffers(int number) { |
|
120 |
numberOfRadialBuffers = number; |
|
121 |
} |
|
55 | 122 |
|
56 |
public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature feature) { |
|
57 |
|
|
58 |
} |
|
59 | 123 |
} |
Also available in: Unified diff