Skip to content

Commit 5888ead

Browse files
authored
feat: add support to different houses system (#27)
1 parent b87b5fc commit 5888ead

File tree

5 files changed

+147
-12
lines changed

5 files changed

+147
-12
lines changed

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
### Usage
3838

39-
Example: Get the horoscope for date `1993-08-06`, time `16:50:00` and timezone `-04:00` at Santiago, Chile (latitude `-33.41167` and longitude `-70.66647`).
39+
Example: Get the horoscope for date `1993-08-06`, time `16:50:00` with timezone `-04:00` at Santiago, Chile (latitude `-33.41167` and longitude `-70.66647`) using Placidus houses system.
4040

4141
Fist, you need to transform the date & time to ISO8601, for this example `1993-08-06T16:50:00-04:00`.
4242

@@ -49,18 +49,52 @@ If you don't want to escape the date and time, you can always send it to UTC
4949
5050
In UTC: `1993-08-06T20:50:00Z`
5151
52+
Then, you need to select the house system from the houses system table.. in this case for the placidus system you need to send the `P` value in the `houseSystem` query param.
53+
5254
Now you can send this...
5355
5456
##### Using cURL
5557
5658
```bash
5759
# escaped
5860
curl --request GET \
59-
--url 'http://localhost:3000/horoscope?time=1993-08-06T16%3A50%3A00-04%3A00&latitude=-33.41167&longitude=-70.66647'
61+
--url 'http://localhost:3000/horoscope?time=1993-08-06T16%3A50%3A00-04%3A00&latitude=-33.41167&longitude=-70.66647&houseSystem=P'
6062
```
6163
6264
```bash
6365
# in utc
6466
curl --request GET \
65-
--url 'http://localhost:3000/horoscope?time=1993-08-06T20:50:00Z&latitude=-33.41167&longitude=-70.66647'
67+
--url 'http://localhost:3000/horoscope?time=1993-08-06T20:50:00Z&latitude=-33.41167&longitude=-70.66647&houseSystem=P'
6668
```
69+
70+
71+
### House system table
72+
73+
The values from each house system is extracted from sweph source code
74+
75+
| Code value | House system |
76+
|--- | ---
77+
| A | equal |
78+
| B | Alcabitius |
79+
| C | Campanus |
80+
| D | equal (MC) |
81+
| E | equal |
82+
| F | Carter poli-equ. |
83+
| G | Gauquelin sectors |
84+
| H | horizon/azimut |
85+
| I | Sunshine |
86+
| i | Sunshine/alt. |
87+
| K | Koch |
88+
| L | Pullen SD |
89+
| M | Morinus |
90+
| N | equal/1=Aries |
91+
| O | Porphyry |
92+
| Q | Pullen SR |
93+
| R | Regiomontanus |
94+
| S | Sripati |
95+
| T | Polich/Page |
96+
| U | Krusinski-Pisa-Goelzer |
97+
| V | equal/Vehlow |
98+
| W | equal/ whole sign |
99+
| X | axial rotation system/Meridian houses |
100+
| Y | APC houses |

src/api/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ router.get('/', async (req, res) => res.status(200).json({ message: 'Welcome to
77

88
router.get('/horoscope', async (req, res) => {
99
const date = new Date(req.query.time)
10-
const { latitude, longitude } = req.query
10+
const { latitude, longitude, houseSystem } = req.query
1111

12-
const chart = astrologer.natalChart(date, latitude, longitude)
12+
const chart = astrologer.natalChart(date, latitude, longitude, houseSystem)
1313

1414
res.status(200).json({
1515
data: chart

src/astrologer/charts.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ const { houses } = require('./houses')
22
const { aspects } = require('./aspects')
33
const { planets } = require('./astros')
44

5-
const natalChart = (date, latitude, longitude) => {
5+
const natalChart = (date, latitude, longitude, houseSystem = 'P') => {
66
const astrosList = planets(date)
77
const aspectsList = aspects(astrosList)
8-
const housesList = houses(date, {
9-
latitude: parseFloat(latitude),
10-
longitude: parseFloat(longitude)
11-
})
8+
const housesList = houses(
9+
date,
10+
{
11+
latitude: parseFloat(latitude),
12+
longitude: parseFloat(longitude)
13+
},
14+
houseSystem
15+
)
1216

1317
return {
1418
astros: {

src/astrologer/houses.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sweph.set_ephe_path(path.join(__dirname, '/../../eph'))
55

66
const { utcToJulianUt, degreesToDms, zodiacSign } = require('./utils')
77

8-
const houses = (date, position) => {
8+
const houses = (date, position, houseSystem = 'P') => {
99
const julianDayUT = utcToJulianUt(date)
1010

1111
const withoutGeoposition = !(position?.latitude && position?.longitude)
@@ -26,7 +26,7 @@ const houses = (date, position) => {
2626
julianDayUT,
2727
position.latitude,
2828
position.longitude,
29-
'P' // placidus system...
29+
houseSystem // placidus system...
3030
).data
3131

3232
const houseCollection = housesPositions.map((cuspid) => ({ position: degreesToDms(cuspid), sign: zodiacSign(cuspid) }))
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
const request = require('supertest')
2+
const app = require('./../../app')
3+
4+
describe('Get Koch houses system cuspids for 1991-07-06T16:50:00-04:00', () => {
5+
let response
6+
7+
beforeEach(async () => {
8+
response = await request(app)
9+
.get('/horoscope')
10+
.query({
11+
time: '1991-07-06T16:50:00-04:00',
12+
latitude: '-33.41167',
13+
longitude: '-70.66647',
14+
houseSystem: 'K' // Koch system...
15+
})
16+
.send()
17+
})
18+
19+
const expectCuspids = (
20+
cuspid,
21+
expectedSign,
22+
expectedDegrees,
23+
expectedMinutes,
24+
expectedSeconds
25+
) => {
26+
expect(cuspid.position.degrees).toBe(expectedDegrees)
27+
expect(cuspid.position.minutes).toBe(expectedMinutes)
28+
expect(cuspid.position.seconds).toBe(expectedSeconds)
29+
expect(cuspid.position.longitude).not.toBeNull()
30+
expect(cuspid.position.longitude).not.toBeUndefined()
31+
expect(cuspid.sign).toBe(expectedSign)
32+
}
33+
34+
it('/horoscope return the ASC axis (cuspid of the house I)', () => {
35+
expectCuspids(response.body.data.axes.asc, 10, 2, 32, 26)
36+
})
37+
38+
it('/horoscope return the DC axis (cuspid of the house VII)', () => {
39+
expectCuspids(response.body.data.axes.dc, 4, 2, 32, 26)
40+
})
41+
42+
it('/horoscope return the MC axis (cuspid of the house X)', () => {
43+
expectCuspids(response.body.data.axes.mc, 6, 14, 58, 42)
44+
})
45+
46+
it('/horoscope return the IC axis (cuspid of the house IV)', () => {
47+
expectCuspids(response.body.data.axes.ic, 12, 14, 58, 42)
48+
})
49+
50+
it('/horoscope response has cuspid of house I', () => {
51+
expectCuspids(response.body.data.houses[0], 10, 2, 32, 26)
52+
})
53+
54+
it('/horoscope response has cuspid of house II', () => {
55+
expectCuspids(response.body.data.houses[1], 10, 27, 14, 48)
56+
})
57+
58+
it('/horoscope response has cuspid of house III', () => {
59+
expectCuspids(response.body.data.houses[2], 11, 20, 59, 20)
60+
})
61+
62+
it('/horoscope response has cuspid of house IV', () => {
63+
expectCuspids(response.body.data.houses[3], 12, 14, 58, 42)
64+
})
65+
66+
it('/horoscope response has cuspid of house V', () => {
67+
expectCuspids(response.body.data.houses[4], 1, 27, 58, 29)
68+
})
69+
70+
it('/horoscope response has cuspid of house VI', () => {
71+
expectCuspids(response.body.data.houses[5], 3, 4, 6, 36)
72+
})
73+
74+
it('/horoscope response has cuspid of house VII', () => {
75+
expectCuspids(response.body.data.houses[6], 4, 2, 32, 26)
76+
})
77+
78+
it('/horoscope response has cuspid of house VIII', () => {
79+
expectCuspids(response.body.data.houses[7], 4, 27, 14, 48)
80+
})
81+
82+
it('/horoscope response has cuspid of house IX', () => {
83+
expectCuspids(response.body.data.houses[8], 5, 20, 59, 20)
84+
})
85+
86+
it('/horoscope response has cuspid of house X', () => {
87+
expectCuspids(response.body.data.houses[9], 6, 14, 58, 42)
88+
})
89+
90+
it('/horoscope response has cuspid of house XI', () => {
91+
expectCuspids(response.body.data.houses[10], 7, 27, 58, 29)
92+
})
93+
94+
it('/horoscope response has cuspid of house XII', () => {
95+
expectCuspids(response.body.data.houses[11], 9, 4, 6, 36)
96+
})
97+
})

0 commit comments

Comments
 (0)