Revision 265 org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.union/src/main/java/org/gvsig/geoprocess/algorithm/union/UnionAlgorithm.java
UnionAlgorithm.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.geoprocess.algorithm.union; |
25 | 25 |
|
26 |
import es.unex.sextante.core.Sextante; |
|
27 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
28 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
29 |
import es.unex.sextante.exceptions.NullParameterValueException; |
|
30 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
31 |
import es.unex.sextante.exceptions.WrongParameterIDException; |
|
32 |
import es.unex.sextante.exceptions.WrongParameterTypeException; |
|
33 |
import es.unex.sextante.outputs.OutputVectorLayer; |
|
34 |
|
|
35 | 26 |
import org.gvsig.fmap.dal.exception.DataException; |
36 | 27 |
import org.gvsig.fmap.dal.exception.ReadException; |
37 | 28 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
... | ... | |
45 | 36 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
46 | 37 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer; |
47 | 38 |
|
39 |
import es.unex.sextante.core.Sextante; |
|
40 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
41 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
42 |
import es.unex.sextante.exceptions.NullParameterValueException; |
|
43 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
44 |
import es.unex.sextante.exceptions.WrongParameterIDException; |
|
45 |
import es.unex.sextante.exceptions.WrongParameterTypeException; |
|
46 |
import es.unex.sextante.outputs.OutputVectorLayer; |
|
47 |
|
|
48 | 48 |
/** |
49 | 49 |
* Union algorithm |
50 | 50 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
... | ... | |
80 | 80 |
} catch (RepeatedParameterNameException e) { |
81 | 81 |
Sextante.addErrorToLog(e); |
82 | 82 |
} |
83 |
addOutputVectorLayer(RESULT1, |
|
84 |
getTranslation("Union_l1"), |
|
83 |
addOutputVectorLayer(RESULT1, getTranslation("Union_l1"), |
|
85 | 84 |
OutputVectorLayer.SHAPE_TYPE_UNDEFINED); |
86 |
addOutputVectorLayer(RESULT2, |
|
87 |
getTranslation("Union_l2"), |
|
85 |
addOutputVectorLayer(RESULT2, getTranslation("Union_l2"), |
|
88 | 86 |
OutputVectorLayer.SHAPE_TYPE_UNDEFINED); |
89 | 87 |
} |
90 | 88 |
|
... | ... | |
120 | 118 |
|
121 | 119 |
//POL-POL |
122 | 120 |
if(isPolygon(storeLayer1) && isPolygon(storeLayer2)) { |
123 |
featStoreOut1 = buildOutPutStoreFromUnion(featureType1, featureType2, layer1.getShapeType(), |
|
124 |
getTranslation("Union_l1"), |
|
121 |
featStoreOut1 = buildOutPutStoreFromUnion(featureType1, |
|
122 |
featureType2, |
|
123 |
layer1.getShapeType(), |
|
124 |
getTranslation("Union_l1"), |
|
125 | 125 |
RESULT1); |
126 | 126 |
computesUnion(storeLayer1, storeLayer2, featStoreOut1, selectedGeom); |
127 | 127 |
} else |
128 | 128 |
//PTO-PTO |
129 | 129 |
if(isPoint(storeLayer1) && isPoint(storeLayer2)) { |
130 |
featStoreOut1 = buildOutPutStoreFromUnion(featureType1, featureType2, layer1.getShapeType(), |
|
131 |
getTranslation("Union_l1"), |
|
130 |
featStoreOut1 = buildOutPutStoreFromUnion(featureType1, |
|
131 |
featureType2, |
|
132 |
layer1.getShapeType(), |
|
133 |
getTranslation("Union_l1"), |
|
132 | 134 |
RESULT1); |
133 | 135 |
computesUnion(storeLayer1, storeLayer2, featStoreOut1, selectedGeom); |
134 | 136 |
} else |
135 | 137 |
//LIN-LIN |
136 | 138 |
if(isLine(storeLayer1) && isLine(storeLayer2)) { |
137 |
featStoreOut1 = buildOutPutStoreFromUnion(featureType1, featureType2, IVectorLayer.SHAPE_TYPE_POINT, |
|
138 |
getTranslation("Union_l1"), RESULT1); |
|
139 |
featStoreOut1 = buildOutPutStoreFromUnion(featureType1, |
|
140 |
featureType2, |
|
141 |
IVectorLayer.SHAPE_TYPE_POINT, |
|
142 |
getTranslation("Union_l1"), |
|
143 |
RESULT1); |
|
139 | 144 |
computesIntersection(storeLayer1, storeLayer2, featStoreOut1, selectedGeom, true); |
140 |
featStoreOut2 = buildOutPutStoreFromUnion(featureType1, featureType2, IVectorLayer.SHAPE_TYPE_LINE, |
|
141 |
getTranslation("Union_l2"), RESULT2); |
|
145 |
featStoreOut2 = buildOutPutStoreFromUnion(featureType1, |
|
146 |
featureType2, |
|
147 |
IVectorLayer.SHAPE_TYPE_LINE, |
|
148 |
getTranslation("Union_l2"), |
|
149 |
RESULT2); |
|
142 | 150 |
computesDifference(storeLayer1, storeLayer2, featStoreOut2, selectedGeom, false); |
143 | 151 |
computesDifference(storeLayer2, storeLayer1, featStoreOut2, selectedGeom, true); |
144 | 152 |
} else |
145 | 153 |
//POL-LIN |
146 | 154 |
if( (isPolygon(storeLayer1) && isLine(storeLayer2)) || |
147 | 155 |
(isLine(storeLayer1) && isPolygon(storeLayer2))) { |
148 |
featStoreOut1 = buildOutPutStoreFromUnion(featureType1, featureType2, IVectorLayer.SHAPE_TYPE_LINE, |
|
156 |
featStoreOut1 = buildOutPutStoreFromUnion(featureType1, |
|
157 |
featureType2, |
|
158 |
IVectorLayer.SHAPE_TYPE_LINE, |
|
149 | 159 |
getTranslation("Union_l1"), RESULT1); |
150 | 160 |
computesIntersection(storeLayer1, storeLayer2, featStoreOut1, selectedGeom, true); |
151 |
featStoreOut2 = buildOutPutStoreFromUnion(featureType1, featureType2, IVectorLayer.SHAPE_TYPE_POLYGON, |
|
152 |
getTranslation("Union_l2"), RESULT2); |
|
161 |
featStoreOut2 = buildOutPutStoreFromUnion(featureType1, |
|
162 |
featureType2, |
|
163 |
IVectorLayer.SHAPE_TYPE_POLYGON, |
|
164 |
getTranslation("Union_l2"), |
|
165 |
RESULT2); |
|
153 | 166 |
computesDifference(storeLayer1, storeLayer2, featStoreOut2, selectedGeom, false); |
154 | 167 |
computesDifference(storeLayer2, storeLayer1, featStoreOut2, selectedGeom, true); |
155 | 168 |
} else |
... | ... | |
174 | 187 |
computesUnion(storeLayer1, storeLayer2, featStoreOut2, selectedGeom); |
175 | 188 |
} |
176 | 189 |
|
190 |
if(featStoreOut2 == null) { |
|
191 |
featStoreOut2 = buildOutPutStoreFromUnion(featureType1, featureType2, IVectorLayer.SHAPE_TYPE_WRONG, |
|
192 |
getTranslation("Null_Layer"), RESULT2); |
|
193 |
} |
|
194 |
|
|
177 | 195 |
} catch (ReadException e) { |
178 | 196 |
throw new GeoAlgorithmExecutionException(e.getMessage()); |
179 | 197 |
} catch (DataException e) { |
Also available in: Unified diff