Revision 334
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.reproject/src/main/java/org/gvsig/geoprocess/algorithm/reproject/ReprojectAlgorithm.java | ||
---|---|---|
44 | 44 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
45 | 45 |
*/ |
46 | 46 |
public class ReprojectAlgorithm extends AbstractSextanteGeoProcess { |
47 |
|
|
48 |
public static final String RESULT = "RESULT"; |
|
47 |
public static final String RESULT_POL = "RESULT_POL"; |
|
48 |
public static final String RESULT_POINT = "RESULT_POINT"; |
|
49 |
public static final String RESULT_LINE = "RESULT_LINE"; |
|
49 | 50 |
public static final String LAYER = "LAYER"; |
50 | 51 |
public static final String SELECTED_GEOM = "SELECTED_GEOM"; |
51 | 52 |
public static final String DST_PROJECTION = "DST_PROJECTION"; |
... | ... | |
69 | 70 |
false); |
70 | 71 |
m_Parameters |
71 | 72 |
.addString(DST_PROJECTION, getTranslation("Projection")); |
72 |
addOutputVectorLayer(RESULT, |
|
73 |
getTranslation("Reproject"), |
|
74 |
OutputVectorLayer.SHAPE_TYPE_UNDEFINED); |
|
73 |
|
|
74 |
addOutputVectorLayer(RESULT_POL, getTranslation("Reproject_polygon"), |
|
75 |
OutputVectorLayer.SHAPE_TYPE_POLYGON); |
|
76 |
addOutputVectorLayer(RESULT_LINE, getTranslation("Reproject_line"), |
|
77 |
OutputVectorLayer.SHAPE_TYPE_LINE); |
|
78 |
addOutputVectorLayer(RESULT_POINT, getTranslation("Reproject_point"), |
|
79 |
OutputVectorLayer.SHAPE_TYPE_POINT); |
|
80 |
|
|
75 | 81 |
} catch (RepeatedParameterNameException e) { |
76 | 82 |
Sextante.addErrorToLog(e); |
77 | 83 |
} |
... | ... | |
82 | 88 |
* @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm() |
83 | 89 |
*/ |
84 | 90 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
85 |
if(existsOutPutFile(ReprojectAlgorithm.RESULT, 0)) { |
|
91 |
if(existsOutPutFile(RESULT_POL, 0) || |
|
92 |
existsOutPutFile(RESULT_LINE, 0) || |
|
93 |
existsOutPutFile(RESULT_POINT, 0)) { |
|
86 | 94 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
87 | 95 |
} |
88 | 96 |
IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER); |
... | ... | |
99 | 107 |
FeatureSet features = null; |
100 | 108 |
features = storeLayer.getFeatureSet(); |
101 | 109 |
FeatureType featureType = features.getDefaultFeatureType(); |
102 |
FeatureStore outFeatStore = |
|
110 |
/*FeatureStore outFeatStore =
|
|
103 | 111 |
buildOutPutStore(featureType, layer.getShapeType(), |
104 | 112 |
getTranslation("Reproject"), RESULT); |
105 | 113 |
IProjection projOutput = CRSFactory.getCRS(dstProj); |
106 | 114 |
ReprojectOperation operation = new ReprojectOperation(((IProjection)layer.getCRS()), projOutput, this); |
107 | 115 |
operation.setTaskStatus(getStatus()); |
108 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
116 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true);*/ |
|
117 |
|
|
118 |
IProjection projOutput = CRSFactory.getCRS(dstProj); |
|
119 |
ReprojectOperation operation = new ReprojectOperation(((IProjection)layer.getCRS()), projOutput, this); |
|
120 |
operation.setTaskStatus(getStatus()); |
|
121 |
|
|
122 |
if (isPolygon(storeLayer) || isUndefined(storeLayer)) { |
|
123 |
FeatureStore outFeatStore = |
|
124 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
|
125 |
getTranslation("Reproject_polygon"), RESULT_POL); |
|
126 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
127 |
} else { |
|
128 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
|
129 |
getTranslation("Null_polygon"), RESULT_POL); |
|
130 |
} |
|
131 |
|
|
132 |
if (isLine(storeLayer) || isUndefined(storeLayer)) { |
|
133 |
FeatureStore outFeatStore = |
|
134 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE, |
|
135 |
getTranslation("Reproject_line"), RESULT_LINE); |
|
136 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
137 |
} else { |
|
138 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_LINE, |
|
139 |
getTranslation("Null_line"), RESULT_LINE); |
|
140 |
} |
|
141 |
|
|
142 |
if (isPoint(storeLayer) || isUndefined(storeLayer)) { |
|
143 |
FeatureStore outFeatStore = |
|
144 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
|
145 |
getTranslation("Reproject_point"), RESULT_POINT); |
|
146 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
147 |
} else { |
|
148 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
|
149 |
getTranslation("Null_point"), RESULT_POINT); |
|
150 |
} |
|
109 | 151 |
} catch (DataException e) { |
110 | 152 |
Sextante.addErrorToLog(e); |
111 | 153 |
return false; |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.reproject/src/main/java/org/gvsig/geoprocess/algorithm/reproject/ReprojectParametersPanel.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.geoprocess.algorithm.reproject; |
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; |
... | ... | |
50 | 49 |
import es.unex.sextante.core.ParametersSet; |
51 | 50 |
import es.unex.sextante.core.Sextante; |
52 | 51 |
import es.unex.sextante.dataObjects.IVectorLayer; |
53 |
import es.unex.sextante.gridCalculus.gridCalculator.GridCalculatorAlgorithm; |
|
54 | 52 |
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel; |
55 | 53 |
import es.unex.sextante.gui.algorithm.OutputChannelSelectionPanel; |
56 | 54 |
import es.unex.sextante.gui.core.SextanteGUI; |
... | ... | |
70 | 68 |
private CRSSelectPanel projectionSrcSelector = null; |
71 | 69 |
private IProjection targetLayerProjection = 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 ReprojectParametersPanel() { |
... | ... | |
125 | 125 |
if(outputPanel == null) { |
126 | 126 |
try { |
127 | 127 |
outputPanel = new JPanel(); |
128 |
outputPanel.setLayout(new BorderLayout()); |
|
128 |
outputPanel.setLayout(new GridBagLayout()); |
|
129 |
|
|
129 | 130 |
final OutputObjectsSet ooSet = m_Algorithm.getOutputObjects(); |
130 |
final Output out = ooSet.getOutput(GridCalculatorAlgorithm.RESULT); |
|
131 |
outputChannelSelectionPanel = new OutputChannelSelectionPanel(out, m_Algorithm.getParameters()); |
|
131 |
final Output out_pol = ooSet.getOutput(ReprojectAlgorithm.RESULT_POL); |
|
132 |
final Output out_line = ooSet.getOutput(ReprojectAlgorithm.RESULT_LINE); |
|
133 |
final Output out_point = ooSet.getOutput(ReprojectAlgorithm.RESULT_POINT); |
|
134 |
|
|
135 |
outputChannelSelectionPanelPol = new OutputChannelSelectionPanel(out_pol, m_Algorithm.getParameters()); |
|
136 |
outputChannelSelectionPanelLine = new OutputChannelSelectionPanel(out_line, m_Algorithm.getParameters()); |
|
137 |
outputChannelSelectionPanelPoint = new OutputChannelSelectionPanel(out_point, m_Algorithm.getParameters()); |
|
138 |
|
|
132 | 139 |
String label = GeoProcessLocator.getGeoProcessManager().getTranslation("Reproject"); |
133 |
outputPanel.add(new JLabel(" " + label + " [Vectorial] "), BorderLayout.WEST); |
|
134 |
outputPanel.add(outputChannelSelectionPanel, BorderLayout.CENTER); |
|
140 |
|
|
141 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
142 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
143 |
gbc.insets = new Insets(0, 0, 4, 0); |
|
144 |
gbc.weightx = 1; |
|
145 |
gbc.gridx = 0; |
|
146 |
gbc.gridy = 0; |
|
147 |
outputPanel.add(new JLabel(" " + label + " [Polygon] "), gbc); |
|
148 |
|
|
149 |
gbc.gridx = 0; |
|
150 |
gbc.gridy = 1; |
|
151 |
outputPanel.add(new JLabel(" " + label + " [Line] "), gbc); |
|
152 |
|
|
153 |
gbc.gridx = 0; |
|
154 |
gbc.gridy = 2; |
|
155 |
outputPanel.add(new JLabel(" " + label + " [Point] "), gbc); |
|
156 |
|
|
157 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
158 |
gbc.weightx = 1; |
|
159 |
gbc.gridx = 1; |
|
160 |
gbc.gridy = 0; |
|
161 |
outputPanel.add(outputChannelSelectionPanelPol, gbc); |
|
162 |
|
|
163 |
gbc.gridx = 1; |
|
164 |
gbc.gridy = 1; |
|
165 |
outputPanel.add(outputChannelSelectionPanelLine, gbc); |
|
166 |
|
|
167 |
gbc.gridx = 1; |
|
168 |
gbc.gridy = 2; |
|
169 |
outputPanel.add(outputChannelSelectionPanelPoint, gbc); |
|
135 | 170 |
} catch (final Exception e) { |
136 | 171 |
Sextante.addErrorToLog(e); |
137 | 172 |
} |
... | ... | |
255 | 290 |
*/ |
256 | 291 |
public void actionPerformed(ActionEvent e) { |
257 | 292 |
if(e.getSource() == getLayersCombo()) { |
258 |
|
|
293 |
init(); |
|
259 | 294 |
} |
260 | 295 |
} |
261 | 296 |
|
... | ... | |
269 | 304 |
params.getParameter(ReprojectAlgorithm.DST_PROJECTION).setParameterValue(proj); |
270 | 305 |
|
271 | 306 |
OutputObjectsSet ooSet = m_Algorithm.getOutputObjects(); |
272 |
Output out = ooSet.getOutput(ReprojectAlgorithm.RESULT); |
|
307 |
Output outPol = ooSet.getOutput(ReprojectAlgorithm.RESULT_POL); |
|
308 |
Output outLine = ooSet.getOutput(ReprojectAlgorithm.RESULT_LINE); |
|
309 |
Output outPoint = ooSet.getOutput(ReprojectAlgorithm.RESULT_POINT); |
|
273 | 310 |
|
274 | 311 |
//Reponer estas l?neas para cambiar el panel de salida y comentar la siguiente |
275 | 312 |
//out.setOutputChannel(new CompositeSourceOutputChannel(getAlgorithmOutputPanel().getOutputParameters())); |
276 |
out.setOutputChannel(outputChannelSelectionPanel.getOutputChannel()); |
|
313 |
outPol.setOutputChannel(outputChannelSelectionPanelPol.getOutputChannel()); |
|
314 |
outLine.setOutputChannel(outputChannelSelectionPanelLine.getOutputChannel()); |
|
315 |
outPoint.setOutputChannel(outputChannelSelectionPanelPoint.getOutputChannel()); |
|
277 | 316 |
} catch (Exception e) { |
278 | 317 |
Sextante.addErrorToLog(e); |
279 | 318 |
} |
Also available in: Unified diff