suncalc
suncalc copied to clipboard
Add getRiseAndSetAtSolarAngle method
I have a use case where I need to get the time on which the sun will be at multiple angles. Since these altitudes are unknown I can't really name them. Therefore I've added the getRiseAndSetAtSolarAngle method.
The method can be seen as a shortcut to addTime followed by getTimes that does not pollute the times array. It saves a method call and does not calculate any other times when it doesn't need to.
@mourner, are you accepting PRs at the moment?
Sorry for not reviewing this in time — I got swamped by other commitments and have fallen behind on this project. :( Closing as the PR is superseded by #137, which is more accurate and complete.
@mourner, that issue seems to address a different issue. #137 changes the height of the observer. This PR allows passing of the angle of the sun you want to know the sun rise and sun set time of. Am I incorrect and does #137 provide a way to do this?
Ah apologies, I misread the description — reopening.
The name might be confusing indeed. What do you think about getTimesAtAngle?
@mourner, I've made some additions:
- Rename the method to be more intuiitive
- Add elevation parameter as was added to
getTimes - Accounted for atmospheric refraction
It's not 100% correct. I tried using the
astroRefractionfunction but that seems to be off by a a few seconds. I'll add a commit to showcase this
This saved me some time, thank you for sharing your solution @MatthiasKunnen !
published a new version which include this as https://github.com/Hypnos3/suncalc3