source: trunk/FACT++/erfa/src/gc2gd.c@ 19536

Last change on this file since 19536 was 18921, checked in by tbretz, 7 years ago
Updated to ERFA 1.4.0
File size: 5.1 KB
Line 
1#include "erfa.h"
2
3int 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-2017, 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
62/* Obtain reference ellipsoid parameters. */
63 j = eraEform ( n, &a, &f );
64
65/* If OK, transform x,y,z to longitude, geodetic latitude, height. */
66 if ( j == 0 ) {
67 j = eraGc2gde ( a, f, xyz, elong, phi, height );
68 if ( j < 0 ) j = -2;
69 }
70
71/* Deal with any errors. */
72 if ( j < 0 ) {
73 *elong = -1e9;
74 *phi = -1e9;
75 *height = -1e9;
76 }
77
78/* Return the status. */
79 return j;
80
81}
82/*----------------------------------------------------------------------
83**
84**
85** Copyright (C) 2013-2017, NumFOCUS Foundation.
86** All rights reserved.
87**
88** This library is derived, with permission, from the International
89** Astronomical Union's "Standards of Fundamental Astronomy" library,
90** available from http://www.iausofa.org.
91**
92** The ERFA version is intended to retain identical functionality to
93** the SOFA library, but made distinct through different function and
94** file names, as set out in the SOFA license conditions. The SOFA
95** original has a role as a reference standard for the IAU and IERS,
96** and consequently redistribution is permitted only in its unaltered
97** state. The ERFA version is not subject to this restriction and
98** therefore can be included in distributions which do not support the
99** concept of "read only" software.
100**
101** Although the intent is to replicate the SOFA API (other than
102** replacement of prefix names) and results (with the exception of
103** bugs; any that are discovered will be fixed), SOFA is not
104** responsible for any errors found in this version of the library.
105**
106** If you wish to acknowledge the SOFA heritage, please acknowledge
107** that you are using a library derived from SOFA, rather than SOFA
108** itself.
109**
110**
111** TERMS AND CONDITIONS
112**
113** Redistribution and use in source and binary forms, with or without
114** modification, are permitted provided that the following conditions
115** are met:
116**
117** 1 Redistributions of source code must retain the above copyright
118** notice, this list of conditions and the following disclaimer.
119**
120** 2 Redistributions in binary form must reproduce the above copyright
121** notice, this list of conditions and the following disclaimer in
122** the documentation and/or other materials provided with the
123** distribution.
124**
125** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
126** the International Astronomical Union nor the names of its
127** contributors may be used to endorse or promote products derived
128** from this software without specific prior written permission.
129**
130** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
131** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
132** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
133** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
134** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
135** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
136** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
137** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
138** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
139** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
140** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
141** POSSIBILITY OF SUCH DAMAGE.
142**
143*/
Note: See TracBrowser for help on using the repository browser.