Add gswe_moment_get_aspect_by_planets() function

This commit is contained in:
Gergely Polonkai 2014-05-07 09:32:21 +02:00
parent cef7815268
commit 6566e5356a
3 changed files with 39 additions and 0 deletions

View File

@ -25,6 +25,7 @@ gswe_moment_get_quality_points
gswe_moment_get_moon_phase
gswe_moment_get_all_aspects
gswe_moment_get_planet_aspects
gswe_moment_get_aspect_by_planets
gswe_moment_get_all_antiscia
gswe_moment_get_all_planet_antiscia
gswe_moment_get_axis_all_antiscia

View File

@ -1121,6 +1121,43 @@ gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **e
return ret;
}
/**
* gswe_moment_get_aspect_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
* doesnt 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.
*/
GsweAspectData *
gswe_moment_get_aspect_by_planets(GsweMoment *moment, GswePlanet planet1, GswePlanet planet2, GError **err)
{
struct GsweAspectFinder aspect_finder;
GList *aspect_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 requested planets is not found in the planet list");
return NULL;
}
aspect_finder.planet1 = planet1;
aspect_finder.planet2 = planet2;
if ((aspect_data_element = g_list_find_custom(moment->priv->aspect_list, &aspect_finder, (GCompareFunc)find_aspect_by_both_planets)) != NULL) {
return aspect_data_element->data;
}
return NULL;
}
static gint
find_antiscion_by_both_planets(GsweAntiscionData *antiscion, struct GsweAspectFinder *antiscion_finder)
{

View File

@ -119,6 +119,7 @@ GsweMoonPhaseData *gswe_moment_get_moon_phase(GsweMoment *moment, GError **err);
GList *gswe_moment_get_all_aspects(GsweMoment *moment);
GList *gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **err);
GsweAspectData *gswe_moment_get_aspect_by_planets(GsweMoment *moment, GswePlanet planet1, GswePlanet planet2, GError **err);
GList *gswe_moment_get_all_antiscia(GsweMoment *moment);
GList *gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet, GError **err);