Revision 29209

View differences:

branches/v2_0_0_prep/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/WFSParamsPanel.java
6 6
import javax.swing.JOptionPane;
7 7
import javax.swing.JTabbedPane;
8 8

  
9
import org.cresques.cts.IProjection;
10
import org.gvsig.fmap.crs.CRSFactory;
9 11
import org.gvsig.fmap.dal.DALLocator;
10 12
import org.gvsig.fmap.dal.DataManager;
11 13
import org.gvsig.fmap.dal.DataStoreParameters;
......
19 21
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
20 22
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
21 23
import org.gvsig.fmap.geom.primitive.Envelope;
24
import org.gvsig.fmap.mapcontext.MapContext;
22 25
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
23 26
import org.gvsig.fmap.mapcontext.layers.FLayer;
24 27
import org.gvsig.fmap.mapcontext.layers.LayerFactory;
......
710 713

  
711 714
		return selectedFeature;
712 715
	}
716
	
717
	/**
718
	 * @return the selected projection
719
	 */
720
	public IProjection getSelectedFeatureProjection(){
721
		WFSSelectedFeature selectedFeature = getSelectedFeature();
722
		if (selectedFeature.getSrs().size() > 0){
723
			String crs = (String)selectedFeature.getSrs().get(0);
724
			crs = getSRS(crs);
725
			IProjection projection = CRSFactory.getCRS(crs);
726
			if (projection != null){
727
				return projection;
728
			}
729
		}
730
		return null;
731
	}
732
	
733
	/**
734
	 * Removing the URN prefix
735
	 * @param srs
736
	 * @return
737
	 */
738
	private String getSRS(String srs){
739
		if (srs == null){
740
			return null;
741
		}
742
		if (srs.startsWith("urn:x-ogc:def:crs:")){
743
			String newString = srs.substring(srs.lastIndexOf(":") + 1, srs.length());
744
			if (srs.indexOf("EPSG") > 0){
745
				if (newString.indexOf("EPSG") < 0){
746
					newString = "EPSG:" + newString;
747
				}
748
			}
749
			return newString;			
750
		}
751
		if (srs.toLowerCase().startsWith("crs:")){
752
			return srs.substring(4, srs.length());
753
		}
754
		return srs;
755
	}
713 756

  
714 757
	/**
715 758
	 * Refresh all the panels every time that a different layer is selected. The info panel is refreshed every time the user 
branches/v2_0_0_prep/extensions/extWFS2/src/com/iver/cit/gvsig/gui/wizards/WFSWizard.java
17 17
import javax.swing.event.ChangeEvent;
18 18
import javax.swing.event.ChangeListener;
19 19

  
20
import org.cresques.cts.IProjection;
21
import org.gvsig.fmap.crs.CRSFactory;
20 22
import org.gvsig.fmap.dal.DALLocator;
21 23
import org.gvsig.fmap.dal.DataManager;
22 24
import org.gvsig.fmap.dal.DataStoreParameters;
......
722 724
	 */
723 725
	public void execute() {
724 726
		FLayer layer = wfsParamsPanel.getLayer();
727
		IProjection projection = wfsParamsPanel.getSelectedFeatureProjection();
728
		if (projection == null){
729
			projection = getMapCtrl().getProjection();
730
		}
731
		layer.setProjection(projection);
725 732
		MapContext mapContext = this.getMapCtrl().getMapContext();
726 733
		mapContext.getLayers().addLayer(layer);
727 734
	}	

Also available in: Unified diff