diff --git a/docs/reference/swe-glib/swe-glib-sections.txt b/docs/reference/swe-glib/swe-glib-sections.txt index 306fb27..2d3f871 100644 --- a/docs/reference/swe-glib/swe-glib-sections.txt +++ b/docs/reference/swe-glib/swe-glib-sections.txt @@ -30,6 +30,7 @@ gswe_moment_get_all_antiscia gswe_moment_get_all_planet_antiscia gswe_moment_get_axis_all_antiscia gswe_moment_get_axis_planet_antiscia +gswe_moment_get_antiscion_by_planets GSWE_IS_MOMENT GSWE_IS_MOMENT_CLASS diff --git a/src/gswe-moment.c b/src/gswe-moment.c index 435fd4b..05e16a4 100644 --- a/src/gswe-moment.c +++ b/src/gswe-moment.c @@ -1351,3 +1351,40 @@ gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis, return ret; } +/** + * gswe_moment_get_antiscion_by_planets: + * @moment: the GsweMoment to operate on + * @planet1: the first planet + * @planet2: the second planet + * @err: a #GError + * + * Get the aspect between two given planets. The order of @planet1 and @planet2 + * doesn’t matter. + * + * Returns: (transfer none): a #GsweAspectData containing the aspect data of the + * two planets. If an error occurs, like when one of the planets are + * not added to the planet list, returns NULL, and @err is set + * accordingly. + */ +GsweAntiscionData * +gswe_moment_get_antiscion_by_planets(GsweMoment *moment, GswePlanet planet1, GswePlanet planet2, GError **err) +{ + struct GsweAspectFinder antiscion_finder; + GList *antiscion_data_element; + + if (!gswe_moment_has_planet(moment, planet1) || !gswe_moment_has_planet(moment, planet2)) { + g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "One of the planets is not found in the planet list"); + + return NULL; + } + + antiscion_finder.planet1 = planet1; + antiscion_finder.planet2 = planet2; + + if ((antiscion_data_element = g_list_find_custom(moment->priv->antiscia_list, &antiscion_finder, (GCompareFunc)find_antiscion_by_both_planets)) != NULL) { + return antiscion_data_element->data; + } + + return NULL; +} + diff --git a/src/gswe-moment.h b/src/gswe-moment.h index b366b05..9909cf4 100644 --- a/src/gswe-moment.h +++ b/src/gswe-moment.h @@ -125,6 +125,7 @@ GList *gswe_moment_get_all_antiscia(GsweMoment *moment); GList *gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet, GError **err); GList *gswe_moment_get_axis_all_antiscia(GsweMoment *moment, GsweAntiscionAxis axis); GList *gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis, GswePlanet planet, GError **err); +GsweAntiscionData *gswe_moment_get_antiscion_by_planets(GsweMoment *moment, GswePlanet planet1, GswePlanet planet2, GError **err); #endif /* __GSWE_MOMENT_H__ */