Revision 2023
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.geoprocess.algorithm.clip.ClipLibrary |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/resources/org/gvsig/geoprocess/algorithm/clip/clip.properties | ||
---|---|---|
1 |
# |
|
2 |
# gvSIG. Desktop Geographic Information System. |
|
3 |
# |
|
4 |
# Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
# |
|
6 |
# This program is free software; you can redistribute it and/or |
|
7 |
# modify it under the terms of the GNU General Public License |
|
8 |
# as published by the Free Software Foundation; either version 2 |
|
9 |
# of the License, or (at your option) any later version. |
|
10 |
# |
|
11 |
# This program is distributed in the hope that it will be useful, |
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
# GNU General Public License for more details. |
|
15 |
# |
|
16 |
# You should have received a copy of the GNU General Public License |
|
17 |
# along with this program; if not, write to the Free Software |
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
# MA 02110-1301, USA. |
|
20 |
# |
|
21 |
# For any additional information, do not hesitate to contact us |
|
22 |
# at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
# |
|
24 |
|
|
25 |
basic_vect_algorithms=Capas vectoriales |
|
26 |
Clip_layer=Capa de recorte |
|
27 |
Clip=Recorte |
|
28 |
Input_layer=Capa de entrada |
|
29 |
Clip_layer=Capa de recorte |
|
30 |
Selected_geometries=Geometr?as seleccionadas |
|
31 |
Selected_geometries_input_layer_clip=Geom. seleccionadas (Capa entrada) |
|
32 |
Selected_geometries_overlay_layer_clip=Geom. seleccionadas (Capa recorte) |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/resources/org/gvsig/geoprocess/algorithm/clip/clip_en.properties | ||
---|---|---|
1 |
# |
|
2 |
# gvSIG. Desktop Geographic Information System. |
|
3 |
# |
|
4 |
# Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
# |
|
6 |
# This program is free software; you can redistribute it and/or |
|
7 |
# modify it under the terms of the GNU General Public License |
|
8 |
# as published by the Free Software Foundation; either version 2 |
|
9 |
# of the License, or (at your option) any later version. |
|
10 |
# |
|
11 |
# This program is distributed in the hope that it will be useful, |
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
# GNU General Public License for more details. |
|
15 |
# |
|
16 |
# You should have received a copy of the GNU General Public License |
|
17 |
# along with this program; if not, write to the Free Software |
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
# MA 02110-1301, USA. |
|
20 |
# |
|
21 |
# For any additional information, do not hesitate to contact us |
|
22 |
# at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
# |
|
24 |
|
|
25 |
basic_vect_algorithms=Vector layers tools |
|
26 |
Clip_layer=Clip cover |
|
27 |
Clip=Clip |
|
28 |
Input_layer=Input cover |
|
29 |
Selected_geometries=Selected features |
|
30 |
Selected_geometries_input_layer_clip=Selected features (Input cover) |
|
31 |
Selected_geometries_overlay_layer_clip=Selected features (Clip cover) |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/resources/help/ClipAlgorithm.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<help> |
|
28 |
<element name="DESCRIPTION" text="Este geoproceso permite limitar el ámbito de trabajo de una capa vectorial (da igual que sea de puntos, líneas o polígonos), extrayendo de ésta una zona de interés. Para ello, el usuario deberá proporcionar una capa de entrada (la capa de la que se quiere extraer un zona) y una capa de recorte, de forma que la unión de las geometrías incluidas en la capa de recorte definirán el ámbito de trabajo. El geoproceso recorrerá todos los elementos vectoriales de la capa de entrada (features), y para aquellos que estén contenidos en el ámbito de trabajo definido por la capa de recorte, calculará sus intersecciones, de forma que en la capa resultado solo estarán los elementos vectoriales de nuestro ámbito de interés. La porción de geometría que quede fuera del ámbito de trabajo será recortada. El esquema alfanumérico de la capa de entrada se mantiene intacto." description="Descripción" type="0"> |
|
29 |
<image description="" file="clipdesc.png"> |
|
30 |
</image> |
|
31 |
</element> |
|
32 |
<element name="ADDITIONAL_INFO" text="" description="Información adicional" type="0"> |
|
33 |
<image description="" file="clip.gif"> |
|
34 |
</image> |
|
35 |
</element> |
|
36 |
<element name="EXTENSION_AUTHOR" text="Nacho Brodin" description="Algoritmo creado por" type="0"> |
|
37 |
</element> |
|
38 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0"> |
|
39 |
</element> |
|
40 |
<element name="USER_NOTES" text="" description="Notas de usuario" type="0"> |
|
41 |
</element> |
|
42 |
<element name="LAYER" text="" description="Capa de entrada" type="3"> |
|
43 |
</element> |
|
44 |
<element name="CLIP" text="" description="Capa de recorte" type="3"> |
|
45 |
</element> |
|
46 |
<element name="CHECK" text="" description="Geometrias seleccionadas" type="3"> |
|
47 |
</element> |
|
48 |
<element name="OUTPUT_DESCRIPTION" text="" description="Descripción" type="2"> |
|
49 |
</element> |
|
50 |
<element name="RESULT" text="" description="Recorte" type="2"> |
|
51 |
</element> |
|
52 |
</help> |
|
53 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/resources/help/ClipAlgorithm_en.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<help> |
|
28 |
<element name="DESCRIPTION" text="This geoprocess clips the geometries of the input layer with the envelope of a clipping layer. After that, result layer will be formed by features whose geometries are within bounding box of clipping layer. Result layer will have the same alphanumeric schema of the input layer. This could be useful to limit the working layer set to a geographical region of interest (for example, making a local gis with layers from a statal dataset)." description="Descripción" type="0"> |
|
29 |
<image description="" file="clipdesc.png"> |
|
30 |
</image> |
|
31 |
</element> |
|
32 |
<element name="ADDITIONAL_INFO" text="" description="Información adicional" type="0"> |
|
33 |
<image description="" file="clip.gif"> |
|
34 |
</image> |
|
35 |
</element> |
|
36 |
<element name="EXTENSION_AUTHOR" text="Nacho Brodin" description="Algoritmo creado por" type="0"> |
|
37 |
</element> |
|
38 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0"> |
|
39 |
</element> |
|
40 |
<element name="USER_NOTES" text="" description="Notas de usuario" type="0"> |
|
41 |
</element> |
|
42 |
<element name="LAYER" text="" description="Capa de entrada" type="3"> |
|
43 |
</element> |
|
44 |
<element name="CLIP" text="" description="Capa de recorte" type="3"> |
|
45 |
</element> |
|
46 |
<element name="CHECK" text="" description="Geometrias seleccionadas" type="3"> |
|
47 |
</element> |
|
48 |
<element name="OUTPUT_DESCRIPTION" text="" description="Descripción" type="2"> |
|
49 |
</element> |
|
50 |
<element name="RESULT" text="" description="Recorte" type="2"> |
|
51 |
</element> |
|
52 |
</help> |
|
53 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/java/org/gvsig/geoprocess/algorithm/clip/ClipLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.geoprocess.algorithm.clip; |
|
25 |
|
|
26 |
import org.gvsig.geoprocess.algorithm.base.core.AlgorithmAbstractLibrary; |
|
27 |
import org.gvsig.i18n.Messages; |
|
28 |
import org.gvsig.tools.library.LibraryException; |
|
29 |
|
|
30 |
/** |
|
31 |
* Initialization of ClipLibrary library. |
|
32 |
* |
|
33 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
34 |
*/ |
|
35 |
public class ClipLibrary extends AlgorithmAbstractLibrary { |
|
36 |
|
|
37 |
@Override |
|
38 |
protected void doInitialize() throws LibraryException { |
|
39 |
// Nothing to do |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
protected void doPostInitialize() throws LibraryException { |
|
44 |
Messages.addResourceFamily("org.gvsig.geoprocess.algorithm.clip.clip", |
|
45 |
ClipLibrary.class.getClassLoader(), ClipLibrary.class.getClass() |
|
46 |
.getName()); |
|
47 |
registerGeoProcess(new ClipAlgorithm()); |
|
48 |
} |
|
49 |
|
|
50 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/java/org/gvsig/geoprocess/algorithm/clip/ClipAlgorithm.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.geoprocess.algorithm.clip; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.exception.DataException; |
|
27 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
28 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
29 |
import org.gvsig.geoprocess.algorithm.base.core.ScalableUnionOperation; |
|
30 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
31 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer; |
|
32 |
|
|
33 |
import es.unex.sextante.core.Sextante; |
|
34 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
35 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
36 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
37 |
import es.unex.sextante.outputs.OutputVectorLayer; |
|
38 |
|
|
39 |
/** |
|
40 |
* Clip algorithm |
|
41 |
* |
|
42 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
43 |
*/ |
|
44 |
public class ClipAlgorithm extends AbstractSextanteGeoProcess { |
|
45 |
|
|
46 |
public static final String RESULT_POL = "RESULT_POL"; |
|
47 |
public static final String RESULT_LIN = "RESULT_LIN"; |
|
48 |
public static final String RESULT_POINT = "RESULT_POINT"; |
|
49 |
public static final String LAYER = "LAYER"; |
|
50 |
public static final String CLIP = "CLIP"; |
|
51 |
public static final String SELECTGEOM_INPUT = "SELECTGEOM_INPUT"; |
|
52 |
public static final String SELECTGEOM_OVERLAY = "SELECTGEOM_OVERLAY"; |
|
53 |
|
|
54 |
/* |
|
55 |
* (non-Javadoc) |
|
56 |
* @see es.unex.sextante.core.GeoAlgorithm#defineCharacteristics() |
|
57 |
*/ |
|
58 |
public void defineCharacteristics() { |
|
59 |
setName(getTranslation("Clip")); |
|
60 |
setGroup(getTranslation("basic_vect_algorithms")); |
|
61 |
// setGeneratesUserDefinedRasterOutput(false); |
|
62 |
|
|
63 |
try { |
|
64 |
m_Parameters.addInputVectorLayer(LAYER, |
|
65 |
getTranslation("Input_layer"), |
|
66 |
IVectorLayer.SHAPE_TYPE_WRONG, |
|
67 |
true); |
|
68 |
m_Parameters.addInputVectorLayer(CLIP, |
|
69 |
getTranslation("Clip_layer"), |
|
70 |
IVectorLayer.SHAPE_TYPE_POLYGON, |
|
71 |
true); |
|
72 |
m_Parameters.addBoolean(SELECTGEOM_INPUT, |
|
73 |
getTranslation("Selected_geometries_input_layer_clip"), false); |
|
74 |
m_Parameters.addBoolean(SELECTGEOM_OVERLAY, |
|
75 |
getTranslation("Selected_geometries_overlay_layer_clip"), false); |
|
76 |
} catch (RepeatedParameterNameException e) { |
|
77 |
Sextante.addErrorToLog(e); |
|
78 |
} |
|
79 |
//addOutputVectorLayer(RESULT, getTranslation("Clip"), |
|
80 |
// OutputVectorLayer.SHAPE_TYPE_UNDEFINED); |
|
81 |
|
|
82 |
addOutputVectorLayer(RESULT_POL, getTranslation("Clip_polygon"), |
|
83 |
OutputVectorLayer.SHAPE_TYPE_POLYGON); |
|
84 |
addOutputVectorLayer(RESULT_LIN, getTranslation("Clip_line"), |
|
85 |
OutputVectorLayer.SHAPE_TYPE_LINE); |
|
86 |
addOutputVectorLayer(RESULT_POINT, getTranslation("Clip_point"), |
|
87 |
OutputVectorLayer.SHAPE_TYPE_POINT); |
|
88 |
} |
|
89 |
|
|
90 |
/* |
|
91 |
* (non-Javadoc) |
|
92 |
* @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm() |
|
93 |
*/ |
|
94 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
|
95 |
if (existsOutPutFile(ClipAlgorithm.RESULT_POL, 0) |
|
96 |
|| existsOutPutFile(ClipAlgorithm.RESULT_LIN, 0) |
|
97 |
|| existsOutPutFile(ClipAlgorithm.RESULT_POINT, 0)) { |
|
98 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
99 |
} |
|
100 |
org.gvsig.fmap.geom.Geometry clippingGeometry = null; |
|
101 |
IVectorLayer clip = m_Parameters.getParameterValueAsVectorLayer(CLIP); |
|
102 |
IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER); |
|
103 |
boolean selectedGeomInput = m_Parameters.getParameter(SELECTGEOM_INPUT).getParameterValueAsBoolean(); |
|
104 |
boolean selectedGeomOverlay = m_Parameters.getParameter(SELECTGEOM_OVERLAY).getParameterValueAsBoolean(); |
|
105 |
|
|
106 |
try { |
|
107 |
clippingGeometry = ScalableUnionOperation.joinLayerGeometries(clip, selectedGeomOverlay); |
|
108 |
} catch (Exception e) { |
|
109 |
Sextante.addErrorToLog(e); |
|
110 |
return false; |
|
111 |
} |
|
112 |
|
|
113 |
FeatureStore storeLayer = null; |
|
114 |
if (layer instanceof FlyrVectIVectorLayer && clippingGeometry != null) { |
|
115 |
storeLayer = ((FlyrVectIVectorLayer) layer).getFeatureStore(); |
|
116 |
} else { |
|
117 |
return false; |
|
118 |
} |
|
119 |
|
|
120 |
try { |
|
121 |
FeatureType featureType = storeLayer.getDefaultFeatureType(); |
|
122 |
|
|
123 |
if (isPolygon(storeLayer) || isUndefined(storeLayer)) { |
|
124 |
FeatureStore outFeatStore |
|
125 |
= buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_MULTIPOLYGON, |
|
126 |
getTranslation("Clip_polygon"), RESULT_POL); |
|
127 |
|
|
128 |
ClipOperation operation = new ClipOperation(clippingGeometry, this); |
|
129 |
operation.setTaskStatus(getStatus()); |
|
130 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, |
|
131 |
selectedGeomInput, false, true); |
|
132 |
} else { |
|
133 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_MULTIPOLYGON, |
|
134 |
getTranslation("Null_polygon"), RESULT_POL); |
|
135 |
} |
|
136 |
|
|
137 |
if (isLine(storeLayer) || isUndefined(storeLayer)) { |
|
138 |
FeatureStore outFeatStore |
|
139 |
= buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_MULTILINE, |
|
140 |
getTranslation("Clip_line"), RESULT_LIN); |
|
141 |
|
|
142 |
ClipOperation operation = new ClipOperation(clippingGeometry, this); |
|
143 |
operation.setTaskStatus(getStatus()); |
|
144 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, |
|
145 |
selectedGeomInput, false, true); |
|
146 |
} else { |
|
147 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_MULTILINE, |
|
148 |
getTranslation("Null_line"), RESULT_LIN); |
|
149 |
} |
|
150 |
|
|
151 |
if (isPoint(storeLayer) || isUndefined(storeLayer)) { |
|
152 |
FeatureStore outFeatStore |
|
153 |
= buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POINT, |
|
154 |
getTranslation("Clip_point"), RESULT_POINT); |
|
155 |
|
|
156 |
ClipOperation operation = new ClipOperation(clippingGeometry, this); |
|
157 |
operation.setTaskStatus(getStatus()); |
|
158 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, |
|
159 |
selectedGeomInput, false, true); |
|
160 |
} else { |
|
161 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POINT, |
|
162 |
getTranslation("Null_point"), RESULT_POINT); |
|
163 |
} |
|
164 |
} catch (DataException e) { |
|
165 |
Sextante.addErrorToLog(e); |
|
166 |
return false; |
|
167 |
} |
|
168 |
|
|
169 |
return true; |
|
170 |
} |
|
171 |
|
|
172 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/java/org/gvsig/geoprocess/algorithm/clip/ClipOperation.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* |
|
25 |
|
|
26 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
27 |
* |
|
28 |
* Copyright (C) 2010 Generalitat Valenciana. |
|
29 |
* |
|
30 |
* This program is free software; you can redistribute it and/or |
|
31 |
* modify it under the terms of the GNU General Public License |
|
32 |
* as published by the Free Software Foundation; either version 2 |
|
33 |
* of the License, or (at your option) any later version. |
|
34 |
* |
|
35 |
* This program is distributed in the hope that it will be useful, |
|
36 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
37 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
38 |
* GNU General Public License for more details. |
|
39 |
* |
|
40 |
* You should have received a copy of the GNU General Public License |
|
41 |
* along with this program; if not, write to the Free Software |
|
42 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
43 |
*/ |
|
44 |
|
|
45 |
package org.gvsig.geoprocess.algorithm.clip; |
|
46 |
|
|
47 |
import org.gvsig.fmap.dal.exception.DataException; |
|
48 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
49 |
import org.gvsig.fmap.dal.feature.Feature; |
|
50 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
51 |
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation; |
|
52 |
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil; |
|
53 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
54 |
|
|
55 |
import com.vividsolutions.jts.geom.Geometry; |
|
56 |
|
|
57 |
import es.unex.sextante.core.Sextante; |
|
58 |
/** |
|
59 |
* This class analyzes all features of a layer, clipping its geometries |
|
60 |
* with the convex hull of another layer. |
|
61 |
* If the geometry of the feature analyzed doesnt intersect with the convex |
|
62 |
* hull geometry, the clipvisitor will ignore it. |
|
63 |
* |
|
64 |
* It intersects, computes intersection and creates a new feature with |
|
65 |
* the same attributes and the new intersection geometry. |
|
66 |
* |
|
67 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
68 |
*/ |
|
69 |
public class ClipOperation extends GeometryOperation { |
|
70 |
|
|
71 |
/** |
|
72 |
* Clipping geometry: the convex hull of the |
|
73 |
* clipping layer |
|
74 |
*/ |
|
75 |
private Geometry clippingConvexHull = null; |
|
76 |
|
|
77 |
public ClipOperation(org.gvsig.fmap.geom.Geometry clip, AbstractSextanteGeoProcess p) { |
|
78 |
super(p); |
|
79 |
this.clippingConvexHull = GeometryUtil.geomToJTS(clip); |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* clips feature's geometry with the clipping geometry, preserving |
|
84 |
* feature's original attributes. |
|
85 |
* If feature's geometry doesnt touch clipping geometry, it will be |
|
86 |
* ignored. |
|
87 |
*/ |
|
88 |
public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature feature) { |
|
89 |
if(g == null) |
|
90 |
return lastEditFeature; |
|
91 |
|
|
92 |
Geometry jtsGeom = GeometryUtil.geomToJTS(g); |
|
93 |
|
|
94 |
if(!jtsGeom.getEnvelope().intersects(clippingConvexHull.getEnvelope())) |
|
95 |
return lastEditFeature; |
|
96 |
|
|
97 |
if(jtsGeom.intersects(clippingConvexHull)) { |
|
98 |
try { |
|
99 |
Geometry newGeom = jtsGeom.intersection(clippingConvexHull); |
|
100 |
lastEditFeature = persister.addFeature(feature, newGeom); |
|
101 |
} catch(com.vividsolutions.jts.geom.TopologyException e){ |
|
102 |
Sextante.addErrorToLog(e); |
|
103 |
if(! jtsGeom.isValid()) { |
|
104 |
System.out.println("La geometria de entrada no es valida"); |
|
105 |
jtsGeom = GeometryUtil.removeDuplicatesFrom(jtsGeom); |
|
106 |
} |
|
107 |
if(! clippingConvexHull.isValid()) { |
|
108 |
System.out.println("La geometria de recorte no es valida"); |
|
109 |
clippingConvexHull = GeometryUtil.removeDuplicatesFrom(clippingConvexHull); |
|
110 |
} |
|
111 |
try { |
|
112 |
Geometry newGeom = jtsGeom.intersection(clippingConvexHull); |
|
113 |
lastEditFeature = persister.addFeature(feature, newGeom); |
|
114 |
} catch(com.vividsolutions.jts.geom.TopologyException ee){ |
|
115 |
Sextante.addErrorToLog(ee); |
|
116 |
} catch (CreateGeometryException ee) { |
|
117 |
Sextante.addErrorToLog(ee); |
|
118 |
} catch (DataException ee) { |
|
119 |
Sextante.addErrorToLog(ee); |
|
120 |
} |
|
121 |
} catch (CreateGeometryException e) { |
|
122 |
Sextante.addErrorToLog(e); |
|
123 |
} catch (DataException e) { |
|
124 |
Sextante.addErrorToLog(e); |
|
125 |
} |
|
126 |
} |
|
127 |
return lastEditFeature; |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* clips feature's geometry with the clipping geometry, preserving |
|
132 |
* feature's original attributes. |
|
133 |
* If feature's geometry doesnt touch clipping geometry, it will be |
|
134 |
* ignored. |
|
135 |
*/ |
|
136 |
public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature feature) { |
|
137 |
if(g == null) |
|
138 |
return; |
|
139 |
|
|
140 |
lastEditFeature = feature; |
|
141 |
|
|
142 |
Geometry jtsGeom = GeometryUtil.geomToJTS(g); |
|
143 |
|
|
144 |
if(!jtsGeom.getEnvelope().intersects(clippingConvexHull.getEnvelope())) |
|
145 |
return; |
|
146 |
|
|
147 |
if(jtsGeom.intersects(clippingConvexHull)) { |
|
148 |
try { |
|
149 |
Geometry newGeom = jtsGeom.intersection(clippingConvexHull); |
|
150 |
persister.addFeature(feature, newGeom); |
|
151 |
} catch(com.vividsolutions.jts.geom.TopologyException e){ |
|
152 |
Sextante.addErrorToLog(e); |
|
153 |
if(! jtsGeom.isValid()) { |
|
154 |
System.out.println("La geometria de entrada no es valida"); |
|
155 |
jtsGeom = GeometryUtil.removeDuplicatesFrom(jtsGeom); |
|
156 |
} |
|
157 |
if(! clippingConvexHull.isValid()) { |
|
158 |
System.out.println("La geometria de recorte no es valida"); |
|
159 |
clippingConvexHull = GeometryUtil.removeDuplicatesFrom(clippingConvexHull); |
|
160 |
} |
|
161 |
try { |
|
162 |
Geometry newGeom = jtsGeom.intersection(clippingConvexHull); |
|
163 |
persister.addFeature(feature, newGeom); |
|
164 |
} catch(com.vividsolutions.jts.geom.TopologyException ee){ |
|
165 |
Sextante.addErrorToLog(ee); |
|
166 |
} catch (CreateGeometryException ee) { |
|
167 |
Sextante.addErrorToLog(ee); |
|
168 |
} catch (DataException ee) { |
|
169 |
Sextante.addErrorToLog(ee); |
|
170 |
} |
|
171 |
} catch (CreateGeometryException e) { |
|
172 |
Sextante.addErrorToLog(e); |
|
173 |
} catch (DataException e) { |
|
174 |
Sextante.addErrorToLog(e); |
|
175 |
} |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Ends the edition and closes the FeatureStore |
|
181 |
*/ |
|
182 |
public void end() { |
|
183 |
persister.end(); |
|
184 |
} |
|
185 |
|
|
186 |
public String getProcessDescription() { |
|
187 |
return "Clipping features agaisnt a clip geometry"; |
|
188 |
} |
|
189 |
} |
|
190 |
|
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.geoprocess.algorithm.clip</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>org.gvsig.geoprocess.algorithm.clip</name> |
|
7 |
|
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.geoprocess.algorithm</artifactId> |
|
11 |
<version>2.2.272</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<dependencies> |
|
15 |
<dependency> |
|
16 |
<groupId>org.gvsig</groupId> |
|
17 |
<artifactId>org.gvsig.geoprocess.algorithm.base</artifactId> |
|
18 |
<scope>compile</scope> |
|
19 |
</dependency> |
|
20 |
</dependencies> |
|
21 |
|
|
22 |
</project> |
|
0 | 23 |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.geoprocess.algorithm.convexhull</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>org.gvsig.geoprocess.algorithm.convexhull</name> |
|
7 |
|
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.geoprocess.algorithm</artifactId> |
|
11 |
<version>2.2.272</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<dependencies> |
|
15 |
<dependency> |
|
16 |
<groupId>org.gvsig</groupId> |
|
17 |
<artifactId>org.gvsig.geoprocess.algorithm.base</artifactId> |
|
18 |
<scope>compile</scope> |
|
19 |
</dependency> |
|
20 |
<dependency> |
|
21 |
<groupId>org.gvsig</groupId> |
|
22 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
23 |
<scope>compile</scope> |
|
24 |
</dependency> |
|
25 |
<dependency> |
|
26 |
<groupId>org.gvsig</groupId> |
|
27 |
<artifactId>org.gvsig.fmap.mapcontext.impl</artifactId> |
|
28 |
<scope>runtime</scope> |
|
29 |
</dependency> |
|
30 |
</dependencies> |
|
31 |
|
|
32 |
</project> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/resources/org/gvsig/geoprocess/algorithm/convexhull/convexhull.properties | ||
---|---|---|
1 |
# |
|
2 |
# gvSIG. Desktop Geographic Information System. |
|
3 |
# |
|
4 |
# Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
# |
|
6 |
# This program is free software; you can redistribute it and/or |
|
7 |
# modify it under the terms of the GNU General Public License |
|
8 |
# as published by the Free Software Foundation; either version 2 |
|
9 |
# of the License, or (at your option) any later version. |
|
10 |
# |
|
11 |
# This program is distributed in the hope that it will be useful, |
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
# GNU General Public License for more details. |
|
15 |
# |
|
16 |
# You should have received a copy of the GNU General Public License |
|
17 |
# along with this program; if not, write to the Free Software |
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
# MA 02110-1301, USA. |
|
20 |
# |
|
21 |
# For any additional information, do not hesitate to contact us |
|
22 |
# at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
# |
|
24 |
|
|
25 |
basic_vect_algorithms=Capas vectoriales |
|
26 |
Input_layer=Capa de entrada |
|
27 |
ConvexHull=Envolvente convexa |
|
28 |
Selected_geometries_convex_hull=Geom. seleccionadas (Capa entrada) |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/resources/org/gvsig/geoprocess/algorithm/convexhull/convexhull_en.properties | ||
---|---|---|
1 |
# |
|
2 |
# gvSIG. Desktop Geographic Information System. |
|
3 |
# |
|
4 |
# Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
# |
|
6 |
# This program is free software; you can redistribute it and/or |
|
7 |
# modify it under the terms of the GNU General Public License |
|
8 |
# as published by the Free Software Foundation; either version 2 |
|
9 |
# of the License, or (at your option) any later version. |
|
10 |
# |
|
11 |
# This program is distributed in the hope that it will be useful, |
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
# GNU General Public License for more details. |
|
15 |
# |
|
16 |
# You should have received a copy of the GNU General Public License |
|
17 |
# along with this program; if not, write to the Free Software |
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
# MA 02110-1301, USA. |
|
20 |
# |
|
21 |
# For any additional information, do not hesitate to contact us |
|
22 |
# at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
# |
|
24 |
|
|
25 |
basic_vect_algorithms=Vector layers tools |
|
26 |
Input_layer=Input cover |
|
27 |
ConvexHull=Convex Hull |
|
28 |
Selected_geometries_convex_hull=Selected features (Input cover) |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/resources/help/ConvexHullAlgorithm.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<help> |
|
28 |
<element name="DESCRIPTION" text="Este geoproceso cálcula la envolvente convexa (convex hull), o polígono convexo de menor área que envuelve a todos los elementos vectoriales de una capa de entrada. Opera únicamente con una capa de entrada, cuyo tipo de geometría podrá ser de cualquier tipo. Las aplicaciones de este geoproceso pueden ser de distinto tipo: <UL> <LI>Determinar la zona de cobertura de un determinado fenómeno geográfico.</LI> <LI>Cálculo del diametro de la zona cubierta por una serie de geometrías,</LI> </UL> etc." description="Descripción" type="0"> |
|
29 |
<image description="" file="convexhulldesc.png"> |
|
30 |
</image> |
|
31 |
</element> |
|
32 |
<element name="ADDITIONAL_INFO" text="" description="Información adicional" type="0"> |
|
33 |
</element> |
|
34 |
<element name="EXTENSION_AUTHOR" text="Nacho Brodin" description="Algoritmo creado por" type="0"> |
|
35 |
</element> |
|
36 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0"> |
|
37 |
</element> |
|
38 |
<element name="USER_NOTES" text="" description="Notas de usuario" type="0"> |
|
39 |
</element> |
|
40 |
<element name="LAYER" text="" description="Capa de entrada" type="3"> |
|
41 |
</element> |
|
42 |
<element name="CHECK" text="" description="Geometrias seleccionadas" type="3"> |
|
43 |
</element> |
|
44 |
<element name="OUTPUT_DESCRIPTION" text="" description="Descripción" type="2"> |
|
45 |
</element> |
|
46 |
<element name="RESULT" text="" description="Convex Hull" type="2"> |
|
47 |
</element> |
|
48 |
</help> |
|
49 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/resources/help/ConvexHullAlgorithm_en.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<help> |
|
28 |
<element name="DESCRIPTION" text="This geoprocess creates a new polygon layer, with polygon buffers of the geometries of the input layer. Input layer geometries could have any geometry type (point, line or polygon). For each input geometry, you could create one or many equidistant polygon buffer rings. Also, if input geometry type is polygon, the buffer could be internal, external or both. It could be useful for: <UL> <LI>See the area of interest of a given geographical sucess..</LI> <LI>Computing the diameter of a set of geometries</LI> </UL> etc." description="Descripción" type="0"> |
|
29 |
<image description="" file="convexhulldesc.png"> |
|
30 |
</image> |
|
31 |
</element> |
|
32 |
<element name="ADDITIONAL_INFO" text="" description="Información adicional" type="0"> |
|
33 |
</element> |
|
34 |
<element name="EXTENSION_AUTHOR" text="Nacho Brodin" description="Algoritmo creado por" type="0"> |
|
35 |
</element> |
|
36 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0"> |
|
37 |
</element> |
|
38 |
<element name="USER_NOTES" text="" description="Notas de usuario" type="0"> |
|
39 |
</element> |
|
40 |
<element name="LAYER" text="" description="Capa de entrada" type="3"> |
|
41 |
</element> |
|
42 |
<element name="CHECK" text="" description="Geometrias seleccionadas" type="3"> |
|
43 |
</element> |
|
44 |
<element name="OUTPUT_DESCRIPTION" text="" description="Descripción" type="2"> |
|
45 |
</element> |
|
46 |
<element name="RESULT" text="" description="Convex Hull" type="2"> |
|
47 |
</element> |
|
48 |
</help> |
|
49 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.geoprocess.algorithm.convexhull.ConvexHullLibrary |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/ConvexHullOperation.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* CVS MESSAGES: |
|
25 |
* |
|
26 |
* $Id: ScalableConvexHullVisitor.java 10626 2007-03-06 16:55:54Z caballero $ |
|
27 |
* $Log$ |
|
28 |
* Revision 1.2 2007-03-06 16:47:58 caballero |
|
29 |
* Exceptions |
|
30 |
* |
|
31 |
* Revision 1.1 2006/06/20 18:20:45 azabala |
|
32 |
* first version in cvs |
|
33 |
* |
|
34 |
* Revision 1.2 2006/06/02 18:21:28 azabala |
|
35 |
* *** empty log message *** |
|
36 |
* |
|
37 |
* Revision 1.1 2006/05/24 21:13:31 azabala |
|
38 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing |
|
39 |
* |
|
40 |
* Revision 1.3 2006/03/15 18:31:06 azabala |
|
41 |
* *** empty log message *** |
|
42 |
* |
|
43 |
* Revision 1.2 2006/03/07 21:01:33 azabala |
|
44 |
* *** empty log message *** |
|
45 |
* |
|
46 |
* Revision 1.1 2006/03/06 19:48:39 azabala |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.2 2006/03/05 19:57:48 azabala |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* Revision 1.1 2006/02/17 16:32:50 azabala |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* |
|
56 |
*/ |
|
57 |
package org.gvsig.geoprocess.algorithm.convexhull; |
|
58 |
|
|
59 |
import com.vividsolutions.jts.geom.Geometry; |
|
60 |
import com.vividsolutions.jts.geom.GeometryCollection; |
|
61 |
import com.vividsolutions.jts.geom.GeometryFactory; |
|
62 |
|
|
63 |
import es.unex.sextante.core.Sextante; |
|
64 |
|
|
65 |
import org.gvsig.fmap.dal.exception.DataException; |
|
66 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
67 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
68 |
import org.gvsig.fmap.geom.GeometryManager; |
|
69 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
70 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
71 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
72 |
import org.gvsig.fmap.geom.operation.fromjts.FromJTS; |
|
73 |
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil; |
|
74 |
|
|
75 |
/** |
|
76 |
* Convex Hull operation |
|
77 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
78 |
*/ |
|
79 |
public class ConvexHullOperation { |
|
80 |
public static final String NAME = "ConvexHull"; |
|
81 |
public static final int CODE = GeometryLocator.getGeometryManager().getGeometryOperationCode(NAME); |
|
82 |
Geometry geometry = null; |
|
83 |
GeometryFactory geomFact = null; |
|
84 |
private GeometryManager geometryManager = null; |
|
85 |
|
|
86 |
public ConvexHullOperation() { |
|
87 |
geometry = null; |
|
88 |
geometryManager = GeometryLocator.getGeometryManager(); |
|
89 |
} |
|
90 |
|
|
91 |
public void setFeatureStore(FeatureStore out, String[] attrNames) throws DataException { |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Returns FMap convex hull geometry. |
|
96 |
* @return |
|
97 |
*/ |
|
98 |
public org.gvsig.fmap.geom.Geometry getGeometry() { |
|
99 |
if(geometry == null) |
|
100 |
return null; |
|
101 |
GeometryOperationContext ctx = new GeometryOperationContext(); |
|
102 |
ctx.setAttribute(FromJTS.PARAM, geometry); |
|
103 |
try { |
|
104 |
return (org.gvsig.fmap.geom.Geometry)geometryManager.invokeOperation(FromJTS.NAME, ctx); |
|
105 |
} catch (GeometryOperationNotSupportedException e) { |
|
106 |
Sextante.addErrorToLog(e); |
|
107 |
return null; |
|
108 |
} catch (GeometryOperationException e) { |
|
109 |
Sextante.addErrorToLog(e); |
|
110 |
return null; |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
|
|
115 |
public org.gvsig.fmap.geom.Geometry invoke(org.gvsig.fmap.geom.Geometry g) { |
|
116 |
if(g == null) |
|
117 |
return null; |
|
118 |
|
|
119 |
com.vividsolutions.jts.geom.Geometry actualGeometry = GeometryUtil.geomToJTS(g); |
|
120 |
|
|
121 |
if(geometry == null) |
|
122 |
geometry = actualGeometry; |
|
123 |
else { |
|
124 |
com.vividsolutions.jts.geom.Geometry[] geoms = new com.vividsolutions.jts.geom.Geometry[2]; |
|
125 |
geoms[0] = geometry; |
|
126 |
geoms[1] = actualGeometry; |
|
127 |
if(geomFact == null) |
|
128 |
geomFact = new GeometryFactory(); |
|
129 |
GeometryCollection gc = geomFact.createGeometryCollection(geoms); |
|
130 |
geometry = gc.convexHull(); |
|
131 |
} |
|
132 |
return getGeometry(); |
|
133 |
} |
|
134 |
|
|
135 |
/* |
|
136 |
* (non-Javadoc) |
|
137 |
* @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex() |
|
138 |
*/ |
|
139 |
public int getOperationIndex() { |
|
140 |
return CODE; |
|
141 |
} |
|
142 |
|
|
143 |
} |
|
144 |
|
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/ConvexHullParametersPanel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.geoprocess.algorithm.convexhull; |
|
25 |
|
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.GridBagConstraints; |
|
28 |
import java.awt.GridBagLayout; |
|
29 |
import java.awt.Insets; |
|
30 |
import java.awt.event.ActionEvent; |
|
31 |
import java.awt.event.ActionListener; |
|
32 |
import java.util.ArrayList; |
|
33 |
import java.util.Iterator; |
|
34 |
import java.util.List; |
|
35 |
|
|
36 |
import javax.swing.JButton; |
|
37 |
import javax.swing.JComboBox; |
|
38 |
|
|
39 |
import es.unex.sextante.core.GeoAlgorithm; |
|
40 |
import es.unex.sextante.core.Sextante; |
|
41 |
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel; |
|
42 |
|
|
43 |
import org.slf4j.Logger; |
|
44 |
import org.slf4j.LoggerFactory; |
|
45 |
|
|
46 |
import org.gvsig.fmap.dal.DALLocator; |
|
47 |
import org.gvsig.fmap.dal.DataManager; |
|
48 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
49 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
50 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
51 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor; |
|
52 |
import org.gvsig.tools.service.ServiceException; |
|
53 |
|
|
54 |
/** |
|
55 |
* @deprecated |
|
56 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
57 |
*/ |
|
58 |
public class ConvexHullParametersPanel extends GeoAlgorithmParametersPanel implements ActionListener { |
|
59 |
|
|
60 |
private static final long serialVersionUID = 3260891769310434508L; |
|
61 |
|
|
62 |
private static final Logger LOG = |
|
63 |
LoggerFactory.getLogger(ConvexHullParametersPanel.class); |
|
64 |
|
|
65 |
private JComboBox combo = null; |
|
66 |
private JButton button = null; |
|
67 |
private ArrayList<DataStoreParameters> paramList = new ArrayList<DataStoreParameters>(); |
|
68 |
|
|
69 |
public ConvexHullParametersPanel() { |
|
70 |
super(); |
|
71 |
} |
|
72 |
|
|
73 |
public void init(GeoAlgorithm algorithm) { |
|
74 |
initGUI(); |
|
75 |
} |
|
76 |
|
|
77 |
private void initGUI() { |
|
78 |
GridBagLayout gbl = new GridBagLayout(); |
|
79 |
this.setLayout(gbl); |
|
80 |
|
|
81 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
82 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
83 |
gbc.weightx = 1.0; |
|
84 |
gbc.gridx = 0; |
|
85 |
gbc.gridy = 0; |
|
86 |
gbc.insets = new Insets(0, 2, 0, 0); |
|
87 |
this.add(getCombo(), gbc); |
|
88 |
|
|
89 |
gbc.fill = GridBagConstraints.NONE; |
|
90 |
gbc.weightx = 0; |
|
91 |
gbc.gridx = 1; |
|
92 |
gbc.insets = new Insets(0, 5, 0, 2); |
|
93 |
this.add(getButton(), gbc); |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* Gets a ComboBox |
|
98 |
* @return |
|
99 |
*/ |
|
100 |
public JComboBox getCombo() { |
|
101 |
if(combo == null) { |
|
102 |
combo = new JComboBox(); |
|
103 |
loadProviderList(combo, paramList); |
|
104 |
combo.addActionListener(this); |
|
105 |
combo.setPreferredSize(new Dimension(0, 18)); |
|
106 |
} |
|
107 |
return combo; |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* Gets a JButton |
|
112 |
* @return |
|
113 |
*/ |
|
114 |
public JButton getButton() { |
|
115 |
if(button == null) { |
|
116 |
button = new JButton("..."); |
|
117 |
button.setPreferredSize(new Dimension(60, 18)); |
|
118 |
button.addActionListener(this); |
|
119 |
} |
|
120 |
return button; |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void assignParameters() { |
|
125 |
// Nothing to do |
|
126 |
} |
|
127 |
|
|
128 |
@Override |
|
129 |
public void setOutputValue(String arg0, String arg1) { |
|
130 |
|
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public void setParameterValue(String arg0, String arg1) { |
|
135 |
|
|
136 |
} |
|
137 |
|
|
138 |
@SuppressWarnings("unchecked") |
|
139 |
private void loadProviderList(JComboBox c, ArrayList<DataStoreParameters> paramList) { |
|
140 |
try { |
|
141 |
DataManager manager = DALLocator.getDataManager(); |
|
142 |
List list = manager.getStoreProviders(); |
|
143 |
Iterator it = list.iterator(); |
|
144 |
c.removeAllItems(); |
|
145 |
paramList.clear(); |
|
146 |
while(it.hasNext()) { |
|
147 |
try { |
|
148 |
String provider = it.next().toString(); |
|
149 |
DataStoreParameters param = manager.createStoreParameters(provider); |
|
150 |
c.addItem(provider); |
|
151 |
paramList.add(param); |
|
152 |
} catch (InitializeException e1) { |
|
153 |
Sextante.addErrorToLog(e1); |
|
154 |
} catch (ProviderNotRegisteredException e1) { |
|
155 |
Sextante.addErrorToLog(e1); |
|
156 |
} |
|
157 |
} |
|
158 |
}catch(Exception e){} |
|
159 |
} |
|
160 |
|
|
161 |
public void actionPerformed(ActionEvent e) { |
|
162 |
if(e.getSource() == getButton()) { |
|
163 |
int index = getCombo().getSelectedIndex(); |
|
164 |
|
|
165 |
try { |
|
166 |
DynObjectEditor editor = new DynObjectEditor(paramList.get(index)); |
|
167 |
editor.editObject(true); |
|
168 |
} catch (ServiceException ex) { |
|
169 |
LOG.error( |
|
170 |
"Error creating a Swing component for the DynObject: " |
|
171 |
+ paramList.get(index), ex); |
|
172 |
Sextante.addErrorToLog(ex); |
|
173 |
} |
|
174 |
|
|
175 |
} |
|
176 |
|
|
177 |
if(e.getSource() == getCombo()) { |
|
178 |
|
|
179 |
} |
|
180 |
} |
|
181 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/ConvexHullLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.geoprocess.algorithm.convexhull; |
|
25 |
|
|
26 |
import org.gvsig.geoprocess.algorithm.base.core.AlgorithmAbstractLibrary; |
|
27 |
import org.gvsig.i18n.Messages; |
|
28 |
import org.gvsig.tools.library.LibraryException; |
|
29 |
|
|
30 |
/** |
|
31 |
* Initialization of ConvexHullLibrary library. |
|
32 |
* |
|
33 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
34 |
*/ |
|
35 |
public class ConvexHullLibrary extends AlgorithmAbstractLibrary { |
|
36 |
|
|
37 |
@Override |
|
38 |
protected void doInitialize() throws LibraryException { |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
protected void doPostInitialize() throws LibraryException { |
|
44 |
Messages.addResourceFamily( |
|
45 |
"org.gvsig.geoprocess.algorithm.convexhull.convexhull", |
|
46 |
ConvexHullLibrary.class.getClassLoader(), ConvexHullLibrary.class |
|
47 |
.getClass().getName()); |
|
48 |
registerGeoProcess(new ConvexHullAlgorithm()); |
|
49 |
} |
|
50 |
|
|
51 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/ConvexHullAlgorithm.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or modify it under |
|
7 |
* the terms of the GNU General Public License as published by the Free Software |
|
8 |
* Foundation; either version 2 of the License, or (at your option) any later |
|
9 |
* version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
14 |
* details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us at info AT |
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.geoprocess.algorithm.convexhull; |
|
24 |
|
|
25 |
import java.util.Iterator; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import org.gvsig.fmap.dal.exception.DataException; |
|
29 |
import org.gvsig.fmap.dal.feature.Feature; |
|
30 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
34 |
import org.gvsig.fmap.geom.Geometry; |
|
35 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
36 |
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil; |
|
37 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
38 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer; |
|
39 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
40 |
import org.slf4j.Logger; |
|
41 |
import org.slf4j.LoggerFactory; |
|
42 |
|
|
43 |
import es.unex.sextante.core.Sextante; |
|
44 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
45 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
46 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
47 |
import es.unex.sextante.outputs.OutputVectorLayer; |
|
48 |
|
|
49 |
/** |
|
50 |
* Convex Hull Algorithm |
|
51 |
* |
|
52 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
53 |
*/ |
|
54 |
public class ConvexHullAlgorithm extends AbstractSextanteGeoProcess { |
|
55 |
|
|
56 |
private static final Logger log = LoggerFactory.getLogger(ConvexHullAlgorithm.class); |
|
57 |
public static final String LAYER = "LAYER"; |
|
58 |
public static final String RESULT = "RESULT"; |
|
59 |
public static final String CHECK = "CHECK"; |
|
60 |
|
|
61 |
public void defineCharacteristics() { |
|
62 |
setName(getTranslation("ConvexHull")); |
|
63 |
setGroup(getTranslation("basic_vect_algorithms")); |
|
64 |
// setGeneratesUserDefinedRasterOutput(false); |
|
65 |
try { |
|
66 |
m_Parameters.addInputVectorLayer(LAYER, |
|
67 |
getTranslation("Input_layer"), IVectorLayer.SHAPE_TYPE_WRONG, |
|
68 |
true); |
|
69 |
addOutputVectorLayer(RESULT, getTranslation("ConvexHull"), |
|
70 |
OutputVectorLayer.SHAPE_TYPE_POLYGON); |
|
71 |
m_Parameters.addBoolean(CHECK, |
|
72 |
getTranslation("Selected_geometries_convex_hull"), false); |
|
73 |
} catch (RepeatedParameterNameException e) { |
|
74 |
Sextante.addErrorToLog(e); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
/* |
|
79 |
* (non-Javadoc) |
|
80 |
* |
|
81 |
* @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm() |
|
82 |
*/ |
|
83 |
@SuppressWarnings("unchecked") |
|
84 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
|
85 |
if (existsOutPutFile(ConvexHullAlgorithm.RESULT, 0)) { |
|
86 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
87 |
} |
|
88 |
|
|
89 |
IVectorLayer input = m_Parameters.getParameterValueAsVectorLayer(LAYER); |
|
90 |
boolean selectedGeom |
|
91 |
= m_Parameters.getParameter(CHECK).getParameterValueAsBoolean(); |
|
92 |
|
|
93 |
FeatureStore store = null; |
|
94 |
|
|
95 |
if (input instanceof FlyrVectIVectorLayer) { |
|
96 |
store = ((FlyrVectIVectorLayer) input).getFeatureStore(); |
|
97 |
} else { |
|
98 |
return false; |
|
99 |
} |
|
100 |
|
|
101 |
ConvexHullOperation convexHullOperation = new ConvexHullOperation(); |
|
102 |
|
|
103 |
FeatureSet features = null; |
|
104 |
try { |
|
105 |
Iterator it = null; |
|
106 |
if (selectedGeom) { |
|
107 |
features = store.getFeatureSet(); |
|
108 |
FeatureSelection ds = store.getFeatureSelection(); |
|
109 |
it = ds.iterator(); |
|
110 |
} else { |
|
111 |
FeatureQuery query = getQueryFromAnalysisExtent(m_AnalysisExtent, store); |
|
112 |
features = store.getFeatureSet(query); |
|
113 |
it = features.iterator(); |
|
114 |
} |
|
115 |
|
|
116 |
int numberOfFeatures = (int) features.getSize(); |
|
117 |
int iCount = 0; |
|
118 |
|
|
119 |
while (it.hasNext()) { |
|
120 |
Feature feature = (Feature) it.next(); |
|
121 |
List geomList = feature.getGeometries(); |
|
122 |
setProgress(iCount, numberOfFeatures); |
|
123 |
iCount++; |
|
124 |
if (geomList == null) { |
|
125 |
Geometry geom = feature.getDefaultGeometry(); |
|
126 |
if (geom != null) { |
|
127 |
convexHullOperation.invoke(geom); |
|
128 |
} |
|
129 |
continue; |
|
130 |
} |
|
131 |
Iterator<Geometry> itGeom = geomList.iterator(); |
|
132 |
while (itGeom.hasNext()) { |
|
133 |
Geometry g = itGeom.next(); |
|
134 |
convexHullOperation.invoke(g); |
|
135 |
} |
|
136 |
} |
|
137 |
Geometry g = convexHullOperation.getGeometry(); |
|
138 |
if (g == null) { |
|
139 |
return false; |
|
140 |
} |
|
141 |
String[] sNames = {"ID"}; |
|
142 |
Class[] types = {Integer.class}; |
|
143 |
IVectorLayer output |
|
144 |
= getNewVectorLayer(RESULT, getTranslation("ConvexHull"), |
|
145 |
OutputVectorLayer.SHAPE_TYPE_POLYGON, types, sNames); |
|
146 |
|
|
147 |
com.vividsolutions.jts.geom.Geometry jtsGeom |
|
148 |
= GeometryUtil.geomToJTS(g); |
|
149 |
|
|
150 |
output.addFeature(jtsGeom, new Object[]{new Integer(0)}); |
|
151 |
//it.dispose(); |
|
152 |
} catch (DataException e) { |
|
153 |
log.error("", e); |
|
154 |
} catch (CreateEnvelopeException e) { |
|
155 |
log.error("Error creating envelope", e); |
|
156 |
} |
|
157 |
return !m_Task.isCanceled(); |
|
158 |
} |
|
159 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.272/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/TestPanel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
Also available in: Unified diff