UNPKG

solar-calc

Version:

A sunrise/sunset/moonrise/moonset calculator

132 lines (122 loc) 3.48 kB
"use strict"; var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; var Sun = require("./sun.js"); var Moon = require("./moon.js"); var degreesBelowHorizon = { sunrise: 0.833, sunriseEnd: 0.3, twilight: 6, nauticalTwilight: 12, night: 18, goldenHour: -6 }; var SolarCalc = (function () { function SolarCalc(date, latitude, longitude) { _classCallCheck(this, SolarCalc); this.date = date; this.lat = latitude; this.longitude = longitude; this.sun = new Sun(date, latitude, longitude); this.moon = new Moon(date, latitude, longitude); } _createClass(SolarCalc, { solarNoon: { get: function () { return this.sun.solarNoon; } }, sunrise: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.sunrise, true); } }, sunset: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.sunrise); } }, sunriseEnd: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.sunriseEnd, true); } }, sunsetStart: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.sunriseEnd, false); } }, civilDawn: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.twilight, true); } }, dawn: { get: function () { return this.civilDawn; } }, civilDusk: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.twilight, false); } }, dusk: { get: function () { return this.civilDusk; } }, nauticalDawn: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.nauticalTwilight, true); } }, nauticalDusk: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.nauticalTwilight, false); } }, nightStart: { get: function () { return this.astronomicalDusk; } }, astronomicalDusk: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.night, false); } }, astronomicalDawn: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.night, true); } }, nightEnd: { get: function () { return this.astronomicalDawn; } }, goldenHourStart: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.goldenHour, false); } }, goldenHourEnd: { get: function () { return this.sun.timeAtAngle(degreesBelowHorizon.goldenHour, true); } }, lunarDistance: { get: function () { return this.moon.distance; } }, lunarIlluminosity: { get: function () { return this.moon.illuminosity; } } }); return SolarCalc; })(); module.exports = SolarCalc;