Revision 40 org.gvsig.sextante/trunk/org.gvsig.sextante.app/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/src/main/java/org/gvsig/sextante/app/algorithm/reproject/ReprojectAlgorithm.java

View differences:

ReprojectAlgorithm.java
18 18
 */
19 19
package org.gvsig.sextante.app.algorithm.reproject;
20 20

  
21
import org.cresques.cts.IProjection;
22
import org.gvsig.fmap.crs.CRSFactory;
21 23
import org.gvsig.fmap.dal.exception.DataException;
22 24
import org.gvsig.fmap.dal.feature.FeatureSet;
23 25
import org.gvsig.fmap.dal.feature.FeatureStore;
......
39 41
	public static final String        RESULT            = "RESULT";
40 42
	public static final String        LAYER             = "LAYER";
41 43
	public static final String        SELECTED_GEOM     = "SELECTED_GEOM";
42
	public static final String        PROJECTION        = "PROJECTION";
44
	public static final String        DST_PROJECTION    = "DST_PROJECTION";
43 45
	
44 46
	/*
45 47
	 * (non-Javadoc)
......
58 60
			m_Parameters.addBoolean(SELECTED_GEOM, 
59 61
									Sextante.getText("Selected_geometries"), 
60 62
									false);
61
			m_Parameters.addString(PROJECTION, Sextante.getText("Projection"));
63
			m_Parameters.addString(DST_PROJECTION, Sextante.getText("Projection"));
62 64
			addOutputVectorLayer(RESULT,
63
								Sextante.getText( "Reproject"),
64
								OutputVectorLayer.SHAPE_TYPE_POLYGON);
65
								Sextante.getText("Reproject"),
66
								OutputVectorLayer.SHAPE_TYPE_UNDEFINED);
65 67
		} catch (RepeatedParameterNameException e) {
66 68
			Sextante.addErrorToLog(e);
67 69
		}
......
75 77
	public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
76 78
		IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER);
77 79
		boolean selectedGeom = m_Parameters.getParameterValueAsBoolean(SELECTED_GEOM);
78
		String projection = m_Parameters.getParameterValueAsString(PROJECTION);
80
		String dstProj = m_Parameters.getParameterValueAsString(DST_PROJECTION);
79 81
		
80 82
		FeatureStore storeLayer = null;
81 83
		if(layer instanceof gvVectorLayer)
......
88 90
			features = storeLayer.getFeatureSet();
89 91
			FeatureType featureType = features.getDefaultFeatureType();
90 92
			FeatureStore outFeatStore = buildOutPutStore(featureType, layer.getShapeType(), Sextante.getText("Reproject"), RESULT);
91

  
92
			ReprojectOperation operation = new ReprojectOperation(projection);
93
			IProjection projOutput = CRSFactory.getCRS(dstProj);
94
			ReprojectOperation operation = new ReprojectOperation(((IProjection)layer.getCRS()), projOutput);
93 95
			operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true);
94 96
		} catch (DataException e) {
95 97
			Sextante.addErrorToLog(e);

Also available in: Unified diff