@hatijs/helper
Version:
Node.js library, which has increased usability in @hatijs/core library.
90 lines (89 loc) • 3.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.house = void 0;
var _1 = require(".");
var house = function (tjdUT, geoLon, geoLat) {
/**
* Gets the 'house' information according to planet 'name'.
* @param name Name of planet you want to know house of
* @param hsys House system name
* @returns 'absolute' - absolute coordinates, 'ruleOfMoiety' - coordinates with planet Moiety applied
*/
var getPlanet = function (name, hsys) {
var posHouse = _1.util.getHouses(tjdUT, geoLon, geoLat, hsys);
var posPlanet = (0, _1.position)(tjdUT, geoLon, geoLat).getPlanet(name);
var calculate = function (houses, planet) {
var A = houses.map(function (longitude) { return longitude >= planet.longitude + planet.moiety; });
var B = houses.map(function (longitude) { return longitude < planet.longitude + planet.moiety; });
if ((A.filter(function (v) { return v; }).length === 0 &&
B.filter(function (v) { return v; }).length === 12) ||
(A.filter(function (v) { return v; }).length === 12 &&
B.filter(function (v) { return v; }).length === 0)) {
return (houses
.map(function (longitude, i) { return ({ i: i, longitude: longitude }); })
.sort(function (a, b) { return (a.longitude > b.longitude ? -1 : 1); })[0]
.i + 1);
}
for (var i = 0; i < A.length; i++) {
if (!A[i % 12] &&
A[(i + 1) % 12] &&
B[i % 12] &&
!B[(i + 1) % 12])
return i + 1;
}
};
return {
absolute: calculate(posHouse.house, {
longitude: posPlanet.position.longitude.absolute,
moiety: 0,
}),
ruleOfMoiety: calculate(posHouse.house, {
longitude: posPlanet.position.longitude.absolute,
moiety: name in _1.constant.MOIETY
? _1.constant.MOIETY[name]
: 0,
}),
};
};
/**
* Gets the 'house' information according to lot 'name'.
* @param name Name of lot you want to know house of
* @param hsys House system name
* @returns 'absolute' - absolute coordinates
*/
var getLot = function (name, hsys) {
var posHouse = _1.util.getHouses(tjdUT, geoLon, geoLat, hsys);
var posLot = (0, _1.position)(tjdUT, geoLon, geoLat).getLot(name);
var calculate = function (houses, planet) {
var A = houses.map(function (longitude) { return longitude >= planet.longitude + planet.moiety; });
var B = houses.map(function (longitude) { return longitude < planet.longitude + planet.moiety; });
if ((A.filter(function (v) { return v; }).length === 0 &&
B.filter(function (v) { return v; }).length === 12) ||
(A.filter(function (v) { return v; }).length === 12 &&
B.filter(function (v) { return v; }).length === 0)) {
return (houses
.map(function (longitude, i) { return ({ i: i, longitude: longitude }); })
.sort(function (a, b) { return (a.longitude > b.longitude ? -1 : 1); })[0]
.i + 1);
}
for (var i = 0; i < A.length; i++) {
if (!A[i % 12] &&
A[(i + 1) % 12] &&
B[i % 12] &&
!B[(i + 1) % 12])
return i + 1;
}
};
return {
absolute: calculate(posHouse.house, {
longitude: posLot.position.longitude.absolute,
moiety: 0,
}),
};
};
return {
getPlanet: getPlanet,
getLot: getLot,
};
};
exports.house = house;