Revision 11932

View differences:

branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/AddLayer.java
49 49

  
50 50
import javax.swing.JOptionPane;
51 51

  
52
import org.cresques.cts.ICoordTrans;
53 52
import org.cresques.cts.IProjection;
54 53

  
55 54
import com.hardcode.driverManager.Driver;
......
144 143
	public void initialize() {
145 144
	}
146 145

  
147
	private void checkProjection(FLayer lyr, ViewPort viewPort) {
146
	private boolean checkProjection(FLayer lyr, ViewPort viewPort) {
148 147
		if (lyr instanceof FLayers){
149 148
			FLayers layers=(FLayers)lyr;
150 149
			for (int i=0;i<layers.getLayersCount();i++){
151 150
				checkProjection(layers.getLayer(i),viewPort);
152 151
			}
153 152
		}
154
		if (lyr instanceof FLyrVect) {
155
			FLyrVect lyrVect = (FLyrVect) lyr;
153
		
154
		if (lyr.isReprojectable()) {
155
			boolean control = true;
156 156
			IProjection proj = lyr.getProjection();
157 157
			// Comprobar que la projecci?n es la misma que la vista
158 158
			if (proj == null) {
159 159
				// SUPONEMOS que la capa est? en la proyecci?n que
160 160
				// estamos pidiendo (que ya es mucho suponer, ya).
161
				lyrVect.setProjection(viewPort.getProjection());
162
				return;
161
				lyr.setProjection(viewPort.getProjection());
162
				return control;
163 163
			}
164 164
			if (proj != viewPort.getProjection()) {
165 165
				int option = JOptionPane.YES_OPTION;
166 166
				if (!CRSFactory.doesRigurousTransformations()) {
167 167
					option = JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(), PluginServices
168
						.getText(this, "reproyectar_aviso")+"\n"+ PluginServices.getText(this,"Capa")+": "+lyrVect.getName(), PluginServices
168
						.getText(this, "reproyectar_aviso")+"\n"+ PluginServices.getText(this,"Capa")+": "+lyr.getName(), PluginServices
169 169
						.getText(this, "reproyectar_pregunta"),
170 170
						JOptionPane.YES_NO_OPTION);
171 171
				}
172

  
173
				if (option != JOptionPane.OK_OPTION) {
174
					return;
172
				
173
				if (option == JOptionPane.NO_OPTION) {
174
					return control;
175
				} else {
176
					control = lyr.reProject(((BaseView)PluginServices.getMDIManager().getActiveWindow()).getMapControl());
177
					return control;
175 178
				}
176
				ICoordTrans ct = proj.getCT(viewPort.getProjection());
177
				lyrVect.setCoordTrans(ct);
178
				System.err.println("coordTrans = " + proj.getAbrev() + " "
179
						+ viewPort.getProjection().getAbrev());
180 179
			}
181 180
		}
181
		return true;
182 182

  
183 183
	}
184 184

  
......
310 310
					if (mapControl.getMapContext().getViewPort().getExtent() == null) {
311 311
						first = true;
312 312
					}
313
					checkProjection(lyr, mapControl.getViewPort());
314
					mapControl.getMapContext().getLayers().addLayer(lyr);
313
					if(checkProjection(lyr, mapControl.getViewPort()))
314
						mapControl.getMapContext().getLayers().addLayer(lyr);
315 315

  
316 316
	//esto ya se hace en layerfactory ?lo dejamos? (azabala)
317 317
	/*

Also available in: Unified diff