1 /*
2    Portions Copyright (C) 2000-2019 The Xastir Group
3 
4    The datum conversion code here and in datum.c is from MacGPS 45.
5 
6    According to the Read_Me file in the source archive of that program,
7    the author says the following:
8 
9    "I've read the legalese statements that everyone attaches to works like this,
10    but I can never remember what they say. Suffice it to say that I am releasing
11    this source code to the public domain, and you are free to do with it what you
12    like. If you find it of some use and include any of it in an application,
13    credits (and perhaps a copy of your program, if your feel so inclined) would
14    be appreciated.
15 
16    John F. Waers <jfwaers@csn.net>"
17 
18    If you ever read this, John, thanks for the code and feel free to try out
19    Xastir, it's free.
20 
21    The UTM to/from Lat/Long translations were written by Chuck Gantz
22    <chuck.gantz@globalstar.com>.  Curt Mills received permission via e-mail
23    to release the code under the GPL for a conversion he did to perl.
24    I deduce from this that including it in Xastir, a GPL program is no problem.
25    Thanks Chuck!
26 
27    N7TAP
28 */
29 
30 
31 
32 // Equatorial radius of the Earth.  In our distance/angular/area
33 // calculations (not here in datum.h/datum.c, but elsewhere in the
34 // code) we currently ignore flattening as you go towards the poles.
35 //
36 // The datum translation code in datum.h/datum.c doesn't use these
37 // three defines at all:  That code uses ellipsoids and so
38 // flattening is accounted for there.
39 #define EARTH_RADIUS_METERS     6378138.0
40 #define EARTH_RADIUS_KILOMETERS 6378.138
41 #define EARTH_RADIUS_MILES      3963.1836
42 
43 
44 #define FROM_WGS_84 1
45 #define TO_WGS_84   0
46 void wgs84_datum_shift(short fromWGS84, double *latitude, double *longitude, short datumID);
47 void datum_shift(double *latitude, double *longitude, short fromDatumID, short toDatumID);
48 
49 typedef struct
50 {
51   char  *name;    // name of ellipsoid
52   double a;       // semi-major axis, meters
53   double invf;    // 1/f
54 } Ellipsoid;
55 
56 extern const Ellipsoid gEllipsoid[];
57 
58 enum Ellipsoid_Names   // Must match the order of the Ellipsoids defined in datum.c
59 {
60   E_AIRY_30,
61   E_MOD_AIRY,
62   E_AUS_NAT,
63   E_BESS_41,
64   E_BESS_41_NAM,
65   E_CLARKE_66,
66   E_CLARKE_80,
67   E_EVR_IND_30,
68   E_EVR_IND_56,
69   E_EVR_SAB_SAR,
70   E_EVR_MAL_69,
71   E_EVR_MAL_SING,
72   E_EVR_PAK,
73   E_FISCH_60_MERC,
74   E_MOD_FISCH_60,
75   E_FISCH_68,
76   E_HELM_06,
77   E_HOUGH_60,
78   E_IND_74,
79   E_INT_24,
80   E_KRASS_40,
81   E_GRS_67,
82   E_GRS_80,
83   E_S_AMER_69,
84   E_WGS_60,
85   E_WGS_66,
86   E_WGS_72,
87   E_WGS_84
88 };
89 
90 typedef struct
91 {
92   char *name;
93   short ellipsoid;
94   short dx;
95   short dy;
96   short dz;
97 } Datum;
98 
99 extern const Datum gDatum[];
100 
101 enum Common_Datum_Names   // Must match the indices of the Datums defined in datum.c
102 {
103   D_NAD_27_CONUS = 131,
104   D_NAD_83_CONUS = 138,
105   D_WGS_72 = 215,
106   D_WGS_84 = 216
107 };
108 
109 void ll_to_utm_ups(short ellipsoidID, const double lat, const double lon,
110                    double *utmNorthing, double *utmEasting, char* utmZone, int utmZoneLength);
111 void utm_ups_to_ll(short ellipsoidID, const double utmNorthing, const double utmEasting,
112                    const char* utmZone, double *lat, double *lon);
113 char utm_letter_designator(double lat, double lon);
114 
115 
116