[1457] | 1 | /* code to convert between .edb format and an Obj */
|
---|
| 2 |
|
---|
| 3 | #include <stdio.h>
|
---|
| 4 | #include <ctype.h>
|
---|
| 5 | #include <math.h>
|
---|
| 6 |
|
---|
| 7 | #if defined(__STDC__)
|
---|
| 8 | #include <stdlib.h>
|
---|
| 9 | #include <string.h>
|
---|
| 10 | #endif
|
---|
| 11 |
|
---|
| 12 | #include "P_.h"
|
---|
| 13 | #include "astro.h"
|
---|
| 14 | #include "circum.h"
|
---|
| 15 | #include "preferences.h"
|
---|
| 16 |
|
---|
| 17 | extern void zero_mem P_((void *loc, unsigned len));
|
---|
| 18 | extern double atod P_((char *buf));
|
---|
| 19 |
|
---|
| 20 | int get_fields P_((char *s, int delim, char *fields[]));
|
---|
| 21 | int db_set_field P_((char bp[], int id, PrefDateFormat pref, Obj *op));
|
---|
| 22 | int db_chk_planet P_((char name[], Obj *op));
|
---|
| 23 |
|
---|
| 24 | #define MAXDBLINE 256 /* longest allowed db line */
|
---|
| 25 |
|
---|
| 26 | #define FLDSEP ',' /* major field separator */
|
---|
| 27 | #define SUBFLD '|' /* subfield separator */
|
---|
| 28 | #define MAXFLDS 20 /* must be more than on any expected line */
|
---|
| 29 |
|
---|
| 30 | #define ASIZ(a) (sizeof(a)/sizeof(a[0]))
|
---|
| 31 |
|
---|
| 32 | static int line_candidate P_((char *buf));
|
---|
| 33 | static void crack_year P_((char *bp, PrefDateFormat pref, double *p));
|
---|
| 34 | static int db_get_field P_((Obj *op, int id, char *bp));
|
---|
| 35 | static int tle_sum P_((char *l));
|
---|
| 36 | static double tle_fld P_((char *l, int from, int thru));
|
---|
| 37 | static double tle_expfld P_((char *l, int start));
|
---|
| 38 |
|
---|
| 39 | /* crack the given .edb database line into op.
|
---|
| 40 | * if ok
|
---|
| 41 | * return 0
|
---|
| 42 | * else
|
---|
| 43 | * if whynot
|
---|
| 44 | * if not even a candidate
|
---|
| 45 | * set whynot[0] = '\0'
|
---|
| 46 | * else
|
---|
| 47 | * fill whynot with reason message.
|
---|
| 48 | * return -1
|
---|
| 49 | */
|
---|
| 50 | int
|
---|
| 51 | db_crack_line (s, op, whynot)
|
---|
| 52 | char s[];
|
---|
| 53 | Obj *op;
|
---|
| 54 | char whynot[];
|
---|
| 55 | {
|
---|
| 56 | char *flds[MAXFLDS]; /* point to each field for easy reference */
|
---|
| 57 | char *sflds[MAXFLDS]; /* point to each sub field for easy reference */
|
---|
| 58 | char copy[MAXDBLINE]; /* work copy; leave s untouched */
|
---|
| 59 | int nf, nsf; /* number of fields and subfields */
|
---|
| 60 | int i;
|
---|
| 61 |
|
---|
| 62 | /* basic initial check */
|
---|
| 63 | if (line_candidate (s) < 0) {
|
---|
| 64 | if (whynot)
|
---|
| 65 | whynot[0] = '\0';
|
---|
| 66 | return (-1);
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | /* do all the parsing on a copy */
|
---|
| 70 | (void) strcpy (copy, s);
|
---|
| 71 | i = strlen(copy);
|
---|
| 72 | if (copy[i-1] == '\n')
|
---|
| 73 | copy[i-1] = '\0';
|
---|
| 74 |
|
---|
| 75 | /* parse into main fields */
|
---|
| 76 | nf = get_fields (copy, FLDSEP, flds);
|
---|
| 77 |
|
---|
| 78 | /* need at least 2: name and type */
|
---|
| 79 | if (nf < 2) {
|
---|
| 80 | if (whynot)
|
---|
| 81 | sprintf (whynot, "Found only %d fields", nf);
|
---|
| 82 | return (-1);
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | /* switch out on type of object - the second field */
|
---|
| 86 | switch (flds[1][0]) {
|
---|
| 87 | case 'f': {
|
---|
| 88 | static int ids[] = {F_RA, F_DEC, F_MAG};
|
---|
| 89 | if (nf < 5 || nf > 7) {
|
---|
| 90 | if (whynot)
|
---|
| 91 | sprintf (whynot, "f needs 5-7 fields: %d", nf);
|
---|
| 92 | return (-1);
|
---|
| 93 | }
|
---|
| 94 | zero_mem ((void *)op, sizeof(ObjF));
|
---|
| 95 | op->o_type = FIXED;
|
---|
| 96 | nsf = get_fields(flds[1], SUBFLD, sflds);
|
---|
| 97 | if (nsf > 1 && db_set_field (sflds[1], F_CLASS, PREF_MDY, op) < 0) {
|
---|
| 98 | if (whynot)
|
---|
| 99 | sprintf (whynot, "Bad f class: %c", sflds[1][0]);
|
---|
| 100 | return (-1);
|
---|
| 101 | }
|
---|
| 102 | if (nsf > 2)
|
---|
| 103 | (void) db_set_field (sflds[2], F_SPECT, PREF_MDY, op);
|
---|
| 104 | for (i = 2; i < ASIZ(ids)+2; i++)
|
---|
| 105 | (void) db_set_field (flds[i], ids[i-2], PREF_MDY, op);
|
---|
| 106 | (void) db_set_field (nf>5 && flds[5][0] ? flds[5] : "2000",
|
---|
| 107 | F_EPOCH, PREF_MDY, op);
|
---|
| 108 | if (nf == 7)
|
---|
| 109 | (void) db_set_field (flds[6], F_SIZE, PREF_MDY, op);
|
---|
| 110 | break;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | case 'e': {
|
---|
| 114 | static int ids[] = {E_INC, E_LAN, E_AOP, E_A, E_N, E_E, E_M,
|
---|
| 115 | E_CEPOCH, E_EPOCH, E_M1, E_M2
|
---|
| 116 | };
|
---|
| 117 | if (nf != 13 && nf != 14) {
|
---|
| 118 | if (whynot)
|
---|
| 119 | sprintf (whynot, "e needs 13 or 14 fields: %d", nf);
|
---|
| 120 | return (-1);
|
---|
| 121 | }
|
---|
| 122 | zero_mem ((void *)op, sizeof(ObjE));
|
---|
| 123 | op->o_type = ELLIPTICAL;
|
---|
| 124 | for (i = 2; i < ASIZ(ids)+2; i++)
|
---|
| 125 | (void) db_set_field (flds[i], ids[i-2], PREF_MDY, op);
|
---|
| 126 | if (nf == 14)
|
---|
| 127 | (void) db_set_field (flds[13], E_SIZE, PREF_MDY, op);
|
---|
| 128 | break;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | case 'h': {
|
---|
| 132 | static int ids[]= {H_EP,H_INC,H_LAN,H_AOP,H_E,H_QP,H_EPOCH,H_G,H_K};
|
---|
| 133 | if (nf != 11 && nf != 12) {
|
---|
| 134 | if (whynot)
|
---|
| 135 | sprintf (whynot, "h needs 11 or 12 fields: %d", nf);
|
---|
| 136 | return (-1);
|
---|
| 137 | }
|
---|
| 138 | zero_mem ((void *)op, sizeof(ObjH));
|
---|
| 139 | op->o_type = HYPERBOLIC;
|
---|
| 140 | for (i = 2; i < ASIZ(ids)+2; i++)
|
---|
| 141 | (void) db_set_field (flds[i], ids[i-2], PREF_MDY, op);
|
---|
| 142 | if (nf == 12)
|
---|
| 143 | (void) db_set_field (flds[11], H_SIZE, PREF_MDY, op);
|
---|
| 144 | break;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | case 'p': {
|
---|
| 148 | static int ids[] = {P_EP,P_INC,P_AOP,P_QP,P_LAN,P_EPOCH,P_G,P_K};
|
---|
| 149 | if (nf != 10 && nf != 11) {
|
---|
| 150 | if (whynot)
|
---|
| 151 | sprintf (whynot, "p needs 10 or 11 fields: %d", nf);
|
---|
| 152 | return (-1);
|
---|
| 153 | }
|
---|
| 154 | zero_mem ((void *)op, sizeof(ObjP));
|
---|
| 155 | op->o_type = PARABOLIC;
|
---|
| 156 | for (i = 2; i < ASIZ(ids)+2; i++)
|
---|
| 157 | (void) db_set_field (flds[i], ids[i-2], PREF_MDY, op);
|
---|
| 158 | if (nf == 11)
|
---|
| 159 | (void) db_set_field (flds[10], P_SIZE, PREF_MDY, op);
|
---|
| 160 | break;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | case 'E': {
|
---|
| 164 | static int ids[] = {ES_EPOCH,ES_INC,ES_RAAN,ES_E,ES_AP,ES_M,ES_N,
|
---|
| 165 | ES_DECAY,ES_ORBIT};
|
---|
| 166 | if (nf != 11 && nf != 12) {
|
---|
| 167 | if (whynot)
|
---|
| 168 | sprintf (whynot, "E needs 11 or 12 fields: %d", nf);
|
---|
| 169 | return (-1);
|
---|
| 170 | }
|
---|
| 171 | zero_mem ((void *)op, sizeof(ObjES));
|
---|
| 172 | op->o_type = EARTHSAT;
|
---|
| 173 | for (i = 2; i < ASIZ(ids)+2; i++)
|
---|
| 174 | (void) db_set_field (flds[i], ids[i-2], PREF_MDY, op);
|
---|
| 175 | if (nf == 12)
|
---|
| 176 | (void) db_set_field (flds[11], ES_DRAG, PREF_MDY, op);
|
---|
| 177 | break;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | case 'P':
|
---|
| 181 | /* allow, though ignore, anything after the P */
|
---|
| 182 | i = db_chk_planet (flds[0], op); /* does o_name too */
|
---|
| 183 | if (i < 0) {
|
---|
| 184 | if (whynot)
|
---|
| 185 | sprintf (whynot, "Bad planet: %s", flds[0]);
|
---|
| 186 | }
|
---|
| 187 | return (i);
|
---|
| 188 |
|
---|
| 189 | default:
|
---|
| 190 | if (whynot)
|
---|
| 191 | sprintf (whynot, "Unknown type: %c", flds[1][0]);
|
---|
| 192 | return (-1);
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | /* load up o_name */
|
---|
| 196 | (void) db_set_field (flds[0], O_NAME, PREF_MDY, op);
|
---|
| 197 |
|
---|
| 198 | return (0);
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | /* return 0 if TLE checksum is ok, else -1 */
|
---|
| 202 | static int
|
---|
| 203 | tle_sum (l)
|
---|
| 204 | char *l;
|
---|
| 205 | {
|
---|
| 206 | char *lastl = l + 68;
|
---|
| 207 | int sum;
|
---|
| 208 |
|
---|
| 209 | for (sum = 0; l < lastl; ) {
|
---|
| 210 | char c = *l++;
|
---|
| 211 | if (c == '\0')
|
---|
| 212 | return (-1);
|
---|
| 213 | if (isdigit(c))
|
---|
| 214 | sum += c - '0';
|
---|
| 215 | else if (c == '-')
|
---|
| 216 | sum++;
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 | return (*l - '0' == (sum%10) ? 0 : -1);
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | /* extract the given columns and return value.
|
---|
| 223 | * N.B. from and to are 1-based within l
|
---|
| 224 | */
|
---|
| 225 | static double
|
---|
| 226 | tle_fld (l, from, thru)
|
---|
| 227 | char *l;
|
---|
| 228 | int from, thru;
|
---|
| 229 | {
|
---|
| 230 | char buf[32];
|
---|
| 231 |
|
---|
| 232 | sprintf (buf, "%.*s", thru-from+1, l+from-1);
|
---|
| 233 | return (atod (buf));
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | /* extract the exponential value starting at the given column.
|
---|
| 237 | * N.B. start is 1-based within l
|
---|
| 238 | */
|
---|
| 239 | static double
|
---|
| 240 | tle_expfld (l, start)
|
---|
| 241 | char *l;
|
---|
| 242 | int start;
|
---|
| 243 | {
|
---|
| 244 | char buf[32];
|
---|
| 245 | double v;
|
---|
| 246 |
|
---|
| 247 | sprintf (buf, ".%.*s", 5, l+start);
|
---|
| 248 | v = atod (buf) * pow (10.0, tle_fld(l, start+6, start+7));
|
---|
| 249 | if (l[start-1] == '-')
|
---|
| 250 | v = -v;
|
---|
| 251 | return (v);
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | /* given 3 lines, first of which is name and next 2 are TLE, fill op.
|
---|
| 255 | * we skip leading whitespace on all lines.
|
---|
| 256 | * we do /not/ assume the 2 TLE lines are 0 terminated, but we do reach out into
|
---|
| 257 | * each as far as 69 chars.
|
---|
| 258 | * we detect nonconformance as efficiently as possible.
|
---|
| 259 | * name ends at first '\0', '\r' or '\n'.
|
---|
| 260 | * if ok return 0 else return -1
|
---|
| 261 | */
|
---|
| 262 | int
|
---|
| 263 | db_tle (name, l1, l2, op)
|
---|
| 264 | char *name, *l1, *l2;
|
---|
| 265 | Obj *op;
|
---|
| 266 | {
|
---|
| 267 | double ep;
|
---|
| 268 | int i;
|
---|
| 269 |
|
---|
| 270 | /* check for correct line numbers, macthing satellite numbers and
|
---|
| 271 | * correct checksums.
|
---|
| 272 | */
|
---|
| 273 | while (isspace(*l1))
|
---|
| 274 | l1++;
|
---|
| 275 | if (*l1 != '1')
|
---|
| 276 | return (-1);
|
---|
| 277 | while (isspace(*l2))
|
---|
| 278 | l2++;
|
---|
| 279 | if (*l2 != '2')
|
---|
| 280 | return (-1);
|
---|
| 281 | if (strncmp (l1+2, l2+2, 5))
|
---|
| 282 | return (-1);
|
---|
| 283 | if (tle_sum (l1) < 0)
|
---|
| 284 | return (-1);
|
---|
| 285 | if (tle_sum (l2) < 0)
|
---|
| 286 | return (-1);
|
---|
| 287 |
|
---|
| 288 | /* assume it's ok from here out */
|
---|
| 289 |
|
---|
| 290 | /* fresh */
|
---|
| 291 | zero_mem ((void *)op, sizeof(ObjES));
|
---|
| 292 | op->o_type = EARTHSAT;
|
---|
| 293 |
|
---|
| 294 | /* name, sans leading and trailing whitespace */
|
---|
| 295 | while (isspace(*name))
|
---|
| 296 | name++;
|
---|
| 297 | i = strcspn (name, "\r\n");
|
---|
| 298 | while (i > 0 && name[i-1] == ' ')
|
---|
| 299 | --i;
|
---|
| 300 | if (i == 0)
|
---|
| 301 | return (-1);
|
---|
| 302 | if (i > MAXNM-1)
|
---|
| 303 | i = MAXNM-1;
|
---|
| 304 | sprintf (op->o_name, "%.*s", i, name);
|
---|
| 305 |
|
---|
| 306 | /* goodies from "line 1" */
|
---|
| 307 | op->es_drag = (float) tle_expfld (l1, 54);
|
---|
| 308 | i = (int) tle_fld (l1, 19, 20);
|
---|
| 309 | if (i < 57)
|
---|
| 310 | i += 100;
|
---|
| 311 | cal_mjd (1, tle_fld(l1, 21, 32), i+1900, &ep);
|
---|
| 312 | op->es_epoch = ep;
|
---|
| 313 |
|
---|
| 314 | /* goodies from "line 2" */
|
---|
| 315 | op->es_n = tle_fld (l2, 53, 63);
|
---|
| 316 | op->es_inc = (float)tle_fld (l2, 9, 16);
|
---|
| 317 | op->es_raan = (float)tle_fld (l2, 18, 25);
|
---|
| 318 | op->es_e = (float)(tle_fld (l2, 27, 33) * 1e-7);
|
---|
| 319 | op->es_ap = (float)tle_fld (l2, 35, 42);
|
---|
| 320 | op->es_M = (float)tle_fld (l2, 44, 51);
|
---|
| 321 | op->es_orbit = (int)tle_fld (l2, 64, 68);
|
---|
| 322 |
|
---|
| 323 | /* yes! */
|
---|
| 324 | return (0);
|
---|
| 325 | }
|
---|
| 326 |
|
---|
| 327 | /* write the given Obj in .edb format to lp[].
|
---|
| 328 | * we do _not_ include a trailing '\n'.
|
---|
| 329 | */
|
---|
| 330 | void
|
---|
| 331 | db_write_line (op, lp)
|
---|
| 332 | Obj *op;
|
---|
| 333 | char *lp;
|
---|
| 334 | {
|
---|
| 335 | int priorpref;
|
---|
| 336 | int i;
|
---|
| 337 |
|
---|
| 338 | /* .edb format always uses MDY.
|
---|
| 339 | * N.B. must restore old value before returning from here!
|
---|
| 340 | */
|
---|
| 341 | priorpref = pref_set (PREF_DATE_FORMAT, PREF_MDY);
|
---|
| 342 |
|
---|
| 343 | switch (op->o_type) {
|
---|
| 344 | case FIXED: {
|
---|
| 345 | static int ids[] = {F_CLASS, F_SPECT, F_RA, F_DEC, F_MAG, F_EPOCH,
|
---|
| 346 | F_SIZE
|
---|
| 347 | };
|
---|
| 348 |
|
---|
| 349 | sprintf (lp, "%s,f", op->o_name);
|
---|
| 350 | lp += strlen(lp);
|
---|
| 351 | for (i = 0; i < ASIZ(ids); i++)
|
---|
| 352 | lp += db_get_field (op, ids[i], lp);
|
---|
| 353 | break;
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 | case ELLIPTICAL: {
|
---|
| 357 | static int ids[] = {E_INC, E_LAN, E_AOP, E_A, E_N, E_E, E_M,
|
---|
| 358 | E_CEPOCH, E_EPOCH, E_M1, E_M2, E_SIZE
|
---|
| 359 | };
|
---|
| 360 |
|
---|
| 361 | sprintf (lp, "%s,e", op->o_name);
|
---|
| 362 | lp += strlen(lp);
|
---|
| 363 | for (i = 0; i < ASIZ(ids); i++)
|
---|
| 364 | lp += db_get_field (op, ids[i], lp);
|
---|
| 365 | break;
|
---|
| 366 | }
|
---|
| 367 |
|
---|
| 368 | case HYPERBOLIC: {
|
---|
| 369 | static int ids[]= {H_EP, H_INC, H_LAN, H_AOP, H_E, H_QP, H_EPOCH,
|
---|
| 370 | H_G, H_K, H_SIZE
|
---|
| 371 | };
|
---|
| 372 |
|
---|
| 373 | sprintf (lp, "%s,h", op->o_name);
|
---|
| 374 | lp += strlen(lp);
|
---|
| 375 | for (i = 0; i < ASIZ(ids); i++)
|
---|
| 376 | lp += db_get_field (op, ids[i], lp);
|
---|
| 377 | break;
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 | case PARABOLIC: {
|
---|
| 381 | static int ids[] = {P_EP, P_INC, P_AOP, P_QP, P_LAN, P_EPOCH, P_G,
|
---|
| 382 | P_K, P_SIZE
|
---|
| 383 | };
|
---|
| 384 |
|
---|
| 385 | sprintf (lp, "%s,p", op->o_name);
|
---|
| 386 | lp += strlen(lp);
|
---|
| 387 | for (i = 0; i < ASIZ(ids); i++)
|
---|
| 388 | lp += db_get_field (op, ids[i], lp);
|
---|
| 389 | break;
|
---|
| 390 | }
|
---|
| 391 |
|
---|
| 392 | case EARTHSAT: {
|
---|
| 393 | static int ids[] = {ES_EPOCH, ES_INC, ES_RAAN, ES_E, ES_AP, ES_M,
|
---|
| 394 | ES_N, ES_DECAY,ES_ORBIT,ES_DRAG
|
---|
| 395 | };
|
---|
| 396 |
|
---|
| 397 | sprintf (lp, "%s,E", op->o_name);
|
---|
| 398 | lp += strlen(lp);
|
---|
| 399 | for (i = 0; i < ASIZ(ids); i++)
|
---|
| 400 | lp += db_get_field (op, ids[i], lp);
|
---|
| 401 | break;
|
---|
| 402 | }
|
---|
| 403 |
|
---|
| 404 | case PLANET:
|
---|
| 405 | sprintf (lp, "%s,P", op->o_name);
|
---|
| 406 | lp += strlen(lp);
|
---|
| 407 | break;
|
---|
| 408 |
|
---|
| 409 | default:
|
---|
| 410 | printf ("Unknown type for %s: %d\n", op->o_name, op->o_type);
|
---|
| 411 | exit(1);
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | /* restore date format preference */
|
---|
| 415 | (void) pref_set (PREF_DATE_FORMAT, priorpref);
|
---|
| 416 | }
|
---|
| 417 |
|
---|
| 418 | /* given a text buffer and a field id, and a PREF_DATE_FORMAT,
|
---|
| 419 | * set the corresponding member in *op.
|
---|
| 420 | * return 0 if ok, else -1.
|
---|
| 421 | */
|
---|
| 422 | int
|
---|
| 423 | db_set_field (bp, id, pref, op)
|
---|
| 424 | char bp[];
|
---|
| 425 | int id;
|
---|
| 426 | PrefDateFormat pref;
|
---|
| 427 | Obj *op;
|
---|
| 428 | {
|
---|
| 429 | double tmp;
|
---|
| 430 |
|
---|
| 431 | /* include all the enums and in numeric order to give us the best
|
---|
| 432 | * possible chance the compiler will implement this as a jump table.
|
---|
| 433 | */
|
---|
| 434 | switch (id) {
|
---|
| 435 | case O_TYPE:
|
---|
| 436 | printf ("db_set_field: called with id==O_TYPE\n");
|
---|
| 437 | exit(1);
|
---|
| 438 | break;
|
---|
| 439 | case O_NAME:
|
---|
| 440 | (void) strncpy (op->o_name, bp, sizeof(op->o_name)-1);
|
---|
| 441 | op->o_name[sizeof(op->o_name)-1] = '\0';
|
---|
| 442 | break;
|
---|
| 443 | case F_RA:
|
---|
| 444 | f_scansex (radhr(op->f_RA), bp, &tmp);
|
---|
| 445 | op->f_RA = (float) hrrad(tmp);
|
---|
| 446 | break;
|
---|
| 447 | case F_DEC:
|
---|
| 448 | f_scansex (raddeg(op->f_dec), bp, &tmp);
|
---|
| 449 | op->f_dec = (float) degrad(tmp);
|
---|
| 450 | break;
|
---|
| 451 | case F_EPOCH:
|
---|
| 452 | tmp = op->f_epoch;
|
---|
| 453 | crack_year (bp, pref, &tmp);
|
---|
| 454 | op->f_epoch = (float) tmp;
|
---|
| 455 | break;
|
---|
| 456 | case F_MAG:
|
---|
| 457 | set_fmag (op, atod(bp));
|
---|
| 458 | break;
|
---|
| 459 | case F_SIZE:
|
---|
| 460 | op->f_size = (float) atod(bp);
|
---|
| 461 | {
|
---|
| 462 | /* optional minor axis and position angle subfields */
|
---|
| 463 | char *sflds[MAXFLDS];
|
---|
| 464 | int nsf = get_fields(bp, SUBFLD, sflds);
|
---|
| 465 |
|
---|
| 466 | if (nsf == 3) {
|
---|
| 467 | set_ratio(op, op->s_size, atod(sflds[1]));
|
---|
| 468 | set_pa(op,degrad(atod(sflds[2])));
|
---|
| 469 | } else {
|
---|
| 470 | set_ratio(op,1,1); /* round */
|
---|
| 471 | set_pa(op,0.0);
|
---|
| 472 | }
|
---|
| 473 | }
|
---|
| 474 | break;
|
---|
| 475 | case F_CLASS:
|
---|
| 476 | switch (bp[0]) {
|
---|
| 477 | case 'A': case 'B': case 'C': case 'D': case 'F': case 'G':
|
---|
| 478 | case 'H': case 'K': case 'J': case 'L': case 'M': case 'N':
|
---|
| 479 | case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T':
|
---|
| 480 | case 'U': case 'V':
|
---|
| 481 | op->f_class = bp[0];
|
---|
| 482 | break;
|
---|
| 483 | default:
|
---|
| 484 | return (-1);
|
---|
| 485 | }
|
---|
| 486 | break;
|
---|
| 487 | case F_SPECT: {
|
---|
| 488 | int i, j;
|
---|
| 489 | /* fill f_spect all the way */
|
---|
| 490 | for (i = j = 0; i < sizeof(op->f_spect); i++)
|
---|
| 491 | if ((op->f_spect[i] = bp[j]) != 0)
|
---|
| 492 | j++;
|
---|
| 493 | break;
|
---|
| 494 | }
|
---|
| 495 |
|
---|
| 496 | case E_INC:
|
---|
| 497 | op->e_inc = (float) atod (bp);
|
---|
| 498 | break;
|
---|
| 499 | case E_LAN:
|
---|
| 500 | op->e_Om = (float) atod (bp);
|
---|
| 501 | break;
|
---|
| 502 | case E_AOP:
|
---|
| 503 | op->e_om = (float) atod (bp);
|
---|
| 504 | break;
|
---|
| 505 | case E_A:
|
---|
| 506 | op->e_a = (float) atod (bp);
|
---|
| 507 | break;
|
---|
| 508 | case E_N:
|
---|
| 509 | /* retired */
|
---|
| 510 | break;
|
---|
| 511 | case E_E:
|
---|
| 512 | op->e_e = (float) atod (bp);
|
---|
| 513 | break;
|
---|
| 514 | case E_M:
|
---|
| 515 | op->e_M = (float) atod (bp);
|
---|
| 516 | break;
|
---|
| 517 | case E_CEPOCH:
|
---|
| 518 | crack_year (bp, pref, &op->e_cepoch);
|
---|
| 519 | break;
|
---|
| 520 | case E_EPOCH:
|
---|
| 521 | crack_year (bp, pref, &op->e_epoch);
|
---|
| 522 | break;
|
---|
| 523 | case E_M1:
|
---|
| 524 | switch (bp[0]) {
|
---|
| 525 | case 'g':
|
---|
| 526 | op->e_mag.whichm = MAG_gk;
|
---|
| 527 | bp++;
|
---|
| 528 | break;
|
---|
| 529 | case 'H':
|
---|
| 530 | op->e_mag.whichm = MAG_HG;
|
---|
| 531 | bp++;
|
---|
| 532 | break;
|
---|
| 533 | default:
|
---|
| 534 | /* leave type unchanged if no or unrecognized prefix */
|
---|
| 535 | break;
|
---|
| 536 | }
|
---|
| 537 | op->e_mag.m1 = (float) atod(bp);
|
---|
| 538 | break;
|
---|
| 539 | case E_M2:
|
---|
| 540 | switch (bp[0]) {
|
---|
| 541 | case 'k':
|
---|
| 542 | op->e_mag.whichm = MAG_gk;
|
---|
| 543 | bp++;
|
---|
| 544 | break;
|
---|
| 545 | case 'G':
|
---|
| 546 | op->e_mag.whichm = MAG_HG;
|
---|
| 547 | bp++;
|
---|
| 548 | break;
|
---|
| 549 | default:
|
---|
| 550 | /* leave type unchanged if no or unrecognized prefix */
|
---|
| 551 | break;
|
---|
| 552 | }
|
---|
| 553 | op->e_mag.m2 = (float) atod(bp);
|
---|
| 554 | break;
|
---|
| 555 | case E_SIZE:
|
---|
| 556 | op->e_size = (float) atod (bp);
|
---|
| 557 | break;
|
---|
| 558 |
|
---|
| 559 | case H_EP:
|
---|
| 560 | crack_year (bp, pref, &op->h_ep);
|
---|
| 561 | break;
|
---|
| 562 | case H_INC:
|
---|
| 563 | op->h_inc = (float) atod (bp);
|
---|
| 564 | break;
|
---|
| 565 | case H_LAN:
|
---|
| 566 | op->h_Om = (float) atod (bp);
|
---|
| 567 | break;
|
---|
| 568 | case H_AOP:
|
---|
| 569 | op->h_om = (float) atod (bp);
|
---|
| 570 | break;
|
---|
| 571 | case H_E:
|
---|
| 572 | op->h_e = (float) atod (bp);
|
---|
| 573 | break;
|
---|
| 574 | case H_QP:
|
---|
| 575 | op->h_qp = (float) atod (bp);
|
---|
| 576 | break;
|
---|
| 577 | case H_EPOCH:
|
---|
| 578 | crack_year (bp, pref, &op->h_epoch);
|
---|
| 579 | break;
|
---|
| 580 | case H_G:
|
---|
| 581 | op->h_g = (float) atod (bp);
|
---|
| 582 | break;
|
---|
| 583 | case H_K:
|
---|
| 584 | op->h_k = (float) atod (bp);
|
---|
| 585 | break;
|
---|
| 586 | case H_SIZE:
|
---|
| 587 | op->h_size = (float) atod (bp);
|
---|
| 588 | break;
|
---|
| 589 |
|
---|
| 590 | case P_EP:
|
---|
| 591 | crack_year (bp, pref, &op->p_ep);
|
---|
| 592 | break;
|
---|
| 593 | case P_INC:
|
---|
| 594 | op->p_inc = (float) atod (bp);
|
---|
| 595 | break;
|
---|
| 596 | case P_AOP:
|
---|
| 597 | op->p_om = (float) atod (bp);
|
---|
| 598 | break;
|
---|
| 599 | case P_QP:
|
---|
| 600 | op->p_qp = (float) atod (bp);
|
---|
| 601 | break;
|
---|
| 602 | case P_LAN:
|
---|
| 603 | op->p_Om = (float) atod (bp);
|
---|
| 604 | break;
|
---|
| 605 | case P_EPOCH:
|
---|
| 606 | crack_year (bp, pref, &op->p_epoch);
|
---|
| 607 | break;
|
---|
| 608 | case P_G:
|
---|
| 609 | op->p_g = (float) atod (bp);
|
---|
| 610 | break;
|
---|
| 611 | case P_K:
|
---|
| 612 | op->p_k = (float) atod (bp);
|
---|
| 613 | break;
|
---|
| 614 | case P_SIZE:
|
---|
| 615 | op->p_size = (float) atod (bp);
|
---|
| 616 | break;
|
---|
| 617 |
|
---|
| 618 | case ES_EPOCH:
|
---|
| 619 | crack_year (bp, pref, &op->es_epoch);
|
---|
| 620 | break;
|
---|
| 621 | case ES_INC:
|
---|
| 622 | op->es_inc = (float) atod (bp);
|
---|
| 623 | break;
|
---|
| 624 | case ES_RAAN:
|
---|
| 625 | op->es_raan = (float) atod (bp);
|
---|
| 626 | break;
|
---|
| 627 | case ES_E:
|
---|
| 628 | op->es_e = (float) atod (bp);
|
---|
| 629 | break;
|
---|
| 630 | case ES_AP:
|
---|
| 631 | op->es_ap = (float) atod (bp);
|
---|
| 632 | break;
|
---|
| 633 | case ES_M:
|
---|
| 634 | op->es_M = (float) atod (bp);
|
---|
| 635 | break;
|
---|
| 636 | case ES_N:
|
---|
| 637 | op->es_n = atod (bp);
|
---|
| 638 | break;
|
---|
| 639 | case ES_DECAY:
|
---|
| 640 | op->es_decay = (float) atod (bp);
|
---|
| 641 | break;
|
---|
| 642 | case ES_ORBIT:
|
---|
| 643 | op->es_orbit = atoi (bp);
|
---|
| 644 | break;
|
---|
| 645 | case ES_DRAG:
|
---|
| 646 | op->es_drag = (float) atod (bp);
|
---|
| 647 | break;
|
---|
| 648 |
|
---|
| 649 | default:
|
---|
| 650 | printf ("BUG! db_set_field: bad id: %d\n", id);
|
---|
| 651 | exit (1);
|
---|
| 652 | }
|
---|
| 653 |
|
---|
| 654 | return (0);
|
---|
| 655 | }
|
---|
| 656 |
|
---|
| 657 | /* given a null-terminated string, fill in fields[] with the starting addresses
|
---|
| 658 | * of each field delimited by delim or '\0'.
|
---|
| 659 | * N.B. each character matching delim is REPLACED BY '\0' IN PLACE.
|
---|
| 660 | * N.B. 0-length fields count, so even if *s=='\0' we return 1.
|
---|
| 661 | * return the number of fields.
|
---|
| 662 | */
|
---|
| 663 | int
|
---|
| 664 | get_fields (s, delim, fields)
|
---|
| 665 | char *s;
|
---|
| 666 | int delim;
|
---|
| 667 | char *fields[];
|
---|
| 668 | {
|
---|
| 669 | int n;
|
---|
| 670 | char c;
|
---|
| 671 |
|
---|
| 672 | *fields = s;
|
---|
| 673 | n = 0;
|
---|
| 674 | do {
|
---|
| 675 | c = *s++;
|
---|
| 676 | if (c == delim || c == '\0') {
|
---|
| 677 | s[-1] = '\0';
|
---|
| 678 | *++fields = s;
|
---|
| 679 | n++;
|
---|
| 680 | }
|
---|
| 681 | } while (c);
|
---|
| 682 |
|
---|
| 683 | return (n);
|
---|
| 684 | }
|
---|
| 685 |
|
---|
| 686 | /* check name for being a planet.
|
---|
| 687 | * if so, fill in *op and return 0, else return -1.
|
---|
| 688 | */
|
---|
| 689 | int
|
---|
| 690 | db_chk_planet (name, op)
|
---|
| 691 | char name[];
|
---|
| 692 | Obj *op;
|
---|
| 693 | {
|
---|
| 694 | char namecpy[256];
|
---|
| 695 | int i;
|
---|
| 696 |
|
---|
| 697 | /* these must match the order in astro.h */
|
---|
| 698 | static char *planet_names[] = {
|
---|
| 699 | "Mercury", "Venus", "Mars", "Jupiter", "Saturn",
|
---|
| 700 | "Uranus", "Neptune", "Pluto", "Sun", "Moon",
|
---|
| 701 | };
|
---|
| 702 |
|
---|
| 703 | /* make a copy to match our case -- strcasecmp() not entirely portable*/
|
---|
| 704 | strcpy (namecpy, name);
|
---|
| 705 | if (islower(namecpy[0]))
|
---|
| 706 | namecpy[0] = toupper(namecpy[0]);
|
---|
| 707 | for (i = 1; namecpy[i]; i++)
|
---|
| 708 | if (isupper(namecpy[i]))
|
---|
| 709 | namecpy[i] = tolower(namecpy[i]);
|
---|
| 710 |
|
---|
| 711 | for (i = MERCURY; i <= MOON; i++) {
|
---|
| 712 | if (strcmp (namecpy, planet_names[i]) == 0) {
|
---|
| 713 | zero_mem ((void *)op, sizeof(ObjPl));
|
---|
| 714 | op->o_type = PLANET;
|
---|
| 715 | (void) strcpy (op->o_name, planet_names[i]);
|
---|
| 716 | op->pl.pl_code = i;
|
---|
| 717 | return (0);
|
---|
| 718 | }
|
---|
| 719 | }
|
---|
| 720 |
|
---|
| 721 | return (-1);
|
---|
| 722 | }
|
---|
| 723 |
|
---|
| 724 | /* return 0 if buf qualifies as a database line worthy of a cracking
|
---|
| 725 | * attempt, else -1.
|
---|
| 726 | */
|
---|
| 727 | static int
|
---|
| 728 | line_candidate (buf)
|
---|
| 729 | char *buf;
|
---|
| 730 | {
|
---|
| 731 | char c = buf[0];
|
---|
| 732 |
|
---|
| 733 | return (c == '#' || c == '!' || isspace(c) ? -1 : 0);
|
---|
| 734 | }
|
---|
| 735 |
|
---|
| 736 | /* given either a decimal year (xxxx[.xxx]) or a calendar (x/x/x)
|
---|
| 737 | * and a DateFormat preference convert it to an mjd and store it at *p.
|
---|
| 738 | */
|
---|
| 739 | static void
|
---|
| 740 | crack_year (bp, pref, p)
|
---|
| 741 | char *bp;
|
---|
| 742 | PrefDateFormat pref;
|
---|
| 743 | double *p;
|
---|
| 744 | {
|
---|
| 745 | int m, y;
|
---|
| 746 | double d;
|
---|
| 747 |
|
---|
| 748 | mjd_cal (*p, &m, &d, &y); /* init with current */
|
---|
| 749 | f_sscandate (bp, pref, &m, &d, &y);
|
---|
| 750 | cal_mjd (m, d, y, p);
|
---|
| 751 | }
|
---|
| 752 |
|
---|
| 753 | /* given an *op and a field id, add it to the given text buffer bp.
|
---|
| 754 | * return the number of characters added to bp.
|
---|
| 755 | */
|
---|
| 756 | static int
|
---|
| 757 | db_get_field (op, id, bp)
|
---|
| 758 | Obj *op;
|
---|
| 759 | int id;
|
---|
| 760 | char *bp;
|
---|
| 761 | {
|
---|
| 762 | char *bpsave = bp;
|
---|
| 763 | double tmp;
|
---|
| 764 |
|
---|
| 765 | /* include all the enums and in numeric order to give us the best
|
---|
| 766 | * possible chance the compiler will implement this as a jump table.
|
---|
| 767 | */
|
---|
| 768 | switch (id) {
|
---|
| 769 | case F_RA:
|
---|
| 770 | sprintf (bp, ",");
|
---|
| 771 | bp += strlen(bp);
|
---|
| 772 | fs_sexa (bp, radhr(op->f_RA), 2, 36000);
|
---|
| 773 | bp += strlen(bp);
|
---|
| 774 | break;
|
---|
| 775 | case F_DEC:
|
---|
| 776 | sprintf (bp, ",");
|
---|
| 777 | bp += strlen(bp);
|
---|
| 778 | fs_sexa (bp, raddeg(op->f_dec), 3, 3600);
|
---|
| 779 | bp += strlen(bp);
|
---|
| 780 | break;
|
---|
| 781 | case F_EPOCH:
|
---|
| 782 | mjd_year (op->f_epoch, &tmp);
|
---|
| 783 | sprintf (bp, ",%.6g", tmp); /* %.7g gives 2000.001 */
|
---|
| 784 | bp += strlen(bp);
|
---|
| 785 | break;
|
---|
| 786 | case F_MAG:
|
---|
| 787 | sprintf (bp, ",%6.2f", get_mag(op));
|
---|
| 788 | bp += strlen(bp);
|
---|
| 789 | break;
|
---|
| 790 | case F_SIZE:
|
---|
| 791 | sprintf (bp, ",%.7g", op->f_size);
|
---|
| 792 | bp += strlen(bp);
|
---|
| 793 | if (op->f_ratio || op->f_pa) {
|
---|
| 794 | sprintf (bp,"|%g|%g", op->f_size*get_ratio(op),
|
---|
| 795 | raddeg(get_pa(op)));
|
---|
| 796 | bp += strlen(bp);
|
---|
| 797 | }
|
---|
| 798 | break;
|
---|
| 799 | case F_CLASS:
|
---|
| 800 | if (op->f_class) {
|
---|
| 801 | sprintf (bp, "|%c", op->f_class);
|
---|
| 802 | bp += strlen(bp);
|
---|
| 803 | }
|
---|
| 804 | break;
|
---|
| 805 | case F_SPECT:
|
---|
| 806 | if (op->f_spect[0] != '\0') {
|
---|
| 807 | sprintf (bp, "|%c", op->f_spect[0]);
|
---|
| 808 | bp += strlen(bp);
|
---|
| 809 | if (op->f_spect[1] != '\0') {
|
---|
| 810 | sprintf (bp, "%c", op->f_spect[1]);
|
---|
| 811 | bp += strlen(bp);
|
---|
| 812 | }
|
---|
| 813 | }
|
---|
| 814 | break;
|
---|
| 815 |
|
---|
| 816 | case E_INC:
|
---|
| 817 | sprintf (bp, ",%.7g", op->e_inc);
|
---|
| 818 | bp += strlen(bp);
|
---|
| 819 | break;
|
---|
| 820 | case E_LAN:
|
---|
| 821 | sprintf (bp, ",%.7g", op->e_Om);
|
---|
| 822 | bp += strlen(bp);
|
---|
| 823 | break;
|
---|
| 824 | case E_AOP:
|
---|
| 825 | sprintf (bp, ",%.7g", op->e_om);
|
---|
| 826 | bp += strlen(bp);
|
---|
| 827 | break;
|
---|
| 828 | case E_A:
|
---|
| 829 | sprintf (bp, ",%.7g", op->e_a);
|
---|
| 830 | bp += strlen(bp);
|
---|
| 831 | break;
|
---|
| 832 | case E_N:
|
---|
| 833 | /* retired */
|
---|
| 834 | sprintf (bp, ",");
|
---|
| 835 | bp += strlen(bp);
|
---|
| 836 | break;
|
---|
| 837 | case E_E:
|
---|
| 838 | sprintf (bp, ",%.7g", op->e_e);
|
---|
| 839 | bp += strlen(bp);
|
---|
| 840 | break;
|
---|
| 841 | case E_M:
|
---|
| 842 | sprintf (bp, ",%.7g", op->e_M);
|
---|
| 843 | bp += strlen(bp);
|
---|
| 844 | break;
|
---|
| 845 | case E_CEPOCH:
|
---|
| 846 | sprintf (bp, ",");
|
---|
| 847 | bp += strlen(bp);
|
---|
| 848 | fs_date (bp, op->e_cepoch);
|
---|
| 849 | bp += strlen(bp);
|
---|
| 850 | break;
|
---|
| 851 | case E_EPOCH:
|
---|
| 852 | sprintf (bp, ",");
|
---|
| 853 | bp += strlen(bp);
|
---|
| 854 | fs_date (bp, op->e_epoch);
|
---|
| 855 | bp += strlen(bp);
|
---|
| 856 | break;
|
---|
| 857 | case E_M1:
|
---|
| 858 | if (op->e_mag.whichm == MAG_gk) {
|
---|
| 859 | sprintf (bp, ",g%.7g", op->e_mag.m1);
|
---|
| 860 | bp += strlen(bp);
|
---|
| 861 | } else if (op->e_mag.whichm == MAG_HG) {
|
---|
| 862 | sprintf (bp, ",H%.7g", op->e_mag.m1);
|
---|
| 863 | bp += strlen(bp);
|
---|
| 864 | } else {
|
---|
| 865 | sprintf (bp, ",%.7g", op->e_mag.m1);
|
---|
| 866 | bp += strlen(bp);
|
---|
| 867 | }
|
---|
| 868 | break;
|
---|
| 869 | case E_M2:
|
---|
| 870 | sprintf (bp, ",%.7g", op->e_mag.m2);
|
---|
| 871 | bp += strlen(bp);
|
---|
| 872 | break;
|
---|
| 873 | case E_SIZE:
|
---|
| 874 | sprintf (bp, ",%.7g", op->e_size);
|
---|
| 875 | bp += strlen(bp);
|
---|
| 876 | break;
|
---|
| 877 |
|
---|
| 878 | case H_EP:
|
---|
| 879 | sprintf (bp, ",");
|
---|
| 880 | bp += strlen(bp);
|
---|
| 881 | fs_date (bp, op->h_ep);
|
---|
| 882 | bp += strlen(bp);
|
---|
| 883 | break;
|
---|
| 884 | case H_INC:
|
---|
| 885 | sprintf (bp, ",%.7g", op->h_inc);
|
---|
| 886 | bp += strlen(bp);
|
---|
| 887 | break;
|
---|
| 888 | case H_LAN:
|
---|
| 889 | sprintf (bp, ",%.7g", op->h_Om);
|
---|
| 890 | bp += strlen(bp);
|
---|
| 891 | break;
|
---|
| 892 | case H_AOP:
|
---|
| 893 | sprintf (bp, ",%.7g", op->h_om);
|
---|
| 894 | bp += strlen(bp);
|
---|
| 895 | break;
|
---|
| 896 | case H_E:
|
---|
| 897 | sprintf (bp, ",%.7g", op->h_e);
|
---|
| 898 | bp += strlen(bp);
|
---|
| 899 | break;
|
---|
| 900 | case H_QP:
|
---|
| 901 | sprintf (bp, ",%.7g", op->h_qp);
|
---|
| 902 | bp += strlen(bp);
|
---|
| 903 | break;
|
---|
| 904 | case H_EPOCH:
|
---|
| 905 | sprintf (bp, ",");
|
---|
| 906 | bp += strlen(bp);
|
---|
| 907 | fs_date (bp, op->h_epoch);
|
---|
| 908 | bp += strlen(bp);
|
---|
| 909 | break;
|
---|
| 910 | case H_G:
|
---|
| 911 | sprintf (bp, ",%.7g", op->h_g);
|
---|
| 912 | bp += strlen(bp);
|
---|
| 913 | break;
|
---|
| 914 | case H_K:
|
---|
| 915 | sprintf (bp, ",%.7g", op->h_k);
|
---|
| 916 | bp += strlen(bp);
|
---|
| 917 | break;
|
---|
| 918 | case H_SIZE:
|
---|
| 919 | sprintf (bp, ",%.7g", op->h_size);
|
---|
| 920 | bp += strlen(bp);
|
---|
| 921 | break;
|
---|
| 922 |
|
---|
| 923 | case P_EP:
|
---|
| 924 | sprintf (bp, ",");
|
---|
| 925 | bp += strlen(bp);
|
---|
| 926 | fs_date (bp, op->p_ep);
|
---|
| 927 | bp += strlen(bp);
|
---|
| 928 | break;
|
---|
| 929 | case P_INC:
|
---|
| 930 | sprintf (bp, ",%.7g", op->p_inc);
|
---|
| 931 | bp += strlen(bp);
|
---|
| 932 | break;
|
---|
| 933 | case P_AOP:
|
---|
| 934 | sprintf (bp, ",%.7g", op->p_om);
|
---|
| 935 | bp += strlen(bp);
|
---|
| 936 | break;
|
---|
| 937 | case P_QP:
|
---|
| 938 | sprintf (bp, ",%.7g", op->p_qp);
|
---|
| 939 | bp += strlen(bp);
|
---|
| 940 | break;
|
---|
| 941 | case P_LAN:
|
---|
| 942 | sprintf (bp, ",%.7g", op->p_Om);
|
---|
| 943 | bp += strlen(bp);
|
---|
| 944 | break;
|
---|
| 945 | case P_EPOCH:
|
---|
| 946 | sprintf (bp, ",");
|
---|
| 947 | bp += strlen(bp);
|
---|
| 948 | fs_date (bp, op->p_epoch);
|
---|
| 949 | bp += strlen(bp);
|
---|
| 950 | break;
|
---|
| 951 | case P_G:
|
---|
| 952 | sprintf (bp, ",%.7g", op->p_g);
|
---|
| 953 | bp += strlen(bp);
|
---|
| 954 | break;
|
---|
| 955 | case P_K:
|
---|
| 956 | sprintf (bp, ",%.7g", op->p_k);
|
---|
| 957 | bp += strlen(bp);
|
---|
| 958 | break;
|
---|
| 959 | case P_SIZE:
|
---|
| 960 | sprintf (bp, ",%.7g", op->p_size);
|
---|
| 961 | bp += strlen(bp);
|
---|
| 962 | break;
|
---|
| 963 |
|
---|
| 964 | case ES_EPOCH:
|
---|
| 965 | sprintf (bp, ",");
|
---|
| 966 | bp += strlen(bp);
|
---|
| 967 | fs_date (bp, op->es_epoch);
|
---|
| 968 | bp += strlen(bp);
|
---|
| 969 | break;
|
---|
| 970 | case ES_INC:
|
---|
| 971 | sprintf (bp, ",%.7g", op->es_inc);
|
---|
| 972 | bp += strlen(bp);
|
---|
| 973 | break;
|
---|
| 974 | case ES_RAAN:
|
---|
| 975 | sprintf (bp, ",%.7g", op->es_raan);
|
---|
| 976 | bp += strlen(bp);
|
---|
| 977 | break;
|
---|
| 978 | case ES_E:
|
---|
| 979 | sprintf (bp, ",%.7g", op->es_e);
|
---|
| 980 | bp += strlen(bp);
|
---|
| 981 | break;
|
---|
| 982 | case ES_AP:
|
---|
| 983 | sprintf (bp, ",%.7g", op->es_ap);
|
---|
| 984 | bp += strlen(bp);
|
---|
| 985 | break;
|
---|
| 986 | case ES_M:
|
---|
| 987 | sprintf (bp, ",%.7g", op->es_M);
|
---|
| 988 | bp += strlen(bp);
|
---|
| 989 | break;
|
---|
| 990 | case ES_N:
|
---|
| 991 | sprintf (bp, ",%.7g", op->es_n);
|
---|
| 992 | bp += strlen(bp);
|
---|
| 993 | break;
|
---|
| 994 | case ES_DECAY:
|
---|
| 995 | sprintf (bp, ",%.7g", op->es_decay);
|
---|
| 996 | bp += strlen(bp);
|
---|
| 997 | break;
|
---|
| 998 | case ES_ORBIT:
|
---|
| 999 | sprintf (bp, ",%d", op->es_orbit);
|
---|
| 1000 | bp += strlen(bp);
|
---|
| 1001 | break;
|
---|
| 1002 | case ES_DRAG:
|
---|
| 1003 | sprintf (bp, ",%.7g", op->es_drag);
|
---|
| 1004 | bp += strlen(bp);
|
---|
| 1005 | break;
|
---|
| 1006 |
|
---|
| 1007 | default:
|
---|
| 1008 | printf ("BUG! db_set_field: bad id: %d\n", id);
|
---|
| 1009 | exit (1);
|
---|
| 1010 | }
|
---|
| 1011 |
|
---|
| 1012 | return (bp - bpsave);
|
---|
| 1013 | }
|
---|
| 1014 |
|
---|
| 1015 | /* For RCS Only -- Do Not Edit */
|
---|
| 1016 | static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: dbfmt.c,v $ $Date: 2001-04-10 14:40:46 $ $Revision: 1.1.1.1 $ $Name: not supported by cvs2svn $"};
|
---|