sun-position
v0.1.0
Published
Calculate the position of the sun for a specific date, time and location. Calculate sunrise and sunset
Downloads
51
Maintainers
Readme
Status: Development ⚠️
Calculate the position of the sun for a specific date, time and location. Calculate sunrise and sunset
Sun Position is a library under the ISC license. It aims to calculate and obtain the position of the sun for a location defined by geographic coordinates and a specific time.
The results of the lib returns can be checked at the following site.
Developed by @fwerley 👨🏽💻
Installation and use
npm i sun-position
import { SunPosition } from 'sun-postion';
const coords = {
lat: -4.56454,
lng: -38.9172
}
// June 22, 2023, at 5 pm, 52 minutes and 3 seconds
const date = new Date(2023, 5, 22, 17, 52, 3);
// Initialize object
const sunPosition = new SunPosition(
// Latitude
coords.lat,
// Longitude
coords.lng,
// Date-time
date
);
// Update coordinates
// sunPosition.setLatitude(coords.lat);
// sunPosition.setLongitude(coords.lng);
// Update Date-time
// sunPosition.setDateTime(date);
// Capturing feedback from the Sun's elevation angle and azimuth
let elevation = await sunPosition.getElevation();
let azimuth = await sunPosition.getAzimuth();
References
Input Functions
Return functions
Change history
- Paradigm shift to support object-oriented programming.
0.1.0 - May 27, 2024
- Addition of the equation of time for hourly correction
0.0.6 - December 28, 2023
- Sunrise and sunset correction
0.0.5 - December 24, 2023
- Public version on npm