Yearly forecast: solar return, transits, progressions, profection, eclipses
CI / test (push) Successful in 56s
CI / build (push) Successful in 4m41s
CI / deploy (push) Skipped

- astro-engine: forecast module (solar return moment, slow-planet transits
  with exact dates and periods, natal house ingresses, secondary
  progressions, annual profection, eclipses via Swiss Ephemeris)
- horoscope-api: POST /v1/forecast, solar return chart cast for the place
  of the birthday
- backend: forecasts table, /v1/charts/{id}/forecasts, /v1/forecasts/{id}
  and its analyses using a new 'forecast' unit; current year of life open,
  the next one 30 days before the birthday
- packages: Páros and Család include forecasts (6 000 / 11 000 Ft),
  +1 éves előrejelzés add-on 2 500 Ft; Egy elemzés unchanged
- worker and prompt: forecast kind with five sections and forecast rules
  (trends, no event predictions); no birth data, place or exact age sent
- frontend: /kepletek/{id}/elorejelzes with the solar return wheel, the
  keys of the year, a monthly timeline, transit list and detailed forecast
- data export: forecasts added, model name removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-18 08:19:13 +00:00
co-authored by Claude Opus 5.5
parent 829c33e52f
commit f1bd34c394
42 changed files with 4764 additions and 85 deletions
+61 -1
View File
@@ -14,7 +14,8 @@ use swisseph_sys as sys;
use crate::angle::normalize;
use crate::engine::{
BodyState, EngineError, Ephemeris, EphemerisInfo, Frame, GeoPosition, HouseResult, Obliquity, Result,
BodyState, EclipseEvent, EclipseKind, EclipseType, EngineError, Ephemeris, EphemerisInfo, Frame, GeoPosition,
HouseResult, Obliquity, Result,
};
use crate::types::{Ayanamsa, Body, HouseSystem};
@@ -324,6 +325,65 @@ impl Ephemeris for SwissEphemeris {
}
Ok(daya)
}
fn eclipses(&self, from_jd: f64, to_jd: f64) -> Result<Vec<EclipseEvent>> {
let _guard = lock();
let mut out = Vec::new();
for kind in [EclipseKind::Solar, EclipseKind::Lunar] {
let mut start = from_jd;
loop {
let mut tret = [0.0f64; 10];
let mut serr = [0 as c_char; sys::AS_MAXCH];
// SAFETY: tret has the 10 elements and serr the AS_MAXCH bytes the API requires.
let ret = unsafe {
match kind {
EclipseKind::Solar => sys::swe_sol_eclipse_when_glob(
start,
sys::SEFLG_SWIEPH,
0,
tret.as_mut_ptr(),
0,
serr.as_mut_ptr(),
),
EclipseKind::Lunar => sys::swe_lun_eclipse_when(
start,
sys::SEFLG_SWIEPH,
sys::SE_ECL_TOTAL | sys::SE_ECL_PARTIAL,
tret.as_mut_ptr(),
0,
serr.as_mut_ptr(),
),
}
};
if ret == sys::ERR {
return Err(EngineError::Calculation(c_string(&serr)));
}
let jd = tret[0];
if jd > to_jd {
break;
}
out.push(EclipseEvent { kind, eclipse_type: eclipse_type(ret), jd_ut: jd });
// Eclipses of one kind are at least two weeks apart.
start = jd + 10.0;
}
}
out.sort_by(|a, b| a.jd_ut.total_cmp(&b.jd_ut));
Ok(out)
}
}
fn eclipse_type(flags: i32) -> EclipseType {
if flags & sys::SE_ECL_ANNULAR_TOTAL != 0 {
EclipseType::Hybrid
} else if flags & sys::SE_ECL_TOTAL != 0 {
EclipseType::Total
} else if flags & sys::SE_ECL_ANNULAR != 0 {
EclipseType::Annular
} else if flags & sys::SE_ECL_PARTIAL != 0 {
EclipseType::Partial
} else {
EclipseType::Penumbral
}
}
#[cfg(test)]