1 /* jpleph.h: header for JPL ephemeris functions
2 
3 Copyright (C) 2011, Project Pluto
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.    */
19 
20 #ifndef JPLEPH_H
21 #define JPLEPH_H
22 
23 /***************************************************************************
24 *******                  JPLEPH.H                                  *********
25 ****************************************************************************
26 **  This header file is used both by ASC2EPH and TESTEPH programs.        **
27 ****************************************************************************
28 **  Written: May 28, 1997 by PAD   **  Last modified: June 23,1997 by PAD **
29 **  Modified further by Bill Gray,  Jun-Aug 2001                          **
30 ****************************************************************************
31 **  PAD: dr. Piotr A. Dybczynski,          e-mail: dybol@phys.amu.edu.pl  **
32 **   Astronomical Observatory of the A.Mickiewicz Univ., Poznan, Poland   **
33 ***************************************************************************/
34 
35 /* By default,  in Windoze 32,  the JPL ephemeris functions are compiled
36    into a DLL.  This is not really all that helpful at present,  but may
37    be useful to people who want to use the functions from languages other
38    than C. */
39 
40 #ifdef _WIN32
41 #define DLL_FUNC __stdcall
42 #else
43 #define DLL_FUNC
44 #endif
45 
46 #ifdef __WATCOMC__
47    #include <stdbool.h>
48 #endif
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 void * DLL_FUNC jpl_init_ephemeris( const char *ephemeris_filename,
55                                              char nam[][6], double *val);
56 void DLL_FUNC jpl_close_ephemeris( void *ephem);
57 int DLL_FUNC jpl_state( void *ephem, const double et, const int list[14],
58                           double pv[][6], double nut[4], const int bary);
59 int DLL_FUNC jpl_pleph( void *ephem, const double et, const int ntarg,
60                       const int ncent, double rrd[], const int calc_velocity);
61 double DLL_FUNC jpl_get_double( const void *ephem, const int value);
62 long DLL_FUNC jpl_get_long( const void *ephem, const int value);
63 int DLL_FUNC make_sub_ephem( void *ephem, const char *sub_filename,
64                               const double start_jd, const double end_jd);
65 double DLL_FUNC jpl_get_constant( const int idx, void *ephem, char *constant_name);
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 
71          /* Following are constants used in          */
72          /* jpl_get_double( ) and jpl_get_long( ):   */
73 
74 #define JPL_EPHEM_START_JD               0
75 #define JPL_EPHEM_END_JD                 8
76 #define JPL_EPHEM_STEP                  16
77 #define JPL_EPHEM_N_CONSTANTS           24
78 #define JPL_EPHEM_AU_IN_KM              28
79 #define JPL_EPHEM_EARTH_MOON_RATIO      36
80 #define JPL_EPHEM_IPT_ARRAY             44
81 #define JPL_EPHEM_EPHEMERIS_VERSION    224
82 #define JPL_EPHEM_KERNEL_SIZE          228
83 #define JPL_EPHEM_KERNEL_RECORD_SIZE   232
84 #define JPL_EPHEM_KERNEL_NCOEFF        236
85 #define JPL_EPHEM_KERNEL_SWAP_BYTES    240
86 
87          /* The following error codes may be returned by */
88          /* jpl_state() and jpl_pleph():                 */
89 #define JPL_EPH_OUTSIDE_RANGE                (-1)
90 #define JPL_EPH_READ_ERROR                   (-2)
91 #define JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS    (-3)
92 #define JPL_EPH_INVALID_INDEX                (-5)
93 #define JPL_EPH_FSEEK_ERROR                  (-6)
94 
95 int DLL_FUNC jpl_init_error_code( void);
96 
97          /* The following error codes may be returned by       */
98          /* jpl_init_error_code( ) after jpl_init_ephemeris( ) */
99          /* has been called:                                   */
100 
101 #define JPL_INIT_NO_ERROR                 0
102 #define JPL_INIT_FILE_NOT_FOUND          -1
103 #define JPL_INIT_FSEEK_FAILED            -2
104 #define JPL_INIT_FREAD_FAILED            -3
105 #define JPL_INIT_FREAD2_FAILED           -4
106 #define JPL_INIT_FREAD5_FAILED           -10
107 #define JPL_INIT_FILE_CORRUPT            -5
108 #define JPL_INIT_MEMORY_FAILURE          -6
109 #define JPL_INIT_FREAD3_FAILED           -7
110 #define JPL_INIT_FREAD4_FAILED           -8
111 #define JPL_INIT_NOT_CALLED              -9
112 
113 #define jpl_get_pvsun( ephem) ((double *)((char *)ephem + 248))
114 
115 /* addition for use in stellarium */
116 #define JPL_MAX_N_CONSTANTS 1018
117 #define CALC_VELOCITY       0
118 #define CENTRAL_PLANET_ID   11  //ID of sun in JPL enumeration
119 
120 const char * jpl_init_error_message(void);
121 
122 #endif // JPLEPH_H
123