Reference · Your sky: altitude and azimuth for a place and a moment
isAboveHorizonfunction
Whether a position is above the horizon of a place at a moment (altitude greater than 0). With refraction: true it counts the bending of the light, so a star can be seen a little below the geometric horizon.
Import it
import { isAboveHorizon } from "@johnmorrisdotca/hoshi-stars/sky";
Definition
function isAboveHorizon(position: SkyPoint, observer: Observer, when: When, options?: HorizontalOptions): boolean
Parameters
| Name | Type | Description |
|---|---|---|
position | SkyPoint | A right ascension and declination in degrees, J2000 or (with |
observer | Observer | Latitude north and longitude east in degrees. |
when | When | The moment, a |
options (optional) | HorizontalOptions | The same as |
Returns
boolean
True when it is up.
Examples
import { starByName, starPosition } from "@johnmorrisdotca/hoshi-stars";
import { isAboveHorizon } from "@johnmorrisdotca/hoshi-stars/sky";
// Polaris never sets for anyone in the northern hemisphere
const polaris = starPosition(starByName("Polaris")!);
console.log(isAboveHorizon(polaris, { latitude: 49.28, longitude: -123.12 }, Date.now()));trueWhat it prints (run when this page was built)