home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / star.lzh / star.13 < prev    next >
Encoding:
Text File  |  1990-03-27  |  48.1 KB  |  1,636 lines

  1. #! /bin/sh
  2. # This is a shell archive.  Remove anything before this line, then unpack
  3. # it by saving it into a file and typing "sh file".  To overwrite existing
  4. # files, type "sh file -c".  You can also feed this as standard input via
  5. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  6. # will see the following message at the end:
  7. #        "End of archive 13 (of 32)."
  8. # Contents:  observe/outsat.c starchart/readfile.c
  9. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  10. if test -f 'observe/outsat.c' -a "${1}" != "-c" ; then 
  11.   echo shar: Will not clobber existing file \"'observe/outsat.c'\"
  12. else
  13. echo shar: Extracting \"'observe/outsat.c'\" \(23472 characters\)
  14. sed "s/^X//" >'observe/outsat.c' <<'END_OF_FILE'
  15. X/*
  16. X * outsat.c
  17. X * Output satellite, PostScript file for satellites
  18. X *
  19. X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
  20. X *
  21. X * This software may be redistributed freely, not sold.
  22. X * This copyright notice and disclaimer of warranty must remain
  23. X *    unchanged. 
  24. X *
  25. X * No representation is made about the suitability of this
  26. X * software for any purpose.  It is provided "as is" without express or
  27. X * implied warranty, to the extent permitted by applicable law.
  28. X *
  29. X */
  30. X
  31. X#ifndef  lint
  32. Xstatic char rcsid[] =
  33. X  "$Header: outsat.c,v 1.7 90/02/25 16:38:03 ccount Exp $";
  34. X#endif
  35. X
  36. X
  37. X#include <stdio.h>
  38. X#include "observe.h"
  39. X#include "date.h"
  40. X
  41. X#ifndef FALSE
  42. X#define FALSE 0
  43. X#endif
  44. X#ifndef TRUE
  45. X#define TRUE 1
  46. X#endif
  47. X
  48. Xvoid outjs(), outjs_PS();
  49. Xvoid jupsat(), satsat();
  50. X
  51. X/* Output satellite, .PS file for satellites */
  52. Xvoid out_sat(o_sat, o_sat_PS, one_day, invert_sats, jd, moon_data, planets)
  53. X     FILE *o_sat, *o_sat_PS;
  54. X     int one_day, invert_sats;
  55. X     double jd;
  56. X     moon_data_t moon_data;
  57. X     planet_data_t planets[];
  58. X{
  59. X  sat_t jovesats[4], saturnsats[8];
  60. X  static int last_jd = 0;
  61. X  static int doing_saturn = FALSE;
  62. X
  63. X  jupsat(jd, planets[3], jovesats);
  64. X  satsat(jd, planets[4], saturnsats);
  65. X
  66. X
  67. X  if (jd < last_jd) {
  68. X    doing_saturn = TRUE;
  69. X  };
  70. X  last_jd = jd;
  71. X  if (!doing_saturn)
  72. X    outjs(o_sat, one_day, jd, jovesats, saturnsats, planets);
  73. X  outjs_PS(o_sat_PS, one_day, invert_sats, jd,
  74. X       jovesats, saturnsats, moon_data, planets);
  75. X}
  76. X
  77. X
  78. Xvoid outjs(outf, one_day, jd, jovesats, saturnsats)
  79. X     FILE *outf;
  80. X     int one_day;
  81. X     double jd;
  82. X     sat_t jovesats[], saturnsats[];
  83. X{
  84. X  int i;
  85. X  char datestr[15];
  86. X
  87. X
  88. X  jd_to_str(jd, datestr);
  89. X  fprintf(outf, "%s\n", datestr);
  90. X
  91. X  fprintf(outf,
  92. X  "Relative position in planet radii, +x west +y north, RA seconds east\n");
  93. X  fprintf(outf,
  94. X"Satellite     Relative position: x  y  z      R.A.      Dec.       mag\n");
  95. X  for (i = 0; i < 4; i++)
  96. X    fprintf(outf, "%-10.10s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
  97. X        jovesats[i].name, jovesats[i].dx, jovesats[i].dy, jovesats[i].dz,
  98. X        jovesats[i].dalpha/15.0, jovesats[i].ddelta,
  99. X        jovesats[i].mag);
  100. X  fprintf(outf, "\n");
  101. X  for (i = 0; i < 8; i++)
  102. X    fprintf(outf, "%-10.10s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
  103. X        saturnsats[i].name, saturnsats[i].dx, saturnsats[i].dy,
  104. X        saturnsats[i].dz,
  105. X        saturnsats[i].dalpha/15.0, saturnsats[i].ddelta,
  106. X        saturnsats[i].mag);
  107. X
  108. X
  109. X  if (!one_day) fprintf(outf, "\f\n");
  110. X}
  111. X
  112. X#define CenterLine 288
  113. X#define DateY 720
  114. X#define JupY 580
  115. X#define SatY 396
  116. X#define JupOneRad 6
  117. X#define SatOneRad 3
  118. X#define JOrderOff 36
  119. X#define SOrderOff 144
  120. X
  121. X#define JupManyRad 4.5
  122. X#define SatManyRad 2.25
  123. X#define JupColumn 144
  124. X#define SatColumn 144
  125. X#define OrderOffset 72
  126. X#define DateOffset 192
  127. X
  128. X#define Fontname "/Times-Roman"
  129. X#define Bigsize 10
  130. X#define JSFontname "/Times-Roman"
  131. X#define JSmlsz 10
  132. X#define SSFontname "/Times-Roman"
  133. X#define SSmlsz 8
  134. X
  135. Xint n_called = 0;
  136. X
  137. X/* output postscript picture of jupiter and saturn */
  138. Xvoid outjs_PS(outf, one_day, invert_sats, jd,
  139. X          jovesats, saturnsats, moon_data, planets)
  140. X     FILE *outf;
  141. X     int one_day, invert_sats;
  142. X     double jd;
  143. X     sat_t jovesats[], saturnsats[];
  144. X     moon_data_t moon_data;
  145. X     planet_data_t planets[];
  146. X{
  147. X  int i, j;
  148. X  static int printed_header = FALSE;
  149. X  static int top = 720;
  150. X  static int last_jd = 0;
  151. X  static int doing_saturn = FALSE;
  152. X  char datestr[15];
  153. X  int zindex[9];
  154. X  double z[9];
  155. X  int yindex[9];
  156. X  double y[9];
  157. X  int xindex[9];
  158. X  double x[9];
  159. X  double beta_e_saturn;
  160. X  int psx, psy;
  161. X
  162. X  jd_to_str(jd, datestr);
  163. X
  164. X  n_called++;
  165. X
  166. X  beta_e_saturn = planets[4].rotation_elements.beta_e;
  167. X
  168. X  /* Start postscript */
  169. X  if (!printed_header) {
  170. X    fprintf(outf, "%%!\n");
  171. X    fprintf(outf, "%%Remove this header and the later footer\n");
  172. X    fprintf(outf,
  173. X     "%%    if you are adding the code to a starchart postscript file.\n");
  174. X    fprintf(outf,
  175. X"%%Place the function definitions after the chart header in that file.\n");
  176. X    if (!one_day) {
  177. X      fprintf(outf, "%%This file was produced for a multiple day display,\n");
  178. X      fprintf(outf,
  179. X"%% and is not suitable for use within a starpost output file.\n");
  180. X      fprintf(outf,
  181. X"%% Prepare charts for individual days\n");
  182. X    };
  183. X    fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
  184. X    fprintf(outf, "\n");
  185. X    fprintf(outf, "1 setlinewidth 2 setlinecap\n");
  186. X    fprintf(outf, "[] 0 setdash 0 setgray\n");
  187. X    fprintf(outf, "/s {newpath 0 360 arc closepath fill} def\n");
  188. X    fprintf(outf, "/s0 {8 s} def\n");
  189. X    fprintf(outf, "/s1 {7 s} def\n");
  190. X    fprintf(outf, "/s2 {6 s} def\n");
  191. X    fprintf(outf, "/s3 {5 s} def\n");
  192. X    fprintf(outf, "/s4 {4 s} def\n");
  193. X    fprintf(outf, "/s5 {3.25 s} def\n");
  194. X    fprintf(outf, "/s6 {2.5 s} def\n");
  195. X    fprintf(outf, "/s7 {2.0 s} def\n");
  196. X    fprintf(outf, "/s8 {1.5 s} def\n");
  197. X    fprintf(outf, "/s9 {1.0 s} def\n");
  198. X    fprintf(outf, "/s10 {0.5 s} def\n");
  199. X    fprintf(outf, "%%\n%%\n%%\n%%End of header\n%%\n%%\n");
  200. X    fprintf(outf, "%%\n%%\n%%\n%%Begin definitions\n%%\n%%\n");
  201. X    fprintf(outf,
  202. X"/centershow { dup stringwidth pop 2 div neg 0 rmoveto show } def\n");
  203. X    fprintf(outf,
  204. X"/atshow10pt { dup stringwidth pop 2 div neg 3.5 neg rmoveto show } def\n");
  205. X
  206. X
  207. X    fprintf(outf,
  208. X "/array-centershow { /str-arr exch def /widthskip exch def\n");
  209. X    fprintf(outf, "  str-arr length widthskip mul 2 div neg 0 rmoveto\n");
  210. X    fprintf(outf, "  str-arr {\n");
  211. X    fprintf(outf, "    gsave show grestore\n");
  212. X    fprintf(outf, "    widthskip 0 rmoveto\n");
  213. X    fprintf(outf, "  } forall\n");
  214. X    fprintf(outf, "} def\n");
  215. X    fprintf(outf, "/array-vertshow { /str-arr exch def /lineskip exch def\n");
  216. X    fprintf(outf, "  0 str-arr length lineskip mul 2 div neg rmoveto\n");
  217. X    fprintf(outf, "  str-arr {\n");
  218. X    fprintf(outf, "    gsave\n");
  219. X    fprintf(outf, "      dup stringwidth pop 2 div neg 0 rmoveto show\n");
  220. X    fprintf(outf, "    grestore\n");
  221. X    fprintf(outf, "    0 lineskip rmoveto\n");
  222. X    fprintf(outf, "  } forall\n");
  223. X    fprintf(outf, "} def\n");
  224. X
  225. X    fprintf(outf, "/Textx 2 def\n");
  226. X    fprintf(outf, "/Texty 2 def\n");
  227. X
  228. X
  229. X    fprintf(outf, "%% x y r phase p_n beta_e chi\n");
  230. X    fprintf(outf, "/planet-with-phase {\n");
  231. X    fprintf(outf, "  /chi exch def /beta_e exch def /p_n exch def\n");
  232. X    fprintf(outf, "  /phase exch def\n");
  233. X    fprintf(outf, "  /r exch def /y exch def /x exch def gsave\n");
  234. X    fprintf(outf, "    0 setgray .01 setlinewidth\n");
  235. X    fprintf(outf, "    x y translate r r scale\n");
  236. X    if (invert_sats) {
  237. X      if (one_day)
  238. X    fprintf(outf, "    1 -1 scale\n");
  239. X      else
  240. X    fprintf(outf, "    -1 1 scale\n");
  241. X      };
  242. X    fprintf(outf, "    gsave p_n rotate\n");
  243. X    fprintf(outf, "      1 setgray\n");
  244. X    fprintf(outf, "      0 0 1.05 0 360 arc fill\n");
  245. X    fprintf(outf, "      0 setgray\n");
  246. X    fprintf(outf, "      0 0 1 0 360 arc stroke\n");
  247. X    fprintf(outf, "      gsave\n");
  248. X    fprintf(outf, "        1 beta_e cos scale\n");
  249. X    fprintf(outf, "        0 1 moveto 0 1.25 lineto stroke\n");
  250. X    fprintf(outf, "      grestore\n");
  251. X    fprintf(outf, "      gsave\n");
  252. X    fprintf(outf, "        1 beta_e sin scale\n");
  253. X    fprintf(outf, "        0 0 1 180 360 arc stroke\n");
  254. X    fprintf(outf, "      grestore\n");
  255. X    fprintf(outf, "    grestore %% restore p_n rotation\n");
  256. X    fprintf(outf, "    gsave\n");
  257. X    fprintf(outf, "      chi rotate\n");
  258. X    fprintf(outf, "      newpath\n");
  259. X    fprintf(outf, "      0 0 1 0 180 arcn\n");
  260. X    fprintf(outf, "      1 phase cos scale\n");
  261. X    fprintf(outf, "      0 0 1 180 360 arc fill\n");
  262. X    fprintf(outf, "    grestore\n");
  263. X    fprintf(outf, "  grestore\n} def\n");
  264. X
  265. X  /* Saturn with rings, no satellites, with north pole and equator */
  266. X    fprintf(outf, "/saturn-with-phase  {\n");
  267. X    fprintf(outf, "  /chi exch def /beta_e exch def /p_n exch def\n");
  268. X    fprintf(outf, "  /phase exch def\n");
  269. X    fprintf(outf, "  /r exch def /y exch def /x exch def gsave\n");
  270. X    fprintf(outf, "    0 setgray .01 setlinewidth\n");
  271. X    fprintf(outf, "    x y translate r r scale\n");
  272. X    if (invert_sats) {
  273. X      if (one_day)
  274. X    fprintf(outf, "    1 -1 scale\n");
  275. X      else
  276. X    fprintf(outf, "    -1 1 scale\n");
  277. X      };
  278. X    fprintf(outf, "    gsave p_n rotate\n");
  279. X    fprintf(outf, "      gsave 1 beta_e sin scale newpath\n"); /* back ring */
  280. X    fprintf(outf, "        0 0 1.51 0 180 arc stroke\n");
  281. X    fprintf(outf, "        0 0 1.94 0 180 arc stroke\n");
  282. X    fprintf(outf, "        0 0 2.00 0 180 arc stroke\n");
  283. X    fprintf(outf, "        0 0 2.27 0 180 arc stroke\n");
  284. X    fprintf(outf, "      grestore\n");
  285. X    fprintf(outf, "      1 setgray\n");
  286. X    fprintf(outf, "      0 0 1.05 0 360 arc fill\n");
  287. X    fprintf(outf, "      0 setgray\n");
  288. X    fprintf(outf, "      0 0 1 0 360 arc stroke\n");
  289. X    fprintf(outf, "      gsave\n");
  290. X    fprintf(outf, "        1 beta_e cos scale\n");
  291. X    fprintf(outf, "        0 1 moveto 0 1.25 lineto stroke\n");
  292. X    fprintf(outf, "      grestore\n");
  293. X    fprintf(outf, "      gsave\n");
  294. X    fprintf(outf, "        1 beta_e sin scale\n");
  295. X    fprintf(outf, "        0 0 1 180 360 arc stroke\n");
  296. X    fprintf(outf, "      grestore\n");
  297. X    fprintf(outf, "    grestore %% restore p_n rotation\n");
  298. X    fprintf(outf, "    gsave\n");
  299. X    fprintf(outf, "      chi rotate\n");
  300. X    fprintf(outf, "      newpath\n");
  301. X    fprintf(outf, "      0 0 1 0 180 arcn\n");
  302. X    fprintf(outf, "      1 phase cos scale\n");
  303. X    fprintf(outf, "      0 0 1 180 360 arc fill\n");
  304. X    fprintf(outf, "    grestore\n");
  305. X    fprintf(outf, "    gsave p_n rotate\n");
  306. X    fprintf(outf, "      gsave 1 beta_e sin scale newpath\n"); /* front ring */
  307. X    fprintf(outf, "        0 0 1.51 180 360 arc stroke\n");
  308. X    fprintf(outf, "        0 0 1.94 180 360 arc stroke\n");
  309. X    fprintf(outf, "        0 0 2.00 180 360 arc stroke\n");
  310. X    fprintf(outf, "        0 0 2.27 180 360 arc stroke\n");
  311. X    fprintf(outf, "      grestore\n");
  312. X    fprintf(outf, "    grestore\n");
  313. X    fprintf(outf, "  grestore\n} def\n");
  314. X
  315. X
  316. X    fprintf(outf, "/Luna-with-phase {\n");
  317. X    fprintf(outf, "  /chi exch def\n");
  318. X    fprintf(outf, "  /phase exch def\n");
  319. X    fprintf(outf, "  /r exch def /y exch def /x exch def gsave\n");
  320. X    fprintf(outf, "    0 setgray .01 setlinewidth\n");
  321. X    fprintf(outf, "    x y translate r r scale\n");
  322. X    if (invert_sats) {
  323. X      if (one_day)
  324. X    fprintf(outf, "    1 -1 scale\n");
  325. X      else
  326. X    fprintf(outf, "    -1 1 scale\n");
  327. X      };
  328. X    fprintf(outf, "    1 setgray\n");
  329. X    fprintf(outf, "    0 0 1.05 0 360 arc fill\n");
  330. X    fprintf(outf, "    0 setgray\n");
  331. X    fprintf(outf, "    0 0 1 0 360 arc stroke\n");
  332. X    fprintf(outf, "    gsave\n");
  333. X    fprintf(outf, "      chi rotate\n");
  334. X    fprintf(outf, "      newpath\n");
  335. X    fprintf(outf, "      0 0 1 0 180 arcn\n");
  336. X    fprintf(outf, "      1 phase cos scale\n");
  337. X    fprintf(outf, "      0 0 1 180 360 arc fill\n");
  338. X    fprintf(outf, "    grestore\n");
  339. X    fprintf(outf, "  grestore\n} def\n");
  340. X
  341. X
  342. X    /* Define satellites */
  343. X    for (i = 0; i < 4; i++) {
  344. X/*
  345. X      if (one_day) {
  346. X    fprintf(outf, "/%s {2 copy s%d\n", jovesats[i].name,
  347. X        (int) (jovesats[i].mag+0.5));
  348. X    fprintf(outf,
  349. X        "     Texty add exch Textx add exch moveto (%c%c) show\n",
  350. X        jovesats[i].name[0], jovesats[i].name[1]);
  351. X      } else {
  352. X    fprintf(outf, "/%s {s%d\n", jovesats[i].name,
  353. X        (int) (jovesats[i].mag+0.5));
  354. X      };
  355. X*/
  356. X      fprintf(outf, "/%s {s%d\n", jovesats[i].name,
  357. X          (int) (jovesats[i].mag+0.5));
  358. X      fprintf(outf, "     } def\n");
  359. X    };
  360. X
  361. X    fprintf(outf,
  362. X"%% Saturn satellites are shown 4 magnitudes brighter then they are\n");
  363. X    for (i = 0; i < 8; i++) {
  364. X      j = saturnsats[i].mag - 4 +0.5;
  365. X      if (j > 10) j = 10;
  366. X      fprintf(outf, "/%s {s%d\n", saturnsats[i].name, j);
  367. X      fprintf(outf, "     } def\n");
  368. X    };
  369. X
  370. X    /* Define Jupiter and saturn without satellites */
  371. X    fprintf(outf, "\n");
  372. X    fprintf(outf, "/Jupiter-body {3 copy newpath 0 360 arc 1 setgray fill\n");
  373. X    fprintf(outf, "    0 360 arc 0 setgray stroke} def\n");
  374. X
  375. X
  376. X    fprintf(outf,
  377. X      "/back-ring {/beta exch def /r exch def /y exch def /x exch def\n");
  378. X    fprintf(outf, "    newpath gsave x y translate 1 beta sin scale\n");
  379. X    fprintf(outf, "    0 0 r 1.51 mul 0 180 arc stroke\n");
  380. X    fprintf(outf, "    0 0 r 2.27 mul 0 180 arc stroke\n");
  381. X    fprintf(outf, "    grestore} def\n");
  382. X    fprintf(outf,
  383. X      "/front-ring {/beta exch def /r exch def /y exch def /x exch def\n");
  384. X    fprintf(outf, "    newpath gsave x y translate 1 beta sin scale\n");
  385. X    fprintf(outf, "    0 0 r 1.51 mul 180 360 arc stroke\n");
  386. X    fprintf(outf, "    0 0 r 2.27 mul 180 360 arc stroke\n");
  387. X    fprintf(outf, "    grestore} def\n");
  388. X    fprintf(outf, "\n");
  389. X    fprintf(outf, "/Saturn-body {/r exch def /y exch def /x exch def\n");
  390. X    fprintf(outf, "    /beta %f def\n", beta_e_saturn);
  391. X    fprintf(outf, "    x y r beta back-ring\n");
  392. X    fprintf(outf, "    x y r 0 360 arc 1 setgray fill\n");
  393. X    fprintf(outf, "    x y r 0 360 arc 0 setgray stroke\n");
  394. X    fprintf(outf, "    x y r beta front-ring\n");
  395. X    fprintf(outf, "} def\n");
  396. X
  397. X
  398. X    fprintf(outf, "\n");
  399. X    fprintf(outf, "\n");
  400. X
  401. X    printed_header = TRUE;
  402. X  };
  403. X
  404. X
  405. X
  406. X  /* Define Jupiter and saturn with satellites */
  407. X  /* Jupiter */
  408. X  /* Find drawing order */
  409. X  for (i = 0; i < 4; i++)
  410. X    z[i] = jovesats[i].dz;
  411. X  z[4] = 0.0;            /* Jupiter's body */
  412. X  HeapSort0(z, zindex, 5);
  413. X
  414. X  fprintf(outf, "/Jupiter ");
  415. X  fprintf(outf, " { /r exch def gsave translate\n");
  416. X  if (invert_sats) {
  417. X    if (one_day)
  418. X      fprintf(outf, "    1 -1 scale\n");
  419. X    else
  420. X      fprintf(outf, "    -1 1 scale\n");
  421. X  };
  422. X  fprintf(outf, "    %f rotate\n",
  423. X      planets[3].rotation_elements.p_n);
  424. X  for (i = 0; i < 5; i++) {
  425. X    if (zindex[i] < 4) {
  426. X      fprintf(outf, "    r %f mul r %f mul %s\n",
  427. X          jovesats[zindex[i]].dx,
  428. X          jovesats[zindex[i]].dy, jovesats[zindex[i]].name);
  429. X    } else {
  430. X      fprintf(outf, "    0 0 r Jupiter-body\n");
  431. X    };
  432. X  };
  433. X  fprintf(outf, "grestore } def\n");
  434. X  /* Define order string */
  435. X  for (i = 0; i < 4; i++)
  436. X    x[i] = -jovesats[i].dalpha;
  437. X
  438. X  if (invert_sats)
  439. X    if (!one_day)
  440. X      for (i = 0; i < 4; i++)
  441. X    x[i] = jovesats[i].dalpha;
  442. X      
  443. X  x[4] = 0.0;            /* Jupiter's body */
  444. X  HeapSort0(x, xindex, 5);
  445. X  for (i = 0; i < 5; i++)
  446. X    if (xindex[i] == 4) j = i;
  447. X
  448. X  fprintf(outf, "/Jup-order-array [");
  449. X  for (i = 0; i < (4 - 2*j); i++) fprintf(outf, " (  )");
  450. X  for (i = 0; i < 5; i++) {
  451. X    if (xindex[i] < 4) {
  452. X      fprintf(outf, " (%c%c)",
  453. X          jovesats[xindex[i]].name[0], jovesats[xindex[i]].name[1]);
  454. X    } else {
  455. X      fprintf(outf, " (J)");
  456. X    }
  457. X  };
  458. X  for (i = 0; i < (2*(j-2)); i++) fprintf(outf, " (  )");
  459. X  fprintf(outf, "] def\n\n");
  460. X  fprintf(outf, "\n");
  461. X
  462. X  /* Saturn */
  463. X  /* Find drawing order */
  464. X  for (i = 0; i < 8; i++)
  465. X    z[i] = saturnsats[i].dz;
  466. X  z[8] = 0.0;            /* Saturn's body */
  467. X  HeapSort0(z, zindex, 9);
  468. X
  469. X  fprintf(outf, "/Saturn ");
  470. X  fprintf(outf, " { /r exch def gsave translate\n");
  471. X  if (invert_sats) {
  472. X    if (one_day)
  473. X      fprintf(outf, "    1 -1 scale\n");
  474. X    else
  475. X      fprintf(outf, "    -1 1 scale\n");
  476. X  };
  477. X  fprintf(outf, "    %f rotate\n",
  478. X      planets[4].rotation_elements.p_n);
  479. X  for (i = 0; i < 9; i++) {
  480. X    if (zindex[i] < 8) {
  481. X      fprintf(outf, "    r %f mul r %f mul %s\n",
  482. X          saturnsats[zindex[i]].dx,
  483. X          saturnsats[zindex[i]].dy, saturnsats[zindex[i]].name);
  484. X    } else {
  485. X      fprintf(outf, "    0 0 r Saturn-body\n");
  486. X    };
  487. X  };
  488. X  fprintf(outf, "grestore } def\n");
  489. X
  490. X  /* Define order string */
  491. X  for (i = 0; i < 8; i++)
  492. X    x[i] = -saturnsats[i].dalpha;
  493. X
  494. X  if (invert_sats)
  495. X    if (!one_day)
  496. X      for (i = 0; i < 8; i++)
  497. X    x[i] = saturnsats[i].dalpha;
  498. X      
  499. X  x[8] = 0.0;            /* Saturn's body */
  500. X  HeapSort0(x, xindex, 9);
  501. X  for (i = 0; i < 9; i++)
  502. X    if (xindex[i] == 8) j = i;
  503. X  fprintf(outf, "/Sat-order-array [");
  504. X  for (i = 0; i < (8 - 2*j); i++) fprintf(outf, " (  )");
  505. X  for (i = 0; i < 9; i++) {
  506. X    if (xindex[i] < 8) {
  507. X      fprintf(outf, " (%c%c)",
  508. X          saturnsats[xindex[i]].name[0], saturnsats[xindex[i]].name[1]);
  509. X    } else {
  510. X      fprintf(outf, " (S)");
  511. X    }
  512. X  };
  513. X  for (i = 0; i < (2*(j-4)); i++) fprintf(outf, " (  )");
  514. X  fprintf(outf, "] def\n\n");
  515. X  fprintf(outf, "\n");
  516. X  fprintf(outf, "\n");
  517. X
  518. X  /* Vertical for saturn */
  519. X  for (i = 0; i < 8; i++)
  520. X    y[i] = saturnsats[i].ddelta;
  521. X
  522. X  if (invert_sats)
  523. X    if (one_day)
  524. X      for (i = 0; i < 8; i++)
  525. X    y[i] = -saturnsats[i].ddelta;
  526. X
  527. X  y[8] = 0.0;            /* Saturn's body */
  528. X  HeapSort0(y, yindex, 9);
  529. X  for (i = 0; i < 9; i++)
  530. X    if (yindex[i] == 8) j = i;
  531. X  fprintf(outf, "/Sat-yorder-array [");
  532. X  for (i = 0; i < (8 - 2*j); i++) fprintf(outf, " (  )");
  533. X  for (i = 0; i < 9; i++) {
  534. X    if (yindex[i] < 8) {
  535. X      fprintf(outf, " (%c%c)",
  536. X          saturnsats[yindex[i]].name[0], saturnsats[yindex[i]].name[1]);
  537. X    } else {
  538. X      fprintf(outf, " (S)");
  539. X    }
  540. X  };
  541. X  for (i = 0; i < (2*(j-4)); i++) fprintf(outf, " (  )");
  542. X  fprintf(outf, "] def\n\n");
  543. X  fprintf(outf, "\n");
  544. X  fprintf(outf, "\n");
  545. X
  546. X  /* Draw them */
  547. X  if (one_day) {
  548. X    fprintf(outf, "/jupiter {2 div Jupiter} def\n");
  549. X    fprintf(outf, "/saturn {2 div Saturn} def\n");
  550. X    fprintf(outf,
  551. X"%% The above \"jupiter\" and \"saturn\" can be called from starchart postscript\n");
  552. X    fprintf(outf, "%%End definitions\n");
  553. X    fprintf(outf,
  554. X      "%%Begin footer: Remove if inserted in starchart postscript file\n");
  555. X    for (i = 0; i < 5; i++) {
  556. X      psx = 72 + i*72;
  557. X      psy = 180;
  558. X      if (i != 4)
  559. X    fprintf(outf,"%d %d %f %f %f %f %f planet-with-phase\n", psx, psy,
  560. X        planets[i].size* 0.70866141732283465, /* 1 cm = 20 s */
  561. X        planets[i].phase,
  562. X        planets[i].rotation_elements.p_n,
  563. X        planets[i].rotation_elements.beta_e,
  564. X        planets[i].chi);
  565. X      else
  566. X    fprintf(outf,"%d %d %f %f %f %f %f saturn-with-phase\n", psx, psy,
  567. X        planets[i].size* 0.70866141732283465, /* 1 cm = 20 s */
  568. X        planets[i].phase,
  569. X        planets[i].rotation_elements.p_n,
  570. X        planets[i].rotation_elements.beta_e,
  571. X        planets[i].chi);
  572. X      fprintf(outf, "%d %d moveto (%s) centershow\n", psx, psy - 72,
  573. X          planets[i].name);
  574. X      fprintf(outf, "%d %d moveto (Meridian) centershow\n",
  575. X          psx, psy - 90);
  576. X      fprintf(outf, "%d %d moveto (%.0f\\312) centershow\n",
  577. X          psx, psy - 102,
  578. X          planets[i].rotation_elements.lambda_e);
  579. X    };
  580. X
  581. X    fprintf(outf, "504 180 36 %f %f Luna-with-phase\n",
  582. X        moon_data.phase, moon_data.chi);
  583. X    fprintf(outf, "504 108 moveto (Moon) centershow\n");
  584. X    fprintf(outf, "504 90 moveto (%.2f arcmin) centershow\n",
  585. X        moon_data.size/60.0);
  586. X
  587. X    psy = 48;
  588. X    psx = 72;
  589. X    fprintf(outf,
  590. X "%d %d moveto %f %d lineto stroke %f %d moveto (  1 cm = 20 arcsec) show\n",
  591. X        psx, psy, psx + 20*0.70866141732283465, /* 1 cm = 20 s */ psy,
  592. X        psx + 20*0.70866141732283465, psy);
  593. X        
  594. X    fprintf(outf, "%d %d moveto (%s) centershow\n",
  595. X        CenterLine, DateY, datestr);
  596. X
  597. X    psx = CenterLine;
  598. X    psy = DateY - 72;
  599. X    if (invert_sats) {
  600. X      fprintf(outf, "%d %d moveto %d %d lineto %d %d lineto stroke\n",
  601. X          psx, psy + 12, psx, psy - 12, psx - 4, psy - 12 + 4);
  602. X      fprintf(outf, "%d %d moveto (N) atshow10pt\n", psx, psy - 12 - 9);
  603. X      fprintf(outf, "%d %d moveto (S) atshow10pt\n", psx, psy + 12 + 9);
  604. X    } else {
  605. X      fprintf(outf, "%d %d moveto %d %d lineto %d %d lineto stroke\n",
  606. X          psx, psy - 12, psx, psy + 12, psx + 4, psy + 12 - 4);
  607. X      fprintf(outf, "%d %d moveto (N) atshow10pt\n", psx, psy + 12 + 9);
  608. X      fprintf(outf, "%d %d moveto (S) atshow10pt\n", psx, psy - 12 - 9);
  609. X    };
  610. X    fprintf(outf, "%d %d moveto %d %d lineto stroke\n",
  611. X        psx-12, psy, psx+12, psy);
  612. X    fprintf(outf, "%d %d moveto (E) atshow10pt\n", psx - 12 - 9, psy);
  613. X    fprintf(outf, "%d %d moveto (W) atshow10pt\n", psx + 12 + 9, psy);
  614. X
  615. X
  616. X    fprintf(outf, "%d %d %d Jupiter\n", CenterLine, JupY, JupOneRad);
  617. X    fprintf(outf, "/MMwidth (MM) stringwidth pop def\n");
  618. X    fprintf(outf,
  619. X "%d MMwidth 2 div add %d moveto MMwidth Jup-order-array array-centershow\n",
  620. X        CenterLine, JupY-JOrderOff);
  621. X    fprintf(outf, "\n");
  622. X
  623. X    fprintf(outf, "%d %d %d Saturn\n", CenterLine, SatY, SatOneRad);
  624. X    fprintf(outf,
  625. X "%d MMwidth 2 div add %d moveto MMwidth Sat-order-array array-centershow\n",
  626. X        CenterLine, SatY-SOrderOff);
  627. X    fprintf(outf, "%d %d moveto 12 Sat-yorder-array array-vertshow\n",
  628. X        CenterLine + SOrderOff, SatY);
  629. X    fprintf(outf, "\n");
  630. X  } else {
  631. X    if (jd < last_jd) {
  632. X      doing_saturn = TRUE;
  633. X      fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
  634. X      fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
  635. X      if (invert_sats) {
  636. X    fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
  637. X    fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
  638. X      } else {
  639. X    fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
  640. X    fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
  641. X      };
  642. X      fprintf(outf, "showpage\n");
  643. X
  644. X      top = 720;
  645. X    };
  646. X    last_jd = jd;
  647. X    if (!doing_saturn) {
  648. X      fprintf(outf, "%d %d %f Jupiter\n", JupColumn, top, JupManyRad);
  649. X      fprintf(outf, "%s findfont %d scalefont setfont\n", JSFontname, JSmlsz);
  650. X      fprintf(outf,
  651. X "%f %d moveto (MM) stringwidth pop Jup-order-array array-centershow\n",
  652. X          JupColumn + 36*JupManyRad + OrderOffset, top);
  653. X      fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
  654. X      fprintf(outf, "%f %d moveto (%s) show\n",
  655. X          JupColumn + 36*JupManyRad + DateOffset,
  656. X          top, datestr);
  657. X
  658. X      fprintf(outf, "\n");
  659. X      top -= 18;
  660. X      if (top <= 71) {
  661. X    fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
  662. X    fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
  663. X    if (invert_sats) {
  664. X      fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
  665. X      fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
  666. X    } else {
  667. X      fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
  668. X      fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
  669. X    };
  670. X    fprintf(outf, "showpage\n");
  671. X    top = 720;
  672. X      };
  673. X    } else {
  674. X      fprintf(outf, "%d %d %f Saturn\n", SatColumn, top, SatManyRad);
  675. X      fprintf(outf, "%s findfont %d scalefont setfont\n", SSFontname, SSmlsz);
  676. X      fprintf(outf,
  677. X "%f %d moveto (MM) stringwidth pop Sat-order-array array-centershow\n",
  678. X          SatColumn + 72*SatManyRad + OrderOffset, top);
  679. X      fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
  680. X      fprintf(outf, "%f %d moveto (%s) show\n",
  681. X          SatColumn + 72*SatManyRad + DateOffset,
  682. X          top, datestr);
  683. X
  684. X      fprintf(outf, "\n");
  685. X      top -= 72;
  686. X      if (top <= 71) {
  687. X    fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
  688. X    fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
  689. X    if (invert_sats) {
  690. X      fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
  691. X      fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
  692. X    } else {
  693. X      fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
  694. X      fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
  695. X    };
  696. X    fprintf(outf, "showpage\n");
  697. X    top = 720;
  698. X      };
  699. X    };
  700. X  };
  701. X
  702. X  if (one_day)
  703. X    fprintf(outf, "showpage\n");
  704. X}
  705. X
  706. X/* End: called if multiple day */
  707. Xvoid out_sat_end(o_sat, outf, invert_sats, start_date, interval_days)
  708. X     FILE *o_sat, *outf;
  709. X     int invert_sats;
  710. X     double start_date, interval_days;
  711. X{
  712. X
  713. X  fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
  714. X  fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
  715. X  fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
  716. X  if (invert_sats) {
  717. X    fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
  718. X    fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
  719. X  } else {
  720. X    fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
  721. X    fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
  722. X  };
  723. X  fprintf(outf, "showpage\n");
  724. X}
  725. END_OF_FILE
  726. if test 23472 -ne `wc -c <'observe/outsat.c'`; then
  727.     echo shar: \"'observe/outsat.c'\" unpacked with wrong size!
  728. fi
  729. # end of 'observe/outsat.c'
  730. fi
  731. if test -f 'starchart/readfile.c' -a "${1}" != "-c" ; then 
  732.   echo shar: Will not clobber existing file \"'starchart/readfile.c'\"
  733. else
  734. echo shar: Extracting \"'starchart/readfile.c'\" \(22399 characters\)
  735. sed "s/^X//" >'starchart/readfile.c' <<'END_OF_FILE'
  736. X/*
  737. X * readfile.c
  738. X * readstar routine
  739. X * Copyright (c) 1989 by Craig Counterman (email: ccount@athena.mit.edu)
  740. X * and Alan Paeth (awpaeth@watcgl)
  741. X * all rights reserved
  742. X *
  743. X * You may copy the program, compile it, and run it,
  744. X * but you may not try to make money off it, or pretend you wrote it.
  745. X * (This copyright prevents you from selling the program - the
  746. X *  author grants anyone the right to copy and install the program
  747. X *  on any machine it will run on)
  748. X */
  749. X
  750. Xstatic char rcsid[]="$Header: readfile.c,v 2.7 90/03/10 15:31:11 ccount Exp $";
  751. X
  752. X#include <stdio.h>
  753. X#include <math.h>
  754. X
  755. Xchar *malloc();
  756. X
  757. X
  758. X#ifndef SYSV
  759. X#include <strings.h>
  760. X#else
  761. X#include <string.h>
  762. X#endif
  763. X#include <ctype.h>
  764. X
  765. X#include "star3.h"
  766. X
  767. X#ifndef READMODE
  768. X#define READMODE "r"
  769. X#endif
  770. X#define OPENFAIL 0
  771. X#define LINELEN 82
  772. X
  773. X
  774. X/* PI / 180 = .0174532925199 */
  775. X#define DCOS(x) (cos((x)*.0174532925199))
  776. X#define DSIN(x) (sin((x)*.0174532925199))
  777. X#define DTAN(x) (tan((x)*.0174532925199))
  778. X#define DASIN(x) (asin(x)/.0174532925199)
  779. X#define DATAN2(x,y) (atan2(x,y)/.0174532925199)
  780. X#define MAX(a,b) ((a)>(b)?(a):(b))
  781. X#define MIN(a,b) ((a)<(b)?(a):(b))
  782. X
  783. X
  784. X/* read file function indirection to allow for use of alternate file readers */
  785. Xextern int (*readfile)();
  786. Xextern char *cur_file_name;
  787. X
  788. X/* Readstar globals */
  789. Xextern double obj_lat, obj_lon, obj_mag;
  790. Xextern char obj_type[3], obj_color[3], obj_label[3];
  791. Xextern char obj_constell[4], obj_name[LINELEN];
  792. Xextern char *obj_commnt, fileline[LINELEN];
  793. X
  794. X
  795. X/* constellation abbreviations */
  796. Xchar *con_table[] = {
  797. X  "   ",
  798. X  "AND",
  799. X  "ANT",
  800. X  "APS",
  801. X  "AQL",
  802. X  "AQR",
  803. X  "ARA",
  804. X  "ARI",
  805. X  "AUR",
  806. X  "BOO",
  807. X  "CAE",
  808. X  "CAM",
  809. X  "CAP",
  810. X  "CAR",
  811. X  "CAS",
  812. X  "CEN",
  813. X  "CEP",
  814. X  "CET",
  815. X  "CHA",
  816. X  "CIR",
  817. X  "CMA",
  818. X  "CMI",
  819. X  "CNC",
  820. X  "COL",
  821. X  "COM",
  822. X  "CRA",
  823. X  "CRB",
  824. X  "CRT",
  825. X  "CRU",
  826. X  "CRV",
  827. X  "CVN",
  828. X  "CYG",
  829. X  "DEL",
  830. X  "DOR",
  831. X  "DRA",
  832. X  "EQU",
  833. X  "ERI",
  834. X  "FOR",
  835. X  "GEM",
  836. X  "GRU",
  837. X  "HER",
  838. X  "HOR",
  839. X  "HYA",
  840. X  "HYI",
  841. X  "IND",
  842. X  "LAC",
  843. X  "LEO",
  844. X  "LEP",
  845. X  "LIB",
  846. X  "LMI",
  847. X  "LUP",
  848. X  "LYN",
  849. X  "LYR",
  850. X  "MEN",
  851. X  "MIC",
  852. X  "MON",
  853. X  "MUS",
  854. X  "NOR",
  855. X  "OCT",
  856. X  "OPH",
  857. X  "ORI",
  858. X  "PAV",
  859. X  "PEG",
  860. X  "PER",
  861. X  "PHE",
  862. X  "PIC",
  863. X  "PSA",
  864. X  "PSC",
  865. X  "PUP",
  866. X  "PYX",
  867. X  "RET",
  868. X  "SCL",
  869. X  "SCO",
  870. X  "SCT",
  871. X  "SER",
  872. X  "SEX",
  873. X  "SGE",
  874. X  "SGR",
  875. X  "TAU",
  876. X  "TEL",
  877. X  "TRA",
  878. X  "TRI",
  879. X  "TUC",
  880. X  "UMA",
  881. X  "UMI",
  882. X  "VEL",
  883. X  "VIR",
  884. X  "VOL",
  885. X  "VUL"
  886. X  };
  887. X
  888. X
  889. X/* typedefs for exact sizes of int */
  890. Xtypedef char int_8;
  891. Xtypedef short int int_16;
  892. Xtypedef long int int_32;
  893. X
  894. X/* BINFULL structure */
  895. Xstruct bfull_struct {
  896. X  int_32 lat;            /* RA in seconds * 1000 */
  897. X  int_32 lon;            /* Dec in seconds * 1000 */
  898. X  int_16 mag;            /* Mag * 1000 */
  899. X  char tycolb[6];        /* Type, color, label fields */
  900. X  int_8 consindx;        /* Index number of constellation */
  901. X  int_16 strlen;        /* length of name and comment field */
  902. X} binfull_in;
  903. X
  904. Xchar name_comment[LINELEN];
  905. X
  906. X/* BINOBJ structure */
  907. Xstruct bobj_struct {
  908. X  int_32 lat;            /* RA in seconds * 1000 */
  909. X  int_32 lon;            /* Dec in seconds * 1000 */
  910. X  int_16 mag;            /* Mag * 1000 */
  911. X  char type[2];            /* e.g. 'SD', 'CO' */
  912. X} binobj_in;
  913. X
  914. X/* BINSTAR structure */
  915. Xstruct bstar_struct {
  916. X  int_32 lat;            /* RA in seconds * 1000 */
  917. X  int_32 lon;            /* Dec in seconds * 1000 */
  918. X  int_16 mag;            /* Mag * 1000 */
  919. X} binstar_in;
  920. X
  921. X#ifndef NO_GSC
  922. X
  923. X#ifndef MAXPATHLEN
  924. X#define MAXPATHLEN 1025
  925. X#endif
  926. X
  927. X/* GSC data */
  928. Xstruct {
  929. X  double ra_deg, dec_deg, mag;
  930. X  int mag_band, class;
  931. X} GSC[100];
  932. Xint GSC_nlines;
  933. Xint GSC_ID = 0;
  934. Xint GSC_skip = FALSE;
  935. Xchar id_str[5];
  936. Xchar last_gsc[MAXPATHLEN] = "";
  937. X#endif /* NO_GSC */
  938. X
  939. X/* readstar reads from the file the information for one object, and
  940. X   loads the following variables:
  941. Xdouble obj_lat, obj_lon, obj_mag;
  942. Xchar obj_type[] ="SS", obj_color[3], obj_label[3];
  943. Xchar obj_constell[3], obj_name[LINELEN];
  944. Xchar *obj_commnt, fileline[LINELEN];
  945. X
  946. Xonly lat, lon, and mag are required.  type should default to 'SS',
  947. Xcolor, label, constell default to "  ", and the rest default to ""
  948. X*/
  949. Xint readstar(file, ftype)
  950. X     FILE *file;
  951. X     int ftype;
  952. X{
  953. X  char *ptr;
  954. X  double rah, ram, ras, dld, dlm, dl, inten;
  955. X  int i, j;
  956. X  int nchars;
  957. X  char m1;
  958. X
  959. X  if ((ftype != LINEREAD) && (ftype != BINFULL)
  960. X      && (ftype != BINOBJ) && (ftype != BINSTAR) && (ftype != GSCTYPE))
  961. X    return (TRUE);
  962. X  /* only LINEREAD, BINFULL, BINOBJ, BINSTAR and GSC supported at this time */
  963. X
  964. X  if (ftype == BINSTAR) {
  965. X    if (fread((char *) &binstar_in, sizeof(binstar_in), 1, file) != 1) {
  966. X      if (feof(file)) return TRUE;
  967. X      perror("Error reading input file");
  968. X      exit(2);
  969. X    }
  970. X
  971. X    obj_lat = ((double) binstar_in.lat) / 3600000L;
  972. X    obj_lon = ((double) binstar_in.lon) / 3600000L;
  973. X    obj_mag = ((double) binstar_in.mag) / 1000L;
  974. X    obj_type[0] = 'S';
  975. X    obj_type[1] = 'S';
  976. X    obj_color[0] = ' ';
  977. X    obj_color[1] = ' ';
  978. X    obj_label[0] = ' ';
  979. X    obj_label[1] = ' ';
  980. X    obj_constell[0] = ' ';
  981. X    obj_constell[1] = ' ';
  982. X    obj_constell[2] = ' ';
  983. X    obj_name[0] = '\0';
  984. X    obj_commnt = "";
  985. X
  986. X    strcpy(fileline, "");
  987. X  } else if (ftype == BINOBJ) {
  988. X    if (fread((char *) &binobj_in, sizeof(binobj_in), 1, file) != 1) {
  989. X      if (feof(file)) return TRUE;
  990. X      perror("Error reading input file");
  991. X      exit(2);
  992. X    }
  993. X
  994. X    obj_lat = ((double) binobj_in.lat) / 3600000L;
  995. X    obj_lon = ((double) binobj_in.lon) / 3600000L;
  996. X    obj_mag = ((double) binobj_in.mag) / 1000L;
  997. X    obj_type[0] = binobj_in.type[0];
  998. X    obj_type[1] = binobj_in.type[1];
  999. X    obj_color[0] = ' ';
  1000. X    obj_color[1] = ' ';
  1001. X    obj_label[0] = ' ';
  1002. X    obj_label[1] = ' ';
  1003. X    obj_constell[0] = ' ';
  1004. X    obj_constell[1] = ' ';
  1005. X    obj_constell[2] = ' ';
  1006. X    obj_name[0] = '\0';
  1007. X    obj_commnt = "";
  1008. X
  1009. X    strcpy(fileline, "");
  1010. X  } else if (ftype == BINFULL) {
  1011. X    if (fread((char *) &binfull_in, sizeof(binfull_in), 1, file) != 1) {
  1012. X      if (feof(file)) return TRUE;
  1013. X      perror("Error reading input file");
  1014. X      exit(2);
  1015. X    }
  1016. X
  1017. X    if (binfull_in.strlen == 0)
  1018. X      strcpy(name_comment, "");
  1019. X    else {
  1020. X      if (fread((char *) name_comment, binfull_in.strlen, 1, file) != 1) {
  1021. X    perror("Error reading input file");
  1022. X    exit(2);
  1023. X      }
  1024. X      name_comment[binfull_in.strlen] = '\0';
  1025. X    }
  1026. X
  1027. X    obj_lat = ((double) binfull_in.lat) / 3600000L;
  1028. X    obj_lon = ((double) binfull_in.lon) / 3600000L;
  1029. X    obj_mag = ((double) binfull_in.mag) / 1000L;
  1030. X    obj_type[0] = binfull_in.tycolb[0];
  1031. X    obj_type[1] = binfull_in.tycolb[1];
  1032. X    obj_color[0] = binfull_in.tycolb[2];
  1033. X    obj_color[1] = binfull_in.tycolb[3];
  1034. X    obj_label[0] = binfull_in.tycolb[4];
  1035. X    obj_label[1] = binfull_in.tycolb[5];
  1036. X    strcpy(obj_constell,con_table[binfull_in.consindx]);
  1037. X
  1038. X    ptr = name_comment;
  1039. X    i = 0;
  1040. X    while (*ptr == ' ') ptr++;
  1041. X    while (*ptr != ',' && *ptr != '\n' && *ptr)
  1042. X      obj_name[i++] = *ptr++;
  1043. X    obj_name[i] = '\0';
  1044. X    if ((*ptr == ',') && (*++ptr) && name_comment[0]) obj_commnt = ptr;
  1045. X    else obj_commnt = "";
  1046. X
  1047. X    strcpy(fileline, "");
  1048. X#ifndef NO_GSC
  1049. X  } else if (ftype == GSCTYPE) {
  1050. X#define Val(ch) (ch - '0')
  1051. X    if (strcmp(cur_file_name, last_gsc)) { /* New file */
  1052. X      fseek(file, 8640L, 0);
  1053. X      strcpy(last_gsc, cur_file_name);
  1054. X      if (fread((char *) id_str, 5, 1, file) != 1) {
  1055. X    if (feof(file)) return TRUE;
  1056. X    perror("Error reading input file");
  1057. X    exit(2);
  1058. X      };
  1059. X      GSC_ID = Val(id_str[0])*10000 +
  1060. X    Val(id_str[1])*1000 +
  1061. X    Val(id_str[2])*100 +
  1062. X    Val(id_str[3])*10 +
  1063. X    Val(id_str[4]);
  1064. X    };
  1065. X    GSC_skip = FALSE;
  1066. X    do {
  1067. X      if (id_str[0] == ' ') return TRUE;
  1068. X      i = 0;
  1069. X      do {
  1070. X    if (fread((char *) fileline, 40, 1, file) != 1) {
  1071. X      if (feof(file)) return TRUE;
  1072. X      perror("Error reading input file");
  1073. X      exit(2);
  1074. X    };
  1075. X    for (j = 0; j < 40; j++) if (fileline[j] == ' ') fileline[j] = '0';
  1076. X    /* We care about RA_DEG, DEC_DEG, MAG, MAG_BAND, CLASS, MULTIPLE */
  1077. X    /* We read the GSC_ID already to see if it is a continuation */
  1078. X    GSC[i].ra_deg = Val(fileline[0]) * 100.0 +
  1079. X      Val(fileline[1]) * 10.0 +
  1080. X      Val(fileline[2]) +
  1081. X      Val(fileline[4]) / 10.0 +
  1082. X      Val(fileline[5]) / 100.0 +
  1083. X      Val(fileline[6]) / 1000.0 +
  1084. X      Val(fileline[7]) / 10000.0 +
  1085. X      Val(fileline[8]) / 100000.0;
  1086. X    if (fileline[10] == '-')
  1087. X      GSC[i].dec_deg = -1 *
  1088. X        (Val(fileline[11]) +
  1089. X         Val(fileline[13]) / 10.0 +
  1090. X         Val(fileline[14]) / 100.0 +
  1091. X         Val(fileline[15]) / 1000.0 +
  1092. X         Val(fileline[16]) / 10000.0 +
  1093. X         Val(fileline[17]) / 100000.0);
  1094. X    else
  1095. X      GSC[i].dec_deg =  ((fileline[9] == '-') ? -1 : 1) *
  1096. X        (Val(fileline[10]) * 10.0 +
  1097. X         Val(fileline[11]) +
  1098. X         Val(fileline[13]) / 10.0 +
  1099. X         Val(fileline[14]) / 100.0 +
  1100. X         Val(fileline[15]) / 1000.0 +
  1101. X         Val(fileline[16]) / 10000.0 +
  1102. X         Val(fileline[17]) / 100000.0);
  1103. X    GSC[i].mag = Val(fileline[23]) * 10.0 +
  1104. X      Val(fileline[24]) +
  1105. X      Val(fileline[26]) / 10.0 +
  1106. X      Val(fileline[27]) / 100.0;
  1107. X    GSC[i].mag_band = Val(fileline[32])*10 + Val(fileline[33]);
  1108. X    GSC[i].class = Val(fileline[34]);
  1109. X    i++;
  1110. X    if (fread((char *) id_str, 5, 1, file) != 1) {
  1111. X      if (!feof(file)) {
  1112. X        perror("Error reading input file");
  1113. X        exit(2);
  1114. X      };
  1115. X    };
  1116. X    if (!feof(file)) {
  1117. X      j = Val(id_str[0])*10000 +
  1118. X        Val(id_str[1])*1000 +
  1119. X        Val(id_str[2])*100 +
  1120. X        Val(id_str[3])*10 +
  1121. X        Val(id_str[4]);
  1122. X    };
  1123. X      } while ((j == GSC_ID) && (!feof(file)) && (id_str[0] != ' '));
  1124. X      GSC_nlines = i;
  1125. X      GSC_ID = j;
  1126. X      /* for now just use first */
  1127. X/* There are many stars with class == 3, so we'll ignore class */
  1128. X/*      if (GSC[0].class == 0) {*/    /* is a star if class == 0 */
  1129. X    obj_lon = GSC[0].ra_deg;
  1130. X    obj_lat = GSC[0].dec_deg;
  1131. X    obj_mag = GSC[0].mag;
  1132. X    obj_type[0] = 'S';
  1133. X    obj_type[1] = 'S';
  1134. X    obj_color[0] = ' ';
  1135. X    obj_color[1] = ' ';
  1136. X    obj_label[0] = ' ';
  1137. X    obj_label[1] = ' ';
  1138. X    obj_constell[0] = ' ';
  1139. X    obj_constell[1] = ' ';
  1140. X    obj_constell[2] = ' ';
  1141. X    obj_name[0] = '\0';
  1142. X/*    obj_commnt = &fileline[0];*/
  1143. X    obj_commnt = "";
  1144. X    fileline[0] = '\0';
  1145. X    GSC_skip = FALSE;
  1146. X/* Ignoring class seems to be the right thing */
  1147. X/*      } else {*/            /* not a star, skip */
  1148. X/*    GSC_skip = TRUE;
  1149. X      };*/
  1150. X    } while (GSC_skip);
  1151. X#endif /* NO_GSC */
  1152. X  } else { /* LINEREAD */
  1153. X
  1154. X/*
  1155. X * file formats:
  1156. X * new
  1157. X064509-1643-14SDA1a CMASirius
  1158. X051432-0812015SDB8b ORIRigel
  1159. X * old
  1160. X064509-1643-146SSSirius
  1161. X051432-08120015SSRigel
  1162. X */
  1163. X
  1164. X    fgets(fileline, LINELEN, file);
  1165. X    if (feof(file)) return(TRUE);    /* IS AN ERROR or eof */
  1166. X    nchars = 0;
  1167. X    while (fileline[nchars++]);
  1168. X    nchars--;
  1169. X    nchars--;
  1170. X
  1171. X/*
  1172. X * sscanf of floats is TOOO slow:
  1173. X *     sscanf(fileline, "%2f%2f%2f%c%2f%2f ... );
  1174. X * use alternate:
  1175. X */
  1176. X#define F2(i) (((fileline[i]-'0')*10.0+fileline[i+1]-'0'))
  1177. X#define F3(i) (((fileline[i]-'0')*100.0+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
  1178. X#define F4(i) (((fileline[i]-'0')*1000.0+(fileline[i+1]-'0')*100+(fileline[i+2])-'0')*10+fileline[i+3]-'0')
  1179. X#define F3M(i) (((fileline[i]-'A'+10.0)*100+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
  1180. X    rah = F2(0);
  1181. X    ram = F2(2);
  1182. X    ras = F2(4);
  1183. X    dld = F2(7);
  1184. X    dlm = F2(9);
  1185. X/*
  1186. X * common code
  1187. X */
  1188. X#define DLDEGSEC 3600.0
  1189. X#define DLMINSEC 60.0
  1190. X#define RAHRSSEC 54000.0
  1191. X#define RAMINSEC 900.0
  1192. X#define RASECSEC 15.0
  1193. X
  1194. X
  1195. X    obj_lon = (RAHRSSEC*rah + RAMINSEC*ram + RASECSEC*ras)/DLDEGSEC;
  1196. X    dl = (DLDEGSEC*dld + DLMINSEC*dlm)/DLDEGSEC;
  1197. X    obj_lat = (fileline[6]  == '-') ? -dl : dl;
  1198. X    
  1199. X    /* set unknowns to blanks */
  1200. X    obj_color[0] = ' ';
  1201. X    obj_color[1] = ' ';
  1202. X    obj_color[2] = '\0';
  1203. X    obj_label[0] = ' ';
  1204. X    obj_label[1] = ' ';
  1205. X    obj_label[2] = '\0';
  1206. X    obj_constell[0] = ' ';
  1207. X    obj_constell[1] = ' ';
  1208. X    obj_constell[2] = ' ';
  1209. X    obj_constell[3] = '\0';
  1210. X    
  1211. X    if  (isdigit(fileline[14])) {
  1212. X    /*
  1213. X     * old reduced Yale catalog
  1214. X     */
  1215. X      inten = F3(12);
  1216. X      if (fileline[11] == '0' || fileline[11] == '+') obj_mag = inten/100.0;
  1217. X      else if (fileline[11] == '-') obj_mag = -inten/100.0;
  1218. X      else obj_mag = F4(11)/1000.0;    /* new feature for stars >= 10.0 mag */
  1219. X      
  1220. X      if (nchars > 15) {
  1221. X    obj_type[0] = fileline[15];
  1222. X    obj_type[1] = fileline[16];
  1223. X    ptr = &fileline[MIN(17,nchars)];
  1224. X    i = 0;
  1225. X    while (*ptr == ' ') ptr++;
  1226. X#ifdef ATARI_ST
  1227. X    while (*ptr != ',' && *ptr != '\n' && *ptr != '\r' && *ptr)
  1228. X      obj_name[i++] = *ptr++;
  1229. X#else
  1230. X    while (*ptr != ',' && *ptr != '\n' && *ptr)
  1231. X      obj_name[i++] = *ptr++;
  1232. X#endif
  1233. X    obj_name[i] = '\0';
  1234. X    if (*++ptr) obj_commnt = ptr;
  1235. X    else obj_commnt = "";
  1236. X      } else {
  1237. X    obj_type[0] = obj_type[1] = 'S'; /* Default SS single star */
  1238. X    obj_name[0] = '\0';
  1239. X    obj_commnt = "";
  1240. X      }
  1241. X    } else {
  1242. X      /*
  1243. X       * new reduced Yale catalog
  1244. X       */
  1245. X      m1 = fileline[11];
  1246. X      obj_mag = ((m1 == '-') ? -F2(12)/10.0 :
  1247. X         (m1 <= '9') ? F3(11)/100.0 : F3M(11)/100.0);
  1248. X      /* let's get Sirius */
  1249. X    
  1250. X      /*
  1251. X       * extract color, label, constellation, name, and comment
  1252. X       * Would be faster to just guarentee that the data file is correct
  1253. X       */
  1254. X      if (nchars > 22) {
  1255. X    obj_constell[0] = fileline[20];
  1256. X    obj_constell[1] = fileline[21];
  1257. X    obj_constell[2] = fileline[22];
  1258. X    obj_constell[3] = '\0';
  1259. X      }
  1260. X      if (nchars > 19) {
  1261. X    obj_label[0] = fileline[18];
  1262. X    obj_label[1] = fileline[19];
  1263. X    obj_label[2] = '\0';
  1264. X      }
  1265. X      if (nchars > 17) {
  1266. X    obj_color[0] = fileline[16]; 
  1267. X    obj_color[1] = fileline[17];
  1268. X    obj_color[2] = '\0';
  1269. X      }
  1270. X      if (nchars > 15) {
  1271. X    obj_type[0] = fileline[14];
  1272. X    obj_type[1] = fileline[15];
  1273. X      }
  1274. X
  1275. X      ptr = &fileline[MIN(23,nchars)];
  1276. X      i = 0;
  1277. X      while (*ptr == ' ') ptr++;
  1278. X#ifdef ATARI_ST
  1279. X      while (*ptr != ',' && *ptr != '\n' && *ptr != '\r' && *ptr)
  1280. X    obj_name[i++] = *ptr++;
  1281. X#else
  1282. X      while (*ptr != ',' && *ptr != '\n' && *ptr)
  1283. X    obj_name[i++] = *ptr++;
  1284. X#endif
  1285. X      obj_name[i] = '\0';
  1286. X      if (*++ptr) obj_commnt = ptr;
  1287. X      else obj_commnt = "";
  1288. X    }
  1289. X  }
  1290. X
  1291. X  return(FALSE); /* NO error */
  1292. X}
  1293. X
  1294. X/* Macintosh, under MPW, currently won't do buf_readstar */
  1295. X#ifndef macintosh
  1296. X#ifdef ATARI_ST
  1297. X#include<types.h>
  1298. X#include<stat.h>
  1299. X#else
  1300. X#include<sys/types.h>
  1301. X#include<sys/stat.h>
  1302. X#endif
  1303. X
  1304. X/* > MAXMAPFILES because more files may be read
  1305. X   if chart is changed interactively */
  1306. Xstruct fbuf {
  1307. X  char *name;
  1308. X  char *data;
  1309. X  char *cur_point;
  1310. X  char *last_point;
  1311. X} buf_files[10*MAXMAPFILES];
  1312. X
  1313. Xint nbuf_files = 0;
  1314. X
  1315. Xchar *last_read = "";
  1316. Xchar *cur_fpt = NULL;
  1317. Xchar *eodata = NULL;
  1318. Xint cur_buf = 0;
  1319. X
  1320. Xint buf_readstar(file, ftype)
  1321. X     FILE *file;
  1322. X     int ftype;
  1323. X{
  1324. X  int i;
  1325. X  struct stat fstats;
  1326. X  unsigned fsze;
  1327. X
  1328. X  char *ptr;
  1329. X  double rah, ram, ras, dld, dlm, dl, inten;
  1330. X  int nchars;
  1331. X  char m1;
  1332. X
  1333. X  if (ftype == GSCTYPE) return readstar(file, ftype);
  1334. X  /* We don't do buffered reads of the GSC data. */
  1335. X
  1336. X  /* if we've read this file before, access from memory
  1337. X     usually will be last read
  1338. X     Otherwise, try to allocate memory for file */
  1339. X
  1340. X  if (strcmp(cur_file_name, last_read)) {    /* New file, most likely */
  1341. X    for (i = 0; i < nbuf_files; i++)
  1342. X      if (!strcmp(cur_file_name, buf_files[i].name)) break;
  1343. X
  1344. X    if (i == nbuf_files) {    /* Need to read the file */
  1345. X      buf_files[nbuf_files].name =
  1346. X    (char *) malloc((unsigned) strlen(cur_file_name)+1);
  1347. X      strcpy(buf_files[nbuf_files].name, cur_file_name);
  1348. X
  1349. X#ifndef ATARI_ST
  1350. X      fstat(fileno(file), &fstats);
  1351. X#else
  1352. X      /* MWC 3.06 fstat is not implemented correctly. st_size is
  1353. X     always 0 (according to the manual !!) despite it's known. */
  1354. X      stat(cur_file_name, &fstats);
  1355. X#endif
  1356. X      fsze = fstats.st_size;
  1357. X      if (fsze != 0) {        /* e.g. /dev/null */
  1358. X    buf_files[nbuf_files].data = (char *) malloc(fsze);
  1359. X    if ((buf_files[nbuf_files].data == NULL)
  1360. X        || (((fsze = fread(buf_files[nbuf_files].data, 1,
  1361. X                   (int) fsze, file)) == 0)  /* no bytes read */
  1362. X        && (!feof(file)))) { /* And it's not the end of the file */
  1363. X      readfile = readstar;    /* Give up on buf_readstar */
  1364. X      D_comment("buffered file read: Out of memory\n");
  1365. X
  1366. X                /* call readstar now */
  1367. X      return readstar(file, ftype);
  1368. X    }
  1369. X      } else
  1370. X    buf_files[nbuf_files].data = "";
  1371. X
  1372. X      buf_files[nbuf_files].cur_point = buf_files[nbuf_files].data;
  1373. X      cur_fpt = buf_files[nbuf_files].cur_point;
  1374. X      buf_files[nbuf_files].last_point =
  1375. X    buf_files[nbuf_files].cur_point + fsze;
  1376. X      eodata = buf_files[nbuf_files].last_point;
  1377. X      last_read = buf_files[nbuf_files].name;
  1378. X      cur_buf = nbuf_files;
  1379. X      nbuf_files++;
  1380. X    } else {             /* Old file */
  1381. X/*      D_comment("Reading from memory\n");*/
  1382. X      last_read = buf_files[i].name;
  1383. X      cur_fpt = buf_files[i].cur_point = buf_files[i].data;
  1384. X      eodata = buf_files[i].last_point;
  1385. X      cur_buf = i;
  1386. X    }
  1387. X  }
  1388. X
  1389. X  /* Now, cur_fpt points to file data.  Read the data as in readstar above */
  1390. X  if ((ftype != LINEREAD) && (ftype != BINFULL)
  1391. X      && (ftype != BINOBJ) && (ftype != BINSTAR))
  1392. X    return (TRUE);
  1393. X  /* only LINEREAD, BINFULL, BINOBJ and BINSTAR supported at this time */
  1394. X
  1395. X  if (cur_fpt == eodata) return TRUE; /* End of data, end of file */
  1396. X
  1397. X
  1398. X  if (ftype == BINSTAR) {
  1399. X    for (i = 0, ptr = (char *) &binstar_in; i < sizeof(binstar_in); i++) 
  1400. X      *ptr++ = *cur_fpt++;
  1401. X    buf_files[cur_buf].cur_point += sizeof(binstar_in);
  1402. X
  1403. X    obj_lat = ((double) binstar_in.lat) / 3600000L;
  1404. X    obj_lon = ((double) binstar_in.lon) / 3600000L;
  1405. X    obj_mag = ((double) binstar_in.mag) / 1000L;
  1406. X    obj_type[0] = 'S';
  1407. X    obj_type[1] = 'S';
  1408. X    obj_color[0] = ' ';
  1409. X    obj_color[1] = ' ';
  1410. X    obj_label[0] = ' ';
  1411. X    obj_label[1] = ' ';
  1412. X    obj_constell[0] = ' ';
  1413. X    obj_constell[1] = ' ';
  1414. X    obj_constell[2] = ' ';
  1415. X    obj_name[0] = '\0';
  1416. X    obj_commnt = "";
  1417. X
  1418. X    strcpy(fileline, "");
  1419. X  } else if (ftype == BINOBJ) {
  1420. X    for (i = 0, ptr = (char *) &binobj_in; i < sizeof(binobj_in); i++) 
  1421. X      *ptr++ = *cur_fpt++;
  1422. X    buf_files[cur_buf].cur_point += sizeof(binobj_in);
  1423. X
  1424. X    obj_lat = ((double) binobj_in.lat) / 3600000L;
  1425. X    obj_lon = ((double) binobj_in.lon) / 3600000L;
  1426. X    obj_mag = ((double) binobj_in.mag) / 1000L;
  1427. X    obj_type[0] = binobj_in.type[0];
  1428. X    obj_type[1] = binobj_in.type[1];
  1429. X    obj_color[0] = ' ';
  1430. X    obj_color[1] = ' ';
  1431. X    obj_label[0] = ' ';
  1432. X    obj_label[1] = ' ';
  1433. X    obj_constell[0] = ' ';
  1434. X    obj_constell[1] = ' ';
  1435. X    obj_constell[2] = ' ';
  1436. X    obj_name[0] = '\0';
  1437. X    obj_commnt = "";
  1438. X
  1439. X    strcpy(fileline, "");
  1440. X  } else if (ftype == BINFULL) {
  1441. X    for (i = 0, ptr = (char *) &binfull_in; i < sizeof(binfull_in); i++) 
  1442. X      *ptr++ = *cur_fpt++;
  1443. X    buf_files[cur_buf].cur_point += sizeof(binfull_in);
  1444. X
  1445. X    if (binfull_in.strlen == 0)
  1446. X      strcpy(name_comment, "");
  1447. X    else {
  1448. X      for (i = 0; i < binfull_in.strlen; i++) 
  1449. X    name_comment[i] = *cur_fpt++;
  1450. X      buf_files[cur_buf].cur_point += binfull_in.strlen;
  1451. X
  1452. X      name_comment[binfull_in.strlen] = '\0';
  1453. X    }
  1454. X
  1455. X    obj_lat = ((double) binfull_in.lat) / 3600000L;
  1456. X    obj_lon = ((double) binfull_in.lon) / 3600000L;
  1457. X    obj_mag = ((double) binfull_in.mag) / 1000L;
  1458. X    obj_type[0] = binfull_in.tycolb[0];
  1459. X    obj_type[1] = binfull_in.tycolb[1];
  1460. X    obj_color[0] = binfull_in.tycolb[2];
  1461. X    obj_color[1] = binfull_in.tycolb[3];
  1462. X    obj_label[0] = binfull_in.tycolb[4];
  1463. X    obj_label[1] = binfull_in.tycolb[5];
  1464. X    strcpy(obj_constell,con_table[binfull_in.consindx]);
  1465. X
  1466. X    ptr = name_comment;
  1467. X    i = 0;
  1468. X    while (*ptr == ' ') ptr++;
  1469. X    while (*ptr != ',' && *ptr != '\n' && *ptr)
  1470. X      obj_name[i++] = *ptr++;
  1471. X    obj_name[i] = '\0';
  1472. X    if ((*ptr == ',') && (*++ptr) && name_comment[0]) obj_commnt = ptr;
  1473. X    else obj_commnt = "";
  1474. X
  1475. X    strcpy(fileline, "");
  1476. X  } else { /* LINEREAD */
  1477. X
  1478. X/*
  1479. X * file formats:
  1480. X * new
  1481. X064509-1643-14SDA1a CMASirius
  1482. X051432-0812015SDB8b ORIRigel
  1483. X * old
  1484. X064509-1643-146SSSirius
  1485. X051432-08120015SSRigel
  1486. X */
  1487. X
  1488. X    ptr = fileline;
  1489. X    while ((*ptr++ = *cur_fpt++) != '\n');
  1490. X    *ptr = '\0';
  1491. X    buf_files[cur_buf].cur_point = cur_fpt;
  1492. X
  1493. X    nchars = 0;
  1494. X    while (fileline[nchars++]);
  1495. X    nchars--;
  1496. X    nchars--;
  1497. X
  1498. X/*
  1499. X * sscanf of floats is TOOO slow:
  1500. X *     sscanf(fileline, "%2f%2f%2f%c%2f%2f ... );
  1501. X * use alternate:
  1502. X */
  1503. X#define F2(i) (((fileline[i]-'0')*10.0+fileline[i+1]-'0'))
  1504. X#define F3(i) (((fileline[i]-'0')*100.0+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
  1505. X#define F4(i) (((fileline[i]-'0')*1000.0+(fileline[i+1]-'0')*100+(fileline[i+2])-'0')*10+fileline[i+3]-'0')
  1506. X#define F3M(i) (((fileline[i]-'A'+10.0)*100+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
  1507. X    rah = F2(0);
  1508. X    ram = F2(2);
  1509. X    ras = F2(4);
  1510. X    dld = F2(7);
  1511. X    dlm = F2(9);
  1512. X/*
  1513. X * common code
  1514. X */
  1515. X#define DLDEGSEC 3600.0
  1516. X#define DLMINSEC 60.0
  1517. X#define RAHRSSEC 54000.0
  1518. X#define RAMINSEC 900.0
  1519. X#define RASECSEC 15.0
  1520. X
  1521. X
  1522. X    obj_lon = (RAHRSSEC*rah + RAMINSEC*ram + RASECSEC*ras)/DLDEGSEC;
  1523. X    dl = (DLDEGSEC*dld + DLMINSEC*dlm)/DLDEGSEC;
  1524. X    obj_lat = (fileline[6]  == '-') ? -dl : dl;
  1525. X    
  1526. X    /* set unknowns to blanks */
  1527. X    obj_color[0] = ' ';
  1528. X    obj_color[1] = ' ';
  1529. X    obj_color[2] = '\0';
  1530. X    obj_label[0] = ' ';
  1531. X    obj_label[1] = ' ';
  1532. X    obj_label[2] = '\0';
  1533. X    obj_constell[0] = ' ';
  1534. X    obj_constell[1] = ' ';
  1535. X    obj_constell[2] = ' ';
  1536. X    obj_constell[3] = '\0';
  1537. X    
  1538. X    if  (isdigit(fileline[14])) {
  1539. X    /*
  1540. X     * old reduced Yale catalog
  1541. X     */
  1542. X      inten = F3(12);
  1543. X      if (fileline[11] == '0' || fileline[11] == '+') obj_mag = inten/100.0;
  1544. X      else if (fileline[11] == '-') obj_mag = -inten/100.0;
  1545. X      else obj_mag = F4(11)/1000.0;    /* new feature for stars >= 10.0 mag */
  1546. X      
  1547. X      if (nchars > 15) {
  1548. X    obj_type[0] = fileline[15];
  1549. X    obj_type[1] = fileline[16];
  1550. X    ptr = &fileline[MIN(17,nchars)];
  1551. X    i = 0;
  1552. X    while (*ptr == ' ') ptr++;
  1553. X    while (*ptr != ',' && *ptr != '\n' && *ptr)
  1554. X      obj_name[i++] = *ptr++;
  1555. X    obj_name[i] = '\0';
  1556. X    if (*++ptr) obj_commnt = ptr;
  1557. X    else obj_commnt = "";
  1558. X      } else {
  1559. X    obj_type[0] = obj_type[1] = 'S'; /* Default SS single star */
  1560. X    obj_name[0] = '\0';
  1561. X    obj_commnt = "";
  1562. X      }
  1563. X    } else {
  1564. X      /*
  1565. X       * new reduced Yale catalog
  1566. X       */
  1567. X      m1 = fileline[11];
  1568. X      obj_mag = ((m1 == '-') ? -F2(12)/10.0 :
  1569. X         (m1 <= '9') ? F3(11)/100.0 : F3M(11)/100.0);
  1570. X      /* let's get Sirius */
  1571. X    
  1572. X      /*
  1573. X       * extract color, label, constellation, name, and comment
  1574. X       * Would be faster to just guarentee that the data file is correct
  1575. X       */
  1576. X      if (nchars > 22) {
  1577. X    obj_constell[0] = fileline[20];
  1578. X    obj_constell[1] = fileline[21];
  1579. X    obj_constell[2] = fileline[22];
  1580. X    obj_constell[3] = '\0';
  1581. X      }
  1582. X      if (nchars > 19) {
  1583. X    obj_label[0] = fileline[18];
  1584. X    obj_label[1] = fileline[19];
  1585. X    obj_label[2] = '\0';
  1586. X      }
  1587. X      if (nchars > 17) {
  1588. X    obj_color[0] = fileline[16]; 
  1589. X    obj_color[1] = fileline[17];
  1590. X    obj_color[2] = '\0';
  1591. X      }
  1592. X      if (nchars > 15) {
  1593. X    obj_type[0] = fileline[14];
  1594. X    obj_type[1] = fileline[15];
  1595. X      }
  1596. X
  1597. X      ptr = &fileline[MIN(23,nchars)];
  1598. X      i = 0;
  1599. X      while (*ptr == ' ') ptr++;
  1600. X      while (*ptr != ',' && *ptr != '\n' && *ptr)
  1601. X    obj_name[i++] = *ptr++;
  1602. X      obj_name[i] = '\0';
  1603. X      if (*++ptr) obj_commnt = ptr;
  1604. X      else obj_commnt = "";
  1605. X    }
  1606. X  }
  1607. X
  1608. X  return(FALSE); /* NO error */
  1609. X}
  1610. X#endif /* macintosh */
  1611. END_OF_FILE
  1612. if test 22399 -ne `wc -c <'starchart/readfile.c'`; then
  1613.     echo shar: \"'starchart/readfile.c'\" unpacked with wrong size!
  1614. fi
  1615. # end of 'starchart/readfile.c'
  1616. fi
  1617. echo shar: End of archive 13 \(of 32\).
  1618. cp /dev/null ark13isdone
  1619. MISSING=""
  1620. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
  1621.     if test ! -f ark${I}isdone ; then
  1622.     MISSING="${MISSING} ${I}"
  1623.     fi
  1624. done
  1625. if test "${MISSING}" = "" ; then
  1626.     echo You have unpacked all 32 archives.
  1627.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1628. else
  1629.     echo You still need to unpack the following archives:
  1630.     echo "        " ${MISSING}
  1631. fi
  1632. ##  End of shell archive.
  1633. exit 0
  1634.  
  1635.  
  1636.