UNPKG

astronomy-bundle

Version:

Bundle for astronomical calculations such as position of moon, sun and planets, sunrise, sunset or solar eclipses. Most of the calculations are based on Jean Meeus 'Astronomical Algorithms' book and the VSOP87 theory.

40 lines (39 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const angleCalc_1 = require("../utils/angleCalc"); const distanceCalc_1 = require("../utils/distanceCalc"); class Location { constructor(lat, lon, elevation = 0) { this.lat = lat; this.lon = lon; this.elevation = elevation; this.prefixesNorthSouth = { positivePrefix: 'N ', negativePrefix: 'S ' }; this.prefixesEastWest = { positivePrefix: 'E ', negativePrefix: 'W ' }; this.location = { lat, lon, elevation }; } getLatitude() { return this.location.lat; } getLongitude() { return this.location.lon; } getLatitudeInDegreeMinutes() { return (0, angleCalc_1.decimal2degreeMinutes)(this.location.lat, false, this.prefixesNorthSouth); } getLongitudeInDegreeMinutes() { return (0, angleCalc_1.decimal2degreeMinutes)(this.location.lon, false, this.prefixesEastWest); } getLatitudeInDegreeMinutesSeconds() { return (0, angleCalc_1.decimal2degreeMinutesSeconds)(this.location.lat, false, this.prefixesNorthSouth); } getLongitudeInDegreeMinutesSeconds() { return (0, angleCalc_1.decimal2degreeMinutesSeconds)(this.location.lon, false, this.prefixesEastWest); } getElevation() { return this.location.elevation; } getDistanceToInKm(location) { return (0, distanceCalc_1.getDistanceInKm)(this.location, location); } } exports.default = Location;