Revision 333

View differences:

org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/java/org/gvsig/geoprocess/algorithm/buffer/BufferParametersPanel.java
44 44
import javax.swing.JScrollPane;
45 45
import javax.swing.JTextField;
46 46

  
47
import org.gvsig.geoprocess.algorithm.dissolve.DissolveAlgorithm;
48 47
import org.gvsig.geoprocess.lib.api.GeoProcessLocator;
49 48
import org.gvsig.geoprocess.sextante.gui.algorithm.AlgorithmOutputPanel;
50 49

  
......
130 129
				outputPanel = new JPanel();
131 130
				outputPanel.setLayout(new BorderLayout());
132 131
				final OutputObjectsSet ooSet = m_Algorithm.getOutputObjects();
133
				final Output out = ooSet.getOutput(DissolveAlgorithm.RESULT);
132
				final Output out = ooSet.getOutput(BufferAlgorithm.RESULT);
134 133
				outputChannelSelectionPanel = new OutputChannelSelectionPanel(out, m_Algorithm.getParameters());
135 134
				outputPanel.add(new JLabel(" Buffer [Vectorial]               "), BorderLayout.WEST);
136 135
				outputPanel.add(outputChannelSelectionPanel, BorderLayout.CENTER);
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.base/src/main/java/org/gvsig/geoprocess/algorithm/base/core/DALFeaturePersister.java
487 487
			}
488 488
			
489 489
			//Sets the geometry
490
			feat.setGeometry(fieldNames.length, newGeom);
490
			feat.setGeometry(fieldNames.length, convertGeometry2MultiGeometry(newGeom));
491 491
			store.insert(feat);
492 492
			return feat;
493 493
		}
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.merge/src/main/java/org/gvsig/geoprocess/algorithm/merge/MergeParametersPanel.java
23 23
 */
24 24
package org.gvsig.geoprocess.algorithm.merge;
25 25

  
26
import java.awt.BorderLayout;
27 26
import java.awt.Dimension;
28 27
import java.awt.GridBagConstraints;
29 28
import java.awt.GridBagLayout;
......
48 47
import es.unex.sextante.core.ParametersSet;
49 48
import es.unex.sextante.core.Sextante;
50 49
import es.unex.sextante.dataObjects.IVectorLayer;
51
import es.unex.sextante.gridCalculus.gridCalculator.GridCalculatorAlgorithm;
52 50
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel;
53 51
import es.unex.sextante.gui.algorithm.OutputChannelSelectionPanel;
54 52
import es.unex.sextante.gui.core.SextanteGUI;
......
70 68
	private TableContainer                   table              = null;
71 69
	private ObjectAndDescription[]           layerList          = null;
72 70
	private AlgorithmOutputPanel             algorithmOutputPanel  = null;
73
	private OutputChannelSelectionPanel      outputChannelSelectionPanel;
71
	private OutputChannelSelectionPanel      outputChannelSelectionPanelPol;
72
	private OutputChannelSelectionPanel      outputChannelSelectionPanelLine;
73
	private OutputChannelSelectionPanel      outputChannelSelectionPanelPoint;
74 74
	private JPanel                           outputPanel;
75 75
	
76 76
	public MergeParametersPanel() {
......
121 121
		if(outputPanel == null) {
122 122
			try {
123 123
				outputPanel = new JPanel();
124
				outputPanel.setLayout(new BorderLayout());
124
				outputPanel.setLayout(new GridBagLayout());
125 125
				final OutputObjectsSet ooSet = m_Algorithm.getOutputObjects();
126
				final Output out = ooSet.getOutput(GridCalculatorAlgorithm.RESULT);
127
				outputChannelSelectionPanel = new OutputChannelSelectionPanel(out, m_Algorithm.getParameters());
126
				final Output out_pol = ooSet.getOutput(MergeAlgorithm.RESULT_POL);
127
				final Output out_line = ooSet.getOutput(MergeAlgorithm.RESULT_LINE);
128
				final Output out_point = ooSet.getOutput(MergeAlgorithm.RESULT_POINT);
129
				
130
				outputChannelSelectionPanelPol = new OutputChannelSelectionPanel(out_pol, m_Algorithm.getParameters());
131
				outputChannelSelectionPanelLine = new OutputChannelSelectionPanel(out_line, m_Algorithm.getParameters());
132
				outputChannelSelectionPanelPoint = new OutputChannelSelectionPanel(out_point, m_Algorithm.getParameters());
133
				
128 134
				String label = GeoProcessLocator.getGeoProcessManager().getTranslation("Merge");
129
				outputPanel.add(new JLabel(" " + label + " [Vectorial]               "), BorderLayout.WEST);
130
				outputPanel.add(outputChannelSelectionPanel, BorderLayout.CENTER);
135
				
136
				GridBagConstraints gbc = new GridBagConstraints();
137
				gbc.fill = GridBagConstraints.HORIZONTAL;
138
				gbc.insets = new Insets(0, 0, 4, 0);
139
				gbc.weightx = 1;
140
				gbc.gridx = 0;
141
				gbc.gridy = 0;
142
				outputPanel.add(new JLabel(" " + label + " [Polygon]               "), gbc);
143
				
144
				gbc.gridx = 0;
145
				gbc.gridy = 1;
146
				outputPanel.add(new JLabel(" " + label + " [Line]               "), gbc);
147
				
148
				gbc.gridx = 0;
149
				gbc.gridy = 2;
150
				outputPanel.add(new JLabel(" " + label + " [Point]               "), gbc);
151
				
152
				gbc.fill = GridBagConstraints.HORIZONTAL;
153
				gbc.weightx = 1;
154
				gbc.gridx = 1;
155
				gbc.gridy = 0;
156
				outputPanel.add(outputChannelSelectionPanelPol, gbc);
157
				
158
				gbc.gridx = 1;
159
				gbc.gridy = 1;
160
				outputPanel.add(outputChannelSelectionPanelLine, gbc);
161
				
162
				gbc.gridx = 1;
163
				gbc.gridy = 2;
164
				outputPanel.add(outputChannelSelectionPanelPoint, gbc);
131 165
			} catch (final Exception e) {
132 166
				Sextante.addErrorToLog(e);
133 167
			}
......
273 307
			params.getParameter(MergeAlgorithm.LAYERS).setParameterValue(getSelectedLayerList());
274 308
			
275 309
			OutputObjectsSet ooSet = m_Algorithm.getOutputObjects();
276
			Output out = ooSet.getOutput(MergeAlgorithm.RESULT);
310
			Output outPol = ooSet.getOutput(MergeAlgorithm.RESULT_POL);
311
			Output outLine = ooSet.getOutput(MergeAlgorithm.RESULT_LINE);
312
			Output outPoint = ooSet.getOutput(MergeAlgorithm.RESULT_POINT);
277 313
			
278 314
			//Reponer estas l?neas para cambiar el panel de salida y comentar la siguiente
279 315
			//AlgorithmOutputPanel fsp = getAlgorithmOutputPanel();
280 316
			//out.setOutputChannel(new CompositeSourceOutputChannel(fsp.getOutputParameters()));
281
	         out.setOutputChannel(outputChannelSelectionPanel.getOutputChannel());
317
			outPol.setOutputChannel(outputChannelSelectionPanelPol.getOutputChannel());
318
			outLine.setOutputChannel(outputChannelSelectionPanelLine.getOutputChannel());
319
			outPoint.setOutputChannel(outputChannelSelectionPanelPoint.getOutputChannel());
282 320
		} catch (Exception e) {
283 321
			Sextante.addErrorToLog(e);
284 322
		}
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.merge/src/main/java/org/gvsig/geoprocess/algorithm/merge/MergeAlgorithm.java
48 48
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
49 49
 */
50 50
public class MergeAlgorithm extends AbstractSextanteGeoProcess {
51

  
52
	public static final String        RESULT            = "RESULT";
51
	public static final String        RESULT_POL        = "RESULT_POL";
52
	public static final String        RESULT_POINT      = "RESULT_POINT";
53
	public static final String        RESULT_LINE       = "RESULT_LINE";
53 54
	public static final String        LAYERS            = "LAYERS";
54 55
	public static final String        FIELDLAYER        = "LAYER";
56
	
55 57
	/*
56 58
	 * (non-Javadoc)
57 59
	 * @see es.unex.sextante.core.GeoAlgorithm#defineCharacteristics()
......
70 72
                getTranslation("Fields"),
71 73
											IVectorLayer.SHAPE_TYPE_WRONG, 
72 74
											true);
73
			addOutputVectorLayer(RESULT,
74
 getTranslation("Merge"),
75
								OutputVectorLayer.SHAPE_TYPE_UNDEFINED);
75
			
76
			addOutputVectorLayer(RESULT_POL, getTranslation("Merge_polygon"),
77
					OutputVectorLayer.SHAPE_TYPE_POLYGON);
78
			addOutputVectorLayer(RESULT_LINE, getTranslation("Merge_line"),
79
					OutputVectorLayer.SHAPE_TYPE_LINE);
80
			addOutputVectorLayer(RESULT_POINT, getTranslation("Merge_point"),
81
					OutputVectorLayer.SHAPE_TYPE_POINT);
82
			
76 83
		} catch (RepeatedParameterNameException e) {
77 84
			Sextante.addErrorToLog(e);
78 85
		}
......
84 91
	 */
85 92
	@SuppressWarnings("unchecked")
86 93
	public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
87
		if(existsOutPutFile(MergeAlgorithm.RESULT, 0)) {
94
		if(existsOutPutFile(MergeAlgorithm.RESULT_POL, 0) || 
95
			existsOutPutFile(MergeAlgorithm.RESULT_LINE, 0) ||
96
			existsOutPutFile(MergeAlgorithm.RESULT_POINT, 0)) {
88 97
    		throw new GeoAlgorithmExecutionException(getTranslation("file_exists"));
89 98
    	}
90 99
		IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(FIELDLAYER);
......
116 125
			FeatureSet features = null;
117 126
			features = storeLayer.getFeatureSet();
118 127
			FeatureType featureType = features.getDefaultFeatureType();
119
            FeatureStore outFeatStore =
128
           /* FeatureStore outFeatStore =
120 129
                buildOutPutStore(featureType, layer.getShapeType(),
121 130
                    getTranslation("Merge"), RESULT);
122 131

  
......
124 133
			GeometryOperation operation = new MergeOperation(layer, this);
125 134
            operation.setTaskStatus(getStatus());
126 135
			operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, false, true);
136
			*/
137
			GeometryOperation operation = new MergeOperation(layer, this);
138
            operation.setTaskStatus(getStatus());
139
            
140
			if (isPolygon(storeLayer) || isUndefined(storeLayer)) {
141
				FeatureStore outFeatStore =
142
					buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON,
143
							getTranslation("Merge_polygon"), RESULT_POL);
144

  
145
				operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, false, true);
146
			} else {
147
				buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON,
148
						getTranslation("Null_polygon"), RESULT_POL);
149
			}
150
			
151
			if (isLine(storeLayer) || isUndefined(storeLayer)) {
152
				FeatureStore outFeatStore =
153
					buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE,
154
							getTranslation("Merge_line"), RESULT_LINE);
155

  
156
				operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, false, true);
157
			} else {
158
				buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_LINE,
159
						getTranslation("Null_line"), RESULT_LINE);
160
			}
161
			
162
			if (isPoint(storeLayer) || isUndefined(storeLayer)) {
163
				FeatureStore outFeatStore =
164
					buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT,
165
							getTranslation("Merge_point"), RESULT_POINT);
166

  
167
				operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, false, true);
168
			} else {
169
				buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT,
170
						getTranslation("Null_point"), RESULT_POINT);
171
			}
172
			
127 173
		} catch (DataException e) {
128 174
			Sextante.addErrorToLog(e);
129 175
			return false;

Also available in: Unified diff