Revision 278 org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/Proj4.java

View differences:

Proj4.java
46 46
import javax.units.ConversionException;
47 47
import javax.units.Unit;
48 48

  
49
import org.geotools.referencing.CRS;
49 50
import org.geotools.referencing.crs.DefaultGeographicCRS;
50 51
import org.geotools.referencing.crs.DefaultProjectedCRS;
51 52
import org.geotools.referencing.datum.DefaultGeodeticDatum;
52 53
import org.geotools.referencing.datum.DefaultPrimeMeridian;
53 54
import org.opengis.metadata.Identifier;
55
import org.opengis.referencing.NoSuchAuthorityCodeException;
54 56
import org.opengis.referencing.crs.CoordinateReferenceSystem;
55 57
import org.opengis.referencing.datum.Ellipsoid;
56 58
import org.opengis.referencing.datum.PrimeMeridian;
59
import org.slf4j.Logger;
60
import org.slf4j.LoggerFactory;
57 61

  
58 62

  
59 63
/**
......
65 69
 */
66 70

  
67 71
public class Proj4 {	
72
        public static final Logger logger = LoggerFactory.getLogger(Proj4.class);
68 73

  
69 74
	private ArrayList projectionNameList= new ArrayList();
70 75
	private ArrayList unitNameList= new ArrayList();
......
85 90
     */
86 91
    private static final double EPS = 1E-8;
87 92
	
93
    /**
94
     * EPSG codes of the Swiss Oblique Mercator CRSs
95
     */
96
    private static final Integer[] somerc_codes = { 2056, 21780, 21781, 21782, 23700 };
97
	
88 98
	public Proj4() throws CrsException
89 99
	{
90 100
		//defineProjectionNames();
......
3300 3310
			if(projectionName.equals("Oblique_Mercator"))
3301 3311
			{
3302 3312
				isOmerc=true;
3303
				if (crs.getCode()==21781)
3304
					isSomerc=true;
3313
				for (int i = 0; i < somerc_codes.length; i++) {
3314
					if (crs.getCode() == somerc_codes[i])
3315
						isSomerc=true;
3316
				}
3305 3317
				for(int j=0;j<gtParameterNames.length;j++)
3306 3318
				{
3307 3319
					String gtParameterName=gtParameterNames[j].trim();
......
3383 3395
				}
3384 3396
			}
3385 3397
			String strProjectionAcronym=projectionAcronym[0];
3398
			if(isSomerc)
3399
				strProjectionAcronym="somerc";
3386 3400
			String strExtraProj4="";
3387 3401
			// Control de casos especiales
3388 3402
			boolean isLaborde=false;
......
3586 3600
				}
3587 3601
				if(isSomerc)
3588 3602
				{
3589
					if(parameterName.equals("rectified_grid_angle"))
3603
					if(parameterName.equals("rectified_grid_angle")
3604
							||parameterName.equals("azimuth"))
3590 3605
						control=false;
3591
					if(parameterName.equals("azimuth"))
3592
						control=false;
3606
					if(parameterAcronym.equals("lonc"))
3607
						parameterAcronym="lon_0";
3608
					if(parameterAcronym.equals("k"))
3609
						parameterAcronym="k_0";	
3593 3610
				}
3594 3611
				if(isOmerc)
3595 3612
				{
......
3926 3943
			if(projectionName.equals("Oblique_Mercator"))
3927 3944
			{
3928 3945
				isOmerc=true;
3929
				// TODO Set isSomerc as true for EPSG:21781  
3930
				//if (crs.getCode()==21781)
3931
				//	isSomerc=true;
3946
                                for (int i = 0; i < somerc_codes.length; i++) {
3947
                                    try {
3948
                                        CoordinateReferenceSystem crsTemp = CRS.decode("EPSG:" + somerc_codes[i].toString());
3949
                                        if ( crs == crsTemp ) {
3950
                                            isSomerc=true;
3951
                                        }
3952
                                    } catch (NoSuchAuthorityCodeException e) {
3953
                                        logger.warn("Can not recognize the EPSG code 'EPSG:"+somerc_codes[i]+"' checking if is a 'somerc'.",e);
3954
                                    }
3955
                                }
3932 3956
				for(int j=0;j<gtParameterNames.length;j++)
3933 3957
				{
3934 3958
					String gtParameterName=gtParameterNames[j].trim();
......
4010 4034
			String projAcronym=projectionAcronym[0];
4011 4035
			if(isLcc)
4012 4036
				projAcronym="lcc";
4037
			if(isSomerc)
4038
				projAcronym="somerc";
4013 4039
			String strExtraProj4="";
4014 4040
			// Control de casos especiales
4015 4041
			boolean isLaborde=false;
......
4204 4230
				}
4205 4231
				if(isSomerc)
4206 4232
				{
4207
					if(parameterName.equals("rectified_grid_angle"))
4233
					if(parameterName.equals("rectified_grid_angle")
4234
							||parameterName.equals("azimuth"))
4208 4235
						control=false;
4209
					if(parameterName.equals("azimuth"))
4210
						control=false;
4236
					if(parameterAcronym.equals("lonc"))
4237
						parameterAcronym="lon_0";
4238
					if(parameterAcronym.equals("k"))
4239
						parameterAcronym="k_0";
4211 4240
				}
4212 4241
				if(isOmerc)
4213 4242
				{

Also available in: Unified diff