Revision 1942

View differences:

org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/src/main/resources/org/gvsig/geoprocess/algorithm/splitlines/splitlines.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
lateral_buffer=?rea de influencia lateral
25
left=Izquierda
26
right=Derecha
27
select_lateral=Seleccionar lateral
28
SplitLines._Introduccion_de_datos=Cortar l?neas. Introducci?n de datos
29
split_lines=Cortar l?neas
30
distance_section=Distancia de la secci?n
31
Mensaje_split=Geoproceso split....
32
Mensaje_procesando_split=Partiendo geometr?as...
33
new_geoprocess=Geoprocesos nuevos
34
multigeometry=Generar tramos como multigeometr?as
0 35

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/src/main/resources/org/gvsig/geoprocess/algorithm/splitlines/splitlines_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
lateral_buffer=Lateral buffer
25
left=Left
26
right=Right
27
select_lateral=Select lateral
28
SplitLines._Introduccion_de_datos=Split lines. Data introduction
29
split_lines=Split lines
30
distance_section=Distance section
31
Mensaje_split=Split geoprocess
32
Mensaje_procesando_split=Splitting geometries...
33
new_geoprocess=New geoprocess
34
multigeometry=Build stretches as multigeometries
0 35

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/src/main/resources/org/gvsig/geoprocess/algorithm/splitlines/splitlines_de.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
lateral_buffer=Lateral buffer
25
left=Left
26
right=Right
27
select_lateral=Select lateral
28
SplitLines._Introduccion_de_datos=Split lines. Data introduction
29
split_lines=Split lines
30
distance_section=Distance section
31
Mensaje_split=Split geoprocess
32
Mensaje_procesando_split=Splitting geometries...
33
new_geoprocess=New geoprocess
0 34

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/src/main/resources/help/SplitLinesAlgorithm.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 crea una nueva capa vectorial de l&#237;neas, generados a partir de dividir la capa de entrada en tramos con la distancia especificada.&#10;&#10;Las geometr&#237;as de la capa de entrada pueden ser de tipo l&#237;nea &#250;nicamente.' description="Descripci&#243;n" type="0">
29
			<image description="" file="split_lines.jpg">
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="INTER" text="" description="Capa de revestimiento" type="3">
43
		</element>
44
		<element name="CHECK" text="" description="Geometrias seleccionadas" type="3">
45
		</element>
46
		<element name="OUTPUT_DESCRIPTION" text="" description="Descripci&#243;n" type="2">
47
		</element>
48
		<element name="RESULT" text="" description="Intersecci&#243;n" type="2">
49
		</element>
50
	</help>
0 51

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/src/main/resources/help/SplitLinesAlgorithm_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 only line types. For each input geometry, you could create one or many equidistant polygon buffer rings.' description="Descripci&#243;n" type="0">
29
			<image description="" file="split_lines.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="INTER" text="" description="Capa de revestimiento" type="3">
43
		</element>
44
		<element name="CHECK" text="" description="Geometrias seleccionadas" type="3">
45
		</element>
46
		<element name="OUTPUT_DESCRIPTION" text="" description="Descripci&#243;n" type="2">
47
		</element>
48
		<element name="RESULT" text="" description="Intersecci&#243;n" type="2">
49
		</element>
50
	</help>
51
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
0 52

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/src/main/resources/help/SplitLinesAlgorithm_de.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='Dies schafft eine neue geoprocess Polygonlayer, mit Polygon-Puffer der Geometrien der Input-Layer.&#10;&#10;Input-Layer-Geometrien haben k?nnte nur Linientypen. F?r jeden Eingang Geometrie, k?nnten Sie einen oder mehrere ?quidistante Polygon-Puffer Ringe.' description="Descripci&#243;n" type="0">
29
			<image description="" file="split_lines.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="INTER" text="" description="Capa de revestimiento" type="3">
43
		</element>
44
		<element name="CHECK" text="" description="Geometrias seleccionadas" type="3">
45
		</element>
46
		<element name="OUTPUT_DESCRIPTION" text="" description="Descripci&#243;n" type="2">
47
		</element>
48
		<element name="RESULT" text="" description="Intersecci&#243;n" type="2">
49
		</element>
50
	</help>
51
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
0 52

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.geoprocess.algorithm.splitlines.SplitLinesLibrary
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/src/main/java/org/gvsig/geoprocess/algorithm/splitlines/SplitLinesLibrary.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.splitlines;
25

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

  
30
/**
31
 * Initialization of IntersectionLibrary library.
32
 * 
33
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
34
 */
35
public class SplitLinesLibrary 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.splitlines.splitlines",
46
            SplitLinesLibrary.class.getClassLoader(),
47
            SplitLinesLibrary.class.getClass().getName());
48
        registerGeoProcess(new SplitLinesAlgorithm());
49
    }
50

  
51
}
0 52

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/src/main/java/org/gvsig/geoprocess/algorithm/splitlines/SplitLinesAlgorithm.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.splitlines;
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.lib.sextante.AbstractSextanteGeoProcess;
30
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer;
31

  
32
import es.unex.sextante.additionalInfo.AdditionalInfoNumericalValue;
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
 * Lateral buffer algorithm
41
 * 
42
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
43
 */
44
public class SplitLinesAlgorithm extends AbstractSextanteGeoProcess {
45

  
46
	public static final String   RESULT                = "RESULT";
47
	public static final String   LAYER                 = "LAYER";
48
	public static final String   DISTANCE              = "DISTANCE";
49
	public static final String   SELECTGEOM_INPUT      = "SELECTGEOM_INPUT";
50
	public static final String   MULTIGEOMETRY         = "MULTIGEOMETRY";
51
	
52
	private FlyrVectIVectorLayer sextanteInputLayer    = null;
53
    protected FeatureStore       inputStore            = null;
54
    protected FeatureStore       outputStore           = null;
55
	
56
	/*
57
	 * (non-Javadoc)
58
	 * @see es.unex.sextante.core.GeoAlgorithm#defineCharacteristics()
59
	 */
60
	public void defineCharacteristics() {
61
        setName(getTranslation("split_lines"));
62
        setGroup(getTranslation("basic_vect_algorithms"));
63
        // setGeneratesUserDefinedRasterOutput(false);
64
		
65
		try {
66
			m_Parameters.addInputVectorLayer(LAYER, 
67
												getTranslation("Input_layer"),
68
												IVectorLayer.SHAPE_TYPE_LINE, 
69
												true);
70
            m_Parameters.addBoolean(SELECTGEOM_INPUT, 
71
            		getTranslation("Selected_geometries"), false);
72
            m_Parameters.addNumericalValue(DISTANCE, getTranslation("distance_section"), 0,
73
                    AdditionalInfoNumericalValue.NUMERICAL_VALUE_DOUBLE);
74
           // m_Parameters.addBoolean(MULTIGEOMETRY, 
75
            		//getTranslation("multigeometry"), false);
76
		} catch (RepeatedParameterNameException e) {
77
			Sextante.addErrorToLog(e);
78
		}
79
		addOutputVectorLayer(RESULT, getTranslation("SplitLines_line"),
80
								OutputVectorLayer.SHAPE_TYPE_LINE);
81
	}
82
	
83
	/*
84
	 * (non-Javadoc)
85
	 * @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm()
86
	 */
87
	public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
88
		if(existsOutPutFile(SplitLinesAlgorithm.RESULT, 0)) {
89
    		throw new GeoAlgorithmExecutionException(getTranslation("file_exists"));
90
    	}
91
		
92
		sextanteInputLayer = (FlyrVectIVectorLayer)m_Parameters.getParameterValueAsVectorLayer(LAYER);
93
		boolean selectedGeomInput = m_Parameters.getParameter(SELECTGEOM_INPUT).getParameterValueAsBoolean();
94
		double distanceValue = m_Parameters.getParameter(DISTANCE).getParameterValueAsDouble();
95
		//boolean multigeometry = m_Parameters.getParameter(MULTIGEOMETRY).getParameterValueAsBoolean();
96
		boolean multigeometry = false;
97
		if (sextanteInputLayer instanceof FlyrVectIVectorLayer)
98
        	inputStore = ((FlyrVectIVectorLayer) sextanteInputLayer).getFeatureStore();
99
        else
100
            return false;
101
		
102
		SplitLinesOperation operation = new SplitLinesOperation(distanceValue, inputStore, this, multigeometry);
103
		operation.setGeoProcess(this, 100);
104
		operation.setTaskStatus(getStatus());
105
		
106
		FeatureType featureType = null;
107
		try {
108
			featureType = inputStore.getDefaultFeatureType();
109
		} catch (DataException e) {
110
			 Sextante.addErrorToLog(e);
111
			 return false;
112
		}
113
		
114
        outputStore = buildOutPutStore(featureType, 
115
        		IVectorLayer.SHAPE_TYPE_MULTILINE,
116
        		getTranslation("split_lines"), 
117
        		RESULT); 
118
    	
119
    	try {
120
			operation.computesGeometryOperation(inputStore, 
121
					outputStore,
122
					attrNames, 
123
					selectedGeomInput, 
124
					false, 
125
					true);
126
		} catch (DataException e) {
127
			 Sextante.addErrorToLog(e);
128
			 return false;
129
		}
130
		
131
		return true;
132
	}
133
}
0 134

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/src/main/java/org/gvsig/geoprocess/algorithm/splitlines/SplitLinesOperation.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.splitlines;
25

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

  
29
import org.gvsig.fmap.dal.exception.DataException;
30
import org.gvsig.fmap.dal.feature.EditableFeature;
31
import org.gvsig.fmap.dal.feature.Feature;
32
import org.gvsig.fmap.dal.feature.FeatureStore;
33
import org.gvsig.fmap.geom.exception.CreateGeometryException;
34
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation;
35
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil;
36
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess;
37

  
38
import com.vividsolutions.jts.geom.Geometry;
39
import com.vividsolutions.jts.linearref.LengthIndexedLine;
40

  
41
import es.unex.sextante.core.Sextante;
42

  
43
/**
44
 * Lateral buffer operation
45
 * 
46
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
47
 */
48
public class SplitLinesOperation extends GeometryOperation {
49
	private double  distance       = 0;
50
	private boolean multigeometry  = false;
51
    
52
	/**
53
     * Builds an instance of this operation.
54
     * 
55
     * @param distance
56
     * @param layer
57
     * @param userDistance
58
     */
59
    public SplitLinesOperation(double distance, 
60
    		FeatureStore inputStore, 
61
    		AbstractSextanteGeoProcess p,
62
    		boolean multigeometry) {
63
        super(p);
64
        this.distance = distance;
65
        this.multigeometry = multigeometry;
66
    }
67

  
68
    public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g,
69
        Feature feature) {
70
        Geometry originalGeometry = GeometryUtil.geomToJTS(g);
71
        
72
        if(originalGeometry == null)
73
        	return null;
74
        
75
        if(multigeometry) {
76
        	splitGeometryAsMultigeometry(originalGeometry, feature);
77
        } else {
78
        	splitGeometryAsMultipleFeatures(originalGeometry, feature);
79
        }
80

  
81
        return lastEditFeature;
82
    }
83
    
84
    /**
85
     * Split lines and store each one as a different feature. The new feature will be the 
86
     * original, so this data will be repeated
87
     * @param originalGeometry
88
     * @param feature
89
     */
90
    private void splitGeometryAsMultipleFeatures(Geometry originalGeometry, Feature feature) {
91
    	LengthIndexedLine lil = new LengthIndexedLine(originalGeometry);
92
        double end = lil.getEndIndex();
93

  
94
        int i = 0;
95
    	while ((distance * i) < end) {
96
    		Geometry newGeom = lil.extractLine(distance * i, distance * (i + 1));
97
    		i++;
98
    		try {
99
    			lastEditFeature = persister.addFeature(feature, newGeom);
100
    		} catch (CreateGeometryException e) {
101
    			Sextante.addErrorToLog(e);
102
    		} catch (DataException e) {
103
    			Sextante.addErrorToLog(e);
104
    		}
105
    	}
106
    }
107
    
108
    /**
109
     * For each feature and its geometries, this method split the lines and stores 
110
     * the new geometries in a multigeometry inside just one feature.
111
     */
112
    private void splitGeometryAsMultigeometry(Geometry originalGeometry, Feature feature) {
113
    	LengthIndexedLine lil = new LengthIndexedLine(originalGeometry);
114
        double end = lil.getEndIndex();
115
        List<Geometry> geomList = new ArrayList<Geometry>();
116

  
117
        int i = 0;
118
    	while ((distance * i) < end) {
119
    		Geometry newGeom = lil.extractLine(distance * i, distance * (i + 1));
120
    		i++;
121
    		geomList.add(newGeom);
122
    	}
123
    	
124
    	try {
125
			lastEditFeature = persister.addFeature(feature, geomList);
126
		} catch (CreateGeometryException e) {
127
			Sextante.addErrorToLog(e);
128
		} catch (DataException e) {
129
			Sextante.addErrorToLog(e);
130
		}
131
    }
132

  
133
    /*
134
     * (non-Javadoc)
135
     * 
136
     * @see
137
     * org.gvsig.geoprocess.algorithm.base.core.GeometryOperation#invoke(org
138
     * .gvsig.fmap.geom.Geometry, org.gvsig.fmap.dal.feature.EditableFeature)
139
     */
140
    public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature feature) {
141
        invoke(g, (Feature) feature);
142
    }
143
}
0 144

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.splitlines/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.splitlines</artifactId>
5
  <packaging>jar</packaging>
6
  <name>org.gvsig.geoprocess.algorithm.splitlines</name>
7
	
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.geoprocess.algorithm</artifactId>
11
		<version>2.2.256</version>
12
	</parent>
13
	
14
	<dependencies>
15
		<dependency>
16
		    <groupId>org.gvsig</groupId>
17
   			<artifactId>org.gvsig.geoprocess.algorithm.base</artifactId>
18
            <scope>compile</scope>
19
   		</dependency>
20
   		<dependency>
21
		    <groupId>org.gvsig</groupId>
22
   			<artifactId>org.gvsig.andami</artifactId>
23
            <scope>compile</scope>
24
   		</dependency>
25
        <dependency>
26
            <groupId>org.gvsig</groupId>
27
            <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
28
            <scope>compile</scope>
29
        </dependency>
30
        <dependency>
31
            <groupId>org.gvsig</groupId>
32
            <artifactId>org.gvsig.fmap.mapcontext.impl</artifactId>
33
            <scope>runtime</scope>
34
        </dependency>
35
		<dependency>
36
            <groupId>org.gvsig</groupId>
37
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
38
            <scope>compile</scope>
39
        </dependency>
40
        <dependency>
41
            <groupId>org.gvsig</groupId>
42
            <artifactId>org.gvsig.fmap.dal.impl</artifactId>
43
            <scope>runtime</scope>
44
        </dependency>
45
        <dependency>
46
            <groupId>org.gvsig</groupId>
47
            <artifactId>org.gvsig.fmap.dal.file.lib</artifactId>
48
            <scope>compile</scope>
49
        </dependency>
50
        <dependency>
51
            <groupId>org.gvsig</groupId>
52
            <artifactId>org.gvsig.fmap.dal.spi</artifactId>
53
            <scope>compile</scope>
54
        </dependency>
55
	</dependencies>
56
	
57
</project>
0 58

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

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

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

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

  
46
    public static final String RESULT_POL = "RESULT_POL";
47
    public static final String RESULT_LIN = "RESULT_LIN";
48
    public static final String RESULT_POINT = "RESULT_POINT";
49
    public static final String LAYER = "LAYER";
50
    public static final String CLIP = "CLIP";
51
    public static final String SELECTGEOM_INPUT = "SELECTGEOM_INPUT";
52
    public static final String SELECTGEOM_OVERLAY = "SELECTGEOM_OVERLAY";
53

  
54
    /*
55
	 * (non-Javadoc)
56
	 * @see es.unex.sextante.core.GeoAlgorithm#defineCharacteristics()
57
     */
58
    public void defineCharacteristics() {
59
        setName(getTranslation("Clip"));
60
        setGroup(getTranslation("basic_vect_algorithms"));
61
        // setGeneratesUserDefinedRasterOutput(false);
62

  
63
        try {
64
            m_Parameters.addInputVectorLayer(LAYER,
65
                    getTranslation("Input_layer"),
66
                    IVectorLayer.SHAPE_TYPE_WRONG,
67
                    true);
68
            m_Parameters.addInputVectorLayer(CLIP,
69
                    getTranslation("Clip_layer"),
70
                    IVectorLayer.SHAPE_TYPE_POLYGON,
71
                    true);
72
            m_Parameters.addBoolean(SELECTGEOM_INPUT,
73
                    getTranslation("Selected_geometries_input_layer_clip"), false);
74
            m_Parameters.addBoolean(SELECTGEOM_OVERLAY,
75
                    getTranslation("Selected_geometries_overlay_layer_clip"), false);
76
        } catch (RepeatedParameterNameException e) {
77
            Sextante.addErrorToLog(e);
78
        }
79
        //addOutputVectorLayer(RESULT, getTranslation("Clip"),
80
        // OutputVectorLayer.SHAPE_TYPE_UNDEFINED);
81

  
82
        addOutputVectorLayer(RESULT_POL, getTranslation("Clip_polygon"),
83
                OutputVectorLayer.SHAPE_TYPE_POLYGON);
84
        addOutputVectorLayer(RESULT_LIN, getTranslation("Clip_line"),
85
                OutputVectorLayer.SHAPE_TYPE_LINE);
86
        addOutputVectorLayer(RESULT_POINT, getTranslation("Clip_point"),
87
                OutputVectorLayer.SHAPE_TYPE_POINT);
88
    }
89

  
90
    /*
91
	 * (non-Javadoc)
92
	 * @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm()
93
     */
94
    public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
95
        if (existsOutPutFile(ClipAlgorithm.RESULT_POL, 0)
96
                || existsOutPutFile(ClipAlgorithm.RESULT_LIN, 0)
97
                || existsOutPutFile(ClipAlgorithm.RESULT_POINT, 0)) {
98
            throw new GeoAlgorithmExecutionException(getTranslation("file_exists"));
99
        }
100
        org.gvsig.fmap.geom.Geometry clippingGeometry = null;
101
        IVectorLayer clip = m_Parameters.getParameterValueAsVectorLayer(CLIP);
102
        IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER);
103
        boolean selectedGeomInput = m_Parameters.getParameter(SELECTGEOM_INPUT).getParameterValueAsBoolean();
104
        boolean selectedGeomOverlay = m_Parameters.getParameter(SELECTGEOM_OVERLAY).getParameterValueAsBoolean();
105

  
106
        try {
107
            clippingGeometry = ScalableUnionOperation.joinLayerGeometries(clip, selectedGeomOverlay);
108
        } catch (Exception e) {
109
            Sextante.addErrorToLog(e);
110
            return false;
111
        }
112

  
113
        FeatureStore storeLayer = null;
114
        if (layer instanceof FlyrVectIVectorLayer && clippingGeometry != null) {
115
            storeLayer = ((FlyrVectIVectorLayer) layer).getFeatureStore();
116
        } else {
117
            return false;
118
        }
119

  
120
        try {
121
            FeatureType featureType = storeLayer.getDefaultFeatureType();
122

  
123
            if (isPolygon(storeLayer) || isUndefined(storeLayer)) {
124
                FeatureStore outFeatStore
125
                        = buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_MULTIPOLYGON,
126
                                getTranslation("Clip_polygon"), RESULT_POL);
127

  
128
                ClipOperation operation = new ClipOperation(clippingGeometry, this);
129
                operation.setTaskStatus(getStatus());
130
                operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames,
131
                        selectedGeomInput, false, true);
132
            } else {
133
                buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_MULTIPOLYGON,
134
                        getTranslation("Null_polygon"), RESULT_POL);
135
            }
136

  
137
            if (isLine(storeLayer) || isUndefined(storeLayer)) {
138
                FeatureStore outFeatStore
139
                        = buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_MULTILINE,
140
                                getTranslation("Clip_line"), RESULT_LIN);
141

  
142
                ClipOperation operation = new ClipOperation(clippingGeometry, this);
143
                operation.setTaskStatus(getStatus());
144
                operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames,
145
                        selectedGeomInput, false, true);
146
            } else {
147
                buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_MULTILINE,
148
                        getTranslation("Null_line"), RESULT_LIN);
149
            }
150

  
151
            if (isPoint(storeLayer) || isUndefined(storeLayer)) {
152
                FeatureStore outFeatStore
153
                        = buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POINT,
154
                                getTranslation("Clip_point"), RESULT_POINT);
155

  
156
                ClipOperation operation = new ClipOperation(clippingGeometry, this);
157
                operation.setTaskStatus(getStatus());
158
                operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames,
159
                        selectedGeomInput, false, true);
160
            } else {
161
                buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POINT,
162
                        getTranslation("Null_point"), RESULT_POINT);
163
            }
164
        } catch (DataException e) {
165
            Sextante.addErrorToLog(e);
166
            return false;
167
        }
168

  
169
        return true;
170
    }
171

  
172
}
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/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.256</version>
12
	</parent>
13
	
14
	<dependencies>
15
		<dependency>
16
		    <groupId>org.gvsig</groupId>
17
   			<artifactId>org.gvsig.geoprocess.algorithm.base</artifactId>
18
            <scope>compile</scope>
19
   		</dependency>
20
	</dependencies>
21
	
22
</project>
0 23

  
org.gvsig.geoprocess/tags/org.gvsig.geoprocess-2.2.256/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
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff