Compare commits
98 Commits
Author | SHA1 | Date | |
---|---|---|---|
cbf2201249 | |||
0326770d73 | |||
a320abc71e | |||
0fb888a940 | |||
b689d3153d | |||
ddf4732dc9 | |||
fd24246bae | |||
2bdd8c3c60 | |||
6009ee908e | |||
2fa75d0906 | |||
41a80ca365 | |||
e23c789ff0 | |||
2a48f402b8 | |||
332110f449 | |||
e8819f9a47 | |||
551ea4cee0 | |||
fa1b4574e4 | |||
bd8c1532e7 | |||
367b777a2d | |||
695f5b96ae | |||
dd803b09f2 | |||
74cc121221 | |||
c4c9e2eced | |||
5f8939d730 | |||
7463b0e5cd | |||
e0893de2d2 | |||
371c123f17 | |||
95f085ea0a | |||
35a8101c91 | |||
70c240b0b3 | |||
c2a0b6bada | |||
cdcf6d1bf5 | |||
f41306a7ab | |||
8bcb9a8389 | |||
7704879c04 | |||
e81df2e4b0 | |||
8ae0c4de71 | |||
acedf464f4 | |||
f3c72120a7 | |||
d261e5ab4f | |||
c5a82b2aae | |||
5dcd5cdd17 | |||
20a350eacc | |||
bd54b5d37a | |||
a224f5ab99 | |||
54698df423 | |||
c78108ce84 | |||
4506e31946 | |||
981c91d702 | |||
2ec9bacf91 | |||
aa9e6db10c | |||
d96671508b | |||
0b15005e3a | |||
6d88993fa3 | |||
dc8146925d | |||
f92caa4e1a | |||
3a06d4bcee | |||
bc9ff2fc09 | |||
27ee3747ad | |||
6b712794c0 | |||
dbee248a6e | |||
7564183aa2 | |||
dcd58b5dd1 | |||
c5d8ee49eb | |||
2dbbd428c1 | |||
8cdcda19f8 | |||
6d84d650b5 | |||
84195964ab | |||
b73ac78f17 | |||
16003cebe9 | |||
8f52abadf0 | |||
a1f8d1f7da | |||
347dae00d3 | |||
5365133de2 | |||
60b51c2ed2 | |||
9ee5569bb1 | |||
20c3aafe85 | |||
39ddb2ee0e | |||
ebeaf1eb4d | |||
886ff03353 | |||
1b0f831333 | |||
e06c73c23d | |||
6ee6650d84 | |||
eb5b3fff5d | |||
d4015cae75 | |||
3fd8c200e0 | |||
9a788f8164 | |||
8044519535 | |||
0e17962278 | |||
14bef9eb06 | |||
4767e7eb98 | |||
54cbcd9bc9 | |||
444c545776 | |||
c395c7f7ea | |||
197f6922c7 | |||
6e96142160 | |||
e7bd73fdc1 | |||
a5a29c7c33 |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -51,6 +51,13 @@ Makefile.in
|
|||||||
/compile
|
/compile
|
||||||
/so_locations
|
/so_locations
|
||||||
|
|
||||||
|
# Testing related files
|
||||||
|
/test-driver
|
||||||
|
/tests/*-test
|
||||||
|
/tests/*-test.log
|
||||||
|
/tests/*-test.trs
|
||||||
|
/tests/test-suite.log
|
||||||
|
|
||||||
# Translation related files
|
# Translation related files
|
||||||
/ABOUT-NLS
|
/ABOUT-NLS
|
||||||
/po/POTFILES
|
/po/POTFILES
|
||||||
@@ -95,7 +102,6 @@ src/gswetest
|
|||||||
/docs/reference/*/*-overrides.txt
|
/docs/reference/*/*-overrides.txt
|
||||||
/docs/reference/*/*-undeclared.txt
|
/docs/reference/*/*-undeclared.txt
|
||||||
/docs/reference/*/version.xml
|
/docs/reference/*/version.xml
|
||||||
/docs/reference/*/*-sections.txt
|
|
||||||
/docs/reference/*/*-undocumented.txt
|
/docs/reference/*/*-undocumented.txt
|
||||||
/docs/reference/*/*-unused.txt
|
/docs/reference/*/*-unused.txt
|
||||||
/docs/reference/*/xml/
|
/docs/reference/*/xml/
|
||||||
|
3
.travis.yml
Normal file
3
.travis.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
language: c
|
||||||
|
install: sudo apt-get install libglib2.0-dev gobject-introspection gnome-common && ./autogen.sh
|
||||||
|
script: ./configure && make && make check
|
@@ -1,5 +1,9 @@
|
|||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
SUBDIRS = swe swe/src swe/doc src po docs/reference/swe-glib data
|
SUBDIRS = swe swe/src swe/doc src po data tests
|
||||||
|
|
||||||
|
if ENABLE_GTK_DOC
|
||||||
|
SUBDIRS += docs/reference/swe-glib
|
||||||
|
endif
|
||||||
|
|
||||||
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
|
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
|
||||||
|
|
||||||
|
13
README.md
13
README.md
@@ -10,17 +10,14 @@ The project utilizes [GTK-Doc](http://www.gtk.org/gtk-doc/), requiring version 1
|
|||||||
|
|
||||||
Still, the documentation generates well, and at least gives a clue about object usage.
|
Still, the documentation generates well, and at least gives a clue about object usage.
|
||||||
|
|
||||||
|
## Bindings
|
||||||
|
|
||||||
|
SWE-GLib utilizes [GObject Introspection](https://wiki.gnome.org/GObjectIntrospection), which means it is available for many languages. Check out the [examples](examples) directory for some sample code!
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Many functions return non-opaque C structs; their documentation can be found inline, and in the generated GTK-Doc. Unless otherwise stated, the returned values should never be freed.
|
Many functions return non-opaque C structs; their documentation can be found inline, and in the generated GTK-Doc. Unless otherwise stated, the returned values should never be freed.
|
||||||
|
|
||||||
### Initialization
|
|
||||||
|
|
||||||
First of all, you have to initialize the library:
|
|
||||||
|
|
||||||
```c
|
|
||||||
gswe_init();
|
|
||||||
```
|
|
||||||
### Creating the required objects
|
### Creating the required objects
|
||||||
|
|
||||||
Then you need to create a `GsweTimestamp` object:
|
Then you need to create a `GsweTimestamp` object:
|
||||||
@@ -90,7 +87,7 @@ The Swiss Ephemeris library requires the altitude value to be specified for seve
|
|||||||
|
|
||||||
## API stability
|
## API stability
|
||||||
|
|
||||||
The project is currently marked as 1.0. This means that API and ABI changes are very unlikely to happen.
|
The project is currently transitioning to 2.0. master is a bit fragile at the moment, 1.x versions are considered to be stable (although see commit 8f52aba about a huge typo-bug).
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
49
autogen.sh
49
autogen.sh
@@ -13,10 +13,49 @@ PKG_NAME="swe-glib"
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
which gnome-autogen.sh || {
|
m4dir=`grep '^AC_CONFIG_MACRO_DIR' configure.ac | sed -n -e 's/AC_CONFIG_MACRO_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`
|
||||||
echo "gnome-autogen.sh not found, you need to install gnome-common"
|
if [ -n "$m4dir" ]; then
|
||||||
exit 1
|
m4dir="-I $m4dir"
|
||||||
}
|
fi
|
||||||
|
|
||||||
REQUIRED_AUTOMAKE_VERSION=1.9 . gnome-autogen.sh
|
echo "Running libtoolize"
|
||||||
|
libtoolize --force --copy || exit $?
|
||||||
|
|
||||||
|
echo "Running autopoint"
|
||||||
|
autopoint --force || exit $?
|
||||||
|
|
||||||
|
echo "Running intltoolize"
|
||||||
|
intltoolize --force --copy --automake || exit $?
|
||||||
|
|
||||||
|
GTKDOCIZE=$(which gtkdocize 2>/dev/null)
|
||||||
|
if test -z $GTKDOCIZE; then
|
||||||
|
echo "You don't have gtk-doc installed, and thus won't be able to generate the documentation."
|
||||||
|
rm -f gtk-doc.make
|
||||||
|
rm -f $m4dir/gtk-doc.m4
|
||||||
|
cat > gtk-doc.make <<EOF
|
||||||
|
EXTRA_DIST =
|
||||||
|
CLEANFILES =
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
echo "Running gtkdocize"
|
||||||
|
gtkdocize --copy || exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running aclocal"
|
||||||
|
aclocal $m4dir $ACLOCAL_FLAGS || exit $?
|
||||||
|
|
||||||
|
echo "Running autoconf"
|
||||||
|
autoconf || exit $?
|
||||||
|
|
||||||
|
if grep "^A[CM]_CONFIG_HEADER" configure.ac >/dev/null; then
|
||||||
|
echo "Running autoheader"
|
||||||
|
autoheader || exit $?
|
||||||
|
# this prevents automake from thinking config.h.in is out of
|
||||||
|
# date, since autoheader doesn't touch the file if it doesn't
|
||||||
|
# change.
|
||||||
|
test -f config.h.in && touch config.h.in
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running automake"
|
||||||
|
automake --gnu --add-missing --copy -Wno-portability || exit $?
|
||||||
|
|
||||||
|
40
configure.ac
40
configure.ac
@@ -1,6 +1,6 @@
|
|||||||
m4_define([swe_glib_major_version], [1])
|
m4_define([swe_glib_major_version], [2])
|
||||||
m4_define([swe_glib_minor_version], [0])
|
m4_define([swe_glib_minor_version], [0])
|
||||||
m4_define([swe_glib_micro_version], [5])
|
m4_define([swe_glib_micro_version], [0])
|
||||||
m4_define([swe_glib_version], [swe_glib_major_version.swe_glib_minor_version.swe_glib_micro_version])
|
m4_define([swe_glib_version], [swe_glib_major_version.swe_glib_minor_version.swe_glib_micro_version])
|
||||||
m4_define([swe_glib_api_version], [swe_glib_major_version.0])
|
m4_define([swe_glib_api_version], [swe_glib_major_version.0])
|
||||||
|
|
||||||
@@ -12,6 +12,12 @@ AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug], [compile with debugging s
|
|||||||
|
|
||||||
if test "x$enable_debug" = "xyes" ; then
|
if test "x$enable_debug" = "xyes" ; then
|
||||||
AC_DEFINE([DEBUG], [1], [Define if debugging is enabled])
|
AC_DEFINE([DEBUG], [1], [Define if debugging is enabled])
|
||||||
|
if test x$cflags_set != xset ; then
|
||||||
|
case " $CFLAGS " in
|
||||||
|
*[[\ \ ]]-g[[\ \ ]]*) ;;
|
||||||
|
*) CFLAGS="$CFLAGS -g" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_SUBST([SWE_GLIB_MAJOR_VERSION], [swe_glib_major_version])
|
AC_SUBST([SWE_GLIB_MAJOR_VERSION], [swe_glib_major_version])
|
||||||
@@ -33,15 +39,30 @@ AM_GNU_GETTEXT([external])
|
|||||||
AM_GNU_GETTEXT_VERSION([0.17])
|
AM_GNU_GETTEXT_VERSION([0.17])
|
||||||
LT_INIT
|
LT_INIT
|
||||||
AC_CHECK_LIB([m], [atan])
|
AC_CHECK_LIB([m], [atan])
|
||||||
|
m4_ifdef([GTK_DOC_CHECK], [
|
||||||
GTK_DOC_CHECK([1.19], [--flavour no-tmpl])
|
GTK_DOC_CHECK([1.19], [--flavour no-tmpl])
|
||||||
|
],[
|
||||||
|
AM_CONDITIONAL([ENABLE_GTK_DOC], false)
|
||||||
|
])
|
||||||
GOBJECT_INTROSPECTION_CHECK([1.0])
|
GOBJECT_INTROSPECTION_CHECK([1.0])
|
||||||
PKG_PROG_PKG_CONFIG
|
PKG_PROG_PKG_CONFIG
|
||||||
AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
|
AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
|
||||||
PKG_CHECK_MODULES([GLIB], [glib-2.0])
|
AC_CANONICAL_HOST
|
||||||
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0])
|
native_win32=no
|
||||||
|
case "$host" in
|
||||||
|
*-*-mingw*)
|
||||||
|
native_win32=yes
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
AM_CONDITIONAL(OS_WIN32, [test "$native_win32" = "yes"])
|
||||||
|
AM_CONDITIONAL(OS_UNIX, [test "$native_win32" != "yes"])
|
||||||
|
AC_PATH_PROG([GTESTER], [gtester])
|
||||||
|
AC_PATH_PROG([GTESTER_REPORT], [gtester-report])
|
||||||
|
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.32.0])
|
||||||
|
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.32.0])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
LIBSWE_LIBS='$(top_builddir)/swe/src/libswe-1.75.la'
|
LIBSWE_LIBS='$(top_builddir)/swe/src/libswe-1.76.la'
|
||||||
AC_SUBST(LIBSWE_LIBS)
|
AC_SUBST(LIBSWE_LIBS)
|
||||||
|
|
||||||
LIBSWE_GLIB_LIBS='$(top_builddir)/src/libswe-glib-$(SWE_GLIB_API_VERSION).la'
|
LIBSWE_GLIB_LIBS='$(top_builddir)/src/libswe-glib-$(SWE_GLIB_API_VERSION).la'
|
||||||
@@ -55,9 +76,14 @@ AC_CONFIG_FILES([
|
|||||||
src/Makefile
|
src/Makefile
|
||||||
data/Makefile
|
data/Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
docs/reference/swe-glib/version.xml
|
tests/Makefile
|
||||||
docs/reference/swe-glib/Makefile
|
|
||||||
data/swe-glib.pc
|
data/swe-glib.pc
|
||||||
data/swe-glib.spec
|
data/swe-glib.spec
|
||||||
])
|
])
|
||||||
|
AM_COND_IF([ENABLE_GTK_DOC], [
|
||||||
|
AC_CONFIG_FILES([
|
||||||
|
docs/reference/swe-glib/version.xml
|
||||||
|
docs/reference/swe-glib/Makefile
|
||||||
|
])
|
||||||
|
])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
@@ -70,9 +70,9 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/locale/hu/LC_MESSAGES/swe-glib.mo
|
|||||||
|
|
||||||
%files
|
%files
|
||||||
%doc ChangeLog
|
%doc ChangeLog
|
||||||
%{_libdir}/libswe-1.75.so.*
|
%{_libdir}/libswe-1.76.so.*
|
||||||
%{_libdir}/libswe-glib-1.0.so.*
|
%{_libdir}/libswe-glib-@SWE_GLIB_API_VERSION@.so.*
|
||||||
%{_libdir}/girepository-1.0/SweGlib-1.0.typelib
|
%{_libdir}/girepository-1.0/SweGlib-@SWE_GLIB_API_VERSION@.typelib
|
||||||
|
|
||||||
%files data
|
%files data
|
||||||
%{_datadir}/swe-glib/*.se1
|
%{_datadir}/swe-glib/*.se1
|
||||||
@@ -83,9 +83,9 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/locale/hu/LC_MESSAGES/swe-glib.mo
|
|||||||
%files devel
|
%files devel
|
||||||
%{_includedir}/*
|
%{_includedir}/*
|
||||||
%{_libdir}/pkgconfig/*
|
%{_libdir}/pkgconfig/*
|
||||||
%{_datadir}/gir-1.0/SweGlib-1.0.gir
|
%{_datadir}/gir-1.0/SweGlib-@SWE_GLIB_API_VERSION@.gir
|
||||||
%{_libdir}/libswe-1.75.so
|
%{_libdir}/libswe-1.76.so
|
||||||
%{_libdir}/libswe-glib-1.0.so
|
%{_libdir}/libswe-glib-@SWE_GLIB_API_VERSION@.so
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ SCANGOBJ_OPTIONS=
|
|||||||
|
|
||||||
# Extra options to supply to gtkdoc-scan.
|
# Extra options to supply to gtkdoc-scan.
|
||||||
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
|
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
|
||||||
SCAN_OPTIONS=--rebuild-sections --rebuild-types
|
SCAN_OPTIONS=--rebuild-types
|
||||||
|
|
||||||
# Extra options to supply to gtkdoc-mkdb.
|
# Extra options to supply to gtkdoc-mkdb.
|
||||||
# e.g. MKDB_OPTIONS=--xml-mode --output-format=xml
|
# e.g. MKDB_OPTIONS=--xml-mode --output-format=xml
|
||||||
@@ -58,7 +58,20 @@ EXTRA_HFILES=
|
|||||||
|
|
||||||
# Header files or dirs to ignore when scanning. Use base file/dir names
|
# Header files or dirs to ignore when scanning. Use base file/dir names
|
||||||
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
|
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
|
||||||
IGNORE_HFILES=swe-glib-private.h gswe-enumtypes.h
|
IGNORE_HFILES = \
|
||||||
|
swe-glib-private.h \
|
||||||
|
gswe-enumtypes.h \
|
||||||
|
gswe-moon-phase-data-private.h \
|
||||||
|
gswe-sign-info-private.h \
|
||||||
|
gswe-planet-info-private.h \
|
||||||
|
gswe-planet-data-private.h \
|
||||||
|
gswe-aspect-info-private.h \
|
||||||
|
gswe-aspect-data-private.h \
|
||||||
|
gswe-antiscion-axis-info-private.h \
|
||||||
|
gswe-antiscion-data-private.h \
|
||||||
|
gswe-house-system-info-private.h \
|
||||||
|
gswe-house-data-private.h \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
# Images to copy into HTML directory.
|
# Images to copy into HTML directory.
|
||||||
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
|
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
|
||||||
@@ -86,12 +99,12 @@ include $(top_srcdir)/gtk-doc.make
|
|||||||
|
|
||||||
# Other files to distribute
|
# Other files to distribute
|
||||||
# e.g. EXTRA_DIST += version.xml.in
|
# e.g. EXTRA_DIST += version.xml.in
|
||||||
EXTRA_DIST +=
|
EXTRA_DIST += version.xml.in
|
||||||
|
|
||||||
# Files not to distribute
|
# Files not to distribute
|
||||||
# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types
|
# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types
|
||||||
# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt
|
# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt
|
||||||
#DISTCLEANFILES +=
|
DISTCLEANFILES = $(DOC_MODULE).types
|
||||||
|
|
||||||
# Comment this out if you want 'make check' to test you doc status
|
# Comment this out if you want 'make check' to test you doc status
|
||||||
# and run some sanity checks
|
# and run some sanity checks
|
||||||
|
@@ -19,6 +19,16 @@
|
|||||||
<chapter>
|
<chapter>
|
||||||
<title>SWE-GLib</title>
|
<title>SWE-GLib</title>
|
||||||
<xi:include href="xml/gswe-types.xml"/>
|
<xi:include href="xml/gswe-types.xml"/>
|
||||||
|
<xi:include href="xml/gswe-sign-info.xml" />
|
||||||
|
<xi:include href="xml/gswe-planet-info.xml" />
|
||||||
|
<xi:include href="xml/gswe-planet-data.xml" />
|
||||||
|
<xi:include href="xml/gswe-moon-phase-data.xml"/>
|
||||||
|
<xi:include href="xml/gswe-aspect-data.xml" />
|
||||||
|
<xi:include href="xml/gswe-aspect-info.xml" />
|
||||||
|
<xi:include href="xml/gswe-antiscion-axis-info.xml" />
|
||||||
|
<xi:include href="xml/gswe-antiscion-data.xml" />
|
||||||
|
<xi:include href="xml/gswe-house-system-info.xml" />
|
||||||
|
<xi:include href="xml/gswe-house-data.xml" />
|
||||||
<xi:include href="xml/swe-glib.xml"/>
|
<xi:include href="xml/swe-glib.xml"/>
|
||||||
<xi:include href="xml/gswe-moment.xml"/>
|
<xi:include href="xml/gswe-moment.xml"/>
|
||||||
<xi:include href="xml/gswe-timestamp.xml"/>
|
<xi:include href="xml/gswe-timestamp.xml"/>
|
||||||
|
299
docs/reference/swe-glib/swe-glib-sections.txt
Normal file
299
docs/reference/swe-glib/swe-glib-sections.txt
Normal file
@@ -0,0 +1,299 @@
|
|||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-moment</FILE>
|
||||||
|
<TITLE>GsweMoment</TITLE>
|
||||||
|
GsweMoment
|
||||||
|
GsweMomentClass
|
||||||
|
gswe_moment_new
|
||||||
|
gswe_moment_new_full
|
||||||
|
gswe_moment_set_timestamp
|
||||||
|
gswe_moment_get_timestamp
|
||||||
|
gswe_moment_set_coordinates
|
||||||
|
gswe_moment_get_coordinates
|
||||||
|
gswe_moment_set_house_system
|
||||||
|
gswe_moment_get_house_system
|
||||||
|
gswe_moment_get_house_cusps
|
||||||
|
gswe_moment_get_house
|
||||||
|
gswe_moment_has_planet
|
||||||
|
gswe_moment_add_planet
|
||||||
|
gswe_moment_add_all_planets
|
||||||
|
gswe_moment_get_all_planets
|
||||||
|
gswe_moment_get_planet
|
||||||
|
gswe_moment_get_sign_planets
|
||||||
|
gswe_moment_get_house_planets
|
||||||
|
gswe_moment_get_element_points
|
||||||
|
gswe_moment_get_quality_points
|
||||||
|
gswe_moment_get_moon_phase
|
||||||
|
gswe_moment_get_all_aspects
|
||||||
|
gswe_moment_get_planet_aspects
|
||||||
|
gswe_moment_get_all_antiscia
|
||||||
|
gswe_moment_get_all_planet_antiscia
|
||||||
|
gswe_moment_get_axis_all_antiscia
|
||||||
|
gswe_moment_get_axis_planet_antiscia
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_IS_MOMENT
|
||||||
|
GSWE_IS_MOMENT_CLASS
|
||||||
|
GSWE_MOMENT
|
||||||
|
GSWE_MOMENT_CLASS
|
||||||
|
GSWE_MOMENT_GET_CLASS
|
||||||
|
GSWE_TYPE_MOMENT
|
||||||
|
GsweMomentPrivate
|
||||||
|
gswe_moment_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-moon-phase-data</FILE>
|
||||||
|
gswe_moon_phase_data_new
|
||||||
|
gswe_moon_phase_data_ref
|
||||||
|
gswe_moon_phase_data_unref
|
||||||
|
gswe_moon_phase_data_calculate_by_timestamp
|
||||||
|
gswe_moon_phase_data_calculate_by_jd
|
||||||
|
gswe_moon_phase_data_get_phase
|
||||||
|
gswe_moon_phase_data_get_illumination
|
||||||
|
GsweMoonPhaseData
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_MOON_PHASE_DATA
|
||||||
|
gswe_moon_phase_data_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-sign-info</FILE>
|
||||||
|
GsweSignInfo
|
||||||
|
gswe_sign_info_new
|
||||||
|
gswe_sign_info_ref
|
||||||
|
gswe_sign_info_unref
|
||||||
|
gswe_sign_info_set_sign
|
||||||
|
gswe_sign_info_get_sign
|
||||||
|
gswe_sign_info_set_name
|
||||||
|
gswe_sign_info_get_name
|
||||||
|
gswe_sign_info_set_element
|
||||||
|
gswe_sign_info_get_element
|
||||||
|
gswe_sign_info_set_quality
|
||||||
|
gswe_sign_info_get_quality
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_SIGN_INFO
|
||||||
|
gswe_sign_info_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-planet-info</FILE>
|
||||||
|
GswePlanetInfo
|
||||||
|
gswe_planet_info_new
|
||||||
|
gswe_planet_info_ref
|
||||||
|
gswe_planet_info_unref
|
||||||
|
gswe_planet_info_set_name
|
||||||
|
gswe_planet_info_get_name
|
||||||
|
gswe_planet_info_set_orb
|
||||||
|
gswe_planet_info_get_orb
|
||||||
|
gswe_planet_info_set_planet
|
||||||
|
gswe_planet_info_get_planet
|
||||||
|
gswe_planet_info_set_points
|
||||||
|
gswe_planet_info_get_points
|
||||||
|
gswe_planet_info_set_real_body
|
||||||
|
gswe_planet_info_get_real_body
|
||||||
|
gswe_planet_info_set_sweph_id
|
||||||
|
gswe_planet_info_get_sweph_id
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_PLANET_INFO
|
||||||
|
gswe_planet_info_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-planet-data</FILE>
|
||||||
|
GswePlanetData
|
||||||
|
gswe_planet_data_new
|
||||||
|
gswe_planet_data_ref
|
||||||
|
gswe_planet_data_unref
|
||||||
|
gswe_planet_data_set_planet
|
||||||
|
gswe_planet_data_get_planet
|
||||||
|
gswe_planet_data_set_planet_info
|
||||||
|
gswe_planet_data_get_planet_info
|
||||||
|
gswe_planet_data_get_position
|
||||||
|
gswe_planet_data_get_retrograde
|
||||||
|
gswe_planet_data_get_house
|
||||||
|
gswe_planet_data_get_sign
|
||||||
|
gswe_planet_data_get_sign_info
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_PLANET_DATA
|
||||||
|
gswe_planet_data_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-aspect-info</FILE>
|
||||||
|
GsweAspectInfo
|
||||||
|
gswe_aspect_info_new
|
||||||
|
gswe_aspect_info_ref
|
||||||
|
gswe_aspect_info_unref
|
||||||
|
gswe_aspect_info_set_aspect
|
||||||
|
gswe_aspect_info_get_aspect
|
||||||
|
gswe_aspect_info_set_name
|
||||||
|
gswe_aspect_info_get_name
|
||||||
|
gswe_aspect_info_set_size
|
||||||
|
gswe_aspect_info_get_size
|
||||||
|
gswe_aspect_info_set_orb_modifier
|
||||||
|
gswe_aspect_info_get_orb_modifier
|
||||||
|
gswe_aspect_info_set_harmonic
|
||||||
|
gswe_aspect_info_get_harmonic
|
||||||
|
gswe_aspect_info_set_major
|
||||||
|
gswe_aspect_info_get_major
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_ASPECT_INFO
|
||||||
|
gswe_aspect_info_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-aspect-data</FILE>
|
||||||
|
GsweAspectData
|
||||||
|
gswe_aspect_data_new
|
||||||
|
gswe_aspect_data_new_with_planets
|
||||||
|
gswe_aspect_data_ref
|
||||||
|
gswe_aspect_data_unref
|
||||||
|
gswe_aspect_data_set_planet1
|
||||||
|
gswe_aspect_data_get_planet1
|
||||||
|
gswe_aspect_data_set_planet2
|
||||||
|
gswe_aspect_data_get_planet2
|
||||||
|
gswe_aspect_data_get_distance
|
||||||
|
gswe_aspect_data_get_aspect
|
||||||
|
gswe_aspect_data_get_aspect_info
|
||||||
|
gswe_aspect_data_get_difference
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_ASPECT_DATA
|
||||||
|
gswe_aspect_data_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-antiscion-axis-info</FILE>
|
||||||
|
GsweAntiscionAxisInfo
|
||||||
|
gswe_antiscion_axis_info_new
|
||||||
|
gswe_antiscion_axis_info_ref
|
||||||
|
gswe_antiscion_axis_info_unref
|
||||||
|
gswe_antiscion_axis_info_set_axis
|
||||||
|
gswe_antiscion_axis_info_get_axis
|
||||||
|
gswe_antiscion_axis_info_set_name
|
||||||
|
gswe_antiscion_axis_info_get_name
|
||||||
|
gswe_antiscion_axis_info_set_sign_offset
|
||||||
|
gswe_antiscion_axis_info_get_sign_offset
|
||||||
|
gswe_antiscion_axis_info_set_start_sign_info
|
||||||
|
gswe_antiscion_axis_info_get_start_sign_info
|
||||||
|
gswe_antiscion_axis_info_set_start_sign
|
||||||
|
gswe_antiscion_axis_info_get_start_sign
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_ANTISCION_AXIS_INFO
|
||||||
|
gswe_antiscion_axis_info_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-antiscion-data</FILE>
|
||||||
|
GsweAntiscionData
|
||||||
|
gswe_antiscion_data_new
|
||||||
|
gswe_antiscion_data_new_with_planets
|
||||||
|
gswe_antiscion_data_ref
|
||||||
|
gswe_antiscion_data_unref
|
||||||
|
gswe_antiscion_data_set_planet1
|
||||||
|
gswe_antiscion_data_get_planet1
|
||||||
|
gswe_antiscion_data_set_planet2
|
||||||
|
gswe_antiscion_data_get_planet2
|
||||||
|
gswe_antiscion_data_calculate
|
||||||
|
gswe_antiscion_data_get_axis
|
||||||
|
gswe_antiscion_data_get_antiscion_axis_info
|
||||||
|
gswe_antiscion_data_get_difference
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_ANTISCION_DATA
|
||||||
|
gswe_antiscion_data_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-house-system-info</FILE>
|
||||||
|
GsweHouseSystemInfo
|
||||||
|
gswe_house_system_info_new
|
||||||
|
gswe_house_system_info_ref
|
||||||
|
gswe_house_system_info_unref
|
||||||
|
gswe_house_system_info_set_house_system
|
||||||
|
gswe_house_system_info_get_house_system
|
||||||
|
gswe_house_system_info_set_sweph_id
|
||||||
|
gswe_house_system_info_get_sweph_id
|
||||||
|
gswe_house_system_info_set_name
|
||||||
|
gswe_house_system_info_get_name
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_HOUSE_SYSTEM_INFO
|
||||||
|
gswe_house_system_info_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-house-data</FILE>
|
||||||
|
GsweHouseData
|
||||||
|
gswe_house_data_new
|
||||||
|
gswe_house_data_ref
|
||||||
|
gswe_house_data_unref
|
||||||
|
gswe_house_data_get_house
|
||||||
|
gswe_house_data_get_cusp_position
|
||||||
|
gswe_house_data_get_sign
|
||||||
|
gswe_house_data_get_sign_info
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_HOUSE_DATA
|
||||||
|
gswe_house_data_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-timestamp</FILE>
|
||||||
|
<TITLE>GsweTimestamp</TITLE>
|
||||||
|
GsweTimestamp
|
||||||
|
GsweTimestampClass
|
||||||
|
gswe_timestamp_new
|
||||||
|
gswe_timestamp_new_from_julian_day
|
||||||
|
gswe_timestamp_new_from_gregorian_full
|
||||||
|
gswe_timestamp_set_gregorian_full
|
||||||
|
gswe_timestamp_set_instant_recalc
|
||||||
|
gswe_timestamp_get_instant_recalc
|
||||||
|
gswe_timestamp_set_gregorian_year
|
||||||
|
gswe_timestamp_get_gregorian_year
|
||||||
|
gswe_timestamp_set_gregorian_month
|
||||||
|
gswe_timestamp_get_gregorian_month
|
||||||
|
gswe_timestamp_set_gregorian_day
|
||||||
|
gswe_timestamp_get_gregorian_day
|
||||||
|
gswe_timestamp_set_gregorian_hour
|
||||||
|
gswe_timestamp_get_gregorian_hour
|
||||||
|
gswe_timestamp_set_gregorian_minute
|
||||||
|
gswe_timestamp_get_gregorian_minute
|
||||||
|
gswe_timestamp_set_gregorian_second
|
||||||
|
gswe_timestamp_get_gregorian_second
|
||||||
|
gswe_timestamp_set_gregorian_microsecond
|
||||||
|
gswe_timestamp_get_gregorian_microsecond
|
||||||
|
gswe_timestamp_set_gregorian_timezone
|
||||||
|
gswe_timestamp_get_gregorian_timezone
|
||||||
|
gswe_timestamp_set_julian_day
|
||||||
|
gswe_timestamp_get_julian_day
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_IS_TIMESTAMP
|
||||||
|
GSWE_IS_TIMESTAMP_CLASS
|
||||||
|
GSWE_TIMESTAMP
|
||||||
|
GSWE_TIMESTAMP_CLASS
|
||||||
|
GSWE_TIMESTAMP_GET_CLASS
|
||||||
|
GSWE_TYPE_TIMESTAMP
|
||||||
|
GsweTimestampPrivate
|
||||||
|
gswe_timestamp_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gswe-types</FILE>
|
||||||
|
GswePlanet
|
||||||
|
GsweZodiac
|
||||||
|
GsweAspect
|
||||||
|
GsweAntiscionAxis
|
||||||
|
GsweElement
|
||||||
|
GsweQuality
|
||||||
|
GsweHouseSystem
|
||||||
|
GsweMoonPhase
|
||||||
|
GsweCoordinates
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GSWE_TYPE_COORDINATES
|
||||||
|
gswe_coordinates_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>swe-glib</FILE>
|
||||||
|
GsweError
|
||||||
|
gswe_error_quark
|
||||||
|
GSWE_ERROR
|
||||||
|
gswe_init
|
||||||
|
</SECTION>
|
||||||
|
|
49
examples/basic.js
Normal file
49
examples/basic.js
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
var Swe = imports.gi.SweGlib;
|
||||||
|
|
||||||
|
Swe.init();
|
||||||
|
|
||||||
|
var timestamp = new Swe.Timestamp();
|
||||||
|
timestamp.set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1);
|
||||||
|
|
||||||
|
var moment = new Swe.Moment();
|
||||||
|
moment.add_all_planets();
|
||||||
|
moment.set_timestamp(timestamp);
|
||||||
|
moment.set_coordinates(19.03990999, 47.49801000, 280);
|
||||||
|
moment.set_house_system(Swe.HouseSystem.PLACIDUS);
|
||||||
|
|
||||||
|
var all_planets = moment.get_all_planets()
|
||||||
|
for (var i = 0; i < all_planets.length; i++) {
|
||||||
|
var planet = all_planets[i];
|
||||||
|
var position = planet.get_position();
|
||||||
|
var sign_position = position % 30;
|
||||||
|
var degree = Math.floor(sign_position);
|
||||||
|
var minute = Math.floor((sign_position - degree) * 60);
|
||||||
|
var second = Math.floor(((sign_position - degree) * 60 - minute) * 60)
|
||||||
|
|
||||||
|
log(planet.get_planet_info().get_name() + ": " + position + " (" + degree + "°" + minute + "′" + second + "″ " + planet.get_sign_info().get_name() + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
var all_aspects = moment.get_all_aspects();
|
||||||
|
for (var i = 0; i < all_aspects.length; i++) {
|
||||||
|
var aspect = all_aspects[i];
|
||||||
|
|
||||||
|
if (aspect.get_aspect() != Swe.Aspect.NONE) {
|
||||||
|
var planet1 = aspect.get_planet1();
|
||||||
|
var planet2 = aspect.get_planet2();
|
||||||
|
|
||||||
|
log(planet1.get_planet_info().get_name() + " in " + aspect.get_aspect_info().get_name() + " with " + planet2.get_planet_info().get_name() + "(±" + aspect.get_difference() + "%)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var all_antiscia = moment.get_all_antiscia();
|
||||||
|
for (var i = 0; i < all_antiscia.length; i++) {
|
||||||
|
var antiscion = all_antiscia[i];
|
||||||
|
|
||||||
|
if (antiscion.get_axis() != Swe.AntiscionAxis.NONE) {
|
||||||
|
var planet1 = antiscion.get_planet1();
|
||||||
|
var planet2 = antiscion.get_planet2();
|
||||||
|
|
||||||
|
log(planet1.get_planet_info().get_name() + " is antiscion of " + planet2.get_planet_info().get_name() + " on axis " + antiscion.get_antiscion_axis_info().get_name() + " (±" + antiscion.get_difference() + "%)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
54
examples/basic.pl
Normal file
54
examples/basic.pl
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package SweGlib;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use POSIX;
|
||||||
|
use Glib::Object::Introspection;
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
Glib::Object::Introspection->setup(basename => 'SweGlib', version => '2.0', package => 'SweGlib');
|
||||||
|
|
||||||
|
package main;
|
||||||
|
|
||||||
|
SweGlib::init();
|
||||||
|
|
||||||
|
my $timestamp = SweGlib::Timestamp->new();
|
||||||
|
$timestamp->set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1);
|
||||||
|
|
||||||
|
my $moment = SweGlib::Moment->new();
|
||||||
|
$moment->set_timestamp($timestamp);
|
||||||
|
$moment->set_coordinates(19.0390999, 47.49801000, 280);
|
||||||
|
$moment->set_house_system("placidus");
|
||||||
|
$moment->add_all_planets();
|
||||||
|
|
||||||
|
my $all_planets = $moment->get_all_planets();
|
||||||
|
foreach my $planet (@{$all_planets}) {
|
||||||
|
my $position = $planet->get_position();
|
||||||
|
my $sign_position = POSIX::fmod($position, 30);
|
||||||
|
my $degree = POSIX::floor($sign_position);
|
||||||
|
my $minute = POSIX::floor(($sign_position - $degree) * 60);
|
||||||
|
my $second = POSIX::floor((($sign_position - $degree) * 60 - $minute) * 60);
|
||||||
|
|
||||||
|
printf("%s: %f (%d°%d′%d″ %s)\n", $planet->get_planet_info()->get_name(), $position, $degree, $minute, $second, $planet->get_sign_info()->get_name());
|
||||||
|
}
|
||||||
|
|
||||||
|
my $all_aspects = $moment->get_all_aspects();
|
||||||
|
foreach my $aspect (@{$all_aspects}) {
|
||||||
|
if ($aspect->get_aspect() ne "none") {
|
||||||
|
my $planet1 = $aspect->get_planet1();
|
||||||
|
my $planet2 = $aspect->get_planet2();
|
||||||
|
|
||||||
|
printf("%s in %s with %s (±%.2f%%)\n", $planet1->get_planet_info()->get_name(), $aspect->get_aspect_info->get_name(), $planet2->get_planet_info()->get_name(), $aspect->get_difference());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $all_antiscia = $moment->get_all_antiscia();
|
||||||
|
foreach my $antiscion (@{$all_antiscia}) {
|
||||||
|
if ($antiscion->get_axis() ne "none") {
|
||||||
|
my $planet1 = $antiscion->get_planet1();
|
||||||
|
my $planet2 = $antiscion->get_planet2();
|
||||||
|
|
||||||
|
printf("%s is antiscion of %s on axis %s (±%.2f%%)\n", $planet1->get_planet_info()->get_name(), $planet2->get_planet_info()->get_name(), $antiscion->get_antiscion_axis_info()->get_name(), $antiscion->get_difference());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
41
examples/basic.py
Normal file
41
examples/basic.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from gi.repository import SweGlib
|
||||||
|
import math
|
||||||
|
|
||||||
|
SweGlib.init()
|
||||||
|
|
||||||
|
timestamp = SweGlib.Timestamp()
|
||||||
|
timestamp.set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1)
|
||||||
|
|
||||||
|
moment = SweGlib.Moment()
|
||||||
|
moment.set_timestamp(timestamp)
|
||||||
|
moment.set_coordinates(19.03990999, 47.49801000, 280)
|
||||||
|
moment.set_house_system(SweGlib.HouseSystem.PLACIDUS)
|
||||||
|
moment.add_all_planets()
|
||||||
|
|
||||||
|
all_planets = moment.get_all_planets()
|
||||||
|
for planet in all_planets:
|
||||||
|
position = planet.get_position()
|
||||||
|
sign_position = position % 30
|
||||||
|
degree = math.floor(sign_position)
|
||||||
|
minute = math.floor((sign_position - degree) * 60)
|
||||||
|
second = math.floor(((sign_position - degree) * 60 - minute) * 60)
|
||||||
|
|
||||||
|
print u"%s: %f (%d°%d′%d″ %s)" % (planet.get_planet_info().get_name(), position, degree, minute, second, planet.get_sign_info().get_name())
|
||||||
|
|
||||||
|
all_aspects = moment.get_all_aspects()
|
||||||
|
for aspect in all_aspects:
|
||||||
|
if aspect.get_aspect() != SweGlib.Aspect.NONE:
|
||||||
|
planet1 = aspect.get_planet1()
|
||||||
|
planet2 = aspect.get_planet2()
|
||||||
|
|
||||||
|
print u"%s in %s with %s (±%.2f%%)" % (planet1.get_planet_info().get_name(), aspect.get_aspect_info().get_name(), planet2.get_planet_info().get_name(), aspect.get_difference())
|
||||||
|
|
||||||
|
all_antiscia = moment.get_all_antiscia()
|
||||||
|
for antiscion in all_antiscia:
|
||||||
|
if antiscion.get_axis() != SweGlib.AntiscionAxis.NONE:
|
||||||
|
planet1 = antiscion.get_planet1()
|
||||||
|
planet2 = antiscion.get_planet2()
|
||||||
|
|
||||||
|
print "%s is antiscion of %s on axis %s (±%.2f%%)" % (planet1.get_planet_info().get_name(), planet2.get_planet_info().get_name(), antiscion.get_antiscion_axis_info().get_name(), antiscion.get_difference())
|
||||||
|
|
2
po/hu.po
2
po/hu.po
@@ -86,7 +86,7 @@ msgid "Dark Moon"
|
|||||||
msgstr "Sötét Hold"
|
msgstr "Sötét Hold"
|
||||||
|
|
||||||
#: ../src/swe-glib.c:133
|
#: ../src/swe-glib.c:133
|
||||||
msgid "Ascendent"
|
msgid "Ascendant"
|
||||||
msgstr "Aszcendens"
|
msgstr "Aszcendens"
|
||||||
|
|
||||||
#: ../src/swe-glib.c:134
|
#: ../src/swe-glib.c:134
|
||||||
|
@@ -1,49 +1,85 @@
|
|||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
AM_CPPFLAGS = -DG_LOG_DOMAIN=\"SWE-GLib\" -DLOCALEDIR=\"$(localedir)\" -D__SWE_GLIB_BUILDING__ -DPKGDATADIR=\"$(pkgdatadir)\"
|
AM_CPPFLAGS = -DG_LOG_DOMAIN=\"SWE-GLib\" -DLOCALEDIR=\"$(localedir)\" -D__SWE_GLIB_BUILDING__ -DPKGDATADIR=\"$(pkgdatadir)\"
|
||||||
|
|
||||||
lib_LTLIBRARIES = libswe-glib-1.0.la
|
lib_LTLIBRARIES = libswe-glib-2.0.la
|
||||||
|
|
||||||
INST_H_SRC_FILES = \
|
INST_H_SRC_FILES = \
|
||||||
swe-glib.h \
|
swe-glib.h \
|
||||||
gswe-types.h \
|
gswe-types.h \
|
||||||
gswe-moment.h \
|
gswe-moon-phase-data.h \
|
||||||
gswe-timestamp.h
|
gswe-sign-info.h \
|
||||||
|
gswe-planet-info.h \
|
||||||
|
gswe-planet-data.h \
|
||||||
|
gswe-aspect-info.h \
|
||||||
|
gswe-aspect-data.h \
|
||||||
|
gswe-antiscion-axis-info.h \
|
||||||
|
gswe-antiscion-data.h \
|
||||||
|
gswe-house-system-info.h \
|
||||||
|
gswe-house-data.h \
|
||||||
|
gswe-moment.h \
|
||||||
|
gswe-timestamp.h \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
INST_H_BUILT_FILES = \
|
INST_H_BUILT_FILES = \
|
||||||
gswe-enumtypes.h
|
gswe-enumtypes.h
|
||||||
|
|
||||||
gswe_headers = gswe-timestamp.h gswe-types.h
|
PRIV_H_SRC_FILES = \
|
||||||
|
swe-glib-private.h \
|
||||||
libswe_glib_1_0_la_SOURCES = \
|
gswe-moon-phase-data-private.h \
|
||||||
swe-glib.c \
|
gswe-sign-info-private.h \
|
||||||
gswe-types.c \
|
gswe-planet-info-private.h \
|
||||||
gswe-moment.c \
|
gswe-planet-data-private.h \
|
||||||
gswe-timestamp.c \
|
gswe-aspect-info-private.h \
|
||||||
gswe-enumtypes.c \
|
gswe-aspect-data-private.h \
|
||||||
|
gswe-antiscion-axis-info-private.h \
|
||||||
|
gswe-antiscion-data-private.h \
|
||||||
|
gswe-house-system-info-private.h \
|
||||||
|
gswe-house-data-private.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
libswe_glib_1_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall
|
|
||||||
libswe_glib_1_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) $(LIBSWE_LIBS)
|
gswe_enum_headers = gswe-timestamp.h gswe-types.h
|
||||||
|
|
||||||
|
libswe_glib_2_0_la_SOURCES = \
|
||||||
|
swe-glib.c \
|
||||||
|
gswe-types.c \
|
||||||
|
gswe-moon-phase-data.c \
|
||||||
|
gswe-sign-info.c \
|
||||||
|
gswe-planet-info.c \
|
||||||
|
gswe-planet-data.c \
|
||||||
|
gswe-aspect-info.c \
|
||||||
|
gswe-aspect-data.c \
|
||||||
|
gswe-antiscion-axis-info.c \
|
||||||
|
gswe-antiscion-data.c \
|
||||||
|
gswe-house-system-info.c \
|
||||||
|
gswe-house-data.c \
|
||||||
|
gswe-moment.c \
|
||||||
|
gswe-timestamp.c \
|
||||||
|
gswe-enumtypes.c \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
libswe_glib_2_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall
|
||||||
|
libswe_glib_2_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) $(LIBSWE_LIBS)
|
||||||
|
|
||||||
BUILT_SOURCES = gswe-enumtypes.c gswe-enumtypes.h
|
BUILT_SOURCES = gswe-enumtypes.c gswe-enumtypes.h
|
||||||
|
|
||||||
CLEANFILES = $(BUILT_SOURCES)
|
CLEANFILES = $(BUILT_SOURCES)
|
||||||
|
|
||||||
EXTRA_DIST = gswe-enumtypes.h.template gswe-enumtypes.c.template swe-glib-private.h $(INST_H_SRC_FILES)
|
EXTRA_DIST = gswe-enumtypes.h.template gswe-enumtypes.c.template $(PRIV_H_SRC_FILES) $(INST_H_SRC_FILES)
|
||||||
|
|
||||||
gswe-enumtypes.h: $(gswe_headers) gswe-enumtypes.h.template
|
gswe-enumtypes.h: $(gswe_enum_headers) gswe-enumtypes.h.template
|
||||||
$(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
|
$(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
|
||||||
gswe-enumtypes.h.tmp && mv gswe-enumtypes.h.tmp gswe-enumtypes.h
|
gswe-enumtypes.h.tmp && mv gswe-enumtypes.h.tmp gswe-enumtypes.h
|
||||||
|
|
||||||
gswe-enumtypes.c: $(gswe_headers) gswe-enumtypes.h gswe-enumtypes.c.template
|
gswe-enumtypes.c: $(gswe_enum_headers) gswe-enumtypes.h gswe-enumtypes.c.template
|
||||||
$(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
|
$(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
|
||||||
gswe-enumtypes.c.tmp && mv gswe-enumtypes.c.tmp gswe-enumtypes.c
|
gswe-enumtypes.c.tmp && mv gswe-enumtypes.c.tmp gswe-enumtypes.c
|
||||||
|
|
||||||
if HAVE_INTROSPECTION
|
if HAVE_INTROSPECTION
|
||||||
|
|
||||||
include $(INTROSPECTION_MAKEFILE)
|
include $(INTROSPECTION_MAKEFILE)
|
||||||
SweGlib-$(SWE_GLIB_API_VERSION).gir: libswe-glib-1.0.la
|
SweGlib-$(SWE_GLIB_API_VERSION).gir: libswe-glib-2.0.la
|
||||||
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_FILES = $(INST_H_SRC_FILES) $(INST_H_BUILT_FILES) $(filter %.c,$(libswe_glib_1_0_la_SOURCES))
|
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_FILES = $(INST_H_SRC_FILES) $(INST_H_BUILT_FILES) $(filter %.c,$(libswe_glib_2_0_la_SOURCES))
|
||||||
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_LIBS = libswe-glib-1.0.la
|
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_LIBS = libswe-glib-2.0.la
|
||||||
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_SCANNERFLAGS = --identifier-prefix=Gswe --symbol-prefix=gswe --warn-all
|
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_SCANNERFLAGS = --identifier-prefix=Gswe --symbol-prefix=gswe --warn-all
|
||||||
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_INCLUDES = GLib-2.0 GObject-2.0
|
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_INCLUDES = GLib-2.0 GObject-2.0
|
||||||
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_CFLAGS = -D__SWE_GLIB_BUILDING__ -I$(top_srcdir) -I$(srcdir) -I$(builddir)
|
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_CFLAGS = -D__SWE_GLIB_BUILDING__ -I$(top_srcdir) -I$(srcdir) -I$(builddir)
|
||||||
@@ -57,15 +93,11 @@ typelibsdir = $(libdir)/girepository-1.0
|
|||||||
typelibs_DATA = SweGlib-$(SWE_GLIB_API_VERSION).typelib
|
typelibs_DATA = SweGlib-$(SWE_GLIB_API_VERSION).typelib
|
||||||
|
|
||||||
headerdir = $(includedir)/swe-glib
|
headerdir = $(includedir)/swe-glib
|
||||||
header_DATA = \
|
header_DATA = \
|
||||||
swe-glib.h \
|
$(INST_H_SRC_FILES) \
|
||||||
gswe-types.h \
|
$(INST_H_BUILT_FILES) \
|
||||||
gswe-enumtypes.h \
|
|
||||||
gswe-moment.h \
|
|
||||||
gswe-timestamp.h \
|
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
||||||
CLEANFILES += $(gir_DATA) $(typelibs_DATA)
|
CLEANFILES += $(gir_DATA) $(typelibs_DATA)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
46
src/gswe-antiscion-axis-info-private.h
Normal file
46
src/gswe-antiscion-axis-info-private.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/* gswe-antiscion-axis-info-private.h: Private parts of GsweAntiscionAxisInfo
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifdef __SWE_GLIB_BUILDING__
|
||||||
|
#ifndef __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_PRIVATE_H__
|
||||||
|
#define __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-antiscion-axis-info.h"
|
||||||
|
|
||||||
|
struct _GsweAntiscionAxisInfo {
|
||||||
|
/* the identifier of this mirror's axis */
|
||||||
|
GsweAntiscionAxis axis;
|
||||||
|
|
||||||
|
/* represents the sign in whict the mirror axis starts */
|
||||||
|
GsweSignInfo *start_sign;
|
||||||
|
|
||||||
|
/* the name of the mirror */
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
/* if TRUE, the axis runs through the middle of its starting sign */
|
||||||
|
gdouble sign_offset;
|
||||||
|
|
||||||
|
/* Reference counter */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_PRIVATE_H__ */
|
||||||
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
#endif /* __SWE_GLIB_BUILDING__ */
|
||||||
|
|
261
src/gswe-antiscion-axis-info.c
Normal file
261
src/gswe-antiscion-axis-info.c
Normal file
@@ -0,0 +1,261 @@
|
|||||||
|
/* gswe-antiscion-axis-info.c: Antiscion axis related information
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "swe-glib.h"
|
||||||
|
#include "swe-glib-private.h"
|
||||||
|
#include "gswe-antiscion-axis-info.h"
|
||||||
|
#include "gswe-antiscion-axis-info-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gswe-antiscion-axis-info
|
||||||
|
* @short_description: a structure storing information about antiscion axes
|
||||||
|
* @title: GsweAntiscionAxisInfo
|
||||||
|
* @stability: Stable
|
||||||
|
* @include: swe-glib.h
|
||||||
|
*
|
||||||
|
* The #GsweAntiscionAxisInfo stores information about an antiscion axis.
|
||||||
|
*/
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE(GsweAntiscionAxisInfo, gswe_antiscion_axis_info, (GBoxedCopyFunc)gswe_antiscion_axis_info_ref, (GBoxedFreeFunc)gswe_antiscion_axis_info_unref);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gswe_antiscion_axis_info_free(GsweAntiscionAxisInfo *antiscion_axis_info)
|
||||||
|
{
|
||||||
|
if (antiscion_axis_info->name) {
|
||||||
|
g_free(antiscion_axis_info->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (antiscion_axis_info->start_sign != NULL) {
|
||||||
|
gswe_sign_info_unref(antiscion_axis_info->start_sign);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(antiscion_axis_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_new:
|
||||||
|
*
|
||||||
|
* Creates a new #GsweAntiscionAxisInfo object with reference count set to 1.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweAntiscionAxisInfo
|
||||||
|
*/
|
||||||
|
GsweAntiscionAxisInfo *
|
||||||
|
gswe_antiscion_axis_info_new(void)
|
||||||
|
{
|
||||||
|
GsweAntiscionAxisInfo *ret;
|
||||||
|
|
||||||
|
ret = g_new0(GsweAntiscionAxisInfo, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_ref:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
*
|
||||||
|
* Increases reference count on @antiscion_axis_info.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GsweAntiscionAxisInfo
|
||||||
|
*/
|
||||||
|
GsweAntiscionAxisInfo *
|
||||||
|
gswe_antiscion_axis_info_ref(GsweAntiscionAxisInfo *antiscion_axis_info)
|
||||||
|
{
|
||||||
|
antiscion_axis_info->refcount++;
|
||||||
|
|
||||||
|
return antiscion_axis_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_unref:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
*
|
||||||
|
* Decreases reference count on @antiscion_axis_info. If reference count reaches zero, @antiscion_axis_info is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_axis_info_unref(GsweAntiscionAxisInfo *antiscion_axis_info)
|
||||||
|
{
|
||||||
|
if (--antiscion_axis_info->refcount == 0) {
|
||||||
|
gswe_antiscion_axis_info_free(antiscion_axis_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_set_axis:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
* @axis: the new axis
|
||||||
|
*
|
||||||
|
* Sets the axis ID.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_axis_info_set_axis(GsweAntiscionAxisInfo *antiscion_axis_info, GsweAntiscionAxis axis)
|
||||||
|
{
|
||||||
|
antiscion_axis_info->axis = axis;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_get_axis:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
*
|
||||||
|
* Gets the axis ID.
|
||||||
|
*
|
||||||
|
* Returns: the axis this #GsweAntiscionAxisInfo represents
|
||||||
|
*/
|
||||||
|
GsweAntiscionAxis
|
||||||
|
gswe_antiscion_axis_info_get_axis(GsweAntiscionAxisInfo *antiscion_axis_info)
|
||||||
|
{
|
||||||
|
return antiscion_axis_info->axis;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_set_start_sign_info:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
* @sign_info: a #GsweSignInfo to set as the starting sign of @antiscion_axis_info
|
||||||
|
*
|
||||||
|
* Sets the starting sign of the axis.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_axis_info_set_start_sign_info(GsweAntiscionAxisInfo *antiscion_axis_info, GsweSignInfo *sign_info)
|
||||||
|
{
|
||||||
|
if (antiscion_axis_info->start_sign != NULL) {
|
||||||
|
gswe_sign_info_unref(antiscion_axis_info->start_sign);
|
||||||
|
}
|
||||||
|
|
||||||
|
antiscion_axis_info->start_sign = gswe_sign_info_ref(sign_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_get_start_sign_info:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
*
|
||||||
|
* Gets the starting sign of the axis.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the #GsweSignInfo of the sign in which this axis starts
|
||||||
|
*/
|
||||||
|
GsweSignInfo *
|
||||||
|
gswe_antiscion_axis_info_get_start_sign_info(GsweAntiscionAxisInfo *antiscion_axis_info)
|
||||||
|
{
|
||||||
|
return antiscion_axis_info->start_sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_set_start_sign:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
* @sign: the new starting sign of @antiscion_axis_info
|
||||||
|
* @err: a #GError
|
||||||
|
*
|
||||||
|
* Sets the starting sign of the axis. Unlike
|
||||||
|
* gswe_antiscion_axis_info_set_start_sign(), this method searches through the
|
||||||
|
* registered signs for a #GsweSignInfo record, and sets that as the starting
|
||||||
|
* sign. @err is populated with GSWE_ERROR_UNKNOWN_SIGN if such record can not
|
||||||
|
* be found.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_axis_info_set_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info, GsweZodiac sign, GError **err)
|
||||||
|
{
|
||||||
|
GsweSignInfo *sign_info;
|
||||||
|
|
||||||
|
if ((sign_info = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER(sign))) == NULL) {
|
||||||
|
g_warning("Trying to fetch an unregistered sign");
|
||||||
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, "The requested sign is not registered");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (antiscion_axis_info->start_sign != NULL) {
|
||||||
|
gswe_sign_info_unref(antiscion_axis_info->start_sign);
|
||||||
|
}
|
||||||
|
|
||||||
|
antiscion_axis_info->start_sign = gswe_sign_info_ref(sign_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_get_start_sign:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
*
|
||||||
|
* Gets the starting sign of the axis.
|
||||||
|
*
|
||||||
|
* Returns: the corresponding sign ID
|
||||||
|
*/
|
||||||
|
GsweZodiac
|
||||||
|
gswe_antiscion_axis_info_get_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info)
|
||||||
|
{
|
||||||
|
if (antiscion_axis_info->start_sign) {
|
||||||
|
return antiscion_axis_info->start_sign->sign;
|
||||||
|
} else {
|
||||||
|
return GSWE_SIGN_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_set_name:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
* @name: the new name of the axis
|
||||||
|
*
|
||||||
|
* Sets the name of the axis
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_axis_info_set_name(GsweAntiscionAxisInfo *antiscion_axis_info, const gchar *name)
|
||||||
|
{
|
||||||
|
if (antiscion_axis_info->name != NULL) {
|
||||||
|
g_free(antiscion_axis_info->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
antiscion_axis_info->name = g_strdup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_get_name:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
*
|
||||||
|
* Gets the name of the axis.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the name of the axis
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
gswe_antiscion_axis_info_get_name(GsweAntiscionAxisInfo *antiscion_axis_info)
|
||||||
|
{
|
||||||
|
return antiscion_axis_info->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_set_sign_offset:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
* @sign_offset: the new sign offset, in degree
|
||||||
|
*
|
||||||
|
* Sets the offset at which the axis starts.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_axis_info_set_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info, gdouble sign_offset)
|
||||||
|
{
|
||||||
|
antiscion_axis_info->sign_offset = sign_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_axis_info_get_sign_offset:
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
*
|
||||||
|
* Gets the offset at which the axis starts.
|
||||||
|
*
|
||||||
|
* Returns: the offset, in degrees
|
||||||
|
*/
|
||||||
|
gdouble
|
||||||
|
gswe_antiscion_axis_info_get_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info)
|
||||||
|
{
|
||||||
|
return antiscion_axis_info->sign_offset;
|
||||||
|
}
|
||||||
|
|
64
src/gswe-antiscion-axis-info.h
Normal file
64
src/gswe-antiscion-axis-info.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/* gswe-antiscion-axis-info.h: Antiscion axis related information
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_H__
|
||||||
|
#define __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-sign-info.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GsweAntiscionAxisInfo:
|
||||||
|
*
|
||||||
|
* <structname>GsweAntiscionAxisInfo</structname> is an opaque structure whose members
|
||||||
|
* cannot be accessed directly.
|
||||||
|
*
|
||||||
|
* Since: 1.1
|
||||||
|
*/
|
||||||
|
typedef struct _GsweAntiscionAxisInfo GsweAntiscionAxisInfo;
|
||||||
|
|
||||||
|
GType gswe_antiscion_axis_info_get_type(void);
|
||||||
|
#define GSWE_TYPE_ANTISCION_AXIS_INFO (gswe_antiscion_axis_info_get_type())
|
||||||
|
|
||||||
|
GsweAntiscionAxisInfo *gswe_antiscion_axis_info_new(void);
|
||||||
|
|
||||||
|
GsweAntiscionAxisInfo *gswe_antiscion_axis_info_ref(GsweAntiscionAxisInfo *antiscion_axis_info);
|
||||||
|
void gswe_antiscion_axis_info_unref(GsweAntiscionAxisInfo *antiscion_axis_info);
|
||||||
|
|
||||||
|
void gswe_antiscion_axis_info_set_axis(GsweAntiscionAxisInfo *antiscion_axis_info, GsweAntiscionAxis axis);
|
||||||
|
GsweAntiscionAxis gswe_antiscion_axis_info_get_axis(GsweAntiscionAxisInfo *antiscion_axis_info);
|
||||||
|
|
||||||
|
void gswe_antiscion_axis_info_set_start_sign_info(GsweAntiscionAxisInfo *antiscion_axis_info, GsweSignInfo *sign_info);
|
||||||
|
GsweSignInfo *gswe_antiscion_axis_info_get_start_sign_info(GsweAntiscionAxisInfo *antiscion_axis_info);
|
||||||
|
|
||||||
|
void gswe_antiscion_axis_info_set_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info, GsweZodiac sign, GError **err);
|
||||||
|
GsweZodiac gswe_antiscion_axis_info_get_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info);
|
||||||
|
|
||||||
|
void gswe_antiscion_axis_info_set_name(GsweAntiscionAxisInfo *antiscion_axis_info, const gchar *name);
|
||||||
|
const gchar *gswe_antiscion_axis_info_get_name(GsweAntiscionAxisInfo *antiscion_axis_info);
|
||||||
|
|
||||||
|
void gswe_antiscion_axis_info_set_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info, gdouble sign_offset);
|
||||||
|
gdouble gswe_antiscion_axis_info_get_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_ANTISCION_AXIS_INFO_H__ */
|
||||||
|
|
47
src/gswe-antiscion-data-private.h
Normal file
47
src/gswe-antiscion-data-private.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/* gswe-antiscion-data-private.h: Private parts of GsweAntiscionData
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifdef __SWE_GLIB_BUILDING__
|
||||||
|
#ifndef __SWE_GLIB_GSWE_ANTISCION_DATA_PRIVATE_H__
|
||||||
|
#define __SWE_GLIB_GSWE_ANTISCION_DATA_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gswe-planet-data.h"
|
||||||
|
|
||||||
|
#include "gswe-antiscion-data.h"
|
||||||
|
|
||||||
|
struct _GsweAntiscionData {
|
||||||
|
/* the first planet in the antiscion */
|
||||||
|
GswePlanetData *planet1;
|
||||||
|
|
||||||
|
/* the second planet in the antiscion */
|
||||||
|
GswePlanetData *planet2;
|
||||||
|
|
||||||
|
/* the #GsweAntiscionAxisInfo structure associated with this antiscion */
|
||||||
|
GsweAntiscionAxisInfo *antiscion_axis_info;
|
||||||
|
|
||||||
|
/* the difference in degrees between an exact antiscion and this given antiscion */
|
||||||
|
gdouble difference;
|
||||||
|
|
||||||
|
/* reference count */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_ANTISCION_DATA_PRIVATE_H__ */
|
||||||
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
#endif /* __SWE_GLIB_BUILDING__ */
|
||||||
|
|
366
src/gswe-antiscion-data.c
Normal file
366
src/gswe-antiscion-data.c
Normal file
@@ -0,0 +1,366 @@
|
|||||||
|
/* gswe-antiscion-data.c: Antiscia related data
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <math.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "swe-glib-private.h"
|
||||||
|
#include "swe-glib.h"
|
||||||
|
#include "gswe-antiscion-data.h"
|
||||||
|
#include "gswe-antiscion-data-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gswe-antiscion-data
|
||||||
|
* @short_description: a structure representing a planet's position-related data
|
||||||
|
* @title: GsweAntiscionData
|
||||||
|
* @stability: Stable
|
||||||
|
* @include: swe-glib.h
|
||||||
|
* @see_also: #GsweAntiscionAxisInfo
|
||||||
|
*
|
||||||
|
* #GsweAntiscionData is a structure that represents an antiscion relationship
|
||||||
|
* between two planets, based on a specified axis.
|
||||||
|
*/
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE(GsweAntiscionData, gswe_antiscion_data, (GBoxedCopyFunc)gswe_antiscion_data_ref, (GBoxedFreeFunc)gswe_antiscion_data_unref);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gswe_antiscion_data_free(GsweAntiscionData *antiscion_data)
|
||||||
|
{
|
||||||
|
if (antiscion_data->planet1) {
|
||||||
|
gswe_planet_data_unref(antiscion_data->planet1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (antiscion_data->planet2) {
|
||||||
|
gswe_planet_data_unref(antiscion_data->planet2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (antiscion_data->antiscion_axis_info) {
|
||||||
|
gswe_antiscion_axis_info_unref(antiscion_data->antiscion_axis_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_new:
|
||||||
|
*
|
||||||
|
* Creates a new #GsweAntiscionData object with reference count set to 1.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweAntiscionData object
|
||||||
|
*/
|
||||||
|
GsweAntiscionData *
|
||||||
|
gswe_antiscion_data_new(void)
|
||||||
|
{
|
||||||
|
GsweAntiscionData *ret;
|
||||||
|
|
||||||
|
ret = g_new0(GsweAntiscionData, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* find_antiscion:
|
||||||
|
* @axis_p: a pointer made with GINT_TO_POINTER(), holding the antiscion axis ID
|
||||||
|
* @antiscion_axis_info: a GsweAntiscionAxisInfo, which will be checked against @antiscion_data
|
||||||
|
* @antiscion_data: a GsweAntiscionData, whose planets' positions will be checked against @antiscion_axis_info
|
||||||
|
*
|
||||||
|
* This function is called internally by gswe_antiscion_data_calculate() to
|
||||||
|
* check if the two planets in @antiscion_data are antiscia of each other on
|
||||||
|
* the axis in @antiscion_axis_info
|
||||||
|
*/
|
||||||
|
static gboolean
|
||||||
|
find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_axis_info, GsweAntiscionData *antiscion_data)
|
||||||
|
{
|
||||||
|
GsweAntiscionAxis axis;
|
||||||
|
gdouble start_point,
|
||||||
|
axis_position,
|
||||||
|
planet_orb;
|
||||||
|
|
||||||
|
if ((axis = GPOINTER_TO_INT(axis_p)) == GSWE_ANTISCION_AXIS_NONE) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
planet_orb = fmin(antiscion_data->planet1->planet_info->orb, antiscion_data->planet2->planet_info->orb);
|
||||||
|
start_point = (antiscion_axis_info->start_sign->sign - 1) * 30.0;
|
||||||
|
|
||||||
|
start_point += antiscion_axis_info->sign_offset;
|
||||||
|
|
||||||
|
axis_position = 2 * start_point - antiscion_data->planet1->position;
|
||||||
|
|
||||||
|
if (axis_position < 0) {
|
||||||
|
axis_position += 360.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((antiscion_data->difference = fabs(antiscion_data->planet2->position - axis_position)) <= planet_orb) {
|
||||||
|
antiscion_data->antiscion_axis_info = antiscion_axis_info;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
antiscion_data->difference = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_calculate:
|
||||||
|
* @antiscion_data: a #GsweAntiscionData
|
||||||
|
*
|
||||||
|
* Calculates the antiscion between the planets set in @antiscion_data. Planets
|
||||||
|
* can be set either by calling gswe_antiscion_data_set_planet1() and
|
||||||
|
* gswe_antiscion_data_set_planet2(), or by creating the #GsweAntiscionData
|
||||||
|
* with gswe_antiscion_data_new_with_planets().
|
||||||
|
*
|
||||||
|
* <note><para>If the object is created by
|
||||||
|
* gswe_antiscion_data_new_with_planets(), or when both planets are set by
|
||||||
|
* calling gswe_antiscion_data_set_planet1() and
|
||||||
|
* gswe_antiscion_data_set_planet2(), the antiscion information is
|
||||||
|
* automatically calculated. However, when either planet's data changes, the
|
||||||
|
* antiscion data is not calculated automatically, so if you expect the planets
|
||||||
|
* to get a new position (e.g. the #GsweTimestamp changes in a #GsweMoment
|
||||||
|
* which holds the @antiscion_data, in which case the planet positions are
|
||||||
|
* automatically adjusted), this function should be called.</para></note>
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_data_calculate(GsweAntiscionData *antiscion_data)
|
||||||
|
{
|
||||||
|
if ((antiscion_data->antiscion_axis_info = g_hash_table_find(gswe_antiscion_axis_info_table, (GHRFunc)find_antiscion, antiscion_data)) == NULL) {
|
||||||
|
antiscion_data->antiscion_axis_info = gswe_antiscion_axis_info_ref(g_hash_table_lookup(gswe_antiscion_axis_info_table, GINT_TO_POINTER(GSWE_ANTISCION_AXIS_NONE)));
|
||||||
|
} else {
|
||||||
|
gswe_antiscion_axis_info_ref(antiscion_data->antiscion_axis_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_new_with_planets:
|
||||||
|
* @planet1: a #GswePlanetData
|
||||||
|
* @planet2: a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Creates a new #GsweAntiscionData object with both planets initially set. The
|
||||||
|
* respective antiscion is instantly calculated.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweAntiscionData
|
||||||
|
*/
|
||||||
|
GsweAntiscionData *
|
||||||
|
gswe_antiscion_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *planet2)
|
||||||
|
{
|
||||||
|
GsweAntiscionData *ret;
|
||||||
|
|
||||||
|
ret = gswe_antiscion_data_new();
|
||||||
|
ret->planet1 = gswe_planet_data_ref(planet1);
|
||||||
|
ret->planet2 = gswe_planet_data_ref(planet2);
|
||||||
|
|
||||||
|
gswe_antiscion_data_calculate(ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_ref:
|
||||||
|
* @antiscion_data: (in): a #GsweAntiscionData
|
||||||
|
*
|
||||||
|
* Increases reference count on @antiscion_data.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GsweAntiscionData
|
||||||
|
*/
|
||||||
|
GsweAntiscionData *
|
||||||
|
gswe_antiscion_data_ref(GsweAntiscionData *antiscion_data)
|
||||||
|
{
|
||||||
|
antiscion_data->refcount++;
|
||||||
|
|
||||||
|
return antiscion_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_unref:
|
||||||
|
* @antiscion_data: (in): a #GsweAntiscionData
|
||||||
|
*
|
||||||
|
* Decreases reference count on @antiscion_data. If reference count reaches zero, @antiscion_data is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_data_unref(GsweAntiscionData *antiscion_data)
|
||||||
|
{
|
||||||
|
if (--antiscion_data->refcount == 0) {
|
||||||
|
gswe_antiscion_data_free(antiscion_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_set_planet1:
|
||||||
|
* @antiscion_data: (in): a #GsweAntiscionData
|
||||||
|
* @planet1: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Sets @planet1 as the first planet of the antiscion.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_data_set_planet1(GsweAntiscionData *antiscion_data, GswePlanetData *planet1)
|
||||||
|
{
|
||||||
|
if (antiscion_data->planet1) {
|
||||||
|
gswe_planet_data_unref(antiscion_data->planet1);
|
||||||
|
}
|
||||||
|
|
||||||
|
antiscion_data->planet1 = gswe_planet_data_ref(planet1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_get_planet1:
|
||||||
|
* @antiscion_data: (in): a #GsweAntiscionData
|
||||||
|
*
|
||||||
|
* Gets the first in the antiscion relationship.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): The #GswePlanetData associated with the first planet.
|
||||||
|
*/
|
||||||
|
GswePlanetData *
|
||||||
|
gswe_antiscion_data_get_planet1(GsweAntiscionData *antiscion_data)
|
||||||
|
{
|
||||||
|
return antiscion_data->planet1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_set_planet2:
|
||||||
|
* @antiscion_data: (in): a #GsweAntiscionData
|
||||||
|
* @planet2: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Sets @planet2 as the second planet of the antiscion.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_data_set_planet2(GsweAntiscionData *antiscion_data, GswePlanetData *planet2)
|
||||||
|
{
|
||||||
|
if (antiscion_data->planet2) {
|
||||||
|
gswe_planet_data_unref(antiscion_data->planet2);
|
||||||
|
}
|
||||||
|
|
||||||
|
antiscion_data->planet2 = gswe_planet_data_ref(planet2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_get_planet2:
|
||||||
|
* @antiscion_data: (in): a #GsweAntiscionData
|
||||||
|
*
|
||||||
|
* Gets the second in the antiscion relationship.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): The #GswePlanetData associated with the second planet.
|
||||||
|
*/
|
||||||
|
GswePlanetData *
|
||||||
|
gswe_antiscion_data_get_planet2(GsweAntiscionData *antiscion_data)
|
||||||
|
{
|
||||||
|
return antiscion_data->planet2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_set_axis:
|
||||||
|
* @antiscion_data: a #GsweAntiscionData
|
||||||
|
* @axis: the axis to set in @antiscion_data
|
||||||
|
* @err: a #GError
|
||||||
|
*
|
||||||
|
* Sets the antiscion axis, which must be known by SWE-GLib (e.g. by calling
|
||||||
|
* gswe_init()). @err is populated with GSWE_ERROR_UNKNOWN_ANTISCION_AXIS if
|
||||||
|
* the axis is not known.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_data_set_axis(GsweAntiscionData *antiscion_data, GsweAntiscionAxis axis, GError **err)
|
||||||
|
{
|
||||||
|
GsweAntiscionAxisInfo *antiscion_axis_info;
|
||||||
|
|
||||||
|
if ((antiscion_axis_info = g_hash_table_lookup(gswe_antiscion_axis_info_table, GINT_TO_POINTER(axis))) == NULL) {
|
||||||
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_ANTISCION_AXIS, "Unknown antiscion axis");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (antiscion_data->antiscion_axis_info) {
|
||||||
|
gswe_antiscion_axis_info_unref(antiscion_data->antiscion_axis_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
antiscion_data->antiscion_axis_info = gswe_antiscion_axis_info_ref(antiscion_axis_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_get_axis:
|
||||||
|
* @antiscion_data: (in): a #GsweAntiscionData
|
||||||
|
*
|
||||||
|
* Gets the axis on which the antiscion relationship exists.
|
||||||
|
*
|
||||||
|
* Returns: the axis ID
|
||||||
|
*/
|
||||||
|
GsweAntiscionAxis
|
||||||
|
gswe_antiscion_data_get_axis(GsweAntiscionData *antiscion_data)
|
||||||
|
{
|
||||||
|
if (antiscion_data->antiscion_axis_info) {
|
||||||
|
return antiscion_data->antiscion_axis_info->axis;
|
||||||
|
} else {
|
||||||
|
return GSWE_ANTISCION_AXIS_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_set_antiscion_axis_info:
|
||||||
|
* @antiscion_data: (in): a #GsweAntiscionData
|
||||||
|
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo
|
||||||
|
*
|
||||||
|
* Sets @antiscion_axis_info as the axis of this #GsweAntiscionData.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_data_set_antiscion_axis_info(GsweAntiscionData *antiscion_data, GsweAntiscionAxisInfo *antiscion_axis_info)
|
||||||
|
{
|
||||||
|
if (antiscion_data->antiscion_axis_info) {
|
||||||
|
gswe_antiscion_axis_info_unref(antiscion_data->antiscion_axis_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
antiscion_data->antiscion_axis_info = gswe_antiscion_axis_info_ref(antiscion_axis_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_get_antiscion_axis_info:
|
||||||
|
* @antiscion_data: (in): a #GsweAntiscionData
|
||||||
|
*
|
||||||
|
* Gets the axis information related to the antiscion relationship's axis.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the #GsweAntiscionAxisInfo associated with this axis
|
||||||
|
*/
|
||||||
|
GsweAntiscionAxisInfo *
|
||||||
|
gswe_antiscion_data_get_antiscion_axis_info(GsweAntiscionData *antiscion_data)
|
||||||
|
{
|
||||||
|
return antiscion_data->antiscion_axis_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_set_difference:
|
||||||
|
* @antiscion_data: a #GsweAntiscionData
|
||||||
|
* @difference: the difference from an exact antiscion, in degrees
|
||||||
|
*
|
||||||
|
* Sets the difference of this antiscion from an exact antiscion.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_antiscion_data_set_difference(GsweAntiscionData *antiscion_data, gdouble difference)
|
||||||
|
{
|
||||||
|
antiscion_data->difference = difference;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_antiscion_data_get_difference:
|
||||||
|
* @antiscion_data: (in): a #GsweAntiscionData
|
||||||
|
*
|
||||||
|
* Gets the difference between an exact antiscion and this antiscion relationship.
|
||||||
|
*
|
||||||
|
* Returns: the difference, in degrees
|
||||||
|
*/
|
||||||
|
gdouble
|
||||||
|
gswe_antiscion_data_get_difference(GsweAntiscionData *antiscion_data)
|
||||||
|
{
|
||||||
|
return antiscion_data->difference;
|
||||||
|
}
|
||||||
|
|
62
src/gswe-antiscion-data.h
Normal file
62
src/gswe-antiscion-data.h
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* gswe-antiscion-data.h: Antiscia related data
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef __SWE_GLIB_GSWE_ANTISCION_DATA_H__
|
||||||
|
#define __SWE_GLIB_GSWE_ANTISCION_DATA_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-planet-data.h"
|
||||||
|
#include "gswe-antiscion-axis-info.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GsweAntiscionData:
|
||||||
|
*
|
||||||
|
* <structname>GsweAntiscionData</structname> is an opaque structure whose members
|
||||||
|
* cannot be accessed directly.
|
||||||
|
*
|
||||||
|
* Since: 1.1
|
||||||
|
*/
|
||||||
|
typedef struct _GsweAntiscionData GsweAntiscionData;
|
||||||
|
|
||||||
|
GType gswe_antiscion_data_get_type(void);
|
||||||
|
#define GSWE_TYPE_ANTISCION_DATA (gswe_antiscion_data_get_type())
|
||||||
|
|
||||||
|
GsweAntiscionData *gswe_antiscion_data_new(void);
|
||||||
|
GsweAntiscionData *gswe_antiscion_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *planet2);
|
||||||
|
|
||||||
|
GsweAntiscionData *gswe_antiscion_data_ref(GsweAntiscionData *antiscion_data);
|
||||||
|
void gswe_antiscion_data_unref(GsweAntiscionData *antiscion_data);
|
||||||
|
|
||||||
|
void gswe_antiscion_data_calculate(GsweAntiscionData *antiscion_data);
|
||||||
|
|
||||||
|
void gswe_antiscion_data_set_planet1(GsweAntiscionData *antiscion_data, GswePlanetData *planet1);
|
||||||
|
GswePlanetData *gswe_antiscion_data_get_planet1(GsweAntiscionData *antiscion_data);
|
||||||
|
|
||||||
|
void gswe_antiscion_data_set_planet2(GsweAntiscionData *antiscion_data, GswePlanetData *planet2);
|
||||||
|
GswePlanetData *gswe_antiscion_data_get_planet2(GsweAntiscionData *antiscion_data);
|
||||||
|
|
||||||
|
GsweAntiscionAxis gswe_antiscion_data_get_axis(GsweAntiscionData *antiscion_data);
|
||||||
|
GsweAntiscionAxisInfo *gswe_antiscion_data_get_antiscion_axis_info(GsweAntiscionData *antiscion_data);
|
||||||
|
gdouble gswe_antiscion_data_get_difference(GsweAntiscionData *antiscion_data);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_ANTISCION_DATA_H__ */
|
||||||
|
|
50
src/gswe-aspect-data-private.h
Normal file
50
src/gswe-aspect-data-private.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/* gswe-aspect-data-private.h: Private parts of GsweAspectData
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifdef __SWE_GLIB_BUILDING__
|
||||||
|
#ifndef __SWE_GLIB_GSWE_ASPECT_DATA_PRIVATE_H__
|
||||||
|
#define __SWE_GLIB_GSWE_ASPECT_DATA_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gswe-aspect-data.h"
|
||||||
|
#include "gswe-planet-data.h"
|
||||||
|
|
||||||
|
struct _GsweAspectData {
|
||||||
|
/* the first planet in the aspect */
|
||||||
|
GswePlanetData *planet1;
|
||||||
|
|
||||||
|
/* the second planet in the aspect */
|
||||||
|
GswePlanetData *planet2;
|
||||||
|
|
||||||
|
/* the distance between the two planets, in degrees */
|
||||||
|
gdouble distance;
|
||||||
|
|
||||||
|
/* the #GsweAspectInfo structure associated with the aspect */
|
||||||
|
GsweAspectInfo *aspect_info;
|
||||||
|
|
||||||
|
/* the difference in percent between an exact aspect and this given aspect */
|
||||||
|
gdouble difference;
|
||||||
|
|
||||||
|
/* reference count */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
|
void gswe_aspect_data_calculate(GsweAspectData *aspect_data);
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_ASPECT_DATA_PRIVATE_H__ */
|
||||||
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
#endif /* __SWE_GLIB_BUILDING__ */
|
313
src/gswe-aspect-data.c
Normal file
313
src/gswe-aspect-data.c
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
/* gswe-aspect-data.c: Aspect related data
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <math.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "swe-glib-private.h"
|
||||||
|
#include "swe-glib.h"
|
||||||
|
#include "gswe-planet-data-private.h"
|
||||||
|
#include "gswe-planet-info-private.h"
|
||||||
|
#include "gswe-aspect-info.h"
|
||||||
|
#include "gswe-aspect-info-private.h"
|
||||||
|
#include "gswe-aspect-data.h"
|
||||||
|
#include "gswe-aspect-data-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gswe-aspect-data
|
||||||
|
* @short_description: a structure representing an aspect between two planets
|
||||||
|
* @title: GsweAspectData
|
||||||
|
* @stability: Stable
|
||||||
|
* @include: swe-glib.h
|
||||||
|
* @see_also: #GsweAspectInfo
|
||||||
|
*
|
||||||
|
* #GsweAspectData is a structure that represents two planets relation to each
|
||||||
|
* other, like their aspect and the aspect's difference from an exact aspect.
|
||||||
|
*/
|
||||||
|
G_DEFINE_BOXED_TYPE(GsweAspectData, gswe_aspect_data, (GBoxedCopyFunc)gswe_aspect_data_ref, (GBoxedFreeFunc)gswe_aspect_data_unref);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gswe_aspect_data_free(GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
if (aspect_data->planet1) {
|
||||||
|
gswe_planet_data_unref(aspect_data->planet1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aspect_data->planet2) {
|
||||||
|
gswe_planet_data_unref(aspect_data->planet2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aspect_data->aspect_info) {
|
||||||
|
gswe_aspect_info_unref(aspect_data->aspect_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(aspect_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* find_aspect:
|
||||||
|
* @aspect_p: a pointer made with GINT_TO_POINTER(), holding the aspect ID
|
||||||
|
* @aspect_info: a GsweAspectInfo, which will be checked against @aspect_data
|
||||||
|
* @aspect_data: a GsweAspectData, whose planets' positions will be checked against @aspect_info
|
||||||
|
*
|
||||||
|
* This function is called internally by gswe_aspect_data_calculate() to check
|
||||||
|
* if the two planets in @aspect_data are in aspect according to @aspect_info
|
||||||
|
*/
|
||||||
|
static gboolean
|
||||||
|
find_aspect(gpointer aspect_p, GsweAspectInfo *aspect_info, GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
gdouble diff,
|
||||||
|
planet_orb,
|
||||||
|
aspect_orb;
|
||||||
|
|
||||||
|
diff = fabs(aspect_info->size - aspect_data->distance);
|
||||||
|
planet_orb = fmin(aspect_data->planet1->planet_info->orb, aspect_data->planet2->planet_info->orb);
|
||||||
|
aspect_orb = fmax(1.0, planet_orb - aspect_info->orb_modifier);
|
||||||
|
|
||||||
|
if (diff < aspect_orb) {
|
||||||
|
aspect_data->aspect_info = gswe_aspect_info_ref(aspect_info);
|
||||||
|
|
||||||
|
if (aspect_info->size == 0) {
|
||||||
|
aspect_data->difference = (1 - ((360.0 - diff) / 360.0)) * 100.0;
|
||||||
|
} else {
|
||||||
|
aspect_data->difference = (1 - ((aspect_info->size - diff) / aspect_info->size)) * 100.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gswe_aspect_data_calculate(GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
if ((aspect_data->distance = fabs(aspect_data->planet1->position - aspect_data->planet2->position)) > 180.0) {
|
||||||
|
aspect_data->distance = 360.0 - aspect_data->distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((aspect_data->aspect_info = g_hash_table_find(gswe_aspect_info_table, (GHRFunc)find_aspect, aspect_data)) == NULL) {
|
||||||
|
aspect_data->aspect_info = gswe_aspect_info_ref(g_hash_table_lookup(gswe_aspect_info_table, GINT_TO_POINTER(GSWE_ASPECT_NONE)));
|
||||||
|
} else {
|
||||||
|
gswe_aspect_info_ref(aspect_data->aspect_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_new:
|
||||||
|
*
|
||||||
|
* Creates a new #GsweAspectData with reference count set to 1.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweAspectData
|
||||||
|
*/
|
||||||
|
GsweAspectData *
|
||||||
|
gswe_aspect_data_new(void)
|
||||||
|
{
|
||||||
|
GsweAspectData *ret;
|
||||||
|
|
||||||
|
gswe_init();
|
||||||
|
|
||||||
|
ret = g_new0(GsweAspectData, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_new_with_planets:
|
||||||
|
* @planet1: (in): a #GswePlanetData
|
||||||
|
* @planet2: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Creates a new #GsweAspectData with a reference count of 1, and both planets
|
||||||
|
* initially set. Also calculates the aspect between them.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweAspectData with all data set.
|
||||||
|
*/
|
||||||
|
GsweAspectData *
|
||||||
|
gswe_aspect_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *planet2)
|
||||||
|
{
|
||||||
|
GsweAspectData *ret;
|
||||||
|
|
||||||
|
ret = gswe_aspect_data_new();
|
||||||
|
ret->planet1 = gswe_planet_data_ref(planet1);
|
||||||
|
ret->planet2 = gswe_planet_data_ref(planet2);
|
||||||
|
|
||||||
|
gswe_aspect_data_calculate(ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_ref:
|
||||||
|
* @aspect_data: a #GsweAspectData
|
||||||
|
*
|
||||||
|
* Increases reference count of @aspect_data.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GsweAspectData
|
||||||
|
*/
|
||||||
|
GsweAspectData *
|
||||||
|
gswe_aspect_data_ref(GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
aspect_data->refcount++;
|
||||||
|
|
||||||
|
return aspect_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_unref:
|
||||||
|
* @aspect_data: (in): a #GsweAspectData
|
||||||
|
*
|
||||||
|
* Decreases reference count on @aspect_data. If reference count reaches zero, @aspect_data is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_aspect_data_unref(GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
if (--aspect_data->refcount == 0) {
|
||||||
|
gswe_aspect_data_free(aspect_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_set_planet1:
|
||||||
|
* @aspect_data: (in): a #GsweAspectData
|
||||||
|
* @planet1: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Sets @planet1 as the first planet of the aspect.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_aspect_data_set_planet1(GsweAspectData *aspect_data, GswePlanetData *planet1)
|
||||||
|
{
|
||||||
|
if (aspect_data->planet1) {
|
||||||
|
gswe_planet_data_unref(aspect_data->planet1);
|
||||||
|
}
|
||||||
|
|
||||||
|
aspect_data->planet1 = gswe_planet_data_ref(planet1);
|
||||||
|
|
||||||
|
if (aspect_data->planet2) {
|
||||||
|
gswe_aspect_data_calculate(aspect_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_get_planet1:
|
||||||
|
* @aspect_data: (in): a #GsweAspectData
|
||||||
|
*
|
||||||
|
* Gets the first planet in the aspect.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): The #GswePlanetData associated with the first planet
|
||||||
|
*/
|
||||||
|
GswePlanetData *
|
||||||
|
gswe_aspect_data_get_planet1(GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
return aspect_data->planet1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_set_planet2:
|
||||||
|
* @aspect_data: (in): a #GsweAspectData
|
||||||
|
* @planet2: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Sets @planet2 as the second planet of the aspect.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_aspect_data_set_planet2(GsweAspectData *aspect_data, GswePlanetData *planet2)
|
||||||
|
{
|
||||||
|
if (aspect_data->planet2) {
|
||||||
|
gswe_planet_data_unref(aspect_data->planet2);
|
||||||
|
}
|
||||||
|
|
||||||
|
aspect_data->planet2 = gswe_planet_data_ref(planet2);
|
||||||
|
|
||||||
|
if (aspect_data->planet1) {
|
||||||
|
gswe_aspect_data_calculate(aspect_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_get_planet2:
|
||||||
|
* @aspect_data: (in): a #GsweAspectData
|
||||||
|
*
|
||||||
|
* Gets the second planet in the aspect.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): The #GswePlanetData associated with the second planet
|
||||||
|
*/
|
||||||
|
GswePlanetData *
|
||||||
|
gswe_aspect_data_get_planet2(GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
return aspect_data->planet2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_get_distance:
|
||||||
|
* @aspect_data: (in): a #GsweAspectData
|
||||||
|
*
|
||||||
|
* Gets the exact distance between the two planets in the aspect.
|
||||||
|
*
|
||||||
|
* Returns: the distance, in degrees
|
||||||
|
*/
|
||||||
|
gdouble
|
||||||
|
gswe_aspect_data_get_distance(GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
return aspect_data->distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_get_aspect:
|
||||||
|
* @aspect_data: (in): a #GsweAspectData
|
||||||
|
*
|
||||||
|
* Gets the actual aspect between the two planets.
|
||||||
|
*
|
||||||
|
* Returns: the aspect ID
|
||||||
|
*/
|
||||||
|
GsweAspect
|
||||||
|
gswe_aspect_data_get_aspect(GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
if (aspect_data->aspect_info) {
|
||||||
|
return aspect_data->aspect_info->aspect;
|
||||||
|
} else {
|
||||||
|
return GSWE_ASPECT_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_get_aspect_info:
|
||||||
|
* @aspect_data: (in): a #GsweAspectData
|
||||||
|
*
|
||||||
|
* Gets the the #GsweAspectInfo object for this aspect.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): a #GsweAspectInfo
|
||||||
|
*/
|
||||||
|
GsweAspectInfo *
|
||||||
|
gswe_aspect_data_get_aspect_info(GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
return aspect_data->aspect_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_data_get_difference:
|
||||||
|
* @aspect_data: (in): a #GsweAspectData
|
||||||
|
*
|
||||||
|
* Gets the difference between an exact aspect and this one.
|
||||||
|
*
|
||||||
|
* Returns: the difference in percent.
|
||||||
|
*/
|
||||||
|
gdouble
|
||||||
|
gswe_aspect_data_get_difference(GsweAspectData *aspect_data)
|
||||||
|
{
|
||||||
|
return aspect_data->difference;
|
||||||
|
}
|
||||||
|
|
62
src/gswe-aspect-data.h
Normal file
62
src/gswe-aspect-data.h
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* gswe-aspect-data.h: Aspect related data
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef __SWE_GLIB_GSWE_ASPECT_DATA_H__
|
||||||
|
#define __SWE_GLIB_GSWE_ASPECT_DATA_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-aspect-info.h"
|
||||||
|
#include "gswe-planet-data.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GsweAspectData:
|
||||||
|
*
|
||||||
|
* <structname>GsweAspectData</structname> is an opaque structure whose members
|
||||||
|
* cannot be accessed directly.
|
||||||
|
*
|
||||||
|
* Since: 1.1
|
||||||
|
*/
|
||||||
|
typedef struct _GsweAspectData GsweAspectData;
|
||||||
|
|
||||||
|
GType gswe_aspect_data_get_type(void);
|
||||||
|
#define GSWE_TYPE_ASPECT_DATA (gswe_aspect_data_get_type())
|
||||||
|
|
||||||
|
GsweAspectData *gswe_aspect_data_new(void);
|
||||||
|
GsweAspectData *gswe_aspect_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *planet2);
|
||||||
|
|
||||||
|
GsweAspectData *gswe_aspect_data_ref(GsweAspectData *aspect_data);
|
||||||
|
void gswe_aspect_data_unref(GsweAspectData *aspect_data);
|
||||||
|
|
||||||
|
void gswe_aspect_data_set_planet1(GsweAspectData *aspect_data, GswePlanetData *planet1);
|
||||||
|
GswePlanetData *gswe_aspect_data_get_planet1(GsweAspectData *aspect_data);
|
||||||
|
|
||||||
|
void gswe_aspect_data_set_planet2(GsweAspectData *aspect_data, GswePlanetData *planet2);
|
||||||
|
GswePlanetData *gswe_aspect_data_get_planet2(GsweAspectData *aspect_data);
|
||||||
|
|
||||||
|
gdouble gswe_aspect_data_get_distance(GsweAspectData *aspect_data);
|
||||||
|
GsweAspect gswe_aspect_data_get_aspect(GsweAspectData *aspect_data);
|
||||||
|
GsweAspectInfo *gswe_aspect_data_get_aspect_info(GsweAspectData *aspect_data);
|
||||||
|
gdouble gswe_aspect_data_get_difference(GsweAspectData *aspect_data);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_ASPECT_DATA_H__ */
|
||||||
|
|
52
src/gswe-aspect-info-private.h
Normal file
52
src/gswe-aspect-info-private.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* gswe-aspect-info-private.h: Private parts of GsweAspectInfo
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifdef __SWE_GLIB_BUILDING__
|
||||||
|
#ifndef __SWE_GLIB_GSWE_ASPECT_INFO_PRIVATE_H__
|
||||||
|
#define __SWE_GLIB_GSWE_ASPECT_INFO_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-aspect-info.h"
|
||||||
|
|
||||||
|
struct _GsweAspectInfo {
|
||||||
|
/* the identifier of this aspect */
|
||||||
|
GsweAspect aspect;
|
||||||
|
|
||||||
|
/* the name of the aspect */
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
/* the size of the aspect, in degrees */
|
||||||
|
guint size;
|
||||||
|
|
||||||
|
/* the modifier of the orb (the maximum allowable difference from an exact orb) */
|
||||||
|
gdouble orb_modifier;
|
||||||
|
|
||||||
|
/* shows whether this aspect is harmonic or not */
|
||||||
|
gboolean harmonic;
|
||||||
|
|
||||||
|
/* shows whether this aspect is major (Ptolemaic) or not */
|
||||||
|
gboolean major;
|
||||||
|
|
||||||
|
/** reference count */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_ASPECT_INFO_PRIVATE_H__ */
|
||||||
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
#endif /* __SWE_GLIB_BUILDING__ */
|
||||||
|
|
272
src/gswe-aspect-info.c
Normal file
272
src/gswe-aspect-info.c
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
/* gswe-aspect-info.c: Aspect related information
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-aspect-info.h"
|
||||||
|
#include "gswe-aspect-info-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gswe-aspect-info
|
||||||
|
* @short_description: a structure storing information about an aspect
|
||||||
|
* @title: GsweAspectInfo
|
||||||
|
* @stability: Stable
|
||||||
|
* @include: swe-glib.h
|
||||||
|
*
|
||||||
|
* The #GsweAspectInfo stores information about an aspect.
|
||||||
|
*
|
||||||
|
* <warning><para>Using set_* type of funcions on an already registered
|
||||||
|
* #GsweAspectInfo can currently cause undocumented side effects, if a
|
||||||
|
* #GsweMoment is already instantiated. Currently, this covers all
|
||||||
|
* #GsweAspectInfo objects. In the future, registering custom aspects may be
|
||||||
|
* possible; until then, you should never use such functions.</para></warning>
|
||||||
|
*/
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE(GsweAspectInfo, gswe_aspect_info, (GBoxedCopyFunc)gswe_aspect_info_ref, (GBoxedFreeFunc)gswe_aspect_info_unref);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gswe_aspect_info_free(GsweAspectInfo *aspect_info)
|
||||||
|
{
|
||||||
|
if (aspect_info->name) {
|
||||||
|
g_free(aspect_info->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(aspect_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_new:
|
||||||
|
*
|
||||||
|
* Creates a new #GsweAspectInfo with reference count set to 1.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweAspectInfo
|
||||||
|
*/
|
||||||
|
GsweAspectInfo *
|
||||||
|
gswe_aspect_info_new(void)
|
||||||
|
{
|
||||||
|
GsweAspectInfo *ret;
|
||||||
|
|
||||||
|
ret = g_new0(GsweAspectInfo, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_ref:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
*
|
||||||
|
* Increases reference count on @aspect_info by one.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GsweAspectInfo
|
||||||
|
*/
|
||||||
|
GsweAspectInfo *
|
||||||
|
gswe_aspect_info_ref(GsweAspectInfo *aspect_info)
|
||||||
|
{
|
||||||
|
aspect_info->refcount++;
|
||||||
|
|
||||||
|
return aspect_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_unref:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
*
|
||||||
|
* Decreases reference count of @aspect_info by one. If reference count drops
|
||||||
|
* to zero, @aspect_info is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_aspect_info_unref(GsweAspectInfo *aspect_info)
|
||||||
|
{
|
||||||
|
if (--aspect_info->refcount == 0) {
|
||||||
|
gswe_aspect_info_free(aspect_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_set_aspect:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
* @aspect: the aspect to set in @aspect_info
|
||||||
|
*
|
||||||
|
* Sets @aspect_info to represenc @aspect.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_aspect_info_set_aspect(GsweAspectInfo *aspect_info, GsweAspect aspect)
|
||||||
|
{
|
||||||
|
aspect_info->aspect = aspect;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_get_aspect:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
*
|
||||||
|
* Gets the aspect ID
|
||||||
|
*/
|
||||||
|
GsweAspect
|
||||||
|
gswe_aspect_info_get_aspect(GsweAspectInfo *aspect_info)
|
||||||
|
{
|
||||||
|
return aspect_info->aspect;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_set_name:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
* @name: (in): the name to be set as @aspect_info’s name
|
||||||
|
*
|
||||||
|
* Sets the name of @aspect_info to @name.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_aspect_info_set_name(GsweAspectInfo *aspect_info, const gchar *name)
|
||||||
|
{
|
||||||
|
if (aspect_info->name) {
|
||||||
|
g_free(aspect_info->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
aspect_info->name = g_strdup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_get_name:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
*
|
||||||
|
* Gets the name of this aspect. If NLS is enabled, name is translated in
|
||||||
|
* gswe_init(), so if you switch locale in your program, it will remain in the
|
||||||
|
* old locale. The returned string should not be freed or modified. It remains
|
||||||
|
* valid until @aspect_info exists.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the name of the aspect
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
gswe_aspect_info_get_name(GsweAspectInfo *aspect_info)
|
||||||
|
{
|
||||||
|
return aspect_info->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_set_size:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
* @size: the new size for @aspect_info, in degrees
|
||||||
|
*
|
||||||
|
* Sets the size of @aspect info.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_aspect_info_set_size(GsweAspectInfo *aspect_info, gdouble size)
|
||||||
|
{
|
||||||
|
aspect_info->size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_get_size:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
*
|
||||||
|
* Gets the size of the aspect.
|
||||||
|
*
|
||||||
|
* Returns: the size of the aspect, in degrees
|
||||||
|
*/
|
||||||
|
gdouble
|
||||||
|
gswe_aspect_info_get_size(GsweAspectInfo *aspect_info)
|
||||||
|
{
|
||||||
|
return aspect_info->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_set_orb_modifier:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
* @orb_modifier: the new orb modifier of @aspect_info
|
||||||
|
*
|
||||||
|
* Sets the orb modifier for @aspect_info. The orb modifier is used in aspect
|
||||||
|
* calculation; if the difference between an exact aspect and the distance
|
||||||
|
* between two positions exceeds this limit, the aspect is not considered.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_aspect_info_set_orb_modifier(GsweAspectInfo *aspect_info, gdouble orb_modifier)
|
||||||
|
{
|
||||||
|
aspect_info->orb_modifier = orb_modifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_get_orb_modifier:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
*
|
||||||
|
* Gets the orb modifier of this aspect. The orb modifier is subtracted from
|
||||||
|
* the planets' orb during aspect calculation.
|
||||||
|
*
|
||||||
|
* Returns: the orb modifier, in degrees
|
||||||
|
*/
|
||||||
|
gdouble
|
||||||
|
gswe_aspect_info_get_orb_modifier(GsweAspectInfo *aspect_info)
|
||||||
|
{
|
||||||
|
return aspect_info->orb_modifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_set_harmonic:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
* @harmonic: TRUE, if @aspect_info should be considered harmonic; FALSE otherwise
|
||||||
|
*
|
||||||
|
* Sets the harmonic state of @aspect_info.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_aspect_info_set_harmonic(GsweAspectInfo *aspect_info, gboolean harmonic)
|
||||||
|
{
|
||||||
|
aspect_info->harmonic = harmonic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_get_harmonic:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
*
|
||||||
|
* Tells if this aspect is considered harmonic.
|
||||||
|
*
|
||||||
|
* Returns: TRUE if the aspect is harmonic; FALSE otherwise
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gswe_aspect_info_get_harmonic(GsweAspectInfo *aspect_info)
|
||||||
|
{
|
||||||
|
return aspect_info->harmonic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_set_major:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
* @major: TRUE, if @aspect_info should be considered major (Ptolemaic); FALSE otherwise
|
||||||
|
*
|
||||||
|
* Sets the major state of @aspect_info.
|
||||||
|
*
|
||||||
|
* <note><para>As all Ptolemaic aspects are registered during gswe_init(), you should never set @major to TRUE on new aspects.</para></note>
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_aspect_info_set_major(GsweAspectInfo *aspect_info, gboolean major)
|
||||||
|
{
|
||||||
|
aspect_info->major = major;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_aspect_info_get_major:
|
||||||
|
* @aspect_info: (in): a #GsweAspectInfo
|
||||||
|
*
|
||||||
|
* Gets the significance of the aspect, e.g. if its Ptolemaic or note.
|
||||||
|
*
|
||||||
|
* Returns: TRUE if the aspect is a major (Ptolemaic) one; FALSE otherwise
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gswe_aspect_info_get_major(GsweAspectInfo *aspect_info)
|
||||||
|
{
|
||||||
|
return aspect_info->major;
|
||||||
|
}
|
||||||
|
|
66
src/gswe-aspect-info.h
Normal file
66
src/gswe-aspect-info.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/* gswe-aspect-info.h: Aspect related information
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef __SWE_GLIB_GSWE_ASPECT_INFO_H__
|
||||||
|
#define __SWE_GLIB_GSWE_ASPECT_INFO_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GsweAspectInfo:
|
||||||
|
*
|
||||||
|
* <structname>GsweAspectInfo</structname> is an opaque structure whose members
|
||||||
|
* cannot be accessed directly.
|
||||||
|
*
|
||||||
|
* Since: 1.1
|
||||||
|
*/
|
||||||
|
typedef struct _GsweAspectInfo GsweAspectInfo;
|
||||||
|
|
||||||
|
GType gswe_aspect_info_get_type(void);
|
||||||
|
#define GSWE_TYPE_ASPECT_INFO (gswe_aspect_info_get_type())
|
||||||
|
|
||||||
|
GsweAspectInfo *gswe_aspect_info_new(void);
|
||||||
|
|
||||||
|
GsweAspectInfo *gswe_aspect_info_ref(GsweAspectInfo *aspect_info);
|
||||||
|
void gswe_aspect_info_unref(GsweAspectInfo *aspect_info);
|
||||||
|
|
||||||
|
void gswe_aspect_info_set_aspect(GsweAspectInfo *aspect_info, GsweAspect aspect);
|
||||||
|
GsweAspect gswe_aspect_info_get_aspect(GsweAspectInfo *aspect_info);
|
||||||
|
|
||||||
|
void gswe_aspect_info_set_name(GsweAspectInfo *aspect_info, const gchar *name);
|
||||||
|
const gchar *gswe_aspect_info_get_name(GsweAspectInfo *aspect_info);
|
||||||
|
|
||||||
|
void gswe_aspect_info_set_size(GsweAspectInfo *aspect_info, gdouble size);
|
||||||
|
gdouble gswe_aspect_info_get_size(GsweAspectInfo *aspect_info);
|
||||||
|
|
||||||
|
void gswe_aspect_info_set_orb_modifier(GsweAspectInfo *aspect_info, gdouble orb_modifier);
|
||||||
|
gdouble gswe_aspect_info_get_orb_modifier(GsweAspectInfo *aspect_info);
|
||||||
|
|
||||||
|
void gswe_aspect_info_set_harmonic(GsweAspectInfo *aspect_info, gboolean harmonic);
|
||||||
|
gboolean gswe_aspect_info_get_harmonic(GsweAspectInfo *aspect_info);
|
||||||
|
|
||||||
|
void gswe_aspect_info_set_major(GsweAspectInfo *aspect_info, gboolean major);
|
||||||
|
gboolean gswe_aspect_info_get_major(GsweAspectInfo *aspect_info);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_ASPECT_INFO_H__ */
|
||||||
|
|
@@ -16,6 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include "swe-glib.h"
|
||||||
#include "gswe-enumtypes.h"
|
#include "gswe-enumtypes.h"
|
||||||
#include "@filename@"
|
#include "@filename@"
|
||||||
|
|
||||||
@@ -31,6 +32,8 @@ GType
|
|||||||
{
|
{
|
||||||
static volatile gsize g_define_type_id__volatile = 0;
|
static volatile gsize g_define_type_id__volatile = 0;
|
||||||
|
|
||||||
|
gswe_init();
|
||||||
|
|
||||||
if (g_once_init_enter(&g_define_type_id__volatile)) {
|
if (g_once_init_enter(&g_define_type_id__volatile)) {
|
||||||
static const G@Type@Value values[] = {
|
static const G@Type@Value values[] = {
|
||||||
/*** END value-header ***/
|
/*** END value-header ***/
|
||||||
|
42
src/gswe-house-data-private.h
Normal file
42
src/gswe-house-data-private.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/* gswe-house-data-private.h: Private parts of GsweHouseData
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifdef __SWE_GLIB_BUILDING__
|
||||||
|
#ifndef __SWE_GLIB_GSWE_HOUSE_DATA_PRIVATE_H__
|
||||||
|
#define __SWE_GLIB_GSWE_HOUSE_DATA_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gswe-house-data.h"
|
||||||
|
|
||||||
|
struct _GsweHouseData {
|
||||||
|
/* the number of the house (usually in the range [1;12]. Sometimes may be [1;36]) */
|
||||||
|
guint house;
|
||||||
|
|
||||||
|
/* the position of the house's cusp on the sky */
|
||||||
|
gdouble cusp_position;
|
||||||
|
|
||||||
|
/* the #GsweSignInfo structure associated with the sign in which the house cusp is in */
|
||||||
|
GsweSignInfo *sign_info;
|
||||||
|
|
||||||
|
/* reference count */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_HOUSE_DATA_PRIVATE_H__ */
|
||||||
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
#endif /* __SWE_GLIB_BUILDING__ */
|
||||||
|
|
155
src/gswe-house-data.c
Normal file
155
src/gswe-house-data.c
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
/* gswe-house-data.c: House related data
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
#include "swe-glib-private.h"
|
||||||
|
#include "swe-glib.h"
|
||||||
|
#include "gswe-house-data.h"
|
||||||
|
#include "gswe-house-data-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gswe-house-data
|
||||||
|
* @short_description: a structure representing a house's position-related data
|
||||||
|
* @title: GsweHouseData
|
||||||
|
* @stability: Stable
|
||||||
|
* @include: swe-glib.h
|
||||||
|
* @see_also: #GsweHouseSystemInfo
|
||||||
|
*
|
||||||
|
* #GsweHouseData is a structure that represents a house's position.
|
||||||
|
*/
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE(GsweHouseData, gswe_house_data, (GBoxedCopyFunc)gswe_house_data_ref, (GBoxedFreeFunc)gswe_house_data_unref);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gswe_house_data_free(GsweHouseData *house_data)
|
||||||
|
{
|
||||||
|
if (house_data->sign_info) {
|
||||||
|
gswe_sign_info_unref(house_data->sign_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(house_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_new:
|
||||||
|
*
|
||||||
|
* Creates a new #GsweHouseData with reference count set to 1.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweHouseData
|
||||||
|
*/
|
||||||
|
GsweHouseData *
|
||||||
|
gswe_house_data_new(void)
|
||||||
|
{
|
||||||
|
GsweHouseData *ret;
|
||||||
|
|
||||||
|
ret = g_new0(GsweHouseData, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_ref:
|
||||||
|
* @house_data: a #GsweHouseData
|
||||||
|
*
|
||||||
|
* Increases reference count on @house_data by one.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GsweHouseData
|
||||||
|
*/
|
||||||
|
GsweHouseData *
|
||||||
|
gswe_house_data_ref(GsweHouseData *house_data)
|
||||||
|
{
|
||||||
|
house_data->refcount++;
|
||||||
|
|
||||||
|
return house_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_unref:
|
||||||
|
* @house_data: a #GsweHouseData
|
||||||
|
*
|
||||||
|
* Decreases reference count on @house_data by one. If reference count drops to zero, @house_data is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_house_data_unref(GsweHouseData *house_data)
|
||||||
|
{
|
||||||
|
if (--house_data->refcount == 0) {
|
||||||
|
gswe_house_data_free(house_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_get_house:
|
||||||
|
* @house_data: (in): a #GsweHouseData
|
||||||
|
*
|
||||||
|
* Gets the number of the house.
|
||||||
|
*
|
||||||
|
* Returns: the house number
|
||||||
|
*/
|
||||||
|
guint
|
||||||
|
gswe_house_data_get_house(GsweHouseData *house_data)
|
||||||
|
{
|
||||||
|
return house_data->house;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_get_cusp_position:
|
||||||
|
* @house_data: (in): a #GsweHouseData
|
||||||
|
*
|
||||||
|
* Gets the position of the house's cusp.
|
||||||
|
*
|
||||||
|
* Returns: the cusp position, in degrees
|
||||||
|
*/
|
||||||
|
gdouble
|
||||||
|
gswe_house_data_get_cusp_position(GsweHouseData *house_data)
|
||||||
|
{
|
||||||
|
return house_data->cusp_position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_get_sign:
|
||||||
|
* @house_data: a #GsweHouseData
|
||||||
|
*
|
||||||
|
* Gets the sign which the house's cusp is in.
|
||||||
|
*
|
||||||
|
* Returns: the GsweZodiac of the house cusp's sign
|
||||||
|
*/
|
||||||
|
GsweZodiac
|
||||||
|
gswe_house_data_get_sign(GsweHouseData *house_data)
|
||||||
|
{
|
||||||
|
if (house_data->sign_info) {
|
||||||
|
return house_data->sign_info->sign;
|
||||||
|
} else {
|
||||||
|
return GSWE_SIGN_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_get_sign_info:
|
||||||
|
* @house_data: (in): a #GsweHouseData
|
||||||
|
*
|
||||||
|
* Gets the #GsweSignInfo that represents the sign which the house's cusp is in.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): a #GsweSignInfo representing the sign
|
||||||
|
*/
|
||||||
|
GsweSignInfo *
|
||||||
|
gswe_house_data_get_sign_info(GsweHouseData *house_data)
|
||||||
|
{
|
||||||
|
return house_data->sign_info;
|
||||||
|
}
|
||||||
|
|
53
src/gswe-house-data.h
Normal file
53
src/gswe-house-data.h
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/* gswe-house-data.h: House related data
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef __SWE_GLIB_GSWE_HOUSE_DATA_H__
|
||||||
|
#define __SWE_GLIB_GSWE_HOUSE_DATA_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-sign-info.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GsweHouseData:
|
||||||
|
*
|
||||||
|
* <structname>GsweHouseData</structname> is an opaque structure whose members
|
||||||
|
* cannot be accessed directly.
|
||||||
|
*
|
||||||
|
* Since: 1.1
|
||||||
|
*/
|
||||||
|
typedef struct _GsweHouseData GsweHouseData;
|
||||||
|
|
||||||
|
GType gswe_house_data_get_type(void);
|
||||||
|
#define GSWE_TYPE_HOUSE_DATA (gswe_house_data_get_type())
|
||||||
|
|
||||||
|
GsweHouseData *gswe_house_data_new(void);
|
||||||
|
|
||||||
|
GsweHouseData *gswe_house_data_ref(GsweHouseData *house_data);
|
||||||
|
void gswe_house_data_unref(GsweHouseData *house_data);
|
||||||
|
|
||||||
|
guint gswe_house_data_get_house(GsweHouseData *house_data);
|
||||||
|
gdouble gswe_house_data_get_cusp_position(GsweHouseData *house_data);
|
||||||
|
GsweZodiac gswe_house_data_get_sign(GsweHouseData *house_data);
|
||||||
|
GsweSignInfo *gswe_house_data_get_sign_info(GsweHouseData *house_data);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_HOUSE_DATA_H__ */
|
||||||
|
|
44
src/gswe-house-system-info-private.h
Normal file
44
src/gswe-house-system-info-private.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/* gswe-house-system-info-private.h: Private parts of GsweHouseSystemInfo
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifdef __SWE_GLIB_BUILDING__
|
||||||
|
#ifndef __SWE_GLIB_GSWE_HOUSE_SYSTEM_INFO_PRIVATE_H__
|
||||||
|
#define __SWE_GLIB_GSWE_HOUSE_SYSTEM_INFO_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
#include "gswe-house-system-info.h"
|
||||||
|
|
||||||
|
struct _GsweHouseSystemInfo {
|
||||||
|
/* the house system's ID */
|
||||||
|
GsweHouseSystem house_system;
|
||||||
|
|
||||||
|
/* the character value that represents this house system in the Swiss Ephemeris library */
|
||||||
|
gchar sweph_id;
|
||||||
|
|
||||||
|
/* the name of this house system */
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
/* reference count */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_HOUSE_SYSTEM_INFO_PRIVATE_H__ */
|
||||||
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
#endif /* __SWE_GLIB_BUILDING__ */
|
||||||
|
|
178
src/gswe-house-system-info.c
Normal file
178
src/gswe-house-system-info.c
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
/* gswe-house-system-info.c: House system information
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-house-system-info.h"
|
||||||
|
#include "gswe-house-system-info-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gswe-house-system-info
|
||||||
|
* @short_description: a structure storing information about a house system
|
||||||
|
* @title: GsweHouseSystemInfo
|
||||||
|
* @stability: Stable
|
||||||
|
* @include: swe-glib.h
|
||||||
|
*
|
||||||
|
* #GsweHouseSystemInfo stores information of a house system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE(GsweHouseSystemInfo, gswe_house_system_info, (GBoxedCopyFunc)gswe_house_system_info_ref, (GBoxedFreeFunc)gswe_house_system_info_unref);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gswe_house_system_info_free(GsweHouseSystemInfo *house_system_info)
|
||||||
|
{
|
||||||
|
if (house_system_info->name) {
|
||||||
|
g_free(house_system_info->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(house_system_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_system_info_new:
|
||||||
|
*
|
||||||
|
* Creates a new #GsweHouseSystemInfo with reference count of 1.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweHouseSystemInfo
|
||||||
|
*/
|
||||||
|
GsweHouseSystemInfo *
|
||||||
|
gswe_house_system_info_new(void)
|
||||||
|
{
|
||||||
|
GsweHouseSystemInfo *ret;
|
||||||
|
|
||||||
|
ret = g_new0(GsweHouseSystemInfo, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_system_info_ref:
|
||||||
|
* @house_system_info: (in): a #GsweHouseSystemInfo
|
||||||
|
*
|
||||||
|
* Increases reference count on @house_system_info by one.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GsweHouseSystemInfo
|
||||||
|
*/
|
||||||
|
GsweHouseSystemInfo *
|
||||||
|
gswe_house_system_info_ref(GsweHouseSystemInfo *house_system_info)
|
||||||
|
{
|
||||||
|
house_system_info->refcount++;
|
||||||
|
|
||||||
|
return house_system_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_system_info_unref:
|
||||||
|
* @house_system_info: a #GsweHouseSystemInfo
|
||||||
|
*
|
||||||
|
* Decreases reference count on @house_system_info by one. If reference count
|
||||||
|
* drops to zero, @house_system_info is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_house_system_info_unref(GsweHouseSystemInfo *house_system_info)
|
||||||
|
{
|
||||||
|
if (--house_system_info->refcount == 0) {
|
||||||
|
gswe_house_system_info_free(house_system_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_system_info_set_house_system:
|
||||||
|
* @house_system_info: (in): a #GsweHouseSystemInfo
|
||||||
|
* @house_system: a #GsweHouseSystem
|
||||||
|
*
|
||||||
|
* Sets up @house_system_info to represent @house_system.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_house_system_info_set_house_system(GsweHouseSystemInfo *house_system_info, GsweHouseSystem house_system)
|
||||||
|
{
|
||||||
|
house_system_info->house_system = house_system;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_system_info_get_house_system:
|
||||||
|
* @house_system_info: (in): a #GsweHouseSystemInfo
|
||||||
|
*
|
||||||
|
* Gets the house system ID this #GsweHouseSystemInfo represents.
|
||||||
|
*
|
||||||
|
* Returns: the house system ID
|
||||||
|
*/
|
||||||
|
GsweHouseSystem
|
||||||
|
gswe_house_system_info_get_house_system(GsweHouseSystemInfo *house_system_info)
|
||||||
|
{
|
||||||
|
return house_system_info->house_system;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_system_info_set_sweph_id:
|
||||||
|
* @house_system_info: a #GsweHouseSystemInfo
|
||||||
|
* @sweph_id: a character recognized by Swiss Ephemeris as a house system
|
||||||
|
*
|
||||||
|
* Sets up @house_system_info to represent the Swiss Ephemeris house system
|
||||||
|
* marked by @sweph_id.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_house_system_info_set_sweph_id(GsweHouseSystemInfo *house_system_info, gchar sweph_id)
|
||||||
|
{
|
||||||
|
house_system_info->sweph_id = sweph_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_system_info_get_sweph_id:
|
||||||
|
* @house_system_info: (in): a #GsweHouseSystemInfo
|
||||||
|
*
|
||||||
|
* Gets the Swiss Ephemeris ID for the house system.
|
||||||
|
*
|
||||||
|
* Returns: the character representing this house system in Swiss Ephemeris
|
||||||
|
*/
|
||||||
|
gchar
|
||||||
|
gswe_house_system_info_get_sweph_id(GsweHouseSystemInfo *house_system_info)
|
||||||
|
{
|
||||||
|
return house_system_info->sweph_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_system_info_set_name:
|
||||||
|
* @house_system_info: a #GsweHouseSystemInfo
|
||||||
|
* @name: the new name for this house system
|
||||||
|
*
|
||||||
|
* Sets the name of @house_system_info.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_house_system_info_set_name(GsweHouseSystemInfo *house_system_info, const gchar *name)
|
||||||
|
{
|
||||||
|
if (house_system_info->name) {
|
||||||
|
g_free(house_system_info->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
house_system_info->name = g_strdup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_system_info_get_name:
|
||||||
|
* @house_system_info: (in): a #GsweHouseSystemInfo
|
||||||
|
*
|
||||||
|
* Gets the name of the house system.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the name of the house system
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
gswe_house_system_info_get_name(GsweHouseSystemInfo *house_system_info)
|
||||||
|
{
|
||||||
|
return house_system_info->name;
|
||||||
|
}
|
||||||
|
|
57
src/gswe-house-system-info.h
Normal file
57
src/gswe-house-system-info.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/* gswe-house-system-info.h: House system information
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef __SWE_GLIB_GSWE_HOUSE_SYSTEM_INFO_H__
|
||||||
|
#define __SWE_GLIB_GSWE_HOUSE_SYSTEM_INFO_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GsweHouseSystemInfo:
|
||||||
|
*
|
||||||
|
* <structname>GsweHouseSystemInfo</structname> is an opaque structure whose members
|
||||||
|
* cannot be accessed directly.
|
||||||
|
*
|
||||||
|
* Since: 1.1
|
||||||
|
*/
|
||||||
|
typedef struct _GsweHouseSystemInfo GsweHouseSystemInfo;
|
||||||
|
|
||||||
|
GType gswe_house_system_info_get_type(void);
|
||||||
|
#define GSWE_TYPE_HOUSE_SYSTEM_INFO (gswe_house_system_info_get_type())
|
||||||
|
|
||||||
|
GsweHouseSystemInfo *gswe_house_system_info_new(void);
|
||||||
|
|
||||||
|
GsweHouseSystemInfo *gswe_house_system_info_ref(GsweHouseSystemInfo *house_system_info);
|
||||||
|
void gswe_house_system_info_unref(GsweHouseSystemInfo *house_system_info);
|
||||||
|
|
||||||
|
void gswe_house_system_info_set_house_system(GsweHouseSystemInfo *house_system_info, GsweHouseSystem house_system);
|
||||||
|
GsweHouseSystem gswe_house_system_info_get_house_system(GsweHouseSystemInfo *house_system_info);
|
||||||
|
|
||||||
|
void gswe_house_system_info_set_sweph_id(GsweHouseSystemInfo *house_system_info, gchar sweph_id);
|
||||||
|
gchar gswe_house_system_info_get_sweph_id(GsweHouseSystemInfo *house_system_info);
|
||||||
|
|
||||||
|
void gswe_house_system_info_set_name(GsweHouseSystemInfo *house_system_info, const gchar *name);
|
||||||
|
const gchar *gswe_house_system_info_get_name(GsweHouseSystemInfo *house_system_info);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_HOUSE_SYSTEM_INFO_H__ */
|
||||||
|
|
@@ -16,12 +16,12 @@
|
|||||||
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "swe-glib.h"
|
#include "swe-glib.h"
|
||||||
#include "gswe-types.h"
|
|
||||||
#include "gswe-moment.h"
|
|
||||||
#include "swe-glib-private.h"
|
#include "swe-glib-private.h"
|
||||||
|
|
||||||
#include "../swe/src/swephexp.h"
|
#include "../swe/src/swephexp.h"
|
||||||
|
|
||||||
|
#define glforeach(a, b) for ((a) = (b); (a); (a) = g_list_next((a)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:gswe-moment
|
* SECTION:gswe-moment
|
||||||
* @short_description: an exact moment of the sky, as seen from a given point
|
* @short_description: an exact moment of the sky, as seen from a given point
|
||||||
@@ -34,8 +34,6 @@
|
|||||||
* one given point on Earth at a given time.
|
* one given point on Earth at a given time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SYNODIC 29.53058867
|
|
||||||
|
|
||||||
#define GSWE_MOMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GSWE_TYPE_MOMENT, GsweMomentPrivate))
|
#define GSWE_MOMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GSWE_TYPE_MOMENT, GsweMomentPrivate))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,7 +75,7 @@ struct _GsweMomentPrivate {
|
|||||||
GHashTable *element_points;
|
GHashTable *element_points;
|
||||||
GHashTable *quality_points;
|
GHashTable *quality_points;
|
||||||
guint moon_phase_revision;
|
guint moon_phase_revision;
|
||||||
GsweMoonPhaseData moon_phase;
|
GsweMoonPhaseData *moon_phase;
|
||||||
GList *aspect_list;
|
GList *aspect_list;
|
||||||
guint aspect_revision;
|
guint aspect_revision;
|
||||||
GList *antiscia_list;
|
GList *antiscia_list;
|
||||||
@@ -168,6 +166,7 @@ gswe_moment_init(GsweMoment *moment)
|
|||||||
moment->priv->planet_list = NULL;
|
moment->priv->planet_list = NULL;
|
||||||
moment->priv->aspect_list = NULL;
|
moment->priv->aspect_list = NULL;
|
||||||
moment->priv->antiscia_list = NULL;
|
moment->priv->antiscia_list = NULL;
|
||||||
|
moment->priv->moon_phase = gswe_moon_phase_data_new();
|
||||||
moment->priv->element_points = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
|
moment->priv->element_points = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
|
||||||
moment->priv->quality_points = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
|
moment->priv->quality_points = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
|
||||||
moment->priv->house_revision = 0;
|
moment->priv->house_revision = 0;
|
||||||
@@ -202,8 +201,14 @@ gswe_moment_finalize(GObject *gobject)
|
|||||||
{
|
{
|
||||||
GsweMoment *moment = GSWE_MOMENT(gobject);
|
GsweMoment *moment = GSWE_MOMENT(gobject);
|
||||||
|
|
||||||
g_list_free_full(moment->priv->house_list, g_free);
|
g_list_free_full(moment->priv->house_list, (GDestroyNotify)gswe_house_data_unref);
|
||||||
g_list_free_full(moment->priv->planet_list, g_free);
|
g_list_free_full(moment->priv->planet_list, (GDestroyNotify)gswe_planet_data_unref);
|
||||||
|
g_list_free_full(moment->priv->aspect_list, (GDestroyNotify)gswe_aspect_data_unref);
|
||||||
|
g_list_free_full(moment->priv->antiscia_list, (GDestroyNotify)gswe_antiscion_data_unref);
|
||||||
|
g_object_unref(moment->priv->timestamp);
|
||||||
|
gswe_moon_phase_data_unref(moment->priv->moon_phase);
|
||||||
|
g_hash_table_unref(moment->priv->element_points);
|
||||||
|
g_hash_table_unref(moment->priv->quality_points);
|
||||||
|
|
||||||
G_OBJECT_CLASS(gswe_moment_parent_class)->finalize(gobject);
|
G_OBJECT_CLASS(gswe_moment_parent_class)->finalize(gobject);
|
||||||
}
|
}
|
||||||
@@ -256,6 +261,7 @@ gswe_moment_get_property(GObject *object, guint prop_id, GValue *value, GParamSp
|
|||||||
case PROP_COORDINATES:
|
case PROP_COORDINATES:
|
||||||
{
|
{
|
||||||
GsweCoordinates *coords = gswe_coordinates_copy(&(priv->coordinates));
|
GsweCoordinates *coords = gswe_coordinates_copy(&(priv->coordinates));
|
||||||
|
|
||||||
g_value_set_boxed(value, coords);
|
g_value_set_boxed(value, coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,15 +393,6 @@ gswe_moment_get_house_system(GsweMoment *moment)
|
|||||||
return moment->priv->house_system;
|
return moment->priv->house_system;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gswe_moment_error_quark:
|
|
||||||
*
|
|
||||||
* Gets the GsweMoment Error Quark.
|
|
||||||
*
|
|
||||||
* Return value: a #GQuark
|
|
||||||
*/
|
|
||||||
G_DEFINE_QUARK(gswe-moment-error-quark, gswe_moment_error);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gswe_moment_new:
|
* gswe_moment_new:
|
||||||
*
|
*
|
||||||
@@ -408,6 +405,8 @@ G_DEFINE_QUARK(gswe-moment-error-quark, gswe_moment_error);
|
|||||||
GsweMoment *
|
GsweMoment *
|
||||||
gswe_moment_new(void)
|
gswe_moment_new(void)
|
||||||
{
|
{
|
||||||
|
gswe_init();
|
||||||
|
|
||||||
return (GsweMoment *)g_object_new(GSWE_TYPE_MOMENT, NULL);
|
return (GsweMoment *)g_object_new(GSWE_TYPE_MOMENT, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,12 +441,13 @@ gswe_moment_new_full(GsweTimestamp *timestamp, gdouble longitude, gdouble latitu
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
find_by_planet_id(gconstpointer a, gconstpointer b)
|
find_planet_by_id(GswePlanetData *planet_data, GswePlanet *planet)
|
||||||
{
|
{
|
||||||
const GswePlanetData *planet_data = a;
|
if (planet_data->planet_info == NULL) {
|
||||||
const GswePlanet *planet = b;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (planet_data->planet_id == *planet) {
|
if (planet_data->planet_info->planet == *planet) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,13 +455,18 @@ find_by_planet_id(gconstpointer a, gconstpointer b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gswe_calculate_data_by_position(GsweMoment *moment, GswePlanet planet, gdouble position, GError **err)
|
calculate_data_by_position(GsweMoment *moment, GswePlanet planet, gdouble position, GError **err)
|
||||||
{
|
{
|
||||||
GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, find_by_planet_id)->data);
|
GswePlanetData *planet_data;
|
||||||
GsweZodiac sign;
|
GsweZodiac sign;
|
||||||
GsweSignInfo *sign_info;
|
GsweSignInfo *sign_info;
|
||||||
|
GList *result;
|
||||||
|
|
||||||
if (planet_data == NULL) {
|
if ((result = g_list_find_custom(moment->priv->planet_list, &planet, (GCompareFunc)find_planet_by_id)) == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((planet_data = (GswePlanetData *)(result->data)) == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,7 +489,7 @@ gswe_calculate_data_by_position(GsweMoment *moment, GswePlanet planet, gdouble p
|
|||||||
planet_data->position = position;
|
planet_data->position = position;
|
||||||
planet_data->retrograde = FALSE;
|
planet_data->retrograde = FALSE;
|
||||||
planet_data->house = gswe_moment_get_house(moment, position, err);
|
planet_data->house = gswe_moment_get_house(moment, position, err);
|
||||||
planet_data->sign = sign_info;
|
planet_data->sign_info = gswe_sign_info_ref(sign_info);
|
||||||
planet_data->revision = moment->priv->revision;
|
planet_data->revision = moment->priv->revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,13 +500,13 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err)
|
|||||||
ascmc[10],
|
ascmc[10],
|
||||||
jd;
|
jd;
|
||||||
gint i;
|
gint i;
|
||||||
GsweHouseSystemInfo *house_system_data;
|
GsweHouseSystemInfo *house_system_info;
|
||||||
|
|
||||||
if (moment->priv->house_revision == moment->priv->revision) {
|
if (moment->priv->house_revision == moment->priv->revision) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free_full(moment->priv->house_list, g_free);
|
g_list_free_full(moment->priv->house_list, (GDestroyNotify)gswe_house_data_unref);
|
||||||
moment->priv->house_list = NULL;
|
moment->priv->house_list = NULL;
|
||||||
|
|
||||||
// If no house system is set, we need no calculations at all. Just leave
|
// If no house system is set, we need no calculations at all. Just leave
|
||||||
@@ -512,8 +517,8 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((house_system_data = g_hash_table_lookup(gswe_house_system_info_table, GINT_TO_POINTER(moment->priv->house_system))) == NULL) {
|
if ((house_system_info = g_hash_table_lookup(gswe_house_system_info_table, GINT_TO_POINTER(moment->priv->house_system))) == NULL) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_UNKNOWN_HSYS, "Unknown house system");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_HSYS, "Unknown house system");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -526,44 +531,46 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
swe_houses(jd, moment->priv->coordinates.latitude, moment->priv->coordinates.longitude, house_system_data->sweph_id, cusps, ascmc);
|
swe_houses(jd, moment->priv->coordinates.latitude, moment->priv->coordinates.longitude, house_system_info->sweph_id, cusps, ascmc);
|
||||||
|
|
||||||
/* TODO: SWE house system 'G' (Gauquelin sector cusps) have 36 houses; we
|
/* TODO: SWE house system 'G' (Gauquelin sector cusps) have 36 houses; we
|
||||||
* should detect that somehow (house system 'G' is not implemented yet in
|
* should detect that somehow (house system 'G' is not implemented yet in
|
||||||
* GsweHouseSystem, and all other house systems have exactly 12 houses, so
|
* GsweHouseSystem, and all other house systems have exactly 12 houses, so
|
||||||
* this should not cause trouble yet, though) */
|
* this should not cause trouble yet, though) */
|
||||||
for (i = 12; i >= 1; i--) {
|
for (i = 12; i >= 1; i--) {
|
||||||
GsweHouseData *house_data = g_new0(GsweHouseData, 1);
|
GsweSignInfo *sign_info;
|
||||||
|
GsweHouseData *house_data = gswe_house_data_new();
|
||||||
|
|
||||||
house_data->house = i;
|
house_data->house = i;
|
||||||
house_data->cusp_position = cusps[i];
|
house_data->cusp_position = cusps[i];
|
||||||
|
|
||||||
if ((house_data->sign = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER((gint)ceilf(cusps[i] / 30.0)))) == NULL) {
|
if ((sign_info = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER((gint)ceilf(cusps[i] / 30.0)))) == NULL) {
|
||||||
g_list_free_full(moment->priv->house_list, g_free);
|
g_list_free_full(moment->priv->house_list, (GDestroyNotify)gswe_house_data_unref);
|
||||||
moment->priv->house_list = NULL;
|
moment->priv->house_list = NULL;
|
||||||
moment->priv->house_revision = 0;
|
moment->priv->house_revision = 0;
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_UNKNOWN_SIGN, "Calculation brought an unknown sign");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, "Calculation brought an unknown sign");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
house_data->sign_info = gswe_sign_info_ref(sign_info);
|
||||||
moment->priv->house_list = g_list_prepend(moment->priv->house_list, house_data);
|
moment->priv->house_list = g_list_prepend(moment->priv->house_list, house_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
moment->priv->house_revision = moment->priv->revision;
|
moment->priv->house_revision = moment->priv->revision;
|
||||||
|
|
||||||
// The Ascendent, MC and Vertex points are also calculated by swe_houses(),
|
// The Ascendant, MC and Vertex points are also calculated by swe_houses(),
|
||||||
// so let's update them.
|
// so let's update them.
|
||||||
if (gswe_moment_has_planet(moment, GSWE_PLANET_ASCENDENT)) {
|
if (gswe_moment_has_planet(moment, GSWE_PLANET_ASCENDANT)) {
|
||||||
gswe_calculate_data_by_position(moment, GSWE_PLANET_ASCENDENT, ascmc[0], err);
|
calculate_data_by_position(moment, GSWE_PLANET_ASCENDANT, ascmc[0], err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gswe_moment_has_planet(moment, GSWE_PLANET_MC)) {
|
if (gswe_moment_has_planet(moment, GSWE_PLANET_MC)) {
|
||||||
gswe_calculate_data_by_position(moment, GSWE_PLANET_MC, ascmc[1], err);
|
calculate_data_by_position(moment, GSWE_PLANET_MC, ascmc[1], err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gswe_moment_has_planet(moment, GSWE_PLANET_VERTEX)) {
|
if (gswe_moment_has_planet(moment, GSWE_PLANET_VERTEX)) {
|
||||||
gswe_calculate_data_by_position(moment, GSWE_PLANET_VERTEX, ascmc[3], err);
|
calculate_data_by_position(moment, GSWE_PLANET_VERTEX, ascmc[3], err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,20 +605,22 @@ gswe_moment_get_house_cusps(GsweMoment *moment, GError **err)
|
|||||||
gboolean
|
gboolean
|
||||||
gswe_moment_has_planet(GsweMoment *moment, GswePlanet planet)
|
gswe_moment_has_planet(GsweMoment *moment, GswePlanet planet)
|
||||||
{
|
{
|
||||||
return (g_list_find_custom(moment->priv->planet_list, &planet, find_by_planet_id) != NULL);
|
return (g_list_find_custom(moment->priv->planet_list, &planet, (GCompareFunc)find_planet_by_id) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gswe_moment_add_planet:
|
* gswe_moment_add_planet:
|
||||||
* @moment: a GsweMoment object
|
* @moment: a GsweMoment object
|
||||||
* @planet: the planet to add
|
* @planet: the planet to add
|
||||||
|
* @err: a #GError
|
||||||
*
|
*
|
||||||
* Adds @planet to the calculated planets of @moment.
|
* Adds @planet to the calculated planets of @moment. @err is populated with
|
||||||
|
* GSWE_ERROR_UNKNOWN_PLANET if the given planet is not known to SWE-GLib.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet)
|
gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet, GError **err)
|
||||||
{
|
{
|
||||||
GswePlanetData *planet_data = g_new0(GswePlanetData, 1);
|
GswePlanetData *planet_data;
|
||||||
GswePlanetInfo *planet_info;
|
GswePlanetInfo *planet_info;
|
||||||
|
|
||||||
if (gswe_moment_has_planet(moment, planet)) {
|
if (gswe_moment_has_planet(moment, planet)) {
|
||||||
@@ -619,32 +628,24 @@ gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((planet_info = g_hash_table_lookup(gswe_planet_info_table, GINT_TO_POINTER(planet))) == NULL) {
|
if ((planet_info = g_hash_table_lookup(gswe_planet_info_table, GINT_TO_POINTER(planet))) == NULL) {
|
||||||
// TODO: Some real error checking should be done here, like checking if
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Unknown planet");
|
||||||
// @planet is really from GswePlanet. If so, that is a fatal error.
|
|
||||||
// Otherwise, the developer erred, and a warning may be still issued.
|
|
||||||
// Also, a GError ** should be added to the parameters.
|
|
||||||
g_warning("Unknown planet ID: %d", planet);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
planet_data->planet_id = planet;
|
planet_data = gswe_planet_data_new();
|
||||||
planet_data->planet_info = planet_info;
|
planet_data->planet_info = gswe_planet_info_ref(planet_info);
|
||||||
planet_data->position = 0.0;
|
|
||||||
planet_data->house = 0;
|
|
||||||
planet_data->sign = NULL;
|
|
||||||
planet_data->revision = 0;
|
planet_data->revision = 0;
|
||||||
|
|
||||||
moment->priv->planet_list = g_list_append(moment->priv->planet_list, planet_data);
|
moment->priv->planet_list = g_list_append(moment->priv->planet_list, planet_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
planet_add(gpointer key, gpointer value, gpointer user_data)
|
planet_add(gpointer key, gpointer value, GsweMoment *moment)
|
||||||
{
|
{
|
||||||
GswePlanet planet = (GswePlanet)GPOINTER_TO_INT(key);
|
GswePlanet planet = (GswePlanet)GPOINTER_TO_INT(key);
|
||||||
GsweMoment *moment = GSWE_MOMENT(user_data);
|
|
||||||
|
|
||||||
gswe_moment_add_planet(moment, planet);
|
gswe_moment_add_planet(moment, planet, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -656,13 +657,13 @@ planet_add(gpointer key, gpointer value, gpointer user_data)
|
|||||||
void
|
void
|
||||||
gswe_moment_add_all_planets(GsweMoment *moment)
|
gswe_moment_add_all_planets(GsweMoment *moment)
|
||||||
{
|
{
|
||||||
g_hash_table_foreach(gswe_planet_info_table, planet_add, moment);
|
g_hash_table_foreach(gswe_planet_info_table, (GHFunc)planet_add, moment);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gswe_moment_calculate_planet(GsweMoment *moment, GswePlanet planet, GError **err)
|
gswe_moment_calculate_planet(GsweMoment *moment, GswePlanet planet, GError **err)
|
||||||
{
|
{
|
||||||
GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, find_by_planet_id)->data);
|
GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, (GCompareFunc)find_planet_by_id)->data);
|
||||||
gchar serr[AS_MAXCH];
|
gchar serr[AS_MAXCH];
|
||||||
gint ret;
|
gint ret;
|
||||||
gdouble x2[6],
|
gdouble x2[6],
|
||||||
@@ -677,29 +678,40 @@ gswe_moment_calculate_planet(GsweMoment *moment, GswePlanet planet, GError **err
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This function should know about Ascendant, MC and Vertex, so it could calculate their positions, too
|
|
||||||
if (planet_data->planet_info->real_body == FALSE) {
|
|
||||||
g_warning("The position data of planet %d can not be calculated by this function", planet);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
swe_set_topo(moment->priv->coordinates.longitude, moment->priv->coordinates.latitude, moment->priv->coordinates.altitude);
|
swe_set_topo(moment->priv->coordinates.longitude, moment->priv->coordinates.latitude, moment->priv->coordinates.altitude);
|
||||||
jd = gswe_timestamp_get_julian_day(moment->priv->timestamp, err);
|
jd = gswe_timestamp_get_julian_day(moment->priv->timestamp, err);
|
||||||
|
|
||||||
|
if (planet_data->planet_info->real_body == FALSE) {
|
||||||
|
if (
|
||||||
|
(planet_data->planet_info->planet != GSWE_PLANET_ASCENDANT)
|
||||||
|
&& (planet_data->planet_info->planet != GSWE_PLANET_MC)
|
||||||
|
&& (planet_data->planet_info->planet != GSWE_PLANET_VERTEX)
|
||||||
|
) {
|
||||||
|
g_warning("The position data of planet %d can not be calculated by this function", planet);
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// gswe_moment_calculate_house_positions() calculates house cusp
|
||||||
|
// positions, together with Ascendant, MC and Vertex points
|
||||||
|
gswe_moment_calculate_house_positions(moment, err);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((err) && (*err)) {
|
if ((err) && (*err)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = swe_calc(jd, planet_data->planet_info->sweph_id, SEFLG_SPEED | SEFLG_TOPOCTR, x2, serr)) < 0) {
|
if ((ret = swe_calc(jd, planet_data->planet_info->sweph_id, SEFLG_SPEED | SEFLG_TOPOCTR, x2, serr)) < 0) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_SWE_ERROR_FATAL, "Swiss Ephemeris error: %s", serr);
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_SWE_FATAL, "Swiss Ephemeris error: %s", serr);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (ret != (SEFLG_SPEED | SEFLG_TOPOCTR)) {
|
} else if (ret != (SEFLG_SPEED | SEFLG_TOPOCTR)) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_SWE_ERROR_NONFATAL, "Swiss Ephemeris error: %s", serr);
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_SWE_NONFATAL, "Swiss Ephemeris error: %s", serr);
|
||||||
}
|
}
|
||||||
|
|
||||||
gswe_calculate_data_by_position(moment, planet, x2[0], &calc_err);
|
calculate_data_by_position(moment, planet, x2[0], &calc_err);
|
||||||
|
|
||||||
if (calc_err != NULL) {
|
if (calc_err != NULL) {
|
||||||
g_clear_error(err);
|
g_clear_error(err);
|
||||||
@@ -715,7 +727,11 @@ gswe_moment_calculate_planet(GsweMoment *moment, GswePlanet planet, GError **err
|
|||||||
static void
|
static void
|
||||||
calculate_planet(GswePlanetData *planet_data, GsweMoment *moment)
|
calculate_planet(GswePlanetData *planet_data, GsweMoment *moment)
|
||||||
{
|
{
|
||||||
gswe_moment_calculate_planet(moment, planet_data->planet_id, NULL);
|
if (planet_data->planet_info) {
|
||||||
|
gswe_moment_calculate_planet(moment, planet_data->planet_info->planet, NULL);
|
||||||
|
} else {
|
||||||
|
g_warning("planet_data holds no planet. This is a possible bug in SWE-GLib, or in your application.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -758,10 +774,10 @@ gswe_moment_get_sign_planets(GsweMoment *moment, GsweZodiac sign)
|
|||||||
|
|
||||||
gswe_moment_calculate_all_planets(moment);
|
gswe_moment_calculate_all_planets(moment);
|
||||||
|
|
||||||
for (planet = moment->priv->planet_list; planet; planet = g_list_next(planet)) {
|
glforeach (planet, moment->priv->planet_list) {
|
||||||
GswePlanetData *pd = planet->data;
|
GswePlanetData *pd = planet->data;
|
||||||
|
|
||||||
if (pd->sign->sign_id == sign) {
|
if (pd->sign_info->sign == sign) {
|
||||||
ret = g_list_prepend(ret, pd);
|
ret = g_list_prepend(ret, pd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -792,7 +808,7 @@ gswe_moment_get_house_planets(GsweMoment *moment, guint house)
|
|||||||
|
|
||||||
gswe_moment_calculate_all_planets(moment);
|
gswe_moment_calculate_all_planets(moment);
|
||||||
|
|
||||||
for (planet = moment->priv->planet_list; planet; planet = g_list_next(planet)) {
|
glforeach (planet, moment->priv->planet_list) {
|
||||||
GswePlanetData *pd = planet->data;
|
GswePlanetData *pd = planet->data;
|
||||||
|
|
||||||
if (pd->house == house) {
|
if (pd->house == house) {
|
||||||
@@ -862,22 +878,22 @@ gswe_moment_get_house(GsweMoment *moment, gdouble position, GError **err)
|
|||||||
* warning. Thus, you should always provide a non-NULL value for @err, and
|
* warning. Thus, you should always provide a non-NULL value for @err, and
|
||||||
* always check it after calling this function.
|
* always check it after calling this function.
|
||||||
*
|
*
|
||||||
* Returns: (transfer none): @planet's data
|
* Returns: (transfer full): @planet's data
|
||||||
*/
|
*/
|
||||||
const GswePlanetData *
|
GswePlanetData *
|
||||||
gswe_moment_get_planet(GsweMoment *moment, GswePlanet planet, GError **err)
|
gswe_moment_get_planet(GsweMoment *moment, GswePlanet planet, GError **err)
|
||||||
{
|
{
|
||||||
GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, find_by_planet_id)->data);
|
GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, (GCompareFunc)find_planet_by_id)->data);
|
||||||
|
|
||||||
if (planet_data == NULL) {
|
if (planet_data == NULL) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Specified planet is not added to the moment object");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gswe_moment_calculate_planet(moment, planet, err);
|
gswe_moment_calculate_planet(moment, planet, err);
|
||||||
|
|
||||||
return planet_data;
|
return gswe_planet_data_ref(planet_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -885,15 +901,13 @@ add_points(GswePlanetData *planet_data, GsweMoment *moment)
|
|||||||
{
|
{
|
||||||
guint point;
|
guint point;
|
||||||
|
|
||||||
gswe_moment_calculate_planet(moment, planet_data->planet_id, NULL);
|
gswe_moment_calculate_planet(moment, planet_data->planet_info->planet, NULL);
|
||||||
|
|
||||||
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign->element))) + planet_data->planet_info->points;
|
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign_info->element))) + planet_data->planet_info->points;
|
||||||
g_hash_table_replace(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign->element), GINT_TO_POINTER(point));
|
g_hash_table_replace(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign_info->element), GINT_TO_POINTER(point));
|
||||||
|
|
||||||
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign->quality)));
|
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign_info->quality))) + planet_data->planet_info->points;
|
||||||
|
g_hash_table_replace(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign_info->quality), GINT_TO_POINTER(point));
|
||||||
point += planet_data->planet_info->points;
|
|
||||||
g_hash_table_replace(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign->quality), GINT_TO_POINTER(point));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -960,114 +974,43 @@ gswe_moment_get_quality_points(GsweMoment *moment, GsweQuality quality)
|
|||||||
*
|
*
|
||||||
* Gets the phase of the Moon.
|
* Gets the phase of the Moon.
|
||||||
*
|
*
|
||||||
* Returns: (transfer none): a #GsweMoonPhaseData representing the phase of the Moon
|
* Returns: (transfer full): a #GsweMoonPhaseData representing the phase of the Moon
|
||||||
*/
|
*/
|
||||||
const GsweMoonPhaseData *
|
GsweMoonPhaseData *
|
||||||
gswe_moment_get_moon_phase(GsweMoment *moment, GError **err)
|
gswe_moment_get_moon_phase(GsweMoment *moment, GError **err)
|
||||||
{
|
{
|
||||||
gdouble difference,
|
|
||||||
phase_percent,
|
|
||||||
jd,
|
|
||||||
jdb;
|
|
||||||
|
|
||||||
if (moment->priv->moon_phase_revision == moment->priv->revision) {
|
if (moment->priv->moon_phase_revision == moment->priv->revision) {
|
||||||
return &(moment->priv->moon_phase);
|
return moment->priv->moon_phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
jd = gswe_timestamp_get_julian_day(moment->priv->timestamp, err);
|
gswe_moon_phase_data_calculate_by_timestamp(moment->priv->moon_phase, moment->priv->timestamp, err);
|
||||||
|
|
||||||
if ((err) && (*err)) {
|
if (!err || !*err) {
|
||||||
return NULL;
|
moment->priv->moon_phase_revision = moment->priv->revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
jdb = gswe_timestamp_get_julian_day(gswe_full_moon_base_date, err);
|
return gswe_moon_phase_data_ref(moment->priv->moon_phase);
|
||||||
|
|
||||||
if ((err) && (*err)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
difference = (jd - jdb);
|
|
||||||
phase_percent = fmod((difference * 100) / SYNODIC, 100);
|
|
||||||
|
|
||||||
if (phase_percent < 0) {
|
|
||||||
phase_percent += 100.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((phase_percent < 0) || (phase_percent > 100)) {
|
|
||||||
g_error("Error during Moon phase calculation!");
|
|
||||||
}
|
|
||||||
|
|
||||||
moment->priv->moon_phase.illumination = (50.0 - fabs(phase_percent - 50.0)) * 2;
|
|
||||||
|
|
||||||
if (phase_percent == 0) {
|
|
||||||
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_NEW;
|
|
||||||
} else if (phase_percent < 25) {
|
|
||||||
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WAXING_CRESCENT;
|
|
||||||
} else if (phase_percent == 25) {
|
|
||||||
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WAXING_HALF;
|
|
||||||
} else if (phase_percent < 50) {
|
|
||||||
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WAXING_GIBBOUS;
|
|
||||||
} else if (phase_percent == 50) {
|
|
||||||
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_FULL;
|
|
||||||
} else if (phase_percent < 75) {
|
|
||||||
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WANING_GIBBOUS;
|
|
||||||
} else if (phase_percent == 75) {
|
|
||||||
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WANING_HALF;
|
|
||||||
} else if (phase_percent < 100) {
|
|
||||||
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WANING_CRESCENT;
|
|
||||||
} else {
|
|
||||||
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_DARK;
|
|
||||||
}
|
|
||||||
|
|
||||||
moment->priv->moon_phase_revision = moment->priv->revision;
|
|
||||||
|
|
||||||
return &(moment->priv->moon_phase);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
find_aspect_by_both_planets(GsweAspectData *aspect, struct GsweAspectFinder *aspect_finder)
|
find_aspect_by_both_planets(GsweAspectData *aspect, struct GsweAspectFinder *aspect_finder)
|
||||||
{
|
{
|
||||||
if (((aspect->planet1->planet_id == aspect_finder->planet1) && (aspect->planet2->planet_id == aspect_finder->planet2)) || ((aspect->planet1->planet_id == aspect_finder->planet2) && (aspect->planet2->planet_id == aspect_finder->planet1))) {
|
if (
|
||||||
|
(
|
||||||
|
(aspect->planet1->planet_info->planet == aspect_finder->planet1)
|
||||||
|
&& (aspect->planet2->planet_info->planet == aspect_finder->planet2)
|
||||||
|
)
|
||||||
|
|| (
|
||||||
|
(aspect->planet1->planet_info->planet == aspect_finder->planet2)
|
||||||
|
&& (aspect->planet2->planet_info->planet == aspect_finder->planet1)
|
||||||
|
)
|
||||||
|
) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
find_aspect(gpointer aspect_p, GsweAspectInfo *aspect_info, GsweAspectData *aspect_data)
|
|
||||||
{
|
|
||||||
GsweAspect aspect = GPOINTER_TO_INT(aspect_p);
|
|
||||||
gdouble diff,
|
|
||||||
planet_orb,
|
|
||||||
aspect_orb;
|
|
||||||
|
|
||||||
aspect_data->distance = fabs(aspect_data->planet1->position - aspect_data->planet2->position);
|
|
||||||
|
|
||||||
if (aspect_data->distance > 180.0) {
|
|
||||||
aspect_data->distance = 360.0 - aspect_data->distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff = fabs(aspect_info->size - aspect_data->distance);
|
|
||||||
planet_orb = fmin(aspect_data->planet1->planet_info->orb, aspect_data->planet2->planet_info->orb);
|
|
||||||
aspect_orb = fmax(1.0, planet_orb - aspect_info->orb_modifier);
|
|
||||||
|
|
||||||
if (diff < aspect_orb) {
|
|
||||||
aspect_data->aspect = aspect;
|
|
||||||
aspect_data->aspect_info = aspect_info;
|
|
||||||
|
|
||||||
if (aspect_info->size == 0) {
|
|
||||||
aspect_data->difference = (1 - ((360.0 - diff) / 360.0)) * 100.0;
|
|
||||||
} else {
|
|
||||||
aspect_data->difference = (1 - ((aspect_info->size - diff) / aspect_info->size)) * 100.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gswe_moment_calculate_aspects(GsweMoment *moment)
|
gswe_moment_calculate_aspects(GsweMoment *moment)
|
||||||
{
|
{
|
||||||
@@ -1079,39 +1022,30 @@ gswe_moment_calculate_aspects(GsweMoment *moment)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gswe_moment_calculate_all_planets(moment);
|
gswe_moment_calculate_all_planets(moment);
|
||||||
g_list_free_full(moment->priv->aspect_list, g_free);
|
g_list_free_full(moment->priv->aspect_list, (GDestroyNotify)gswe_aspect_data_unref);
|
||||||
moment->priv->aspect_list = NULL;
|
moment->priv->aspect_list = NULL;
|
||||||
|
|
||||||
for (oplanet = moment->priv->planet_list; oplanet; oplanet = oplanet->next) {
|
for (oplanet = moment->priv->planet_list; oplanet; oplanet = g_list_next(oplanet)) {
|
||||||
for (iplanet = moment->priv->planet_list; iplanet; iplanet = iplanet->next) {
|
for (iplanet = moment->priv->planet_list; iplanet; iplanet = g_list_next(iplanet)) {
|
||||||
GswePlanetData *outer_planet = oplanet->data,
|
GswePlanetData *outer_planet = oplanet->data,
|
||||||
*inner_planet = iplanet->data;
|
*inner_planet = iplanet->data;
|
||||||
struct GsweAspectFinder aspect_finder;
|
struct GsweAspectFinder aspect_finder;
|
||||||
GsweAspectData *aspect_data;
|
GsweAspectData *aspect_data;
|
||||||
|
GList *aspect_data_element;
|
||||||
|
|
||||||
if (outer_planet->planet_id == inner_planet->planet_id) {
|
if (outer_planet->planet_info->planet == inner_planet->planet_info->planet) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
aspect_finder.planet1 = outer_planet->planet_id;
|
aspect_finder.planet1 = outer_planet->planet_info->planet;
|
||||||
aspect_finder.planet2 = inner_planet->planet_id;
|
aspect_finder.planet2 = inner_planet->planet_info->planet;
|
||||||
|
|
||||||
if (g_list_find_custom(moment->priv->aspect_list, &aspect_finder, (GCompareFunc)find_aspect_by_both_planets) != NULL) {
|
if ((aspect_data_element = g_list_find_custom(moment->priv->aspect_list, &aspect_finder, (GCompareFunc)find_aspect_by_both_planets)) != NULL) {
|
||||||
continue;
|
gswe_aspect_data_calculate(aspect_data_element->data);
|
||||||
|
} else {
|
||||||
|
aspect_data = gswe_aspect_data_new_with_planets(inner_planet, outer_planet);
|
||||||
|
moment->priv->aspect_list = g_list_prepend(moment->priv->aspect_list, aspect_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
aspect_data = g_new0(GsweAspectData, 1);
|
|
||||||
aspect_data->planet1 = outer_planet;
|
|
||||||
aspect_data->planet2 = inner_planet;
|
|
||||||
aspect_data->aspect = GSWE_ASPECT_NONE;
|
|
||||||
|
|
||||||
(void)g_hash_table_find(gswe_aspect_info_table, (GHRFunc)find_aspect, aspect_data);
|
|
||||||
|
|
||||||
if (aspect_data->aspect == GSWE_ASPECT_NONE) {
|
|
||||||
aspect_data->aspect_info = g_hash_table_lookup(gswe_aspect_info_table, GINT_TO_POINTER(GSWE_ASPECT_NONE));
|
|
||||||
}
|
|
||||||
|
|
||||||
moment->priv->aspect_list = g_list_prepend(moment->priv->aspect_list, aspect_data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1159,17 +1093,20 @@ gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **e
|
|||||||
*aspect;
|
*aspect;
|
||||||
|
|
||||||
if (!gswe_moment_has_planet(moment, planet)) {
|
if (!gswe_moment_has_planet(moment, planet)) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Specified planet is not added to the moment object");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gswe_moment_calculate_aspects(moment);
|
gswe_moment_calculate_aspects(moment);
|
||||||
|
|
||||||
for (aspect = moment->priv->aspect_list; aspect; aspect = aspect->next) {
|
for (aspect = moment->priv->aspect_list; aspect; aspect = g_list_next(aspect)) {
|
||||||
GsweAspectData *aspect_data = aspect->data;
|
GsweAspectData *aspect_data = aspect->data;
|
||||||
|
|
||||||
if ((aspect_data->planet1->planet_id == planet) || (aspect_data->planet2->planet_id == planet)) {
|
if (
|
||||||
|
(aspect_data->planet1->planet_info->planet == planet)
|
||||||
|
|| (aspect_data->planet2->planet_info->planet == planet)
|
||||||
|
) {
|
||||||
ret = g_list_prepend(ret, aspect_data);
|
ret = g_list_prepend(ret, aspect_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1177,47 +1114,19 @@ gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **e
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_info, GsweAntiscionData *antiscion_data)
|
|
||||||
{
|
|
||||||
GsweAntiscionAxis axis;
|
|
||||||
gdouble start_point,
|
|
||||||
axis_position,
|
|
||||||
planet_orb;
|
|
||||||
|
|
||||||
if ((axis = GPOINTER_TO_INT(axis_p)) == GSWE_ANTISCION_AXIS_NONE) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
planet_orb = fmin(antiscion_data->planet1->planet_info->orb, antiscion_data->planet2->planet_info->orb);
|
|
||||||
start_point = (antiscion_info->start_sign->sign_id - 1) * 30.0;
|
|
||||||
|
|
||||||
if (antiscion_info->middle_axis == TRUE) {
|
|
||||||
start_point += 15.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
axis_position = 2 * start_point - antiscion_data->planet1->position;
|
|
||||||
|
|
||||||
if (axis_position < 0) {
|
|
||||||
axis_position += 360.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((antiscion_data->difference = fabs(antiscion_data->planet2->position - axis_position)) <= planet_orb) {
|
|
||||||
antiscion_data->antiscion_info = antiscion_info;
|
|
||||||
antiscion_data->axis = axis;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
} else {
|
|
||||||
antiscion_data->difference = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
find_antiscion_by_both_planets(GsweAntiscionData *antiscion, struct GsweAspectFinder *antiscion_finder)
|
find_antiscion_by_both_planets(GsweAntiscionData *antiscion, struct GsweAspectFinder *antiscion_finder)
|
||||||
{
|
{
|
||||||
if (((antiscion->planet1->planet_id == antiscion_finder->planet1) && (antiscion->planet2->planet_id == antiscion_finder->planet2)) || ((antiscion->planet1->planet_id == antiscion_finder->planet2) && (antiscion->planet2->planet_id == antiscion_finder->planet1))) {
|
if (
|
||||||
|
(
|
||||||
|
(antiscion->planet1->planet_info->planet == antiscion_finder->planet1)
|
||||||
|
&& (antiscion->planet2->planet_info->planet == antiscion_finder->planet2)
|
||||||
|
)
|
||||||
|
|| (
|
||||||
|
(antiscion->planet1->planet_info->planet == antiscion_finder->planet2)
|
||||||
|
&& (antiscion->planet2->planet_info->planet == antiscion_finder->planet1)
|
||||||
|
)
|
||||||
|
) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1235,39 +1144,30 @@ gswe_moment_calculate_antiscia(GsweMoment *moment)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gswe_moment_calculate_all_planets(moment);
|
gswe_moment_calculate_all_planets(moment);
|
||||||
g_list_free_full(moment->priv->antiscia_list, g_free);
|
g_list_free_full(moment->priv->antiscia_list, (GDestroyNotify)gswe_antiscion_data_unref);
|
||||||
moment->priv->antiscia_list = NULL;
|
moment->priv->antiscia_list = NULL;
|
||||||
|
|
||||||
for (oplanet = moment->priv->planet_list; oplanet; oplanet = oplanet->next) {
|
for (oplanet = moment->priv->planet_list; oplanet; oplanet = g_list_next(oplanet)) {
|
||||||
for (iplanet = moment->priv->planet_list; iplanet; iplanet = iplanet->next) {
|
for (iplanet = moment->priv->planet_list; iplanet; iplanet = g_list_next(iplanet)) {
|
||||||
GswePlanetData *outer_planet = oplanet->data,
|
GswePlanetData *outer_planet = oplanet->data,
|
||||||
*inner_planet = iplanet->data;
|
*inner_planet = iplanet->data;
|
||||||
GsweAntiscionData *antiscion_data;
|
|
||||||
struct GsweAspectFinder antiscion_finder;
|
struct GsweAspectFinder antiscion_finder;
|
||||||
|
GsweAntiscionData *antiscion_data;
|
||||||
|
GList *antiscion_data_element;
|
||||||
|
|
||||||
if (outer_planet->planet_id == inner_planet->planet_id) {
|
if (outer_planet->planet_info->planet == inner_planet->planet_info->planet) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
antiscion_finder.planet1 = outer_planet->planet_id;
|
antiscion_finder.planet1 = outer_planet->planet_info->planet;
|
||||||
antiscion_finder.planet2 = inner_planet->planet_id;
|
antiscion_finder.planet2 = inner_planet->planet_info->planet;
|
||||||
|
|
||||||
if (g_list_find_custom(moment->priv->antiscia_list, &antiscion_finder, (GCompareFunc)find_antiscion_by_both_planets) != NULL) {
|
if ((antiscion_data_element = g_list_find_custom(moment->priv->antiscia_list, &antiscion_finder, (GCompareFunc)find_antiscion_by_both_planets)) != NULL) {
|
||||||
continue;
|
gswe_antiscion_data_calculate(antiscion_data_element->data);
|
||||||
|
} else {
|
||||||
|
antiscion_data = gswe_antiscion_data_new_with_planets(inner_planet, outer_planet);
|
||||||
|
moment->priv->antiscia_list = g_list_prepend(moment->priv->antiscia_list, antiscion_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
antiscion_data = g_new0(GsweAntiscionData, 1);
|
|
||||||
antiscion_data->planet1 = outer_planet;
|
|
||||||
antiscion_data->planet2 = inner_planet;
|
|
||||||
antiscion_data->axis = GSWE_ANTISCION_AXIS_NONE;
|
|
||||||
|
|
||||||
(void)g_hash_table_find(gswe_antiscion_info_table, (GHRFunc)find_antiscion, antiscion_data);
|
|
||||||
|
|
||||||
if (antiscion_data->axis == GSWE_ANTISCION_AXIS_NONE) {
|
|
||||||
antiscion_data->antiscion_info = g_hash_table_lookup(gswe_antiscion_info_table, GINT_TO_POINTER(GSWE_ANTISCION_AXIS_NONE));
|
|
||||||
}
|
|
||||||
|
|
||||||
moment->priv->antiscia_list = g_list_prepend(moment->priv->antiscia_list, antiscion_data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1309,20 +1209,20 @@ GList *
|
|||||||
gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet, GError **err)
|
gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet, GError **err)
|
||||||
{
|
{
|
||||||
GList *ret = NULL,
|
GList *ret = NULL,
|
||||||
*antiscion;
|
*antiscion_l;
|
||||||
|
|
||||||
if (!gswe_moment_has_planet(moment, planet)) {
|
if (!gswe_moment_has_planet(moment, planet)) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Specified planet is not added to the moment object");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gswe_moment_calculate_antiscia(moment);
|
gswe_moment_calculate_antiscia(moment);
|
||||||
|
|
||||||
for (antiscion = moment->priv->antiscia_list; antiscion; antiscion = g_list_next(antiscion)) {
|
glforeach (antiscion_l, moment->priv->antiscia_list) {
|
||||||
GsweAntiscionData *antiscion_data = antiscion->data;
|
GsweAntiscionData *antiscion_data = antiscion_l->data;
|
||||||
|
|
||||||
if ((antiscion_data->planet1->planet_id == planet) || (antiscion_data->planet2->planet_id == planet)) {
|
if ((antiscion_data->planet1->planet_info->planet == planet) || (antiscion_data->planet2->planet_info->planet == planet)) {
|
||||||
ret = g_list_prepend(ret, antiscion_data);
|
ret = g_list_prepend(ret, antiscion_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1350,10 +1250,10 @@ gswe_moment_get_axis_all_antiscia(GsweMoment *moment, GsweAntiscionAxis axis)
|
|||||||
|
|
||||||
gswe_moment_calculate_antiscia(moment);
|
gswe_moment_calculate_antiscia(moment);
|
||||||
|
|
||||||
for (antiscion_l = moment->priv->antiscia_list; antiscion_l; antiscion_l = g_list_next(antiscion_l)) {
|
glforeach (antiscion_l, moment->priv->antiscia_list) {
|
||||||
GsweAntiscionData *antiscion_data = antiscion_l->data;
|
GsweAntiscionData *antiscion_data = antiscion_l->data;
|
||||||
|
|
||||||
if (antiscion_data->axis == axis) {
|
if (antiscion_data->antiscion_axis_info->axis == axis) {
|
||||||
ret = g_list_prepend(ret, antiscion_data);
|
ret = g_list_prepend(ret, antiscion_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1383,17 +1283,23 @@ gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis,
|
|||||||
*antiscion_l;
|
*antiscion_l;
|
||||||
|
|
||||||
if (!gswe_moment_has_planet(moment, planet)) {
|
if (!gswe_moment_has_planet(moment, planet)) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Specified planet is not added to the moment object");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gswe_moment_calculate_antiscia(moment);
|
gswe_moment_calculate_antiscia(moment);
|
||||||
|
|
||||||
for (antiscion_l = moment->priv->antiscia_list; antiscion_l; antiscion_l = g_list_next(antiscion_l)) {
|
glforeach (antiscion_l, moment->priv->antiscia_list) {
|
||||||
GsweAntiscionData *antiscion_data = antiscion_l->data;
|
GsweAntiscionData *antiscion_data = antiscion_l->data;
|
||||||
|
|
||||||
if (((antiscion_data->planet1->planet_id == planet) || (antiscion_data->planet2->planet_id == planet)) && (antiscion_data->axis == axis)) {
|
if (
|
||||||
|
(
|
||||||
|
(antiscion_data->planet1->planet_info->planet == planet)
|
||||||
|
|| (antiscion_data->planet2->planet_info->planet == planet)
|
||||||
|
)
|
||||||
|
&& (antiscion_data->antiscion_axis_info->axis == axis)
|
||||||
|
) {
|
||||||
ret = g_list_prepend(ret, antiscion_data);
|
ret = g_list_prepend(ret, antiscion_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,9 @@
|
|||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
#include "gswe-timestamp.h"
|
#include "gswe-timestamp.h"
|
||||||
|
#include "gswe-moon-phase-data.h"
|
||||||
|
#include "gswe-planet-data.h"
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
#define GSWE_TYPE_MOMENT (gswe_moment_get_type())
|
#define GSWE_TYPE_MOMENT (gswe_moment_get_type())
|
||||||
#define GSWE_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSWE_TYPE_MOMENT, GsweMoment))
|
#define GSWE_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSWE_TYPE_MOMENT, GsweMoment))
|
||||||
@@ -33,42 +36,6 @@ typedef struct _GsweMoment GsweMoment;
|
|||||||
typedef struct _GsweMomentClass GsweMomentClass;
|
typedef struct _GsweMomentClass GsweMomentClass;
|
||||||
typedef struct _GsweMomentPrivate GsweMomentPrivate;
|
typedef struct _GsweMomentPrivate GsweMomentPrivate;
|
||||||
|
|
||||||
/**
|
|
||||||
* GSWE_MOMENT_ERROR:
|
|
||||||
*
|
|
||||||
* Error domain for GsweMoment. Errors in this domain will be from
|
|
||||||
* #GsweMomentError enumeration. See #GError for more information on error
|
|
||||||
* domains.
|
|
||||||
*/
|
|
||||||
#define GSWE_MOMENT_ERROR gswe_moment_error_quark()
|
|
||||||
GQuark gswe_moment_error_quark(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweMomentError:
|
|
||||||
* @GSWE_MOMENT_ERROR_SUCCESS: no error
|
|
||||||
* @GSWE_MOMENT_ERROR_UNKNOWN_HSYS: house system provided is unknown (a
|
|
||||||
* #GsweHouseSystem value must be passed)
|
|
||||||
* @GSWE_MOMENT_ERROR_UNKNOWN_SIGN: an unknown zodiac sign is calculated
|
|
||||||
* @GSWE_MOMENT_ERROR_NONADDED_PLANET: the referenced planet is not added to
|
|
||||||
* the GsweMoment object
|
|
||||||
* @GSWE_MOMENT_ERROR_SWE_ERROR_NONFATAL: an error reported by the Swiss
|
|
||||||
* Ephemeris library. Errors marked with
|
|
||||||
* this value are not fatal, so it's
|
|
||||||
* more like a warning
|
|
||||||
* @GSWE_MOMENT_ERROR_SWE_ERROR_FATAL: a fatal error reported by the Swiss
|
|
||||||
* Ephemeris library
|
|
||||||
*
|
|
||||||
* Error codes returned by GsweMoment functions.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
GSWE_MOMENT_ERROR_SUCCESS,
|
|
||||||
GSWE_MOMENT_ERROR_UNKNOWN_HSYS,
|
|
||||||
GSWE_MOMENT_ERROR_UNKNOWN_SIGN,
|
|
||||||
GSWE_MOMENT_ERROR_NONADDED_PLANET,
|
|
||||||
GSWE_MOMENT_ERROR_SWE_ERROR_NONFATAL,
|
|
||||||
GSWE_MOMENT_ERROR_SWE_ERROR_FATAL
|
|
||||||
} GsweMomentError;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GsweMoment:
|
* GsweMoment:
|
||||||
*
|
*
|
||||||
@@ -138,17 +105,17 @@ GList *gswe_moment_get_house_cusps(GsweMoment *moment, GError **err);
|
|||||||
gint gswe_moment_get_house(GsweMoment *moment, gdouble position, GError **err);
|
gint gswe_moment_get_house(GsweMoment *moment, gdouble position, GError **err);
|
||||||
|
|
||||||
gboolean gswe_moment_has_planet(GsweMoment *moment, GswePlanet planet);
|
gboolean gswe_moment_has_planet(GsweMoment *moment, GswePlanet planet);
|
||||||
void gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet);
|
void gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet, GError **err);
|
||||||
void gswe_moment_add_all_planets(GsweMoment *moment);
|
void gswe_moment_add_all_planets(GsweMoment *moment);
|
||||||
GList *gswe_moment_get_all_planets(GsweMoment *moment);
|
GList *gswe_moment_get_all_planets(GsweMoment *moment);
|
||||||
const GswePlanetData *gswe_moment_get_planet(GsweMoment *moment, GswePlanet planet, GError **err);
|
GswePlanetData *gswe_moment_get_planet(GsweMoment *moment, GswePlanet planet, GError **err);
|
||||||
GList *gswe_moment_get_sign_planets(GsweMoment *moment, GsweZodiac sign);
|
GList *gswe_moment_get_sign_planets(GsweMoment *moment, GsweZodiac sign);
|
||||||
GList *gswe_moment_get_house_planets(GsweMoment *moment, guint house);
|
GList *gswe_moment_get_house_planets(GsweMoment *moment, guint house);
|
||||||
|
|
||||||
guint gswe_moment_get_element_points(GsweMoment *moment, GsweElement element);
|
guint gswe_moment_get_element_points(GsweMoment *moment, GsweElement element);
|
||||||
guint gswe_moment_get_quality_points(GsweMoment *moment, GsweQuality quality);
|
guint gswe_moment_get_quality_points(GsweMoment *moment, GsweQuality quality);
|
||||||
|
|
||||||
const GsweMoonPhaseData *gswe_moment_get_moon_phase(GsweMoment *moment, GError **err);
|
GsweMoonPhaseData *gswe_moment_get_moon_phase(GsweMoment *moment, GError **err);
|
||||||
|
|
||||||
GList *gswe_moment_get_all_aspects(GsweMoment *moment);
|
GList *gswe_moment_get_all_aspects(GsweMoment *moment);
|
||||||
GList *gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **err);
|
GList *gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **err);
|
||||||
|
40
src/gswe-moon-phase-data-private.h
Normal file
40
src/gswe-moon-phase-data-private.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/* gswe-moon-phase-data-private.h: Private parts of GsweMoonPhaseData
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifdef __SWE_GLIB_BUILDING__
|
||||||
|
#ifndef __SWE_GLIB_GSWE_MOON_PHASE_DATA_PRIVATE_H__
|
||||||
|
#define __SWE_GLIB_GSWE_MOON_PHASE_DATA_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gswe-moon-phase-data.h"
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
struct _GsweMoonPhaseData {
|
||||||
|
/* the actual phase of the Moon */
|
||||||
|
GsweMoonPhase phase;
|
||||||
|
|
||||||
|
/* the illumination percentage of the Moon */
|
||||||
|
gdouble illumination;
|
||||||
|
|
||||||
|
/* reference count */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_MOON_PHASE_DATA_PRIVATE_H__ */
|
||||||
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
#endif /* __SWE_GLIB_BUILDING__ */
|
||||||
|
|
191
src/gswe-moon-phase-data.c
Normal file
191
src/gswe-moon-phase-data.c
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
/* gswe-moon-phase-data.c: Moon phase representation
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
#include "swe-glib-private.h"
|
||||||
|
#include "gswe-moon-phase-data.h"
|
||||||
|
#include "gswe-moon-phase-data-private.h"
|
||||||
|
#include "gswe-timestamp.h"
|
||||||
|
|
||||||
|
#define SYNODIC 29.53058867
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gswe-moon-phase-data
|
||||||
|
* @short_description: a structure representing the phase of the Moon
|
||||||
|
* @title: GsweMoonPhaseData
|
||||||
|
* @stability: Stable
|
||||||
|
* @include: swe-glib.h
|
||||||
|
* @see_also: #GsweMoonPhase
|
||||||
|
*
|
||||||
|
* #GsweMoonPhaseData is a structure that represents the actual phase of the
|
||||||
|
* Moon, including its illumination percentage.
|
||||||
|
*/
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE(GsweMoonPhaseData, gswe_moon_phase_data, (GBoxedCopyFunc)gswe_moon_phase_data_ref, (GBoxedFreeFunc)gswe_moon_phase_data_unref);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_moon_phase_data_new:
|
||||||
|
*
|
||||||
|
* Creates a new #GsweMoonPhaseData object with reference count set to 1.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweMoonPhaseData object
|
||||||
|
*/
|
||||||
|
GsweMoonPhaseData *
|
||||||
|
gswe_moon_phase_data_new(void)
|
||||||
|
{
|
||||||
|
GsweMoonPhaseData *ret;
|
||||||
|
|
||||||
|
ret = g_new0(GsweMoonPhaseData, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_moon_phase_data_ref:
|
||||||
|
* @moon_phase_data: (in): a #GsweMoonPhaseData
|
||||||
|
*
|
||||||
|
* Increases reference count on @moon_phase_data by one.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GsweMoonPhaseData
|
||||||
|
*/
|
||||||
|
GsweMoonPhaseData *
|
||||||
|
gswe_moon_phase_data_ref(GsweMoonPhaseData *moon_phase_data)
|
||||||
|
{
|
||||||
|
moon_phase_data->refcount++;
|
||||||
|
|
||||||
|
return moon_phase_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_moon_phase_data_unref:
|
||||||
|
* @moon_phase_data: (in): a #GsweMoonPhaseData
|
||||||
|
*
|
||||||
|
* Decreases reference count on @moon_phase_data by one. If reference count drops to zero, @moon_phase_data is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_moon_phase_data_unref(GsweMoonPhaseData *moon_phase_data)
|
||||||
|
{
|
||||||
|
if (--moon_phase_data->refcount == 0) {
|
||||||
|
g_free(moon_phase_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_moon_phase_data_calculate_by_jd:
|
||||||
|
* @moon_phase_data: a #GsweMoonPhaseData
|
||||||
|
* @jd: a Julian Day number, with hours as fractions
|
||||||
|
* @err: a #GError
|
||||||
|
*
|
||||||
|
* Calculates the moon at a given time, specified by @jd.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_moon_phase_data_calculate_by_jd(GsweMoonPhaseData *moon_phase_data, gdouble jd, GError **err)
|
||||||
|
{
|
||||||
|
gdouble jdb,
|
||||||
|
phase_percent;
|
||||||
|
|
||||||
|
jdb = gswe_timestamp_get_julian_day(gswe_full_moon_base_date, err);
|
||||||
|
|
||||||
|
if ((err) && (*err)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((phase_percent = fmod(((jd - jdb) * 100) / SYNODIC, 100)) < 0) {
|
||||||
|
phase_percent += 100.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((phase_percent < 0) || (phase_percent > 100)) {
|
||||||
|
g_error("Error during Moon phase calculation!");
|
||||||
|
}
|
||||||
|
|
||||||
|
moon_phase_data->illumination = (50.0 - fabs(phase_percent - 50.0)) * 2;
|
||||||
|
|
||||||
|
if (phase_percent == 0) {
|
||||||
|
moon_phase_data->phase = GSWE_MOON_PHASE_NEW;
|
||||||
|
} else if (phase_percent < 25) {
|
||||||
|
moon_phase_data->phase = GSWE_MOON_PHASE_WAXING_CRESCENT;
|
||||||
|
} else if (phase_percent == 25) {
|
||||||
|
moon_phase_data->phase = GSWE_MOON_PHASE_WAXING_HALF;
|
||||||
|
} else if (phase_percent < 50) {
|
||||||
|
moon_phase_data->phase = GSWE_MOON_PHASE_WAXING_GIBBOUS;
|
||||||
|
} else if (phase_percent == 50) {
|
||||||
|
moon_phase_data->phase = GSWE_MOON_PHASE_FULL;
|
||||||
|
} else if (phase_percent < 75) {
|
||||||
|
moon_phase_data->phase = GSWE_MOON_PHASE_WANING_GIBBOUS;
|
||||||
|
} else if (phase_percent == 75) {
|
||||||
|
moon_phase_data->phase = GSWE_MOON_PHASE_WANING_HALF;
|
||||||
|
} else if (phase_percent < 100) {
|
||||||
|
moon_phase_data->phase = GSWE_MOON_PHASE_WANING_CRESCENT;
|
||||||
|
} else {
|
||||||
|
moon_phase_data->phase = GSWE_MOON_PHASE_DARK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_moon_phase_data_calculate_by_timestamp:
|
||||||
|
* @moon_phase_data: a #GsweMoonPhaseData
|
||||||
|
* @timestamp: a #GsweTimestamp with a valid timestamp set
|
||||||
|
* @err: a #GError
|
||||||
|
*
|
||||||
|
* Calculates the moon at a given time, specified by @timestamp.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_moon_phase_data_calculate_by_timestamp(GsweMoonPhaseData *moon_phase_data, GsweTimestamp *timestamp, GError **err)
|
||||||
|
{
|
||||||
|
gdouble jd;
|
||||||
|
|
||||||
|
jd = gswe_timestamp_get_julian_day(timestamp, err);
|
||||||
|
|
||||||
|
if (*err) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gswe_moon_phase_data_calculate_by_jd(moon_phase_data, jd, err);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_moon_phase_data_get_phase:
|
||||||
|
* @moon_phase_data: (in): a GsweMoonPhaseData
|
||||||
|
*
|
||||||
|
* Gets the phase of the Moon in the given GsweMoonPhaseData.
|
||||||
|
*
|
||||||
|
* Returns: the Moon phase
|
||||||
|
*/
|
||||||
|
GsweMoonPhase
|
||||||
|
gswe_moon_phase_data_get_phase(GsweMoonPhaseData *moon_phase_data)
|
||||||
|
{
|
||||||
|
return moon_phase_data->phase;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_moon_phase_data_get_illumination:
|
||||||
|
* @moon_phase_data: (in): a GsweMoonPhaseData
|
||||||
|
*
|
||||||
|
* Gets the illumination percentage from the given GsweMoonPhaseData.
|
||||||
|
*
|
||||||
|
* Returns: the illumination percentage
|
||||||
|
*/
|
||||||
|
gdouble
|
||||||
|
gswe_moon_phase_data_get_illumination(GsweMoonPhaseData *moon_phase_data)
|
||||||
|
{
|
||||||
|
return moon_phase_data->illumination;
|
||||||
|
}
|
||||||
|
|
55
src/gswe-moon-phase-data.h
Normal file
55
src/gswe-moon-phase-data.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/* gswe-moon-phase-data.h: Moon phase representation
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef __SWE_GLIB_GSWE_MOON_PHASE_DATA_H__
|
||||||
|
#define __SWE_GLIB_GSWE_MOON_PHASE_DATA_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-timestamp.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GsweMoonPhaseData:
|
||||||
|
*
|
||||||
|
* <structname>GsweMoonPhaseData</structname> is an opaque structure whose members
|
||||||
|
* cannot be accessed directly.
|
||||||
|
*
|
||||||
|
* Since: 1.1
|
||||||
|
*/
|
||||||
|
typedef struct _GsweMoonPhaseData GsweMoonPhaseData;
|
||||||
|
|
||||||
|
GsweMoonPhaseData *gswe_moon_phase_data_new(void);
|
||||||
|
|
||||||
|
GsweMoonPhaseData *gswe_moon_phase_data_ref(GsweMoonPhaseData *moon_phase_data);
|
||||||
|
void gswe_moon_phase_data_unref(GsweMoonPhaseData *moon_phase_data);
|
||||||
|
|
||||||
|
void gswe_moon_phase_data_calculate_by_jd(GsweMoonPhaseData *moon_phase_data, gdouble jd, GError **err);
|
||||||
|
void gswe_moon_phase_data_calculate_by_timestamp(GsweMoonPhaseData *moon_phase_data, GsweTimestamp *timestamp, GError **err);
|
||||||
|
|
||||||
|
GsweMoonPhase gswe_moon_phase_data_get_phase(GsweMoonPhaseData *moon_phase_data);
|
||||||
|
gdouble gswe_moon_phase_data_get_illumination(GsweMoonPhaseData *moon_phase_data);
|
||||||
|
|
||||||
|
GType gswe_moon_phase_data_get_type(void);
|
||||||
|
#define GSWE_TYPE_MOON_PHASE_DATA (gswe_moon_phase_data_get_type())
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_MOON_PHASE_DATA_H__ */
|
||||||
|
|
52
src/gswe-planet-data-private.h
Normal file
52
src/gswe-planet-data-private.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* gswe-planet-data-private.h: Private parts of GswePlanetData
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifdef __SWE_GLIB_BUILDING__
|
||||||
|
#ifndef __SWE_GLIB_GSWE_PLANET_DATA_PRIVATE_H__
|
||||||
|
#define __SWE_GLIB_GSWE_PLANET_DATA_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gswe-planet-data.h"
|
||||||
|
#include "gswe-planet-info.h"
|
||||||
|
|
||||||
|
struct _GswePlanetData {
|
||||||
|
/* A GswePlanetInfo structure, holding every information about the planet */
|
||||||
|
GswePlanetInfo *planet_info;
|
||||||
|
|
||||||
|
/* The longitude position of the planet */
|
||||||
|
gdouble position;
|
||||||
|
|
||||||
|
/* TRUE if the planet is in retrograde motion */
|
||||||
|
gboolean retrograde;
|
||||||
|
|
||||||
|
/* Number of the house in which the planet is in */
|
||||||
|
gint house;
|
||||||
|
|
||||||
|
/* A GsweSignInfo structure, holding every information about the sign the planet is in */
|
||||||
|
GsweSignInfo *sign_info;
|
||||||
|
|
||||||
|
/* An internal version number of the calculation */
|
||||||
|
guint revision;
|
||||||
|
|
||||||
|
/* reference count */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_PLANET_DATA_PRIVATE_H__ */
|
||||||
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
#endif /* __SWE_GLIB_BUILDING__ */
|
||||||
|
|
253
src/gswe-planet-data.c
Normal file
253
src/gswe-planet-data.c
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
/* gswe-planet-data.c: Planetary positions
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
#include "swe-glib-private.h"
|
||||||
|
#include "swe-glib.h"
|
||||||
|
#include "gswe-planet-data.h"
|
||||||
|
#include "gswe-planet-data-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gswe-planet-data
|
||||||
|
* @short_description: a structure representing a planet's position-related data
|
||||||
|
* @title: GswePlanetData
|
||||||
|
* @stability: Stable
|
||||||
|
* @include: swe-glib.h
|
||||||
|
* @see_also: #GswePlanetInfo
|
||||||
|
*
|
||||||
|
* #GswePlanetData is a structure that represents a planet's position-related
|
||||||
|
* data, like its actual position on the sky or the house and sign the planet
|
||||||
|
* is in.
|
||||||
|
*/
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE(GswePlanetData, gswe_planet_data, (GBoxedCopyFunc)gswe_planet_data_ref, (GBoxedFreeFunc)gswe_planet_data_unref);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gswe_planet_data_free(GswePlanetData *planet_data)
|
||||||
|
{
|
||||||
|
if (planet_data->planet_info) {
|
||||||
|
gswe_planet_info_unref(planet_data->planet_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (planet_data->sign_info) {
|
||||||
|
gswe_sign_info_unref(planet_data->sign_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(planet_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_new:
|
||||||
|
*
|
||||||
|
* Creates a new #GswePlanetData object with reference count set to 1.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GswePlanetData
|
||||||
|
*/
|
||||||
|
GswePlanetData *
|
||||||
|
gswe_planet_data_new(void)
|
||||||
|
{
|
||||||
|
GswePlanetData *ret;
|
||||||
|
|
||||||
|
ret = g_new0(GswePlanetData, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_ref:
|
||||||
|
* @planet_data: a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Increases reference count on @planet_data by one.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GswePlanetData
|
||||||
|
*/
|
||||||
|
GswePlanetData *
|
||||||
|
gswe_planet_data_ref(GswePlanetData *planet_data)
|
||||||
|
{
|
||||||
|
planet_data->refcount++;
|
||||||
|
|
||||||
|
return planet_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_unref:
|
||||||
|
* @planet_data: a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Decreases reference count on @planet_data by one. If reference count drops to zero, @planet_data is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_planet_data_unref(GswePlanetData *planet_data)
|
||||||
|
{
|
||||||
|
if (--planet_data->refcount == 0) {
|
||||||
|
gswe_planet_data_free(planet_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_set_planet:
|
||||||
|
* @planet_data: (in): a #GswePlanetData
|
||||||
|
* @planet: the planet to add
|
||||||
|
* @err: a #GError
|
||||||
|
*
|
||||||
|
* Sets @planet as the planet ID of @planet_data. @planet must be registered
|
||||||
|
* via gswe_init(); otherwise, @err is populated with
|
||||||
|
* GSWE_ERROR_UNKNOWN_PLANET, and the planet ID is not set.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_planet_data_set_planet(GswePlanetData *planet_data, GswePlanet planet, GError **err)
|
||||||
|
{
|
||||||
|
GswePlanetInfo *planet_info;
|
||||||
|
|
||||||
|
if ((planet_info = g_hash_table_lookup(gswe_planet_info_table, GINT_TO_POINTER(planet))) == NULL) {
|
||||||
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Planet is unknown");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (planet_data->planet_info) {
|
||||||
|
gswe_planet_info_unref(planet_data->planet_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
planet_data->planet_info = gswe_planet_info_ref(planet_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_get_planet:
|
||||||
|
* @planet_data: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Gets the planet ID for this #GswePlanetData.
|
||||||
|
*
|
||||||
|
* Returns: the planet ID
|
||||||
|
*/
|
||||||
|
GswePlanet
|
||||||
|
gswe_planet_data_get_planet(GswePlanetData *planet_data)
|
||||||
|
{
|
||||||
|
if (planet_data->planet_info) {
|
||||||
|
return planet_data->planet_info->planet;
|
||||||
|
} else {
|
||||||
|
return GSWE_PLANET_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_set_planet_info:
|
||||||
|
* @planet_data: a #GswePlanetData
|
||||||
|
* @planet_info: a #GswePlanetInfo
|
||||||
|
*
|
||||||
|
* Sets @planet_info as the planet information for @planet_data.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_planet_data_set_planet_info(GswePlanetData *planet_data, GswePlanetInfo *planet_info)
|
||||||
|
{
|
||||||
|
if (planet_data->planet_info) {
|
||||||
|
gswe_planet_info_unref(planet_data->planet_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
planet_data->planet_info = gswe_planet_info_ref(planet_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_get_planet_info:
|
||||||
|
* @planet_data: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Gets the planet info related to this #GswePlanetData.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the #GswePlanetInfo associated with this planet
|
||||||
|
*/
|
||||||
|
GswePlanetInfo *
|
||||||
|
gswe_planet_data_get_planet_info(GswePlanetData *planet_data)
|
||||||
|
{
|
||||||
|
return planet_data->planet_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_get_position:
|
||||||
|
* @planet_data: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Gets the position of the planet on the sky.
|
||||||
|
*
|
||||||
|
* Returns: the position, in degrees
|
||||||
|
*/
|
||||||
|
gdouble
|
||||||
|
gswe_planet_data_get_position(GswePlanetData *planet_data)
|
||||||
|
{
|
||||||
|
return planet_data->position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_get_retrograde:
|
||||||
|
* @planet_data: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Returns the planet's retrograde status, e.g. if it looks like it moves
|
||||||
|
* backwards on the sky.
|
||||||
|
*
|
||||||
|
* Returns: TRUE, if the planet is in retrograde motion; FALSE otherwise
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gswe_planet_data_get_retrograde(GswePlanetData *planet_data)
|
||||||
|
{
|
||||||
|
return planet_data->retrograde;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_get_house:
|
||||||
|
* @planet_data: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Gets the house number which the planet is in.
|
||||||
|
*
|
||||||
|
* Returns: a house number
|
||||||
|
*/
|
||||||
|
guint
|
||||||
|
gswe_planet_data_get_house(GswePlanetData *planet_data)
|
||||||
|
{
|
||||||
|
return planet_data->house;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_get_sign:
|
||||||
|
* @planet_data: a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Gets the zodiac sign in which the planet is currently in. If the planet's data is not calculated yet, this function yields GSWE_PLANET_NONE.
|
||||||
|
*
|
||||||
|
* Returns: a #GsweZodiac, which @planet_data is currently in
|
||||||
|
*/
|
||||||
|
GsweZodiac
|
||||||
|
gswe_planet_data_get_sign(GswePlanetData *planet_data)
|
||||||
|
{
|
||||||
|
if (planet_data->sign_info) {
|
||||||
|
return planet_data->sign_info->sign;
|
||||||
|
} else {
|
||||||
|
return GSWE_SIGN_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_data_get_sign_info:
|
||||||
|
* @planet_data: (in): a #GswePlanetData
|
||||||
|
*
|
||||||
|
* Gets the sign which the planet is in.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): a #GsweSignInfo
|
||||||
|
*/
|
||||||
|
GsweSignInfo *
|
||||||
|
gswe_planet_data_get_sign_info(GswePlanetData *planet_data)
|
||||||
|
{
|
||||||
|
return planet_data->sign_info;
|
||||||
|
}
|
||||||
|
|
62
src/gswe-planet-data.h
Normal file
62
src/gswe-planet-data.h
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* gswe-planet-data.h: Planetary positions
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef __SWE_GLIB_GSWE_PLANET_DATA_H__
|
||||||
|
#define __SWE_GLIB_GSWE_PLANET_DATA_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-planet-info.h"
|
||||||
|
#include "gswe-sign-info.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GswePlanetData:
|
||||||
|
*
|
||||||
|
* <structname>GswePlanetData</structname> is an opaque structure whose members
|
||||||
|
* cannot be accessed directly.
|
||||||
|
*
|
||||||
|
* Since: 1.1
|
||||||
|
*/
|
||||||
|
typedef struct _GswePlanetData GswePlanetData;
|
||||||
|
|
||||||
|
GType gswe_planet_data_get_type(void);
|
||||||
|
#define GSWE_TYPE_PLANET_DATA (gswe_planet_data_get_type())
|
||||||
|
|
||||||
|
GswePlanetData *gswe_planet_data_new(void);
|
||||||
|
|
||||||
|
GswePlanetData *gswe_planet_data_ref(GswePlanetData *planet_data);
|
||||||
|
void gswe_planet_data_unref(GswePlanetData *planet_data);
|
||||||
|
|
||||||
|
void gswe_planet_data_set_planet(GswePlanetData *planet_data, GswePlanet planet, GError **err);
|
||||||
|
GswePlanet gswe_planet_data_get_planet(GswePlanetData *planet_data);
|
||||||
|
|
||||||
|
void gswe_planet_data_set_planet_info(GswePlanetData *planet_data, GswePlanetInfo *planet_info);
|
||||||
|
GswePlanetInfo *gswe_planet_data_get_planet_info(GswePlanetData *planet_data);
|
||||||
|
|
||||||
|
gdouble gswe_planet_data_get_position(GswePlanetData *planet_data);
|
||||||
|
gboolean gswe_planet_data_get_retrograde(GswePlanetData *planet_data);
|
||||||
|
guint gswe_planet_data_get_house(GswePlanetData *planet_data);
|
||||||
|
GsweZodiac gswe_planet_data_get_sign(GswePlanetData *planet_data);
|
||||||
|
GsweSignInfo *gswe_planet_data_get_sign_info(GswePlanetData *planet_data);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_PLANET_DATA_H__ */
|
||||||
|
|
52
src/gswe-planet-info-private.h
Normal file
52
src/gswe-planet-info-private.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* gswe-planet-info-private.h: Private parts of GswePlanetInfo
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifdef __SWE_GLIB_BUILDING__
|
||||||
|
#ifndef __SWE_GLIB_GSWE_PLANET_INFO_PRIVATE_H__
|
||||||
|
#define __SWE_GLIB_GSWE_PLANET_INFO_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-planet-info.h"
|
||||||
|
|
||||||
|
struct _GswePlanetInfo {
|
||||||
|
/* the planet ID */
|
||||||
|
GswePlanet planet;
|
||||||
|
|
||||||
|
/* the planet ID according to the Swiss Ephemeris libarary (or -1, if the planet has no such ID) */
|
||||||
|
gint32 sweph_id;
|
||||||
|
|
||||||
|
/* TRUE if the planet is a "real" celestial body on the sky. Please note that this will be true for Dark Moon (Lilith). Everything that has a planet ID in Swiss Ephemeris is treated as a real celestial body. */
|
||||||
|
gboolean real_body;
|
||||||
|
|
||||||
|
/* the planet's “personal” orb */
|
||||||
|
gdouble orb;
|
||||||
|
|
||||||
|
/* the planet's name */
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
/* the value this planet counts in the element/quality points table */
|
||||||
|
gint points;
|
||||||
|
|
||||||
|
/* reference counter */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_PLANET_INFO_PRIVATE_H__ */
|
||||||
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
#endif /* __SWE_GLIB_BUILDING__ */
|
||||||
|
|
260
src/gswe-planet-info.c
Normal file
260
src/gswe-planet-info.c
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
/* gswe-planet-info.c: Planet related information
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
#include "gswe-planet-info.h"
|
||||||
|
#include "gswe-planet-info-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gswe-planet-info
|
||||||
|
* @short_description: a structure storing information about a planet
|
||||||
|
* @title: GswePlanetInfo
|
||||||
|
* @stability: Stable
|
||||||
|
* @include: swe-glib.h
|
||||||
|
*
|
||||||
|
* The #GswePlanetInfo structure stores information about a planet.
|
||||||
|
*/
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE(GswePlanetInfo, gswe_planet_info, (GBoxedCopyFunc)gswe_planet_info_ref, (GBoxedFreeFunc)gswe_planet_info_unref);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_new:
|
||||||
|
*
|
||||||
|
* Creates a new #GswePlanetInfo object with reference count set to 1.
|
||||||
|
*
|
||||||
|
* Returns: a new #GswePlanetInfo
|
||||||
|
*/
|
||||||
|
GswePlanetInfo *
|
||||||
|
gswe_planet_info_new(void)
|
||||||
|
{
|
||||||
|
GswePlanetInfo *ret;
|
||||||
|
|
||||||
|
ret = g_new0(GswePlanetInfo, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_ref:
|
||||||
|
* @planet_info: (in): a #GswePlanetInfo
|
||||||
|
*
|
||||||
|
* Increases reference count on @planet_info.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GswePlanetData
|
||||||
|
*/
|
||||||
|
GswePlanetInfo *
|
||||||
|
gswe_planet_info_ref(GswePlanetInfo *planet_info)
|
||||||
|
{
|
||||||
|
planet_info->refcount++;
|
||||||
|
|
||||||
|
return planet_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gswe_planet_info_free(GswePlanetInfo *planet_info)
|
||||||
|
{
|
||||||
|
if (planet_info->name) {
|
||||||
|
g_free(planet_info->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(planet_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_unref:
|
||||||
|
* @planet_info: a #GswePlanetInfo
|
||||||
|
*
|
||||||
|
* Decreases reference count on @planet_info. If reference count reaches zero, @planet_info is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_planet_info_unref(GswePlanetInfo *planet_info)
|
||||||
|
{
|
||||||
|
if (--planet_info->refcount == 0) {
|
||||||
|
gswe_planet_info_free(planet_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_set_planet:
|
||||||
|
* @planet_info: a #GswePlanetInfo
|
||||||
|
* @planet: the new planet ID
|
||||||
|
*
|
||||||
|
* Sets the planet ID that will be represented by @planet_info.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_planet_info_set_planet(GswePlanetInfo *planet_info, GswePlanet planet)
|
||||||
|
{
|
||||||
|
planet_info->planet = planet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_get_planet:
|
||||||
|
* @planet_info: (in): A #GswePlanetInfo
|
||||||
|
*
|
||||||
|
* Gets the planet ID represented by this #GswePlanetInfo.
|
||||||
|
*
|
||||||
|
* Returns: the planet ID
|
||||||
|
*/
|
||||||
|
GswePlanet
|
||||||
|
gswe_planet_info_get_planet(GswePlanetInfo *planet_info)
|
||||||
|
{
|
||||||
|
return planet_info->planet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_set_sweph_id:
|
||||||
|
* @planet_info: a #GswePlanetInfo
|
||||||
|
* @sweph_id: the new Swiss Ephemeris planet ID
|
||||||
|
*
|
||||||
|
* Sets the Swiss Ephemeris planet_id associated with this planet.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_planet_info_set_sweph_id(GswePlanetInfo *planet_info, gint32 sweph_id)
|
||||||
|
{
|
||||||
|
planet_info->sweph_id = sweph_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_get_sweph_id:
|
||||||
|
* @planet_info: (in): A #GswePlanetInfo
|
||||||
|
*
|
||||||
|
* Gets the Swiss Ephemeris planet ID associated with this planet.
|
||||||
|
*
|
||||||
|
* Returns: the Swiss Ephemeris planet ID
|
||||||
|
*/
|
||||||
|
gint32
|
||||||
|
gswe_planet_info_get_sweph_id(GswePlanetInfo *planet_info)
|
||||||
|
{
|
||||||
|
return planet_info->sweph_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_set_real_body:
|
||||||
|
* @planet_info: a #GswePlanetInfo
|
||||||
|
* @real_body: a boolean that indicates if this planet is an object recognized
|
||||||
|
* by Swiss Ephemeris
|
||||||
|
*
|
||||||
|
* Sets whether this planet is an object recognized by the Swiss Ephemeris library.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_planet_info_set_real_body(GswePlanetInfo *planet_info, gboolean real_body)
|
||||||
|
{
|
||||||
|
planet_info->real_body = real_body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_get_real_body:
|
||||||
|
* @planet_info: (in): A #GswePlanetInfo
|
||||||
|
*
|
||||||
|
* Checks weather this planet is a real celestial body (e.g. it has a Swiss Ephemeris planet ID) or not.
|
||||||
|
*
|
||||||
|
* Returns: TRUE if the planet has a Swiss Ephemeris planet ID; FALSE otherwise
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gswe_planet_info_get_real_body(GswePlanetInfo *planet_info)
|
||||||
|
{
|
||||||
|
return planet_info->real_body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_set_orb:
|
||||||
|
* @planet_info: a #GswePlanetInfo
|
||||||
|
* @orb: the planet's own orb
|
||||||
|
*
|
||||||
|
* Sets the orb of @planet_info. This value is used in aspect and antiscion
|
||||||
|
* calculations.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_planet_info_set_orb(GswePlanetInfo *planet_info, gdouble orb)
|
||||||
|
{
|
||||||
|
planet_info->orb = orb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_get_orb:
|
||||||
|
* @planet_info: (in): A #GswePlanetInfo
|
||||||
|
*
|
||||||
|
* Gets the orb of the planet.
|
||||||
|
*
|
||||||
|
* Returns: the orb, in degrees
|
||||||
|
*/
|
||||||
|
gdouble
|
||||||
|
gswe_planet_info_get_orb(GswePlanetInfo *planet_info)
|
||||||
|
{
|
||||||
|
return planet_info->orb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_set_name:
|
||||||
|
* @planet_info: (in): a #GswePlanetInfo
|
||||||
|
* @name: (in): the new name of the planet
|
||||||
|
*
|
||||||
|
* Sets the name of @planet_info.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_planet_info_set_name(GswePlanetInfo *planet_info, const gchar *name)
|
||||||
|
{
|
||||||
|
if (planet_info->name) {
|
||||||
|
g_free(planet_info->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
planet_info->name = g_strdup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_get_name:
|
||||||
|
* @planet_info: (in): A #GswePlanetInfo
|
||||||
|
*
|
||||||
|
* Gets the name of the planet.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the planet's name
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
gswe_planet_info_get_name(GswePlanetInfo *planet_info)
|
||||||
|
{
|
||||||
|
return planet_info->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_set_points:
|
||||||
|
* @planet_info: a #GswePlanetInfo
|
||||||
|
* @points: the new point value
|
||||||
|
*
|
||||||
|
* Sets the point value of @planet_info. This value is used in points calculations.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_planet_info_set_points(GswePlanetInfo *planet_info, gint points)
|
||||||
|
{
|
||||||
|
planet_info->points = points;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_planet_info_get_points:
|
||||||
|
* @planet_info: (in): A #GswePlanetInfo
|
||||||
|
*
|
||||||
|
* Gets the value this planet counts in point calculations.
|
||||||
|
*
|
||||||
|
* Returns: the point value
|
||||||
|
*/
|
||||||
|
gint
|
||||||
|
gswe_planet_info_get_points(GswePlanetInfo *planet_info)
|
||||||
|
{
|
||||||
|
return planet_info->points;
|
||||||
|
}
|
||||||
|
|
66
src/gswe-planet-info.h
Normal file
66
src/gswe-planet-info.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/* gswe-planet-info.h: Planet related information
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef __SWE_GLIB_GSWE_PLANET_INFO_H__
|
||||||
|
#define __SWE_GLIB_GSWE_PLANET_INFO_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GswePlanetInfo:
|
||||||
|
*
|
||||||
|
* <structname>GswePlanetInfo</structname> is an opaque structure whose members
|
||||||
|
* cannot be accessed directly.
|
||||||
|
*
|
||||||
|
* Since: 1.1
|
||||||
|
*/
|
||||||
|
typedef struct _GswePlanetInfo GswePlanetInfo;
|
||||||
|
|
||||||
|
GType gswe_planet_info_get_type(void);
|
||||||
|
#define GSWE_TYPE_PLANET_INFO (gswe_planet_info_get_type())
|
||||||
|
|
||||||
|
GswePlanetInfo *gswe_planet_info_new(void);
|
||||||
|
|
||||||
|
GswePlanetInfo *gswe_planet_info_ref(GswePlanetInfo *planet_info);
|
||||||
|
void gswe_planet_info_unref(GswePlanetInfo *planet_info);
|
||||||
|
|
||||||
|
void gswe_planet_info_set_planet(GswePlanetInfo *planet_info, GswePlanet planet);
|
||||||
|
GswePlanet gswe_planet_info_get_planet(GswePlanetInfo *planet_info);
|
||||||
|
|
||||||
|
void gswe_planet_info_set_sweph_id(GswePlanetInfo *planet_info, gint32 sweph_id);
|
||||||
|
gint32 gswe_planet_info_get_sweph_id(GswePlanetInfo *planet_info);
|
||||||
|
|
||||||
|
void gswe_planet_info_set_real_body(GswePlanetInfo *planet_info, gboolean real_body);
|
||||||
|
gboolean gswe_planet_info_get_real_body(GswePlanetInfo *planet_info);
|
||||||
|
|
||||||
|
void gswe_planet_info_set_orb(GswePlanetInfo *planet_info, gdouble orb);
|
||||||
|
gdouble gswe_planet_info_get_orb(GswePlanetInfo *planet_info);
|
||||||
|
|
||||||
|
void gswe_planet_info_set_name(GswePlanetInfo *planet_info, const gchar *name);
|
||||||
|
const gchar *gswe_planet_info_get_name(GswePlanetInfo *planet_info);
|
||||||
|
|
||||||
|
void gswe_planet_info_set_points(GswePlanetInfo *planet_info, gint points);
|
||||||
|
gint gswe_planet_info_get_points(GswePlanetInfo *planet_info);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_PLANET_INFO_PRIVATE_H__ */
|
||||||
|
|
47
src/gswe-sign-info-private.h
Normal file
47
src/gswe-sign-info-private.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/* gswe-sign-info-private.h: Private parts of GsweSignInfo
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifdef __SWE_GLIB_BUILDING__
|
||||||
|
#ifndef __SWE_GLIB_GSWE_SIGN_INFO_PRIVATE_H__
|
||||||
|
#define __SWE_GLIB_GSWE_SIGN_INFO_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
#include "gswe-sign-info.h"
|
||||||
|
|
||||||
|
struct _GsweSignInfo {
|
||||||
|
/* the identifier for this sign */
|
||||||
|
GsweZodiac sign;
|
||||||
|
|
||||||
|
/* the name of this sign */
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
/* the element of the sign */
|
||||||
|
GsweElement element;
|
||||||
|
|
||||||
|
/* the quality of the sign */
|
||||||
|
GsweQuality quality;
|
||||||
|
|
||||||
|
/* Reference counter */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_SIGN_INFO_PRIVATE_H__ */
|
||||||
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
#endif /* __SWE_GLIB_BUILDING__ */
|
||||||
|
|
204
src/gswe-sign-info.c
Normal file
204
src/gswe-sign-info.c
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
/* gswe-sign-info.c: Zodiac sign related information
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
#include "gswe-sign-info.h"
|
||||||
|
#include "gswe-sign-info-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gswe-sign-info
|
||||||
|
* @short_description: a structure storing information about a zodiac sign
|
||||||
|
* @title: GsweSignInfo
|
||||||
|
* @stability: Stable
|
||||||
|
* @include: swe-glib.h
|
||||||
|
*
|
||||||
|
* The #GsweSignInfo stores information about a zodiac sign.
|
||||||
|
*/
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE(GsweSignInfo, gswe_sign_info, (GBoxedCopyFunc)gswe_sign_info_ref, (GBoxedFreeFunc)gswe_sign_info_unref);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gswe_sign_info_free(GsweSignInfo *sign_info)
|
||||||
|
{
|
||||||
|
if (sign_info->name) {
|
||||||
|
g_free(sign_info->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(sign_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_new:
|
||||||
|
*
|
||||||
|
* Creates a new GsweSignInfo object with reference count set to 1.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweSignInfo
|
||||||
|
*/
|
||||||
|
GsweSignInfo *
|
||||||
|
gswe_sign_info_new(void)
|
||||||
|
{
|
||||||
|
GsweSignInfo *ret;
|
||||||
|
|
||||||
|
ret = g_new0(GsweSignInfo, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_ref:
|
||||||
|
* @sign_info: (in): a #GsweSignInfo
|
||||||
|
*
|
||||||
|
* Increases reference count on @sign_info.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GsweSignInfo
|
||||||
|
*/
|
||||||
|
GsweSignInfo *
|
||||||
|
gswe_sign_info_ref(GsweSignInfo *sign_info)
|
||||||
|
{
|
||||||
|
sign_info->refcount++;
|
||||||
|
|
||||||
|
return sign_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_unref:
|
||||||
|
* @sign_info: a #GsweSignInfo
|
||||||
|
*
|
||||||
|
* Decreases reference count or @sign_info. If reference count reaches zero, @sign_info is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_sign_info_unref(GsweSignInfo *sign_info)
|
||||||
|
{
|
||||||
|
if (--sign_info->refcount == 0) {
|
||||||
|
gswe_sign_info_free(sign_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_set_sign:
|
||||||
|
* @sign_info: (in): a #GsweSignInfo
|
||||||
|
* @sign: the sign to set in @sign_info
|
||||||
|
*
|
||||||
|
* Sets the sign ID that is represented by this #GsweSignInfo.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_sign_info_set_sign(GsweSignInfo *sign_info, GsweZodiac sign)
|
||||||
|
{
|
||||||
|
sign_info->sign = sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_get_sign:
|
||||||
|
* @sign_info: (in): a #GsweSignInfo
|
||||||
|
*
|
||||||
|
* Gets the sign ID that is represented by this #GsweSignInfo.
|
||||||
|
*
|
||||||
|
* Returns: the sign ID
|
||||||
|
*/
|
||||||
|
GsweZodiac
|
||||||
|
gswe_sign_info_get_sign(GsweSignInfo *sign_info)
|
||||||
|
{
|
||||||
|
return sign_info->sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_set_name:
|
||||||
|
* @sign_info: (in): a #GsweSignInfo
|
||||||
|
* @name: (in): the name of the sign
|
||||||
|
*
|
||||||
|
* Sets the name of the sign.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_sign_info_set_name(GsweSignInfo *sign_info, const gchar *name)
|
||||||
|
{
|
||||||
|
if (sign_info->name) {
|
||||||
|
g_free(sign_info->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
sign_info->name = g_strdup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_get_name:
|
||||||
|
* @sign_info: (in): a #GsweSignInfo
|
||||||
|
*
|
||||||
|
* Gets the name associated with this sign.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the name of the zodiac sign
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
gswe_sign_info_get_name(GsweSignInfo *sign_info)
|
||||||
|
{
|
||||||
|
return sign_info->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_set_element:
|
||||||
|
* @sign_info: (in): a #GsweSignInfo
|
||||||
|
* @element: a #GsweElement
|
||||||
|
*
|
||||||
|
* Sets the element @sign_info should belong to.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_sign_info_set_element(GsweSignInfo *sign_info, GsweElement element)
|
||||||
|
{
|
||||||
|
sign_info->element = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_get_element:
|
||||||
|
* @sign_info: (in): a #GsweSignInfo
|
||||||
|
*
|
||||||
|
* Gets the element this sign belongs to.
|
||||||
|
*
|
||||||
|
* Returns: the element
|
||||||
|
*/
|
||||||
|
GsweElement
|
||||||
|
gswe_sign_info_get_element(GsweSignInfo *sign_info)
|
||||||
|
{
|
||||||
|
return sign_info->element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_set_quality:
|
||||||
|
* @sign_info: (in): a #GsweSignInfo
|
||||||
|
* @quality: a #GsweQuality
|
||||||
|
*
|
||||||
|
* Sets the quality @sign should belong to
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_sign_info_set_quality(GsweSignInfo *sign_info, GsweQuality quality)
|
||||||
|
{
|
||||||
|
sign_info->quality = quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_sign_info_get_quality:
|
||||||
|
* @sign_info: (in): a #GsweSignInfo
|
||||||
|
*
|
||||||
|
* Gets the quality this sign belongs to.
|
||||||
|
*
|
||||||
|
* Returns: the quality
|
||||||
|
*/
|
||||||
|
GsweQuality
|
||||||
|
gswe_sign_info_get_quality(GsweSignInfo *sign_info)
|
||||||
|
{
|
||||||
|
return sign_info->quality;
|
||||||
|
}
|
||||||
|
|
60
src/gswe-sign-info.h
Normal file
60
src/gswe-sign-info.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/* gswe-sign-info.h: Zodiac sign related information
|
||||||
|
*
|
||||||
|
* Copyright © 2013 Gergely Polonkai
|
||||||
|
*
|
||||||
|
* SWE-GLib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SWE-GLib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef __SWE_GLIB_GSWE_SIGN_INFO_H__
|
||||||
|
#define __SWE_GLIB_GSWE_SIGN_INFO_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GsweSignInfo:
|
||||||
|
*
|
||||||
|
* <structname>GsweSignInfo</structname> is an opaque structure whose members
|
||||||
|
* cannot be accessed directly.
|
||||||
|
*
|
||||||
|
* Since: 1.1
|
||||||
|
*/
|
||||||
|
typedef struct _GsweSignInfo GsweSignInfo;
|
||||||
|
|
||||||
|
GType gswe_sign_info_get_type(void);
|
||||||
|
#define GSWE_TYPE_SIGN_INFO (gswe_sign_info_get_type())
|
||||||
|
|
||||||
|
GsweSignInfo *gswe_sign_info_new(void);
|
||||||
|
|
||||||
|
GsweSignInfo *gswe_sign_info_ref(GsweSignInfo *sign_info);
|
||||||
|
void gswe_sign_info_unref(GsweSignInfo *sign_info);
|
||||||
|
|
||||||
|
void gswe_sign_info_set_sign(GsweSignInfo *sign_info, GsweZodiac sign);
|
||||||
|
GsweZodiac gswe_sign_info_get_sign(GsweSignInfo *sign_info);
|
||||||
|
|
||||||
|
void gswe_sign_info_set_name(GsweSignInfo *sign_info, const gchar *name);
|
||||||
|
const gchar *gswe_sign_info_get_name(GsweSignInfo *sign_info);
|
||||||
|
|
||||||
|
void gswe_sign_info_set_element(GsweSignInfo *sign_info, GsweElement element);
|
||||||
|
GsweElement gswe_sign_info_get_element(GsweSignInfo *sign_info);
|
||||||
|
|
||||||
|
void gswe_sign_info_set_quality(GsweSignInfo *sign_info, GsweQuality quality);
|
||||||
|
GsweQuality gswe_sign_info_get_quality(GsweSignInfo *sign_info);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __SWE_GLIB_GSWE_SIGN_INFO_H__ */
|
||||||
|
|
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "../swe/src/swephexp.h"
|
#include "../swe/src/swephexp.h"
|
||||||
#include "swe-glib-private.h"
|
#include "swe-glib-private.h"
|
||||||
|
#include "swe-glib.h"
|
||||||
#include "gswe-timestamp.h"
|
#include "gswe-timestamp.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -383,7 +384,7 @@ gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp, GError **err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (timestamp->priv->valid_dates == 0) {
|
if (timestamp->priv->valid_dates == 0) {
|
||||||
g_set_error(err, GSWE_TIMESTAMP_ERROR, GSWE_TIMESTAMP_ERROR_NO_VALID, "This timestamp object holds no valid values");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_NO_VALID_VALUE, "This timestamp object holds no valid values");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,14 +803,14 @@ gswe_timestamp_calculate_julian(GsweTimestamp *timestamp, GError **err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (timestamp->priv->valid_dates == 0) {
|
if (timestamp->priv->valid_dates == 0) {
|
||||||
g_set_error(err, GSWE_TIMESTAMP_ERROR, GSWE_TIMESTAMP_ERROR_NO_VALID, "This timestamp object holds no valid values");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_NO_VALID_VALUE, "This timestamp object holds no valid values");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
swe_utc_time_zone(timestamp->priv->gregorian_year, timestamp->priv->gregorian_month, timestamp->priv->gregorian_day, timestamp->priv->gregorian_hour, timestamp->priv->gregorian_minute, timestamp->priv->gregorian_second + timestamp->priv->gregorian_microsecond / 1000.0, timestamp->priv->gregorian_timezone_offset, &utc_year, &utc_month, &utc_day, &utc_hour, &utc_minute, &utc_second);
|
swe_utc_time_zone(timestamp->priv->gregorian_year, timestamp->priv->gregorian_month, timestamp->priv->gregorian_day, timestamp->priv->gregorian_hour, timestamp->priv->gregorian_minute, timestamp->priv->gregorian_second + timestamp->priv->gregorian_microsecond / 1000.0, timestamp->priv->gregorian_timezone_offset, &utc_year, &utc_month, &utc_day, &utc_hour, &utc_minute, &utc_second);
|
||||||
|
|
||||||
if ((retval = swe_utc_to_jd(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second, SE_GREG_CAL, dret, serr)) == ERR) {
|
if ((retval = swe_utc_to_jd(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second, SE_GREG_CAL, dret, serr)) == ERR) {
|
||||||
g_set_error(err, GSWE_TIMESTAMP_ERROR, GSWE_TIMESTAMP_ERROR_SWE_ERROR, "Swiss Ephemeris error: %s", serr);
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_SWE_FATAL, "Swiss Ephemeris error: %s", serr);
|
||||||
} else {
|
} else {
|
||||||
timestamp->priv->julian_day = dret[0];
|
timestamp->priv->julian_day = dret[0];
|
||||||
timestamp->priv->valid_dates |= VALID_JULIAN_DAY;
|
timestamp->priv->valid_dates |= VALID_JULIAN_DAY;
|
||||||
@@ -853,15 +854,6 @@ gswe_timestamp_get_julian_day(GsweTimestamp *timestamp, GError **err)
|
|||||||
return timestamp->priv->julian_day;
|
return timestamp->priv->julian_day;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gswe_timestamp_error_quark:
|
|
||||||
*
|
|
||||||
* Gets the GsweTimestamp Error Quark.
|
|
||||||
*
|
|
||||||
* Return value: a #GQuark
|
|
||||||
*/
|
|
||||||
G_DEFINE_QUARK(gswe-timestamp-error-quark, gswe_timestamp_error);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gswe_timestamp_new:
|
* gswe_timestamp_new:
|
||||||
*
|
*
|
||||||
@@ -873,6 +865,8 @@ G_DEFINE_QUARK(gswe-timestamp-error-quark, gswe_timestamp_error);
|
|||||||
GsweTimestamp *
|
GsweTimestamp *
|
||||||
gswe_timestamp_new(void)
|
gswe_timestamp_new(void)
|
||||||
{
|
{
|
||||||
|
gswe_init();
|
||||||
|
|
||||||
return GSWE_TIMESTAMP(g_object_new(GSWE_TYPE_TIMESTAMP, NULL));
|
return GSWE_TIMESTAMP(g_object_new(GSWE_TYPE_TIMESTAMP, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -894,7 +888,11 @@ gswe_timestamp_new(void)
|
|||||||
GsweTimestamp *
|
GsweTimestamp *
|
||||||
gswe_timestamp_new_from_gregorian_full(gint year, gint month, gint day, gint hour, gint minute, gint second, gint microsecond, gdouble time_zone_offset)
|
gswe_timestamp_new_from_gregorian_full(gint year, gint month, gint day, gint hour, gint minute, gint second, gint microsecond, gdouble time_zone_offset)
|
||||||
{
|
{
|
||||||
GsweTimestamp *timestamp = GSWE_TIMESTAMP(g_object_new(GSWE_TYPE_TIMESTAMP,
|
GsweTimestamp *timestamp;
|
||||||
|
|
||||||
|
gswe_init();
|
||||||
|
|
||||||
|
timestamp = GSWE_TIMESTAMP(g_object_new(GSWE_TYPE_TIMESTAMP,
|
||||||
"gregorian-year", year,
|
"gregorian-year", year,
|
||||||
"gregorian-month", month,
|
"gregorian-month", month,
|
||||||
"gregorian-day", day,
|
"gregorian-day", day,
|
||||||
|
@@ -32,39 +32,6 @@ typedef struct _GsweTimestamp GsweTimestamp;
|
|||||||
typedef struct _GsweTimestampClass GsweTimestampClass;
|
typedef struct _GsweTimestampClass GsweTimestampClass;
|
||||||
typedef struct _GsweTimestampPrivate GsweTimestampPrivate;
|
typedef struct _GsweTimestampPrivate GsweTimestampPrivate;
|
||||||
|
|
||||||
/**
|
|
||||||
* GSWE_TIMESTAMP_ERROR:
|
|
||||||
*
|
|
||||||
* Error domain for GsweTimestamp. Errors in this domain will be from
|
|
||||||
* #GsweTimestampError enumeration. See #GError for more information on error
|
|
||||||
* domains.
|
|
||||||
*/
|
|
||||||
#define GSWE_TIMESTAMP_ERROR (gswe_timestamp_error_quark())
|
|
||||||
GQuark gswe_timestamp_error_quark(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweTimestampError:
|
|
||||||
* @GSWE_TIMESTAMP_ERROR_SUCCESS: no error
|
|
||||||
* @GSWE_TIMESTAMP_ERROR_INVALID_DATE: the Gregorian date specified in this
|
|
||||||
* GsweTimestamp is invalid
|
|
||||||
* @GSWE_TIMESTAMP_ERROR_INVALID_TIME: the time specified in this
|
|
||||||
* GsweTimestamp is invalid
|
|
||||||
* @GSWE_TIMESTAMP_ERROR_NO_VALID: the GsweTimestamp object holds no valid
|
|
||||||
* timestamp
|
|
||||||
* @GSWE_TIMESTAMP_ERROR_SWE_ERROR: denotes an error detected by the Swiss
|
|
||||||
* Ephemeris library, converted from their
|
|
||||||
* static char array to a #GError
|
|
||||||
*
|
|
||||||
* Error codes returned by GsweTimestamp functions.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
GSWE_TIMESTAMP_ERROR_SUCCESS,
|
|
||||||
GSWE_TIMESTAMP_ERROR_INVALID_DATE,
|
|
||||||
GSWE_TIMESTAMP_ERROR_INVALID_TIME,
|
|
||||||
GSWE_TIMESTAMP_ERROR_NO_VALID,
|
|
||||||
GSWE_TIMESTAMP_ERROR_SWE_ERROR
|
|
||||||
} GsweTimestampError;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GsweTimestamp:
|
* GsweTimestamp:
|
||||||
*
|
*
|
||||||
|
@@ -17,36 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "gswe-types.h"
|
#include "gswe-types.h"
|
||||||
|
|
||||||
static GsweMoonPhaseData *
|
|
||||||
gswe_moon_phase_data_copy(GsweMoonPhaseData *moon_phase_data)
|
|
||||||
{
|
|
||||||
GsweMoonPhaseData *ret = g_new0(GsweMoonPhaseData, 1);
|
|
||||||
|
|
||||||
ret->phase = moon_phase_data->phase;
|
|
||||||
ret->illumination = moon_phase_data->illumination;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE(GsweMoonPhaseData, gswe_moon_phase_data, (GBoxedCopyFunc)gswe_moon_phase_data_copy, (GBoxedFreeFunc)g_free);
|
|
||||||
|
|
||||||
static GswePlanetData *
|
|
||||||
gswe_planet_data_copy(GswePlanetData *planet_data)
|
|
||||||
{
|
|
||||||
GswePlanetData *ret = g_new0(GswePlanetData, 1);
|
|
||||||
|
|
||||||
ret->planet_id = planet_data->planet_id;
|
|
||||||
ret->planet_info = planet_data->planet_info;
|
|
||||||
ret->position = planet_data->position;
|
|
||||||
ret->retrograde = planet_data->retrograde;
|
|
||||||
ret->house = planet_data->house;
|
|
||||||
ret->sign = planet_data->sign;
|
|
||||||
ret->revision = planet_data->revision;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE(GswePlanetData, gswe_planet_data, (GBoxedCopyFunc)gswe_planet_data_copy, (GBoxedFreeFunc)g_free);
|
|
||||||
|
|
||||||
GsweCoordinates *
|
GsweCoordinates *
|
||||||
gswe_coordinates_copy(GsweCoordinates *coordinates)
|
gswe_coordinates_copy(GsweCoordinates *coordinates)
|
||||||
@@ -62,49 +32,3 @@ gswe_coordinates_copy(GsweCoordinates *coordinates)
|
|||||||
|
|
||||||
G_DEFINE_BOXED_TYPE(GsweCoordinates, gswe_coordinates, (GBoxedCopyFunc)gswe_coordinates_copy, (GBoxedFreeFunc)g_free);
|
G_DEFINE_BOXED_TYPE(GsweCoordinates, gswe_coordinates, (GBoxedCopyFunc)gswe_coordinates_copy, (GBoxedFreeFunc)g_free);
|
||||||
|
|
||||||
static GsweHouseData *
|
|
||||||
gswe_house_data_copy(GsweHouseData *house_data)
|
|
||||||
{
|
|
||||||
GsweHouseData *ret = g_new0(GsweHouseData, 1);
|
|
||||||
|
|
||||||
ret->house = house_data->house;
|
|
||||||
ret->cusp_position = house_data->cusp_position;
|
|
||||||
ret->sign = house_data->sign;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE(GsweHouseData, gswe_house_data, (GBoxedCopyFunc)gswe_house_data_copy, (GBoxedFreeFunc)g_free);
|
|
||||||
|
|
||||||
static GsweAspectData *
|
|
||||||
gswe_aspect_data_copy(GsweAspectData *aspect_data)
|
|
||||||
{
|
|
||||||
GsweAspectData *ret = g_new0(GsweAspectData, 1);
|
|
||||||
|
|
||||||
ret->planet1 = aspect_data->planet1;
|
|
||||||
ret->planet2 = aspect_data->planet2;
|
|
||||||
ret->distance = aspect_data->distance;
|
|
||||||
ret->aspect = aspect_data->aspect;
|
|
||||||
ret->aspect_info = aspect_data->aspect_info;
|
|
||||||
ret->difference = aspect_data->difference;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE(GsweAspectData, gswe_aspect_data, (GBoxedCopyFunc)gswe_aspect_data_copy, (GBoxedFreeFunc)g_free);
|
|
||||||
|
|
||||||
static GsweAntiscionData *
|
|
||||||
gswe_antiscion_data_copy(GsweAntiscionData *antiscion_data)
|
|
||||||
{
|
|
||||||
GsweAntiscionData *ret = g_new0(GsweAntiscionData, 1);
|
|
||||||
|
|
||||||
ret->planet1 = antiscion_data->planet1;
|
|
||||||
ret->planet2 = antiscion_data->planet2;
|
|
||||||
ret->axis = antiscion_data->axis;
|
|
||||||
ret->antiscion_info = antiscion_data->antiscion_info;
|
|
||||||
ret->difference = antiscion_data->difference;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE(GsweAntiscionData, gswe_antiscion_data, (GBoxedCopyFunc)gswe_antiscion_data_copy, (GBoxedFreeFunc)g_free);
|
|
||||||
|
220
src/gswe-types.h
220
src/gswe-types.h
@@ -53,7 +53,7 @@
|
|||||||
* @GSWE_PLANET_MOON_NODE: the mean ascending (north) Moon node
|
* @GSWE_PLANET_MOON_NODE: the mean ascending (north) Moon node
|
||||||
* @GSWE_PLANET_MOON_APOGEE: the mean Moon apogee (sometimes called Dark Moon,
|
* @GSWE_PLANET_MOON_APOGEE: the mean Moon apogee (sometimes called Dark Moon,
|
||||||
* or Lilith)
|
* or Lilith)
|
||||||
* @GSWE_PLANET_ASCENDENT: the ascendent
|
* @GSWE_PLANET_ASCENDANT: the ascendant
|
||||||
* @GSWE_PLANET_MC: midheaven (Medium Coeli)
|
* @GSWE_PLANET_MC: midheaven (Medium Coeli)
|
||||||
* @GSWE_PLANET_VERTEX: the Vertex (the point where the ecliptic meats the
|
* @GSWE_PLANET_VERTEX: the Vertex (the point where the ecliptic meats the
|
||||||
* primal vertical)
|
* primal vertical)
|
||||||
@@ -80,7 +80,7 @@ typedef enum {
|
|||||||
GSWE_PLANET_VESTA,
|
GSWE_PLANET_VESTA,
|
||||||
GSWE_PLANET_MOON_NODE,
|
GSWE_PLANET_MOON_NODE,
|
||||||
GSWE_PLANET_MOON_APOGEE,
|
GSWE_PLANET_MOON_APOGEE,
|
||||||
GSWE_PLANET_ASCENDENT,
|
GSWE_PLANET_ASCENDANT,
|
||||||
GSWE_PLANET_MC,
|
GSWE_PLANET_MC,
|
||||||
GSWE_PLANET_VERTEX
|
GSWE_PLANET_VERTEX
|
||||||
} GswePlanet;
|
} GswePlanet;
|
||||||
@@ -210,7 +210,7 @@ typedef enum {
|
|||||||
* @GSWE_HOUSE_SYSTEM_NONE: no house system
|
* @GSWE_HOUSE_SYSTEM_NONE: no house system
|
||||||
* @GSWE_HOUSE_SYSTEM_PLACIDUS: Placidus house system
|
* @GSWE_HOUSE_SYSTEM_PLACIDUS: Placidus house system
|
||||||
* @GSWE_HOUSE_SYSTEM_KOCH: Koch house system
|
* @GSWE_HOUSE_SYSTEM_KOCH: Koch house system
|
||||||
* @GSWE_HOUSE_SISTEM_EQUAL: Equal house system
|
* @GSWE_HOUSE_SYSTEM_EQUAL: Equal house system
|
||||||
*
|
*
|
||||||
* The house systems currently known by SWE-GLib.
|
* The house systems currently known by SWE-GLib.
|
||||||
*/
|
*/
|
||||||
@@ -218,11 +218,12 @@ typedef enum {
|
|||||||
GSWE_HOUSE_SYSTEM_NONE,
|
GSWE_HOUSE_SYSTEM_NONE,
|
||||||
GSWE_HOUSE_SYSTEM_PLACIDUS,
|
GSWE_HOUSE_SYSTEM_PLACIDUS,
|
||||||
GSWE_HOUSE_SYSTEM_KOCH,
|
GSWE_HOUSE_SYSTEM_KOCH,
|
||||||
GSWE_HOUSE_SISTEM_EQUAL
|
GSWE_HOUSE_SYSTEM_EQUAL
|
||||||
} GsweHouseSystem;
|
} GsweHouseSystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GsweMoonPhase:
|
* GsweMoonPhase:
|
||||||
|
* @GSWE_MOON_PHASE_NONE: Moon phase is not defined
|
||||||
* @GSWE_MOON_PHASE_NEW: New Moon
|
* @GSWE_MOON_PHASE_NEW: New Moon
|
||||||
* @GSWE_MOON_PHASE_WAXING_CRESCENT: Waxing crescent Moon
|
* @GSWE_MOON_PHASE_WAXING_CRESCENT: Waxing crescent Moon
|
||||||
* @GSWE_MOON_PHASE_WAXING_HALF: First half
|
* @GSWE_MOON_PHASE_WAXING_HALF: First half
|
||||||
@@ -236,6 +237,7 @@ typedef enum {
|
|||||||
* The phases of the Moon.
|
* The phases of the Moon.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
GSWE_MOON_PHASE_NONE,
|
||||||
GSWE_MOON_PHASE_NEW,
|
GSWE_MOON_PHASE_NEW,
|
||||||
GSWE_MOON_PHASE_WAXING_CRESCENT,
|
GSWE_MOON_PHASE_WAXING_CRESCENT,
|
||||||
GSWE_MOON_PHASE_WAXING_HALF,
|
GSWE_MOON_PHASE_WAXING_HALF,
|
||||||
@@ -247,150 +249,6 @@ typedef enum {
|
|||||||
GSWE_MOON_PHASE_DARK
|
GSWE_MOON_PHASE_DARK
|
||||||
} GsweMoonPhase;
|
} GsweMoonPhase;
|
||||||
|
|
||||||
/**
|
|
||||||
* GswePlanetInfo:
|
|
||||||
* @planet: the planet ID
|
|
||||||
* @sweph_id: the planet ID according to the Swiss Ephemeris libarary
|
|
||||||
* (or -1, if the planet has no such ID)
|
|
||||||
* @real_body: TRUE if the planet is a "real" celestial body on the sky.
|
|
||||||
* Please note that this will be true for Dark Moon (Lilith).
|
|
||||||
* Everything that has a planet ID in Swiss Ephemeris is
|
|
||||||
* treated as a real celestial body.
|
|
||||||
* @orb: the planet's “personal” orb
|
|
||||||
* @name: the planet's name
|
|
||||||
* @points: the value this planet counts in the element/quality points
|
|
||||||
* table
|
|
||||||
* @domicile_sign_1: the first sign in which the planet is domicile
|
|
||||||
* @domicile_sign_2: the second sign in which the planet is domicile
|
|
||||||
* @exile_sign_1: the first sign in which the planet is in exile
|
|
||||||
* @exile_sign_2: the second sign in which the planet is in exile
|
|
||||||
* @exalted_sign: the sign in which the planet is exalted
|
|
||||||
* @fall_sign: the sign in which the planet is in fall
|
|
||||||
*
|
|
||||||
* This struct holds different informations of planets. You should never modify
|
|
||||||
* such a structure unless you really know what you are doing.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
GswePlanet planet;
|
|
||||||
gint sweph_id;
|
|
||||||
gboolean real_body;
|
|
||||||
gdouble orb;
|
|
||||||
gchar *name;
|
|
||||||
gint points;
|
|
||||||
GsweZodiac domicile_sign_1;
|
|
||||||
GsweZodiac domicile_sign_2;
|
|
||||||
GsweZodiac exile_sign_1;
|
|
||||||
GsweZodiac exile_sign_2;
|
|
||||||
GsweZodiac exalted_sign;
|
|
||||||
GsweZodiac fall_sign;
|
|
||||||
} GswePlanetInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweSignInfo:
|
|
||||||
* @sign_id: the identifier for this sign
|
|
||||||
* @name: the name of this sign
|
|
||||||
* @element: the element of the sign
|
|
||||||
* @quality: the quality of the sign
|
|
||||||
*
|
|
||||||
* Holds information about zodiac signs known by SWE-GLib.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
GsweZodiac sign_id;
|
|
||||||
gchar *name;
|
|
||||||
GsweElement element;
|
|
||||||
GsweQuality quality;
|
|
||||||
} GsweSignInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweHouseSystemInfo:
|
|
||||||
* @system: the house system's ID
|
|
||||||
* @sweph_id: the character value that represents this house system in the Swiss Ephemeris library
|
|
||||||
* @name: the name of this house system
|
|
||||||
*
|
|
||||||
* Holds information about house systems known by SWE-GLib.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
GsweHouseSystem system;
|
|
||||||
gchar sweph_id;
|
|
||||||
gchar *name;
|
|
||||||
} GsweHouseSystemInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweAspectInfo:
|
|
||||||
* @aspect: the identifier of this aspect
|
|
||||||
* @name: the name of the aspect
|
|
||||||
* @size: the size of the aspect, in degrees
|
|
||||||
* @orb_modifier: the modifier of the orb (the maximum allowable difference from an exact orb)
|
|
||||||
* @harmonic: shows whether this aspect is harmonic or not
|
|
||||||
* @major: shows whether this aspect is major (Ptolemaic) or not
|
|
||||||
*
|
|
||||||
* Holds informations about the aspects known by SWE-GLib.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
GsweAspect aspect;
|
|
||||||
gchar *name;
|
|
||||||
guint size;
|
|
||||||
guint orb_modifier;
|
|
||||||
gboolean harmonic;
|
|
||||||
gboolean major;
|
|
||||||
} GsweAspectInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweAntiscionAxisInfo:
|
|
||||||
* @axis_id: the identifier of this mirror's axis
|
|
||||||
* @start_sign: represents the sign in whict the mirror axis starts
|
|
||||||
* @name: the name of the mirror
|
|
||||||
* @middle_axis: if TRUE, the axis runs through the middle of its starting sign
|
|
||||||
*
|
|
||||||
* Holds information of antiscion axes.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
GsweAntiscionAxis axis_id;
|
|
||||||
GsweSignInfo *start_sign;
|
|
||||||
gchar *name;
|
|
||||||
gboolean middle_axis;
|
|
||||||
} GsweAntiscionAxisInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweMoonPhaseData:
|
|
||||||
* @phase: the current phase of the Moon
|
|
||||||
* @illumination: the portion of the Moon that is currently illuminated
|
|
||||||
*
|
|
||||||
* Holds information of a Moon phase.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
GsweMoonPhase phase;
|
|
||||||
gdouble illumination;
|
|
||||||
} GsweMoonPhaseData;
|
|
||||||
|
|
||||||
GType gswe_moon_phase_data_get_type(void);
|
|
||||||
#define GSWE_TYPE_MOON_PHASE_DATA (gswe_moon_phase_data_get_type())
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GswePlanetData:
|
|
||||||
* @planet_id: A GswePlanet, the identifier of the planet
|
|
||||||
* @planet_info: A GswePlanetInfo structure, holding every information about the planet
|
|
||||||
* @position: The longitude position of the planet
|
|
||||||
* @retrograde: TRUE if the planet is in retrograde motion
|
|
||||||
* @house: Number of the house in which the planet is in
|
|
||||||
* @sign: A GsweSignInfo structure, holding every information about the sign the planet is in
|
|
||||||
* @revision: An internal version number of the calculation
|
|
||||||
*
|
|
||||||
* Holds information of a given planet.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
GswePlanet planet_id;
|
|
||||||
GswePlanetInfo *planet_info;
|
|
||||||
gdouble position;
|
|
||||||
gboolean retrograde;
|
|
||||||
gint house;
|
|
||||||
GsweSignInfo *sign;
|
|
||||||
guint revision;
|
|
||||||
} GswePlanetData;
|
|
||||||
|
|
||||||
GType gswe_planet_data_get_type(void);
|
|
||||||
#define GSWE_TYPE_PLANET_DATA (gswe_planet_data_get_type())
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GsweCoordinates:
|
* GsweCoordinates:
|
||||||
* @longitude: longitude part of the coordinates
|
* @longitude: longitude part of the coordinates
|
||||||
@@ -408,71 +266,5 @@ typedef struct _GsweCoordinates {
|
|||||||
GType gswe_coordinates_get_type(void);
|
GType gswe_coordinates_get_type(void);
|
||||||
#define GSWE_TYPE_COORDINATES (gswe_coordinates_get_type())
|
#define GSWE_TYPE_COORDINATES (gswe_coordinates_get_type())
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweHouseData:
|
|
||||||
* @house: the number of the house (usually in the range [1;12]. Sometimes may
|
|
||||||
* be [1;36].
|
|
||||||
* @cusp_position: the position of the house's cusp on the sky
|
|
||||||
* @sign: the #GsweSignInfo structure associated with the sign in which the
|
|
||||||
* house cusp is in
|
|
||||||
*
|
|
||||||
* Holds information of a given house.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
guint house;
|
|
||||||
gdouble cusp_position;
|
|
||||||
GsweSignInfo *sign;
|
|
||||||
} GsweHouseData;
|
|
||||||
|
|
||||||
GType gswe_house_data_get_type(void);
|
|
||||||
#define GSWE_TYPE_HOUSE_DATA (gswe_house_data_get_type())
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweAspectData:
|
|
||||||
* @planet1: the first planet in the aspect
|
|
||||||
* @planet2: the second planet in the aspect
|
|
||||||
* @distance: the distance between the two planets, in degrees
|
|
||||||
* @aspect: the aspect between the two planets
|
|
||||||
* @aspect_info: the #GsweAspectInfo structure associated with the aspect
|
|
||||||
* @difference: the difference in percent between an exact aspect and this
|
|
||||||
* given aspect
|
|
||||||
*
|
|
||||||
* Holds information about a given aspect.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
GswePlanetData *planet1;
|
|
||||||
GswePlanetData *planet2;
|
|
||||||
gdouble distance;
|
|
||||||
GsweAspect aspect;
|
|
||||||
GsweAspectInfo *aspect_info;
|
|
||||||
gdouble difference;
|
|
||||||
} GsweAspectData;
|
|
||||||
|
|
||||||
GType gswe_aspect_data_get_type(void);
|
|
||||||
#define GSWE_TYPE_ASPECT_DATA (gswe_aspect_data_get_type())
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweAntiscionData:
|
|
||||||
* @planet1: the first planet in the antiscion
|
|
||||||
* @planet2: the second planet in the antiscion
|
|
||||||
* @axis: the axis on which this antiscion is
|
|
||||||
* @antiscion_info: the #GsweAntiscionAxisInfo structure associated with this
|
|
||||||
* antiscion
|
|
||||||
* @difference: the difference in degrees between an exact antiscion and this
|
|
||||||
* given antiscion
|
|
||||||
*
|
|
||||||
* Holds information about a given antiscion.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
GswePlanetData *planet1;
|
|
||||||
GswePlanetData *planet2;
|
|
||||||
GsweAntiscionAxis axis;
|
|
||||||
GsweAntiscionAxisInfo *antiscion_info;
|
|
||||||
gdouble difference;
|
|
||||||
} GsweAntiscionData;
|
|
||||||
|
|
||||||
GType gswe_antiscion_data_get_type(void);
|
|
||||||
#define GSWE_TYPE_ANTISCION_DATA (gswe_antiscion_data_get_type())
|
|
||||||
|
|
||||||
#endif /* __SWE_GLIB_GSWE_TYPES_H__ */
|
#endif /* __SWE_GLIB_GSWE_TYPES_H__ */
|
||||||
|
|
||||||
|
@@ -19,14 +19,25 @@
|
|||||||
|
|
||||||
#include "gswe-timestamp.h"
|
#include "gswe-timestamp.h"
|
||||||
#include "gswe-types.h"
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-moon-phase-data-private.h"
|
||||||
|
#include "gswe-sign-info-private.h"
|
||||||
|
#include "gswe-planet-info-private.h"
|
||||||
|
#include "gswe-planet-data-private.h"
|
||||||
|
#include "gswe-aspect-info-private.h"
|
||||||
|
#include "gswe-aspect-data-private.h"
|
||||||
|
#include "gswe-antiscion-axis-info-private.h"
|
||||||
|
#include "gswe-antiscion-data-private.h"
|
||||||
|
#include "gswe-house-system-info-private.h"
|
||||||
|
#include "gswe-house-data-private.h"
|
||||||
|
|
||||||
|
extern gboolean gswe_initialized;
|
||||||
extern gchar *gswe_ephe_path;
|
extern gchar *gswe_ephe_path;
|
||||||
extern GsweTimestamp *gswe_full_moon_base_date;
|
extern GsweTimestamp *gswe_full_moon_base_date;
|
||||||
extern GHashTable *gswe_planet_info_table;
|
extern GHashTable *gswe_planet_info_table;
|
||||||
extern GHashTable *gswe_sign_info_table;
|
extern GHashTable *gswe_sign_info_table;
|
||||||
extern GHashTable *gswe_house_system_info_table;
|
extern GHashTable *gswe_house_system_info_table;
|
||||||
extern GHashTable *gswe_aspect_info_table;
|
extern GHashTable *gswe_aspect_info_table;
|
||||||
extern GHashTable *gswe_antiscion_info_table;
|
extern GHashTable *gswe_antiscion_axis_info_table;
|
||||||
|
|
||||||
GsweCoordinates *gswe_coordinates_copy(GsweCoordinates *coordinates);
|
GsweCoordinates *gswe_coordinates_copy(GsweCoordinates *coordinates);
|
||||||
|
|
||||||
|
260
src/swe-glib.c
260
src/swe-glib.c
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "../swe/src/swephexp.h"
|
#include "../swe/src/swephexp.h"
|
||||||
#include "swe-glib.h"
|
#include "swe-glib.h"
|
||||||
|
#include "swe-glib-private.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:swe-glib
|
* SECTION:swe-glib
|
||||||
@@ -39,87 +40,70 @@ GHashTable *gswe_planet_info_table;
|
|||||||
GHashTable *gswe_sign_info_table;
|
GHashTable *gswe_sign_info_table;
|
||||||
GHashTable *gswe_house_system_info_table;
|
GHashTable *gswe_house_system_info_table;
|
||||||
GHashTable *gswe_aspect_info_table;
|
GHashTable *gswe_aspect_info_table;
|
||||||
GHashTable *gswe_antiscion_info_table;
|
GHashTable *gswe_antiscion_axis_info_table;
|
||||||
GsweTimestamp *gswe_full_moon_base_date;
|
GsweTimestamp *gswe_full_moon_base_date;
|
||||||
|
static gboolean gswe_initializing = FALSE;
|
||||||
|
|
||||||
#define ADD_PLANET(ht, v, i, s, r, n, o, h, dom1, dom2, exi1, exi2, exa, fal) (v) = g_new0(GswePlanetInfo, 1); \
|
#define ADD_PLANET(ht, v, i, s, r, n, o, h) \
|
||||||
(v)->planet = (i); \
|
(v) = gswe_planet_info_new(); \
|
||||||
(v)->sweph_id = (s); \
|
(v)->planet = (i); \
|
||||||
(v)->real_body = (r); \
|
(v)->sweph_id = (s); \
|
||||||
(v)->orb = (o); \
|
(v)->real_body = (r); \
|
||||||
(v)->name = g_strdup(n); \
|
(v)->orb = (o); \
|
||||||
(v)->points = (h); \
|
(v)->name = g_strdup(n); \
|
||||||
(v)->domicile_sign_1 = (dom1); \
|
(v)->points = (h); \
|
||||||
(v)->domicile_sign_2 = (dom2); \
|
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v)); \
|
||||||
(v)->exile_sign_1 = (exi1); \
|
|
||||||
(v)->exile_sign_2 = (exi2); \
|
|
||||||
(v)->exalted_sign = (exa); \
|
|
||||||
(v)->fall_sign = (fal); \
|
|
||||||
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
|
|
||||||
|
|
||||||
#define ADD_SIGN(ht, v, s, n, e, q) (v) = g_new0(GsweSignInfo, 1); \
|
#define ADD_SIGN(ht, v, s, n, e, q) \
|
||||||
(v)->sign_id = (s); \
|
(v) = gswe_sign_info_new(); \
|
||||||
(v)->name = g_strdup(n); \
|
(v)->sign = (s); \
|
||||||
(v)->element = (e); \
|
(v)->name = g_strdup(n); \
|
||||||
(v)->quality = (q); \
|
(v)->element = (e); \
|
||||||
g_hash_table_replace((ht), GINT_TO_POINTER(s), (v));
|
(v)->quality = (q); \
|
||||||
|
g_hash_table_replace((ht), GINT_TO_POINTER(s), (v)); \
|
||||||
|
|
||||||
#define ADD_HOUSE_SYSTEM(ht, v, i, s, n) (v) = g_new0(GsweHouseSystemInfo, 1); \
|
#define ADD_HOUSE_SYSTEM(ht, v, i, s, n) \
|
||||||
(v)->system = i; \
|
(v) = gswe_house_system_info_new(); \
|
||||||
(v)->sweph_id = s; \
|
(v)->house_system = i; \
|
||||||
(v)->name = g_strdup(n); \
|
(v)->sweph_id = s; \
|
||||||
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
|
(v)->name = g_strdup(n); \
|
||||||
|
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v)); \
|
||||||
|
|
||||||
#define ADD_ASPECT(ht, v, i, n, s, o, h, m) (v) = g_new0(GsweAspectInfo, 1); \
|
#define ADD_ASPECT(ht, v, i, n, s, o, h, m) \
|
||||||
(v)->aspect = (i); \
|
(v) = gswe_aspect_info_new(); \
|
||||||
(v)->name = g_strdup(n); \
|
(v)->aspect = (i); \
|
||||||
(v)->size = (s); \
|
(v)->name = g_strdup(n); \
|
||||||
(v)->orb_modifier = (o); \
|
(v)->size = (s); \
|
||||||
(v)->harmonic = (h); \
|
(v)->orb_modifier = (o); \
|
||||||
(v)->major = (m); \
|
(v)->harmonic = (h); \
|
||||||
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
|
(v)->major = (m); \
|
||||||
|
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v)); \
|
||||||
|
|
||||||
#define ADD_ANTISCION(ht, v, hts, vs, i, n, s, m) (v) = g_new0(GsweAntiscionAxisInfo, 1); \
|
#define ADD_ANTISCION(ht, v, hts, vs, i, n, s, m) \
|
||||||
(vs) = g_hash_table_lookup((hts), GINT_TO_POINTER(i)); \
|
(v) = gswe_antiscion_axis_info_new(); \
|
||||||
(v)->axis_id = (i); \
|
(vs) = g_hash_table_lookup((hts), GINT_TO_POINTER(i)); \
|
||||||
(v)->start_sign = (vs); \
|
(v)->axis = (i); \
|
||||||
(v)->name = g_strdup(n); \
|
(v)->start_sign = (vs); \
|
||||||
(v)->middle_axis = m; \
|
(v)->name = g_strdup(n); \
|
||||||
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
|
(v)->sign_offset = m; \
|
||||||
void
|
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v)); \
|
||||||
gswe_free_planet_info(gpointer planet_info)
|
|
||||||
|
/**
|
||||||
|
* gswe_error_quark:
|
||||||
|
*
|
||||||
|
* Gets the SWE-GLib Error Quark.
|
||||||
|
*
|
||||||
|
* Return value: a #GQuark
|
||||||
|
*/
|
||||||
|
#if GLIB_CHECK_VERSION(2, 34, 0)
|
||||||
|
G_DEFINE_QUARK(gswe-error-quark, gswe_error);
|
||||||
|
#else
|
||||||
|
GQuark
|
||||||
|
gswe_error_quark(void)
|
||||||
{
|
{
|
||||||
g_free(((GswePlanetInfo *)planet_info)->name);
|
return g_quark_from_static_string("gswe-error-quark");
|
||||||
g_free(planet_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gswe_free_sign_info(gpointer sign_info)
|
|
||||||
{
|
|
||||||
g_free(((GsweSignInfo *)sign_info)->name);
|
|
||||||
g_free(sign_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gswe_free_house_system_info(gpointer house_system_info)
|
|
||||||
{
|
|
||||||
g_free(((GsweHouseSystemInfo *)house_system_info)->name);
|
|
||||||
g_free(house_system_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gswe_free_aspect_info(gpointer aspect_info)
|
|
||||||
{
|
|
||||||
g_free(((GsweAspectInfo *)aspect_info)->name);
|
|
||||||
g_free(aspect_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gswe_free_antiscion_info(GsweAntiscionAxisInfo *antiscion_info)
|
|
||||||
{
|
|
||||||
g_free(antiscion_info->name);
|
|
||||||
g_free(antiscion_info);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gswe_init:
|
* gswe_init:
|
||||||
@@ -134,35 +118,50 @@ gswe_init(void)
|
|||||||
GsweSignInfo *sign_info;
|
GsweSignInfo *sign_info;
|
||||||
GsweHouseSystemInfo *house_system_info;
|
GsweHouseSystemInfo *house_system_info;
|
||||||
GsweAspectInfo *aspect_info;
|
GsweAspectInfo *aspect_info;
|
||||||
GsweAntiscionAxisInfo *antiscion_info;
|
GsweAntiscionAxisInfo *antiscion_axis_info;
|
||||||
|
|
||||||
|
if (gswe_initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gswe_initializing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gswe_initializing = TRUE;
|
||||||
|
|
||||||
|
/* Before 2.34, g_type_init() must have been called. Let's do it! */
|
||||||
|
#if !GLIB_CHECK_VERSION(2, 36, 0)
|
||||||
|
g_type_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
||||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||||
|
|
||||||
gswe_planet_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, gswe_free_planet_info);
|
gswe_planet_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_planet_info_unref);
|
||||||
|
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_SUN, SE_SUN, TRUE, _("Sun"), 13.0, 2, GSWE_SIGN_LEO, GSWE_SIGN_NONE, GSWE_SIGN_AQUARIUS, GSWE_SIGN_NONE, GSWE_SIGN_ARIES, GSWE_SIGN_LIBRA);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_SUN, SE_SUN, TRUE, _("Sun"), 13.0, 2);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON, SE_MOON, TRUE, _("Moon"), 9.0, 2, GSWE_SIGN_CANCER, GSWE_SIGN_NONE, GSWE_SIGN_CAPRICORN, GSWE_SIGN_NONE, GSWE_SIGN_TAURUS, GSWE_SIGN_SCORPIO);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON, SE_MOON, TRUE, _("Moon"), 9.0, 2);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MERCURY, SE_MERCURY, TRUE, _("Mercury"), 7.0, 2, GSWE_SIGN_GEMINI, GSWE_SIGN_VIRGO, GSWE_SIGN_SAGITTARIUS, GSWE_SIGN_PISCES, GSWE_SIGN_VIRGO, GSWE_SIGN_PISCES);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MERCURY, SE_MERCURY, TRUE, _("Mercury"), 7.0, 2);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VENUS, SE_VENUS, TRUE, _("Venus"), 7.0, 1, GSWE_SIGN_TAURUS, GSWE_SIGN_LIBRA, GSWE_SIGN_SCORPIO, GSWE_SIGN_ARIES, GSWE_SIGN_PISCES, GSWE_SIGN_VIRGO);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VENUS, SE_VENUS, TRUE, _("Venus"), 7.0, 1);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MARS, SE_MARS, TRUE, _("Mars"), 7.0, 1, GSWE_SIGN_ARIES, GSWE_SIGN_SCORPIO, GSWE_SIGN_LIBRA, GSWE_SIGN_TAURUS, GSWE_SIGN_CAPRICORN, GSWE_SIGN_CANCER);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MARS, SE_MARS, TRUE, _("Mars"), 7.0, 1);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_JUPITER, SE_JUPITER, TRUE, _("Jupiter"), 9.0, 1, GSWE_SIGN_SAGITTARIUS, GSWE_SIGN_PISCES, GSWE_SIGN_GEMINI, GSWE_SIGN_VIRGO, GSWE_SIGN_CANCER, GSWE_SIGN_CAPRICORN);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_JUPITER, SE_JUPITER, TRUE, _("Jupiter"), 9.0, 1);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_SATURN, SE_SATURN, TRUE, _("Saturn"), 7.0, 1, GSWE_SIGN_CAPRICORN, GSWE_SIGN_AQUARIUS, GSWE_SIGN_CANCER, GSWE_SIGN_LEO, GSWE_SIGN_LIBRA, GSWE_SIGN_ARIES);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_SATURN, SE_SATURN, TRUE, _("Saturn"), 7.0, 1);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_URANUS, SE_URANUS, TRUE, _("Uranus"), 5.0, 1, GSWE_SIGN_AQUARIUS, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_URANUS, SE_URANUS, TRUE, _("Uranus"), 5.0, 1);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_NEPTUNE, SE_NEPTUNE, TRUE, _("Neptune"), 5.0, 1, GSWE_SIGN_PISCES, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_NEPTUNE, SE_NEPTUNE, TRUE, _("Neptune"), 5.0, 1);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PLUTO, SE_PLUTO, TRUE, _("Pluto"), 3.0, 1, GSWE_SIGN_SCORPIO, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PLUTO, SE_PLUTO, TRUE, _("Pluto"), 3.0, 1);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CHIRON, SE_CHIRON, TRUE, _("Chiron"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CHIRON, SE_CHIRON, TRUE, _("Chiron"), 2.0, 0);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CERES, SE_CERES, TRUE, _("Ceres"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CERES, SE_CERES, TRUE, _("Ceres"), 2.0, 0);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PALLAS, SE_PALLAS, TRUE, _("Pallas"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PALLAS, SE_PALLAS, TRUE, _("Pallas"), 2.0, 0);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_JUNO, SE_JUNO, TRUE, _("Juno"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_JUNO, SE_JUNO, TRUE, _("Juno"), 2.0, 0);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VESTA, SE_VESTA, TRUE, _("Vesta"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VESTA, SE_VESTA, TRUE, _("Vesta"), 2.0, 0);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON_NODE, SE_MEAN_NODE, TRUE, _("Ascending Moon Node"), 2.0, 1, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON_NODE, SE_MEAN_NODE, TRUE, _("Ascending Moon Node"), 2.0, 1);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON_APOGEE, SE_MEAN_APOG, TRUE, _("Dark Moon"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON_APOGEE, SE_MEAN_APOG, TRUE, _("Dark Moon"), 2.0, 0);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_ASCENDENT, -1, FALSE, _("Ascendent"), 9.0, 2, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_ASCENDANT, -1, FALSE, _("Ascendant"), 9.0, 2);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MC, -1, FALSE, _("Midheaven"), 5.0, 1, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MC, -1, FALSE, _("Midheaven"), 5.0, 1);
|
||||||
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VERTEX, -1, FALSE, _("Vertex"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
|
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VERTEX, -1, FALSE, _("Vertex"), 2.0, 0);
|
||||||
|
|
||||||
gswe_sign_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, gswe_free_sign_info);
|
gswe_sign_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_sign_info_unref);
|
||||||
|
|
||||||
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_ARIES, _("Aries"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_CARDINAL);
|
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_ARIES, _("Aries"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_CARDINAL);
|
||||||
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_TAURUS, _("Taurus"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_FIX);
|
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_TAURUS, _("Taurus"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_FIX);
|
||||||
@@ -177,14 +176,14 @@ gswe_init(void)
|
|||||||
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_AQUARIUS, _("Aquarius"), GSWE_ELEMENT_AIR, GSWE_QUALITY_FIX);
|
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_AQUARIUS, _("Aquarius"), GSWE_ELEMENT_AIR, GSWE_QUALITY_FIX);
|
||||||
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_PISCES, _("Pisces"), GSWE_ELEMENT_WATER, GSWE_QUALITY_MUTABLE);
|
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_PISCES, _("Pisces"), GSWE_ELEMENT_WATER, GSWE_QUALITY_MUTABLE);
|
||||||
|
|
||||||
gswe_house_system_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, gswe_free_house_system_info);
|
gswe_house_system_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_house_system_info_unref);
|
||||||
|
|
||||||
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_NONE, 0, _("None"));
|
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_NONE, 0, _("None"));
|
||||||
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_PLACIDUS, 'P', _("Placidus"));
|
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_PLACIDUS, 'P', _("Placidus"));
|
||||||
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_KOCH, 'K', _("Koch"));
|
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_KOCH, 'K', _("Koch"));
|
||||||
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SISTEM_EQUAL, 'E', _("Equal"));
|
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_EQUAL, 'E', _("Equal"));
|
||||||
|
|
||||||
gswe_aspect_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, gswe_free_aspect_info);
|
gswe_aspect_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_aspect_info_unref);
|
||||||
|
|
||||||
// Note that because all aspects must be <= 180°, GSWE_ASPECT_NONE can
|
// Note that because all aspects must be <= 180°, GSWE_ASPECT_NONE can
|
||||||
// never really exist. It is provided for name fetching purposes only.
|
// never really exist. It is provided for name fetching purposes only.
|
||||||
@@ -201,13 +200,13 @@ gswe_init(void)
|
|||||||
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_QUINTILE, _("Quintile"), 72, 3, TRUE, FALSE);
|
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_QUINTILE, _("Quintile"), 72, 3, TRUE, FALSE);
|
||||||
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_BIQUINTILE, _("Bi-quintile"), 144, 3, TRUE, FALSE);
|
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_BIQUINTILE, _("Bi-quintile"), 144, 3, TRUE, FALSE);
|
||||||
|
|
||||||
gswe_antiscion_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_free_antiscion_info);
|
gswe_antiscion_axis_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_antiscion_axis_info_unref);
|
||||||
|
|
||||||
ADD_ANTISCION(gswe_antiscion_info_table, antiscion_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_NONE, _("None"), GSWE_SIGN_NONE, FALSE);
|
ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_NONE, _("None"), GSWE_SIGN_NONE, 0.0);
|
||||||
ADD_ANTISCION(gswe_antiscion_info_table, antiscion_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_ARIES, _("Aries/Libra"), GSWE_SIGN_ARIES, FALSE);
|
ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_ARIES, _("Aries/Libra"), GSWE_SIGN_ARIES, 0.0);
|
||||||
ADD_ANTISCION(gswe_antiscion_info_table, antiscion_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_MID_TAURUS, _("mid Taurus/Scorpio"), GSWE_SIGN_TAURUS, TRUE);
|
ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_MID_TAURUS, _("mid Taurus/Scorpio"), GSWE_SIGN_TAURUS, 15.0);
|
||||||
ADD_ANTISCION(gswe_antiscion_info_table, antiscion_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_CANCER, _("Cancer/Capricorn"), GSWE_SIGN_CANCER, FALSE);
|
ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_CANCER, _("Cancer/Capricorn"), GSWE_SIGN_CANCER, 0.0);
|
||||||
ADD_ANTISCION(gswe_antiscion_info_table, antiscion_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_MID_LEO, _("mid Leo/Aquarius"), GSWE_SIGN_LEO, TRUE);
|
ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_MID_LEO, _("mid Leo/Aquarius"), GSWE_SIGN_LEO, 15.0);
|
||||||
|
|
||||||
gswe_full_moon_base_date = gswe_timestamp_new_from_gregorian_full(2005, 5, 8, 3, 48, 0, 0, 0.0);
|
gswe_full_moon_base_date = gswe_timestamp_new_from_gregorian_full(2005, 5, 8, 3, 48, 0, 0, 0.0);
|
||||||
|
|
||||||
@@ -216,54 +215,3 @@ gswe_init(void)
|
|||||||
gswe_initialized = TRUE;
|
gswe_initialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GswePlanetInfo *
|
|
||||||
gswe_planet_info_copy(GswePlanetInfo *planet_info)
|
|
||||||
{
|
|
||||||
GswePlanetInfo *ret = g_new0(GswePlanetInfo, 1);
|
|
||||||
|
|
||||||
ret->planet = planet_info->planet;
|
|
||||||
ret->sweph_id = planet_info->sweph_id;
|
|
||||||
ret->real_body = planet_info->real_body;
|
|
||||||
ret->orb = planet_info->orb;
|
|
||||||
ret->name = g_strdup(planet_info->name);
|
|
||||||
ret->points = planet_info->points;
|
|
||||||
ret->domicile_sign_1 = planet_info->domicile_sign_1;
|
|
||||||
ret->domicile_sign_2 = planet_info->domicile_sign_2;
|
|
||||||
ret->exile_sign_1 = planet_info->exile_sign_1;
|
|
||||||
ret->exile_sign_2 = planet_info->exile_sign_2;
|
|
||||||
ret->exalted_sign = planet_info->exalted_sign;
|
|
||||||
ret->fall_sign = planet_info->fall_sign;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gswe_planet_info_free(GswePlanetInfo *planet_info)
|
|
||||||
{
|
|
||||||
g_free(planet_info->name);
|
|
||||||
g_free(planet_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE(GswePlanetInfo, gswe_planet_info, (GBoxedCopyFunc)gswe_planet_info_copy, (GBoxedFreeFunc)gswe_planet_info_free);
|
|
||||||
|
|
||||||
static GsweSignInfo *
|
|
||||||
gswe_sign_info_copy(GsweSignInfo *sign_info)
|
|
||||||
{
|
|
||||||
GsweSignInfo *ret = g_new0(GsweSignInfo, 1);
|
|
||||||
|
|
||||||
ret->sign_id = sign_info->sign_id;
|
|
||||||
ret->name = g_strdup(sign_info->name);
|
|
||||||
ret->element = sign_info->element;
|
|
||||||
ret->quality = sign_info->quality;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gswe_sign_info_free(GsweSignInfo *sign_info)
|
|
||||||
{
|
|
||||||
g_free(sign_info->name);
|
|
||||||
g_free(sign_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE(GsweSignInfo, gswe_sign_info, (GBoxedCopyFunc)gswe_sign_info_copy, (GBoxedFreeFunc)gswe_sign_info_free);
|
|
||||||
|
@@ -20,17 +20,60 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "gswe-types.h"
|
#include "gswe-types.h"
|
||||||
|
#include "gswe-moon-phase-data.h"
|
||||||
|
#include "gswe-sign-info.h"
|
||||||
|
#include "gswe-planet-info.h"
|
||||||
|
#include "gswe-planet-data.h"
|
||||||
|
#include "gswe-aspect-info.h"
|
||||||
|
#include "gswe-aspect-data.h"
|
||||||
|
#include "gswe-antiscion-axis-info.h"
|
||||||
|
#include "gswe-antiscion-data.h"
|
||||||
|
#include "gswe-house-system-info.h"
|
||||||
|
#include "gswe-house-data.h"
|
||||||
#include "gswe-timestamp.h"
|
#include "gswe-timestamp.h"
|
||||||
#include "gswe-moment.h"
|
#include "gswe-moment.h"
|
||||||
#include "gswe-enumtypes.h"
|
#include "gswe-enumtypes.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GsweError:
|
||||||
|
* @GSWE_ERROR_SUCCESS: No error
|
||||||
|
* @GSWE_ERROR_SWE_NONFATAL: Non-fatal Swiss Ephemeris library error
|
||||||
|
* @GSWE_ERROR_SWE_FATAL: Fatal Swiss Ephemeris library error
|
||||||
|
* @GSWE_ERROR_INVALID_DATE: The specified Gregorian date is invalid
|
||||||
|
* @GSWE_ERROR_INVALID_TIME: The specified time is invalid
|
||||||
|
* @GSWE_ERROR_NO_VALID_VALUE: the #GsweTimestamp object holds no valid values
|
||||||
|
* @GSWE_ERROR_UNKNOWN_HSYS: the requested house system is unknown
|
||||||
|
* @GSWE_ERROR_UNKNOWN_SIGN: an invalid zodiac sign would have been returned
|
||||||
|
* @GSWE_ERROR_UNKNOWN_PLANET: the referenced planet was not added with
|
||||||
|
* gswe_moment_add_planet()
|
||||||
|
* @GSWE_ERROR_UNKNOWN_ANTISCION_AXIS: the given axis is unknown to SWE-GLib
|
||||||
|
*
|
||||||
|
* Error codes returned by the SWE-GLib functions.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
GSWE_ERROR_SUCCESS,
|
||||||
|
GSWE_ERROR_SWE_NONFATAL,
|
||||||
|
GSWE_ERROR_SWE_FATAL,
|
||||||
|
GSWE_ERROR_INVALID_DATE,
|
||||||
|
GSWE_ERROR_INVALID_TIME,
|
||||||
|
GSWE_ERROR_NO_VALID_VALUE,
|
||||||
|
GSWE_ERROR_UNKNOWN_HSYS,
|
||||||
|
GSWE_ERROR_UNKNOWN_SIGN,
|
||||||
|
GSWE_ERROR_UNKNOWN_PLANET,
|
||||||
|
GSWE_ERROR_UNKNOWN_ANTISCION_AXIS,
|
||||||
|
} GsweError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GSWE_ERROR:
|
||||||
|
*
|
||||||
|
* Error domain for SWE-GLib in general. Since 2.0, all errors generated by
|
||||||
|
* SWE-GLib functions are from this domain. See #GError for more information on
|
||||||
|
* error domains.
|
||||||
|
*/
|
||||||
|
#define GSWE_ERROR gswe_error_quark()
|
||||||
|
GQuark gswe_error_quark(void);
|
||||||
|
|
||||||
void gswe_init();
|
void gswe_init();
|
||||||
|
|
||||||
GType gswe_planet_info_get_type(void);
|
|
||||||
#define GSWE_TYPE_PLANET_INFO (gswe_planet_info_get_type())
|
|
||||||
|
|
||||||
GType gswe_sign_info_get_type(void);
|
|
||||||
#define GSWE_TYPE_SIGN_INFO (gswe_sign_info_get_type())
|
|
||||||
|
|
||||||
#endif /* __SWE_GLIB_H__ */
|
#endif /* __SWE_GLIB_H__ */
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
This directory contains version 1.75 of the Swiss Ephemeris programming
|
This directory contains version 1.76 of the Swiss Ephemeris programming
|
||||||
library in a reduced form, so it can be used in an Autotools project like
|
library in a reduced form, so it can be used in an Autotools project like
|
||||||
Astrognome.
|
Astrognome.
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
lib_LTLIBRARIES = libswe-1.75.la
|
lib_LTLIBRARIES = libswe-1.76.la
|
||||||
libswe_1_75_la_SOURCES = swedate.c swehouse.c swejpl.c swemmoon.c swemplan.c swepcalc.c sweph.c swepdate.c swephlib.c swecl.c swehel.c
|
libswe_1_76_la_SOURCES = swedate.c swehouse.c swejpl.c swemmoon.c swemplan.c swepcalc.c sweph.c swepdate.c swephlib.c swecl.c swehel.c
|
||||||
libswe_1_75_la_CFLAGS = $(CFLAGS) -Wall
|
libswe_1_76_la_CFLAGS = $(CFLAGS) -Wall
|
||||||
libswe_1_75_la_LIBADD = $(LIBS)
|
libswe_1_76_la_LIBADD = $(LIBS)
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
LICENSE \
|
LICENSE \
|
||||||
|
192
tests/Makefile.am
Normal file
192
tests/Makefile.am
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
# glib.mk - Borrowed from GLib
|
||||||
|
# initialize variables for unconditional += appending
|
||||||
|
BUILT_SOURCES =
|
||||||
|
BUILT_EXTRA_DIST =
|
||||||
|
CLEANFILES = *.log *.trs
|
||||||
|
DISTCLEANFILES =
|
||||||
|
MAINTAINERCLEANFILES =
|
||||||
|
EXTRA_DIST =
|
||||||
|
TEST_PROGS =
|
||||||
|
|
||||||
|
noinst_LTLIBRARIES =
|
||||||
|
noinst_PROGRAMS =
|
||||||
|
noinst_SCRIPTS =
|
||||||
|
noinst_DATA =
|
||||||
|
|
||||||
|
check_LTLIBRARIES =
|
||||||
|
check_PROGRAMS =
|
||||||
|
check_SCRIPTS =
|
||||||
|
check_DATA =
|
||||||
|
|
||||||
|
TESTS =
|
||||||
|
|
||||||
|
### testing rules
|
||||||
|
|
||||||
|
# test: run all tests in cwd and subdirs
|
||||||
|
test: test-nonrecursive
|
||||||
|
if OS_UNIX
|
||||||
|
@ for subdir in $(SUBDIRS) . ; do \
|
||||||
|
test "$$subdir" = "." -o "$$subdir" = "po" || \
|
||||||
|
( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
|
||||||
|
done
|
||||||
|
|
||||||
|
# test-nonrecursive: run tests only in cwd
|
||||||
|
test-nonrecursive: ${TEST_PROGS}
|
||||||
|
@test -z "${TEST_PROGS}" || G_TEST_SRCDIR="$(abs_srcdir)" G_TEST_BUILDDIR="$(abs_builddir)" G_DEBUG=gc-friendly MALLOC_CHECK_=2 MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) ${GTESTER} --verbose ${TEST_PROGS}
|
||||||
|
else
|
||||||
|
test-nonrecursive:
|
||||||
|
endif
|
||||||
|
|
||||||
|
# test-report: run tests in subdirs and generate report
|
||||||
|
# perf-report: run tests in subdirs with -m perf and generate report
|
||||||
|
# full-report: like test-report: with -m perf and -m slow
|
||||||
|
test-report perf-report full-report: ${TEST_PROGS}
|
||||||
|
@test -z "${TEST_PROGS}" || { \
|
||||||
|
case $@ in \
|
||||||
|
test-report) test_options="-k";; \
|
||||||
|
perf-report) test_options="-k -m=perf";; \
|
||||||
|
full-report) test_options="-k -m=perf -m=slow";; \
|
||||||
|
esac ; \
|
||||||
|
if test -z "$$GTESTER_LOGDIR" ; then \
|
||||||
|
G_TEST_SRCDIR="$(abs_srcdir)" G_TEST_BUILDDIR="$(abs_builddir)" ${GTESTER} --verbose $$test_options -o test-report.xml ${TEST_PROGS} ; \
|
||||||
|
elif test -n "${TEST_PROGS}" ; then \
|
||||||
|
G_TEST_SRCDIR="$(abs_srcdir)" G_TEST_BUILDDIR="$(abs_builddir)" ${GTESTER} --verbose $$test_options -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ${TEST_PROGS} ; \
|
||||||
|
fi ; \
|
||||||
|
}
|
||||||
|
@ ignore_logdir=true ; \
|
||||||
|
if test -z "$$GTESTER_LOGDIR" ; then \
|
||||||
|
GTESTER_LOGDIR=`mktemp -d "\`pwd\`/.testlogs-XXXXXX"`; export GTESTER_LOGDIR ; \
|
||||||
|
ignore_logdir=false ; \
|
||||||
|
fi ; \
|
||||||
|
if test -d "$(top_srcdir)/.git" ; then \
|
||||||
|
REVISION=`git describe` ; \
|
||||||
|
else \
|
||||||
|
REVISION=$(VERSION) ; \
|
||||||
|
fi ; \
|
||||||
|
for subdir in $(SUBDIRS) . ; do \
|
||||||
|
test "$$subdir" = "." -o "$$subdir" = "po" || \
|
||||||
|
( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
|
||||||
|
done ; \
|
||||||
|
$$ignore_logdir || { \
|
||||||
|
echo '<?xml version="1.0"?>' > $@.xml ; \
|
||||||
|
echo '<report-collection>' >> $@.xml ; \
|
||||||
|
echo '<info>' >> $@.xml ; \
|
||||||
|
echo ' <package>$(PACKAGE)</package>' >> $@.xml ; \
|
||||||
|
echo ' <version>$(VERSION)</version>' >> $@.xml ; \
|
||||||
|
echo " <revision>$$REVISION</revision>" >> $@.xml ; \
|
||||||
|
echo '</info>' >> $@.xml ; \
|
||||||
|
for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \
|
||||||
|
sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $@.xml ; \
|
||||||
|
done ; \
|
||||||
|
echo >> $@.xml ; \
|
||||||
|
echo '</report-collection>' >> $@.xml ; \
|
||||||
|
rm -rf "$$GTESTER_LOGDIR"/ ; \
|
||||||
|
${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \
|
||||||
|
}
|
||||||
|
.PHONY: test test-report perf-report full-report test-nonrecursive
|
||||||
|
|
||||||
|
.PHONY: lcov genlcov lcov-clean
|
||||||
|
# use recursive makes in order to ignore errors during check
|
||||||
|
lcov:
|
||||||
|
-$(MAKE) $(AM_MAKEFLAGS) -k check
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS) genlcov
|
||||||
|
|
||||||
|
# we have to massage the lcov.info file slightly to hide the effect of libtool
|
||||||
|
# placing the objects files in the .libs/ directory separate from the *.c
|
||||||
|
# we also have to delete tests/.libs/libmoduletestplugin_*.gcda
|
||||||
|
genlcov:
|
||||||
|
rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda
|
||||||
|
$(LTP) --directory $(top_builddir) --capture --output-file glib-lcov.info --test-name GLIB_PERF --no-checksum --compat-libtool
|
||||||
|
LANG=C $(LTP_GENHTML) --prefix $(top_builddir) --output-directory glib-lcov --title "GLib Code Coverage" --legend --show-details glib-lcov.info
|
||||||
|
@echo "file://$(abs_top_builddir)/glib-lcov/index.html"
|
||||||
|
|
||||||
|
lcov-clean:
|
||||||
|
-$(LTP) --directory $(top_builddir) -z
|
||||||
|
-rm -rf glib-lcov.info glib-lcov
|
||||||
|
-find -name '*.gcda' -print | xargs rm
|
||||||
|
|
||||||
|
# run tests in cwd as part of make check
|
||||||
|
check-local: test-nonrecursive
|
||||||
|
|
||||||
|
# We support a fairly large range of possible variables. It is expected that all types of files in a test suite
|
||||||
|
# will belong in exactly one of the following variables.
|
||||||
|
#
|
||||||
|
# First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
|
||||||
|
#
|
||||||
|
# test_programs, test_scripts, test_data, test_ltlibraries
|
||||||
|
#
|
||||||
|
# The above are used to list files that are involved in both uninstalled and installed testing. The
|
||||||
|
# test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
|
||||||
|
# Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is
|
||||||
|
# installed in the same way as it appears in the package layout.
|
||||||
|
#
|
||||||
|
# In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
|
||||||
|
# like so:
|
||||||
|
#
|
||||||
|
# installed_test_programs, uninstalled_test_programs
|
||||||
|
# installed_test_scripts, uninstalled_test_scripts
|
||||||
|
# installed_test_data, uninstalled_test_data
|
||||||
|
# installed_test_ltlibraries, uninstalled_test_ltlibraries
|
||||||
|
#
|
||||||
|
# Additionally, we support 'extra' infixes for programs and scripts. This is used for support programs/scripts
|
||||||
|
# that should not themselves be run as testcases (but exist to be used from other testcases):
|
||||||
|
#
|
||||||
|
# test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
|
||||||
|
# test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
|
||||||
|
#
|
||||||
|
# Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data
|
||||||
|
# file automatically end up in the tarball.
|
||||||
|
#
|
||||||
|
# dist_test_scripts, dist_test_data, dist_test_extra_scripts
|
||||||
|
# dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
|
||||||
|
# dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
|
||||||
|
#
|
||||||
|
# Note that no file is automatically disted unless it appears in one of the dist_ variables. This follows the
|
||||||
|
# standard automake convention of not disting programs scripts or data by default.
|
||||||
|
#
|
||||||
|
# test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted
|
||||||
|
# variants) will be run as part of the in-tree 'make check'. These are all assumed to be runnable under
|
||||||
|
# gtester. That's a bit strange for scripts, but it's possible.
|
||||||
|
|
||||||
|
# we use test -z "$(TEST_PROGS)" above, so make sure we have no extra whitespace...
|
||||||
|
TEST_PROGS += $(strip $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
|
||||||
|
$(dist_test_scripts) $(dist_uninstalled_test_scripts))
|
||||||
|
|
||||||
|
if OS_WIN32
|
||||||
|
TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
|
||||||
|
$(dist_test_scripts) $(dist_uninstalled_test_scripts)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Note: build even the installed-only targets during 'make check' to ensure that they still work.
|
||||||
|
# We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to
|
||||||
|
# prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were
|
||||||
|
# filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'.
|
||||||
|
all_test_programs = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \
|
||||||
|
$(test_extra_programs) $(uninstalled_test_extra_programs) $(installed_test_extra_programs)
|
||||||
|
all_test_scripts = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \
|
||||||
|
$(test_extra_scripts) $(uninstalled_test_extra_scripts) $(installed_test_extra_scripts)
|
||||||
|
all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts) \
|
||||||
|
$(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts) $(dist_installed_test_extra_scripts)
|
||||||
|
all_test_scripts += $(all_dist_test_scripts)
|
||||||
|
EXTRA_DIST += $(all_dist_test_scripts)
|
||||||
|
all_test_data = $(test_data) $(uninstalled_test_data) $(installed_test_data)
|
||||||
|
all_dist_test_data = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data)
|
||||||
|
all_test_data += $(all_dist_test_data)
|
||||||
|
EXTRA_DIST += $(all_dist_test_data)
|
||||||
|
all_test_ltlibs = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries)
|
||||||
|
|
||||||
|
check_LTLIBRARIES += $(all_test_ltlibs)
|
||||||
|
check_PROGRAMS += $(all_test_programs)
|
||||||
|
check_SCRIPTS += $(all_test_scripts)
|
||||||
|
check_DATA += $(all_test_data)
|
||||||
|
|
||||||
|
# End of glib.mk
|
||||||
|
|
||||||
|
LDADD = $(top_builddir)/src/libswe-glib-2.0.la
|
||||||
|
DEFS = -DG_LOG_DOMAIN=\"SWE-GLib\"
|
||||||
|
AM_CPPFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) $(LIBSWE_CFLAGS) -I$(top_srcdir)/src
|
||||||
|
AM_CFLAGS = -g
|
||||||
|
|
||||||
|
test_programs = gswe-timestamp-test
|
||||||
|
TESTS += $(test_programs)
|
||||||
|
|
40
tests/gswe-timestamp-test.c
Normal file
40
tests/gswe-timestamp-test.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#undef G_DISABLE_ASSERT
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <swe-glib.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_timestamp_jd(void)
|
||||||
|
{
|
||||||
|
GsweTimestamp *timestamp;
|
||||||
|
gdouble jd;
|
||||||
|
|
||||||
|
timestamp = gswe_timestamp_new_from_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1);
|
||||||
|
g_assert(timestamp);
|
||||||
|
|
||||||
|
jd = gswe_timestamp_get_julian_day(timestamp, NULL);
|
||||||
|
|
||||||
|
g_object_unref(timestamp);
|
||||||
|
|
||||||
|
timestamp = gswe_timestamp_new_from_julian_day(jd);
|
||||||
|
g_assert(timestamp);
|
||||||
|
g_assert(gswe_timestamp_get_gregorian_year(timestamp, NULL) == 1983);
|
||||||
|
g_assert(gswe_timestamp_get_gregorian_month(timestamp, NULL) == 3);
|
||||||
|
g_assert(gswe_timestamp_get_gregorian_day(timestamp, NULL) == 7);
|
||||||
|
g_assert(gswe_timestamp_get_gregorian_hour(timestamp, NULL) == 11);
|
||||||
|
g_assert(gswe_timestamp_get_gregorian_minute(timestamp, NULL) == 54);
|
||||||
|
g_assert(gswe_timestamp_get_gregorian_second(timestamp, NULL) == 45);
|
||||||
|
g_assert(gswe_timestamp_get_gregorian_microsecond(timestamp, NULL) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
g_test_init(&argc, &argv, NULL);
|
||||||
|
|
||||||
|
g_test_add_func("/gswe-timestamp/jd", test_timestamp_jd);
|
||||||
|
|
||||||
|
return g_test_run();
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user