-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathriseset.c
61 lines (48 loc) · 1.48 KB
/
riseset.c
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
riseset.c - by Don Cross - 2019-06-14
Example C program for Astronomy Engine:
https://github.com/cosinekitty/astronomy
This program calculates sunrise, sunset, moonrise, and moonset
times for an observer at a given latitude and longitude.
*/
#include <stdio.h>
#include "astro_demo_common.h"
int PrintEvent(const char *name, astro_search_result_t evt)
{
printf("%-8s : ", name);
if (evt.status == ASTRO_SUCCESS)
{
PrintTime(evt.time);
printf("\n");
return 0;
}
else
{
printf("ERROR %d\n", evt.status);
return 1;
}
}
int main(int argc, const char *argv[])
{
astro_observer_t observer;
astro_time_t time;
astro_search_result_t sunrise, sunset, moonrise, moonset;
if (ParseArgs(argc, argv, &observer, &time))
return 1;
printf("search : ");
PrintTime(time);
printf("\n");
sunrise = Astronomy_SearchRiseSet(BODY_SUN, observer, DIRECTION_RISE, time, 300.0);
sunset = Astronomy_SearchRiseSet(BODY_SUN, observer, DIRECTION_SET, time, 300.0);
moonrise = Astronomy_SearchRiseSet(BODY_MOON, observer, DIRECTION_RISE, time, 300.0);
moonset = Astronomy_SearchRiseSet(BODY_MOON, observer, DIRECTION_SET, time, 300.0);
if (PrintEvent("sunrise", sunrise))
return 1;
if (PrintEvent("sunset", sunset))
return 1;
if (PrintEvent("moonrise", moonrise))
return 1;
if (PrintEvent("moonset", moonset))
return 1;
return 0;
}