Add gswe_moment_get_antiscion_by_planets() function

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

View File

@ -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
<SUBSECTION Standard>
GSWE_IS_MOMENT
GSWE_IS_MOMENT_CLASS

View File

@ -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
* 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.
*/
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;
}

View File

@ -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__ */