star-cem

Compute the position of the sun
git clone git://git.meso-star.fr/star-cem.git
Log | Files | Refs | README | LICENSE

commit 6abf1f34d9a3c22ced471e13c5e5a6c001b6a8bc
parent 9d88f450dff9c7cf7dd6db112a1e0e0eb134256f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 29 Sep 2025 17:16:12 +0200

Use the local UTC time for the test

Previously, the local time was not expressed as UTC as expected by the
scem API.

Diffstat:
Msrc/test_scem_sun_position.c | 24++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/test_scem_sun_position.c b/src/test_scem_sun_position.c @@ -15,6 +15,7 @@ #include "scem.h" +#include <rsys/math.h> #include <rsys/rsys.h> #include <time.h> @@ -26,23 +27,30 @@ static void test_api(void) { time_t epoch; - struct tm* tm = NULL; + struct tm* utc = NULL; struct scem_gcs pos = SCEM_GCS_NULL; struct scem_zad sun = SCEM_ZAD_NULL; epoch = time(NULL); CHK(epoch != ((time_t)-1)); - tm = localtime(&epoch); - CHK(tm != NULL); + utc = gmtime(&epoch); + CHK(utc != NULL); - pos.latitude = 43.599998; - pos.longitude = 1.43333; + printf("%s", asctime(utc)); + + pos.latitude = 43.604600; + pos.longitude = 1.44422; + printf("Lat: %g°; lon: %g°\n", pos.latitude, pos.longitude); CHK(scem_sun_position_from_earth(NULL, &pos, &sun) == RES_BAD_ARG); - CHK(scem_sun_position_from_earth(tm, NULL, &sun) == RES_BAD_ARG); - CHK(scem_sun_position_from_earth(tm, &pos, NULL) == RES_BAD_ARG); - CHK(scem_sun_position_from_earth(tm, &pos, &sun) == RES_OK); + CHK(scem_sun_position_from_earth(utc, NULL, &sun) == RES_BAD_ARG); + CHK(scem_sun_position_from_earth(utc, &pos, NULL) == RES_BAD_ARG); + CHK(scem_sun_position_from_earth(utc, &pos, &sun) == RES_OK); + + printf("azimuth: %g°; elevation %g°\n", + MRAD2DEG(sun.azimuth), + MRAD2DEG(sun.zenith)); } /*******************************************************************************