Revision 1103
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.xyshift/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.geoprocess.algorithm.xyshift.XYShiftLibrary |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.xyshift/src/main/resources/org/gvsig/geoprocess/algorithm/xyshift/xyshift.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 |
XYShift=Desplazamiento en X e Y |
|
27 |
Input_layer=Capa de entrada |
|
28 |
Selected_geometries_xy=Geom. seleccionadas (Capa entrada) |
|
29 |
X_traslation=Traslaci?n en X |
|
30 |
Y_traslation=Traslaci?n en Y |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.xyshift/src/main/resources/org/gvsig/geoprocess/algorithm/xyshift/xyshift_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 |
XYShift=X and Y shift |
|
27 |
Input_layer=Input cover |
|
28 |
Selected_geometries_xy=Selected features (Input cover) |
|
29 |
X_traslation=X shift |
|
30 |
Y_traslation=Y shift |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.xyshift/src/main/resources/help/XYShiftAlgorithm_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 applies a 2D translation transform to all points of the geometry of all the features of the input layer. To do that, user must enter x and y offsets. This is useful for conflation task, to integrate layers from different sources and cartographic technical specs" description="Descripción" type="0"> |
|
29 |
<image description="" file="xyshiftdesc.png"> |
|
30 |
</image> |
|
31 |
</element> |
|
32 |
<element name="ADDITIONAL_INFO" text="" description="Información adicional" type="0"> |
|
33 |
</element> |
|
34 |
<element name="EXTENSION_AUTHOR" text="Nacho Brodin" description="Algoritmo creado por" type="0"> |
|
35 |
</element> |
|
36 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0"> |
|
37 |
</element> |
|
38 |
<element name="USER_NOTES" text="" description="Notas de usuario" type="0"> |
|
39 |
</element> |
|
40 |
<element name="LAYER" text="" description="Capa de entrada" type="3"> |
|
41 |
</element> |
|
42 |
<element name="CHECK" text="" description="Geometrias seleccionadas" type="3"> |
|
43 |
</element> |
|
44 |
<element name="X" text="" description="Traslación en X" type="3"> |
|
45 |
</element> |
|
46 |
<element name="Y" text="" description="Traslación en Y" type="3"> |
|
47 |
</element> |
|
48 |
<element name="OUTPUT_DESCRIPTION" text="" description="Descripción" type="2"> |
|
49 |
</element> |
|
50 |
<element name="RESULT" text="" description="XY-Shift" type="2"> |
|
51 |
</element> |
|
52 |
</help> |
|
53 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.xyshift/src/main/resources/help/XYShiftAlgorithm.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<help> |
|
28 |
<element name="DESCRIPTION" text="Este geoproceso permite aplicar una transformación de traslación sobre todos los puntos de las geometrías de la capa de entrada. Para tal fin, el usuario deberá especificar el desplazamiento en X y en Y a aplicar. Este geoproceso puede ser de gran utilidad para hacer concordar cartografías procedentes de fuentes distintas, en lo que se viene a denominar por el término inglés conflation." description="Descripción" type="0"> |
|
29 |
<image description="" file="xyshiftdesc.png"> |
|
30 |
</image> |
|
31 |
</element> |
|
32 |
<element name="ADDITIONAL_INFO" text="" description="Información adicional" type="0"> |
|
33 |
</element> |
|
34 |
<element name="EXTENSION_AUTHOR" text="Nacho Brodin" description="Algoritmo creado por" type="0"> |
|
35 |
</element> |
|
36 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0"> |
|
37 |
</element> |
|
38 |
<element name="USER_NOTES" text="" description="Notas de usuario" type="0"> |
|
39 |
</element> |
|
40 |
<element name="LAYER" text="" description="Capa de entrada" type="3"> |
|
41 |
</element> |
|
42 |
<element name="CHECK" text="" description="Geometrias seleccionadas" type="3"> |
|
43 |
</element> |
|
44 |
<element name="X" text="" description="Traslación en X" type="3"> |
|
45 |
</element> |
|
46 |
<element name="Y" text="" description="Traslación en Y" type="3"> |
|
47 |
</element> |
|
48 |
<element name="OUTPUT_DESCRIPTION" text="" description="Descripción" type="2"> |
|
49 |
</element> |
|
50 |
<element name="RESULT" text="" description="XY-Shift" type="2"> |
|
51 |
</element> |
|
52 |
</help> |
|
53 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.xyshift/src/main/java/org/gvsig/geoprocess/algorithm/xyshift/XYShiftOperation.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* |
|
25 |
|
|
26 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
27 |
* |
|
28 |
* Copyright (C) 2010 Generalitat Valenciana. |
|
29 |
* |
|
30 |
* This program is free software; you can redistribute it and/or |
|
31 |
* modify it under the terms of the GNU General Public License |
|
32 |
* as published by the Free Software Foundation; either version 2 |
|
33 |
* of the License, or (at your option) any later version. |
|
34 |
* |
|
35 |
* This program is distributed in the hope that it will be useful, |
|
36 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
37 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
38 |
* GNU General Public License for more details. |
|
39 |
* |
|
40 |
* You should have received a copy of the GNU General Public License |
|
41 |
* along with this program; if not, write to the Free Software |
|
42 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
43 |
*/ |
|
44 |
|
|
45 |
package org.gvsig.geoprocess.algorithm.xyshift; |
|
46 |
|
|
47 |
import java.util.Iterator; |
|
48 |
import java.util.List; |
|
49 |
|
|
50 |
import org.gvsig.fmap.dal.exception.DataException; |
|
51 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
52 |
import org.gvsig.fmap.dal.feature.Feature; |
|
53 |
import org.gvsig.fmap.geom.Geometry; |
|
54 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
55 |
import org.gvsig.fmap.geom.GeometryManager; |
|
56 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
|
57 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
58 |
import org.gvsig.fmap.geom.aggregate.MultiSurface; |
|
59 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
60 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
61 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
62 |
import org.gvsig.fmap.geom.primitive.OrientablePrimitive; |
|
63 |
import org.gvsig.fmap.geom.primitive.Point; |
|
64 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
65 |
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation; |
|
66 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
67 |
|
|
68 |
import es.unex.sextante.core.Sextante; |
|
69 |
/** |
|
70 |
* Translates all geometries |
|
71 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
72 |
*/ |
|
73 |
@SuppressWarnings("deprecation") |
|
74 |
public class XYShiftOperation extends GeometryOperation { |
|
75 |
private double x = 0D; |
|
76 |
private double y = 0D; |
|
77 |
private GeometryManager geometryManager = null; |
|
78 |
|
|
79 |
public XYShiftOperation(double x, double y, AbstractSextanteGeoProcess p) { |
|
80 |
super(p); |
|
81 |
this.x = x; |
|
82 |
this.y = y; |
|
83 |
this.geometryManager = GeometryLocator.getGeometryManager(); |
|
84 |
} |
|
85 |
/* |
|
86 |
* (non-Javadoc) |
|
87 |
* @see org.gvsig.geoprocess.algorithm.base.core.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.dal.feature.Feature) |
|
88 |
*/ |
|
89 |
@SuppressWarnings("unchecked") |
|
90 |
public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature feature) { |
|
91 |
List geomList = feature.getGeometries(); |
|
92 |
try { |
|
93 |
if(!persister.isCompatibleType(feature.getDefaultGeometry())) |
|
94 |
return lastEditFeature; |
|
95 |
|
|
96 |
if(geomList == null) { |
|
97 |
org.gvsig.fmap.geom.Geometry oldGeom = feature.getDefaultGeometry(); |
|
98 |
Geometry newGeom = shiftGeometry(oldGeom); |
|
99 |
lastEditFeature = persister.addFeature(feature, newGeom); |
|
100 |
} else { |
|
101 |
Iterator<org.gvsig.fmap.geom.Geometry> itGeom = geomList.iterator(); |
|
102 |
EditableFeature editFeat = null; |
|
103 |
int nGeom = 0; |
|
104 |
while(itGeom.hasNext()) { |
|
105 |
org.gvsig.fmap.geom.Geometry oldGeom = itGeom.next(); |
|
106 |
Geometry newGeom = shiftGeometry(oldGeom); |
|
107 |
nGeom ++; |
|
108 |
if(editFeat == null) |
|
109 |
editFeat = persister.addFeature(feature, newGeom); |
|
110 |
else |
|
111 |
persister.addGeometryToExistingFeature(editFeat, newGeom); |
|
112 |
lastEditFeature = editFeat; |
|
113 |
} |
|
114 |
} |
|
115 |
} catch (DataException e) { |
|
116 |
Sextante.addErrorToLog(e); |
|
117 |
} catch (CreateGeometryException e1) { |
|
118 |
Sextante.addErrorToLog(e1); |
|
119 |
} |
|
120 |
|
|
121 |
return lastEditFeature; |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* Shifts all coordinates in a geometry |
|
126 |
* @param oldGeom |
|
127 |
* @return |
|
128 |
* @throws CreateGeometryException |
|
129 |
*/ |
|
130 |
private Geometry shiftGeometry(Geometry oldGeom) throws CreateGeometryException { |
|
131 |
if(oldGeom.getType() == Geometry.TYPES.SURFACE) |
|
132 |
return shiftSurface((Surface)oldGeom); |
|
133 |
else if(oldGeom.getType() == Geometry.TYPES.MULTISURFACE) |
|
134 |
return shiftMultiSurface((MultiSurface)oldGeom); |
|
135 |
else if(oldGeom.getType() == Geometry.TYPES.CURVE) |
|
136 |
return shiftCurve((Curve)oldGeom); |
|
137 |
else if(oldGeom.getType() == Geometry.TYPES.MULTICURVE) |
|
138 |
return shiftMultiCurve((MultiCurve)oldGeom); |
|
139 |
else if(oldGeom.getType() == Geometry.TYPES.POINT) |
|
140 |
return shiftPoint((Point)oldGeom); |
|
141 |
else if(oldGeom.getType() == Geometry.TYPES.MULTIPOINT) |
|
142 |
return shiftMultiPoint((MultiPoint)oldGeom); |
|
143 |
return oldGeom; |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* Shifts all coordinates in a surface |
|
148 |
* @param geom |
|
149 |
* @return |
|
150 |
* @throws CreateGeometryException |
|
151 |
*/ |
|
152 |
private Surface shiftSurface(Surface geom) throws CreateGeometryException { |
|
153 |
Surface surface = (Surface)geometryManager.create(Geometry.TYPES.SURFACE, Geometry.SUBTYPES.GEOM2D); |
|
154 |
return (Surface)shiftGeom(geom, surface); |
|
155 |
} |
|
156 |
|
|
157 |
/** |
|
158 |
* Shifts all coordinates in a multisurface |
|
159 |
* @param geom |
|
160 |
* @return |
|
161 |
* @throws CreateGeometryException |
|
162 |
*/ |
|
163 |
private MultiSurface shiftMultiSurface(MultiSurface geom) throws CreateGeometryException { |
|
164 |
MultiSurface surface = (MultiSurface)geometryManager.create(Geometry.TYPES.MULTISURFACE, geom.getGeometryType().getSubType()); |
|
165 |
for (int i = 0; i < geom.getPrimitivesNumber(); i++) { |
|
166 |
Surface s = geom.getSurfaceAt(i); |
|
167 |
Surface newSurface = shiftSurface(s); |
|
168 |
surface.addSurface(newSurface); |
|
169 |
} |
|
170 |
return surface; |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* Shifts all coordinates in a curve |
|
175 |
* @param geom |
|
176 |
* @return |
|
177 |
* @throws CreateGeometryException |
|
178 |
*/ |
|
179 |
private Curve shiftCurve(Curve geom) throws CreateGeometryException { |
|
180 |
Curve curve = (Curve)geometryManager.create(Geometry.TYPES.CURVE, Geometry.SUBTYPES.GEOM2D); |
|
181 |
return (Curve)shiftGeom(geom, curve); |
|
182 |
} |
|
183 |
|
|
184 |
private OrientablePrimitive shiftGeom(OrientablePrimitive src, OrientablePrimitive dst) throws CreateGeometryException { |
|
185 |
GeneralPathX gp = (GeneralPathX)src.getGeneralPath().clone(); |
|
186 |
double[] pcoords = gp.getPointCoords(); |
|
187 |
|
|
188 |
for (int i = 0; i < pcoords.length; i++) { |
|
189 |
if((i % 2) == 0) |
|
190 |
pcoords[i] = pcoords[i] + x; |
|
191 |
else |
|
192 |
pcoords[i] = pcoords[i] + y; |
|
193 |
} |
|
194 |
gp.setPointCoords(pcoords); |
|
195 |
dst.setGeneralPath(gp); |
|
196 |
return dst; |
|
197 |
} |
|
198 |
|
|
199 |
/** |
|
200 |
* Shifts all coordinates in a multicurve |
|
201 |
* @param geom |
|
202 |
* @return |
|
203 |
* @throws CreateGeometryException |
|
204 |
*/ |
|
205 |
private MultiCurve shiftMultiCurve(MultiCurve geom) throws CreateGeometryException { |
|
206 |
MultiCurve curve = (MultiCurve)geometryManager.create(Geometry.TYPES.MULTICURVE, geom.getGeometryType().getSubType()); |
|
207 |
for (int i = 0; i < geom.getPrimitivesNumber(); i++) { |
|
208 |
Curve c = geom.getCurveAt(i); |
|
209 |
Curve newCurve = shiftCurve(c); |
|
210 |
curve.addCurve(newCurve); |
|
211 |
} |
|
212 |
return curve; |
|
213 |
} |
|
214 |
|
|
215 |
/** |
|
216 |
* Shifts a point |
|
217 |
* @param geom |
|
218 |
* @return |
|
219 |
* @throws CreateGeometryException |
|
220 |
*/ |
|
221 |
private Point shiftPoint(Point geom) throws CreateGeometryException { |
|
222 |
Point point = (Point)geometryManager.create(Geometry.TYPES.POINT, geom.getGeometryType().getSubType()); |
|
223 |
point.setX(geom.getX() + x); |
|
224 |
point.setY(geom.getY() + y); |
|
225 |
return point; |
|
226 |
} |
|
227 |
|
|
228 |
/** |
|
229 |
* Shifts all coordinates in a multisurface |
|
230 |
* @param geom |
|
231 |
* @return |
|
232 |
* @throws CreateGeometryException |
|
233 |
*/ |
|
234 |
private MultiPoint shiftMultiPoint(MultiPoint geom) throws CreateGeometryException { |
|
235 |
MultiPoint point = (MultiPoint)geometryManager.create(Geometry.TYPES.MULTIPOINT, geom.getGeometryType().getSubType()); |
|
236 |
for (int i = 0; i < geom.getPrimitivesNumber(); i++) { |
|
237 |
Point p = geom.getPointAt(i); |
|
238 |
Point newPoint = shiftPoint(p); |
|
239 |
point.addPoint(newPoint); |
|
240 |
} |
|
241 |
return point; |
|
242 |
} |
|
243 |
|
|
244 |
/* |
|
245 |
* (non-Javadoc) |
|
246 |
* @see org.gvsig.geoprocess.algorithm.base.core.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.dal.feature.EditableFeature) |
|
247 |
*/ |
|
248 |
public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature feature) { |
|
249 |
} |
|
250 |
} |
|
251 |
|
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.xyshift/src/main/java/org/gvsig/geoprocess/algorithm/xyshift/XYShiftLibrary.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.xyshift; |
|
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 XYShiftLibrary library. |
|
32 |
* |
|
33 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
34 |
*/ |
|
35 |
public class XYShiftLibrary extends AlgorithmAbstractLibrary { |
|
36 |
|
|
37 |
@Override |
|
38 |
protected void doInitialize() throws LibraryException { |
|
39 |
// Nothing to do |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
protected void doPostInitialize() throws LibraryException { |
|
44 |
Messages.addResourceFamily( |
|
45 |
"org.gvsig.geoprocess.algorithm.xyshift.xyshift", |
|
46 |
XYShiftLibrary.class.getClassLoader(), XYShiftLibrary.class |
|
47 |
.getClass().getName()); |
|
48 |
registerGeoProcess(new XYShiftAlgorithm()); |
|
49 |
} |
|
50 |
|
|
51 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.xyshift/src/main/java/org/gvsig/geoprocess/algorithm/xyshift/XYShiftAlgorithm.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.xyshift; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.exception.DataException; |
|
27 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
28 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
29 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
30 |
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation; |
|
31 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
32 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer; |
|
33 |
|
|
34 |
import es.unex.sextante.additionalInfo.AdditionalInfoNumericalValue; |
|
35 |
import es.unex.sextante.core.Sextante; |
|
36 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
37 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
38 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
39 |
import es.unex.sextante.outputs.OutputVectorLayer; |
|
40 |
|
|
41 |
/** |
|
42 |
* XYShift algorithm |
|
43 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
44 |
*/ |
|
45 |
public class XYShiftAlgorithm extends AbstractSextanteGeoProcess { |
|
46 |
|
|
47 |
public static final String RESULT_POL = "RESULT_POL"; |
|
48 |
public static final String RESULT_POINT = "RESULT_POINT"; |
|
49 |
public static final String RESULT_LINE = "RESULT_LINE"; |
|
50 |
public static final String LAYER = "LAYER"; |
|
51 |
public static final String CHECK = "CHECK"; |
|
52 |
public static final String X = "X"; |
|
53 |
public static final String Y = "Y"; |
|
54 |
|
|
55 |
/* |
|
56 |
* (non-Javadoc) |
|
57 |
* @see es.unex.sextante.core.GeoAlgorithm#defineCharacteristics() |
|
58 |
*/ |
|
59 |
public void defineCharacteristics(){ |
|
60 |
setName(getTranslation("XYShift")); |
|
61 |
setGroup(getTranslation("basic_vect_algorithms")); |
|
62 |
// setGeneratesUserDefinedRasterOutput(false); |
|
63 |
|
|
64 |
try { |
|
65 |
m_Parameters.addInputVectorLayer(LAYER, |
|
66 |
getTranslation("Input_layer"), |
|
67 |
IVectorLayer.SHAPE_TYPE_WRONG, |
|
68 |
true); |
|
69 |
m_Parameters.addBoolean(CHECK, |
|
70 |
getTranslation("Selected_geometries_xy"), false); |
|
71 |
m_Parameters.addNumericalValue(X, getTranslation("X_traslation"), |
|
72 |
0, AdditionalInfoNumericalValue.NUMERICAL_VALUE_DOUBLE); |
|
73 |
m_Parameters.addNumericalValue(Y, getTranslation("Y_traslation"), |
|
74 |
0, AdditionalInfoNumericalValue.NUMERICAL_VALUE_DOUBLE); |
|
75 |
} catch (RepeatedParameterNameException e) { |
|
76 |
Sextante.addErrorToLog(e); |
|
77 |
} |
|
78 |
addOutputVectorLayer(RESULT_POL, getTranslation("XYShift_polygon"), |
|
79 |
OutputVectorLayer.SHAPE_TYPE_POLYGON); |
|
80 |
addOutputVectorLayer(RESULT_LINE, getTranslation("XYShift_line"), |
|
81 |
OutputVectorLayer.SHAPE_TYPE_LINE); |
|
82 |
addOutputVectorLayer(RESULT_POINT, getTranslation("XYShift_point"), |
|
83 |
OutputVectorLayer.SHAPE_TYPE_POINT); |
|
84 |
} |
|
85 |
|
|
86 |
/* |
|
87 |
* (non-Javadoc) |
|
88 |
* @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm() |
|
89 |
*/ |
|
90 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
|
91 |
if(existsOutPutFile(XYShiftAlgorithm.RESULT_POL, 0) || |
|
92 |
existsOutPutFile(XYShiftAlgorithm.RESULT_LINE, 0) || |
|
93 |
existsOutPutFile(XYShiftAlgorithm.RESULT_POINT, 0)) { |
|
94 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
95 |
} |
|
96 |
IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER); |
|
97 |
boolean selectedGeom = m_Parameters.getParameter(CHECK).getParameterValueAsBoolean(); |
|
98 |
double x = m_Parameters.getParameterValueAsDouble(X); |
|
99 |
double y = m_Parameters.getParameterValueAsDouble(Y); |
|
100 |
|
|
101 |
FeatureStore storeLayer = null; |
|
102 |
if(layer instanceof FlyrVectIVectorLayer) |
|
103 |
storeLayer = ((FlyrVectIVectorLayer)layer).getFeatureStore(); |
|
104 |
else |
|
105 |
return false; |
|
106 |
|
|
107 |
try { |
|
108 |
FeatureSet features = null; |
|
109 |
features = storeLayer.getFeatureSet(); |
|
110 |
FeatureType featureType = features.getDefaultFeatureType(); |
|
111 |
|
|
112 |
if (isPolygon(storeLayer) || isUndefined(storeLayer)) { |
|
113 |
FeatureStore outFeatStore = |
|
114 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
|
115 |
getTranslation("XYShift_polygon"), RESULT_POL); |
|
116 |
|
|
117 |
GeometryOperation operation = new XYShiftOperation(x, y, this); |
|
118 |
operation.setTaskStatus(getStatus()); |
|
119 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, |
|
120 |
selectedGeom, false, true); |
|
121 |
} else { |
|
122 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
|
123 |
getTranslation("Null_polygon"), RESULT_POL); |
|
124 |
} |
|
125 |
|
|
126 |
if (isLine(storeLayer) || isUndefined(storeLayer)) { |
|
127 |
FeatureStore outFeatStore = |
|
128 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE, |
|
129 |
getTranslation("XYShift_line"), RESULT_LINE); |
|
130 |
|
|
131 |
GeometryOperation operation = new XYShiftOperation(x, y, this); |
|
132 |
operation.setTaskStatus(getStatus()); |
|
133 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, |
|
134 |
selectedGeom, false, true); |
|
135 |
} else { |
|
136 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_LINE, |
|
137 |
getTranslation("Null_line"), RESULT_LINE); |
|
138 |
} |
|
139 |
|
|
140 |
if (isPoint(storeLayer) || isUndefined(storeLayer)) { |
|
141 |
FeatureStore outFeatStore = |
|
142 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
|
143 |
getTranslation("XYShift_point"), RESULT_POINT); |
|
144 |
|
|
145 |
GeometryOperation operation = new XYShiftOperation(x, y, this); |
|
146 |
operation.setTaskStatus(getStatus()); |
|
147 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, |
|
148 |
selectedGeom, false, true); |
|
149 |
} else { |
|
150 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
|
151 |
getTranslation("Null_point"), RESULT_POINT); |
|
152 |
} |
|
153 |
} catch (DataException e) { |
|
154 |
Sextante.addErrorToLog(e); |
|
155 |
return false; |
|
156 |
} |
|
157 |
|
|
158 |
if(getTaskMonitor().isCanceled()) |
|
159 |
return false; |
|
160 |
|
|
161 |
return true; |
|
162 |
} |
|
163 |
|
|
164 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.xyshift/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.xyshift</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>org.gvsig.geoprocess.algorithm.xyshift</name> |
|
7 |
|
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.geoprocess.algorithm</artifactId> |
|
11 |
<version>2.2.98</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 |
</project> |
|
0 | 22 |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.merge/src/main/java/org/gvsig/geoprocess/algorithm/merge/MergeOperation.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.merge; |
|
25 |
|
|
26 |
import es.unex.sextante.core.Sextante; |
|
27 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
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.geom.exception.CreateGeometryException; |
|
33 |
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation; |
|
34 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
35 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer; |
|
36 |
|
|
37 |
/** |
|
38 |
* Builds a geometry with the intersection between two layers |
|
39 |
* |
|
40 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
41 |
*/ |
|
42 |
public class MergeOperation extends GeometryOperation { |
|
43 |
private IVectorLayer layer = null; |
|
44 |
|
|
45 |
public MergeOperation(IVectorLayer layer, AbstractSextanteGeoProcess p) { |
|
46 |
super(p); |
|
47 |
this.layer = layer; |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* Computes intersection between the geometry and the overlay layer. The fields of the |
|
52 |
* intersected features will be added. |
|
53 |
* @param g |
|
54 |
* @param featureInput |
|
55 |
* @return |
|
56 |
*/ |
|
57 |
public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature featureInput) { |
|
58 |
if(g == null) |
|
59 |
return lastEditFeature; |
|
60 |
|
|
61 |
try { |
|
62 |
if(inFeatureStore == ((FlyrVectIVectorLayer)layer).getFeatureStore()) |
|
63 |
lastEditFeature = persister.addFeature(featureInput, g); |
|
64 |
else |
|
65 |
lastEditFeature = persister.addDifferentFieldFeature(featureInput, g); |
|
66 |
} catch (CreateGeometryException e) { |
|
67 |
Sextante.addErrorToLog(e); |
|
68 |
} catch (DataException e) { |
|
69 |
Sextante.addErrorToLog(e); |
|
70 |
} |
|
71 |
|
|
72 |
return lastEditFeature; |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* clips feature's geometry with the clipping geometry, preserving |
|
77 |
* feature's original attributes. |
|
78 |
* If feature's geometry doesn't touch clipping geometry, it will be |
|
79 |
* ignored. |
|
80 |
*/ |
|
81 |
public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature featureInput) { |
|
82 |
try { |
|
83 |
lastEditFeature = persister.addGeometryToExistingFeature(featureInput, g); |
|
84 |
} catch (CreateGeometryException e) { |
|
85 |
Sextante.addErrorToLog(e); |
|
86 |
} catch (DataException e) { |
|
87 |
Sextante.addErrorToLog(e); |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
|
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.merge/src/main/java/org/gvsig/geoprocess/algorithm/merge/MergeParametersPanel.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.merge; |
|
25 |
|
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.GridBagConstraints; |
|
28 |
import java.awt.GridBagLayout; |
|
29 |
import java.awt.Insets; |
|
30 |
import java.awt.event.ActionEvent; |
|
31 |
import java.awt.event.ActionListener; |
|
32 |
import java.util.ArrayList; |
|
33 |
|
|
34 |
import javax.swing.JCheckBox; |
|
35 |
import javax.swing.JComboBox; |
|
36 |
import javax.swing.JLabel; |
|
37 |
import javax.swing.JPanel; |
|
38 |
|
|
39 |
import org.gvsig.geoprocess.lib.api.GeoProcessLocator; |
|
40 |
import org.gvsig.geoprocess.sextante.gui.algorithm.AlgorithmOutputPanel; |
|
41 |
import org.gvsig.gui.beans.table.TableContainer; |
|
42 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
43 |
|
|
44 |
import es.unex.sextante.core.GeoAlgorithm; |
|
45 |
import es.unex.sextante.core.ObjectAndDescription; |
|
46 |
import es.unex.sextante.core.OutputObjectsSet; |
|
47 |
import es.unex.sextante.core.ParametersSet; |
|
48 |
import es.unex.sextante.core.Sextante; |
|
49 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
50 |
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel; |
|
51 |
import es.unex.sextante.gui.algorithm.OutputChannelSelectionPanel; |
|
52 |
import es.unex.sextante.gui.core.SextanteGUI; |
|
53 |
import es.unex.sextante.outputs.Output; |
|
54 |
|
|
55 |
/** |
|
56 |
* Panel for merge algorithm |
|
57 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
58 |
*/ |
|
59 |
public class MergeParametersPanel extends GeoAlgorithmParametersPanel implements ActionListener { |
|
60 |
private static final long serialVersionUID = 1L; |
|
61 |
private GeoAlgorithm m_Algorithm = null; |
|
62 |
private JComboBox fieldsCombo = null; |
|
63 |
private JCheckBox allLayers = null; |
|
64 |
//private AlgorithmOutputPanel output = null; |
|
65 |
private final String[] columnNames = { GeoProcessLocator.getGeoProcessManager().getTranslation("Selected"), |
|
66 |
GeoProcessLocator.getGeoProcessManager().getTranslation("Layer") }; |
|
67 |
private final int[] columnWidths = { 35, 334 }; |
|
68 |
private TableContainer table = null; |
|
69 |
private ObjectAndDescription[] layerList = null; |
|
70 |
private AlgorithmOutputPanel algorithmOutputPanel = null; |
|
71 |
private OutputChannelSelectionPanel outputChannelSelectionPanelPol; |
|
72 |
private OutputChannelSelectionPanel outputChannelSelectionPanelLine; |
|
73 |
private OutputChannelSelectionPanel outputChannelSelectionPanelPoint; |
|
74 |
private JPanel outputPanel; |
|
75 |
|
|
76 |
public MergeParametersPanel() { |
|
77 |
super(); |
|
78 |
} |
|
79 |
|
|
80 |
public void init(GeoAlgorithm algorithm) { |
|
81 |
m_Algorithm = algorithm; |
|
82 |
initGUI(); |
|
83 |
} |
|
84 |
|
|
85 |
private void initGUI() { |
|
86 |
GridBagLayout gbl = new GridBagLayout(); |
|
87 |
this.setLayout(gbl); |
|
88 |
|
|
89 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
90 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
91 |
gbc.weightx = 1.0; |
|
92 |
gbc.gridx = 0; |
|
93 |
gbc.gridy = 0; |
|
94 |
gbc.insets = new Insets(5, 5, 8, 5); |
|
95 |
this.add(getAllLayersCheck(), gbc); |
|
96 |
|
|
97 |
gbc.gridy = 1; |
|
98 |
gbc.fill = GridBagConstraints.BOTH; |
|
99 |
gbc.insets = new Insets(0, 0, 12, 0); |
|
100 |
gbc.weighty = 1.0; |
|
101 |
this.add(getCheckBoxTable(), gbc); |
|
102 |
|
|
103 |
gbc.gridy = 2; |
|
104 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
105 |
gbc.insets = new Insets(5, 5, 8, 5); |
|
106 |
gbc.weightx = 1.0; |
|
107 |
gbc.weighty = 0; |
|
108 |
this.add(getFieldsComboPanel(GeoProcessLocator.getGeoProcessManager().getTranslation("use_fields_from_layer"), getFieldsCombo()), gbc); |
|
109 |
|
|
110 |
gbc.gridy = 3; |
|
111 |
this.add(getOutputChannelSelectionPanel(), gbc); |
|
112 |
|
|
113 |
initTable(); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* Gets the output panel (SEXTANTE) |
|
118 |
* @return |
|
119 |
*/ |
|
120 |
private JPanel getOutputChannelSelectionPanel() { |
|
121 |
if(outputPanel == null) { |
|
122 |
try { |
|
123 |
outputPanel = new JPanel(); |
|
124 |
outputPanel.setLayout(new GridBagLayout()); |
|
125 |
final OutputObjectsSet ooSet = m_Algorithm.getOutputObjects(); |
|
126 |
final Output out_pol = ooSet.getOutput(MergeAlgorithm.RESULT_POL); |
|
127 |
final Output out_line = ooSet.getOutput(MergeAlgorithm.RESULT_LINE); |
|
128 |
final Output out_point = ooSet.getOutput(MergeAlgorithm.RESULT_POINT); |
|
129 |
|
|
130 |
outputChannelSelectionPanelPol = new OutputChannelSelectionPanel(out_pol, m_Algorithm.getParameters()); |
|
131 |
outputChannelSelectionPanelLine = new OutputChannelSelectionPanel(out_line, m_Algorithm.getParameters()); |
|
132 |
outputChannelSelectionPanelPoint = new OutputChannelSelectionPanel(out_point, m_Algorithm.getParameters()); |
|
133 |
|
|
134 |
String label = GeoProcessLocator.getGeoProcessManager().getTranslation("Merge"); |
|
135 |
|
|
136 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
137 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
138 |
gbc.insets = new Insets(0, 0, 4, 0); |
|
139 |
gbc.weightx = 1; |
|
140 |
gbc.gridx = 0; |
|
141 |
gbc.gridy = 0; |
|
142 |
outputPanel.add(new JLabel(" " + label + " [" + |
|
143 |
GeoProcessLocator.getGeoProcessManager().getTranslation("Polygon") + "] "), gbc); |
|
144 |
|
|
145 |
gbc.gridx = 0; |
|
146 |
gbc.gridy = 1; |
|
147 |
outputPanel.add(new JLabel(" " + label + " [" + |
|
148 |
GeoProcessLocator.getGeoProcessManager().getTranslation("Line") + "] "), gbc); |
|
149 |
|
|
150 |
gbc.gridx = 0; |
|
151 |
gbc.gridy = 2; |
|
152 |
outputPanel.add(new JLabel(" " + label + " [" + |
|
153 |
GeoProcessLocator.getGeoProcessManager().getTranslation("Point") + "] "), gbc); |
|
154 |
|
|
155 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
156 |
gbc.weightx = 1; |
|
157 |
gbc.gridx = 1; |
|
158 |
gbc.gridy = 0; |
|
159 |
outputPanel.add(outputChannelSelectionPanelPol, gbc); |
|
160 |
|
|
161 |
gbc.gridx = 1; |
|
162 |
gbc.gridy = 1; |
|
163 |
outputPanel.add(outputChannelSelectionPanelLine, gbc); |
|
164 |
|
|
165 |
gbc.gridx = 1; |
|
166 |
gbc.gridy = 2; |
|
167 |
outputPanel.add(outputChannelSelectionPanelPoint, gbc); |
|
168 |
} catch (final Exception e) { |
|
169 |
Sextante.addErrorToLog(e); |
|
170 |
} |
|
171 |
} |
|
172 |
return outputPanel; |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* Gets the output panel (DAL) |
|
177 |
* @return |
|
178 |
*/ |
|
179 |
@SuppressWarnings("unused") |
|
180 |
private AlgorithmOutputPanel getAlgorithmOutputPanel() { |
|
181 |
if(algorithmOutputPanel == null) |
|
182 |
algorithmOutputPanel = new AlgorithmOutputPanel(); |
|
183 |
return algorithmOutputPanel; |
|
184 |
} |
|
185 |
|
|
186 |
/** |
|
187 |
* Gets a new JPanel with the text and JComboBox |
|
188 |
* @param text |
|
189 |
* @param combo |
|
190 |
* @return |
|
191 |
*/ |
|
192 |
public JPanel getFieldsComboPanel(String text, JComboBox combo) { |
|
193 |
JPanel panel = new JPanel(); |
|
194 |
GridBagLayout gbl = new GridBagLayout(); |
|
195 |
panel.setLayout(gbl); |
|
196 |
|
|
197 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
198 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
199 |
gbc.weightx = 1.0; |
|
200 |
gbc.gridx = 0; |
|
201 |
gbc.insets = new Insets(0, 0, 4, 0); |
|
202 |
JLabel label = new JLabel(text); |
|
203 |
// label.setPreferredSize(new Dimension(80, 18)); |
|
204 |
panel.add(label, gbc); |
|
205 |
|
|
206 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
207 |
gbc.weightx = 1.0; |
|
208 |
gbc.gridx = 1; |
|
209 |
// gbc.anchor = GridBagConstraints.EAST; |
|
210 |
gbc.insets = new Insets(0, 0, 4, 0); |
|
211 |
panel.add(combo, gbc); |
|
212 |
return panel; |
|
213 |
} |
|
214 |
|
|
215 |
/** |
|
216 |
* Gets a ComboBox |
|
217 |
* @return |
|
218 |
*/ |
|
219 |
public JComboBox getFieldsCombo() { |
|
220 |
if(fieldsCombo == null) { |
|
221 |
fieldsCombo = new JComboBox(); |
|
222 |
// fieldsCombo.setPreferredSize(new Dimension(0, 18)); |
|
223 |
ObjectAndDescription[] fieldList = getLayerList(); |
|
224 |
fieldsCombo.removeAllItems(); |
|
225 |
for (int i = 0; i < fieldList.length; i++) |
|
226 |
fieldsCombo.addItem(fieldList[i]); |
|
227 |
} |
|
228 |
return fieldsCombo; |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* Gets a CheckBox |
|
233 |
* @return |
|
234 |
*/ |
|
235 |
public JCheckBox getAllLayersCheck() { |
|
236 |
if(allLayers == null) { |
|
237 |
allLayers = new JCheckBox(GeoProcessLocator.getGeoProcessManager().getTranslation("select_all_layers")); |
|
238 |
allLayers.addActionListener(this); |
|
239 |
} |
|
240 |
return allLayers; |
|
241 |
} |
|
242 |
|
|
243 |
/** |
|
244 |
* Gets the summary table |
|
245 |
* @return TableContainer |
|
246 |
*/ |
|
247 |
public TableContainer getCheckBoxTable() { |
|
248 |
if (table == null) { |
|
249 |
table = new TableContainer(columnNames, columnWidths, null); |
|
250 |
table.setModel("CheckBoxModel"); |
|
251 |
table.setControlVisible(false); |
|
252 |
table.initialize(); |
|
253 |
} |
|
254 |
return table; |
|
255 |
} |
|
256 |
|
|
257 |
//------------------------------------------------------------ |
|
258 |
|
|
259 |
/* |
|
260 |
* (non-Javadoc) |
|
261 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
262 |
*/ |
|
263 |
public void actionPerformed(ActionEvent e) { |
|
264 |
if(e.getSource() == getAllLayersCheck()) { |
|
265 |
//Selecci?n de todas las capas de la tabla |
|
266 |
try { |
|
267 |
for (int i = 0; i < getCheckBoxTable().getRowCount(); i++) { |
|
268 |
if(getAllLayersCheck().isSelected()) |
|
269 |
getCheckBoxTable().getModel().setValueAt(new Boolean(true), i, 0); |
|
270 |
else |
|
271 |
getCheckBoxTable().getModel().setValueAt(new Boolean(false), i, 0); |
|
272 |
} |
|
273 |
} catch (NotInitializeException e1) { |
|
274 |
Sextante.addErrorToLog(e1); |
|
275 |
} |
|
276 |
} |
|
277 |
} |
|
278 |
|
|
279 |
/** |
|
280 |
* Adds to the table one entry for each field |
|
281 |
*/ |
|
282 |
private void initTable() { |
|
283 |
try { |
|
284 |
getCheckBoxTable().removeAllRows(); |
|
285 |
ObjectAndDescription[] layerList = getLayerList(); |
|
286 |
for (int i = 0; i < layerList.length; i++) |
|
287 |
addTableRow(layerList[i].getDescription()); |
|
288 |
} catch (NotInitializeException e) { |
|
289 |
Sextante.addErrorToLog(e); |
|
290 |
} |
|
291 |
} |
|
292 |
|
|
293 |
/** |
|
294 |
* Adds one entry to the table |
|
295 |
* @param layerName |
|
296 |
* Layer name |
|
297 |
* @throws NotInitializeException |
|
298 |
*/ |
|
299 |
private void addTableRow(String layerName) throws NotInitializeException { |
|
300 |
Object[] row = { new Boolean(false), |
|
301 |
layerName }; |
|
302 |
getCheckBoxTable().addRow(row); |
|
303 |
} |
|
304 |
|
|
305 |
@Override |
|
306 |
public void assignParameters() { |
|
307 |
try { |
|
308 |
ParametersSet params = m_Algorithm.getParameters(); |
|
309 |
params.getParameter(MergeAlgorithm.FIELDLAYER).setParameterValue(getSelectedVectorLayer()); |
|
310 |
params.getParameter(MergeAlgorithm.LAYERS).setParameterValue(getSelectedLayerList()); |
|
311 |
|
|
312 |
OutputObjectsSet ooSet = m_Algorithm.getOutputObjects(); |
|
313 |
Output outPol = ooSet.getOutput(MergeAlgorithm.RESULT_POL); |
|
314 |
Output outLine = ooSet.getOutput(MergeAlgorithm.RESULT_LINE); |
|
315 |
Output outPoint = ooSet.getOutput(MergeAlgorithm.RESULT_POINT); |
|
316 |
|
|
317 |
//Reponer estas l?neas para cambiar el panel de salida y comentar la siguiente |
|
318 |
//AlgorithmOutputPanel fsp = getAlgorithmOutputPanel(); |
|
319 |
//out.setOutputChannel(new CompositeSourceOutputChannel(fsp.getOutputParameters())); |
|
320 |
outPol.setOutputChannel(outputChannelSelectionPanelPol.getOutputChannel()); |
|
321 |
outLine.setOutputChannel(outputChannelSelectionPanelLine.getOutputChannel()); |
|
322 |
outPoint.setOutputChannel(outputChannelSelectionPanelPoint.getOutputChannel()); |
|
323 |
} catch (Exception e) { |
|
324 |
Sextante.addErrorToLog(e); |
|
325 |
} |
|
326 |
} |
|
327 |
|
|
328 |
@Override |
|
329 |
public void setOutputValue(String arg0, String arg1) { |
|
330 |
|
|
331 |
} |
|
332 |
|
|
333 |
@Override |
|
334 |
public void setParameterValue(String arg0, String arg1) { |
|
335 |
|
|
336 |
} |
|
337 |
|
|
338 |
/** |
|
339 |
* Gets the input layer list |
|
340 |
* @return |
|
341 |
*/ |
|
342 |
private ObjectAndDescription[] getLayerList() { |
|
343 |
if(layerList == null) { |
|
344 |
IVectorLayer[] layers = SextanteGUI.getInputFactory() |
|
345 |
.getVectorLayers(IVectorLayer.SHAPE_TYPE_WRONG); |
|
346 |
layerList = new ObjectAndDescription[layers.length]; |
|
347 |
for (int i = 0; i < layers.length; i++) |
|
348 |
layerList[i] = new ObjectAndDescription(layers[i].getName(), layers[i]); |
|
349 |
} |
|
350 |
return layerList; |
|
351 |
} |
|
352 |
|
|
353 |
/** |
|
354 |
* Gets the list of selected layers |
|
355 |
* @return |
|
356 |
*/ |
|
357 |
private ArrayList<IVectorLayer> getSelectedLayerList() { |
|
358 |
ObjectAndDescription[] layerList = getLayerList(); |
|
359 |
ArrayList<IVectorLayer> vLayer = new ArrayList<IVectorLayer>(); |
|
360 |
for (int i = 0; i < layerList.length; i++) { |
|
361 |
Boolean check = (Boolean)getCheckBoxTable().getModel().getValueAt(i, 0); |
|
362 |
if(check.booleanValue()) |
|
363 |
vLayer.add((IVectorLayer)layerList[i].getObject()); |
|
364 |
} |
|
365 |
return vLayer; |
|
366 |
} |
|
367 |
|
|
368 |
/** |
|
369 |
* Gets the selected vector layer in the JComboBox |
|
370 |
* @return |
|
371 |
*/ |
|
372 |
private IVectorLayer getSelectedVectorLayer() { |
|
373 |
if(getFieldsCombo().getSelectedItem() != null) |
|
374 |
return (IVectorLayer)((ObjectAndDescription)getFieldsCombo().getSelectedItem()).getObject(); |
|
375 |
return null; |
|
376 |
} |
|
377 |
|
|
378 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.merge/src/main/java/org/gvsig/geoprocess/algorithm/merge/MergeLibrary.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.merge; |
|
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 MergeLibrary library. |
|
32 |
* |
|
33 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
34 |
*/ |
|
35 |
public class MergeLibrary extends AlgorithmAbstractLibrary { |
|
36 |
|
|
37 |
@Override |
|
38 |
protected void doInitialize() throws LibraryException { |
|
39 |
// Nothing to do |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
protected void doPostInitialize() throws LibraryException { |
|
44 |
Messages.addResourceFamily( |
|
45 |
"org.gvsig.geoprocess.algorithm.merge.merge", MergeLibrary.class |
|
46 |
.getClassLoader(), MergeLibrary.class.getClass().getName()); |
|
47 |
registerGeoProcess(new MergeAlgorithm()); |
|
48 |
} |
|
49 |
|
|
50 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.merge/src/main/java/org/gvsig/geoprocess/algorithm/merge/MergeAlgorithm.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.merge; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
|
|
28 |
import javax.swing.JOptionPane; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.exception.DataException; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
34 |
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation; |
|
35 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
36 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer; |
|
37 |
|
|
38 |
import es.unex.sextante.additionalInfo.AdditionalInfoMultipleInput; |
|
39 |
import es.unex.sextante.core.Sextante; |
|
40 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
41 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
42 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
43 |
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel; |
|
44 |
import es.unex.sextante.outputs.OutputVectorLayer; |
|
45 |
|
|
46 |
/** |
|
47 |
* Merge algorithm |
|
48 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
49 |
*/ |
|
50 |
public class MergeAlgorithm extends AbstractSextanteGeoProcess { |
|
51 |
public static final String RESULT_POL = "RESULT_POL"; |
|
52 |
public static final String RESULT_POINT = "RESULT_POINT"; |
|
53 |
public static final String RESULT_LINE = "RESULT_LINE"; |
|
54 |
public static final String LAYERS = "LAYERS"; |
|
55 |
public static final String FIELDLAYER = "LAYER"; |
|
56 |
|
|
57 |
/* |
|
58 |
* (non-Javadoc) |
|
59 |
* @see es.unex.sextante.core.GeoAlgorithm#defineCharacteristics() |
|
60 |
*/ |
|
61 |
public void defineCharacteristics() { |
|
62 |
setName(getTranslation("Merge")); |
|
63 |
setGroup(getTranslation("basic_vect_algorithms")); |
|
64 |
// setGeneratesUserDefinedRasterOutput(false); |
|
65 |
|
|
66 |
try { |
|
67 |
m_Parameters.addMultipleInput(LAYERS, |
|
68 |
getTranslation("Input_layers"), |
|
69 |
AdditionalInfoMultipleInput.DATA_TYPE_VECTOR_ANY, |
|
70 |
true); |
|
71 |
m_Parameters.addInputVectorLayer(FIELDLAYER, |
|
72 |
getTranslation("Fields"), |
|
73 |
IVectorLayer.SHAPE_TYPE_WRONG, |
|
74 |
true); |
|
75 |
|
|
76 |
addOutputVectorLayer(RESULT_POL, getTranslation("Merge_polygon"), |
|
77 |
OutputVectorLayer.SHAPE_TYPE_POLYGON); |
|
78 |
addOutputVectorLayer(RESULT_LINE, getTranslation("Merge_line"), |
|
79 |
OutputVectorLayer.SHAPE_TYPE_LINE); |
|
80 |
addOutputVectorLayer(RESULT_POINT, getTranslation("Merge_point"), |
|
81 |
OutputVectorLayer.SHAPE_TYPE_POINT); |
|
82 |
|
|
83 |
} catch (RepeatedParameterNameException e) { |
|
84 |
Sextante.addErrorToLog(e); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
90 |
* @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm() |
|
91 |
*/ |
|
92 |
@SuppressWarnings("unchecked") |
|
93 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
|
94 |
if(existsOutPutFile(RESULT_POL, 0) || |
|
95 |
existsOutPutFile(RESULT_LINE, 0) || |
|
96 |
existsOutPutFile(RESULT_POINT, 0)) { |
|
97 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
98 |
} |
|
99 |
IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(FIELDLAYER); |
|
100 |
ArrayList<IVectorLayer> layers = m_Parameters.getParameterValueAsArrayList(LAYERS); |
|
101 |
|
|
102 |
FeatureStore storeLayer = null; |
|
103 |
if(layer instanceof FlyrVectIVectorLayer) |
|
104 |
storeLayer = ((FlyrVectIVectorLayer)layer).getFeatureStore(); |
|
105 |
else |
|
106 |
return false; |
|
107 |
|
|
108 |
try { |
|
109 |
//Gets the list of FeatureStore |
|
110 |
ArrayList<FeatureStore> featureStoreList = new ArrayList<FeatureStore>(); |
|
111 |
for (int i = 0; i < layers.size(); i++) { |
|
112 |
IVectorLayer lyr = layers.get(i); |
|
113 |
if(lyr instanceof FlyrVectIVectorLayer && layer.getShapeType() == lyr.getShapeType()) |
|
114 |
featureStoreList.add(((FlyrVectIVectorLayer)lyr).getFeatureStore()); |
|
115 |
else { |
|
116 |
JOptionPane.showMessageDialog(null, |
|
117 |
getTranslation("layers_type_are_different"), |
|
118 |
"Error", |
|
119 |
JOptionPane.WARNING_MESSAGE); |
|
120 |
return false; |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
//Builds the output FeatureStore |
|
125 |
FeatureSet features = null; |
|
126 |
features = storeLayer.getFeatureSet(); |
|
127 |
FeatureType featureType = features.getDefaultFeatureType(); |
|
128 |
/* FeatureStore outFeatStore = |
|
129 |
buildOutPutStore(featureType, layer.getShapeType(), |
|
130 |
getTranslation("Merge"), RESULT); |
|
131 |
|
|
132 |
//Calls the operation |
|
133 |
GeometryOperation operation = new MergeOperation(layer, this); |
|
134 |
operation.setTaskStatus(getStatus()); |
|
135 |
operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, false, true); |
|
136 |
*/ |
|
137 |
GeometryOperation operation = new MergeOperation(layer, this); |
|
138 |
operation.setTaskStatus(getStatus()); |
|
139 |
|
|
140 |
if (isPolygon(storeLayer) || isUndefined(storeLayer)) { |
|
141 |
FeatureStore outFeatStore = |
|
142 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
|
143 |
getTranslation("Merge_polygon"), RESULT_POL); |
|
144 |
|
|
145 |
operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, |
|
146 |
false, false, true); |
|
147 |
} else { |
|
148 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
|
149 |
getTranslation("Null_polygon"), RESULT_POL); |
|
150 |
} |
|
151 |
|
|
152 |
if (isLine(storeLayer) || isUndefined(storeLayer)) { |
|
153 |
FeatureStore outFeatStore = |
|
154 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE, |
|
155 |
getTranslation("Merge_line"), RESULT_LINE); |
|
156 |
|
|
157 |
operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, |
|
158 |
false, false, true); |
|
159 |
} else { |
|
160 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_LINE, |
|
161 |
getTranslation("Null_line"), RESULT_LINE); |
|
162 |
} |
|
163 |
|
|
164 |
if (isPoint(storeLayer) || isUndefined(storeLayer)) { |
|
165 |
FeatureStore outFeatStore = |
|
166 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
|
167 |
getTranslation("Merge_point"), RESULT_POINT); |
|
168 |
|
|
169 |
operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, |
|
170 |
false, false, true); |
|
171 |
} else { |
|
172 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
|
173 |
getTranslation("Null_point"), RESULT_POINT); |
|
174 |
} |
|
175 |
|
|
176 |
} catch (DataException e) { |
|
177 |
Sextante.addErrorToLog(e); |
|
178 |
return false; |
|
179 |
} |
|
180 |
|
|
181 |
if(getTaskMonitor().isCanceled()) |
|
182 |
return false; |
|
183 |
|
|
184 |
return true; |
|
185 |
} |
|
186 |
|
|
187 |
@Override |
|
188 |
public Class<? extends GeoAlgorithmParametersPanel> getCustomParametersPanelClass() { |
|
189 |
return MergeParametersPanel.class; |
|
190 |
} |
|
191 |
|
|
192 |
} |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.merge/src/main/resources/org/gvsig/geoprocess/algorithm/merge/merge.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_layers=Capas de entrada |
|
27 |
Fields=Campos |
|
28 |
Merge=Juntar |
|
29 |
layers_type_are_different=Los tipos de capa son diferentes |
|
30 |
Field=Campo |
|
31 |
select_all_layers=Seleccionar todas las capas |
|
32 |
use_fields_from_layer=Usar campos de la capa |
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.98/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.merge/src/main/resources/org/gvsig/geoprocess/algorithm/merge/merge_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 |
Also available in: Unified diff