Revision 687

View differences:

org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4
  <artifactId>org.gvsig.geoprocess.algorithm.clip</artifactId>
5
  <packaging>jar</packaging>
6
  <name>org.gvsig.geoprocess.algorithm.clip</name>
7
	
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.geoprocess.algorithm</artifactId>
11
		<version>2.2.26</version>
12
	</parent>
13
	
14
	<dependencies>
15
		<dependency>
16
		    <groupId>org.gvsig</groupId>
17
   			<artifactId>org.gvsig.geoprocess.algorithm.base</artifactId>
18
            <scope>compile</scope>
19
   		</dependency>
20
	</dependencies>
21
	
22
</project>
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/java/org/gvsig/geoprocess/algorithm/clip/ClipOperation.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2012 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25

  
26
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
27
 *
28
 * Copyright (C) 2010 Generalitat Valenciana.
29
 *
30
 * This program is free software; you can redistribute it and/or
31
 * modify it under the terms of the GNU General Public License
32
 * as published by the Free Software Foundation; either version 2
33
 * of the License, or (at your option) any later version.
34
 *
35
 * This program is distributed in the hope that it will be useful,
36
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
38
 * GNU General Public License for more details.
39
 *
40
 * You should have received a copy of the GNU General Public License
41
 * along with this program; if not, write to the Free Software
42
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
43
 */
44

  
45
package org.gvsig.geoprocess.algorithm.clip;
46

  
47
import org.gvsig.fmap.dal.exception.DataException;
48
import org.gvsig.fmap.dal.feature.EditableFeature;
49
import org.gvsig.fmap.dal.feature.Feature;
50
import org.gvsig.fmap.geom.exception.CreateGeometryException;
51
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation;
52
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil;
53
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess;
54

  
55
import com.vividsolutions.jts.geom.Geometry;
56

  
57
import es.unex.sextante.core.Sextante;
58
/**
59
 * This class analyzes all features of a layer, clipping its geometries
60
 * with the convex hull of another layer.
61
 * If the geometry of the feature analyzed doesnt intersect with the convex
62
 * hull geometry, the clipvisitor will ignore it.
63
 *
64
 * It intersects, computes intersection and creates a new feature with
65
 * the same attributes and the new intersection geometry.
66
 * 
67
 * @author Nacho Brodin (nachobrodin@gmail.com)
68
 */
69
public class ClipOperation extends GeometryOperation {
70

  
71
	/**
72
	 * Clipping geometry: the convex hull of the
73
	 * clipping layer
74
	 */
75
	private Geometry                         clippingConvexHull   = null;
76

  
77
	public ClipOperation(org.gvsig.fmap.geom.Geometry clip, AbstractSextanteGeoProcess p) {
78
		super(p);
79
		this.clippingConvexHull = GeometryUtil.geomToJTS(clip);
80
	}
81

  
82
	/**
83
	 * clips feature's geometry with the clipping geometry, preserving
84
	 * feature's original attributes.
85
	 * If feature's geometry doesnt touch clipping geometry, it will be
86
	 * ignored.
87
	 */
88
	public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature feature) {
89
		if(g == null)
90
			return lastEditFeature;
91
		
92
		Geometry jtsGeom = GeometryUtil.geomToJTS(g);
93
		
94
		if(!jtsGeom.getEnvelope().intersects(clippingConvexHull.getEnvelope()))
95
			return lastEditFeature;
96
		
97
		if(jtsGeom.intersects(clippingConvexHull)) {
98
			try {
99
				Geometry newGeom = jtsGeom.intersection(clippingConvexHull);
100
				lastEditFeature = persister.addFeature(feature, newGeom);
101
			} catch(com.vividsolutions.jts.geom.TopologyException e){
102
				Sextante.addErrorToLog(e);
103
				if(! jtsGeom.isValid()) {
104
					System.out.println("La geometria de entrada no es valida");
105
					jtsGeom = GeometryUtil.removeDuplicatesFrom(jtsGeom);
106
				}
107
				if(! clippingConvexHull.isValid()) {
108
					System.out.println("La geometria de recorte no es valida");
109
					clippingConvexHull = GeometryUtil.removeDuplicatesFrom(clippingConvexHull);
110
				}
111
				try {
112
					Geometry newGeom = jtsGeom.intersection(clippingConvexHull);
113
					lastEditFeature = persister.addFeature(feature, newGeom);
114
				} catch(com.vividsolutions.jts.geom.TopologyException ee){
115
					Sextante.addErrorToLog(ee);
116
				} catch (CreateGeometryException ee) {
117
					Sextante.addErrorToLog(ee);
118
				} catch (DataException ee) {
119
					Sextante.addErrorToLog(ee);
120
				}
121
			} catch (CreateGeometryException e) {
122
				Sextante.addErrorToLog(e);
123
			} catch (DataException e) {
124
				Sextante.addErrorToLog(e);
125
			}
126
		}
127
		return lastEditFeature;
128
	}
129
	
130
	/**
131
	 * clips feature's geometry with the clipping geometry, preserving
132
	 * feature's original attributes.
133
	 * If feature's geometry doesnt touch clipping geometry, it will be
134
	 * ignored.
135
	 */
136
	public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature feature) {
137
		if(g == null)
138
			return;
139
		
140
		lastEditFeature = feature;
141
		
142
		Geometry jtsGeom = GeometryUtil.geomToJTS(g);
143
		
144
		if(!jtsGeom.getEnvelope().intersects(clippingConvexHull.getEnvelope()))
145
			return;
146
		
147
		if(jtsGeom.intersects(clippingConvexHull)) {
148
			try {
149
				Geometry newGeom = jtsGeom.intersection(clippingConvexHull);
150
				persister.addFeature(feature, newGeom);
151
			} catch(com.vividsolutions.jts.geom.TopologyException e){
152
				Sextante.addErrorToLog(e);
153
				if(! jtsGeom.isValid()) {
154
					System.out.println("La geometria de entrada no es valida");
155
					jtsGeom = GeometryUtil.removeDuplicatesFrom(jtsGeom);
156
				}
157
				if(! clippingConvexHull.isValid()) {
158
					System.out.println("La geometria de recorte no es valida");
159
					clippingConvexHull = GeometryUtil.removeDuplicatesFrom(clippingConvexHull);
160
				}
161
				try {
162
					Geometry newGeom = jtsGeom.intersection(clippingConvexHull);
163
					persister.addFeature(feature, newGeom);
164
				} catch(com.vividsolutions.jts.geom.TopologyException ee){
165
					Sextante.addErrorToLog(ee);
166
				} catch (CreateGeometryException ee) {
167
					Sextante.addErrorToLog(ee);
168
				} catch (DataException ee) {
169
					Sextante.addErrorToLog(ee);
170
				}
171
			} catch (CreateGeometryException e) {
172
				Sextante.addErrorToLog(e);
173
			} catch (DataException e) {
174
				Sextante.addErrorToLog(e);
175
			}
176
		}
177
	}
178
	
179
	/**
180
	 * Ends the edition and closes the FeatureStore
181
	 */
182
	public void end() {
183
		persister.end();
184
	}
185

  
186
	public String getProcessDescription() {
187
		return "Clipping features agaisnt a clip geometry";
188
	}
189
}
190

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/java/org/gvsig/geoprocess/algorithm/clip/ClipLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2012 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.geoprocess.algorithm.clip;
25

  
26
import org.gvsig.geoprocess.algorithm.base.core.AlgorithmAbstractLibrary;
27
import org.gvsig.i18n.Messages;
28
import org.gvsig.tools.library.LibraryException;
29

  
30
/**
31
 * Initialization of ClipLibrary library.
32
 * 
33
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
34
 */
35
public class ClipLibrary extends AlgorithmAbstractLibrary {
36

  
37
    @Override
38
    protected void doInitialize() throws LibraryException {
39
        // Nothing to do
40
    }
41

  
42
    @Override
43
    protected void doPostInitialize() throws LibraryException {
44
        Messages.addResourceFamily("org.gvsig.geoprocess.algorithm.clip.clip",
45
            ClipLibrary.class.getClassLoader(), ClipLibrary.class.getClass()
46
                .getName());
47
        registerGeoProcess(new ClipAlgorithm());
48
    }
49

  
50
}
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/java/org/gvsig/geoprocess/algorithm/clip/ClipAlgorithm.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2012 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.geoprocess.algorithm.clip;
25

  
26
import org.gvsig.fmap.dal.exception.DataException;
27
import org.gvsig.fmap.dal.feature.FeatureStore;
28
import org.gvsig.fmap.dal.feature.FeatureType;
29
import org.gvsig.geoprocess.algorithm.base.core.ScalableUnionOperation;
30
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess;
31
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer;
32

  
33
import es.unex.sextante.core.Sextante;
34
import es.unex.sextante.dataObjects.IVectorLayer;
35
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException;
36
import es.unex.sextante.exceptions.RepeatedParameterNameException;
37
import es.unex.sextante.outputs.OutputVectorLayer;
38

  
39
/**
40
 * Clip algorithm
41
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
42
 */
43
public class ClipAlgorithm extends AbstractSextanteGeoProcess {
44

  
45
	public static final String  RESULT_POL            = "RESULT_POL";
46
	public static final String  RESULT_LIN            = "RESULT_LIN";
47
	public static final String  RESULT_POINT          = "RESULT_POINT";
48
	public static final String  LAYER                 = "LAYER";
49
	public static final String  CLIP                  = "CLIP";
50
	public static final String  SELECTGEOM_INPUT      = "SELECTGEOM_INPUT";
51
	public static final String  SELECTGEOM_OVERLAY    = "SELECTGEOM_OVERLAY";
52
	
53
	/*
54
	 * (non-Javadoc)
55
	 * @see es.unex.sextante.core.GeoAlgorithm#defineCharacteristics()
56
	 */
57
	public void defineCharacteristics() {
58
        setName(getTranslation("Clip"));
59
        setGroup(getTranslation("basic_vect_algorithms"));
60
        // setGeneratesUserDefinedRasterOutput(false);
61
		
62
		try {
63
			m_Parameters.addInputVectorLayer(LAYER, 
64
                getTranslation("Input_layer"),
65
												IVectorLayer.SHAPE_TYPE_WRONG, 
66
												true);
67
			m_Parameters.addInputVectorLayer(CLIP, 
68
                getTranslation("Clip_layer"),
69
												IVectorLayer.SHAPE_TYPE_POLYGON, 
70
												true);
71
            m_Parameters.addBoolean(SELECTGEOM_INPUT, 
72
            		getTranslation("Selected_geometries_input_layer_clip"), false);
73
            m_Parameters.addBoolean(SELECTGEOM_OVERLAY, 
74
            		getTranslation("Selected_geometries_overlay_layer_clip"), false);
75
		} catch (RepeatedParameterNameException e) {
76
			Sextante.addErrorToLog(e);
77
		}
78
        //addOutputVectorLayer(RESULT, getTranslation("Clip"),
79
           // OutputVectorLayer.SHAPE_TYPE_UNDEFINED);
80
        
81
        addOutputVectorLayer(RESULT_POL, getTranslation("Clip_polygon"),
82
        		OutputVectorLayer.SHAPE_TYPE_POLYGON);
83
        addOutputVectorLayer(RESULT_LIN, getTranslation("Clip_line"),
84
        		OutputVectorLayer.SHAPE_TYPE_LINE);
85
        addOutputVectorLayer(RESULT_POINT, getTranslation("Clip_point"),
86
        		OutputVectorLayer.SHAPE_TYPE_POINT);
87
	}
88
	
89
	/*
90
	 * (non-Javadoc)
91
	 * @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm()
92
	 */
93
	public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
94
		if(existsOutPutFile(ClipAlgorithm.RESULT_POL, 0) || 
95
			existsOutPutFile(ClipAlgorithm.RESULT_LIN, 0) ||
96
			existsOutPutFile(ClipAlgorithm.RESULT_POINT, 0)) {
97
    		throw new GeoAlgorithmExecutionException(getTranslation("file_exists"));
98
    	}
99
		org.gvsig.fmap.geom.Geometry clippingGeometry = null;
100
		IVectorLayer clip = m_Parameters.getParameterValueAsVectorLayer(CLIP);
101
		IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER);
102
		boolean selectedGeomInput = m_Parameters.getParameter(SELECTGEOM_INPUT).getParameterValueAsBoolean();
103
		boolean selectedGeomOverlay = m_Parameters.getParameter(SELECTGEOM_OVERLAY).getParameterValueAsBoolean();
104
		
105
		try {
106
			clippingGeometry = ScalableUnionOperation.joinLayerGeometries(clip, selectedGeomOverlay);
107
		} catch (Exception e) {
108
			Sextante.addErrorToLog(e);
109
			return false;
110
		}
111
		
112
		FeatureStore storeLayer = null;
113
		if(layer instanceof FlyrVectIVectorLayer && clippingGeometry != null)
114
			storeLayer = ((FlyrVectIVectorLayer)layer).getFeatureStore();
115
		else
116
			return false;
117
		
118
		try {
119
			FeatureType featureType = storeLayer.getDefaultFeatureType();
120
			
121
			if(isPolygon(storeLayer) || isUndefined(storeLayer)) {
122
				FeatureStore outFeatStore =
123
					buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON,
124
							getTranslation("Clip_polygon"), RESULT_POL);
125

  
126
				ClipOperation operation = new ClipOperation(clippingGeometry, this);
127
				operation.setTaskStatus(getStatus());
128
				operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, 
129
						selectedGeomInput, false, true);
130
			} else {
131
				buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON,
132
							getTranslation("Null_polygon"), RESULT_POL);
133
			}
134
			
135
			if(isLine(storeLayer) || isUndefined(storeLayer)) {
136
				FeatureStore outFeatStore =
137
					buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE,
138
							getTranslation("Clip_line"), RESULT_LIN);
139

  
140
				ClipOperation operation = new ClipOperation(clippingGeometry, this);
141
				operation.setTaskStatus(getStatus());
142
				operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, 
143
						selectedGeomInput, false, true);
144
			} else {
145
				buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE,
146
						getTranslation("Null_line"), RESULT_LIN);
147
			}
148
			
149
			if(isPoint(storeLayer) || isUndefined(storeLayer)) {
150
				FeatureStore outFeatStore =
151
					buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POINT,
152
							getTranslation("Clip_point"), RESULT_POINT);
153

  
154
				ClipOperation operation = new ClipOperation(clippingGeometry, this);
155
				operation.setTaskStatus(getStatus());
156
				operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, 
157
						selectedGeomInput, false, true);
158
			} else {
159
				buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POINT,
160
						getTranslation("Null_point"), RESULT_POINT);
161
			}
162
		} catch (DataException e) {
163
			Sextante.addErrorToLog(e);
164
			return false;
165
		}
166
		
167
		return true;
168
	}
169
	
170
}
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.geoprocess.algorithm.clip.ClipLibrary
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/resources/org/gvsig/geoprocess/algorithm/clip/clip.properties
1
#
2
# gvSIG. Desktop Geographic Information System.
3
#
4
# Copyright (C) 2007-2012 gvSIG Association.
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
# MA  02110-1301, USA.
20
#
21
# For any additional information, do not hesitate to contact us
22
# at info AT gvsig.com, or visit our website www.gvsig.com.
23
#
24

  
25
basic_vect_algorithms=Capas vectoriales
26
Clip_layer=Capa de recorte
27
Clip=Recorte
28
Input_layer=Capa de entrada
29
Clip_layer=Capa de recorte
30
Selected_geometries=Geometr?as seleccionadas
31
Selected_geometries_input_layer_clip=Geom. seleccionadas (Capa entrada)
32
Selected_geometries_overlay_layer_clip=Geom. seleccionadas (Capa recorte)
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/resources/org/gvsig/geoprocess/algorithm/clip/clip_en.properties
1
#
2
# gvSIG. Desktop Geographic Information System.
3
#
4
# Copyright (C) 2007-2012 gvSIG Association.
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
# MA  02110-1301, USA.
20
#
21
# For any additional information, do not hesitate to contact us
22
# at info AT gvsig.com, or visit our website www.gvsig.com.
23
#
24

  
25
basic_vect_algorithms=Vector layers tools
26
Clip_layer=Clip cover
27
Clip=Clip
28
Input_layer=Input cover
29
Selected_geometries=Selected features
30
Selected_geometries_input_layer_clip=Selected features (Input cover)
31
Selected_geometries_overlay_layer_clip=Selected features (Clip cover)
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/resources/help/ClipAlgorithm.xml
1
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2012 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 2
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
	<help>
28
		<element name="DESCRIPTION" text="Este geoproceso permite limitar el &#225;mbito de trabajo de una capa vectorial (da igual que sea de puntos, l&#237;neas o pol&#237;gonos), extrayendo de &#233;sta una zona de inter&#233;s.&#10;&#10;Para ello, el usuario deber&#225; proporcionar una capa de entrada (la capa de la que se quiere extraer un zona) y una capa de recorte, de forma que la uni&#243;n de las geometr&#237;as incluidas en la capa de recorte definir&#225;n el &#225;mbito de trabajo.&#10;&#10;El geoproceso recorrer&#225; todos los elementos vectoriales de la capa de entrada (features), y para aquellos que est&#233;n contenidos en el &#225;mbito de trabajo definido por la capa de recorte, calcular&#225; sus intersecciones, de forma que en la capa resultado solo estar&#225;n los elementos vectoriales de nuestro &#225;mbito de inter&#233;s. La porci&#243;n de geometr&#237;a que quede fuera del &#225;mbito de trabajo ser&#225; recortada.&#10;&#10;El esquema alfanum&#233;rico de la capa de entrada se mantiene intacto." description="Descripci&#243;n" type="0">
29
			<image description="" file="clipdesc.png">
30
			</image>
31
		</element>
32
		<element name="ADDITIONAL_INFO" text="" description="Informaci&#243;n adicional" type="0">
33
			<image description="" file="clip.gif">
34
			</image>
35
		</element>
36
		<element name="EXTENSION_AUTHOR" text="Nacho Brodin" description="Algoritmo creado por" type="0">
37
		</element>
38
		<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0">
39
		</element>
40
		<element name="USER_NOTES" text="" description="Notas de usuario" type="0">
41
		</element>
42
		<element name="LAYER" text="" description="Capa de entrada" type="3">
43
		</element>
44
		<element name="CLIP" text="" description="Capa de recorte" type="3">
45
		</element>
46
		<element name="CHECK" text="" description="Geometrias seleccionadas" type="3">
47
		</element>
48
		<element name="OUTPUT_DESCRIPTION" text="" description="Descripci&#243;n" type="2">
49
		</element>
50
		<element name="RESULT" text="" description="Recorte" type="2">
51
		</element>
52
	</help>
53
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/resources/help/ClipAlgorithm_en.xml
1
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2012 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 2
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
	<help>
28
		<element name="DESCRIPTION" text="This geoprocess clips the geometries of the input layer with the envelope of a clipping layer. After that, result layer will be formed by features whose geometries are within bounding box of clipping layer.&#10;&#10;Result layer will have the same alphanumeric schema of the input layer.&#10;&#10;This could be useful to limit the working layer set to a geographical region of interest (for example, making a local gis with layers from a statal dataset)." description="Descripci&#243;n" type="0">
29
			<image description="" file="clipdesc.png">
30
			</image>
31
		</element>
32
		<element name="ADDITIONAL_INFO" text="" description="Informaci&#243;n adicional" type="0">
33
			<image description="" file="clip.gif">
34
			</image>
35
		</element>
36
		<element name="EXTENSION_AUTHOR" text="Nacho Brodin" description="Algoritmo creado por" type="0">
37
		</element>
38
		<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0">
39
		</element>
40
		<element name="USER_NOTES" text="" description="Notas de usuario" type="0">
41
		</element>
42
		<element name="LAYER" text="" description="Capa de entrada" type="3">
43
		</element>
44
		<element name="CLIP" text="" description="Capa de recorte" type="3">
45
		</element>
46
		<element name="CHECK" text="" description="Geometrias seleccionadas" type="3">
47
		</element>
48
		<element name="OUTPUT_DESCRIPTION" text="" description="Descripci&#243;n" type="2">
49
		</element>
50
		<element name="RESULT" text="" description="Recorte" type="2">
51
		</element>
52
	</help>
53
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
0 54

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/ConvexHullOperation.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2012 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* CVS MESSAGES:
25
*
26
* $Id: ScalableConvexHullVisitor.java 10626 2007-03-06 16:55:54Z caballero $
27
* $Log$
28
* Revision 1.2  2007-03-06 16:47:58  caballero
29
* Exceptions
30
*
31
* Revision 1.1  2006/06/20 18:20:45  azabala
32
* first version in cvs
33
*
34
* Revision 1.2  2006/06/02 18:21:28  azabala
35
* *** empty log message ***
36
*
37
* Revision 1.1  2006/05/24 21:13:31  azabala
38
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
39
*
40
* Revision 1.3  2006/03/15 18:31:06  azabala
41
* *** empty log message ***
42
*
43
* Revision 1.2  2006/03/07 21:01:33  azabala
44
* *** empty log message ***
45
*
46
* Revision 1.1  2006/03/06 19:48:39  azabala
47
* *** empty log message ***
48
*
49
* Revision 1.2  2006/03/05 19:57:48  azabala
50
* *** empty log message ***
51
*
52
* Revision 1.1  2006/02/17 16:32:50  azabala
53
* *** empty log message ***
54
*
55
*
56
*/
57
package org.gvsig.geoprocess.algorithm.convexhull;
58

  
59
import com.vividsolutions.jts.geom.Geometry;
60
import com.vividsolutions.jts.geom.GeometryCollection;
61
import com.vividsolutions.jts.geom.GeometryFactory;
62

  
63
import es.unex.sextante.core.Sextante;
64

  
65
import org.gvsig.fmap.dal.exception.DataException;
66
import org.gvsig.fmap.dal.feature.FeatureStore;
67
import org.gvsig.fmap.geom.GeometryLocator;
68
import org.gvsig.fmap.geom.GeometryManager;
69
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
70
import org.gvsig.fmap.geom.operation.GeometryOperationException;
71
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
72
import org.gvsig.fmap.geom.operation.fromjts.FromJTS;
73
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil;
74

  
75
/**
76
 * Convex Hull operation
77
 * @author Nacho Brodin (nachobrodin@gmail.com)
78
 */
79
public class ConvexHullOperation {
80
	public static final String  NAME             = "ConvexHull";
81
	public static final int     CODE             = GeometryLocator.getGeometryManager().getGeometryOperationCode(NAME);
82
	Geometry                    geometry         = null;
83
	GeometryFactory             geomFact         = null;
84
	private GeometryManager     geometryManager  = null;
85
	
86
	public ConvexHullOperation() {
87
		geometry = null;
88
		geometryManager = GeometryLocator.getGeometryManager();
89
	}
90
	
91
	public void setFeatureStore(FeatureStore out, String[] attrNames) throws DataException {
92
	}
93
	
94
	/**
95
	 * Returns FMap convex hull geometry.
96
	 * @return
97
	 */
98
	public org.gvsig.fmap.geom.Geometry getGeometry() {
99
		if(geometry == null)
100
			return null;
101
		GeometryOperationContext ctx = new GeometryOperationContext();
102
		ctx.setAttribute(FromJTS.PARAM, geometry);
103
		try {
104
			return (org.gvsig.fmap.geom.Geometry)geometryManager.invokeOperation(FromJTS.NAME, ctx);
105
		} catch (GeometryOperationNotSupportedException e) {
106
			Sextante.addErrorToLog(e);
107
			return null;
108
		} catch (GeometryOperationException e) {
109
			Sextante.addErrorToLog(e);
110
			return null;
111
		}
112
	}
113

  
114
	
115
	public org.gvsig.fmap.geom.Geometry invoke(org.gvsig.fmap.geom.Geometry g) {
116
		if(g == null)
117
			return null;
118
		
119
		com.vividsolutions.jts.geom.Geometry actualGeometry = GeometryUtil.geomToJTS(g);
120
		
121
		if(geometry == null)
122
			geometry = actualGeometry;
123
		else {
124
			com.vividsolutions.jts.geom.Geometry[] geoms = new com.vividsolutions.jts.geom.Geometry[2];
125
			geoms[0] = geometry;
126
			geoms[1] = actualGeometry;
127
			if(geomFact == null)
128
				geomFact = new GeometryFactory();
129
			GeometryCollection gc = geomFact.createGeometryCollection(geoms);
130
			geometry = gc.convexHull();	
131
		}
132
		return getGeometry();
133
	}
134

  
135
	/*
136
	 * (non-Javadoc)
137
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
138
	 */
139
	public int getOperationIndex() {
140
		return CODE;
141
	}
142

  
143
}
144

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/ConvexHullParametersPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2012 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.geoprocess.algorithm.convexhull;
25

  
26
import java.awt.Dimension;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.Insets;
30
import java.awt.event.ActionEvent;
31
import java.awt.event.ActionListener;
32
import java.util.ArrayList;
33
import java.util.Iterator;
34
import java.util.List;
35

  
36
import javax.swing.JButton;
37
import javax.swing.JComboBox;
38

  
39
import es.unex.sextante.core.GeoAlgorithm;
40
import es.unex.sextante.core.Sextante;
41
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel;
42

  
43
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
45

  
46
import org.gvsig.fmap.dal.DALLocator;
47
import org.gvsig.fmap.dal.DataManager;
48
import org.gvsig.fmap.dal.DataStoreParameters;
49
import org.gvsig.fmap.dal.exception.InitializeException;
50
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
51
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor;
52
import org.gvsig.tools.service.ServiceException;
53

  
54
/**
55
 * @deprecated
56
 * @author Nacho Brodin (nachobrodin@gmail.com)
57
 */
58
public class ConvexHullParametersPanel extends GeoAlgorithmParametersPanel implements ActionListener {
59

  
60
    private static final long serialVersionUID = 3260891769310434508L;
61

  
62
    private static final Logger LOG =
63
        LoggerFactory.getLogger(ConvexHullParametersPanel.class);
64
    
65
	private JComboBox                        combo               = null;
66
	private JButton                          button              = null;
67
	private ArrayList<DataStoreParameters>   paramList           = new ArrayList<DataStoreParameters>();
68
	
69
	public ConvexHullParametersPanel() {
70
		super();
71
	}
72

  
73
    public void init(GeoAlgorithm algorithm) {
74
    	initGUI();
75
    }
76

  
77
	private void initGUI() {
78
		GridBagLayout gbl = new GridBagLayout();
79
		this.setLayout(gbl);
80
		
81
		GridBagConstraints gbc = new GridBagConstraints();
82
		gbc.fill = GridBagConstraints.HORIZONTAL;
83
		gbc.weightx = 1.0;
84
		gbc.gridx = 0;
85
		gbc.gridy = 0;
86
		gbc.insets = new Insets(0, 2, 0, 0);
87
		this.add(getCombo(), gbc);
88
		
89
		gbc.fill = GridBagConstraints.NONE;
90
		gbc.weightx = 0;
91
		gbc.gridx = 1;
92
		gbc.insets = new Insets(0, 5, 0, 2);
93
		this.add(getButton(), gbc);
94
	}
95

  
96
	/**
97
	 * Gets a ComboBox
98
	 * @return
99
	 */
100
	public JComboBox getCombo() {
101
		if(combo == null) {
102
			combo = new JComboBox();
103
			loadProviderList(combo, paramList);
104
			combo.addActionListener(this);
105
			combo.setPreferredSize(new Dimension(0, 18));
106
		}
107
		return combo;
108
	}
109
	
110
	/**
111
	 * Gets a JButton
112
	 * @return
113
	 */
114
	public JButton getButton() {
115
		if(button == null) {
116
			button = new JButton("...");
117
			button.setPreferredSize(new Dimension(60, 18));
118
			button.addActionListener(this);
119
		}
120
		return button;
121
	}
122
	
123
	@Override
124
    public void assignParameters() {
125
        // Nothing to do
126
	}
127

  
128
	@Override
129
	public void setOutputValue(String arg0, String arg1) {
130
		
131
	}
132

  
133
	@Override
134
	public void setParameterValue(String arg0, String arg1) {
135
		
136
	}
137
	
138
	@SuppressWarnings("unchecked")
139
	private void loadProviderList(JComboBox c, ArrayList<DataStoreParameters> paramList) {
140
		try {
141
		DataManager manager = DALLocator.getDataManager();
142
		List list = manager.getStoreProviders();
143
		Iterator it = list.iterator();
144
		c.removeAllItems();
145
		paramList.clear();
146
		while(it.hasNext()) {
147
			try {
148
				String provider = it.next().toString();
149
				DataStoreParameters param = manager.createStoreParameters(provider);
150
				c.addItem(provider);
151
				paramList.add(param);
152
			} catch (InitializeException e1) {
153
				Sextante.addErrorToLog(e1);
154
			} catch (ProviderNotRegisteredException e1) {
155
				Sextante.addErrorToLog(e1);
156
			}
157
		}
158
		}catch(Exception e){}
159
	}
160

  
161
	public void actionPerformed(ActionEvent e) {
162
		if(e.getSource() == getButton()) {
163
			int index = getCombo().getSelectedIndex();
164
			
165
            try {
166
                DynObjectEditor editor = new DynObjectEditor(paramList.get(index));
167
                editor.editObject(true);
168
            } catch (ServiceException ex) {
169
                LOG.error(
170
                    "Error creating a Swing component for the DynObject: "
171
                        + paramList.get(index), ex);
172
                Sextante.addErrorToLog(ex);
173
            }
174

  
175
		}
176
		
177
		if(e.getSource() == getCombo()) {
178
			
179
		}
180
	}
181
}
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/ConvexHullLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2012 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.geoprocess.algorithm.convexhull;
25

  
26
import org.gvsig.geoprocess.algorithm.base.core.AlgorithmAbstractLibrary;
27
import org.gvsig.i18n.Messages;
28
import org.gvsig.tools.library.LibraryException;
29

  
30
/**
31
 * Initialization of ConvexHullLibrary library.
32
 * 
33
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
34
 */
35
public class ConvexHullLibrary extends AlgorithmAbstractLibrary {
36

  
37
    @Override
38
    protected void doInitialize() throws LibraryException {
39

  
40
    }
41

  
42
    @Override
43
    protected void doPostInitialize() throws LibraryException {
44
        Messages.addResourceFamily(
45
            "org.gvsig.geoprocess.algorithm.convexhull.convexhull",
46
            ConvexHullLibrary.class.getClassLoader(), ConvexHullLibrary.class
47
                .getClass().getName());
48
        registerGeoProcess(new ConvexHullAlgorithm());
49
    }
50

  
51
}
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/ConvexHullAlgorithm.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2012 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.geoprocess.algorithm.convexhull;
25

  
26
import java.util.Iterator;
27
import java.util.List;
28

  
29
import org.gvsig.fmap.dal.exception.DataException;
30
import org.gvsig.fmap.dal.feature.Feature;
31
import org.gvsig.fmap.dal.feature.FeatureQuery;
32
import org.gvsig.fmap.dal.feature.FeatureSelection;
33
import org.gvsig.fmap.dal.feature.FeatureSet;
34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import org.gvsig.fmap.geom.Geometry;
36
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
37
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil;
38
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess;
39
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer;
40
import org.gvsig.tools.dispose.DisposableIterator;
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
43

  
44
import es.unex.sextante.core.Sextante;
45
import es.unex.sextante.dataObjects.IVectorLayer;
46
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException;
47
import es.unex.sextante.exceptions.RepeatedParameterNameException;
48
import es.unex.sextante.outputs.OutputVectorLayer;
49

  
50
/**
51
 * Convex Hull Algorithm
52
 *
53
 * @author Nacho Brodin (nachobrodin@gmail.com)
54
 */
55
public class ConvexHullAlgorithm extends AbstractSextanteGeoProcess {
56
	private static final Logger log = LoggerFactory.getLogger(ConvexHullAlgorithm.class);
57
    public static final String LAYER = "LAYER";
58
    public static final String RESULT = "RESULT";
59
    public static final String CHECK = "CHECK";
60

  
61
    public void defineCharacteristics() {
62
        setName(getTranslation("ConvexHull"));
63
        setGroup(getTranslation("basic_vect_algorithms"));
64
        // setGeneratesUserDefinedRasterOutput(false);
65
        try {
66
            m_Parameters.addInputVectorLayer(LAYER,
67
                getTranslation("Input_layer"), IVectorLayer.SHAPE_TYPE_WRONG,
68
                true);
69
            addOutputVectorLayer(RESULT, getTranslation("ConvexHull"),
70
                OutputVectorLayer.SHAPE_TYPE_POLYGON);
71
            m_Parameters.addBoolean(CHECK,
72
                getTranslation("Selected_geometries_convex_hull"), false);
73
        } catch (RepeatedParameterNameException e) {
74
            Sextante.addErrorToLog(e);
75
        }
76
    }
77

  
78
    /*
79
     * (non-Javadoc)
80
     *
81
     * @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm()
82
     */
83
    @SuppressWarnings("unchecked")
84
    public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
85
		if(existsOutPutFile(ConvexHullAlgorithm.RESULT, 0)) {
86
    		throw new GeoAlgorithmExecutionException(getTranslation("file_exists"));
87
    	}
88

  
89
        IVectorLayer input = m_Parameters.getParameterValueAsVectorLayer(LAYER);
90
        boolean selectedGeom =
91
            m_Parameters.getParameter(CHECK).getParameterValueAsBoolean();
92

  
93
        FeatureStore store = null;
94

  
95
        if (input instanceof FlyrVectIVectorLayer)
96
            store = ((FlyrVectIVectorLayer) input).getFeatureStore();
97
        else
98
            return false;
99

  
100
        ConvexHullOperation convexHullOperation = new ConvexHullOperation();
101

  
102
        FeatureSet features = null;
103
        try {
104
            DisposableIterator it = null;
105
            if (selectedGeom) {
106
            	features = store.getFeatureSet();
107
                FeatureSelection ds = store.getFeatureSelection();
108
                it = ds.iterator();
109
            } else {
110
            	FeatureQuery query = getQueryFromAnalysisExtent(m_AnalysisExtent, store);
111
                features = store.getFeatureSet(query);
112
                it = features.iterator();
113
            }
114

  
115
            int numberOfFeatures = (int) features.getSize();
116
            int iCount = 0;
117

  
118
            while (it.hasNext()) {
119
                Feature feature = (Feature) it.next();
120
                List geomList = feature.getGeometries();
121
                setProgress(iCount, numberOfFeatures);
122
                iCount++;
123
                if (geomList == null) {
124
                    Geometry geom = feature.getDefaultGeometry();
125
                    if (geom != null)
126
                        convexHullOperation.invoke(geom);
127
                    continue;
128
                }
129
                Iterator<Geometry> itGeom = geomList.iterator();
130
                while (itGeom.hasNext()) {
131
                    Geometry g = itGeom.next();
132
                    convexHullOperation.invoke(g);
133
                }
134
            }
135
            Geometry g = convexHullOperation.getGeometry();
136
            if (g == null)
137
                return false;
138
            String[] sNames = { "ID" };
139
            Class[] types = { Integer.class };
140
            IVectorLayer output =
141
                getNewVectorLayer(RESULT, getTranslation("ConvexHull"),
142
                    OutputVectorLayer.SHAPE_TYPE_POLYGON, types, sNames);
143

  
144
            com.vividsolutions.jts.geom.Geometry jtsGeom =
145
                GeometryUtil.geomToJTS(g);
146

  
147
            output.addFeature(jtsGeom, new Object[] { new Integer(0) });
148
            it.dispose();
149
        } catch (DataException e) {
150
            log.error("", e);
151
        } catch (CreateEnvelopeException e) {
152
			log.error("Error creating envelope", e);
153
		}
154
        return !m_Task.isCanceled();
155
    }
156
}
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/java/org/gvsig/geoprocess/algorithm/convexhull/TestPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2012 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.geoprocess.algorithm.convexhull;
25

  
26
import javax.swing.JFrame;
27
import javax.swing.UIManager;
28

  
29
public class TestPanel {
30
	private JFrame 			            frame = new JFrame();
31
	@SuppressWarnings("deprecation")
32
	private ConvexHullParametersPanel	hp = null;
33

  
34
	public TestPanel() {
35
		super();
36
		initialize();
37
	}
38

  
39
	public static void main(String[] args){
40
		try {
41
			UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
42
		} catch( Exception e ) {
43
			System.err.println( "No se puede cambiar al LookAndFeel");
44
		}
45
		new TestPanel();
46
	}
47

  
48
	@SuppressWarnings("deprecation")
49
	private void initialize() {
50
		frame.setSize(new java.awt.Dimension(370, 50));
51
		hp = new ConvexHullParametersPanel();
52
		hp.init(null);
53
		frame.setContentPane(hp);
54
		frame.setResizable(true);
55
		frame.setTitle("Panel");
56
		frame.setVisible(true);
57
		frame.addWindowListener(new java.awt.event.WindowAdapter() {
58
			public void windowClosing(java.awt.event.WindowEvent e) {
59
				System.exit(0);
60
			}
61
		});
62
	}
63
}
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/resources/org/gvsig/geoprocess/algorithm/convexhull/convexhull.properties
1
#
2
# gvSIG. Desktop Geographic Information System.
3
#
4
# Copyright (C) 2007-2012 gvSIG Association.
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
# MA  02110-1301, USA.
20
#
21
# For any additional information, do not hesitate to contact us
22
# at info AT gvsig.com, or visit our website www.gvsig.com.
23
#
24

  
25
basic_vect_algorithms=Capas vectoriales
26
Input_layer=Capa de entrada
27
ConvexHull=Envolvente convexa
28
Selected_geometries_convex_hull=Geom. seleccionadas (Capa entrada)
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/resources/org/gvsig/geoprocess/algorithm/convexhull/convexhull_en.properties
1
#
2
# gvSIG. Desktop Geographic Information System.
3
#
4
# Copyright (C) 2007-2012 gvSIG Association.
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
# MA  02110-1301, USA.
20
#
21
# For any additional information, do not hesitate to contact us
22
# at info AT gvsig.com, or visit our website www.gvsig.com.
23
#
24

  
25
basic_vect_algorithms=Vector layers tools
26
Input_layer=Input cover
27
ConvexHull=Convex Hull
28
Selected_geometries_convex_hull=Selected features (Input cover)
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/resources/help/ConvexHullAlgorithm.xml
1
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2012 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 2
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
	<help>
28
		<element name="DESCRIPTION" text="Este geoproceso c&#225;lcula la envolvente convexa (convex hull), o pol&#237;gono convexo de menor &#225;rea que envuelve a todos los elementos vectoriales de una capa de entrada.&#10;Opera &#250;nicamente con una capa de entrada, cuyo tipo de geometr&#237;a podr&#225; ser de cualquier tipo.&#10;&#10;Las aplicaciones de este geoproceso pueden ser de distinto tipo:&#10;&lt;UL&gt;&#10;&lt;LI&gt;Determinar la zona de cobertura de un determinado fen&#243;meno geogr&#225;fico.&lt;/LI&gt;&#10;&lt;LI&gt;C&#225;lculo del diametro de la zona cubierta por una serie de geometr&#237;as,&lt;/LI&gt;&#10;&lt;/UL&gt;&#10;etc." description="Descripci&#243;n" type="0">
29
			<image description="" file="convexhulldesc.png">
30
			</image>
31
		</element>
32
		<element name="ADDITIONAL_INFO" text="" description="Informaci&#243;n adicional" type="0">
33
		</element>
34
		<element name="EXTENSION_AUTHOR" text="Nacho Brodin" description="Algoritmo creado por" type="0">
35
		</element>
36
		<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0">
37
		</element>
38
		<element name="USER_NOTES" text="" description="Notas de usuario" type="0">
39
		</element>
40
		<element name="LAYER" text="" description="Capa de entrada" type="3">
41
		</element>
42
		<element name="CHECK" text="" description="Geometrias seleccionadas" type="3">
43
		</element>
44
		<element name="OUTPUT_DESCRIPTION" text="" description="Descripci&#243;n" type="2">
45
		</element>
46
		<element name="RESULT" text="" description="Convex Hull" type="2">
47
		</element>
48
	</help>
49
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.26/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.convexhull/src/main/resources/help/ConvexHullAlgorithm_en.xml
1
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2012 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 2
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
	<help>
28
		<element name="DESCRIPTION" text="This geoprocess creates a new polygon layer, with polygon buffers of the geometries of the input layer.&#10;&#10;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.&#10;&#10;It could be useful for:&#10;&lt;UL&gt;&#10;&lt;LI&gt;See the area of interest of a given geographical sucess..&lt;/LI&gt;&#10;&lt;LI&gt;Computing the diameter of a set of geometries&lt;/LI&gt;&#10;&lt;/UL&gt;&#10;etc." description="Descripci&#243;n" type="0">
29
			<image description="" file="convexhulldesc.png">
30
			</image>
31
		</element>
32
		<element name="ADDITIONAL_INFO" text="" description="Informaci&#243;n adicional" type="0">
33
		</element>
34
		<element name="EXTENSION_AUTHOR" text="Nacho Brodin" description="Algoritmo creado por" type="0">
35
		</element>
36
		<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0">
37
		</element>
38
		<element name="USER_NOTES" text="" description="Notas de usuario" type="0">
39
		</element>
40
		<element name="LAYER" text="" description="Capa de entrada" type="3">
41
		</element>
42
		<element name="CHECK" text="" description="Geometrias seleccionadas" type="3">
43
		</element>
44
		<element name="OUTPUT_DESCRIPTION" text="" description="Descripci&#243;n" type="2">
45
		</element>
46
		<element name="RESULT" text="" description="Convex Hull" type="2">
47
		</element>
48
	</help>
49
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff