[Kstars-devel] new API for calculation of raise/set time

Alexey Khudyakov alexey.skladnoy at gmail.com
Sat Jul 3 20:48:50 CEST 2010


In the comments to the bug "Moon rise and set information wrong"[1] I and
Prakash came to conclusion that currect API for finding rise/set time is
unsatisfactory. Main problem is that function SkyObject::riseSetTime returns
time of rise/set but not the date.

I think it's good opportunity to revise and generalize API. Here is my proposal.
First of all I think that boolean parameter to disnguish between rise and set
time is bad it impede code readability so I splitted function in two:

Function prototypes:
> KSDateTime SkyObject::riseTime(const KSDateTime& t, Direction d, dms alt = 0);
> KSDateTime SkyObject::setTime(const  KSDateTime& t, Direction d, dms alt = 0);

t - time for which rise or set time should be calculated.

d - Since it not obvious which rise should be picked lets force caller to choose
    explicitly which rise he want. One which precede time `t' or new one.
    Direction is simple enumeration. I can't think of better names.
> enum Direction { Next , Prev };

alt - altitude for which rise of set time are calculted. This required for
      calculation of twillight times.

Since algorithms for Solar System objects is different (they are moving)
functions should be made virtual and reimplemented in KSPlanetBase.

Open problem: how to handle object never rise situation.
So far can't come with satisfactory solution

Comments are welcome.


[1] https://bugs.kde.org/show_bug.cgi?id=211772


More information about the Kstars-devel mailing list