Compare commits

...

241 Commits
v1.0.1 ... main

Author SHA1 Message Date
Gergely Polonkai e03ed37133
Remove the bundled Swiss Ephemeris library 2021-04-27 08:42:06 +02:00
Gergely Polonkai aadf4a280e
Add GTK-Doc’s .actions file to .gitignore 2021-04-27 08:25:47 +02:00
Gergely Polonkai 827a8f3641
Allow using LTP 1.14 2021-04-27 08:24:45 +02:00
Gergely Polonkai 2879fa72cd
Fix location of @filename@ in gswe-enumtypes.c.template 2021-04-25 06:20:54 +02:00
Gergely Polonkai 4e53c0c771 Add opposing points: DESC, MC, ANTIVERTEX
Solves #4
2016-09-29 08:42:02 +02:00
Gergely Polonkai c0711d512d Add possibility to calculate Moon South Node position 2016-09-20 15:23:47 +02:00
Gergely Polonkai aed102ea11 Update to Swiss Ephemeris 2.04 2016-07-25 12:42:52 +02:00
Gergely Polonkai ae1ba0a5e9 Merge branch 'master' into testing 2015-11-24 12:31:34 +01:00
Gergely Polonkai b3d335259c Backport g_assert_true() and g_assert_false()
These macros were defined in 2.38, but SWE-GLib depends on
2.32. Requiring a newer version solely for this would be an overkill, so
let’s just backport them.
2015-11-24 12:27:35 +01:00
Gergely Polonkai eedcc3fb3a Create test for GsweTimestamp::instant-recalc 2015-11-24 12:14:22 +01:00
Gergely Polonkai b3345b1cd7 Fix gswe_timestamp_set_now_local()
It calculated the timezone offset wrong (for 1.0 hour it became 1000.0).
2015-11-24 12:06:30 +01:00
Gergely Polonkai 230ec75043 Add codecov support 2015-11-23 19:38:06 +01:00
Gergely Polonkai da90330152 Fix tests 2015-11-23 16:53:16 +01:00
Gergely Polonkai 92f3b7e957 Merge branch 'master' into testing
Conflicts:
	tests/Makefile.am
2015-11-23 16:51:57 +01:00
Gergely Polonkai f4b6bfe37d Add build status badge 2015-09-14 11:18:42 +02:00
Gergely Polonkai 7b3a1ddeaf Move to container based Travis 2015-09-14 11:16:25 +02:00
Gergely Polonkai e394ffa15e Upgrade to Swiss Ephemeris 2.02.01 2015-09-13 15:35:49 +02:00
Gergely Polonkai dbfb734b1f Revert "Move to container based Travis"
This reverts commit a006498281.

SWE-GLib cannot use container based tests, as the gnome-common package
is disallowed.

Issue travis-ci/apt-package-whitelist#1103 has been opened to resolve
this dependency.
2015-09-03 08:42:11 +00:00
Gergely Polonkai a006498281 Move to container based Travis 2015-09-03 08:31:43 +00:00
Gergely Polonkai 258dcc8356 Fix .travis.yml 2015-09-03 07:39:33 +00:00
Gergely Polonkai 9da6941f0a Fix tests Makefile.am
It couldn’t run tests due to missing CFLAGS and LDADD parameters.
2015-09-03 07:27:20 +00:00
Gergely Polonkai d87f5e98f7 Restructure README file 2015-09-02 14:27:04 +00:00
Gergely Polonkai e854485da3 Merge branch 'master' into testing 2015-01-12 10:17:35 +01:00
Gergely Polonkai 5dc7240420 Add leap second for 2015 2015-01-12 09:57:55 +01:00
Gergely Polonkai 93d0fd68aa Backport g_assert_null() and g_assert_nonnull()
These were added in newer GLibbversions, but upgrading requirements
just because of these would be an overkill.
2014-11-18 08:04:35 +01:00
Gergely Polonkai 064d39b970 Begin refactoring GsweTimestamp tests 2014-11-18 00:43:29 +01:00
Gergely Polonkai 0886396879 Move gswe_timestamp_new_from_julian_day() to g_object_new() call 2014-11-18 00:42:17 +01:00
Gergely Polonkai 27338c465f Update Travis CI config 2014-11-17 17:21:45 +01:00
Gergely Polonkai 1c14b451fd Remove GLib-specific names from configure.ac
Code coverage reports were migrated from GLib sources, and some names remained
2014-11-17 13:33:23 +01:00
Gergely Polonkai 6187d45177 Make TimestampValidity public with name GsweTimestampValidityFlags 2014-11-17 13:32:54 +01:00
Gergely Polonkai b4612e1e89 Update .gitignore with more testing related files 2014-11-17 13:22:23 +01:00
Gergely Polonkai a8844a3ed8 Merge branch 'master' into testing 2014-11-17 13:20:47 +01:00
Gergely Polonkai 2a615e44c8 Remove unnecessary notifications upon GsweTimestamp creation 2014-11-17 13:17:07 +01:00
Gergely Polonkai e850018d62 Add GsweTimestamp::julian-day property
It was somehow missing from the property list
2014-11-17 11:27:26 +01:00
Gergely Polonkai 34ded1881f Fix instant-recalc property change handling
Despite the actual value, only the gswe_timestamp_calculate_all() was called.
2014-11-14 17:57:10 +01:00
Gergely Polonkai 02703b7045 Add code coverage support 2014-11-13 17:30:16 +01:00
Gergely Polonkai efa7b7fab3 Remove double free for some GsweMoment internal lists 2014-11-13 01:13:39 +01:00
Gergely Polonkai bf5a839511 Add more guards to aspect calculations
gswe_aspect_data_calculate() may get called if the currently set
planet is NULL
2014-11-13 01:13:11 +01:00
Gergely Polonkai 4d5866b405 Add missing g_free in gswe_antiscion_data_free() 2014-11-13 01:12:24 +01:00
Gergely Polonkai 714f3dbcb0 Add LUA example 2014-11-04 16:35:16 +01:00
Gergely Polonkai 68351b2177 Unify output of example scripts 2014-11-04 16:35:16 +01:00
Gergely Polonkai 9b47d216e3 Unify coordinates in example scripts 2014-11-04 16:35:16 +01:00
Gergely Polonkai 121357e863 Remove unnecessary Data::Dumper use from Perl example 2014-11-04 16:35:16 +01:00
gitolite tester fc1a6328f1 Add full UTF-8 support to Perl example 2014-11-01 01:31:25 +01:00
gitolite tester 5b7124aca5 Protect Gswe*Data from NULL pointers 2014-11-01 01:24:06 +01:00
Gergely Polonkai c461b743e4 Create GSettings schema with the available enum types 2014-10-31 23:19:26 +01:00
gitolite tester c03f1eac6a Code beautification 2014-10-31 19:12:35 +01:00
Gergely Polonkai 820a41cb8f Protect gswe_house_data_unref() from NULL pointers 2014-10-31 18:47:43 +01:00
Gergely Polonkai 185c235b6b Remove unnecessary g_object_unref() in gswe_moment_dispose() 2014-10-31 18:43:53 +01:00
Gergely Polonkai bf4fad5388 Add signal GsweMoment::planet-added 2014-10-07 23:25:24 +02:00
Gergely Polonkai 2dd4ea1ca7 Add a variable to save the handler of the timestamp changed signal 2014-10-07 23:24:11 +02:00
Gergely Polonkai 46b6b86f88 Fix type during signal registering 2014-10-07 23:23:32 +02:00
Gergely Polonkai 0b190d47d0 Add GObject notifications to GsweMoment 2014-10-02 01:25:37 +02:00
Gergely Polonkai 385458d655 Make GsweTimestamp emit the changed signal only if something really changed 2014-10-02 00:13:31 +02:00
Gergely Polonkai 5b61a42976 Change warning messages so the user may know if it is fatal 2014-09-24 18:54:43 +02:00
Gergely Polonkai 9991269c8e Remove SEGFAULT possibility from gswe_moment_calculate_planet() 2014-09-24 18:52:46 +02:00
Gergely Polonkai b34fc1c8a0 Fix condition for checking double pointer 2014-09-24 11:34:27 +02:00
Gergely Polonkai 510e440ef4 Add gswe_all_(planets|aspects|antiscion_axes) functions 2014-09-22 00:20:05 +02:00
Gergely Polonkai 188a12d1ee Fix untested bugs
Data file path and enum generation failed after last commit
2014-09-02 16:10:18 +02:00
Gergely Polonkai a3a1dd0bd4 Add data files for asteroids 2014-09-02 15:28:53 +02:00
Gergely Polonkai f21ce84b17 Merge pull request #16 from gergelypolonkai/bug-15
Add error reporting to add_points()
2014-09-02 12:47:30 +02:00
Gergely Polonkai 06fce9c9d5 Add error reporting to add_points()
It is possible that planet_data->sign_info is NULL, which results in
a SEGFAULT.
2014-09-02 11:56:10 +02:00
Gergely Polonkai 366155b835 Apply Law of Demeter to add_points() 2014-09-02 11:51:03 +02:00
Gergely Polonkai b981ed1b3b Add gswe_timestamp_new_now_local() and gswe_timestamp_set_now_local()
Fixes #14
2014-08-14 14:59:07 +02:00
Gergely Polonkai 68994b8cb5 Code beautification in GsweTimestamp header 2014-08-14 12:15:27 +02:00
Gergely Polonkai c9e382d04b Remove ./configure from travis.yml
configure is invoket by autogen.sh already, due to jhbuild compatibility
2014-08-13 18:29:02 +02:00
Gergely Polonkai fbc5a4e922 Revert "Remove make check from Travis config"
This reverts commit cb9cf3a4ce.
The make check problem has been fixed since then
2014-08-13 01:06:46 +02:00
Gergely Polonkai b77aae9f5c Fix GsweTimestamp tests 2014-08-13 00:56:48 +02:00
Gergely Polonkai e16c4eca70 Code beautification 2014-08-13 00:55:31 +02:00
Gergely Polonkai c10881fff1 Sending "notify" signals upon property change 2014-08-13 00:55:22 +02:00
Gergely Polonkai aae1f06ed7 Setting Gregorian timezone now invalidates Gregorian date
* It calculates Julian Day beforehands, so a valid date remains in
  timestamp
* gswe_timestamp_set_gregorian_timezone() doesn’t emit the "changed"
  signal any more
2014-08-13 00:54:15 +02:00
Gergely Polonkai 8bf5a49c4b Store property GParamSpecs in an array for notify emission 2014-08-13 00:51:26 +02:00
Gergely Polonkai 68b46d2aee Add configure invocation to autogen.sh
Without this, jhbuild fails to install SWE-GLib
2014-08-01 21:28:40 +02:00
Gergely Polonkai e621a2eda2 Add element-type to gswe_all_house_systems documentation 2014-07-16 22:55:14 +02:00
Gergely Polonkai 600712c901 Add gswe_all_house_systems() function
This is required for Astrognome to configure house systems in the charts.
See gergelypolonkai/astrognome#36
2014-07-16 22:47:59 +02:00
Gergely Polonkai dca2071c88 Move GsweError and GSWE_ERROR documentation to .c file
This is to hide documentation details from installed .h files
2014-07-16 22:38:47 +02:00
Gergely Polonkai cb9cf3a4ce Remove make check from Travis config
The checks are not working yet, thus Travis is continuously fails.
2014-07-08 13:24:59 +02:00
Gergely Polonkai 1225c5c8ed Fix comment in gswe_init_with_dir() 2014-07-08 13:24:07 +02:00
Gergely Polonkai 0caebd4f94 Revert "Remove gswe_init() call from GsweTimestamp initializers"
This reverts commit 078ff3370d.

It turns out that we actually need to call gswe_init() (or at least
g_type_init()) for GObjects to work.
2014-07-08 13:16:59 +02:00
Gergely Polonkai 80b5da88a3 Version bump to 2.1.0 2014-07-08 11:25:55 +02:00
Gergely Polonkai d5bea25e4d Add version information to some new functions 2014-07-08 11:02:25 +02:00
Gergely Polonkai 95e89a4c25 Code beautification 2014-07-08 10:43:54 +02:00
Gergely Polonkai cb1fa1f67a Move gswe-version.h generating to the right place 2014-07-06 10:23:59 +02:00
Gergely Polonkai 078ff3370d Remove gswe_init() call from GsweTimestamp initializers
That call is unnecessary for time related functions.
2014-07-06 00:48:20 +02:00
Gergely Polonkai 66c8c3371c Code beautifying in gswe-timestamp.c
Wrap really long lines
2014-07-06 00:47:37 +02:00
Gergely Polonkai d2638adf8a Fix time zone value to be a float in GsweTimestamp test case 2014-07-06 00:46:34 +02:00
Gergely Polonkai 4b61c453fd Add time zone check to GsweTimestamp test case 2014-07-06 00:45:47 +02:00
Gergely Polonkai 105cf7c83b Fix GsweTimestamp test not to use deprecated functions 2014-07-06 00:45:22 +02:00
Gergely Polonkai 8adfd0b966 Fix error that makes class init fail on machines with UTC as time zone
For a more universal solution, the default values for a GsweTimestamp
are set according to the current UTC time, with time zone also set
to UTC.
2014-07-06 00:44:43 +02:00
Gergely Polonkai 8dd6eedb88 Remove debugging line in gswe_init_with_dir() 2014-07-05 23:14:08 +02:00
Gergely Polonkai 89baa44005 Add documentation for GSWE_PLANET_LILITH 2014-07-05 23:04:43 +02:00
Gergely Polonkai a50a967ad3 Add gswe_find_*_info() functions to find registered Gswe*Info objects 2014-07-05 22:58:54 +02:00
Gergely Polonkai 75a9318629 Add version information related functions 2014-07-05 22:57:34 +02:00
Gergely Polonkai 8a5d700d93 Fix swe/src/Makefile.am after moving away seleapsec.txt from that directory
$ make dist failed after doing so
2014-06-24 09:52:11 +02:00
Gergely Polonkai 95face8294 Add function gswe_timestamp_get_sidereal_time() 2014-06-11 15:59:55 +02:00
Gergely Polonkai fbf341dcec Fix GTK-Doc warnings about deprecated symbols 2014-06-11 15:41:32 +02:00
Gergely Polonkai 784987a2b6 Remove deprecated function calls from own code 2014-06-11 15:41:32 +02:00
Gergely Polonkai 07a351c373 Add Universal Time calculation functions
This is required for sidereal time calculations later. get/set Julian
day functions have been renamed to have an _et suffix. Meanwhile, the
old gswe_timestamp_get_julian_day() and gswe_timestamp_set_julian_day()
functions have been deprecated.
2014-06-11 15:41:32 +02:00
Gergely Polonkai 55621bc25d Add asteroid Hygiea 2014-05-29 08:14:00 +02:00
Gergely Polonkai a120b22861 Add GSWE_PLANET_LILITH and offsets to the documentation sections 2014-05-29 08:11:30 +02:00
Gergely Polonkai c9a0944504 Comment block fixup for GswePlanet
Add Orcus and Asbolus
Reorder comments so it lines up with the actual values
2014-05-29 08:07:45 +02:00
Gergely Polonkai 9d7eedb371 Add seleapsec.txt to installed file in RPM .spec 2014-05-28 16:55:12 +02:00
Gergely Polonkai cd36bafe9c Remove two unreliable lines from the test code
A fix must be introduced later, though!
2014-05-28 16:41:01 +02:00
Gergely Polonkai d3e4443922 Add GswePlanet planet offsets for later use 2014-05-28 16:39:43 +02:00
Gergely Polonkai 6a69271007 Add asteroids Orcus and Asbolus 2014-05-28 16:39:43 +02:00
Gergely Polonkai b6071a4e46 Reordered planets in GswePlanet
This is to bring some consistency in the API
2014-05-28 16:39:43 +02:00
Gergely Polonkai 21298fb219 Add alias to GSWE_PLANET_MOON_APOGEE as GSWE_PLANET_LILITH 2014-05-24 09:57:51 +02:00
Gergely Polonkai 243eac9de8 Add asteroid Circe as GSWE_PLANET_CIRCE 2014-05-23 21:42:49 +02:00
Gergely Polonkai 97dceeb45c Add seasnam.txt and seorbel.txt datafiles 2014-05-21 18:42:03 +02:00
Gergely Polonkai 45833584b7 Update Swiss Ephemeris to 2.0 2014-05-21 17:28:41 +02:00
Gergely Polonkai 26dcd74338 Add seleapsec.txt to installed data file list 2014-05-19 10:11:03 +02:00
Gergely Polonkai 3296f9dfce Add leap seconds to seleapsec.txt 2014-05-19 10:09:34 +02:00
Gergely Polonkai eec99bcb05 Update Swiss Ephemeris data files 2014-05-19 09:44:15 +02:00
Gergely Polonkai de5ac1b63b Add dwarf planet Dejanira 2014-05-18 20:38:29 +02:00
Gergely Polonkai 97df73c64f Add dwarf planets Sedna and Eris 2014-05-18 17:19:25 +02:00
Gergely Polonkai 2d75226310 Reindent some planet table creating lines 2014-05-18 17:19:04 +02:00
Gergely Polonkai ae3393133a Fix RPM .spec to install vala .vapi file 2014-05-08 21:58:51 +02:00
Gergely Polonkai 903beaf2c2 Jump to version 2.0.3 2014-05-07 10:00:23 +02:00
Gergely Polonkai e3a6e25bda Add gswe_moment_get_antiscion_by_planets() function 2014-05-07 10:00:23 +02:00
Gergely Polonkai 6566e5356a Add gswe_moment_get_aspect_by_planets() function 2014-05-07 10:00:23 +02:00
Gergely Polonkai cef7815268 Jump to version 2.0.2 2014-05-07 08:37:21 +02:00
Gergely Polonkai 12c08c865d Add Vala API generating code to build tools configuration 2014-05-07 08:36:24 +02:00
Gergely Polonkai 2116c8103a Add NULL protection to gswe_moment_get_planet()'s find part 2014-04-05 22:38:43 +02:00
Gergely Polonkai 8cd8cd67e2 Add NULL protection to GswePlanetData functions 2014-04-05 22:34:06 +02:00
Gergely Polonkai f2bc764f87 Add new asteroids to the planet list
* Pholus
* Nessus
* Chariklo

Fix #10
2014-04-01 22:23:53 +02:00
Gergely Polonkai b394e31f0a Add function gswe_init_with_dir()
This is to be able to specify the SWE data files' path
2014-04-01 08:15:10 +02:00
Gergely Polonkai cbf2201249 Free all objects in gswe_moment_finalize() 2014-03-29 14:55:29 +01:00
Gergely Polonkai 0326770d73 Remove unneeded gswe_planet_data_ref() call 2014-03-29 14:44:17 +01:00
Gergely Polonkai a320abc71e Remove unnecessary gswe_*_ref() calls
This is to revert part of 41a80ca365,
which was kind of an overhead.
2014-03-19 20:32:46 +01:00
Gergely Polonkai 0fb888a940 Make gswe_planet_info_free() free its name only if it is set 2014-03-16 09:52:18 +01:00
Gergely Polonkai b689d3153d Add comment to find_aspect() 2014-03-16 09:46:09 +01:00
Gergely Polonkai ddf4732dc9 Add comment to find_antiscion() 2014-03-16 09:35:25 +01:00
Gergely Polonkai fd24246bae Reduce local variable count in planet_add() 2014-03-16 09:20:10 +01:00
Gergely Polonkai 2bdd8c3c60 Removed unprecise test line 2014-03-16 09:05:43 +01:00
Gergely Polonkai 6009ee908e Extend example programs 2014-03-15 20:28:44 +01:00
Gergely Polonkai 2fa75d0906 Remove LUA example
LUA-LGI seems to be buggy with GLists (or I a too lame), thus the
example code cannot be reproduced in LUA yet.
2014-03-15 20:27:05 +01:00
Gergely Polonkai 41a80ca365 Make gswe_antiscion_axis_info_free() to unref its start_sign
This is to fix a bug that makes the library crash when the timestamp
or the chart changes.
2014-03-15 18:38:27 +01:00
Gergely Polonkai e23c789ff0 Change GList->next calls to g_list_next(GList) 2014-03-15 11:40:52 +01:00
Gergely Polonkai 2a48f402b8 Fix a typo 2014-03-09 22:34:54 +01:00
Gergely Polonkai 332110f449 Make python example a bit more featureful
Other languages will follow soon
2013-10-09 00:06:51 +02:00
Gergely Polonkai e8819f9a47 Create glforeach convenience macro 2013-10-09 00:06:08 +02:00
Gergely Polonkai 551ea4cee0 Add missing documentation
gswe_antiscion_data_new_with_planets() and gswe_antiscion_data_calculate()
were not documented, nor exposed to the public API as they should be.
2013-10-09 00:05:38 +02:00
Gergely Polonkai fa1b4574e4 Add package version requirement
GLib 2.32.0 is now required. Every recent distribution ships with at least
2.32.0 now.
2013-10-05 03:05:22 +02:00
Gergely Polonkai bd8c1532e7 Protect gswe_init() from re-entry
As gswe_init() calls functions that call gswe_init(), gswe_init() must
be protected against such re-entry.
2013-10-05 03:04:03 +02:00
Gergely Polonkai 367b777a2d Initialize SWE-GLib from each class init function
This is to satisfy #8. Also, this makes SWE-GLib available for GLib
before 2.36, as gswe_init() also calls g_type_init(), which was necessary
before GLib 2.36
2013-10-05 02:18:30 +02:00
Gergely Polonkai 695f5b96ae Initialize GLib type system when necessary
With 2.36 it became deprecated, as the type system is initialized
automatically. Before that version, just call g_type_init()
from gswe_init()
2013-10-05 02:11:12 +02:00
Gergely Polonkai dd803b09f2 Create own autogen.sh
gnome-autogen.sh can not really make GTK-Doc optional. With this script,
GTK-Doc is only used if it is actually present on the system.
2013-10-05 02:05:17 +02:00
Gergely Polonkai 74cc121221 Fix script in Travis CI configuration
The default C script uses make test, but we have make check instead
2013-10-05 01:24:52 +02:00
Gergely Polonkai c4c9e2eced Make docs/reference/swe-glib SUBDIR part optional
Depending on GTK-Doc availability
2013-10-05 01:16:28 +02:00
Gergely Polonkai 5f8939d730 Make gswe_error_quark() available to glib < 2.34 2013-10-05 01:12:09 +02:00
Gergely Polonkai 7463b0e5cd Patch autogen.sh to make GTK-Doc really optional
• gnome-autogen.sh does’t recognize the need for GTK-Doc if GTK_DOC_CHECK
  is not present at the beginning of a line of configure.ac (which is
  the case here)

• autogen.sh now takes care of running gtkdocize, thus copying over
  gtk-doc.make. If GTK-Doc is not present, a fake gtk-doc.make is
  generated, so automake doesn’t complain anymore
2013-10-05 00:57:38 +02:00
Gergely Polonkai e0893de2d2 Make GTK-Doc Makefile creation conditional
If GTK-Doc is not present, they cannot be generated at all…
2013-10-05 00:00:48 +02:00
Gergely Polonkai 371c123f17 Add gnome-common to Travis CI configuration
With removing GTK-Doc as a dependency, it is not installed any more –
however, it is badly needed by autogen.sh
2013-10-04 23:53:26 +02:00
Gergely Polonkai 95f085ea0a Make GTK-Doc optional
If it is not installed on the system, that should not be a problem anymore
2013-10-04 23:46:00 +02:00
Gergely Polonkai 35a8101c91 Update Travis CI configuration
Disabling GTK-Doc call, as Travis Linux doesn't include GTK-Doc 1.19 yet
2013-10-04 23:43:20 +02:00
Gergely Polonkai 70c240b0b3 Updat .gitignore with testing related files 2013-10-04 23:39:31 +02:00
Gergely Polonkai c2a0b6bada Add test case for GsweTimestamp
This can be run with make check. Other tests are to follow
2013-10-04 23:37:36 +02:00
Gergely Polonkai cdcf6d1bf5 Added gobject-introspection to Travis CI build deps 2013-10-04 17:28:17 +02:00
Gergely Polonkai f41306a7ab Updated Travis CI config 2013-10-04 17:22:03 +02:00
Gergely Polonkai 8bcb9a8389 Updated Travis CI config 2013-10-04 17:07:54 +02:00
Gergely Polonkai 7704879c04 Created Travis CI configuration 2013-10-04 17:03:06 +02:00
Gergely Polonkai e81df2e4b0 Moved antiscion calculation code to GsweAntiscionData 2013-10-04 17:01:15 +02:00
Gergely Polonkai 8ae0c4de71 Removed unnecessary variable from gswe_aspect_data_calculate() 2013-10-04 17:00:52 +02:00
Gergely Polonkai acedf464f4 Documentation fix on GsweAntiscionAxisInfo 2013-10-04 01:46:53 +02:00
Gergely Polonkai f3c72120a7 Documentation fix for GsweMoonPhaseData 2013-10-04 01:46:53 +02:00
Gergely Polonkai d261e5ab4f Added warning if the planet position can not be calculated due to missing planet info 2013-10-04 01:46:53 +02:00
Gergely Polonkai c5a82b2aae Added missing parameter for Moon phase calculation call 2013-10-04 01:46:53 +02:00
Gergely Polonkai 5dcd5cdd17 Outsourced Moon phase calculation to GsweMoonPhaseData 2013-10-04 01:18:34 +02:00
Gergely Polonkai 20a350eacc Small performance fixes
Removed some unnecessary checks
2013-10-04 01:00:26 +02:00
Gergely Polonkai bd54b5d37a Fixed GsweAntiscionAxisInfo API to comply with GsweAspectInfo API 2013-10-04 00:33:28 +02:00
Gergely Polonkai a224f5ab99 Bug fix in gswe_moment_calculate_antiscia()
antiscion_data->antiscion_axis_info can be NULL, but at that point
antiscion_data->antiscion_axis_info->axes can't be GSWE_ANTISCION_AXIS_NONE
2013-10-04 00:20:32 +02:00
Gergely Polonkai 54698df423 Removed unnecessary const prefix from GsweMoment methods returning boxed types 2013-10-04 00:19:11 +02:00
Gergely Polonkai c78108ce84 Fixed Makefile to install all header files as required 2013-10-04 00:17:32 +02:00
Gergely Polonkai 4506e31946 Fixed name of Ascendant
it was typed consequently as “ascendent”
2013-10-03 23:09:55 +02:00
Gergely Polonkai 981c91d702 Fixed gswe_moment_calculate_planet() so it now understands Asc, MC and Vertex 2013-10-01 01:48:43 +02:00
Gergely Polonkai 2ec9bacf91 Fixed up things so RPM for 2.0.0 can be built 2013-10-01 01:06:45 +02:00
Gergely Polonkai aa9e6db10c Fixed error in RPM spec.in file
were using Makefile variables instead of .in substitutes
2013-10-01 01:06:25 +02:00
Gergely Polonkai d96671508b Updated example scripts to work with 2.0.0 2013-10-01 01:04:45 +02:00
Gergely Polonkai 0b15005e3a Made GsweHouseData a refcounted boxed type
This is to satisfy #7
2013-09-30 23:11:52 +02:00
Gergely Polonkai 6d88993fa3 Made GsweAntiscionData a refcounted boxed type
This is to satisfy #7
2013-09-30 23:02:18 +02:00
Gergely Polonkai dc8146925d Made GsweHouseSystemInfo a refcounted boxed type
This is to satisfy #7
2013-09-30 22:53:44 +02:00
Gergely Polonkai f92caa4e1a Made GsweMoonPhaseData a refcounted boxed type
This is to satisfy #7
2013-09-30 22:39:46 +02:00
Gergely Polonkai 3a06d4bcee Fixed gswe_sign_info_table creation
This is a fixup for commit a1f8d1f7da
2013-09-30 22:25:20 +02:00
Gergely Polonkai bc9ff2fc09 Fixed gswe_planet_info_table creation
This is a fixup for commit dcd58b5dd1
2013-09-30 22:25:19 +02:00
Gergely Polonkai 27ee3747ad Fixed gswe_antiscion_axis_info_table creation
This is a fixup for commit 84195964ab
2013-09-30 22:15:40 +02:00
Gergely Polonkai 6b712794c0 Made GswePlanetData a refcounted boxed type
This is to satisfy #7
2013-09-30 22:13:37 +02:00
Gergely Polonkai dbee248a6e Made GsweAspectData a refcounted boxed type
This is to satisfy #7, but it also satisfies #8, as gswe_init() is
called where data initialized there is necessary.
2013-09-30 21:42:19 +02:00
Gergely Polonkai 7564183aa2 Made GsweAspectInfo a refcounted boxed type
This is to satisfy #7
2013-09-30 21:31:21 +02:00
Gergely Polonkai dcd58b5dd1 Changed GswePlanetInfo to a refcounted boxed type 2013-09-27 18:33:52 +02:00
Gergely Polonkai c5d8ee49eb Updated README.md with examples link 2013-09-27 04:05:50 +02:00
Gergely Polonkai 2dbbd428c1 Dirname typo... 2013-09-27 04:04:10 +02:00
Gergely Polonkai 8cdcda19f8 Changed README to reflect 2.0 transition, and the lack of need of initialization 2013-09-27 03:58:19 +02:00
Gergely Polonkai 6d84d650b5 Now calling gswe_init() in GsweMoment constructors
This is to satisfy #8, although it's not fully implemented yet.
2013-09-27 03:49:51 +02:00
Gergely Polonkai 84195964ab Made GsweAntiscionAxisInfo a refcounted boxed type 2013-09-27 03:09:29 +02:00
Gergely Polonkai b73ac78f17 Moved all GError domains into one global GSWE_ERROR domain 2013-09-27 02:39:24 +02:00
Gergely Polonkai 16003cebe9 Added code samples to use with GObject Introspection
* JavaScript
* Python
* LUA
* Perl
2013-09-27 02:39:24 +02:00
Gergely Polonkai 8f52abadf0 Typo fix in house system name, in gswe-types.h 2013-09-27 02:39:24 +02:00
Gergely Polonkai a1f8d1f7da Made GsweSignInfo a refcounted boxed type 2013-09-27 02:39:24 +02:00
Gergely Polonkai 347dae00d3 Went to major version 2.0
There are too many API (and ABI) changes there, so let's just switch to 2.0
2013-09-26 22:30:31 +02:00
Gergely Polonkai 5365133de2 Fixed Swiss Ephemeris version number
It's actually 1.76, although the sources suggest it's 1.75
2013-09-26 22:29:19 +02:00
Gergely Polonkai 60b51c2ed2 Fixed plural in GsweAspectInfo description 2013-09-24 01:24:18 +02:00
Gergely Polonkai 9ee5569bb1 Moved GsweHouseData to its own sources 2013-09-24 01:24:00 +02:00
Gergely Polonkai 20c3aafe85 Moved GsweHouseSystemInfo to its own sources 2013-09-24 01:16:33 +02:00
Gergely Polonkai 39ddb2ee0e Moved GsweSignInfo to its own sources 2013-09-24 00:42:42 +02:00
Gergely Polonkai ebeaf1eb4d Moved GswePlanetInfo to its own sources 2013-09-24 00:00:58 +02:00
Gergely Polonkai 886ff03353 Fixed documentation link in gswe-antiscion-data.c 2013-09-23 23:37:57 +02:00
Gergely Polonkai 1b0f831333 Added section information to GsweAspectInfo 2013-09-23 23:13:08 +02:00
Gergely Polonkai e06c73c23d Moved GsweAntiscionAxisInfo to its own source files 2013-09-23 23:12:50 +02:00
Gergely Polonkai 6ee6650d84 Moved GsweAntiscionData to its own source files 2013-09-23 22:27:18 +02:00
Gergely Polonkai eb5b3fff5d Fixed GsweAspectData's short description 2013-09-23 22:14:40 +02:00
Gergely Polonkai d4015cae75 Moved GsweAspectData to its own source files 2013-09-23 21:36:26 +02:00
Gergely Polonkai 3fd8c200e0 Moved GswePlanetData to its own source files 2013-09-23 21:18:41 +02:00
Gergely Polonkai 9a788f8164 Fixed MoonPhaseData related errors
• Added missing include in swe-glib.h
• Fixed @include in GsweMoonPhaseData section documentation
2013-09-23 20:16:28 +02:00
Gergely Polonkai 8044519535 Removed unneeded includes from gswe-moment.c 2013-09-23 20:14:30 +02:00
Gergely Polonkai 0e17962278 Moved GsweAspectData to its own source files 2013-09-23 20:13:56 +02:00
Gergely Polonkai 14bef9eb06 Merge branch 'docs-bug-fix' 2013-09-23 00:40:27 +02:00
Gergely Polonkai 4767e7eb98 Outsourced GsweMoonPhaseData to its own sources 2013-09-23 00:40:11 +02:00
Gergely Polonkai 54cbcd9bc9 Added version.xml.in to EXTRA_DIST in docs/references/swe-glib 2013-09-23 00:33:54 +02:00
Gergely Polonkai 444c545776 Fixed removed documentation for GsweMoonPhaseData 2013-09-23 00:33:02 +02:00
Gergely Polonkai c395c7f7ea Added version.xml.in to EXTRA_DIST in docs/references/swe-glib 2013-09-23 00:08:10 +02:00
Gergely Polonkai 197f6922c7 Outsourced GsweMoonPhaseData to its own sources
This messed up documentation, still checking why
2013-09-23 00:03:10 +02:00
Gergely Polonkai 6e96142160 Made swe-glib-sections.txt versioned. 2013-09-23 00:01:21 +02:00
Gergely Polonkai e7bd73fdc1 Renamed gswe_headers to gswe_enum_headers for better understanding 2013-09-22 23:48:35 +02:00
Gergely Polonkai a5a29c7c33 Added GSWE_MOON_PHASE_NONE as a new Moon phase
!!!ABI BREAKAGE!!!
2013-09-22 23:46:54 +02:00
Gergely Polonkai fc6f7ea159 Fixet protector definition in gswe-types.h 2013-09-22 23:18:33 +02:00
Gergely Polonkai 835dfddccd Added comment block at the beginning of gswe-types.c 2013-09-22 23:03:30 +02:00
Gergely Polonkai 20aacb8c6d Typo fix - = instead of == 2013-09-22 22:58:18 +02:00
Gergely Polonkai a918338bdf Added some comments, mostly TODO items 2013-09-22 18:59:19 +02:00
Gergely Polonkai 67979d9890 Made HOUSE_SYSTEM_NONE a valid and working house system
Solves #1
2013-09-22 18:59:01 +02:00
Gergely Polonkai 4f61aea449 Now using enum values instead of numbers in gswe_calculate_data_by_position()
It's just more beautiful.
2013-09-22 18:56:55 +02:00
Gergely Polonkai cac67e57e3 Fixed licensing issue
Fixes #2
2013-09-22 18:22:13 +02:00
Gergely Polonkai ac012aada2 Bug fix in find_antiscion()
Was assuming that first parameter is a pointer to an enum. It is
actually an int converted to a pointer with GINT_TO_POINTER.
2013-09-18 22:15:53 +02:00
Gergely Polonkai 5b0a2b33c1 Bug fix - house, aspect and antiscia lists were not freed correctly
After calling g_list_free_full(), the list must be set to NULL.
2013-09-18 21:55:49 +02:00
Gergely Polonkai 984ed5d527 Setting the time zone value now doesn't validate the Gregorian date 2013-09-18 21:54:52 +02:00
Gergely Polonkai a790512f13 Fixed GsweTimestamp to comply with documentation
Although documentation states that an "empty" timestamp object has
the current date and time in the current time zone, it was not true.
2013-09-18 21:54:17 +02:00
Gergely Polonkai a7dc5cb8c0 Fixed data/Makefile.am 2013-09-18 11:59:00 +02:00
Gergely Polonkai 8d3e16465d Incremented patch version 2013-09-18 11:55:40 +02:00
Gergely Polonkai b7f7f0c02a Bug fix: gswe_moment_get_all_planets() didn't calculate planet positions before returning the list 2013-09-18 11:55:26 +02:00
Gergely Polonkai 7b28bb519c RPM spec file is now generated
Version number no longer needs to be updated
2013-09-18 11:54:05 +02:00
Gergely Polonkai f814f26ef4 Fixed RPM version in .spec file 2013-09-17 09:53:19 +02:00
Gergely Polonkai 46a59fedf6 Fixed zodiac calculation in GsweMoment
Yielded GSWE_SIGN_NONE instead of GSWE_SIGN_ARIES at position 0.0
2013-09-17 09:43:10 +02:00
156 changed files with 8699 additions and 50389 deletions

24
.gitignore vendored
View File

@ -14,6 +14,7 @@
/.dirstamp
*.gir
*.typelib
*.gschema.valid
ChangeLog
# Files created by the build tools
@ -51,6 +52,17 @@ Makefile.in
/compile
/so_locations
# Testing related files
/test-driver
/tests/*-test
/tests/*-test.log
/tests/*-test.trs
/swe-glib-lcov*
test-suite.log
*.gcno
*.gcda
*.gcov
# Translation related files
/ABOUT-NLS
/po/POTFILES
@ -76,12 +88,17 @@ Makefile.in
/intltool-update.in
# SWE-GLib related files
src/gswe-enumtypes.c
src/gswe-enumtypes.h
src/gswetest
/src/gswe-enumtypes.c
/src/gswe-enumtypes.h
/src/gswetest
/data/swe-glib.pc
/data/swe-glib.spec
/src/*.vapi
/src/gswe-version.h
/data/*.gschema.xml
# Documentation related files
/docs/reference/*/*.actions
/docs/reference/*/*.args
/docs/reference/*/*.hierarchy
/docs/reference/*/*.interfaces
@ -94,7 +111,6 @@ src/gswetest
/docs/reference/*/*-overrides.txt
/docs/reference/*/*-undeclared.txt
/docs/reference/*/version.xml
/docs/reference/*/*-sections.txt
/docs/reference/*/*-undocumented.txt
/docs/reference/*/*-unused.txt
/docs/reference/*/xml/

17
.travis.yml Normal file
View File

@ -0,0 +1,17 @@
sudo: false
language: c
addons:
apt:
packages:
- libglib2.0-dev
- gobject-introspection
- gnome-common
- autopoint
before_script: ./autogen.sh
script:
- make
- make check
before_install:
- pip install --user codecov
after_success:
- codecov

View File

@ -1,15 +1,21 @@
include $(top_srcdir)/swe-glib.mk
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = swe swe/src swe/doc src po docs/reference/swe-glib data
SUBDIRS = src po data tests
if ENABLE_GTK_DOC
SUBDIRS += docs/reference/swe-glib
endif
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
intltool_extra = intltool-extract.in intltool-merge.in intltool-update.in
EXTRA_DIST = $(intltool_extra) $(header_DATA) autogen.sh
EXTRA_DIST += $(intltool_extra) $(header_DATA) autogen.sh
DISTCLEANFILES = intltool-extract intltool-merge intltool-update
DISTCLEANFILES += intltool-extract intltool-merge intltool-update
MAINTAINERCLEANFILES = ChangeLog
MAINTAINERCLEANFILES += ChangeLog
distclean-local:
if test "$(srcdir)" = "."; then :; else \

View File

@ -1,26 +1,38 @@
# SWE-GLib
SWE-GLib is a GLib style wrapper library around Astrodienst's [Swiss Ephemeris library](http://www.astro.com/swisseph/).
[![Build Status](https://travis-ci.org/gergelypolonkai/swe-glib.svg?branch=master)](https://travis-ci.org/gergelypolonkai/swe-glib)
[![codecov.io](https://codecov.io/github/gergelypolonkai/swe-glib/coverage.svg?branch=master)](https://codecov.io/github/gergelypolonkai/swe-glib?branch=master)
The source tree contains Astrodienst's ephemeride files, as requested by Alois Treindl of Astrodienst in a mail written to me on 24 July, 2013.
SWE-GLib is a GLib style wrapper library around Astrodienst's
[Swiss Ephemeris library](http://www.astro.com/swisseph/).
The source tree contains Astrodienst's ephemeride files, as requested
by Alois Treindl of Astrodienst in a mail written to me on 24 July,
2013.
## GTK-Doc
The project utilizes [GTK-Doc](http://www.gtk.org/gtk-doc/), requiring version 1.19 or later. Although the generated documentation is a bit messy (not everything is documented, and there are some unresolved variables, like [SERVER] on the generated index page.
The project utilizes [GTK-Doc](http://www.gtk.org/gtk-doc/), requiring
version 1.19 or later. Although the generated documentation is a bit
messy (not everything is documented, and there are some unresolved
variables, like [SERVER] on the generated index page.
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
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
Then you need to create a `GsweTimestamp` object:
@ -70,11 +82,13 @@ GList *sun_aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_SUN);
GList *sun_antiscia = gswe_moment_get_planet_antiscia(moment, GSWE_PLANET_SUN);
```
The returned GList objects hold zero or more `GsweAspectData` or `GsweAntiscionData` objects, respectively.
The returned GList objects hold zero or more `GsweAspectData` or
`GsweAntiscionData` objects, respectively.
### Getting the Moon phase
Last, but not least, SWE-GLib can calculate Moon's phase at the given moment. For that, you have to call `gswe_moment_get_moon_phase()`:
Last, but not least, SWE-GLib can calculate Moon's phase at the given
moment. For that, you have to call `gswe_moment_get_moon_phase()`:
```c
GsweMoonPhaseData *moon_phase = gswe_moment_get_moon_phase(moment);
@ -82,30 +96,60 @@ GsweMoonPhaseData *moon_phase = gswe_moment_get_moon_phase(moment);
### About altitude
The Swiss Ephemeris library requires the altitude value to be specified for several calculations. It also notifies how important it is:
The Swiss Ephemeris library requires the altitude value to be
specified for several calculations. It also notifies how important it
is:
> the altitude above sea must be in meters. Neglecting the altitude can result in an error of about 2 arc seconds with the moon and at an altitude 3000m.
> the altitude above sea must be in meters. Neglecting the altitude
> can result in an error of about 2 arc seconds with the moon and at
> an altitude 3000m.
2 arc seconds is about 0.000555 degrees of error, which is, well, kind of small. Of course, if you need very precise horoscopes or need planetary positions for a totally different thing, you should really provide a (close to) exact value; otherwise, it is safe to pass any value (well, which seems logical: the average level of all dry lands is about 840 meters; the average level of the whole planet Earth (including oceans and seas) is around 280 meters. Providing a value of ~400 should be OK most of the time).
2 arc seconds is about 0.000555 degrees of error, which is, well, kind
of small. Of course, if you need very precise horoscopes or need
planetary positions for a totally different thing, you should really
provide a (close to) exact value; otherwise, it is safe to pass any
value (well, which seems logical: the average level of all dry lands
is about 840 meters; the average level of the whole planet Earth
(including oceans and seas) is around 280 meters. Providing a value of
~400 should be OK most of the time).
## 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
### Topocentric calculations only
Although the original Swiss Ephemeris library supports it, SWE-GLib can't do Heliocentric, nor Geocentric (as seen from the center of Earth) calculations, only Topocentric (as seen from a given point on Earth"s surface) calculations yet.
Although the original Swiss Ephemeris library supports it, SWE-GLib
can't do Heliocentric, nor Geocentric (as seen from the center of
Earth) calculations, only Topocentric (as seen from a given point on
Earths surface) calculations yet.
### Database size
The size of all data files provided by Astrodienst is around 40MB. Although it should not be a problem with today's home hardware, it can be a hard requirement on embedded systems. For basic calculations, keeping the following files under $(datadir)/swe-glib is usually enough:
The size of all data files provided by Astrodienst is around
40MB. Although it should not be a problem with today's home hardware,
it can be a hard requirement on embedded systems. For basic
calculations, keeping the following files under $(datadir)/swe-glib is
usually enough:
* seas_18.se1
* semo_18.se1
* sepl_18.se1
* `seas_18.se1`
* `semo_18.se1`
* `sepl_18.se1`
### Fixed stars are not known yet
Although Swiss Ephemeris has the functionality to calculate the position of fixed stars, SWE-GLib doesn't provide such functionality. This, however, is a planned feature for the close future.
Although Swiss Ephemeris has the functionality to calculate the
position of fixed stars, SWE-GLib doesn't provide such
functionality. This, however, is a planned feature for the close
future.
## Licencing
As the underlying Swiss Ephemeris is published under GPL (or a
commercial license I can not afford), SWE-GLib is also uses that. This
means that you can currently use SWE-GLib in software published under
the GNU GPL v3 (or, at your option, any later version).

View File

@ -13,10 +13,51 @@ PKG_NAME="swe-glib"
exit 1
}
which gnome-autogen.sh || {
echo "gnome-autogen.sh not found, you need to install gnome-common"
exit 1
}
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`
if [ -n "$m4dir" ]; then
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 $?
"$srcdir/configure" "$@"

View File

@ -1,17 +1,33 @@
m4_define([swe_glib_major_version], [1])
m4_define([swe_glib_minor_version], [0])
m4_define([swe_glib_micro_version], [1])
m4_define([swe_glib_major_version], [2])
m4_define([swe_glib_minor_version], [1])
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_api_version], [swe_glib_major_version.0])
m4_define([swe_major_version], [2])
m4_define([swe_minor_version], [0])
m4_define([swe_version], [swe_major_version.swe_minor_version])
AC_INIT([SWE-GLib], [swe_glib_version], [gergely@polonkai.eu], [swe-glib])
AM_INIT_AUTOMAKE([-Wall foreign])
AC_CONFIG_HEADERS([config.h])
AM_SILENT_RULES([yes])
AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug], [compile with debugging support])], , enable_debug=no)
dnl ********************************
dnl *** Enable debugging support ***
dnl ********************************
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug],
[compile with debugging support]),
[enable_debug=$enableval], [enable_debug=no])
if test "x$enable_debug" = "xyes" ; then
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
AC_SUBST([SWE_GLIB_MAJOR_VERSION], [swe_glib_major_version])
@ -20,6 +36,7 @@ AC_SUBST([SWE_GLIB_MICRO_VERSION], [swe_glib_micro_version])
AC_SUBST([SWE_GLIB_VERSION], [swe_glib_version])
AC_SUBST([SWE_GLIB_API_VERSION], [swe_glib_api_version])
AC_SUBST([SWE_GLIB_API_VERSION_U], [AS_TR_SH([swe_glib_api_version])])
AC_SUBST([SWE_VERSION], [swe_version])
AC_PROG_CC
AM_PROG_CC_C_O
@ -33,30 +50,133 @@ AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.17])
LT_INIT
AC_CHECK_LIB([m], [atan])
m4_ifdef([GTK_DOC_CHECK], [
GTK_DOC_CHECK([1.19], [--flavour no-tmpl])
],[
AM_CONDITIONAL([ENABLE_GTK_DOC], false)
])
GOBJECT_INTROSPECTION_CHECK([1.0])
m4_ifdef([VALA_PROG_VAPIGEN], [
VALA_PROG_VAPIGEN([0.21])
AM_CONDITIONAL([HAVE_VAPIGEN], true)
],[
AM_CONDITIONAL([HAVE_VAPIGEN], false)
])
PKG_PROG_PKG_CONFIG
AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
PKG_CHECK_MODULES([GLIB], [glib-2.0])
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_HOST
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])
LIBSWE_LIBS='$(top_builddir)/swe/src/libswe-1.75.la'
AC_SUBST(LIBSWE_LIBS)
dnl ************************************
dnl *** Enable lcov coverage reports ***
dnl ************************************
AC_ARG_ENABLE(coverage,
AS_HELP_STRING([--enable-coverage],
[enable coverage testing with gcov]),
[use_gcov=$enableval], [use_gcov=no])
AS_IF([ test "x$use_gcov" = "xyes"], [
dnl we need gcc:
if test "$GCC" != "yes"; then
AC_MSG_ERROR([GCC is required for --enable-coverage])
fi
dnl Check if ccache is being used
AC_CHECK_PROG(SHTOOL, shtool, shtool)
case `$SHTOOL path $CC` in
*ccache*[)] gcc_ccache=yes;;
*[)] gcc_ccache=no;;
esac
if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
AC_MSG_ERROR([ccache must be disabled when --enable-coverage option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
fi
ltp_version_list="1.6 1.7 1.8 1.9 1.10 1.14"
AC_CHECK_PROG(LTP, lcov, lcov)
AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
AS_IF([ test "$LTP" ], [
AC_CACHE_CHECK([for ltp version], sw_glib_cv_ltp_version, [
swe_glib_cv_ltp_version=invalid
ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
for ltp_check_version in $ltp_version_list; do
if test "$ltp_version" = "$ltp_check_version"; then
swe_glib_cv_ltp_version="$ltp_check_version (ok)"
fi
done
])
], [
ltp_msg="To enable code coverage reporting you must have one of the following LTP versions installed: $ltp_version_list"
AC_MSG_ERROR([$ltp_msg])
])
case $swe_glib_cv_ltp_version in
""|invalid[)]
ltp_msg="You must have one of the following versions of LTP: $ltp_version_list (found: $ltp_version)."
AC_MSG_ERROR([$ltp_msg])
LTP="exit 0;"
;;
esac
if test -z "$LTP_GENHTML"; then
AC_MSG_ERROR([Could not find genhtml from the LTP package])
fi
dnl Remove all optimization flags from CFLAGS
changequote({,})
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
changequote([,])
dnl Add the special gcc flags
CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
LDFLAGS="$LDFLAGS -lgcov"
])
if test "x$enable_debug" = "xyes" ; then
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
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.32.0])
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.32.0])
PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.26])
GLIB_GSETTINGS
AC_CONFIG_MACRO_DIR([m4])
LIBSWE_GLIB_LIBS='$(top_builddir)/src/libswe-glib-$(SWE_GLIB_API_VERSION).la'
AC_SUBST(LIBSWE_GLIB_LIBS)
AC_CONFIG_FILES([
Makefile
swe/Makefile
swe/src/Makefile
swe/doc/Makefile
src/Makefile
data/Makefile
po/Makefile.in
docs/reference/swe-glib/version.xml
docs/reference/swe-glib/Makefile
tests/Makefile
data/swe-glib.pc
data/swe-glib.spec
src/gswe-version.h
])
AM_COND_IF([ENABLE_GTK_DOC], [
AC_CONFIG_FILES([
docs/reference/swe-glib/version.xml
docs/reference/swe-glib/Makefile
])
])
AC_OUTPUT

View File

@ -1,65 +1,16 @@
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = swe-glib.pc $(NULL)
swephdir = $(pkgdatadir)
sweph_DATA = \
sweph-data/seas_00.se1 \
sweph-data/seas_06.se1 \
sweph-data/seas_12.se1 \
sweph-data/seas_18.se1 \
sweph-data/seas_24.se1 \
sweph-data/seas_30.se1 \
sweph-data/seas_36.se1 \
sweph-data/seas_42.se1 \
sweph-data/seas_48.se1 \
sweph-data/seasm06.se1 \
sweph-data/seasm12.se1 \
sweph-data/seasm18.se1 \
sweph-data/seasm24.se1 \
sweph-data/seasm30.se1 \
sweph-data/seasm36.se1 \
sweph-data/seasm42.se1 \
sweph-data/seasm48.se1 \
sweph-data/seasm54.se1 \
sweph-data/semo_00.se1 \
sweph-data/semo_06.se1 \
sweph-data/semo_12.se1 \
sweph-data/semo_18.se1 \
sweph-data/semo_24.se1 \
sweph-data/semo_30.se1 \
sweph-data/semo_36.se1 \
sweph-data/semo_42.se1 \
sweph-data/semo_48.se1 \
sweph-data/semom06.se1 \
sweph-data/semom12.se1 \
sweph-data/semom18.se1 \
sweph-data/semom24.se1 \
sweph-data/semom30.se1 \
sweph-data/semom36.se1 \
sweph-data/semom42.se1 \
sweph-data/semom48.se1 \
sweph-data/semom54.se1 \
sweph-data/sepl_00.se1 \
sweph-data/sepl_06.se1 \
sweph-data/sepl_12.se1 \
sweph-data/sepl_18.se1 \
sweph-data/sepl_24.se1 \
sweph-data/sepl_30.se1 \
sweph-data/sepl_36.se1 \
sweph-data/sepl_42.se1 \
sweph-data/sepl_48.se1 \
sweph-data/seplm06.se1 \
sweph-data/seplm12.se1 \
sweph-data/seplm18.se1 \
sweph-data/seplm24.se1 \
sweph-data/seplm30.se1 \
sweph-data/seplm36.se1 \
sweph-data/seplm42.se1 \
sweph-data/seplm48.se1 \
sweph-data/seplm54.se1 \
$(NULL)
eu.polonkai.gergely.swe-glib.gschema.xml: gschema.template $(top_builddir)/src/gswe-types.h
$(GLIB_MKENUMS) --comments "<!-- @comment@ -->" --template $(filter %.template,$^) $(filter-out %.template,$^) > \
$@.tmp && mv $@.tmp $@
gsettings_SCHEMAS = eu.polonkai.gergely.swe-glib.gschema.xml
@GSETTINGS_RULES@
EXTRA_DIST = \
$(sweph_DATA) \
swe-glib-$(SWE_GLIB_VERSION).spec
swe-glib.spec \
gschema.template
DISTCLEANFILES = $(gsettings_SCHEMAS)

22
data/gschema.template Normal file
View File

@ -0,0 +1,22 @@
/*** BEGIN file-header ***/
<schemalist>
/*** END file-header ***/
/*** BEGIN file-production ***/
/*** END file-production ***/
/*** BEGIN value-header ***/
<enum id="eu.polonkai.gergely.swe-glib.@EnumName@">
/*** END value-header ***/
/*** BEGIN value-production ***/
<value nick="@valuenick@" value="@valuenum@"/>
/*** END value-production ***/
/*** BEGIN value-tail ***/
</enum>
/*** END value-tail ***/
/*** BEGIN file-tail ***/
</schemalist>
/*** END file-tail ***/

View File

@ -1,12 +1,12 @@
Name: swe-glib
Version: 1.0.1
Version: @SWE_GLIB_VERSION@
Release: 1%{?dist}
Summary: A GLib style wrapper library around the Swiss Ephemeris library, created by Astrodienst.
Group: Development/Libraries
License: LGPLv3+
URL: http://gergely.polonkai.eu/swe-glib/
Source: https://github.com/gergelypolonkai/%{name}/archive/v%{version}.tar.gz
Source: http://gergely.polonkai.eu/download/%{name}-%{version}.tar.gz
BuildRequires: pkgconfig
BuildRequires: glib2-devel
@ -70,12 +70,13 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/locale/hu/LC_MESSAGES/swe-glib.mo
%files
%doc ChangeLog
%{_libdir}/libswe-1.75.so.*
%{_libdir}/libswe-glib-1.0.so.*
%{_libdir}/girepository-1.0/SweGlib-1.0.typelib
%{_libdir}/libswe-@SWE_VERSION@.so.*
%{_libdir}/libswe-glib-@SWE_GLIB_API_VERSION@.so.*
%{_libdir}/girepository-1.0/SweGlib-@SWE_GLIB_API_VERSION@.typelib
%files data
%{_datadir}/swe-glib/*.se1
%{_datadir}/swe-glib/seleapsec.txt
%files doc
%doc %{_datadir}/gtk-doc/html/*
@ -83,9 +84,10 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/locale/hu/LC_MESSAGES/swe-glib.mo
%files devel
%{_includedir}/*
%{_libdir}/pkgconfig/*
%{_datadir}/gir-1.0/SweGlib-1.0.gir
%{_libdir}/libswe-1.75.so
%{_libdir}/libswe-glib-1.0.so
%{_datadir}/gir-1.0/SweGlib-@SWE_GLIB_API_VERSION@.gir
%{_libdir}/libswe-@SWE_VERSION@.so
%{_libdir}/libswe-glib-@SWE_GLIB_API_VERSION@.so
%{_datadir}/vala/vapi/SweGlib-@SWE_GLIB_API_VERSION@.vapi
%changelog

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -29,7 +29,7 @@ SCANGOBJ_OPTIONS=
# Extra options to supply to gtkdoc-scan.
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
SCAN_OPTIONS=--rebuild-sections --rebuild-types
SCAN_OPTIONS=--rebuild-types --deprecated-guards="GSWE_DISABLE_DEPRECATED"
# Extra options to supply to gtkdoc-mkdb.
# 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
# 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.
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
@ -79,19 +92,19 @@ expand_content_files=
# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
GTKDOC_CFLAGS=
GTKDOC_LIBS=$(LIBSWE_GLIB_LIBS) $(NULL)
GTKDOC_LIBS=$(LIBSWE_GLIB_LIBS) -lswe -ldl $(NULL)
# This includes the standard gtk-doc make rules, copied by gtkdocize.
include $(top_srcdir)/gtk-doc.make
# Other files to distribute
# e.g. EXTRA_DIST += version.xml.in
EXTRA_DIST +=
EXTRA_DIST += version.xml.in
# Files not to distribute
# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types
# 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
# and run some sanity checks

View File

@ -19,9 +19,20 @@
<chapter>
<title>SWE-GLib</title>
<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/gswe-moment.xml"/>
<xi:include href="xml/gswe-timestamp.xml"/>
<xi:include href="xml/gswe-version.xml"/>
</chapter>
<chapter id="object-tree">

View File

@ -0,0 +1,331 @@
<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_aspect_by_planets
gswe_moment_get_all_antiscia
gswe_moment_get_all_planet_antiscia
gswe_moment_get_axis_all_antiscia
gswe_moment_get_axis_planet_antiscia
gswe_moment_get_antiscion_by_planets
<SUBSECTION Standard>
GSWE_IS_MOMENT
GSWE_IS_MOMENT_CLASS
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_find_sign_info_by_id
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_find_planet_info_by_id
gswe_all_planets
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_find_aspect_info_by_id
gswe_all_aspects
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_find_antiscion_axis_info_by_id
gswe_all_antiscion_axes
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_find_house_system_info_by_id
gswe_all_house_systems
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
GsweTimestampValidityFlags
gswe_timestamp_new
gswe_timestamp_new_from_julian_day
gswe_timestamp_new_from_gregorian_full
gswe_timestamp_new_from_now_local
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_now_local
gswe_timestamp_set_julian_day
gswe_timestamp_get_julian_day
gswe_timestamp_set_julian_day_et
gswe_timestamp_get_julian_day_et
gswe_timestamp_set_julian_day_ut
gswe_timestamp_get_julian_day_ut
gswe_timestamp_get_sidereal_time
<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
GSWE_PLANET_LILITH
GSWE_PLANET_OFFSET_VIRTUAL_NODES
GSWE_PLANET_OFFSET_PLANETS
GSWE_PLANET_OFFSET_ASTEROIDS
GSWE_PLANET_OFFSET_CUSTOM
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>
<SECTION>
<FILE>gswe-version</FILE>
GSWE_MAJOR_VERSION
GSWE_MINOR_VERSION
GSWE_MICRO_VERSION
GSWE_CHECK_VERSION
gswe_check_version
</SECTION>

52
examples/basic.js Normal file
View File

@ -0,0 +1,52 @@
const GLib = imports.gi.GLib;
const Swe = imports.gi.SweGlib;
const Format = imports.format;
String.prototype.format = Format.format;
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.03991, 47.49801, 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)
print("%s: %.6f (%d°%d%d″ %s)".format(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();
print("%s in %s with %s (±%.2f%%)".format(planet1.get_planet_info().get_name(), aspect.get_aspect_info().get_name(), 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();
print("%s is antiscion of %s on axis %s (±%.2f%%)".format(planet1.get_planet_info().get_name(), planet2.get_planet_info().get_name(), antiscion.get_antiscion_axis_info().get_name(), antiscion.get_difference().toFixed(2)));
}
}

44
examples/basic.lua Normal file
View File

@ -0,0 +1,44 @@
local lgi = require 'lgi'
local SweGlib = lgi.require('SweGlib', '2.0')
SweGlib.init()
local timestamp = SweGlib.Timestamp.new()
timestamp:set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1)
local moment = SweGlib.Moment.new()
moment:set_timestamp(timestamp)
moment:set_timestamp(timestamp)
moment:set_coordinates(19.03990999, 47.49801000, 280)
moment:set_house_system(SweGlib.HouseSystem.PLACIDUS)
moment:add_all_planets()
local all_planets = moment:get_all_planets()
for _, planet in ipairs(all_planets) do
local position = planet:get_position()
local sign_position = math.fmod(position, 30)
local degree = math.floor(sign_position)
local minute = math.floor((sign_position - degree) * 60)
local second = math.floor(((sign_position - degree) * 60 - minute) * 60)
io.write(string.format("%s: %f (%d°%d%d″ %s)\n", planet:get_planet_info():get_name(), position, degree, minute, second, planet:get_sign_info():get_name()))
end
local all_aspects = moment:get_all_aspects()
for _, aspect in ipairs(all_aspects) do
if aspect:get_aspect() ~= "NONE" then
local planet1 = aspect:get_planet1()
local planet2 = aspect:get_planet2()
io.write(string.format("%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()))
end
end
local all_antiscia = moment:get_all_antiscia()
for _, antiscion in ipairs(all_antiscia) do
if antiscion:get_axis() ~= "NONE" then
local planet1 = antiscion:get_planet1()
local planet2 = antiscion:get_planet2()
io.write(string.format("%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()))
end
end

55
examples/basic.pl Normal file
View File

@ -0,0 +1,55 @@
#!/bin/env perl
package SweGlib;
use utf8;
use strict;
use POSIX;
use Glib::Object::Introspection;
binmode STDOUT, ':encoding(UTF-8)';
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.03991, 47.49801, 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());
}
}

44
examples/basic.py Normal file
View File

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
from gi.repository import SweGlib
import math
import codecs
import sys
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
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.03991, 47.49801, 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 u"%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())

View File

@ -86,7 +86,7 @@ msgid "Dark Moon"
msgstr "Sötét Hold"
#: ../src/swe-glib.c:133
msgid "Ascendent"
msgid "Ascendant"
msgstr "Aszcendens"
#: ../src/swe-glib.c:134

View File

@ -1,52 +1,100 @@
## Process this file with automake to produce Makefile.in
include $(top_srcdir)/swe-glib.mk
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 = \
swe-glib.h \
gswe-types.h \
gswe-moment.h \
gswe-timestamp.h
swe-glib.h \
gswe-types.h \
gswe-moon-phase-data.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 = \
gswe-enumtypes.h
gswe_headers = gswe-timestamp.h gswe-types.h
libswe_glib_1_0_la_SOURCES = \
swe-glib.c \
gswe-types.c \
gswe-moment.c \
gswe-timestamp.c \
gswe-enumtypes.c \
gswe-enumtypes.h \
gswe-version.h \
$(NULL)
PRIV_H_SRC_FILES = \
swe-glib-private.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)
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 \
gswe-version.c \
$(NULL)
libswe_glib_2_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall
libswe_glib_2_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) -lswe
libswe_glib_2_0_la_DEPENDENCIES = \
$(NULL)
libswe_glib_1_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall
libswe_glib_1_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) $(LIBSWE_LIBS)
BUILT_SOURCES = gswe-enumtypes.c gswe-enumtypes.h
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,$^) > \
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,$^) > \
gswe-enumtypes.c.tmp && mv gswe-enumtypes.c.tmp gswe-enumtypes.c
SweGlib-2.0.vapi: SweGlib-$(SWE_GLIB_API_VERSION).gir
$(AM_V_GEN)$(VAPIGEN) --library=SweGlib-2.0 SweGlib-2.0.gir
if HAVE_INTROSPECTION
include $(INTROSPECTION_MAKEFILE)
SweGlib-$(SWE_GLIB_API_VERSION).gir: libswe-glib-1.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_LIBS = 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_2_0_la_SOURCES))
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_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_LDFLAGS = $(GLIB_LIBS) $(GOBJECT_LIBS) -lswe
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_EXPORT_PACKAGES = swe-glib
INTROSPECTION_GIRS = SweGlib-$(SWE_GLIB_API_VERSION).gir
@ -57,15 +105,16 @@ typelibsdir = $(libdir)/girepository-1.0
typelibs_DATA = SweGlib-$(SWE_GLIB_API_VERSION).typelib
headerdir = $(includedir)/swe-glib
header_DATA = \
swe-glib.h \
gswe-types.h \
gswe-enumtypes.h \
gswe-moment.h \
gswe-timestamp.h \
header_DATA = \
$(INST_H_SRC_FILES) \
$(INST_H_BUILT_FILES) \
$(NULL)
CLEANFILES += $(gir_DATA) $(typelibs_DATA)
if HAVE_VAPIGEN
vapidir = $(datadir)/vala/vapi
vapi_DATA = SweGlib-$(SWE_GLIB_API_VERSION).vapi
endif
endif

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

View File

@ -0,0 +1,290 @@
/* 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;
}

View File

@ -0,0 +1,88 @@
/* 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__ */

View File

@ -0,0 +1,48 @@
/* 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__ */

425
src/gswe-antiscion-data.c Normal file
View File

@ -0,0 +1,425 @@
/* 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);
}
g_free(antiscion_data);
}
/**
* 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 == NULL) {
return;
}
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;
}

78
src/gswe-antiscion-data.h Normal file
View File

@ -0,0 +1,78 @@
/* 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__ */

View File

@ -0,0 +1,51 @@
/* 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__ */

350
src/gswe-aspect-data.c Normal file
View File

@ -0,0 +1,350 @@
/* 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 == NULL) {
return;
}
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 (planet1 && 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 && planet2) {
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;
}

76
src/gswe-aspect-data.h Normal file
View File

@ -0,0 +1,76 @@
/* 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__ */

View File

@ -0,0 +1,53 @@
/* 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__ */

282
src/gswe-aspect-info.c Normal file
View File

@ -0,0 +1,282 @@
/* 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_infos 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;
}

78
src/gswe-aspect-info.h Normal file
View File

@ -0,0 +1,78 @@
/* 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__ */

View File

@ -1,28 +1,28 @@
/*** BEGIN file-header ***/
/* gswe-enumtypes.c - Enumeration types for SWE-GLib
*
* Copyright (C) 2013 Gergely Polonkai
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your opinion)
* any later version.
* 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 Lesser General Public License for more
* details.
* 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 Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* 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 "gswe-enumtypes.h"
#include "@filename@"
/*** END file-header ***/
/*** BEGIN file-production ***/
#include "@filename@"
/* enumerations from "@filename@" */
/*** END file-production ***/
@ -32,19 +32,28 @@ GType
{
static volatile gsize g_define_type_id__volatile = 0;
gswe_init();
if (g_once_init_enter(&g_define_type_id__volatile)) {
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
{
@VALUENAME@,
"@VALUENAME@",
"@valuenick@"
},
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType g_define_type_id = g_@type@_register_static(g_intern_static_string("@EnumName@"), values);
GType g_define_type_id = g_@type@_register_static(
g_intern_static_string("@EnumName@"),
values
);
g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
}

View File

@ -1,21 +1,20 @@
/*** BEGIN file-header ***/
/* gswe-enumtypes.h - Enumeration types for SWE-GLib
*
* Copyright (C) 2013 Gergely Polonkai
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your opinion)
* any later version.
* 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 Lesser General Public License for more
* details.
* 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 Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* 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 __GSWE_ENUM_TYPES_H__
#define __GSWE_ENUM_TYPES_H__

View File

@ -0,0 +1,44 @@
/* 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__ */

165
src/gswe-house-data.c Normal file
View File

@ -0,0 +1,165 @@
/* 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 == NULL) {
return;
}
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
View 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__ */

View File

@ -0,0 +1,45 @@
/* 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__ */

View File

@ -0,0 +1,189 @@
/* 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;
}

View File

@ -0,0 +1,71 @@
/* 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__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,19 @@
/* gswe-moment.h - Planetary moment object for SWE-GLib
*
* Copyright (C) 2013 Gergely Polonkai
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your opinion)
* any later version.
* 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 Lesser General Public License for more
* details.
* 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 Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* 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 __GSWE_MOMENT_H__
#define __GSWE_MOMENT_H__
@ -22,54 +21,34 @@
#include <glib-object.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_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSWE_TYPE_MOMENT, GsweMoment))
#define GSWE_IS_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSWE_TYPE_MOMENT))
#define GSWE_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GSWE_TYPE_MOMENT, GsweMomentClass))
#define GSWE_IS_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSWE_TYPE_MOMENT))
#define GSWE_MOMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSWE_TYPE_MOMENT, GsweMomentClass))
#define GSWE_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST( \
(obj), \
GSWE_TYPE_MOMENT, \
GsweMoment))
#define GSWE_IS_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE( \
(obj), \
GSWE_TYPE_MOMENT))
#define GSWE_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST( \
(klass), \
GSWE_TYPE_MOMENT, \
GsweMomentClass))
#define GSWE_IS_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE( \
(klass), \
GSWE_TYPE_MOMENT))
#define GSWE_MOMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS( \
(obj), \
GSWE_TYPE_MOMENT, \
GsweMomentClass))
typedef struct _GsweMoment GsweMoment;
typedef struct _GsweMomentClass GsweMomentClass;
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:
*
@ -124,40 +103,97 @@ GType gswe_moment_get_type(void);
/* Method definitions */
GsweMoment *gswe_moment_new(void);
GsweMoment *gswe_moment_new_full(GsweTimestamp *timestamp, gdouble longitude, gdouble latitude, gdouble altitude, GsweHouseSystem house_system);
GsweMoment *gswe_moment_new_full(
GsweTimestamp *timestamp,
gdouble longitude,
gdouble latitude,
gdouble altitude,
GsweHouseSystem house_system);
void gswe_moment_set_timestamp(GsweMoment *moment, GsweTimestamp *timestamp);
GsweTimestamp *gswe_moment_get_timestamp(GsweMoment *moment);
void gswe_moment_set_coordinates(GsweMoment *moment, gdouble longitude, gdouble latitude, gdouble altitude);
void gswe_moment_set_coordinates(
GsweMoment *moment,
gdouble longitude,
gdouble latitude,
gdouble altitude);
GsweCoordinates *gswe_moment_get_coordinates(GsweMoment *moment);
void gswe_moment_set_house_system(GsweMoment *moment, GsweHouseSystem house_system);
void gswe_moment_set_house_system(
GsweMoment *moment,
GsweHouseSystem house_system);
GsweHouseSystem gswe_moment_get_house_system(GsweMoment *moment);
GList *gswe_moment_get_house_cusps(GsweMoment *moment, GError **err);
gint gswe_moment_get_house(GsweMoment *moment, gdouble position, GError **err);
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);
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_house_planets(GsweMoment *moment, guint house);
guint gswe_moment_get_element_points(GsweMoment *moment, GsweElement element);
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_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **err);
GList *gswe_moment_get_planet_aspects(
GsweMoment *moment,
GswePlanet planet,
GError **err);
GsweAspectData *gswe_moment_get_aspect_by_planets(
GsweMoment *moment,
GswePlanet planet1,
GswePlanet planet2,
GError **err);
GList *gswe_moment_get_all_antiscia(GsweMoment *moment);
GList *gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet, GError **err);
GList *gswe_moment_get_axis_all_antiscia(GsweMoment *moment, GsweAntiscionAxis axis);
GList *gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis, GswePlanet planet, GError **err);
GList *gswe_moment_get_all_planet_antiscia(
GsweMoment *moment,
GswePlanet planet,
GError **err);
GList *gswe_moment_get_axis_all_antiscia(
GsweMoment *moment,
GsweAntiscionAxis axis);
GList *gswe_moment_get_axis_planet_antiscia(
GsweMoment *moment,
GsweAntiscionAxis axis,
GswePlanet planet,
GError **err);
GsweAntiscionData *gswe_moment_get_antiscion_by_planets(
GsweMoment *moment,
GswePlanet planet1,
GswePlanet planet2,
GError **err);
#endif /* __GSWE_MOMENT_H__ */

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

206
src/gswe-moon-phase-data.c Normal file
View File

@ -0,0 +1,206 @@
/* 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 == NULL) {
return;
}
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_et(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_et(timestamp, err);
if (err && *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;
}

View File

@ -0,0 +1,66 @@
/* 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__ */

View File

@ -0,0 +1,53 @@
/* 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__ */

306
src/gswe-planet-data.c Normal file
View File

@ -0,0 +1,306 @@
/* 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 == NULL) {
return;
}
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 == NULL) {
return GSWE_PLANET_NONE;
}
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 == NULL) {
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_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)
{
if (planet_data == NULL) {
return NULL;
}
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)
{
if (planet_data == NULL) {
return 0.0;
}
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)
{
if (planet_data == NULL) {
return FALSE;
}
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)
{
if (planet_data == NULL) {
return 0;
}
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 == NULL) {
return GSWE_SIGN_NONE;
}
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)
{
if (planet_data == NULL) {
return NULL;
}
return planet_data->sign_info;
}

74
src/gswe-planet-data.h Normal file
View File

@ -0,0 +1,74 @@
/* 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__ */

Some files were not shown because too many files have changed in this diff Show More