Skip to content

Commit

Permalink
Merge ea48e74 into 064b3cb
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuphi committed Aug 20, 2021
2 parents 064b3cb + ea48e74 commit d72ef79
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/astrologer/astros.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const swisseph = require("swisseph");

swisseph.swe_set_ephe_path(`${__dirname}/../../eph`);

const { utcToJulianEt, utcToJulianUt, zodiacSign, degreesToDms } = require("./utils");
const { utcToJulianEt, zodiacSign, degreesToDms } = require("./utils");

const PLANETS = {
sun: swisseph.SE_SUN,
Expand Down Expand Up @@ -46,21 +46,27 @@ const FLAG = swisseph.SEFLG_SPEED | swisseph.SEFLG_SWIEPH;

const getPositionOfAstro = (astro, julianDay) => swisseph.swe_calc(julianDay, PLANETS[astro], FLAG);

const isRetrograde = (speed) => speed < 0;

const position = (astrologyObject, moment) => {
const julianDay = utcToJulianEt(moment);
const astro = getPositionOfAstro(astrologyObject, julianDay);
const dms = degreesToDms(astro.longitude);
const { longitude, longitudeSpeed: speed } = getPositionOfAstro(astrologyObject, julianDay);
const dms = degreesToDms(longitude);
const retrograde = isRetrograde(speed);

return {
position: {
longitude: astro.longitude,
longitude,
...dms,
},
sign: zodiacSign(astro.longitude),
speed,
retrograde,
sign: zodiacSign(longitude),
};
};

const planets = (date) => {
const astros = Object.keys(PLANETS)
return Object.keys(PLANETS)
.reduce(
(accumulator, name) => {
const planetPosition = position(name, date);
Expand All @@ -73,7 +79,6 @@ const planets = (date) => {
},
{}
);
return astros;
};

module.exports = {
Expand Down

0 comments on commit d72ef79

Please sign in to comment.