FACT++  1.0
gc2gd.c
Go to the documentation of this file.
1 #include "erfa.h"
2 
3 int eraGc2gd ( int n, double xyz[3],
4  double *elong, double *phi, double *height )
5 /*
6 ** - - - - - - - - -
7 ** e r a G c 2 g d
8 ** - - - - - - - - -
9 **
10 ** Transform geocentric coordinates to geodetic using the specified
11 ** reference ellipsoid.
12 **
13 ** Given:
14 ** n int ellipsoid identifier (Note 1)
15 ** xyz double[3] geocentric vector (Note 2)
16 **
17 ** Returned:
18 ** elong double longitude (radians, east +ve, Note 3)
19 ** phi double latitude (geodetic, radians, Note 3)
20 ** height double height above ellipsoid (geodetic, Notes 2,3)
21 **
22 ** Returned (function value):
23 ** int status: 0 = OK
24 ** -1 = illegal identifier (Note 3)
25 ** -2 = internal error (Note 3)
26 **
27 ** Notes:
28 **
29 ** 1) The identifier n is a number that specifies the choice of
30 ** reference ellipsoid. The following are supported:
31 **
32 ** n ellipsoid
33 **
34 ** 1 ERFA_WGS84
35 ** 2 ERFA_GRS80
36 ** 3 ERFA_WGS72
37 **
38 ** The n value has no significance outside the ERFA software. For
39 ** convenience, symbols ERFA_WGS84 etc. are defined in erfam.h.
40 **
41 ** 2) The geocentric vector (xyz, given) and height (height, returned)
42 ** are in meters.
43 **
44 ** 3) An error status -1 means that the identifier n is illegal. An
45 ** error status -2 is theoretically impossible. In all error cases,
46 ** all three results are set to -1e9.
47 **
48 ** 4) The inverse transformation is performed in the function eraGd2gc.
49 **
50 ** Called:
51 ** eraEform Earth reference ellipsoids
52 ** eraGc2gde geocentric to geodetic transformation, general
53 **
54 ** Copyright (C) 2013-2015, NumFOCUS Foundation.
55 ** Derived, with permission, from the SOFA library. See notes at end of file.
56 */
57 {
58  int j;
59  double a, f;
60 
61 /* Obtain reference ellipsoid parameters. */
62  j = eraEform ( n, &a, &f );
63 
64 /* If OK, transform x,y,z to longitude, geodetic latitude, height. */
65  if ( j == 0 ) {
66  j = eraGc2gde ( a, f, xyz, elong, phi, height );
67  if ( j < 0 ) j = -2;
68  }
69 
70 /* Deal with any errors. */
71  if ( j < 0 ) {
72  *elong = -1e9;
73  *phi = -1e9;
74  *height = -1e9;
75  }
76 
77 /* Return the status. */
78  return j;
79 
80 }
81 /*----------------------------------------------------------------------
82 **
83 **
84 ** Copyright (C) 2013-2015, NumFOCUS Foundation.
85 ** All rights reserved.
86 **
87 ** This library is derived, with permission, from the International
88 ** Astronomical Union's "Standards of Fundamental Astronomy" library,
89 ** available from http://www.iausofa.org.
90 **
91 ** The ERFA version is intended to retain identical functionality to
92 ** the SOFA library, but made distinct through different function and
93 ** file names, as set out in the SOFA license conditions. The SOFA
94 ** original has a role as a reference standard for the IAU and IERS,
95 ** and consequently redistribution is permitted only in its unaltered
96 ** state. The ERFA version is not subject to this restriction and
97 ** therefore can be included in distributions which do not support the
98 ** concept of "read only" software.
99 **
100 ** Although the intent is to replicate the SOFA API (other than
101 ** replacement of prefix names) and results (with the exception of
102 ** bugs; any that are discovered will be fixed), SOFA is not
103 ** responsible for any errors found in this version of the library.
104 **
105 ** If you wish to acknowledge the SOFA heritage, please acknowledge
106 ** that you are using a library derived from SOFA, rather than SOFA
107 ** itself.
108 **
109 **
110 ** TERMS AND CONDITIONS
111 **
112 ** Redistribution and use in source and binary forms, with or without
113 ** modification, are permitted provided that the following conditions
114 ** are met:
115 **
116 ** 1 Redistributions of source code must retain the above copyright
117 ** notice, this list of conditions and the following disclaimer.
118 **
119 ** 2 Redistributions in binary form must reproduce the above copyright
120 ** notice, this list of conditions and the following disclaimer in
121 ** the documentation and/or other materials provided with the
122 ** distribution.
123 **
124 ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
125 ** the International Astronomical Union nor the names of its
126 ** contributors may be used to endorse or promote products derived
127 ** from this software without specific prior written permission.
128 **
129 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
130 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
131 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
132 ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
133 ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
134 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
135 ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
136 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
137 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
138 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
139 ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
140 ** POSSIBILITY OF SUCH DAMAGE.
141 **
142 */
int eraGc2gde(double a, double f, double xyz[3], double *elong, double *phi, double *height)
Definition: gc2gde.c:3
float height
Definition: HeadersGPS.h:26
int eraEform(int n, double *a, double *f)
Definition: eform.c:3
int eraGc2gd(int n, double xyz[3], double *elong, double *phi, double *height)
Definition: gc2gd.c:3