Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more user friendly API additions for obscure functions #52

Open
aloistr opened this issue Jul 29, 2021 · 1 comment
Open

more user friendly API additions for obscure functions #52

aloistr opened this issue Jul 29, 2021 · 1 comment

Comments

@aloistr
Copy link
Collaborator

aloistr commented Jul 29, 2021

Work on php-sweph inspired me to look deeper into the existing SwissEph perl module.
I have taken over the concept of compiling SE library directly into the perl module, instead of relying on the installed
libswe.so (or DLL). This has pro- and contras.

Something else cam to my attention:
functions like
swe_lun_occult_when_loc($tjd_ut, $ipl, $star, $iflag, $ifltype, $backw, $geopos);
have more eplicit return hashes in perl.
Instead of arrays with numbered indices like in C, the perl function in addition to the arrays tret and attr also
named hash fields with the data unpacked in a meaningful way:
-> ecl_maximum time of maximum occultation (UT)
-> t1st_contact
-> t2nd_contact
-> t3rd_contact
-> t4th_contact
-> disc_ratio size ratio of the two discs
-> fraction_diameter percentage of diameter occulted
-> fraction_disc percentage of disc occulted
-> core_shadow_km diameter of core shadow (km, negative
with total, positive with annular ecl.)
-> body_azimuth
-> body_alt_true
-> separation_angle

This might also be done for php-sweph.
It will not break the existing API, because extra named array fields will not hurt.
The same field names as in Perl should be used.

@kevindecapite
Copy link
Collaborator

We could go even further and return an object for cases like this. With typehinting, this would make for a very robust extension that is easy to use.

Refs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants