Revision 2669 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/cts/gt2/CSDatum.java

View differences:

CSDatum.java
1 1
/*
2 2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
5 3
 *
4
 * Copyright (C) 2004-5.
5
 *
6 6
 * This program is free software; you can redistribute it and/or
7 7
 * modify it under the terms of the GNU General Public License
8 8
 * as published by the Free Software Foundation; either version 2
......
18 18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19 19
 *
20 20
 * For more information, contact:
21
 * 
21
 *
22 22
 * cresques@gmail.com
23 23
 */
24 24
package org.cresques.cts.gt2;
25 25

  
26
import java.util.Locale;
26
import org.cresques.cts.IDatum;
27 27

  
28
import org.cresques.cts.IDatum;
29 28
import org.geotools.cs.CoordinateSystemFactory;
30 29
import org.geotools.cs.GeographicCoordinateSystem;
31 30
import org.geotools.cs.HorizontalDatum;
31

  
32 32
import org.opengis.referencing.FactoryException;
33 33

  
34
import java.util.Locale;
35

  
36

  
34 37
/**
35 38
 * Datum (y Ellipsoid) de GeoTools2.
36
 * 
39
 *
37 40
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
38 41
 */
39 42
public class CSDatum implements IDatum {
40
	private static String line1 = "DATUM[\"WGS_1984\"," +
41
		"SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]]," +
42
		"TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]]";
43
	private static String line2 = "DATUM[\"European_Datum_1950\"," +
44
		"SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
45
		"TOWGS84[-84,-107,-120,0,0,0,0],AUTHORITY[\"EPSG\",\"6230\"]]";
46
	private static String line3 = "DATUM[\"Nouvelle_Triangulation_Francaise\"," +
47
		"SPHEROID[\"Clarke 1880 (IGN)\",6378249.2,293.466021293627, AUTHORITY[\"EPSG\",\"7011\"]]," +
48
		"TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY[\"EPSG\",\"6275\"]]";
49
	private static String line4 = "DATUM[\"Datum 73\","+
50
		"SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
51
		"TOWGS84[-87,-98,-121,0,0,0,0],AUTHORITY[\"EPSG\",\"4274\"]]";
52
	private static String line5 = "DATUM[\"North_American_Datum_1927\","+
53
		"SPHEROID[\"Clarke 1866\",6378206.4,294.978698213901,AUTHORITY[\"EPSG\",\"7008\"]]," +
54
		"TOWGS84[-3,142,183,0,0,0,0],AUTHORITY[\"EPSG\",\"6267\"]]";
55
	private static String line6 = "DATUM[\"North_American_Datum_1983\","+
56
        "SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],"+
57
        "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6269\"]]";
58
/*
59
 * INSERT INTO epsg_coordinatereferencesystem VALUES ( 
60
 * 4288, 'Loma Quintana', 1313, 'geographic 2D', 6422, 6288, 
61
 * Null, Null, Null, Null, 'Geodetic survey.', 
62
 * 'Superseded by La Canoa (code 4247).', '', 
63
 * 'EPSG', '2004/01/06', '2003.37', 1, 0 );
64
 * 
65
 *  DX (m) = -270.933
66
	DY (m) =  115.599
67
	DZ (m) = -360.226
43
    private static String line1 = "DATUM[\"WGS_1984\"," +
44
                                  "SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]]," +
45
                                  "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]]";
46
    private static String line2 = "DATUM[\"European_Datum_1950\"," +
47
                                  "SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
48
                                  "TOWGS84[-84,-107,-120,0,0,0,0],AUTHORITY[\"EPSG\",\"6230\"]]";
49
    private static String line3 = "DATUM[\"Nouvelle_Triangulation_Francaise\"," +
50
                                  "SPHEROID[\"Clarke 1880 (IGN)\",6378249.2,293.466021293627, AUTHORITY[\"EPSG\",\"7011\"]]," +
51
                                  "TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY[\"EPSG\",\"6275\"]]";
52
    private static String line4 = "DATUM[\"Datum 73\"," +
53
                                  "SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
54
                                  "TOWGS84[-87,-98,-121,0,0,0,0],AUTHORITY[\"EPSG\",\"4274\"]]";
55
    private static String line5 = "DATUM[\"North_American_Datum_1927\"," +
56
                                  "SPHEROID[\"Clarke 1866\",6378206.4,294.978698213901,AUTHORITY[\"EPSG\",\"7008\"]]," +
57
                                  "TOWGS84[-3,142,183,0,0,0,0],AUTHORITY[\"EPSG\",\"6267\"]]";
58
    private static String line6 = "DATUM[\"North_American_Datum_1983\"," +
59
                                  "SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]," +
60
                                  "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6269\"]]";
68 61

  
69
	EX (") = -5.266
70
	EY (") = -1.238
71
  	EZ (")  =  2.381
72
	FE (ppm) = -5.109
73
 */
74
	private static String line7 = "DATUM[\"Loma Quintana\","+
75
	"SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
76
	"TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6288\"]]";	
77
/*
78
# La Canoa
79
<4247> +proj=longlat +ellps=intl +towgs84=-273.5,110.6,-357.9,0,0,0,0
80
no_defs <>
81
# PSAD56
82
<4248> +proj=longlat +ellps=intl +towgs84=-288,175,-376,0,0,0,0 no_defs <>
83
 */	
84
	private static String line8 = "DATUM[\"La Canoa\","+
85
	"SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
86
	"TOWGS84[-270.933,115.599,-360.226,-5.266,-1.238,2.381,-5.109],AUTHORITY[\"EPSG\",\"6288\"]]";	
62
    /*
63
     * INSERT INTO epsg_coordinatereferencesystem VALUES (
64
     * 4288, 'Loma Quintana', 1313, 'geographic 2D', 6422, 6288,
65
     * Null, Null, Null, Null, 'Geodetic survey.',
66
     * 'Superseded by La Canoa (code 4247).', '',
67
     * 'EPSG', '2004/01/06', '2003.37', 1, 0 );
68
     *
69
     *  DX (m) = -270.933
70
            DY (m) =  115.599
71
            DZ (m) = -360.226
87 72

  
88
	public final static CSDatum wgs84 = new CSDatum(line1);
89
	public final static CSDatum ed50 = new CSDatum(line2);
90
	public final static CSDatum ntf = new CSDatum(line3);
91
	public final static CSDatum d73 = new CSDatum(line4);
92
	public final static CSDatum nad27 = new CSDatum(line5);
93
	public final static CSDatum nad83 = new CSDatum(line6);
94
	public final static CSDatum lomaQuintana = new CSDatum(line7);
95
	public final static CSDatum laCanoa = new CSDatum(line8);
96
	
97
	private String sGeo1 = "GEOGCS[\"WGS 84\",";
98
	private String sGeo2 = ",PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," +
99
			"UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]," +
100
			"AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
101
			"AUTHORITY[\"EPSG\",\"4326\"]]";
102
	private HorizontalDatum datum = null;
103
	
104
	public CSDatum(String sDatum) {
105
		try {
106
			datum = ((GeographicCoordinateSystem) CoordinateSystemFactory.getDefault().createFromWKT(sGeo1+sDatum+sGeo2)).getHorizontalDatum();
107
		} catch (FactoryException e) {
108
			// TODO Bloque catch generado autom?ticamente
109
			e.printStackTrace();
110
		}
111
	}
112
	
113
	public String getName(Locale loc) {
114
		return datum.getName().toString();
115
	}
116
	
117
	HorizontalDatum getDatum() {
118
		return datum;
119
	}
120
	
121
	public double getESemiMajorAxis() {
122
		return datum.getEllipsoid().getSemiMajorAxis();
123
	}
124
	
125
	public double getEIFlattening() {
126
		return datum.getEllipsoid().getInverseFlattening();
127
	}
128
	
129
	public String toString() {
130
		return datum.toString();
131
	}
73
            EX (") = -5.266
74
            EY (") = -1.238
75
              EZ (")  =  2.381
76
            FE (ppm) = -5.109
77
     */
78
    private static String line7 = "DATUM[\"Loma Quintana\"," +
79
                                  "SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
80
                                  "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6288\"]]";
81

  
82
    /*
83
    # La Canoa
84
    <4247> +proj=longlat +ellps=intl +towgs84=-273.5,110.6,-357.9,0,0,0,0
85
    no_defs <>
86
    # PSAD56
87
    <4248> +proj=longlat +ellps=intl +towgs84=-288,175,-376,0,0,0,0 no_defs <>
88
     */
89
    private static String line8 = "DATUM[\"La Canoa\"," +
90
                                  "SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
91
                                  "TOWGS84[-270.933,115.599,-360.226,-5.266,-1.238,2.381,-5.109],AUTHORITY[\"EPSG\",\"6288\"]]";
92
    public final static CSDatum wgs84 = new CSDatum(line1);
93
    public final static CSDatum ed50 = new CSDatum(line2);
94
    public final static CSDatum ntf = new CSDatum(line3);
95
    public final static CSDatum d73 = new CSDatum(line4);
96
    public final static CSDatum nad27 = new CSDatum(line5);
97
    public final static CSDatum nad83 = new CSDatum(line6);
98
    public final static CSDatum lomaQuintana = new CSDatum(line7);
99
    public final static CSDatum laCanoa = new CSDatum(line8);
100
    private String sGeo1 = "GEOGCS[\"WGS 84\",";
101
    private String sGeo2 =
102
        ",PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," +
103
        "UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]," +
104
        "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
105
        "AUTHORITY[\"EPSG\",\"4326\"]]";
106
    private HorizontalDatum datum = null;
107

  
108
    public CSDatum(String sDatum) {
109
        try {
110
            datum = ((GeographicCoordinateSystem) CoordinateSystemFactory.getDefault()
111
                                                                         .createFromWKT(sGeo1 +
112
                                                                                        sDatum +
113
                                                                                        sGeo2)).getHorizontalDatum();
114
        } catch (FactoryException e) {
115
            // TODO Bloque catch generado autom?ticamente
116
            e.printStackTrace();
117
        }
118
    }
119

  
120
    public String getName(Locale loc) {
121
        return datum.getName().toString();
122
    }
123

  
124
    HorizontalDatum getDatum() {
125
        return datum;
126
    }
127

  
128
    public double getESemiMajorAxis() {
129
        return datum.getEllipsoid().getSemiMajorAxis();
130
    }
131

  
132
    public double getEIFlattening() {
133
        return datum.getEllipsoid().getInverseFlattening();
134
    }
135

  
136
    public String toString() {
137
        return datum.toString();
138
    }
132 139
}
133

  

Also available in: Unified diff