Revision 879
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.61/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.61/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.61/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.61/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.61/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 |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.61/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 |
private FeatureStore storeOverlay = null; |
|
69 |
protected GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
70 |
private Logger log = LoggerFactory.getLogger(IntersectionOperation.class); |
|
71 |
private boolean errorInfo = false; |
|
72 |
|
|
73 |
public IntersectionOperation(FeatureStore overlayLayer, AbstractSextanteGeoProcess p) { |
|
74 |
super(p); |
|
75 |
this.storeOverlay = overlayLayer; |
|
76 |
} |
|
77 |
|
|
78 |
public boolean getErrorInfo() { |
|
79 |
return errorInfo; |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* Computes intersection between the geometry and the overlay layer. The fields of the |
|
84 |
* intersected features will be added. |
|
85 |
* @param g |
|
86 |
* @param featureInput |
|
87 |
* @return |
|
88 |
*/ |
|
89 |
@SuppressWarnings({ "unchecked", "deprecation" }) |
|
90 |
public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature featureInput) { |
|
91 |
if(g == null) |
|
92 |
return lastEditFeature; |
|
93 |
|
|
94 |
FeatureSet features = null; |
|
95 |
Iterator it = null; |
|
96 |
try { |
|
97 |
if(selectedGeomOverlay) { |
|
98 |
features = (FeatureSet)storeOverlay.getSelection(); |
|
99 |
} else { |
|
100 |
features = storeOverlay.getFeatureSet(); |
|
101 |
} |
|
102 |
it = features.iterator(); |
|
103 |
} catch (DataException e) { |
|
104 |
Sextante.addErrorToLog(e); |
|
105 |
return lastEditFeature; |
|
106 |
} |
|
107 |
|
|
108 |
while( it.hasNext() ) { |
|
109 |
Feature featureOverlay = (Feature)it.next(); |
|
110 |
List<org.gvsig.fmap.geom.Geometry> geomList = featureOverlay.getGeometries(); |
|
111 |
if(geomList == null) { |
|
112 |
org.gvsig.fmap.geom.Geometry geom = featureOverlay.getDefaultGeometry(); |
|
113 |
lastEditFeature = intersection(g, geom, featureInput, featureOverlay); |
|
114 |
continue; |
|
115 |
} |
|
116 |
|
|
117 |
Iterator<org.gvsig.fmap.geom.Geometry> itGeom = geomList.iterator(); |
|
118 |
while(itGeom.hasNext()) { |
|
119 |
org.gvsig.fmap.geom.Geometry geom = itGeom.next(); |
|
120 |
lastEditFeature = intersection(g, geom, featureInput, featureOverlay); |
|
121 |
} |
|
122 |
} |
|
123 |
// it.dispose(); |
|
124 |
return lastEditFeature; |
|
125 |
} |
|
126 |
|
|
127 |
private EditableFeature intersection( org.gvsig.fmap.geom.Geometry g1, |
|
128 |
org.gvsig.fmap.geom.Geometry g2, |
|
129 |
Feature featureInput, |
|
130 |
Feature featureOverlay) { |
|
131 |
if(g1 == null || g2 == null){ |
|
132 |
return null; |
|
133 |
} |
|
134 |
Geometry overlaysGeom = null; |
|
135 |
Geometry jtsGeom = null; |
|
136 |
int outPutType = TYPES.SURFACE; |
|
137 |
|
|
138 |
try { |
|
139 |
outPutType = persister.getOutputFeatureStore().getDefaultFeatureType() |
|
140 |
.getDefaultGeometryAttribute().getGeomType().getType(); |
|
141 |
} catch (DataException e2) { |
|
142 |
Sextante.addErrorToLog(e2); |
|
143 |
} |
|
144 |
|
|
145 |
try { |
|
146 |
if( ((g1 instanceof Surface && g2 instanceof Curve) || |
|
147 |
(g2 instanceof Surface && g1 instanceof Curve)) && |
|
148 |
outPutType == TYPES.MULTIPOINT) { |
|
149 |
org.gvsig.fmap.geom.Geometry overGeom = (g1 instanceof Surface) ? g1 : g2; |
|
150 |
jtsGeom = (g1 instanceof Surface) ? GeometryUtil.geomToJTS(g2) : GeometryUtil.geomToJTS(g1); |
|
151 |
overlaysGeom = (Geometry)overGeom.invokeOperation("toJTSLineString", null); |
|
152 |
} else { |
|
153 |
if( g1 instanceof Surface && |
|
154 |
g2 instanceof Surface && |
|
155 |
(outPutType == TYPES.MULTIPOINT)) { |
|
156 |
jtsGeom = (Geometry)g1.invokeOperation("toJTSLineString", null); |
|
157 |
overlaysGeom = (Geometry)g2.invokeOperation("toJTSLineString", null); |
|
158 |
} else { |
|
159 |
jtsGeom = GeometryUtil.geomToJTS(g1); |
|
160 |
overlaysGeom = GeometryUtil.geomToJTS(g2); |
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
if(!jtsGeom.getEnvelope().intersects(overlaysGeom.getEnvelope())) |
|
165 |
return lastEditFeature; |
|
166 |
|
|
167 |
if(jtsGeom.intersects(overlaysGeom)) { |
|
168 |
Geometry newGeom = EnhancedPrecisionOp.intersection(jtsGeom, overlaysGeom); |
|
169 |
if(!newGeom.isEmpty()) { |
|
170 |
if(typesMatch(outPutType, newGeom) || newGeom instanceof GeometryCollection) { |
|
171 |
lastEditFeature = persister.addFeature(featureInput, featureOverlay, newGeom); |
|
172 |
} else { |
|
173 |
//Para intersecciones entre pol?gonos cuando la salida es de tipo l?nea |
|
174 |
//la generamos a partir del pol?gono resultante de la intersecci?n |
|
175 |
if( g1 instanceof Surface && |
|
176 |
g2 instanceof Surface && |
|
177 |
outPutType == TYPES.MULTICURVE && |
|
178 |
(newGeom instanceof Polygon || newGeom instanceof MultiPolygon)) { |
|
179 |
GeometryOperationContext ctx = new GeometryOperationContext(); |
|
180 |
ctx.setAttribute(FromJTS.PARAM, newGeom); |
|
181 |
org.gvsig.fmap.geom.Geometry newDalGeom = (org.gvsig.fmap.geom.Geometry)geomManager.invokeOperation(FromJTS.NAME, ctx); |
|
182 |
newGeom = (Geometry)newDalGeom.invokeOperation("toJTSLineString", null); |
|
183 |
} |
|
184 |
|
|
185 |
lastEditFeature = persister.addFeature(featureInput, featureOverlay, newGeom); |
|
186 |
} |
|
187 |
} |
|
188 |
} |
|
189 |
} catch (CreateGeometryException e) { |
|
190 |
Sextante.addErrorToLog(e); |
|
191 |
} catch (DataException e) { |
|
192 |
Sextante.addErrorToLog(e); |
|
193 |
} catch (GeometryOperationNotSupportedException e1) { |
|
194 |
Sextante.addErrorToLog(e1); |
|
195 |
} catch (GeometryOperationException e1) { |
|
196 |
Sextante.addErrorToLog(e1); |
|
197 |
} catch (com.vividsolutions.jts.geom.TopologyException e) { |
|
198 |
errorInfo = true; |
|
199 |
log.info("Problems operating intersection: ", e); |
|
200 |
} |
|
201 |
return lastEditFeature; |
|
202 |
} |
|
203 |
|
|
204 |
private boolean typesMatch(int dalType, Geometry newGeom) { |
|
205 |
return |
|
206 |
((dalType == TYPES.MULTICURVE && |
|
207 |
(newGeom instanceof MultiLineString || newGeom instanceof LineString)) || |
|
208 |
(dalType == TYPES.MULTIPOINT && |
|
209 |
(newGeom instanceof MultiPoint || newGeom instanceof Point)) || |
|
210 |
(dalType == TYPES.MULTISURFACE && |
|
211 |
(newGeom instanceof Polygon || newGeom instanceof MultiPolygon)) || |
|
212 |
(dalType == TYPES.CURVE && newGeom instanceof LineString) || |
|
213 |
(dalType == TYPES.SURFACE && newGeom instanceof Polygon) || |
|
214 |
(dalType == TYPES.POINT && newGeom instanceof Point)); |
|
215 |
|
|
216 |
} |
|
217 |
|
|
218 |
/** |
|
219 |
* clips feature's geometry with the clipping geometry, preserving |
|
220 |
* feature's original attributes. |
|
221 |
* If feature's geometry doesn't touch clipping geometry, it will be |
|
222 |
* ignored. |
|
223 |
*/ |
|
224 |
public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature featureInput) { |
|
225 |
} |
|
226 |
|
|
227 |
} |
|
228 |
|
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.61/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.61/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 |
|
|
40 |
/** |
|
41 |
* Intersection algorithm |
|
42 |
* <UL> |
|
43 |
* <LI>Pol-Pol: 3 layers (polygon, point, line)</LI> |
|
44 |
* <LI>Pol-Line: 2 layers (point, line)</LI> |
|
45 |
* <LI>Pol-Point: 1 layer (point)</LI> |
|
46 |
* <LI>Line-Point: 1 layer (point)</LI> |
|
47 |
* <LI>Line-Line: 2 layers (point, line)</LI> |
|
48 |
* <LI>Point-Point: 1 layer (point)</LI> |
|
49 |
* </UL> |
|
50 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
51 |
*/ |
|
52 |
public class IntersectionAlgorithm extends AbstractSextanteGeoProcess { |
|
53 |
|
|
54 |
public static final String RESULT_POL = "RESULT_POL"; |
|
55 |
public static final String RESULT_POINT = "RESULT_POINT"; |
|
56 |
public static final String RESULT_LINE = "RESULT_LINE"; |
|
57 |
public static final String LAYER = "LAYER"; |
|
58 |
public static final String INTER = "INTER"; |
|
59 |
public static final String SELECTGEOM_INPUT = "SELECTGEOM_INPUT"; |
|
60 |
public static final String SELECTGEOM_OVERLAY = "SELECTGEOM_OVERLAY"; |
|
61 |
|
|
62 |
/* |
|
63 |
* (non-Javadoc) |
|
64 |
* @see es.unex.sextante.core.GeoAlgorithm#defineCharacteristics() |
|
65 |
*/ |
|
66 |
public void defineCharacteristics() { |
|
67 |
setName(getTranslation("Intersection")); |
|
68 |
setGroup(getTranslation("basic_vect_algorithms")); |
|
69 |
// setGeneratesUserDefinedRasterOutput(false); |
|
70 |
|
|
71 |
try { |
|
72 |
m_Parameters.addInputVectorLayer(LAYER, |
|
73 |
getTranslation("Input_layer"), |
|
74 |
IVectorLayer.SHAPE_TYPE_WRONG, |
|
75 |
true); |
|
76 |
m_Parameters.addInputVectorLayer(INTER, |
|
77 |
getTranslation("Overlays_layer"), |
|
78 |
IVectorLayer.SHAPE_TYPE_WRONG, |
|
79 |
true); |
|
80 |
m_Parameters.addBoolean(SELECTGEOM_INPUT, |
|
81 |
getTranslation("Selected_geometries_input_layer_inters"), false); |
|
82 |
m_Parameters.addBoolean(SELECTGEOM_OVERLAY, |
|
83 |
getTranslation("Selected_geometries_overlay_layer_inters"), false); |
|
84 |
} catch (RepeatedParameterNameException e) { |
|
85 |
Sextante.addErrorToLog(e); |
|
86 |
} |
|
87 |
addOutputVectorLayer(RESULT_POL, getTranslation("Intersection_polygon"), |
|
88 |
OutputVectorLayer.SHAPE_TYPE_POLYGON); |
|
89 |
addOutputVectorLayer(RESULT_LINE, getTranslation("Intersection_line"), |
|
90 |
OutputVectorLayer.SHAPE_TYPE_LINE); |
|
91 |
addOutputVectorLayer(RESULT_POINT, getTranslation("Intersection_point"), |
|
92 |
OutputVectorLayer.SHAPE_TYPE_POINT); |
|
93 |
} |
|
94 |
|
|
95 |
/* |
|
96 |
* (non-Javadoc) |
|
97 |
* @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm() |
|
98 |
*/ |
|
99 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
|
100 |
if(existsOutPutFile(IntersectionAlgorithm.RESULT_LINE, 0)) { |
|
101 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
102 |
} |
|
103 |
if(existsOutPutFile(IntersectionAlgorithm.RESULT_POINT, 0)) { |
|
104 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
105 |
} |
|
106 |
if(existsOutPutFile(IntersectionAlgorithm.RESULT_LINE, 0)) { |
|
107 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
108 |
} |
|
109 |
IVectorLayer inter = m_Parameters.getParameterValueAsVectorLayer(INTER); |
|
110 |
IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER); |
|
111 |
boolean selectedGeomInput = m_Parameters.getParameter(SELECTGEOM_INPUT).getParameterValueAsBoolean(); |
|
112 |
boolean selectedGeomOverlay = m_Parameters.getParameter(SELECTGEOM_OVERLAY).getParameterValueAsBoolean(); |
|
113 |
boolean error = false; |
|
114 |
|
|
115 |
try { |
|
116 |
error = computesIntersection(layer, inter, layer.getShapeType(), selectedGeomInput, selectedGeomOverlay); |
|
117 |
} catch (DataException e) { |
|
118 |
Sextante.addErrorToLog(e); |
|
119 |
return false; |
|
120 |
} |
|
121 |
|
|
122 |
if(getTaskMonitor().isCanceled()) |
|
123 |
return false; |
|
124 |
if(error) |
|
125 |
JOptionPane.showMessageDialog(null, |
|
126 |
getTranslation("problems_with_some_geometries"), "Error", |
|
127 |
JOptionPane.WARNING_MESSAGE); |
|
128 |
return true; |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* Builds a layer with the intersection between the input layer and the templateGeometry |
|
133 |
* @param layer |
|
134 |
* Input layer |
|
135 |
* @param templateGeometry |
|
136 |
* @param shapeType |
|
137 |
* Output shape type |
|
138 |
* @param selectedGeom |
|
139 |
* If it's true only selected geometries will be computed |
|
140 |
* @throws GeoAlgorithmExecutionException |
|
141 |
*/ |
|
142 |
private boolean computesIntersection(IVectorLayer layer, |
|
143 |
IVectorLayer overlay, |
|
144 |
int shapeType, |
|
145 |
boolean selectedGeomInput, |
|
146 |
boolean selectedGeomOverlay) throws DataException, GeoAlgorithmExecutionException { |
|
147 |
FeatureStore storeLayer = null; |
|
148 |
FeatureStore storeOverlay = null; |
|
149 |
if(layer instanceof FlyrVectIVectorLayer && |
|
150 |
overlay instanceof FlyrVectIVectorLayer) { |
|
151 |
storeLayer = ((FlyrVectIVectorLayer)layer).getFeatureStore(); |
|
152 |
storeOverlay = ((FlyrVectIVectorLayer)overlay).getFeatureStore(); |
|
153 |
} else |
|
154 |
return false; |
|
155 |
|
|
156 |
FeatureType featureType1 = storeLayer.getDefaultFeatureType(); |
|
157 |
FeatureType featureType2 = storeOverlay.getDefaultFeatureType(); |
|
158 |
|
|
159 |
FeatureStore outFeatStorePol = null; |
|
160 |
FeatureStore outFeatStoreLine = null; |
|
161 |
FeatureStore outFeatStorePoint = null; |
|
162 |
|
|
163 |
IntersectionOperation operation = new IntersectionOperation(storeOverlay, this); |
|
164 |
operation.setTaskStatus(getStatus()); |
|
165 |
|
|
166 |
//La de puntos se genera siempre |
|
167 |
outFeatStorePoint = |
|
168 |
buildOutPutStoreFromUnion(featureType1, featureType2, |
|
169 |
IVectorLayer.SHAPE_TYPE_POINT, |
|
170 |
getTranslation("Intersection_point"), RESULT_POINT); |
|
171 |
|
|
172 |
if (outFeatStorePoint != null) { |
|
173 |
getStatus().setTitle("Point"); |
|
174 |
operation.computesGeometryOperation(storeLayer, outFeatStorePoint, |
|
175 |
attrNames, selectedGeomInput, selectedGeomOverlay, true); |
|
176 |
} |
|
177 |
//La de pol?gonos solo si es intersecci?n entre pol?gonos |
|
178 |
if (isPolygon(storeLayer) && isPolygon(storeOverlay)) { |
|
179 |
outFeatStorePol = |
|
180 |
buildOutPutStoreFromUnion(featureType1, featureType2, |
|
181 |
IVectorLayer.SHAPE_TYPE_POLYGON, getTranslation("Intersection_polygon"), RESULT_POL); |
|
182 |
if (outFeatStorePol != null) { |
|
183 |
getStatus().setTitle("Polygon"); |
|
184 |
operation.computesGeometryOperation(storeLayer, |
|
185 |
outFeatStorePol, attrNames, selectedGeomInput, |
|
186 |
selectedGeomOverlay, true); |
|
187 |
} |
|
188 |
} |
|
189 |
|
|
190 |
//La capa de l?neas se genera cuando ning?na de las dos es de puntos |
|
191 |
if (!isPoint(storeLayer) && !isPoint(storeOverlay)) { |
|
192 |
outFeatStoreLine = |
|
193 |
buildOutPutStoreFromUnion(featureType1, featureType2, |
|
194 |
IVectorLayer.SHAPE_TYPE_LINE, getTranslation("Intersection_line"), RESULT_LINE); |
|
195 |
if (outFeatStoreLine != null) { |
|
196 |
getStatus().setTitle("Line"); |
|
197 |
operation.computesGeometryOperation(storeLayer, |
|
198 |
outFeatStoreLine, attrNames, selectedGeomInput, |
|
199 |
selectedGeomOverlay, true); |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
if(outFeatStorePol == null) { |
|
204 |
getNewVectorLayer(RESULT_POL, getTranslation("Null_polygon"), |
|
205 |
OutputVectorLayer.SHAPE_TYPE_POLYGON, new Class[]{Integer.class}, new String[]{""}); |
|
206 |
} |
|
207 |
|
|
208 |
if(outFeatStoreLine == null) { |
|
209 |
getNewVectorLayer(RESULT_LINE, getTranslation("Null_line"), |
|
210 |
OutputVectorLayer.SHAPE_TYPE_LINE, new Class[]{Integer.class}, new String[]{""}); |
|
211 |
} |
|
212 |
|
|
213 |
if(outFeatStorePoint == null) { |
|
214 |
getNewVectorLayer(RESULT_POINT, getTranslation("Null_point"), |
|
215 |
OutputVectorLayer.SHAPE_TYPE_POINT, new Class[]{Integer.class}, new String[]{""}); |
|
216 |
} |
|
217 |
|
|
218 |
return operation.getErrorInfo(); |
|
219 |
} |
|
220 |
|
|
221 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.61/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.61</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.61/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.61/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.61/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.61/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.61/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.61/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/java/org/gvsig/geoprocess/algorithm/buffer/InOutBufferOperation.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.util.ArrayList; |
|
27 |
import java.util.List; |
|
28 |
import java.util.Stack; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.exception.DataException; |
|
31 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
32 |
import org.gvsig.fmap.dal.feature.Feature; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
34 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
35 |
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil; |
|
36 |
import org.gvsig.geoprocess.algorithm.base.util.JTSFacade; |
|
37 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
38 |
|
|
39 |
import com.vividsolutions.jts.geom.Geometry; |
|
40 |
import com.vividsolutions.jts.geom.GeometryCollection; |
|
41 |
import com.vividsolutions.jts.geom.GeometryFactory; |
|
42 |
import com.vividsolutions.jts.geom.MultiPolygon; |
|
43 |
import com.vividsolutions.jts.geom.Polygon; |
|
44 |
import com.vividsolutions.jts.operation.buffer.BufferOp; |
|
45 |
import com.vividsolutions.jts.operation.buffer.BufferParameters; |
|
46 |
import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier; |
|
47 |
|
|
48 |
import es.unex.sextante.core.Sextante; |
|
49 |
|
|
50 |
/** |
|
51 |
* Buffer operation |
|
52 |
* |
|
53 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
54 |
*/ |
|
55 |
public class InOutBufferOperation extends BufferOperation { |
|
56 |
|
|
57 |
/** |
|
58 |
* Builds an instance of this operation. |
|
59 |
* |
|
60 |
* @param distance |
|
61 |
* @param layer |
|
62 |
* @param userDistance |
|
63 |
*/ |
|
64 |
public InOutBufferOperation(IDistance distance, |
|
65 |
FeatureStore inputStore, |
|
66 |
AbstractSextanteGeoProcess p, |
|
67 |
byte tableFields) { |
|
68 |
super(distance, inputStore, p, tableFields); |
|
69 |
} |
|
70 |
|
|
71 |
public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, |
|
72 |
Feature feature) { |
|
73 |
GeometryFactory geomFact = new GeometryFactory(); |
|
74 |
Geometry newGeom = null; |
|
75 |
Geometry previousExteriorRing = null; |
|
76 |
Geometry previousInteriorRing = null; |
|
77 |
Geometry originalGeometry = GeometryUtil.geomToJTS(g); |
|
78 |
Geometry inputParam = originalGeometry; |
|
79 |
distance.setFeature(feature); |
|
80 |
double bufferDistance = |
|
81 |
distance.getBufferDistance(projection, |
|
82 |
getDistanceUnits(), getMapUnits()); |
|
83 |
|
|
84 |
if (originalGeometry.getDimension() != 0) |
|
85 |
inputParam = |
|
86 |
TopologyPreservingSimplifier.simplify(originalGeometry, |
|
87 |
bufferDistance / 10d); |
|
88 |
|
|
89 |
for (int i = 1; i <= numberOfRadialBuffers; i++) { |
|
90 |
double distRing = i * bufferDistance; |
|
91 |
BufferOp bufOp = new BufferOp(inputParam); |
|
92 |
bufOp.setEndCapStyle(capBuffer == CAP_ROUND |
|
93 |
? BufferParameters.CAP_ROUND : BufferParameters.CAP_SQUARE); |
|
94 |
Geometry out = bufOp.getResultGeometry(distRing); |
|
95 |
Geometry in = bufOp.getResultGeometry(-1 * distRing); |
|
96 |
boolean collapsedInterior = verifyNilGeometry(in); |
|
97 |
if (previousExteriorRing == null || previousInteriorRing == null) { |
|
98 |
if (collapsedInterior) |
|
99 |
newGeom = out; |
|
100 |
else |
|
101 |
newGeom = JTSFacade.difference(out, in); |
|
102 |
} else { |
|
103 |
if (collapsedInterior) |
|
104 |
newGeom = JTSFacade.difference(out, previousExteriorRing); |
|
105 |
else { |
|
106 |
Geometry outRing = |
|
107 |
JTSFacade.difference(out, previousExteriorRing); |
|
108 |
Geometry inRing = |
|
109 |
JTSFacade.difference(previousInteriorRing, in); |
|
110 |
|
|
111 |
Geometry[] geomArray = new Geometry[] { outRing, inRing }; |
|
112 |
newGeom = geomFact.createGeometryCollection(geomArray); |
|
113 |
|
|
114 |
// FMap doesnt work with GeometryCollection, so we try to |
|
115 |
// pass to a MultiPolygon. |
|
116 |
List<Geometry> polygons = new ArrayList<Geometry>(); |
|
117 |
Stack<Geometry> stack = new Stack<Geometry>(); |
|
118 |
stack.push(newGeom); |
|
119 |
while (stack.size() != 0) { |
|
120 |
GeometryCollection geCol = |
|
121 |
(GeometryCollection) stack.pop(); |
|
122 |
|
|
123 |
for (int j = 0; j < geCol.getNumGeometries(); j++) { |
|
124 |
Geometry geometry = geCol.getGeometryN(j); |
|
125 |
if (geometry instanceof GeometryCollection) |
|
126 |
stack.push(geometry); |
|
127 |
if (geometry instanceof Polygon) |
|
128 |
polygons.add(geometry); |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
Polygon[] pols = new Polygon[polygons.size()]; |
|
133 |
pols = polygons.toArray(pols); |
|
134 |
MultiPolygon newSolution = |
|
135 |
geomFact.createMultiPolygon(pols); |
|
136 |
newGeom = newSolution; |
|
137 |
} |
|
138 |
} |
|
139 |
try { |
|
140 |
if (newGeom != null && !newGeom.isEmpty()) { |
|
141 |
if(getTableFieldStructure() == BufferAlgorithm.SOURCE_FIELDS) |
|
142 |
lastEditFeature = persister.addFeature(feature, newGeom); |
|
143 |
else |
|
144 |
lastEditFeature = persister.addFeature(newGeom, id, -1 * distRing, distRing); |
|
145 |
id++; |
|
146 |
} |
|
147 |
} catch (CreateGeometryException e) { |
|
148 |
Sextante.addErrorToLog(e); |
|
149 |
} catch (DataException e) { |
|
150 |
Sextante.addErrorToLog(e); |
|
151 |
} |
|
152 |
previousExteriorRing = out; |
|
153 |
if (!collapsedInterior) |
|
154 |
previousInteriorRing = in; |
|
155 |
} |
|
156 |
return lastEditFeature; |
|
157 |
} |
|
158 |
|
|
159 |
/* |
|
160 |
* (non-Javadoc) |
|
161 |
* |
|
162 |
* @see |
|
163 |
* org.gvsig.geoprocess.algorithm.base.core.GeometryOperation#invoke(org |
|
164 |
* .gvsig.fmap.geom.Geometry, org.gvsig.fmap.dal.feature.EditableFeature) |
|
165 |
*/ |
|
166 |
public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature feature) { |
|
167 |
invoke(g, (Feature) feature); |
|
168 |
} |
|
169 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.61/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/java/org/gvsig/geoprocess/algorithm/buffer/BufferOperation.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 org.cresques.cts.IProjection; |
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
29 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
30 |
import org.gvsig.fmap.dal.exception.DataException; |
|
31 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
32 |
import org.gvsig.fmap.dal.feature.Feature; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
34 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
35 |
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation; |
|
36 |
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil; |
|
37 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
38 |
|
|
39 |
import com.vividsolutions.jts.geom.Geometry; |
|
40 |
import com.vividsolutions.jts.geom.GeometryCollection; |
|
41 |
|
|
42 |
/** |
|
43 |
* Buffer operation |
|
44 |
* |
|
45 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
46 |
*/ |
|
47 |
public abstract class BufferOperation extends GeometryOperation { |
|
48 |
|
|
49 |
public static final byte CAP_SQUARE = 0; |
|
50 |
public static final byte CAP_ROUND = 1; |
|
51 |
|
|
52 |
protected byte capBuffer = CAP_ROUND; |
|
53 |
protected int numberOfRadialBuffers = 1; |
|
54 |
protected IDistance distance = null; |
|
55 |
protected int id = 0; |
|
56 |
protected IProjection projection = null; |
|
57 |
protected byte tableFieldStructure = BufferAlgorithm.SOURCE_FIELDS; |
|
58 |
|
|
59 |
public BufferOperation(IDistance distance, |
|
60 |
FeatureStore inputStore, |
|
61 |
AbstractSextanteGeoProcess p, |
|
62 |
byte tableFieldStructure) { |
|
63 |
super(p); |
|
64 |
this.distance = distance; |
|
65 |
try { |
|
66 |
this.projection = (IProjection) inputStore.getDefaultFeatureType().getDefaultSRS(); |
|
67 |
} catch (DataException e) { |
|
68 |
} |
|
69 |
this.tableFieldStructure = tableFieldStructure; |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* Verifys if a geometry buffer is null. |
|
74 |
* It is useful when you're working with internal buffers. If the internal |
|
75 |
* buffer distance is greater than the geometry radius, the buffer result |
|
76 |
* will be null. |
|
77 |
* |
|
78 |
* @param newGeometry |
|
79 |
* @return |
|
80 |
*/ |
|
81 |
protected boolean verifyNilGeometry(Geometry newGeometry) { |
|
82 |
if (newGeometry instanceof GeometryCollection) { |
|
83 |
if (((GeometryCollection) newGeometry).getNumGeometries() == 0) { |
|
84 |
// we have collapsed initial geometry |
|
85 |
return true; |
|
86 |
} |
|
87 |
} |
|
88 |
return false; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Adds a new feature |
|
93 |
* |
|
94 |
* @param feature |
|
95 |
* @param newGeom |
|
96 |
* @throws CreateGeometryException |
|
97 |
* @throws DataException |
|
98 |
* @deprecated No es necesario porque no hay diferencia entre las llamadas |
|
99 |
* entre ambos invoke |
|
100 |
*/ |
|
101 |
protected void addFeature(Feature feature, Geometry newGeom) |
|
102 |
throws CreateGeometryException, DataException { |
|
103 |
if (!(feature instanceof EditableFeature)) |
|
104 |
lastEditFeature = persister.addFeature(feature, newGeom); |
|
105 |
else { |
|
106 |
org.gvsig.fmap.geom.Geometry g = GeometryUtil.jtsToGeom(newGeom); |
|
107 |
persister |
|
108 |
.addGeometryToExistingFeature((EditableFeature) feature, g); |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* Sets type of cap flag |
|
114 |
* |
|
115 |
* @param typeOfCap |
|
116 |
*/ |
|
117 |
public void setTypeOfCap(byte typeOfCap) { |
|
118 |
capBuffer = typeOfCap; |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* Sets number of radial rings buffers |
|
123 |
* |
|
124 |
* @param number |
|
125 |
*/ |
|
126 |
public void setNumberOfRadialBuffers(int number) { |
|
127 |
numberOfRadialBuffers = number; |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* <p> |
|
132 |
* Gets the measurement unit used by this view port for the map. |
|
133 |
* </p> |
|
134 |
* |
|
135 |
* @return Returns the current map measure unit |
|
136 |
*/ |
|
137 |
protected int getMapUnits() { |
|
138 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
|
139 |
if (!(w instanceof AbstractViewPanel)) { |
|
140 |
IWindow[] wList = PluginServices.getMDIManager().getAllWindows(); |
|
141 |
for (int i = 0; i < wList.length; i++) { |
|
142 |
if (wList[i] instanceof AbstractViewPanel) |
|
143 |
w = (IWindow) wList[i]; |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
147 |
if (w != null && w instanceof AbstractViewPanel) { |
|
148 |
IProjection proj = |
|
149 |
((AbstractViewPanel) w).getMapControl().getViewPort() |
|
150 |
.getProjection(); |
|
151 |
if (proj.isProjected()) |
|
152 |
return ((AbstractViewPanel) w).getMapControl().getViewPort() |
|
153 |
.getMapUnits(); |
|
154 |
} |
|
155 |
return 1; |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* <p> |
|
160 |
* Returns the measurement unit of this view port used for measuring |
|
161 |
* distances and displaying information. |
|
162 |
* </p> |
|
163 |
* |
|
164 |
* @return the measurement unit of this view used for measuring distances |
|
165 |
* and displaying information |
|
166 |
*/ |
|
167 |
protected int getDistanceUnits() { |
|
168 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
|
169 |
if (!(w instanceof AbstractViewPanel)) { |
|
170 |
IWindow[] wList = PluginServices.getMDIManager().getAllWindows(); |
|
171 |
for (int i = 0; i < wList.length; i++) { |
|
172 |
if (wList[i] instanceof AbstractViewPanel) |
|
173 |
w = (IWindow) wList[i]; |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
if (w != null && w instanceof AbstractViewPanel) |
|
178 |
return ((AbstractViewPanel) w).getMapControl().getViewPort() |
|
179 |
.getDistanceUnits(); |
|
180 |
else |
|
181 |
return 1; |
|
182 |
} |
|
183 |
|
|
184 |
public byte getTableFieldStructure() { |
|
185 |
return tableFieldStructure; |
|
186 |
} |
|
187 |
|
|
188 |
public IDistance getDistance() { |
|
189 |
return distance; |
|
190 |
} |
|
191 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.61/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); |
Also available in: Unified diff