source: trunk/FACT++/erfa/src/gd2gc.c@ 19008

Last change on this file since 19008 was 18921, checked in by tbretz, 7 years ago
Updated to ERFA 1.4.0
File size: 5.2 KB
Line 
1#include "erfa.h"
2
3int 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-2017, 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
65/* Obtain reference ellipsoid parameters. */
66 j = eraEform ( n, &a, &f );
67
68/* If OK, transform longitude, geodetic latitude, height to x,y,z. */
69 if ( j == 0 ) {
70 j = eraGd2gce ( a, f, elong, phi, height, xyz );
71 if ( j != 0 ) j = -2;
72 }
73
74/* Deal with any errors. */
75 if ( j != 0 ) eraZp ( xyz );
76
77/* Return the status. */
78 return j;
79
80}
81/*----------------------------------------------------------------------
82**
83**
84** Copyright (C) 2013-2017, 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*/
Note: See TracBrowser for help on using the repository browser.