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