forked from jscuba/jyotish-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
101 lines (80 loc) · 2.54 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
require __DIR__.'/vendor/autoload.php';
use Jyotish\Base\Data;
use Jyotish\Base\Locality;
use Jyotish\Base\Analysis;
use Jyotish\Ganita\Method\Swetest;
use Jyotish\Dasha\Dasha;
use Jyotish\Panchanga\AngaDefiner;
use Jyotish\Graha\Lagna;
use Jyotish\Yoga\Yoga;
use Jyotish\Bala\AshtakaVarga;
use Jyotish\Bala\GrahaBala;
use Jyotish\Bala\RashiBala;
lambda(function ($event) {
if (isset($event['path']) && $event['path'] == '/ping') {
return strtotime('now');
}
$charttype = null;
if (isset($event['charttype'])) {
$charttype = $event['charttype'];
}
$longitude = null;
if (isset($event['longitude'])) {
$longitude = $event['longitude'];
}
$latitude = null;
if (isset($event['latitude'])) {
$latitude = $event['latitude'];
}
$altitude = null;
if (isset($event['altitude'])) {
$altitude = $event['altitude'];
}
$datetime = null;
if (isset($event['datetime'])) {
$datetime = $event['datetime'];
}
if (
!isset($charttype) ||
!isset($longitude) ||
!isset($latitude) ||
!isset($altitude) ||
!isset($datetime)
) {
return '';
}
$locality = new Locality([
'longitude' => $longitude,
'latitude' => $latitude,
'altitude' => $altitude
]);
$now = new DateTime($datetime);
$ganita = new Swetest(["swetest" => __DIR__.'/bin/']);
$data = new Data($now, $locality, $ganita);
$data->calcYoga([Yoga::TYPE_MAHAPURUSHA, Yoga::TYPE_DHANA, Yoga::TYPE_RAJA, Yoga::TYPE_NABHASHA, Yoga::TYPE_PARIVARTHANA, Yoga::TYPE_SANNYASA]);
$data->calcVargaData([$charttype]);
$analysis = new Analysis($data);
$vargaData = $analysis->getVargaData($charttype);
$ashtakaVarga = new AshtakaVarga($data);
$vargaData['ashtakavarga'] = $ashtakaVarga->getBhinnAshtakavarga();
$grahaBala = new GrahaBala($data);
$vargaData['grahabala'] = $grahaBala->getBala();
$rashiBala = new RashiBala($data);
$vargaData['rashibala'] = $rashiBala->getBala();
$angaDefiner = new AngaDefiner($data);
$nakshatra = null;
foreach ($vargaData['graha'] as $grahaKey => $value) {
$nakshatra = $angaDefiner->getNakshatra(false, false, $grahaKey);
$vargaData['graha'][$grahaKey]['nakshatra'] = $nakshatra['key'];
}
$nakshatra = $angaDefiner->getNakshatra(false, false, Lagna::KEY_LG);
$vargaData['lagna'][Lagna::KEY_LG]['nakshatra'] = $nakshatra['key'];
// dasha
$data = new Data($now, $locality, $ganita);
$data->calcDasha(Dasha::TYPE_VIMSHOTTARI, null);
$dasha = $data->getData();
$vargaData['panchanga'] = $dasha['panchanga'];
$vargaData['dasha'] = $dasha['dasha']['vimshottari'];
return json_encode($vargaData);
});