Revision 251
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/ConvexHullAlgorithm.java | ||
---|---|---|
26 | 26 |
import java.util.Iterator; |
27 | 27 |
import java.util.List; |
28 | 28 |
|
29 |
import es.unex.sextante.core.Sextante; |
|
30 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
31 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
32 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
33 |
import es.unex.sextante.outputs.OutputVectorLayer; |
|
34 |
|
|
29 |
import org.gvsig.fmap.dal.DALLocator; |
|
30 |
import org.gvsig.fmap.dal.DataManager; |
|
35 | 31 |
import org.gvsig.fmap.dal.exception.DataException; |
36 | 32 |
import org.gvsig.fmap.dal.feature.Feature; |
33 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
37 | 34 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
38 | 35 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
39 | 36 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
40 | 37 |
import org.gvsig.fmap.geom.Geometry; |
38 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
41 | 39 |
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil; |
42 | 40 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
43 | 41 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer; |
44 | 42 |
import org.gvsig.tools.dispose.DisposableIterator; |
43 |
import org.slf4j.Logger; |
|
44 |
import org.slf4j.LoggerFactory; |
|
45 | 45 |
|
46 |
import es.unex.sextante.core.Sextante; |
|
47 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
48 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
49 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
50 |
import es.unex.sextante.outputs.OutputVectorLayer; |
|
51 |
|
|
46 | 52 |
/** |
47 | 53 |
* Convex Hull Algorithm |
48 | 54 |
* |
49 | 55 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
50 | 56 |
*/ |
51 | 57 |
public class ConvexHullAlgorithm extends AbstractSextanteGeoProcess { |
52 |
|
|
58 |
private static final Logger log = LoggerFactory.getLogger(ConvexHullAlgorithm.class); |
|
53 | 59 |
public static final String LAYER = "LAYER"; |
54 | 60 |
public static final String RESULT = "RESULT"; |
55 | 61 |
public static final String CHECK = "CHECK"; |
... | ... | |
93 | 99 |
|
94 | 100 |
FeatureSet features = null; |
95 | 101 |
try { |
96 |
features = store.getFeatureSet(); |
|
97 |
|
|
98 | 102 |
DisposableIterator it = null; |
99 | 103 |
if (selectedGeom) { |
104 |
features = store.getFeatureSet(); |
|
100 | 105 |
FeatureSelection ds = store.getFeatureSelection(); |
101 | 106 |
it = ds.iterator(); |
102 |
// if(!it.hasNext())Mensaje de no hay geometrias seleccionadas |
|
103 |
} else |
|
107 |
} else { |
|
108 |
FeatureQuery query = getQueryFromAnalysisExtent(m_AnalysisExtent, store); |
|
109 |
features = store.getFeatureSet(query); |
|
104 | 110 |
it = features.iterator(); |
111 |
} |
|
105 | 112 |
|
106 | 113 |
int numberOfFeatures = (int) features.getSize(); |
107 | 114 |
int iCount = 0; |
... | ... | |
138 | 145 |
output.addFeature(jtsGeom, new Object[] { new Integer(0) }); |
139 | 146 |
it.dispose(); |
140 | 147 |
} catch (DataException e) { |
141 |
Sextante.addErrorToLog(e); |
|
142 |
} |
|
148 |
log.error("", e); |
|
149 |
} catch (CreateEnvelopeException e) { |
|
150 |
log.error("Error creating envelope", e); |
|
151 |
} |
|
143 | 152 |
return !m_Task.isCanceled(); |
144 | 153 |
} |
145 | 154 |
} |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.lib/org.gvsig.geoprocess.lib.sextante/src/main/java/org/gvsig/geoprocess/lib/sextante/AbstractSextanteGeoProcess.java | ||
---|---|---|
26 | 26 |
import java.util.HashMap; |
27 | 27 |
import java.util.Iterator; |
28 | 28 |
|
29 |
import es.unex.sextante.core.GeoAlgorithm; |
|
30 |
import es.unex.sextante.core.ITaskMonitor; |
|
31 |
import es.unex.sextante.core.OutputFactory; |
|
32 |
import es.unex.sextante.core.Sextante; |
|
33 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
34 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
35 |
import es.unex.sextante.exceptions.UnsupportedOutputChannelException; |
|
36 |
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel; |
|
37 |
|
|
38 | 29 |
import org.gvsig.fmap.dal.exception.DataException; |
39 | 30 |
import org.gvsig.fmap.dal.exception.ReadException; |
40 | 31 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
32 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
41 | 33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
42 | 34 |
import org.gvsig.fmap.dal.feature.FeatureType; |
43 | 35 |
import org.gvsig.fmap.geom.Geometry; |
36 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
37 |
import org.gvsig.fmap.geom.GeometryManager; |
|
38 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
39 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
40 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
41 |
import org.gvsig.fmap.mapcontext.layers.vectorial.IntersectsEnvelopeEvaluator; |
|
44 | 42 |
import org.gvsig.geoprocess.lib.api.GeoProcess; |
45 | 43 |
import org.gvsig.geoprocess.lib.api.GeoProcessLocator; |
46 | 44 |
import org.gvsig.geoprocess.lib.api.GeoProcessManager; |
47 | 45 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer; |
48 | 46 |
|
47 |
import es.unex.sextante.core.AnalysisExtent; |
|
48 |
import es.unex.sextante.core.GeoAlgorithm; |
|
49 |
import es.unex.sextante.core.ITaskMonitor; |
|
50 |
import es.unex.sextante.core.OutputFactory; |
|
51 |
import es.unex.sextante.core.Sextante; |
|
52 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
53 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
54 |
import es.unex.sextante.exceptions.UnsupportedOutputChannelException; |
|
55 |
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel; |
|
56 |
|
|
49 | 57 |
/** |
50 | 58 |
* Base implementation for Sextante based {@link GeoProcess} objects. |
51 | 59 |
* |
52 | 60 |
* @author gvSIG Team |
53 | 61 |
* @version $Id$ |
54 | 62 |
*/ |
55 |
public abstract class AbstractSextanteGeoProcess extends GeoAlgorithm implements |
|
56 |
GeoProcess { |
|
63 |
public abstract class AbstractSextanteGeoProcess extends GeoAlgorithm implements GeoProcess { |
|
64 |
protected String[] attrNames = null; |
|
65 |
private SimpleTaskStatusDelegated status = null; |
|
66 |
protected GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
57 | 67 |
|
58 |
protected String[] attrNames = null; |
|
59 |
private SimpleTaskStatusDelegated status; |
|
60 |
|
|
61 | 68 |
@Override |
62 | 69 |
public boolean execute(ITaskMonitor task, OutputFactory outputFactory, |
63 | 70 |
HashMap<String, String> outputMap) |
... | ... | |
323 | 330 |
public Class<? extends GeoAlgorithmParametersPanel> getCustomParametersPanelClass() { |
324 | 331 |
return null; |
325 | 332 |
} |
333 |
|
|
334 |
/** |
|
335 |
* Gets a feature query using the analysis bounding box |
|
336 |
* @param e |
|
337 |
* @param store |
|
338 |
* @return |
|
339 |
* @throws CreateEnvelopeException |
|
340 |
* @throws DataException |
|
341 |
*/ |
|
342 |
public FeatureQuery getQueryFromAnalysisExtent(AnalysisExtent e, FeatureStore store) throws CreateEnvelopeException, DataException { |
|
343 |
Envelope analysisEnvelope = geomManager.createEnvelope(e.getXMin(), e.getYMin(), e.getXMax(), e.getYMax(), SUBTYPES.GEOM2D); |
|
344 |
String geomName = store.getDefaultFeatureType().getDefaultGeometryAttributeName(); |
|
345 |
FeatureQuery query = store.createFeatureQuery(); |
|
346 |
IntersectsEnvelopeEvaluator filter = new IntersectsEnvelopeEvaluator( |
|
347 |
analysisEnvelope, |
|
348 |
store.getDefaultFeatureType().getDefaultSRS(), |
|
349 |
store.getDefaultFeatureType(), |
|
350 |
geomName); |
|
351 |
query.setFilter(filter); |
|
352 |
return query; |
|
353 |
} |
|
354 |
|
|
326 | 355 |
} |
Also available in: Unified diff