Statistics
| Revision:

svn-gvsig-desktop / tags / gvSIGv0_6_1RELEASE / libraries / libCq CMS for java.old / src / org / cresques / cts / gt2 / CSDatum.java @ 5222

History | View | Annotate | Download (7.46 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.cts.gt2;
25

    
26
import org.cresques.cts.IDatum;
27

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

    
32
import org.opengis.referencing.FactoryException;
33

    
34
import java.util.Locale;
35

    
36

    
37
/**
38
 * Datum (y Ellipsoid) de GeoTools2.
39
 *
40
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
41
 */
42
public class CSDatum implements IDatum {
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\"]]";
61

    
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
72

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

    
93
    private static String line9 = "DATUM[\"Nouvelle_Triangulation_Francaise_Paris\"," +
94
                "SPHEROID[\"Clarke 1880 (IGN)\",6378249.2,293.4660212936269,AUTHORITY[\"EPSG\",\"7011\"]]," +
95
                "TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY[\"EPSG\",\"8903\"]]";
96
    
97
    private static String line10 = "DATUM[\"Reseau Geodesique Francais 1993\"," +
98
            "SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]," +
99
            "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6171\"]]";
100

    
101
    private String sGeo1 = "GEOGCS[\"WGS 84\",";
102
    private String sGeo2 =
103
        ",PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," +
104
        "UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]," +
105
        "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
106
        "AUTHORITY[\"EPSG\",\"4326\"]]";
107
    private static String sGeo1_9 = "GEOGCS[\"NTF (Paris)\",";
108
    private static String sGeo2_9 =
109
        ",PRIMEM[\"Paris\",2.33722917,AUTHORITY[\"EPSG\",\"8903\"]]," +
110
        "UNIT[\"grad\",0.01570796326794897,AUTHORITY[\"EPSG\",\"9105\"]]," +
111
        "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
112
        "AUTHORITY[\"EPSG\",\"4807\"]]";
113
    
114
    private static String sGeo1_10 = "GEOGCS[\"RGF93\",";
115
    private static String sGeo2_10 =
116
        ",PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," +
117
        "UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]," +
118
        "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
119
        "AUTHORITY[\"EPSG\",\"4171\"]]";
120

    
121
    public final static CSDatum wgs84 = new CSDatum(line1);
122
    public final static CSDatum ed50 = new CSDatum(line2);
123
    public final static CSDatum ntf = new CSDatum(line3);
124
    public final static CSDatum d73 = new CSDatum(line4);
125
    public final static CSDatum nad27 = new CSDatum(line5);
126
    public final static CSDatum nad83 = new CSDatum(line6);
127
    public final static CSDatum lomaQuintana = new CSDatum(line7);
128
    public final static CSDatum laCanoa = new CSDatum(line8);
129
    public final static CSDatum ntfParis = new CSDatum(sGeo1_9, line9, sGeo2_9);
130
    public final static CSDatum rgf93 = new CSDatum(sGeo1_10, line10, sGeo2_10);
131
    private HorizontalDatum datum = null;
132

    
133
    public CSDatum(String sDatum) {
134
            initDatum(sGeo1, sDatum, sGeo2);
135
    }
136

    
137
    public CSDatum(String sGeo1, String sDatum, String sGeo2) {
138
            initDatum(sGeo1, sDatum, sGeo2);
139
    }
140
    private void initDatum(String sGeo1, String sDatum, String sGeo2) {
141
        try {
142
            datum = ((GeographicCoordinateSystem) CoordinateSystemFactory.getDefault()
143
                                                                         .createFromWKT(sGeo1 +
144
                                                                                        sDatum +
145
                                                                                        sGeo2)).getHorizontalDatum();
146
        } catch (FactoryException e) {
147
            // TODO Bloque catch generado autom?ticamente
148
            e.printStackTrace();
149
        }
150
    }
151

    
152
    public String getName(Locale loc) {
153
        return datum.getName().toString();
154
    }
155

    
156
    HorizontalDatum getDatum() {
157
        return datum;
158
    }
159

    
160
    public double getESemiMajorAxis() {
161
        return datum.getEllipsoid().getSemiMajorAxis();
162
    }
163

    
164
    public double getEIFlattening() {
165
        return datum.getEllipsoid().getInverseFlattening();
166
    }
167

    
168
    public String toString() {
169
        return datum.toString();
170
    }
171
}