Revision 1972
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/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.intersection</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>org.gvsig.geoprocess.algorithm.intersection</name> |
|
7 |
|
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.geoprocess.algorithm</artifactId> |
|
11 |
<version>2.2.262</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> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/src/main/java/org/gvsig/geoprocess/algorithm/intersection/IntersectionOperation.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.intersection; |
|
25 |
|
|
26 |
import java.util.Iterator; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.exception.DataException; |
|
30 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
31 |
import org.gvsig.fmap.dal.feature.Feature; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
34 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
35 |
import org.gvsig.fmap.geom.GeometryManager; |
|
36 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
37 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
38 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
39 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
40 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
41 |
import org.gvsig.fmap.geom.operation.fromjts.FromJTS; |
|
42 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
43 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
44 |
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation; |
|
45 |
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil; |
|
46 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
47 |
import org.slf4j.Logger; |
|
48 |
import org.slf4j.LoggerFactory; |
|
49 |
|
|
50 |
import com.vividsolutions.jts.geom.Geometry; |
|
51 |
import com.vividsolutions.jts.geom.GeometryCollection; |
|
52 |
import com.vividsolutions.jts.geom.LineString; |
|
53 |
import com.vividsolutions.jts.geom.MultiLineString; |
|
54 |
import com.vividsolutions.jts.geom.MultiPoint; |
|
55 |
import com.vividsolutions.jts.geom.MultiPolygon; |
|
56 |
import com.vividsolutions.jts.geom.Point; |
|
57 |
import com.vividsolutions.jts.geom.Polygon; |
|
58 |
import com.vividsolutions.jts.precision.EnhancedPrecisionOp; |
|
59 |
|
|
60 |
import es.unex.sextante.core.Sextante; |
|
61 |
|
|
62 |
/** |
|
63 |
* Builds a geometry with the intersection between two layers |
|
64 |
* |
|
65 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
66 |
*/ |
|
67 |
public class IntersectionOperation extends GeometryOperation { |
|
68 |
|
|
69 |
private FeatureStore storeOverlay = null; |
|
70 |
protected GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
71 |
private Logger log = LoggerFactory.getLogger(IntersectionOperation.class); |
|
72 |
private boolean errorInfo = false; |
|
73 |
|
|
74 |
public IntersectionOperation(FeatureStore overlayLayer, AbstractSextanteGeoProcess p) { |
|
75 |
super(p); |
|
76 |
this.storeOverlay = overlayLayer; |
|
77 |
} |
|
78 |
|
|
79 |
public boolean getErrorInfo() { |
|
80 |
return errorInfo; |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* Computes intersection between the geometry and the overlay layer. The |
|
85 |
* fields of the intersected features will be added. |
|
86 |
* |
|
87 |
* @param g |
|
88 |
* @param featureInput |
|
89 |
* @return |
|
90 |
*/ |
|
91 |
@SuppressWarnings({"unchecked", "deprecation"}) |
|
92 |
public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature featureInput) { |
|
93 |
if (g == null) { |
|
94 |
return lastEditFeature; |
|
95 |
} |
|
96 |
|
|
97 |
FeatureSet features = null; |
|
98 |
Iterator it = null; |
|
99 |
try { |
|
100 |
if (selectedGeomOverlay) { |
|
101 |
features = (FeatureSet) storeOverlay.getSelection(); |
|
102 |
} else { |
|
103 |
features = storeOverlay.getFeatureSet(); |
|
104 |
} |
|
105 |
it = features.iterator(); |
|
106 |
} catch (DataException e) { |
|
107 |
Sextante.addErrorToLog(e); |
|
108 |
return lastEditFeature; |
|
109 |
} |
|
110 |
|
|
111 |
while (it.hasNext()) { |
|
112 |
Feature featureOverlay = (Feature) it.next(); |
|
113 |
List<org.gvsig.fmap.geom.Geometry> geomList = featureOverlay.getGeometries(); |
|
114 |
if (geomList == null) { |
|
115 |
org.gvsig.fmap.geom.Geometry geom = featureOverlay.getDefaultGeometry(); |
|
116 |
lastEditFeature = intersection(g, geom, featureInput, featureOverlay); |
|
117 |
continue; |
|
118 |
} |
|
119 |
|
|
120 |
Iterator<org.gvsig.fmap.geom.Geometry> itGeom = geomList.iterator(); |
|
121 |
while (itGeom.hasNext()) { |
|
122 |
org.gvsig.fmap.geom.Geometry geom = itGeom.next(); |
|
123 |
lastEditFeature = intersection(g, geom, featureInput, featureOverlay); |
|
124 |
} |
|
125 |
} |
|
126 |
// it.dispose(); |
|
127 |
return lastEditFeature; |
|
128 |
} |
|
129 |
|
|
130 |
private EditableFeature intersection(org.gvsig.fmap.geom.Geometry g1, |
|
131 |
org.gvsig.fmap.geom.Geometry g2, |
|
132 |
Feature featureInput, |
|
133 |
Feature featureOverlay) { |
|
134 |
if (g1 == null || g2 == null) { |
|
135 |
return null; |
|
136 |
} |
|
137 |
Geometry overlaysGeom = null; |
|
138 |
Geometry jtsGeom = null; |
|
139 |
int outPutType = TYPES.SURFACE; |
|
140 |
|
|
141 |
try { |
|
142 |
outPutType = persister.getOutputFeatureStore().getDefaultFeatureType() |
|
143 |
.getDefaultGeometryAttribute().getGeomType().getType(); |
|
144 |
} catch (DataException e2) { |
|
145 |
Sextante.addErrorToLog(e2); |
|
146 |
} |
|
147 |
|
|
148 |
try { |
|
149 |
if (((g1 instanceof Surface && g2 instanceof Curve) |
|
150 |
|| (g2 instanceof Surface && g1 instanceof Curve)) |
|
151 |
&& outPutType == TYPES.MULTIPOINT) { |
|
152 |
org.gvsig.fmap.geom.Geometry overGeom = (g1 instanceof Surface) ? g1 : g2; |
|
153 |
jtsGeom = (g1 instanceof Surface) ? GeometryUtil.geomToJTS(g2) : GeometryUtil.geomToJTS(g1); |
|
154 |
overlaysGeom = (Geometry) overGeom.invokeOperation("toJTSLineString", null); |
|
155 |
} else { |
|
156 |
if (g1 instanceof Surface |
|
157 |
&& g2 instanceof Surface |
|
158 |
&& (outPutType == TYPES.MULTIPOINT)) { |
|
159 |
jtsGeom = (Geometry) g1.invokeOperation("toJTSLineString", null); |
|
160 |
overlaysGeom = (Geometry) g2.invokeOperation("toJTSLineString", null); |
|
161 |
} else { |
|
162 |
jtsGeom = GeometryUtil.geomToJTS(g1); |
|
163 |
overlaysGeom = GeometryUtil.geomToJTS(g2); |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
if (!jtsGeom.getEnvelope().intersects(overlaysGeom.getEnvelope())) { |
|
168 |
return lastEditFeature; |
|
169 |
} |
|
170 |
|
|
171 |
if (jtsGeom.intersects(overlaysGeom)) { |
|
172 |
Geometry newGeom = EnhancedPrecisionOp.intersection(jtsGeom, overlaysGeom); |
|
173 |
if (!newGeom.isEmpty()) { |
|
174 |
if (typesMatch(outPutType, newGeom) || newGeom instanceof GeometryCollection) { |
|
175 |
lastEditFeature = persister.addFeature(featureInput, featureOverlay, newGeom); |
|
176 |
} else { |
|
177 |
//Para intersecciones entre pol?gonos cuando la salida es de tipo l?nea |
|
178 |
//la generamos a partir del pol?gono resultante de la intersecci?n |
|
179 |
if (g1 instanceof Surface |
|
180 |
&& g2 instanceof Surface |
|
181 |
&& outPutType == TYPES.MULTICURVE |
|
182 |
&& (newGeom instanceof Polygon || newGeom instanceof MultiPolygon)) { |
|
183 |
GeometryOperationContext ctx = new GeometryOperationContext(); |
|
184 |
ctx.setAttribute(FromJTS.PARAM, newGeom); |
|
185 |
org.gvsig.fmap.geom.Geometry newDalGeom = (org.gvsig.fmap.geom.Geometry) geomManager.invokeOperation(FromJTS.NAME, ctx); |
|
186 |
newGeom = (Geometry) newDalGeom.invokeOperation("toJTSLineString", null); |
|
187 |
} |
|
188 |
|
|
189 |
lastEditFeature = persister.addFeature(featureInput, featureOverlay, newGeom); |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
} catch (CreateGeometryException e) { |
|
194 |
Sextante.addErrorToLog(e); |
|
195 |
} catch (DataException e) { |
|
196 |
Sextante.addErrorToLog(e); |
|
197 |
} catch (GeometryOperationNotSupportedException e1) { |
|
198 |
Sextante.addErrorToLog(e1); |
|
199 |
} catch (GeometryOperationException e1) { |
|
200 |
Sextante.addErrorToLog(e1); |
|
201 |
} catch (com.vividsolutions.jts.geom.TopologyException e) { |
|
202 |
errorInfo = true; |
|
203 |
log.info("Problems operating intersection: ", e); |
|
204 |
} |
|
205 |
return lastEditFeature; |
|
206 |
} |
|
207 |
|
|
208 |
private boolean typesMatch(int dalType, Geometry newGeom) { |
|
209 |
|
|
210 |
return ((geomManager.isSubtype(TYPES.MULTICURVE, dalType) |
|
211 |
&& (newGeom instanceof MultiLineString || newGeom instanceof LineString)) |
|
212 |
|| (geomManager.isSubtype(TYPES.MULTIPOINT, dalType) |
|
213 |
&& (newGeom instanceof MultiPoint || newGeom instanceof Point)) |
|
214 |
|| (geomManager.isSubtype(TYPES.MULTISURFACE, dalType) |
|
215 |
&& (newGeom instanceof Polygon || newGeom instanceof MultiPolygon)) |
|
216 |
|| (geomManager.isSubtype(TYPES.CURVE, dalType) && newGeom instanceof LineString) |
|
217 |
|| (geomManager.isSubtype(TYPES.SURFACE, dalType) && newGeom instanceof Polygon) |
|
218 |
|| (geomManager.isSubtype(TYPES.POINT, dalType) && newGeom instanceof Point)); |
|
219 |
|
|
220 |
} |
|
221 |
|
|
222 |
/** |
|
223 |
* clips feature's geometry with the clipping geometry, preserving feature's |
|
224 |
* original attributes. If feature's geometry doesn't touch clipping |
|
225 |
* geometry, it will be ignored. |
|
226 |
*/ |
|
227 |
public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature featureInput) { |
|
228 |
} |
|
229 |
|
|
230 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/src/main/java/org/gvsig/geoprocess/algorithm/intersection/IntersectionLibrary.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.intersection; |
|
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 IntersectionLibrary library. |
|
32 |
* |
|
33 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
34 |
*/ |
|
35 |
public class IntersectionLibrary 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.intersection.intersection", |
|
46 |
IntersectionLibrary.class.getClassLoader(), |
|
47 |
IntersectionLibrary.class.getClass().getName()); |
|
48 |
registerGeoProcess(new IntersectionAlgorithm()); |
|
49 |
} |
|
50 |
|
|
51 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/src/main/java/org/gvsig/geoprocess/algorithm/intersection/IntersectionAlgorithm.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.intersection; |
|
25 |
|
|
26 |
import javax.swing.JOptionPane; |
|
27 |
|
|
28 |
import org.gvsig.fmap.dal.exception.DataException; |
|
29 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
30 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
31 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
32 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer; |
|
33 |
|
|
34 |
import es.unex.sextante.core.Sextante; |
|
35 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
36 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
37 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
38 |
import es.unex.sextante.outputs.OutputVectorLayer; |
|
39 |
import org.gvsig.tools.namestranslator.NamesTranslator; |
|
40 |
|
|
41 |
/** |
|
42 |
* Intersection algorithm |
|
43 |
* <UL> |
|
44 |
* <LI>Pol-Pol: 3 layers (polygon, point, line)</LI> |
|
45 |
* <LI>Pol-Line: 2 layers (point, line)</LI> |
|
46 |
* <LI>Pol-Point: 1 layer (point)</LI> |
|
47 |
* <LI>Line-Point: 1 layer (point)</LI> |
|
48 |
* <LI>Line-Line: 2 layers (point, line)</LI> |
|
49 |
* <LI>Point-Point: 1 layer (point)</LI> |
|
50 |
* </UL> |
|
51 |
* |
|
52 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
53 |
*/ |
|
54 |
public class IntersectionAlgorithm extends AbstractSextanteGeoProcess { |
|
55 |
|
|
56 |
public static final String RESULT_POL = "RESULT_POL"; |
|
57 |
public static final String RESULT_POINT = "RESULT_POINT"; |
|
58 |
public static final String RESULT_LINE = "RESULT_LINE"; |
|
59 |
public static final String LAYER = "LAYER"; |
|
60 |
public static final String INTER = "INTER"; |
|
61 |
public static final String SELECTGEOM_INPUT = "SELECTGEOM_INPUT"; |
|
62 |
public static final String SELECTGEOM_OVERLAY = "SELECTGEOM_OVERLAY"; |
|
63 |
|
|
64 |
|
|
65 |
/* |
|
66 |
* (non-Javadoc) |
|
67 |
* @see es.unex.sextante.core.GeoAlgorithm#defineCharacteristics() |
|
68 |
*/ |
|
69 |
public void defineCharacteristics() { |
|
70 |
setName(getTranslation("Intersection")); |
|
71 |
setGroup(getTranslation("basic_vect_algorithms")); |
|
72 |
// setGeneratesUserDefinedRasterOutput(false); |
|
73 |
|
|
74 |
try { |
|
75 |
m_Parameters.addInputVectorLayer(LAYER, |
|
76 |
getTranslation("Input_layer"), |
|
77 |
IVectorLayer.SHAPE_TYPE_WRONG, |
|
78 |
true); |
|
79 |
m_Parameters.addInputVectorLayer(INTER, |
|
80 |
getTranslation("Overlays_layer"), |
|
81 |
IVectorLayer.SHAPE_TYPE_WRONG, |
|
82 |
true); |
|
83 |
m_Parameters.addBoolean(SELECTGEOM_INPUT, |
|
84 |
getTranslation("Selected_geometries_input_layer_inters"), false); |
|
85 |
m_Parameters.addBoolean(SELECTGEOM_OVERLAY, |
|
86 |
getTranslation("Selected_geometries_overlay_layer_inters"), false); |
|
87 |
} catch (RepeatedParameterNameException e) { |
|
88 |
Sextante.addErrorToLog(e); |
|
89 |
} |
|
90 |
addOutputVectorLayer(RESULT_POL, getTranslation("Intersection_polygon"), |
|
91 |
OutputVectorLayer.SHAPE_TYPE_POLYGON); |
|
92 |
addOutputVectorLayer(RESULT_LINE, getTranslation("Intersection_line"), |
|
93 |
OutputVectorLayer.SHAPE_TYPE_LINE); |
|
94 |
addOutputVectorLayer(RESULT_POINT, getTranslation("Intersection_point"), |
|
95 |
OutputVectorLayer.SHAPE_TYPE_POINT); |
|
96 |
} |
|
97 |
|
|
98 |
/* |
|
99 |
* (non-Javadoc) |
|
100 |
* @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm() |
|
101 |
*/ |
|
102 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
|
103 |
if (existsOutPutFile(IntersectionAlgorithm.RESULT_LINE, 0)) { |
|
104 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
105 |
} |
|
106 |
if (existsOutPutFile(IntersectionAlgorithm.RESULT_POINT, 0)) { |
|
107 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
108 |
} |
|
109 |
if (existsOutPutFile(IntersectionAlgorithm.RESULT_LINE, 0)) { |
|
110 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
111 |
} |
|
112 |
IVectorLayer inter = m_Parameters.getParameterValueAsVectorLayer(INTER); |
|
113 |
IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER); |
|
114 |
boolean selectedGeomInput = m_Parameters.getParameter(SELECTGEOM_INPUT).getParameterValueAsBoolean(); |
|
115 |
boolean selectedGeomOverlay = m_Parameters.getParameter(SELECTGEOM_OVERLAY).getParameterValueAsBoolean(); |
|
116 |
boolean error = false; |
|
117 |
|
|
118 |
try { |
|
119 |
error = computesIntersection(layer, inter, layer.getShapeType(), selectedGeomInput, selectedGeomOverlay); |
|
120 |
} catch (DataException e) { |
|
121 |
Sextante.addErrorToLog(e); |
|
122 |
return false; |
|
123 |
} |
|
124 |
|
|
125 |
if (getTaskMonitor().isCanceled()) { |
|
126 |
return false; |
|
127 |
} |
|
128 |
if (error) { |
|
129 |
JOptionPane.showMessageDialog(null, |
|
130 |
getTranslation("problems_with_some_geometries"), "Error", |
|
131 |
JOptionPane.WARNING_MESSAGE); |
|
132 |
} |
|
133 |
return true; |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* Builds a layer with the intersection between the input layer and the |
|
138 |
* templateGeometry |
|
139 |
* |
|
140 |
* @param layer Input layer |
|
141 |
* @param templateGeometry |
|
142 |
* @param shapeType Output shape type |
|
143 |
* @param selectedGeom If it's true only selected geometries will be |
|
144 |
* computed |
|
145 |
* @throws GeoAlgorithmExecutionException |
|
146 |
*/ |
|
147 |
private boolean computesIntersection(IVectorLayer layer, |
|
148 |
IVectorLayer overlay, |
|
149 |
int shapeType, |
|
150 |
boolean selectedGeomInput, |
|
151 |
boolean selectedGeomOverlay) throws DataException, GeoAlgorithmExecutionException { |
|
152 |
FeatureStore storeLayer = null; |
|
153 |
FeatureStore storeOverlay = null; |
|
154 |
if (layer instanceof FlyrVectIVectorLayer |
|
155 |
&& overlay instanceof FlyrVectIVectorLayer) { |
|
156 |
storeLayer = ((FlyrVectIVectorLayer) layer).getFeatureStore(); |
|
157 |
storeOverlay = ((FlyrVectIVectorLayer) overlay).getFeatureStore(); |
|
158 |
} else { |
|
159 |
return false; |
|
160 |
} |
|
161 |
|
|
162 |
FeatureType featureType1 = storeLayer.getDefaultFeatureType(); |
|
163 |
FeatureType featureType2 = storeOverlay.getDefaultFeatureType(); |
|
164 |
|
|
165 |
FeatureStore outFeatStorePol = null; |
|
166 |
FeatureStore outFeatStoreLine = null; |
|
167 |
FeatureStore outFeatStorePoint = null; |
|
168 |
|
|
169 |
IntersectionOperation operation = new IntersectionOperation(storeOverlay, this); |
|
170 |
operation.setTaskStatus(getStatus()); |
|
171 |
|
|
172 |
//La de puntos se genera siempre |
|
173 |
outFeatStorePoint |
|
174 |
= buildOutPutStoreFromUnion(featureType1, featureType2, |
|
175 |
IVectorLayer.SHAPE_TYPE_POINT, |
|
176 |
getTranslation("Intersection_point"), RESULT_POINT); |
|
177 |
|
|
178 |
if (outFeatStorePoint != null) { |
|
179 |
getStatus().setTitle("Point"); |
|
180 |
operation.computesGeometryOperation(storeLayer, outFeatStorePoint, |
|
181 |
attrNames, selectedGeomInput, selectedGeomOverlay, true); |
|
182 |
} |
|
183 |
//La de pol?gonos solo si es intersecci?n entre pol?gonos |
|
184 |
if (isPolygon(storeLayer) && isPolygon(storeOverlay)) { |
|
185 |
outFeatStorePol |
|
186 |
= buildOutPutStoreFromUnion(featureType1, featureType2, |
|
187 |
IVectorLayer.SHAPE_TYPE_MULTIPOLYGON, getTranslation("Intersection_polygon"), RESULT_POL); |
|
188 |
if (outFeatStorePol != null) { |
|
189 |
getStatus().setTitle("Polygon"); |
|
190 |
operation.computesGeometryOperation(storeLayer, |
|
191 |
outFeatStorePol, attrNames, selectedGeomInput, |
|
192 |
selectedGeomOverlay, true); |
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
//La capa de l?neas se genera cuando ning?na de las dos es de puntos |
|
197 |
if (!isPoint(storeLayer) && !isPoint(storeOverlay)) { |
|
198 |
outFeatStoreLine |
|
199 |
= buildOutPutStoreFromUnion(featureType1, featureType2, |
|
200 |
IVectorLayer.SHAPE_TYPE_MULTILINE, getTranslation("Intersection_line"), RESULT_LINE); |
|
201 |
if (outFeatStoreLine != null) { |
|
202 |
getStatus().setTitle("Line"); |
|
203 |
operation.computesGeometryOperation(storeLayer, |
|
204 |
outFeatStoreLine, attrNames, selectedGeomInput, |
|
205 |
selectedGeomOverlay, true); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
if (outFeatStorePol == null) { |
|
210 |
getNewVectorLayer(RESULT_POL, getTranslation("Null_polygon"), |
|
211 |
OutputVectorLayer.SHAPE_TYPE_POLYGON, new Class[]{Integer.class}, new String[]{""}); |
|
212 |
} |
|
213 |
|
|
214 |
if (outFeatStoreLine == null) { |
|
215 |
getNewVectorLayer(RESULT_LINE, getTranslation("Null_line"), |
|
216 |
OutputVectorLayer.SHAPE_TYPE_LINE, new Class[]{Integer.class}, new String[]{""}); |
|
217 |
} |
|
218 |
|
|
219 |
if (outFeatStorePoint == null) { |
|
220 |
getNewVectorLayer(RESULT_POINT, getTranslation("Null_point"), |
|
221 |
OutputVectorLayer.SHAPE_TYPE_POINT, new Class[]{Integer.class}, new String[]{""}); |
|
222 |
} |
|
223 |
|
|
224 |
return operation.getErrorInfo(); |
|
225 |
} |
|
226 |
|
|
227 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/src/main/resources/org/gvsig/geoprocess/algorithm/intersection/intersection.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 |
Overlays_layer=Capa de intersecci?n |
|
28 |
Selected_geometries=Geometrias seleccionadas |
|
29 |
Intersection=Intersecci?n |
|
30 |
Selected_geometries_input_layer_inters=Geom. seleccionadas (Capa entrada) |
|
31 |
Selected_geometries_overlay_layer_inters=Geom. seleccionadas (Capa intersecci?n) |
|
32 |
problems_with_some_geometries=El proceso ha terminado pero ocurri? un error en alguna geometr?a. Es posible que el resultado no sea del todo exacto. Consulte el log. |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/src/main/resources/org/gvsig/geoprocess/algorithm/intersection/intersection_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 |
Overlays_layer=Intersection cover |
|
28 |
Selected_geometries=Selected geometries |
|
29 |
Intersection=Intersection |
|
30 |
Selected_geometries_input_layer_inters=Selected features (Input cover) |
|
31 |
Selected_geometries_overlay_layer_inters=Selected features (Intersection cover) |
|
32 |
problems_with_some_geometries=The process has ended but an error happened in some geometry. Maybe the result not be totally accuracy. See the log. |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/src/main/resources/help/IntersectionAlgorithm_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 works with two layers: the input layer and the overlay layer. For each geometry in the input layer, it computes its intersections with the geometries of the overlay layer. For each intersection, it adds a new feature with the intersection as geometry and all attributes of the features which originates it. It is called "Spatial AND", because features of the result layer models a space common to both layers.' description="Descripción" type="0"> |
|
29 |
<image description="" file="intersectdesc.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="INTER" text="" description="Capa de revestimiento" type="3"> |
|
43 |
</element> |
|
44 |
<element name="CHECK" text="" description="Geometrias seleccionadas" type="3"> |
|
45 |
</element> |
|
46 |
<element name="OUTPUT_DESCRIPTION" text="" description="Descripción" type="2"> |
|
47 |
</element> |
|
48 |
<element name="RESULT" text="" description="Intersección" type="2"> |
|
49 |
</element> |
|
50 |
</help> |
|
51 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/src/main/resources/help/IntersectionAlgorithm.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 opera sobre dos capas, la "capa de entrada" y la "capa de solape", las geometrías de estas capas pueden ser de polígonos, líneas o puntos. Para cada geometría de la capa de entrada, calcula la interseccion con las diferentes geometrías de la capa de solape, originando un nuevo elemento por cada intersección. Este elemento tomará todos los atributos alfanuméricos de las geometrías que lo originaron (de entrada y solape). Por este motivo (modela zonas del espacio que cumplen la condición de pertenecer a los dos polígonos que lo han originado) a este geoproceso se le conoce como operador AND espacial. Un ejemplo de aplicación de este geoproceso sería para, dada una capa de usos del suelo Corine 2000, y una capa del mapa geológico nacional, obtener una capa de polígonos con información homogénea de uso del suelo y material geológico.' description="Descripción" type="0"> |
|
29 |
<image description="" file="intersectdesc.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="INTER" text="" description="Capa de revestimiento" type="3"> |
|
43 |
</element> |
|
44 |
<element name="CHECK" text="" description="Geometrias seleccionadas" type="3"> |
|
45 |
</element> |
|
46 |
<element name="OUTPUT_DESCRIPTION" text="" description="Descripción" type="2"> |
|
47 |
</element> |
|
48 |
<element name="RESULT" text="" description="Intersección" type="2"> |
|
49 |
</element> |
|
50 |
</help> |
|
51 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.geoprocess.algorithm.intersection.IntersectionLibrary |
|
0 | 2 |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/resources/org/gvsig/geoprocess/algorithm/buffer/buffer.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 |
Buffer=Buffer |
|
27 |
poly_in=Dentro del pol?gono |
|
28 |
poly_out=Fuera del pol?gono |
|
29 |
poly_inandout=Dentro y fuera del pol?gono |
|
30 |
Input_layer=Capa de entrada |
|
31 |
Selected_geometries=Geometrias seleccionadas |
|
32 |
Distance=Distancia |
|
33 |
Field=Campo |
|
34 |
Fields=Campos |
|
35 |
Merge=Mezcla |
|
36 |
Round_border=Borde redondeado |
|
37 |
Builds_influence_area=Areas de influencia |
|
38 |
Number_of_rings=N?mero de anillos |
|
39 |
Wrong_type_for_this_shapetype=Tipo erroneo para este tipo de shape |
|
40 |
area_field=?rea definida por un campo en metros |
|
41 |
area_distance=?rea definida por una distancia en metros |
|
42 |
file_exists=El fichero de salida existe |
|
43 |
Dissolve_entities=Disolver entidades (solo un anillo) |
|
44 |
options=Opciones |
|
45 |
input=Entradas |
|
46 |
outputs=Salidas |
|
47 |
calc_buffer=Calculando Buffer |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/resources/org/gvsig/geoprocess/algorithm/buffer/buffer_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 |
Buffer=Buffer |
|
27 |
poly_in=Inside the polygon |
|
28 |
poly_out=Outside the polygon |
|
29 |
poly_inandout=Inside and outside the polygon |
|
30 |
Input_layer=Input cover |
|
31 |
Selected_geometries=Selected features |
|
32 |
Distance=Distance |
|
33 |
Field=Field |
|
34 |
Fields=Fields |
|
35 |
Merge=Merge |
|
36 |
Round_border=Round border |
|
37 |
Builds_influence_area=Influence areas (only polygons) |
|
38 |
Number_of_rings=Number of radial buffers |
|
39 |
Wrong_type_for_this_shapetype=wrong type for this shape type |
|
40 |
area_field=Area defined by a field in meters |
|
41 |
area_distance=Area defined by a distance in meters |
|
42 |
file_exists=The output file exists |
|
43 |
Dissolve_entities=Dissolve entities |
|
44 |
options=Options |
|
45 |
input=Inputs |
|
46 |
outputs=Outputs |
|
47 |
calc_buffer=Calculating buffer |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/resources/help/BufferAlgorithm.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" |
|
29 |
text="Este geoproceso crea una nueva capa vectorial de polígonos, generados como zonas de influencia alrededor de las geometrías de los elementos vectoriales de una capa de entrada. Las geometrías de la capa de entrada pueden ser tanto de puntos, como de líneas o polígonos. Se pueden generar varios anillos concéntricos equidistantes en torno a las geometrías de entrada. Además, en el caso de geometrías de entrada poligonales el área de influencia puede ser exterior, interior o exterior e interior al polígono original. Este Geoproceso puede ser de gran utilidad para la realización de análisis de corredor. Por ejemplo: <UL> <LI>Qué zonas urbanos no tienen una parada de autobuses en un radio de 500 m.</LI> <LI>Qué zonas urbanas carecen de colegios en un radio de 1000 m.</LI> <LI>Qué pozos incumplen la normativa al no respetar la distancia mínima entre dos consecutivos.</LI> </UL> Etc. Nota: Las distancias del buffer hay que definirlas en metros. En caso de que el sistema de referencia no sea proyectado esta distancia se calcula a la altura del ecuador. El usuario deber? considerar la desviaci?n o bien convertir la cartograf?a a un sistema de referencia en metros. " |
|
30 |
description="Descripción" type="0"> |
|
31 |
<image description="" file="bufferdesc.png"> |
|
32 |
</image> |
|
33 |
</element> |
|
34 |
<element name="ADDITIONAL_INFO" text="" |
|
35 |
description="Información adicional" type="0"> |
|
36 |
</element> |
|
37 |
<element name="EXTENSION_AUTHOR" text="Nacho Brodin" |
|
38 |
description="Algoritmo creado por" type="0"> |
|
39 |
</element> |
|
40 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" |
|
41 |
type="0"> |
|
42 |
</element> |
|
43 |
<element name="USER_NOTES" text="" description="Notas de usuario" |
|
44 |
type="0"> |
|
45 |
</element> |
|
46 |
<element name="LAYER" text="" description="Capa de entrada" |
|
47 |
type="3"> |
|
48 |
</element> |
|
49 |
<element name="SELECTED_GEOM" text="" description="Geometrias seleccionadas" |
|
50 |
type="3"> |
|
51 |
</element> |
|
52 |
<element name="DISTANCE" text="" description="Distancia" type="3"> |
|
53 |
</element> |
|
54 |
<element name="FIELD" text="" description="Campo" type="3"> |
|
55 |
</element> |
|
56 |
<element name="ROUND_BORDER" text="" description="Borde redondeado" |
|
57 |
type="3"> |
|
58 |
</element> |
|
59 |
<element name="AREA" text="" description="Areas de influencia" |
|
60 |
type="3"> |
|
61 |
</element> |
|
62 |
<element name="RING_NUMBER" text="" description="Número de anillos" |
|
63 |
type="3"> |
|
64 |
</element> |
|
65 |
<element name="OUTPUT_DESCRIPTION" text="" description="Descripción" |
|
66 |
type="2"> |
|
67 |
</element> |
|
68 |
<element name="RESULT" text="" description="Buffer" type="2"> |
|
69 |
</element> |
|
70 |
</help> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/resources/help/BufferAlgorithm_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" |
|
29 |
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. Note: The buffer distance has to be defined in meters. If the reference system is not projected, this distance is calculated in the Ecuador. The user should be consider the deviation, or convert the cartography into a reference system in meters." |
|
30 |
description="Descripción" type="0"> |
|
31 |
<image description="" file="bufferdesc.png"> |
|
32 |
</image> |
|
33 |
</element> |
|
34 |
<element name="ADDITIONAL_INFO" text="" |
|
35 |
description="Información adicional" type="0"> |
|
36 |
</element> |
|
37 |
<element name="EXTENSION_AUTHOR" text="Nacho Brodin" |
|
38 |
description="Algoritmo creado por" type="0"> |
|
39 |
</element> |
|
40 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" |
|
41 |
type="0"> |
|
42 |
</element> |
|
43 |
<element name="USER_NOTES" text="" description="Notas de usuario" |
|
44 |
type="0"> |
|
45 |
</element> |
|
46 |
<element name="LAYER" text="" description="Capa de entrada" |
|
47 |
type="3"> |
|
48 |
</element> |
|
49 |
<element name="SELECTED_GEOM" text="" description="Geometrias seleccionadas" |
|
50 |
type="3"> |
|
51 |
</element> |
|
52 |
<element name="DISTANCE" text="" description="Distancia" type="3"> |
|
53 |
</element> |
|
54 |
<element name="FIELD" text="" description="Campo" type="3"> |
|
55 |
</element> |
|
56 |
<element name="ROUND_BORDER" text="" description="Borde redondeado" |
|
57 |
type="3"> |
|
58 |
</element> |
|
59 |
<element name="AREA" text="" description="Areas de influencia" |
|
60 |
type="3"> |
|
61 |
</element> |
|
62 |
<element name="RING_NUMBER" text="" description="Número de anillos" |
|
63 |
type="3"> |
|
64 |
</element> |
|
65 |
<element name="OUTPUT_DESCRIPTION" text="" description="Descripción" |
|
66 |
type="2"> |
|
67 |
</element> |
|
68 |
<element name="RESULT" text="" description="Buffer" type="2"> |
|
69 |
</element> |
|
70 |
</help> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.geoprocess.algorithm.buffer.BufferLibrary |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.262/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/java/org/gvsig/geoprocess/algorithm/buffer/BufferParametersPanel.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.buffer; |
|
25 |
|
|
26 |
import java.awt.BorderLayout; |
|
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.List; |
|
34 |
|
|
35 |
import javax.swing.BorderFactory; |
|
36 |
import javax.swing.ButtonGroup; |
|
37 |
import javax.swing.ComboBoxModel; |
|
38 |
import javax.swing.DefaultComboBoxModel; |
|
39 |
import javax.swing.JCheckBox; |
|
40 |
import javax.swing.JComboBox; |
|
41 |
import javax.swing.JLabel; |
|
42 |
import javax.swing.JPanel; |
|
43 |
import javax.swing.JRadioButton; |
|
44 |
import javax.swing.JScrollPane; |
|
45 |
import javax.swing.JTextField; |
|
46 |
|
|
47 |
import org.gvsig.geoprocess.lib.api.GeoProcessLocator; |
|
48 |
import org.gvsig.geoprocess.sextante.gui.algorithm.AlgorithmOutputPanel; |
|
49 |
|
|
50 |
import es.unex.sextante.core.GeoAlgorithm; |
|
51 |
import es.unex.sextante.core.ObjectAndDescription; |
|
52 |
import es.unex.sextante.core.OutputObjectsSet; |
|
53 |
import es.unex.sextante.core.ParametersSet; |
|
54 |
import es.unex.sextante.core.Sextante; |
|
55 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
56 |
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel; |
|
57 |
import es.unex.sextante.gui.algorithm.OutputChannelSelectionPanel; |
|
58 |
import es.unex.sextante.gui.core.SextanteGUI; |
|
59 |
import es.unex.sextante.outputs.Output; |
|
60 |
|
|
61 |
/** |
|
62 |
* Panel for buffer algorithm |
|
63 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
64 |
*/ |
|
65 |
public class BufferParametersPanel extends GeoAlgorithmParametersPanel implements ActionListener { |
|
66 |
private static final long serialVersionUID = 1L; |
|
67 |
private final int marginSides = 15; |
|
68 |
private final int marginBottom = 8; |
|
69 |
private GeoAlgorithm m_Algorithm = null; |
|
70 |
private JComboBox layers = null; |
|
71 |
private JComboBox fields = null; |
|
72 |
private JComboBox influenceAreas = null; |
|
73 |
private JComboBox radialBuffers = null; |
|
74 |
private JCheckBox selectionOnly = null; |
|
75 |
private JCheckBox dissolveEntities = null; |
|
76 |
private JCheckBox roundBorder = null; |
|
77 |
private JTextField distance = null; |
|
78 |
private JRadioButton selectDistance = null; |
|
79 |
private JRadioButton selectField = null; |
|
80 |
|
|
81 |
private List<String> fieldList = new ArrayList<String>(); |
|
82 |
private AlgorithmOutputPanel algorithmOutputPanel = null; |
|
83 |
private OutputChannelSelectionPanel outputChannelSelectionPanel; |
|
84 |
private JPanel outputPanel; |
|
85 |
|
|
86 |
public BufferParametersPanel() { |
|
87 |
super(); |
|
88 |
} |
|
89 |
|
|
90 |
public void init(GeoAlgorithm algorithm) { |
|
91 |
m_Algorithm = algorithm; |
|
92 |
initGUI(); |
|
93 |
} |
|
94 |
|
|
95 |
private void initGUI() { |
|
96 |
this.setLayout(new BorderLayout()); |
|
97 |
this.add(getMainJScrollPane(), BorderLayout.CENTER); |
|
98 |
} |
|
99 |
|
|
100 |
private JScrollPane getMainJScrollPane() { |
|
101 |
JPanel panel = new JPanel(); |
|
102 |
GridBagLayout gbl = new GridBagLayout(); |
|
103 |
panel.setLayout(gbl); |
|
104 |
|
|
105 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
106 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
107 |
gbc.weightx = 1.0; |
|
108 |
gbc.gridx = 0; |
|
109 |
gbc.gridy = 0; |
|
110 |
gbc.insets = new Insets(0, marginSides, 0, marginSides); |
|
111 |
panel.add(getInputPanel(), gbc); |
|
112 |
|
|
113 |
gbc.gridy = 1; |
|
114 |
panel.add(getOptionsPanel(), gbc); |
|
115 |
|
|
116 |
gbc.gridy = 2; |
|
117 |
panel.add(getOutputsPanel(), gbc); |
|
118 |
JScrollPane scrollPane = new JScrollPane(panel); |
|
119 |
return scrollPane; |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* Gets the output panel (SEXTANTE) |
|
124 |
* @return |
|
125 |
*/ |
|
126 |
private JPanel getOutputChannelSelectionPanel() { |
|
127 |
if(outputPanel == null) { |
|
128 |
try { |
|
129 |
outputPanel = new JPanel(); |
|
130 |
outputPanel.setLayout(new BorderLayout()); |
|
131 |
final OutputObjectsSet ooSet = m_Algorithm.getOutputObjects(); |
|
132 |
final Output out = ooSet.getOutput(BufferAlgorithm.RESULT); |
|
133 |
outputChannelSelectionPanel = new OutputChannelSelectionPanel(out, m_Algorithm.getParameters()); |
|
134 |
outputPanel.add(new JLabel(" " + GeoProcessLocator.getGeoProcessManager().getTranslation("Buffer") + |
|
135 |
" [" + GeoProcessLocator.getGeoProcessManager().getTranslation("Vectorial") + |
|
136 |
"] "), BorderLayout.WEST); |
|
137 |
outputPanel.add(outputChannelSelectionPanel, BorderLayout.CENTER); |
|
138 |
} catch (final Exception e) { |
|
139 |
Sextante.addErrorToLog(e); |
|
140 |
} |
|
141 |
} |
|
142 |
return outputPanel; |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* Gets the output panel |
|
147 |
* @return |
|
148 |
*/ |
|
149 |
@SuppressWarnings("unused") |
|
150 |
private AlgorithmOutputPanel getAlgorithmOutputPanel() { |
|
151 |
if(algorithmOutputPanel == null) |
|
152 |
algorithmOutputPanel = new AlgorithmOutputPanel(); |
|
153 |
return algorithmOutputPanel; |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Gets a new input panel |
|
158 |
* @param text |
|
159 |
* @param combo |
|
160 |
* @return |
|
161 |
*/ |
|
162 |
public JPanel getOutputsPanel() { |
|
163 |
JPanel panel = new JPanel(); |
|
164 |
GridBagLayout gbl = new GridBagLayout(); |
|
165 |
panel.setLayout(gbl); |
|
166 |
panel.setBorder(BorderFactory.createTitledBorder(GeoProcessLocator.getGeoProcessManager().getTranslation("outputs"))); |
|
167 |
|
|
168 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
169 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
170 |
gbc.weightx = 1.0; |
|
171 |
gbc.insets = new Insets(0, marginSides, marginBottom, marginSides); |
|
172 |
panel.add(getOutputChannelSelectionPanel(), gbc); |
|
173 |
|
|
174 |
return panel; |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
178 |
* Gets a new input panel |
|
179 |
* @param text |
|
180 |
* @param combo |
|
181 |
* @return |
|
182 |
*/ |
|
183 |
public JPanel getInputPanel() { |
|
184 |
JPanel panel = new JPanel(); |
|
185 |
GridBagLayout gbl = new GridBagLayout(); |
|
186 |
panel.setLayout(gbl); |
|
187 |
panel.setBorder(BorderFactory.createTitledBorder(GeoProcessLocator.getGeoProcessManager().getTranslation("input"))); |
|
188 |
|
|
189 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
190 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
191 |
gbc.weightx = 1.0; |
|
192 |
gbc.insets = new Insets(0, marginSides, marginBottom, marginSides); |
|
193 |
panel.add(getComboLayers(), gbc); |
|
194 |
|
|
195 |
return panel; |
|
196 |
} |
|
197 |
|
|
198 |
/** |
|
199 |
* Gets a new options panel |
|
200 |
* @param text |
|
201 |
* @param combo |
|
202 |
* @return |
|
203 |
*/ |
|
204 |
public JPanel getOptionsPanel() { |
|
205 |
JPanel panel = new JPanel(); |
|
206 |
GridBagLayout gbl = new GridBagLayout(); |
|
207 |
panel.setLayout(gbl); |
|
208 |
panel.setBorder(BorderFactory.createTitledBorder(GeoProcessLocator.getGeoProcessManager().getTranslation("options"))); |
|
209 |
|
|
210 |
ButtonGroup group = new ButtonGroup(); |
|
211 |
group.add(getRadioSelectDistance()); |
|
212 |
group.add(getRadioSelectField()); |
|
213 |
|
|
214 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
215 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
216 |
gbc.weightx = 1.0; |
|
217 |
gbc.insets = new Insets(0, marginSides, marginBottom, marginSides); |
|
218 |
panel.add(getRadioSelectField(), gbc); |
|
219 |
|
|
220 |
gbc.gridy = 1; |
|
221 |
gbc.insets = new Insets(0, marginSides + 10, marginBottom, marginSides); |
|
222 |
panel.add(getComboFields(), gbc); |
|
223 |
|
|
224 |
gbc.gridy = 2; |
|
225 |
gbc.insets = new Insets(0, marginSides, marginBottom, marginSides); |
|
226 |
panel.add(getRadioSelectDistance(), gbc); |
|
227 |
|
|
228 |
gbc.gridy = 3; |
|
229 |
gbc.insets = new Insets(0, marginSides + 10, marginBottom, marginSides); |
|
230 |
panel.add(getTextDistance(), gbc); |
|
231 |
|
|
232 |
gbc.gridy = 4; |
|
233 |
gbc.insets = new Insets(0, marginSides, marginBottom, marginSides); |
|
234 |
panel.add(getCheckSelectedGeom(), gbc); |
|
235 |
|
|
236 |
gbc.gridy = 5; |
|
237 |
panel.add(getCheckDissolveEntities(), gbc); |
|
238 |
|
|
239 |
gbc.gridy = 6; |
|
240 |
panel.add(getCheckRoundBorder(), gbc); |
|
241 |
|
|
242 |
gbc.gridy = 7; |
|
243 |
panel.add(getComboInfluenceAreas(), gbc); |
|
244 |
|
|
245 |
gbc.gridy = 8; |
|
246 |
panel.add(getComboRadialBuffers(), gbc); |
|
247 |
|
|
248 |
checkLineLayer(); |
|
249 |
|
|
250 |
return panel; |
|
251 |
} |
|
252 |
|
|
253 |
/** |
|
254 |
* Gets a ComboBox |
|
255 |
* @return |
|
256 |
*/ |
|
257 |
public JComboBox getComboLayers() { |
|
258 |
if(layers == null) { |
|
259 |
layers = new JComboBox(); |
|
260 |
ComboBoxModel comboModel = new DefaultComboBoxModel(getLayerList()); |
|
261 |
layers.setModel(comboModel); |
|
262 |
layers.addActionListener(this); |
|
263 |
} |
|
264 |
return layers; |
|
265 |
} |
|
266 |
|
|
267 |
/** |
|
268 |
* Gets a influence areas ComboBox |
|
269 |
* @return |
|
270 |
*/ |
|
271 |
public JComboBox getComboInfluenceAreas() { |
|
272 |
if(influenceAreas == null) { |
|
273 |
influenceAreas = new JComboBox(); |
|
274 |
for (int i = 0; i < BufferAlgorithm.sOptions.length; i++) { |
|
275 |
influenceAreas.addItem(BufferAlgorithm.sOptions[i]); |
|
276 |
} |
|
277 |
influenceAreas.addActionListener(this); |
|
278 |
} |
|
279 |
return influenceAreas; |
|
280 |
} |
|
281 |
|
|
282 |
/** |
|
283 |
* Gets a influence areas ComboBox |
|
284 |
* @return |
|
285 |
*/ |
|
286 |
public JComboBox getComboRadialBuffers() { |
|
287 |
if(radialBuffers == null) { |
|
288 |
radialBuffers = new JComboBox(); |
|
289 |
radialBuffers.addItem(BufferAlgorithm.BUFFER_OUTSIDE_POLY + 1 + ""); |
|
290 |
radialBuffers.addItem(BufferAlgorithm.BUFFER_INSIDE_POLY + 1 + ""); |
|
291 |
radialBuffers.addItem(BufferAlgorithm.BUFFER_INSIDE_OUTSIDE_POLY + 1 + ""); |
|
292 |
radialBuffers.addActionListener(this); |
|
293 |
} |
|
294 |
return radialBuffers; |
|
295 |
} |
|
296 |
|
|
297 |
/** |
|
298 |
* Gets a CheckBox |
|
299 |
* @return |
|
300 |
*/ |
|
301 |
public JCheckBox getCheckSelectedGeom() { |
|
302 |
if(selectionOnly == null) { |
|
303 |
selectionOnly = new JCheckBox(GeoProcessLocator.getGeoProcessManager().getTranslation("Selected_geometries")); |
|
304 |
} |
|
305 |
return selectionOnly; |
|
306 |
} |
|
307 |
|
|
308 |
/** |
|
309 |
* Gets a CheckBox |
|
310 |
* @return |
|
311 |
*/ |
|
312 |
public JCheckBox getCheckDissolveEntities() { |
|
313 |
if(dissolveEntities == null) { |
|
314 |
dissolveEntities = new JCheckBox(GeoProcessLocator.getGeoProcessManager().getTranslation("Dissolve_entities")); |
|
315 |
} |
|
316 |
return dissolveEntities; |
|
317 |
} |
|
318 |
|
|
319 |
/** |
|
320 |
* Gets a CheckBox |
|
321 |
* @return |
|
322 |
*/ |
|
323 |
public JCheckBox getCheckRoundBorder() { |
|
324 |
if(roundBorder == null) { |
|
325 |
roundBorder = new JCheckBox(GeoProcessLocator.getGeoProcessManager().getTranslation("Round_border")); |
|
326 |
} |
|
327 |
return roundBorder; |
|
328 |
} |
|
329 |
|
|
330 |
/** |
|
331 |
* Gets a ComboBox |
|
332 |
* @return |
|
333 |
*/ |
|
334 |
public JComboBox getComboFields() { |
|
335 |
if(fields == null) { |
|
336 |
fields = new JComboBox(); |
|
337 |
loadFieldsInAreaCombo(); |
|
338 |
fields.setEnabled(true); |
|
339 |
} |
|
340 |
return fields; |
|
341 |
} |
|
342 |
|
|
343 |
private void loadFieldsInAreaCombo() { |
|
344 |
List<String> fieldList = getFieldList(); |
|
345 |
getComboFields().removeAllItems(); |
|
346 |
for (int i = 0; i < fieldList.size(); i++) |
|
347 |
getComboFields().addItem(fieldList.get(i)); |
|
348 |
} |
|
349 |
|
|
350 |
private void checkLineLayer() { |
|
351 |
IVectorLayer vectorLyr = getSelectedVectorLayer(); |
|
352 |
if(vectorLyr.getShapeType() == IVectorLayer.SHAPE_TYPE_LINE || vectorLyr.getShapeType() == IVectorLayer.SHAPE_TYPE_POINT) { |
|
353 |
getComboInfluenceAreas().setSelectedIndex(BufferAlgorithm.BUFFER_OUTSIDE_POLY); |
|
354 |
getComboInfluenceAreas().setEnabled(false); |
|
355 |
} else { |
|
356 |
getComboInfluenceAreas().setEnabled(true); |
|
357 |
} |
|
358 |
} |
|
359 |
|
|
360 |
/** |
|
361 |
* Gets a CheckBox |
|
362 |
* @return |
|
363 |
*/ |
|
364 |
public JTextField getTextDistance() { |
|
365 |
if(distance == null) { |
|
366 |
distance = new JTextField("0.0"); |
|
367 |
distance.setEnabled(false); |
|
368 |
} |
|
369 |
return distance; |
|
370 |
} |
|
371 |
|
|
372 |
/** |
|
373 |
* Gets a JRadioButton |
|
374 |
* @return |
|
375 |
*/ |
|
376 |
public JRadioButton getRadioSelectDistance() { |
|
377 |
if(selectDistance == null) { |
|
378 |
selectDistance = new JRadioButton(GeoProcessLocator.getGeoProcessManager().getTranslation("area_distance")); |
|
379 |
selectDistance.addActionListener(this); |
|
380 |
selectDistance.setSelected(false); |
|
381 |
} |
|
382 |
return selectDistance; |
|
383 |
} |
|
384 |
|
|
385 |
/** |
|
386 |
* Gets a JRadioButton |
|
387 |
* @return |
|
388 |
*/ |
|
389 |
public JRadioButton getRadioSelectField() { |
|
390 |
if(selectField == null) { |
|
391 |
selectField = new JRadioButton(GeoProcessLocator.getGeoProcessManager().getTranslation("area_field")); |
|
392 |
selectField.addActionListener(this); |
|
393 |
selectField.setSelected(true); |
|
394 |
} |
|
395 |
return selectField; |
|
396 |
} |
|
397 |
|
|
398 |
//------------------------------------------------------------ |
|
399 |
|
|
400 |
/* |
|
401 |
* (non-Javadoc) |
|
402 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
403 |
*/ |
|
404 |
public void actionPerformed(ActionEvent e) { |
|
405 |
if(e.getSource() == getRadioSelectDistance()) { |
|
406 |
getTextDistance().setEnabled(true); |
|
407 |
getComboFields().setEnabled(false); |
|
408 |
} |
|
409 |
|
|
410 |
if(e.getSource() == getRadioSelectField()) { |
|
411 |
getTextDistance().setEnabled(false); |
|
412 |
getTextDistance().setText("0.0"); |
|
413 |
getComboFields().setEnabled(true); |
|
414 |
} |
|
415 |
|
|
416 |
if(e.getSource() == getComboLayers()) { |
|
417 |
loadFieldsInAreaCombo(); |
|
418 |
checkLineLayer(); |
|
419 |
} |
|
420 |
} |
|
421 |
|
|
422 |
@Override |
|
423 |
public void assignParameters() { |
|
424 |
try { |
|
425 |
ParametersSet params = m_Algorithm.getParameters(); |
|
426 |
params.getParameter(BufferAlgorithm.LAYER).setParameterValue(getSelectedVectorLayer()); |
|
427 |
params.getParameter(BufferAlgorithm.FIELD).setParameterValue(getFieldPosition()); |
|
428 |
params.getParameter(BufferAlgorithm.FIELD).setParameterValue(getFieldName()); |
|
429 |
params.getParameter(BufferAlgorithm.SELECTED_GEOM).setParameterValue(getCheckSelectedGeom().isSelected()); |
|
430 |
double dist = 0; |
|
431 |
try { |
|
432 |
dist = new Double(getTextDistance().getText()); |
|
433 |
} catch(NumberFormatException e) { |
|
434 |
} |
|
435 |
params.getParameter(BufferAlgorithm.DISTANCE).setParameterValue(dist); |
|
436 |
params.getParameter(BufferAlgorithm.DISSOLVE).setParameterValue(getCheckDissolveEntities().isSelected()); |
|
437 |
params.getParameter(BufferAlgorithm.ROUND_BORDER).setParameterValue(getCheckRoundBorder().isSelected()); |
|
438 |
params.getParameter(BufferAlgorithm.AREA).setParameterValue(getComboInfluenceAreas().getSelectedIndex()); |
|
439 |
params.getParameter(BufferAlgorithm.RING_NUMBER).setParameterValue(getComboRadialBuffers().getSelectedIndex()); |
|
440 |
|
|
441 |
OutputObjectsSet ooSet = m_Algorithm.getOutputObjects(); |
|
442 |
Output out = ooSet.getOutput(BufferAlgorithm.RESULT); |
|
443 |
|
|
444 |
//Reponer estas l?neas para cambiar el panel de salida y comentar la siguiente |
|
445 |
//AlgorithmOutputPanel fsp = getAlgorithmOutputPanel(); |
|
446 |
//out.setOutputChannel(new CompositeSourceOutputChannel(fsp.getOutputParameters())); |
|
447 |
out.setOutputChannel(outputChannelSelectionPanel.getOutputChannel()); |
|
448 |
} catch (Exception e) { |
|
449 |
Sextante.addErrorToLog(e); |
|
450 |
} |
|
451 |
} |
|
452 |
|
|
453 |
|
|
454 |
|
|
455 |
@Override |
|
456 |
public void setOutputValue(String arg0, String arg1) { |
|
457 |
|
|
458 |
} |
|
459 |
|
Also available in: Unified diff